MCPcopy Index your code
hub / github.com/anomalyco/opencode / createFreshSession

Function createFreshSession

packages/opencode/src/cli/cmd/run.ts:550–576  ·  view source on GitHub ↗
(
        sdk: OpencodeClient,
        input: { agent: string | undefined; model: ModelInput | undefined; variant: string | undefined },
      )

Source from the content-addressed store, hash-verified

548 }
549
550 async function createFreshSession(
551 sdk: OpencodeClient,
552 input: { agent: string | undefined; model: ModelInput | undefined; variant: string | undefined },
553 ): Promise<SessionInfo> {
554 const result = await sdk.session.create({
555 title: args.title !== undefined && args.title !== "" ? args.title : undefined,
556 agent: input.agent,
557 model: input.model
558 ? {
559 providerID: input.model.providerID,
560 id: input.model.modelID,
561 variant: input.variant,
562 }
563 : undefined,
564 permission: [...rules],
565 })
566 const id = result.data?.id
567 if (!id) {
568 throw new Error("Failed to create session")
569 }
570
571 void share(sdk, id).catch(() => {})
572 return {
573 id,
574 title: result.data?.title,
575 }
576 }
577
578 async function current(sdk: OpencodeClient): Promise<string> {
579 if (!args.attach) {

Callers

nothing calls this directly

Calls 2

shareFunction · 0.70
createMethod · 0.65

Tested by

no test coverage detected