From f6e7aefa728585832b6ac737c0fb2bc97461dc16 Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" Date: Thu, 12 Feb 2026 04:55:00 +0000 Subject: chore: generate --- packages/web/src/content/docs/sdk.mdx | 90 +++++++++++++++++------------------ 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'packages/web') diff --git a/packages/web/src/content/docs/sdk.mdx b/packages/web/src/content/docs/sdk.mdx index 56b4a093d..4462d3440 100644 --- a/packages/web/src/content/docs/sdk.mdx +++ b/packages/web/src/content/docs/sdk.mdx @@ -127,24 +127,24 @@ You can request structured JSON output from the model by specifying an `outputFo const result = await client.session.prompt({ path: { id: sessionId }, body: { - parts: [{ type: 'text', text: 'Research Anthropic and provide company info' }], + parts: [{ type: "text", text: "Research Anthropic and provide company info" }], outputFormat: { - type: 'json_schema', + type: "json_schema", schema: { - type: 'object', + type: "object", properties: { - company: { type: 'string', description: 'Company name' }, - founded: { type: 'number', description: 'Year founded' }, + company: { type: "string", description: "Company name" }, + founded: { type: "number", description: "Year founded" }, products: { - type: 'array', - items: { type: 'string' }, - description: 'Main products' - } + type: "array", + items: { type: "string" }, + description: "Main products", + }, }, - required: ['company', 'founded'] - } - } - } + required: ["company", "founded"], + }, + }, + }, }) // Access the structured output @@ -154,29 +154,29 @@ console.log(result.data.info.structured_output) ### Output Format Types -| Type | Description | -|------|-------------| -| `text` | Default. Standard text response (no structured output) | -| `json_schema` | Returns validated JSON matching the provided schema | +| Type | Description | +| ------------- | ------------------------------------------------------ | +| `text` | Default. Standard text response (no structured output) | +| `json_schema` | Returns validated JSON matching the provided schema | ### JSON Schema Format When using `type: 'json_schema'`, provide: -| Field | Type | Description | -|-------|------|-------------| -| `type` | `'json_schema'` | Required. Specifies JSON schema mode | -| `schema` | `object` | Required. JSON Schema object defining the output structure | -| `retryCount` | `number` | Optional. Number of validation retries (default: 2) | +| Field | Type | Description | +| ------------ | --------------- | ---------------------------------------------------------- | +| `type` | `'json_schema'` | Required. Specifies JSON schema mode | +| `schema` | `object` | Required. JSON Schema object defining the output structure | +| `retryCount` | `number` | Optional. Number of validation retries (default: 2) | ### Error Handling If the model fails to produce valid structured output after all retries, the response will include a `StructuredOutputError`: ```typescript -if (result.data.info.error?.name === 'StructuredOutputError') { - console.error('Failed to produce structured output:', result.data.info.error.message) - console.error('Attempts:', result.data.info.error.retries) +if (result.data.info.error?.name === "StructuredOutputError") { + console.error("Failed to produce structured output:", result.data.info.error.message) + console.error("Attempts:", result.data.info.error.retries) } ``` @@ -298,27 +298,27 @@ const { providers, default: defaults } = await client.config.providers() ### Sessions -| Method | Description | Notes | -| ---------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `session.list()` | List sessions | Returns Session[] | -| `session.get({ path })` | Get session | Returns Session | -| `session.children({ path })` | List child sessions | Returns Session[] | -| `session.create({ body })` | Create session | Returns Session | -| `session.delete({ path })` | Delete session | Returns `boolean` | -| `session.update({ path, body })` | Update session properties | Returns Session | -| `session.init({ path, body })` | Analyze app and create `AGENTS.md` | Returns `boolean` | -| `session.abort({ path })` | Abort a running session | Returns `boolean` | -| `session.share({ path })` | Share session | Returns Session | -| `session.unshare({ path })` | Unshare session | Returns Session | -| `session.summarize({ path, body })` | Summarize session | Returns `boolean` | -| `session.messages({ path })` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` | -| `session.message({ path })` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` | +| Method | Description | Notes | +| ---------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `session.list()` | List sessions | Returns Session[] | +| `session.get({ path })` | Get session | Returns Session | +| `session.children({ path })` | List child sessions | Returns Session[] | +| `session.create({ body })` | Create session | Returns Session | +| `session.delete({ path })` | Delete session | Returns `boolean` | +| `session.update({ path, body })` | Update session properties | Returns Session | +| `session.init({ path, body })` | Analyze app and create `AGENTS.md` | Returns `boolean` | +| `session.abort({ path })` | Abort a running session | Returns `boolean` | +| `session.share({ path })` | Share session | Returns Session | +| `session.unshare({ path })` | Unshare session | Returns Session | +| `session.summarize({ path, body })` | Summarize session | Returns `boolean` | +| `session.messages({ path })` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` | +| `session.message({ path })` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` | | `session.prompt({ path, body })` | Send prompt message | `body.noReply: true` returns UserMessage (context only). Default returns AssistantMessage with AI response. Supports `body.outputFormat` for [structured output](#structured-output) | -| `session.command({ path, body })` | Send command to session | Returns `{ info: `AssistantMessage`, parts: `Part[]`}` | -| `session.shell({ path, body })` | Run a shell command | Returns AssistantMessage | -| `session.revert({ path, body })` | Revert a message | Returns Session | -| `session.unrevert({ path })` | Restore reverted messages | Returns Session | -| `postSessionByIdPermissionsByPermissionId({ path, body })` | Respond to a permission request | Returns `boolean` | +| `session.command({ path, body })` | Send command to session | Returns `{ info: `AssistantMessage`, parts: `Part[]`}` | +| `session.shell({ path, body })` | Run a shell command | Returns AssistantMessage | +| `session.revert({ path, body })` | Revert a message | Returns Session | +| `session.unrevert({ path })` | Restore reverted messages | Returns Session | +| `postSessionByIdPermissionsByPermissionId({ path, body })` | Respond to a permission request | Returns `boolean` | --- -- cgit v1.2.3