@theokit/sdk 2.20.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +115 -0
- package/dist/a2a/index.cjs +592 -290
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +593 -291
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/types.d.cts +7 -0
- package/dist/a2a/types.d.ts +7 -0
- package/dist/agent-builder.d.ts +2 -1
- package/dist/agent-generate.d.ts +12 -0
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +5 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/theokit-client.d.cts +6 -0
- package/dist/client/theokit-client.d.ts +6 -0
- package/dist/client/types.d.cts +2 -0
- package/dist/client/types.d.ts +2 -0
- package/dist/{cron-D2yLOrk2.d.ts → cron-YrmsszEN.d.cts} +53 -3
- package/dist/{cron-B8fqui49.d.cts → cron-dpvtRoro.d.ts} +53 -3
- package/dist/cron.cjs +642 -387
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +3 -2
- package/dist/cron.d.ts +3 -2
- package/dist/cron.js +643 -388
- package/dist/cron.js.map +1 -1
- package/dist/{errors-5lj1EWgs.d.ts → errors-C4vZPqXf.d.ts} +2 -2
- package/dist/{errors-CE-lMBi2.d.cts → errors-DrcpYVfZ.d.cts} +2 -2
- package/dist/errors.d.cts +3 -2
- package/dist/eval.cjs +642 -387
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +642 -387
- package/dist/eval.js.map +1 -1
- package/dist/generate-object.d.ts +4 -3
- package/dist/index.cjs +788 -390
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +259 -17
- package/dist/index.d.ts +259 -17
- package/dist/index.js +786 -392
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop-types.d.ts +2 -0
- package/dist/internal/agent-loop/tool-result-guard.d.ts +1 -0
- package/dist/internal/llm/tool-result-content.d.ts +40 -0
- package/dist/internal/llm/types.d.ts +6 -1
- package/dist/internal/persistence/conversation-storage-fs.d.cts +3 -1
- package/dist/internal/persistence/conversation-storage-fs.d.ts +3 -1
- package/dist/internal/persistence/conversation-storage-memory.d.cts +3 -1
- package/dist/internal/persistence/conversation-storage-memory.d.ts +3 -1
- package/dist/internal/persistence/session-meta.d.cts +13 -0
- package/dist/internal/persistence/session-meta.d.ts +13 -0
- package/dist/internal/runtime/model-selection.d.ts +14 -0
- package/dist/internal/structured-output-helpers.d.ts +1 -1
- package/dist/permission-engine.d.ts +32 -1
- package/dist/{run-BgfBWX-z.d.cts → run-BMo8yRwK.d.cts} +262 -19
- package/dist/{run-BgfBWX-z.d.ts → run-BMo8yRwK.d.ts} +262 -19
- package/dist/stream-object.d.ts +2 -1
- package/dist/tool-error.d.ts +30 -0
- package/dist/types/agent-prims.d.ts +10 -8
- package/dist/types/agent.d.ts +12 -1
- package/dist/types/content-blocks.d.ts +47 -0
- package/dist/types/conversation-storage.d.ts +38 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/messages.d.ts +2 -9
- package/dist/types/run-events.d.ts +84 -0
- package/dist/types/run.d.ts +115 -1
- package/dist/types/session.d.ts +99 -0
- package/dist/types/workflow.d.ts +7 -0
- package/dist/workflow.cjs +7 -2
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -0
- package/dist/workflow.d.ts +2 -0
- package/dist/workflow.js +7 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +14 -34
- package/dist/internal/observability/context.d.cts +0 -23
- package/dist/internal/observability/context.d.ts +0 -23
- package/dist/internal/observability/index.cjs +0 -38
- package/dist/internal/observability/index.cjs.map +0 -1
- package/dist/internal/observability/index.d.cts +0 -8
- package/dist/internal/observability/index.d.ts +0 -8
- package/dist/internal/observability/index.js +0 -33
- package/dist/internal/observability/index.js.map +0 -1
- package/dist/internal/plugins/index.cjs +0 -363
- package/dist/internal/plugins/index.cjs.map +0 -1
- package/dist/internal/plugins/index.js +0 -357
- package/dist/internal/plugins/index.js.map +0 -1
- package/dist/internal/workflow/index.d.ts +0 -12
- package/dist/server/adapter/index.d.cts +0 -8
- package/dist/server/adapter/index.d.ts +0 -8
package/dist/a2a/types.d.cts
CHANGED
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
* A2A (Agent-to-Agent) communication types (T20.1, ADR D453).
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
+
import type { MessageOrigin } from "../types/run.js";
|
|
5
6
|
export interface A2AMessage<T = unknown> {
|
|
6
7
|
type: string;
|
|
7
8
|
payload: T;
|
|
8
9
|
from: string;
|
|
9
10
|
to: string;
|
|
10
11
|
timestamp: number;
|
|
12
|
+
/**
|
|
13
|
+
* SE3 — provenance projection of the sender address: `{ kind: "peer", from }`.
|
|
14
|
+
* A thin view over `from` (not a parallel system), so a receiver that turns an
|
|
15
|
+
* a2a message into a turn can forward it via `SendOptions.origin`.
|
|
16
|
+
*/
|
|
17
|
+
origin?: MessageOrigin;
|
|
11
18
|
}
|
|
12
19
|
export type MessageHandler<T = unknown> = (message: A2AMessage<T>) => undefined | unknown | Promise<undefined | unknown>;
|
package/dist/a2a/types.d.ts
CHANGED
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
* A2A (Agent-to-Agent) communication types (T20.1, ADR D453).
|
|
3
3
|
* @public
|
|
4
4
|
*/
|
|
5
|
+
import type { MessageOrigin } from "../types/run.js";
|
|
5
6
|
export interface A2AMessage<T = unknown> {
|
|
6
7
|
type: string;
|
|
7
8
|
payload: T;
|
|
8
9
|
from: string;
|
|
9
10
|
to: string;
|
|
10
11
|
timestamp: number;
|
|
12
|
+
/**
|
|
13
|
+
* SE3 — provenance projection of the sender address: `{ kind: "peer", from }`.
|
|
14
|
+
* A thin view over `from` (not a parallel system), so a receiver that turns an
|
|
15
|
+
* a2a message into a turn can forward it via `SendOptions.origin`.
|
|
16
|
+
*/
|
|
17
|
+
origin?: MessageOrigin;
|
|
11
18
|
}
|
|
12
19
|
export type MessageHandler<T = unknown> = (message: A2AMessage<T>) => undefined | unknown | Promise<undefined | unknown>;
|
package/dist/agent-builder.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ export declare class AgentBuilder {
|
|
|
18
18
|
private opts;
|
|
19
19
|
private readonly deps;
|
|
20
20
|
constructor(deps?: AgentBuilderDeps);
|
|
21
|
-
|
|
21
|
+
/** SE8 — accepts a bare-string id shorthand (`"openai/gpt-4o-mini"`) or a {@link ModelSelection}. */
|
|
22
|
+
model(m: string | ModelSelection): this;
|
|
22
23
|
apiKey(k: string): this;
|
|
23
24
|
name(n: string): this;
|
|
24
25
|
systemPrompt(p: string | SystemPromptResolver): this;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SE9 — integrated structured output: `agent.generate(input, { output })` runs the
|
|
3
|
+
* agent's NORMAL tool loop (the user's tools run first) and then coerces the final
|
|
4
|
+
* answer into a Zod schema, returning a validated, inferred-typed object.
|
|
5
|
+
*
|
|
6
|
+
* This is SUGAR over `generateObject` (ADR D33) — it does NOT fork the
|
|
7
|
+
* synthetic-forced-tool machinery. Phase 1 is the user's own `agent.send()` run;
|
|
8
|
+
* phase 2 reuses `generateObjectImpl` over the run's final answer.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export type { GenerateOptions, GenerateRunResult } from "./types/run.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/theokit-client.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../../src/client/theokit-client.ts"],"names":[],"mappings":";;;AAkBO,IAAM,gBAAN,MAAoB;AAAA,EACR,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,IAAA,EAAqB;AAC/B,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAO,EA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E,CAAA;AAAA,IAC/E;AAEA,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAA,EAAM,SAAA,EAAU;AACxC,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,MAAM,8CAA8C,CAAA;AAAA,IAChE;AAEA,IAAA,MAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAChC,IAAA,IAAI,MAAA,GAAS,EAAA;AAEb,IAAA,IAAI;AAEF,MAAA,OAAO,IAAA,EAAM;AACX,QAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAM,GAAI,MAAM,OAAO,IAAA,EAAK;AAC1C,QAAA,IAAI,IAAA,EAAM;AAEV,QAAA,MAAA,IAAU,QAAQ,MAAA,CAAO,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAM,CAAA;AAChD,QAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,KAAA,CAAM,IAAI,CAAA;AAC/B,QAAA,MAAA,GAAS,KAAA,CAAM,KAAI,IAAK,EAAA;AAGxB,QAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,UAAA,MAAM,OAAA,GAAU,KAAK,IAAA,EAAK;AAC1B,UAAA,IAAI,OAAA,CAAQ,UAAA,CAAW,QAAQ,CAAA,EAAG;AAChC,YAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,KAAA,CAAM,CAAC,CAAA;AAC5B,YAAA,IAAI,SAAS,QAAA,EAAU;AACvB,YAAA,IAAI;AACF,cAAA,MAAM,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,YACvB,CAAA,CAAA,MAAQ;AAAA,YAER;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAA,SAAE;AACA,MAAA,MAAA,CAAO,WAAA,EAAY;AAAA,IACrB;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["/**\n * TheoKitClient — browser-safe client for consuming server adapter endpoints\n * (T20.2, ADR D454).\n *\n * Zero Node dependencies. Uses native fetch + manual SSE parsing.\n * Consumes the same HTTP contract as server adapters (POST /send, GET /stream).\n *\n * @public\n * @deprecated since 2.x — consumes a legacy server-adapter HTTP contract\n * (`POST /agent/send`, `GET /agent/stream`) that the ecosystem no longer\n * produces. For in-process agent runs use the `Agent` façade (`@theokit/sdk`);\n * for HTTP, the framework (`theokit`) exposes agents at `POST /api/agents/<name>`\n * over a `UIMessageStream` with its own typed client. The `@theokit/sdk/client`\n * sub-path will be removed in the next major.\n */\n\nimport type { ClientOptions, SendResponse, StreamEvent } from \"./types.js\";\n\nexport class TheoKitClient {\n private readonly _baseUrl: string;\n private readonly _basePath: string;\n private readonly _headers: Record<string, string>;\n\n constructor(opts: ClientOptions) {\n this._baseUrl = opts.baseUrl.replace(/\\/$/, \"\");\n this._basePath = opts.basePath ?? \"/agent\";\n this._headers = opts.headers ?? {};\n }\n\n async send(input: string): Promise<SendResponse> {\n const url = `${this._baseUrl}${this._basePath}/send`;\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...this._headers,\n },\n body: JSON.stringify({ input }),\n });\n\n if (!response.ok) {\n throw new Error(`TheoKitClient: send failed with status ${response.status}`);\n }\n\n return (await response.json()) as SendResponse;\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: SSE stream parsing with fetch + ReadableStream reader requires sequential control flow\n async *stream(input: string): AsyncGenerator<StreamEvent, void, void> {\n const url = `${this._baseUrl}${this._basePath}/stream?input=${encodeURIComponent(input)}`;\n const response = await fetch(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...this._headers,\n },\n });\n\n if (!response.ok) {\n throw new Error(`TheoKitClient: stream failed with status ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"TheoKitClient: response body is not readable\");\n }\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n try {\n // jscpd:ignore-start — SSE stream buffer pattern (different protocol from NDJSON in ollama-native)\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n // jscpd:ignore-end\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed.startsWith(\"data: \")) {\n const data = trimmed.slice(6);\n if (data === \"[DONE]\") return;\n try {\n yield JSON.parse(data) as StreamEvent;\n } catch {\n // Skip malformed SSE data lines\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n}\n"]}
|
package/dist/client/index.d.cts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Client sub-path barrel (T20.2, ADR D454).
|
|
3
3
|
* Exported via `@theokit/sdk/client`.
|
|
4
4
|
* @public
|
|
5
|
+
* @deprecated since 2.x — the `@theokit/sdk/client` sub-path consumes a legacy
|
|
6
|
+
* server-adapter HTTP contract (`/agent/send`, `/agent/stream`) that the
|
|
7
|
+
* ecosystem no longer produces. Use the `Agent` façade (`@theokit/sdk`) for
|
|
8
|
+
* in-process runs, or the framework's `POST /api/agents/<name>` typed client for
|
|
9
|
+
* HTTP. This sub-path will be removed in the next major.
|
|
5
10
|
*/
|
|
6
11
|
export { TheoKitClient } from "./theokit-client.js";
|
|
7
12
|
export type { ClientOptions, SendResponse, StreamEvent } from "./types.js";
|
package/dist/client/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Client sub-path barrel (T20.2, ADR D454).
|
|
3
3
|
* Exported via `@theokit/sdk/client`.
|
|
4
4
|
* @public
|
|
5
|
+
* @deprecated since 2.x — the `@theokit/sdk/client` sub-path consumes a legacy
|
|
6
|
+
* server-adapter HTTP contract (`/agent/send`, `/agent/stream`) that the
|
|
7
|
+
* ecosystem no longer produces. Use the `Agent` façade (`@theokit/sdk`) for
|
|
8
|
+
* in-process runs, or the framework's `POST /api/agents/<name>` typed client for
|
|
9
|
+
* HTTP. This sub-path will be removed in the next major.
|
|
5
10
|
*/
|
|
6
11
|
export { TheoKitClient } from "./theokit-client.js";
|
|
7
12
|
export type { ClientOptions, SendResponse, StreamEvent } from "./types.js";
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/theokit-client.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/client/theokit-client.ts"],"names":[],"mappings":";AAkBO,IAAM,gBAAN,MAAoB;AAAA,EACR,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EAEjB,YAAY,IAAA,EAAqB;AAC/B,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAO,EAAE,CAAA;AAC9C,IAAA,IAAA,CAAK,SAAA,GAAY,KAAK,QAAA,IAAY,QAAA;AAClC,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,OAAA,IAAW,EAAC;AAAA,EACnC;AAAA,EAEA,MAAM,KAAK,KAAA,EAAsC;AAC/C,IAAA,MAAM,MAAM,CAAA,EAAG,IAAA,CAAK,QAAQ,CAAA,EAAG,KAAK,SAAS,CAAA,KAAA,CAAA;AAC7C,IAAA,MAAM,QAAA,GAAW,MAAM,KAAA,CAAM,GAAA,EAAK;AAAA,MAChC,MAAA,EAAQ,MAAA;AAAA,MACR,OAAA,EAAS;AAAA,QACP,cAAA,EAAgB,kBAAA;AAAA,QAChB,GAAG,IAAA,CAAK;AAAA,OACV;AAAA,MACA,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,EAAE,OAAO;AAAA,KAC/B,CAAA;AAED,IAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AAChB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,uCAAA,EAA0C,QAAA,CAAS,MAAM,CAAA,CAAE,CAAA;AAAA,IAC7E;AAEA,IAAA,OAAQ,MAAM,SAAS,IAAA,EAAK;AAAA,EAC9B;AAAA;AAAA,EAGA,OAAO,OAAO,KAAA,EAAwD;AACpE,IAAA,MAAM,GAAA,GAAM,CAAA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AA,CAAM,CAAC,CAAA;AAC5B,YAAA,IAAI,SAAS,QAAA,EAAU;AACvB,YAAA,IAAI;AACF,cAAA,MAAM,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,YACvB,CAAA,CAAA,MAAQ;AAAA,YAER;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAA,SAAE;AACA,MAAA,MAAA,CAAO,WAAA,EAAY;AAAA,IACrB;AAAA,EACF;AACF","file":"index.js","sourcesContent":["/**\n * TheoKitClient — browser-safe client for consuming server adapter endpoints\n * (T20.2, ADR D454).\n *\n * Zero Node dependencies. Uses native fetch + manual SSE parsing.\n * Consumes the same HTTP contract as server adapters (POST /send, GET /stream).\n *\n * @public\n * @deprecated since 2.x — consumes a legacy server-adapter HTTP contract\n * (`POST /agent/send`, `GET /agent/stream`) that the ecosystem no longer\n * produces. For in-process agent runs use the `Agent` façade (`@theokit/sdk`);\n * for HTTP, the framework (`theokit`) exposes agents at `POST /api/agents/<name>`\n * over a `UIMessageStream` with its own typed client. The `@theokit/sdk/client`\n * sub-path will be removed in the next major.\n */\n\nimport type { ClientOptions, SendResponse, StreamEvent } from \"./types.js\";\n\nexport class TheoKitClient {\n private readonly _baseUrl: string;\n private readonly _basePath: string;\n private readonly _headers: Record<string, string>;\n\n constructor(opts: ClientOptions) {\n this._baseUrl = opts.baseUrl.replace(/\\/$/, \"\");\n this._basePath = opts.basePath ?? \"/agent\";\n this._headers = opts.headers ?? {};\n }\n\n async send(input: string): Promise<SendResponse> {\n const url = `${this._baseUrl}${this._basePath}/send`;\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...this._headers,\n },\n body: JSON.stringify({ input }),\n });\n\n if (!response.ok) {\n throw new Error(`TheoKitClient: send failed with status ${response.status}`);\n }\n\n return (await response.json()) as SendResponse;\n }\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: SSE stream parsing with fetch + ReadableStream reader requires sequential control flow\n async *stream(input: string): AsyncGenerator<StreamEvent, void, void> {\n const url = `${this._baseUrl}${this._basePath}/stream?input=${encodeURIComponent(input)}`;\n const response = await fetch(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...this._headers,\n },\n });\n\n if (!response.ok) {\n throw new Error(`TheoKitClient: stream failed with status ${response.status}`);\n }\n\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"TheoKitClient: response body is not readable\");\n }\n\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n try {\n // jscpd:ignore-start — SSE stream buffer pattern (different protocol from NDJSON in ollama-native)\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n // jscpd:ignore-end\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed.startsWith(\"data: \")) {\n const data = trimmed.slice(6);\n if (data === \"[DONE]\") return;\n try {\n yield JSON.parse(data) as StreamEvent;\n } catch {\n // Skip malformed SSE data lines\n }\n }\n }\n }\n } finally {\n reader.releaseLock();\n }\n }\n}\n"]}
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* Consumes the same HTTP contract as server adapters (POST /send, GET /stream).
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
|
+
* @deprecated since 2.x — consumes a legacy server-adapter HTTP contract
|
|
10
|
+
* (`POST /agent/send`, `GET /agent/stream`) that the ecosystem no longer
|
|
11
|
+
* produces. For in-process agent runs use the `Agent` façade (`@theokit/sdk`);
|
|
12
|
+
* for HTTP, the framework (`theokit`) exposes agents at `POST /api/agents/<name>`
|
|
13
|
+
* over a `UIMessageStream` with its own typed client. The `@theokit/sdk/client`
|
|
14
|
+
* sub-path will be removed in the next major.
|
|
9
15
|
*/
|
|
10
16
|
import type { ClientOptions, SendResponse, StreamEvent } from "./types.js";
|
|
11
17
|
export declare class TheoKitClient {
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
* Consumes the same HTTP contract as server adapters (POST /send, GET /stream).
|
|
7
7
|
*
|
|
8
8
|
* @public
|
|
9
|
+
* @deprecated since 2.x — consumes a legacy server-adapter HTTP contract
|
|
10
|
+
* (`POST /agent/send`, `GET /agent/stream`) that the ecosystem no longer
|
|
11
|
+
* produces. For in-process agent runs use the `Agent` façade (`@theokit/sdk`);
|
|
12
|
+
* for HTTP, the framework (`theokit`) exposes agents at `POST /api/agents/<name>`
|
|
13
|
+
* over a `UIMessageStream` with its own typed client. The `@theokit/sdk/client`
|
|
14
|
+
* sub-path will be removed in the next major.
|
|
9
15
|
*/
|
|
10
16
|
import type { ClientOptions, SendResponse, StreamEvent } from "./types.js";
|
|
11
17
|
export declare class TheoKitClient {
|
package/dist/client/types.d.cts
CHANGED
package/dist/client/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection,
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-BMo8yRwK.cjs';
|
|
2
|
+
import * as zod from 'zod';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
|
@@ -602,6 +603,31 @@ interface StoredMessage {
|
|
|
602
603
|
/** Optional epoch-ms timestamp. Implementations MAY default to `Date.now()` on append. */
|
|
603
604
|
at?: number;
|
|
604
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* SE4 — light, session-level metadata stored ALONGSIDE the transcript (title +
|
|
608
|
+
* tag). Distinct from {@link StoredMessage} (which is per-turn content): this is
|
|
609
|
+
* per-conversation display metadata a host sets to build a session UI.
|
|
610
|
+
*
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
interface SessionMeta {
|
|
614
|
+
/** Human-facing title set via `renameSession`. Absent = untitled. */
|
|
615
|
+
readonly title?: string;
|
|
616
|
+
/** Single free-form tag set via `tagSession`. Absent = untagged. */
|
|
617
|
+
readonly tag?: string;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* SE4 — a partial update to {@link SessionMeta}. An omitted field is left
|
|
621
|
+
* unchanged; `tag: null` explicitly CLEARS the tag (distinct from omitting it).
|
|
622
|
+
*
|
|
623
|
+
* @public
|
|
624
|
+
*/
|
|
625
|
+
interface SessionMetaPatch {
|
|
626
|
+
/** Set the title; `null` explicitly CLEARS it (distinct from omitting it). */
|
|
627
|
+
readonly title?: string | null;
|
|
628
|
+
/** Set the tag; `null` explicitly CLEARS it (distinct from omitting it). */
|
|
629
|
+
readonly tag?: string | null;
|
|
630
|
+
}
|
|
605
631
|
/**
|
|
606
632
|
* Pluggable conversation persistence contract.
|
|
607
633
|
*
|
|
@@ -673,6 +699,19 @@ interface ConversationStorageAdapter {
|
|
|
673
699
|
* trims old turns past a soft cap; other backends typically no-op.
|
|
674
700
|
*/
|
|
675
701
|
compact?(conversationId: string, maxTurns: number): Promise<void>;
|
|
702
|
+
/**
|
|
703
|
+
* SE4 — optional: read the session-level metadata (title/tag) for a
|
|
704
|
+
* conversation. MUST return `undefined` when none was set (NOT throw).
|
|
705
|
+
* Adapters that cannot store side metadata MAY omit this — the session
|
|
706
|
+
* manager then reports rename/tag as unsupported rather than throwing.
|
|
707
|
+
*/
|
|
708
|
+
getSessionMeta?(conversationId: string): Promise<SessionMeta | undefined>;
|
|
709
|
+
/**
|
|
710
|
+
* SE4 — optional: apply a {@link SessionMetaPatch} to a conversation's
|
|
711
|
+
* session metadata (set title, set/clear tag). MUST create the metadata
|
|
712
|
+
* lazily. Adapters that cannot store side metadata MAY omit this.
|
|
713
|
+
*/
|
|
714
|
+
setSessionMeta?(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
676
715
|
/**
|
|
677
716
|
* Optional: dispose underlying handles (close DB pool, etc.).
|
|
678
717
|
* MUST be safe to call multiple times.
|
|
@@ -1335,7 +1374,12 @@ interface TelemetrySettings {
|
|
|
1335
1374
|
* @public
|
|
1336
1375
|
*/
|
|
1337
1376
|
interface AgentOptions {
|
|
1338
|
-
|
|
1377
|
+
/**
|
|
1378
|
+
* The model to run. SE8 — accepts a bare-string id shorthand
|
|
1379
|
+
* (`"openai/gpt-4o-mini"`, normalized to `{ id }`) OR a {@link ModelSelection}
|
|
1380
|
+
* object (use the object form to pass `params`).
|
|
1381
|
+
*/
|
|
1382
|
+
model?: string | ModelSelection;
|
|
1339
1383
|
/** Falls back to `THEOKIT_API_KEY`. */
|
|
1340
1384
|
apiKey?: string;
|
|
1341
1385
|
name?: string;
|
|
@@ -1627,6 +1671,12 @@ interface SDKAgent {
|
|
|
1627
1671
|
*/
|
|
1628
1672
|
readonly plugins?: SDKAgentPlugins;
|
|
1629
1673
|
send(message: string | SDKUserMessage, options?: SendOptions): Promise<Run>;
|
|
1674
|
+
/**
|
|
1675
|
+
* SE9 — integrated structured output. Runs the normal tool loop (the tools run
|
|
1676
|
+
* first) then coerces the final answer into the `output` Zod schema, returning a
|
|
1677
|
+
* validated, inferred-typed object. Sugar over `Agent.generateObject` (ADR D33).
|
|
1678
|
+
*/
|
|
1679
|
+
generate<T extends zod.ZodType>(message: string | SDKUserMessage, options: GenerateOptions<T>): Promise<GenerateRunResult<zod.z.infer<T>>>;
|
|
1630
1680
|
/** Fire-and-forget disposal. */
|
|
1631
1681
|
close(): void;
|
|
1632
1682
|
/** Re-read filesystem config (context, hooks, project MCP, subagents) without disposing. */
|
|
@@ -2096,4 +2146,4 @@ declare class Cron {
|
|
|
2096
2146
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2097
2147
|
}
|
|
2098
2148
|
|
|
2099
|
-
export { type
|
|
2149
|
+
export { type CronStartOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type ContextManagerKind as I, type ContextSnapshot as J, type ContextSource as K, type LocalOptions as L, type MemorySettings as M, type ContextSourceStatus as N, type CreateSkillSpec as O, type ProviderRoutingSettings as P, Cron as Q, type CronCreateOptions as R, type SystemPromptResolver as S, type CronGetOptions as T, type CronJob as U, type CronJobStatus as V, type CronListOptions as W, type CronOperationOptions as X, type CronRunOptions as Y, type CronRuntime as Z, type CronSchedulerStatus as _, type AgentDefinition as a, type GoalEvent as a0, type GoalOptions as a1, type GoalResult as a2, type HookName as a3, type InlineSkill as a4, type InvalidateCacheOptions as a5, type MemoryAdapter as a6, type MemoryAdapterCapabilities as a7, type MemoryContext as a8, type MemoryFact as a9, type TelemetrySettings as aA, createSkill as aB, definePlugin as aC, type MemoryProviderHandle as aa, type MemoryProviderInitOptions as ab, type MemoryRevision as ac, type MemoryToolSchema as ad, type MemoryTurnMessage as ae, type PersonalityPreset as af, type PluginContext as ag, type PostAssistantReplyContext as ah, type PreToolCallContext as ai, type PreUserSendContext as aj, type PreUserSendResult as ak, type ProviderCapability as al, type ProviderRoute as am, type RecordSessionSummaryArgs as an, type ResolvedProviderRoute as ao, type RunUntilIterator as ap, type SDKAgentPlugins as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SettingSource as aw, type SystemPromptContext as ax, type SystemPromptMemoryFact as ay, type SystemPromptSkillRef as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type ProviderProfile as l, type Plugin as m, type ConversationStorageAdapter as n, type StoredMessage as o, type SessionMeta as p, type SessionMetaPatch as q, type MemoryProvider as r, type MemoryId as s, type PreToolCallDecision as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { C as CustomTool, M as ModelSelection,
|
|
1
|
+
import { C as CustomTool, M as ModelSelection, Z as SDKUserMessage, $ as SendOptions, b as Run, G as GenerateOptions, j as GenerateRunResult, F as RunToCompletionOptions, H as RunToCompletionResult, S as SDKMessage, a6 as StreamToCompletionResult, a as McpServerConfig } from './run-BMo8yRwK.js';
|
|
2
|
+
import * as zod from 'zod';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Fork primitive public type contracts (T1.2, ADRs D110-D114).
|
|
@@ -602,6 +603,31 @@ interface StoredMessage {
|
|
|
602
603
|
/** Optional epoch-ms timestamp. Implementations MAY default to `Date.now()` on append. */
|
|
603
604
|
at?: number;
|
|
604
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* SE4 — light, session-level metadata stored ALONGSIDE the transcript (title +
|
|
608
|
+
* tag). Distinct from {@link StoredMessage} (which is per-turn content): this is
|
|
609
|
+
* per-conversation display metadata a host sets to build a session UI.
|
|
610
|
+
*
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
interface SessionMeta {
|
|
614
|
+
/** Human-facing title set via `renameSession`. Absent = untitled. */
|
|
615
|
+
readonly title?: string;
|
|
616
|
+
/** Single free-form tag set via `tagSession`. Absent = untagged. */
|
|
617
|
+
readonly tag?: string;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* SE4 — a partial update to {@link SessionMeta}. An omitted field is left
|
|
621
|
+
* unchanged; `tag: null` explicitly CLEARS the tag (distinct from omitting it).
|
|
622
|
+
*
|
|
623
|
+
* @public
|
|
624
|
+
*/
|
|
625
|
+
interface SessionMetaPatch {
|
|
626
|
+
/** Set the title; `null` explicitly CLEARS it (distinct from omitting it). */
|
|
627
|
+
readonly title?: string | null;
|
|
628
|
+
/** Set the tag; `null` explicitly CLEARS it (distinct from omitting it). */
|
|
629
|
+
readonly tag?: string | null;
|
|
630
|
+
}
|
|
605
631
|
/**
|
|
606
632
|
* Pluggable conversation persistence contract.
|
|
607
633
|
*
|
|
@@ -673,6 +699,19 @@ interface ConversationStorageAdapter {
|
|
|
673
699
|
* trims old turns past a soft cap; other backends typically no-op.
|
|
674
700
|
*/
|
|
675
701
|
compact?(conversationId: string, maxTurns: number): Promise<void>;
|
|
702
|
+
/**
|
|
703
|
+
* SE4 — optional: read the session-level metadata (title/tag) for a
|
|
704
|
+
* conversation. MUST return `undefined` when none was set (NOT throw).
|
|
705
|
+
* Adapters that cannot store side metadata MAY omit this — the session
|
|
706
|
+
* manager then reports rename/tag as unsupported rather than throwing.
|
|
707
|
+
*/
|
|
708
|
+
getSessionMeta?(conversationId: string): Promise<SessionMeta | undefined>;
|
|
709
|
+
/**
|
|
710
|
+
* SE4 — optional: apply a {@link SessionMetaPatch} to a conversation's
|
|
711
|
+
* session metadata (set title, set/clear tag). MUST create the metadata
|
|
712
|
+
* lazily. Adapters that cannot store side metadata MAY omit this.
|
|
713
|
+
*/
|
|
714
|
+
setSessionMeta?(conversationId: string, patch: SessionMetaPatch): Promise<void>;
|
|
676
715
|
/**
|
|
677
716
|
* Optional: dispose underlying handles (close DB pool, etc.).
|
|
678
717
|
* MUST be safe to call multiple times.
|
|
@@ -1335,7 +1374,12 @@ interface TelemetrySettings {
|
|
|
1335
1374
|
* @public
|
|
1336
1375
|
*/
|
|
1337
1376
|
interface AgentOptions {
|
|
1338
|
-
|
|
1377
|
+
/**
|
|
1378
|
+
* The model to run. SE8 — accepts a bare-string id shorthand
|
|
1379
|
+
* (`"openai/gpt-4o-mini"`, normalized to `{ id }`) OR a {@link ModelSelection}
|
|
1380
|
+
* object (use the object form to pass `params`).
|
|
1381
|
+
*/
|
|
1382
|
+
model?: string | ModelSelection;
|
|
1339
1383
|
/** Falls back to `THEOKIT_API_KEY`. */
|
|
1340
1384
|
apiKey?: string;
|
|
1341
1385
|
name?: string;
|
|
@@ -1627,6 +1671,12 @@ interface SDKAgent {
|
|
|
1627
1671
|
*/
|
|
1628
1672
|
readonly plugins?: SDKAgentPlugins;
|
|
1629
1673
|
send(message: string | SDKUserMessage, options?: SendOptions): Promise<Run>;
|
|
1674
|
+
/**
|
|
1675
|
+
* SE9 — integrated structured output. Runs the normal tool loop (the tools run
|
|
1676
|
+
* first) then coerces the final answer into the `output` Zod schema, returning a
|
|
1677
|
+
* validated, inferred-typed object. Sugar over `Agent.generateObject` (ADR D33).
|
|
1678
|
+
*/
|
|
1679
|
+
generate<T extends zod.ZodType>(message: string | SDKUserMessage, options: GenerateOptions<T>): Promise<GenerateRunResult<zod.z.infer<T>>>;
|
|
1630
1680
|
/** Fire-and-forget disposal. */
|
|
1631
1681
|
close(): void;
|
|
1632
1682
|
/** Re-read filesystem config (context, hooks, project MCP, subagents) without disposing. */
|
|
@@ -2096,4 +2146,4 @@ declare class Cron {
|
|
|
2096
2146
|
static status(_options?: CronStartOptions): Promise<CronSchedulerStatus>;
|
|
2097
2147
|
}
|
|
2098
2148
|
|
|
2099
|
-
export { type
|
|
2149
|
+
export { type CronStartOptions as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type BudgetUsageEvent as D, type CloudEnv as E, type CloudRepo as F, type GetAgentOptions as G, type ContextBudget as H, type ContextManagerKind as I, type ContextSnapshot as J, type ContextSource as K, type LocalOptions as L, type MemorySettings as M, type ContextSourceStatus as N, type CreateSkillSpec as O, type ProviderRoutingSettings as P, Cron as Q, type CronCreateOptions as R, type SystemPromptResolver as S, type CronGetOptions as T, type CronJob as U, type CronJobStatus as V, type CronListOptions as W, type CronOperationOptions as X, type CronRunOptions as Y, type CronRuntime as Z, type CronSchedulerStatus as _, type AgentDefinition as a, type GoalEvent as a0, type GoalOptions as a1, type GoalResult as a2, type HookName as a3, type InlineSkill as a4, type InvalidateCacheOptions as a5, type MemoryAdapter as a6, type MemoryAdapterCapabilities as a7, type MemoryContext as a8, type MemoryFact as a9, type TelemetrySettings as aA, createSkill as aB, definePlugin as aC, type MemoryProviderHandle as aa, type MemoryProviderInitOptions as ab, type MemoryRevision as ac, type MemoryToolSchema as ad, type MemoryTurnMessage as ae, type PersonalityPreset as af, type PluginContext as ag, type PostAssistantReplyContext as ah, type PreToolCallContext as ai, type PreUserSendContext as aj, type PreUserSendResult as ak, type ProviderCapability as al, type ProviderRoute as am, type RecordSessionSummaryArgs as an, type ResolvedProviderRoute as ao, type RunUntilIterator as ap, type SDKAgentPlugins as aq, type SDKAgentSkills as ar, type SDKArtifact as as, type SDKContextManager as at, type SDKPluginMetadata as au, type SDKProvidersManager as av, type SettingSource as aw, type SystemPromptContext as ax, type SystemPromptMemoryFact as ay, type SystemPromptSkillRef as az, type ContextSettings as b, type PluginsSettings as c, type SkillsSettings as d, type SDKAgent as e, type ListAgentsOptions as f, type ListResult as g, type SDKAgentInfo as h, type ListRunsOptions as i, type GetRunOptions as j, type AgentOperationOptions as k, type ProviderProfile as l, type Plugin as m, type ConversationStorageAdapter as n, type StoredMessage as o, type SessionMeta as p, type SessionMetaPatch as q, type MemoryProvider as r, type MemoryId as s, type PreToolCallDecision as t, type SDKProvider as u, type ActiveMemoryPassArgs as v, type ActiveMemoryPassResult as w, type AgentMemory as x, type BudgetCheck as y, type BudgetTotal as z };
|