diff options
| author | Adam <[email protected]> | 2026-02-28 15:27:11 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-28 15:27:11 -0600 |
| commit | e1e18c7abdb1025d7be63acee1f188b94d16eb9b (patch) | |
| tree | ad14a08aba4752d3ab03452209520c94bb0df59e /packages/web/src/content/docs/de/sdk.mdx | |
| parent | 971bd30516fb2b245f87bdf79e36bb64e72265bc (diff) | |
| download | opencode-e1e18c7abdb1025d7be63acee1f188b94d16eb9b.tar.gz opencode-e1e18c7abdb1025d7be63acee1f188b94d16eb9b.zip | |
chore(docs): i18n sync (#15417)
Diffstat (limited to 'packages/web/src/content/docs/de/sdk.mdx')
| -rw-r--r-- | packages/web/src/content/docs/de/sdk.mdx | 202 |
1 files changed, 137 insertions, 65 deletions
diff --git a/packages/web/src/content/docs/de/sdk.mdx b/packages/web/src/content/docs/de/sdk.mdx index 21791db05..22e70071d 100644 --- a/packages/web/src/content/docs/de/sdk.mdx +++ b/packages/web/src/content/docs/de/sdk.mdx @@ -119,6 +119,78 @@ try { --- +## Structured Output + +Du kannst eine strukturierte JSON-Ausgabe vom Modell anfordern, indem du ein `format` mit einem JSON-Schema angibst. Das Modell verwendet dann ein `StructuredOutput`-Tool, um validiertes JSON zurueckzugeben, das deinem Schema entspricht. + +### Grundlegende Verwendung + +```typescript +const result = await client.session.prompt({ + path: { id: sessionId }, + body: { + parts: [{ type: "text", text: "Recherchiere Anthropic und gib Firmeninfos zurueck" }], + format: { + type: "json_schema", + schema: { + type: "object", + properties: { + company: { type: "string", description: "Firmenname" }, + founded: { type: "number", description: "Gruendungsjahr" }, + products: { + type: "array", + items: { type: "string" }, + description: "Hauptprodukte", + }, + }, + required: ["company", "founded"], + }, + }, + }, +}) + +// Zugriff auf die strukturierte Ausgabe +console.log(result.data.info.structured_output) +// { company: "Anthropic", founded: 2021, products: ["Claude", "Claude API"] } +``` + +### Ausgabeformate + +| Type | Description | +| ------------- | ----------------------------------------------------------- | +| `text` | Standard. Normale Textantwort (keine strukturierte Ausgabe) | +| `json_schema` | Gibt validiertes JSON zurueck, das dem Schema entspricht | + +### JSON-Schema-Format + +Bei Verwendung von `type: 'json_schema'` musst du Folgendes angeben: + +| Field | Type | Description | +| ------------ | --------------- | ------------------------------------------------------------- | +| `type` | `'json_schema'` | Erforderlich. Gibt den JSON-Schema-Modus an | +| `schema` | `object` | Erforderlich. JSON-Schema-Objekt, das die Struktur definiert | +| `retryCount` | `number` | Optional. Anzahl der Validierungswiederholungen (Standard: 2) | + +### Fehlerbehandlung + +Wenn das Modell nach allen Wiederholungen keine valide strukturierte Ausgabe liefert, enthaelt die Antwort einen `StructuredOutputError`: + +```typescript +if (result.data.info.error?.name === "StructuredOutputError") { + console.error("Strukturierte Ausgabe fehlgeschlagen:", result.data.info.error.message) + console.error("Versuche:", result.data.info.error.retries) +} +``` + +### Best Practices + +1. **Klare Beschreibungen**: Gib in deinen Schema-Properties klare Beschreibungen an, damit das Modell versteht, welche Daten extrahiert werden sollen. +2. **`required` nutzen**: Definiere, welche Felder zwingend vorhanden sein muessen. +3. **Schemas einfach halten**: Komplexe verschachtelte Schemas sind fuer das Modell schwerer korrekt auszufuellen. +4. **`retryCount` anpassen**: Erhoehe den Wert bei komplexen Schemas, verringere ihn bei einfachen. + +--- + ## APIs Das SDK stellt alle Server-APIs ueber einen typsicheren Client bereit. @@ -127,9 +199,9 @@ Das SDK stellt alle Server-APIs ueber einen typsicheren Client bereit. ### Global -| Method | Description | Response | -| ----------------- | ------------------------------- | ------------------------------------ | -| `global.health()` | Check server health and version | `{ healthy: true, version: string }` | +| Method | Description | Response | +| ----------------- | -------------------------------- | ------------------------------------ | +| `global.health()` | Prueft Server-Status und Version | `{ healthy: true, version: string }` | --- @@ -144,10 +216,10 @@ console.log(health.data.version) ### App -| Method | Description | Response | -| -------------- | ------------------------- | ------------------------------------------- | -| `app.log()` | Write a log entry | `boolean` | -| `app.agents()` | List all available agents | <a href={typesUrl}><code>Agent[]</code></a> | +| Method | Description | Response | +| -------------- | -------------------------------- | ------------------------------------------- | +| `app.log()` | Schreibt einen Log-Eintrag | `boolean` | +| `app.agents()` | Listet alle verfuegbaren Agenten | <a href={typesUrl}><code>Agent[]</code></a> | --- @@ -171,10 +243,10 @@ const agents = await client.app.agents() ### Project -| Method | Description | Response | -| ------------------- | ------------------- | --------------------------------------------- | -| `project.list()` | List all projects | <a href={typesUrl}><code>Project[]</code></a> | -| `project.current()` | Get current project | <a href={typesUrl}><code>Project</code></a> | +| Method | Description | Response | +| ------------------- | ---------------------------- | --------------------------------------------- | +| `project.list()` | Listet alle Projekte | <a href={typesUrl}><code>Project[]</code></a> | +| `project.current()` | Ruft das aktuelle Projekt ab | <a href={typesUrl}><code>Project</code></a> | --- @@ -192,9 +264,9 @@ const currentProject = await client.project.current() ### Path -| Method | Description | Response | -| ------------ | ---------------- | ---------------------------------------- | -| `path.get()` | Get current path | <a href={typesUrl}><code>Path</code></a> | +| Method | Description | Response | +| ------------ | -------------------------- | ---------------------------------------- | +| `path.get()` | Ruft den aktuellen Pfad ab | <a href={typesUrl}><code>Path</code></a> | --- @@ -209,10 +281,10 @@ const pathInfo = await client.path.get() ### Config -| Method | Description | Response | -| -------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `config.get()` | Get config info | <a href={typesUrl}><code>Config</code></a> | -| `config.providers()` | List providers and default models | `{ providers: `<a href={typesUrl}><code>Provider[]</code></a>`, default: { [key: string]: string } }` | +| Method | Description | Response | +| -------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------- | +| `config.get()` | Ruft Konfigurationsinfos ab | <a href={typesUrl}><code>Config</code></a> | +| `config.providers()` | Listet Provider und Standard-Modelle | `{ providers: `<a href={typesUrl}><code>Provider[]</code></a>`, default: { [key: string]: string } }` | --- @@ -228,27 +300,27 @@ const { providers, default: defaults } = await client.config.providers() ### Sessions -| Method | Description | Notes | -| ---------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| `session.list()` | List sessions | Returns <a href={typesUrl}><code>Session[]</code></a> | -| `session.get({ path })` | Get session | Returns <a href={typesUrl}><code>Session</code></a> | -| `session.children({ path })` | List child sessions | Returns <a href={typesUrl}><code>Session[]</code></a> | -| `session.create({ body })` | Create session | Returns <a href={typesUrl}><code>Session</code></a> | -| `session.delete({ path })` | Delete session | Returns `boolean` | -| `session.update({ path, body })` | Update session properties | Returns <a href={typesUrl}><code>Session</code></a> | -| `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 <a href={typesUrl}><code>Session</code></a> | -| `session.unshare({ path })` | Unshare session | Returns <a href={typesUrl}><code>Session</code></a> | -| `session.summarize({ path, body })` | Summarize session | Returns `boolean` | -| `session.messages({ path })` | List messages in a session | Returns `{ info: `<a href={typesUrl}><code>Message</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}[]` | -| `session.message({ path })` | Get message details | Returns `{ info: `<a href={typesUrl}><code>Message</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}` | -| `session.prompt({ path, body })` | Send prompt message | `body.noReply: true` returns UserMessage (context only). Default returns <a href={typesUrl}><code>AssistantMessage</code></a> with AI response | -| `session.command({ path, body })` | Send command to session | Returns `{ info: `<a href={typesUrl}><code>AssistantMessage</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}` | -| `session.shell({ path, body })` | Run a shell command | Returns <a href={typesUrl}><code>AssistantMessage</code></a> | -| `session.revert({ path, body })` | Revert a message | Returns <a href={typesUrl}><code>Session</code></a> | -| `session.unrevert({ path })` | Restore reverted messages | Returns <a href={typesUrl}><code>Session</code></a> | -| `postSessionByIdPermissionsByPermissionId({ path, body })` | Respond to a permission request | Returns `boolean` | +| Method | Description | Notes | +| ---------------------------------------------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `session.list()` | Listet Sessions | Gibt <a href={typesUrl}><code>Session[]</code></a> zurueck | +| `session.get({ path })` | Ruft Session ab | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.children({ path })` | Listet Kind-Sessions | Gibt <a href={typesUrl}><code>Session[]</code></a> zurueck | +| `session.create({ body })` | Erstellt Session | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.delete({ path })` | Loescht Session | Gibt `boolean` zurueck | +| `session.update({ path, body })` | Aktualisiert Session-Eigenschaften | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.init({ path, body })` | Analysiert App und erstellt `AGENTS.md` | Gibt `boolean` zurueck | +| `session.abort({ path })` | Bricht eine laufende Session ab | Gibt `boolean` zurueck | +| `session.share({ path })` | Teilt Session | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.unshare({ path })` | Hebt Teilen der Session auf | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.summarize({ path, body })` | Fasst Session zusammen | Gibt `boolean` zurueck | +| `session.messages({ path })` | Listet Nachrichten einer Session | Gibt `{ info: `<a href={typesUrl}><code>Message</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}[]` zurueck | +| `session.message({ path })` | Ruft Nachrichtendetails ab | Gibt `{ info: `<a href={typesUrl}><code>Message</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}` zurueck | +| `session.prompt({ path, body })` | Sendet Prompt-Nachricht | `body.noReply: true` gibt UserMessage (nur Kontext) zurueck. Standard gibt <a href={typesUrl}><code>AssistantMessage</code></a> mit AI-Antwort zurueck. Unterstuetzt `body.outputFormat` fuer [strukturierte Ausgabe](#structured-output) | +| `session.command({ path, body })` | Sendet Befehl an Session | Gibt `{ info: `<a href={typesUrl}><code>AssistantMessage</code></a>`, parts: `<a href={typesUrl}><code>Part[]</code></a>`}` zurueck | +| `session.shell({ path, body })` | Fuehrt Shell-Befehl aus | Gibt <a href={typesUrl}><code>AssistantMessage</code></a> zurueck | +| `session.revert({ path, body })` | Setzt Nachricht zurueck | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `session.unrevert({ path })` | Stellt zurueckgesetzte Nachrichten wieder her | Gibt <a href={typesUrl}><code>Session</code></a> zurueck | +| `postSessionByIdPermissionsByPermissionId({ path, body })` | Antwortet auf eine Berechtigungsanfrage | Gibt `boolean` zurueck | --- @@ -285,19 +357,19 @@ await client.session.prompt({ ### Files -| Method | Description | Response | -| ------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------- | -| `find.text({ query })` | Search for text in files | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` | -| `find.files({ query })` | Find files and directories by name | `string[]` (paths) | -| `find.symbols({ query })` | Find workspace symbols | <a href={typesUrl}><code>Symbol[]</code></a> | -| `file.read({ query })` | Read a file | `{ type: "raw" \| "patch", content: string }` | -| `file.status({ query? })` | Get status for tracked files | <a href={typesUrl}><code>File[]</code></a> | +| Method | Description | Response | +| ------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `find.text({ query })` | Sucht Text in Dateien | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` | +| `find.files({ query })` | Findet Dateien und Verzeichnisse nach Namen | `string[]` (paths) | +| `find.symbols({ query })` | Findet Workspace-Symbole | <a href={typesUrl}><code>Symbol[]</code></a> | +| `file.read({ query })` | Liest eine Datei | `{ type: "raw" \| "patch", content: string }` | +| `file.status({ query? })` | Ruft Status fuer getrackte Dateien ab | <a href={typesUrl}><code>File[]</code></a> | -`find.files` supports a few optional query fields: +`find.files` unterstuetzt einige optionale Query-Felder: -- `type`: `"file"` or `"directory"` -- `directory`: override the project root for the search -- `limit`: max results (1–200) +- `type`: `"file"` oder `"directory"` +- `directory`: Ueberschreibt das Projekt-Root fuer die Suche +- `limit`: Maximale Ergebnisse (1–200) --- @@ -326,17 +398,17 @@ const content = await client.file.read({ ### TUI -| Method | Description | Response | -| ------------------------------ | ------------------------- | --------- | -| `tui.appendPrompt({ body })` | Append text to the prompt | `boolean` | -| `tui.openHelp()` | Open the help dialog | `boolean` | -| `tui.openSessions()` | Open the session selector | `boolean` | -| `tui.openThemes()` | Open the theme selector | `boolean` | -| `tui.openModels()` | Open the model selector | `boolean` | -| `tui.submitPrompt()` | Submit the current prompt | `boolean` | -| `tui.clearPrompt()` | Clear the prompt | `boolean` | -| `tui.executeCommand({ body })` | Execute a command | `boolean` | -| `tui.showToast({ body })` | Show toast notification | `boolean` | +| Method | Description | Response | +| ------------------------------ | ------------------------------ | --------- | +| `tui.appendPrompt({ body })` | Haengt Text an den Prompt an | `boolean` | +| `tui.openHelp()` | Oeffnet den Hilfedialog | `boolean` | +| `tui.openSessions()` | Oeffnet die Session-Auswahl | `boolean` | +| `tui.openThemes()` | Oeffnet die Theme-Auswahl | `boolean` | +| `tui.openModels()` | Oeffnet die Modell-Auswahl | `boolean` | +| `tui.submitPrompt()` | Sendet den aktuellen Prompt ab | `boolean` | +| `tui.clearPrompt()` | Leert den Prompt | `boolean` | +| `tui.executeCommand({ body })` | Fuehrt einen Befehl aus | `boolean` | +| `tui.showToast({ body })` | Zeigt Toast-Benachrichtigung | `boolean` | --- @@ -357,9 +429,9 @@ await client.tui.showToast({ ### Auth -| Method | Description | Response | -| ------------------- | ------------------------------ | --------- | -| `auth.set({ ... })` | Set authentication credentials | `boolean` | +| Method | Description | Response | +| ------------------- | ----------------------------- | --------- | +| `auth.set({ ... })` | Setzt Authentifizierungsdaten | `boolean` | --- @@ -378,7 +450,7 @@ await client.auth.set({ | Method | Description | Response | | ------------------- | ------------------------- | ------------------------- | -| `event.subscribe()` | Server-sent events stream | Server-sent events stream | +| `event.subscribe()` | Server-Sent Events Stream | Server-sent events stream | --- |
