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

Function validateSession

packages/opencode/src/cli/tui/validate-session.ts:7–29  ·  view source on GitHub ↗
(input: {
  url: string
  sessionID?: string
  directory?: string
  fetch?: typeof fetch
  headers?: RequestInit["headers"]
})

Source from the content-addressed store, hash-verified

5const decodeSessionID = Schema.decodeUnknownSync(SessionID)
6
7export async function validateSession(input: {
8 url: string
9 sessionID?: string
10 directory?: string
11 fetch?: typeof fetch
12 headers?: RequestInit["headers"]
13}) {
14 if (!input.sessionID) return
15
16 let sessionID: SessionID
17 try {
18 sessionID = decodeSessionID(input.sessionID)
19 } catch (error) {
20 throw new Error(`Invalid session ID: ${error instanceof Error ? error.message : "unknown error"}`, { cause: error })
21 }
22
23 await createOpencodeClient({
24 baseUrl: input.url,
25 directory: input.directory,
26 fetch: input.fetch,
27 headers: input.headers,
28 }).session.get({ sessionID }, { throwOnError: true })
29}

Callers 3

tui.tsFile · 0.90
attach.tsFile · 0.90

Calls 2

createOpencodeClientFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected