@k9o/extension-runtime 0.0.0-stage → 1.6.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.
Files changed (40) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +166 -2
  4. package/package.json +30 -4
  5. package/src/base64.ts +11 -0
  6. package/src/bff-hook-discriminator.ts +72 -0
  7. package/src/client.ts +148 -0
  8. package/src/context.ts +70 -0
  9. package/src/dispatch-context.ts +58 -0
  10. package/src/guards.ts +35 -0
  11. package/src/http.ts +233 -0
  12. package/src/index.ts +163 -0
  13. package/src/insecure-http.ts +575 -0
  14. package/src/invoke-server.ts +150 -0
  15. package/src/kerror.ts +45 -0
  16. package/src/namespaces/ai-agent-runtime.ts +170 -0
  17. package/src/namespaces/ai.ts +56 -0
  18. package/src/namespaces/analytics.ts +122 -0
  19. package/src/namespaces/attributes.ts +34 -0
  20. package/src/namespaces/audit.ts +92 -0
  21. package/src/namespaces/auth-migrations.ts +176 -0
  22. package/src/namespaces/bff.ts +140 -0
  23. package/src/namespaces/collections.ts +104 -0
  24. package/src/namespaces/compliance.ts +48 -0
  25. package/src/namespaces/credentials.ts +85 -0
  26. package/src/namespaces/documents.ts +128 -0
  27. package/src/namespaces/egress.ts +31 -0
  28. package/src/namespaces/files.ts +96 -0
  29. package/src/namespaces/functions.ts +91 -0
  30. package/src/namespaces/hooks.ts +186 -0
  31. package/src/namespaces/identity.ts +97 -0
  32. package/src/namespaces/kibo.ts +60 -0
  33. package/src/namespaces/policy.ts +50 -0
  34. package/src/namespaces/streaming.ts +80 -0
  35. package/src/namespaces/tables.ts +166 -0
  36. package/src/namespaces/vectors.ts +243 -0
  37. package/src/namespaces/webhook-ingress.ts +98 -0
  38. package/src/namespaces/workflow.ts +65 -0
  39. package/src/types.ts +143 -0
  40. package/src/warden.ts +320 -0
package/src/context.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Sandbox context resolution for @k9o/extension-runtime.
3
+ *
4
+ * The K9O runtime injects context via environment variables for both
5
+ * runtime_tier: "wasm" (Bun WASM sandbox) and runtime_tier: "container"
6
+ * (Firecracker microVM). Extensions call createExtensionClient() with no
7
+ * args and the context is resolved automatically.
8
+ *
9
+ * Env vars injected by the sandbox:
10
+ * K9O_PLUGIN_TOKEN — scoped plugin token
11
+ * K9O_BASE_URL — platform API base, e.g. https://<orgSlug>.api.k9o.io (no path, no version — version in K9o-API-Version header)
12
+ * K9O_PROJECT_ID — bound project ID (e.g. proj_abc123) — data-model identity
13
+ * K9O_PROJECT_SLUG — bound project slug (e.g. my-project) — `@<slug>` URL path position
14
+ * K9O_EXTENSION_SLUG — extension's slug
15
+ * K9O_DEV_MODE — "true" when running inside k9o partner dev
16
+ * K9O_DEV_MODE_KEY_FINGERPRINT — SHA256 fingerprint of the synthetic dev key
17
+ */
18
+
19
+ import type { SandboxContext } from "./types.ts";
20
+
21
+ export function resolveContext(override?: Partial<SandboxContext>): SandboxContext {
22
+ const pluginToken =
23
+ override?.pluginToken ?? process.env["K9O_PLUGIN_TOKEN"] ?? "";
24
+ const baseUrl =
25
+ override?.baseUrl ??
26
+ process.env["K9O_BASE_URL"] ??
27
+ "";
28
+ const projectId =
29
+ override?.projectId ?? process.env["K9O_PROJECT_ID"] ?? "";
30
+ const projectSlug =
31
+ override?.projectSlug ?? process.env["K9O_PROJECT_SLUG"] ?? "";
32
+ const extensionSlug =
33
+ override?.extensionSlug ?? process.env["K9O_EXTENSION_SLUG"] ?? "";
34
+ const devMode =
35
+ override?.devMode ?? (process.env["K9O_DEV_MODE"] === "true" ? true : undefined);
36
+ const devModeKeyFingerprint =
37
+ override?.devModeKeyFingerprint ?? process.env["K9O_DEV_MODE_KEY_FINGERPRINT"];
38
+
39
+ if (!pluginToken) {
40
+ throw new Error(
41
+ "K9O_PLUGIN_TOKEN is not set. The K9O runtime must inject this before extension code runs.",
42
+ );
43
+ }
44
+ if (!baseUrl) {
45
+ throw new Error(
46
+ "K9O_BASE_URL is not set. The K9O runtime must inject this before extension code runs. " +
47
+ "Canonical form: https://<orgSlug>.api.k9o.io (no path segment; version in K9o-API-Version header).",
48
+ );
49
+ }
50
+ if (!projectId) {
51
+ throw new Error(
52
+ "K9O_PROJECT_ID is not set. The K9O runtime must inject this before extension code runs.",
53
+ );
54
+ }
55
+ if (!projectSlug) {
56
+ throw new Error(
57
+ "K9O_PROJECT_SLUG is not set. The K9O runtime must inject this before extension code runs.",
58
+ );
59
+ }
60
+
61
+ return {
62
+ pluginToken,
63
+ baseUrl,
64
+ projectId,
65
+ projectSlug,
66
+ extensionSlug,
67
+ ...(devMode !== undefined ? { devMode } : {}),
68
+ ...(devModeKeyFingerprint !== undefined ? { devModeKeyFingerprint } : {}),
69
+ };
70
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Per-dispatch client context.
3
+ *
4
+ * The plugin token and base URL are minted per invocation and ride the frame `context`, NOT the
5
+ * environment: a client built once at module load from `K9O_PLUGIN_TOKEN` holds a stale token on the
6
+ * second request in a warm sandbox. Handlers build their callback client per request:
7
+ *
8
+ * bff.handle("/x", (req, ctx) => {
9
+ * const k9o = createExtensionClient({ context: ctx.client });
10
+ * ...
11
+ * });
12
+ */
13
+
14
+ import type { SandboxContext } from "./types.ts";
15
+
16
+ /** What a handler receives alongside the request for the current dispatch. */
17
+ export type DispatchContext = {
18
+ /** Gateway-set discriminator for this frame. */
19
+ kind: string;
20
+ /** Override map for `createExtensionClient({ context })`, built from this dispatch's frame context. */
21
+ client: Partial<SandboxContext>;
22
+ /** Plugin-token expiry (ISO 8601) when the gateway supplies it. */
23
+ expiresAt?: string;
24
+ };
25
+
26
+ function str(v: unknown): string | undefined {
27
+ return typeof v === "string" && v.length > 0 ? v : undefined;
28
+ }
29
+
30
+ /**
31
+ * Build the per-dispatch context from the frame's `context`. The plugin token MUST come from the
32
+ * frame; there is no env fallback here, so a missing token is an error rather than a stale one.
33
+ * `baseUrl`, `projectId` and `projectSlug` are taken from the frame when the gateway supplies them
34
+ * and otherwise fall back to the sandbox env in `createExtensionClient`.
35
+ */
36
+ export function dispatchContextFromFrame(frameContext: unknown): DispatchContext {
37
+ if (frameContext === null || typeof frameContext !== "object" || Array.isArray(frameContext)) {
38
+ throw new Error("dispatch context missing: the frame carries no context object");
39
+ }
40
+ const c = frameContext as Record<string, unknown>;
41
+ const pluginToken = str(c["pluginToken"]);
42
+ if (pluginToken === undefined) throw new Error("dispatch context has no pluginToken");
43
+ const client: Partial<SandboxContext> = { pluginToken };
44
+ const baseUrl = str(c["baseUrl"]);
45
+ const projectId = str(c["projectId"]);
46
+ const projectSlug = str(c["projectSlug"]);
47
+ const extensionSlug = str(c["extensionSlug"]);
48
+ if (baseUrl !== undefined) client.baseUrl = baseUrl;
49
+ if (projectId !== undefined) client.projectId = projectId;
50
+ if (projectSlug !== undefined) client.projectSlug = projectSlug;
51
+ if (extensionSlug !== undefined) client.extensionSlug = extensionSlug;
52
+ const expiresAt = str(c["expiresAt"]);
53
+ return {
54
+ kind: String(c["kind"] ?? ""),
55
+ client,
56
+ ...(expiresAt !== undefined ? { expiresAt } : {}),
57
+ };
58
+ }
package/src/guards.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Type narrowing helpers for RuntimeKError ergonomics.
3
+ *
4
+ * Extension authors catch errors from k9o.* calls and use these helpers
5
+ * to narrow the error type before inspecting `e.code`:
6
+ *
7
+ * try {
8
+ * const docs = await k9o.documents.read("orders");
9
+ * } catch (e) {
10
+ * if (isKError(e) && e.code === "EXTENSION_PERMISSION_DENIED") {
11
+ * // handle gracefully
12
+ * }
13
+ * throw e;
14
+ * }
15
+ */
16
+
17
+ import { RuntimeKError } from "./kerror.ts";
18
+
19
+ /** Returns true when `e` is a RuntimeKError instance. */
20
+ export function isKError(e: unknown): e is RuntimeKError {
21
+ return e instanceof RuntimeKError;
22
+ }
23
+
24
+ /**
25
+ * Asserts that `e` is a RuntimeKError.
26
+ * Throws `TypeError` if not — use in contexts where a KError is
27
+ * structurally guaranteed and a non-KError indicates a programming error.
28
+ */
29
+ export function assertKError(e: unknown): asserts e is RuntimeKError {
30
+ if (!(e instanceof RuntimeKError)) {
31
+ throw new TypeError(
32
+ `Expected KError but received: ${e instanceof Error ? e.message : String(e)}`,
33
+ );
34
+ }
35
+ }
package/src/http.ts ADDED
@@ -0,0 +1,233 @@
1
+ /**
2
+ * HTTP transport for the @k9o/extension-runtime runtime SDK.
3
+ *
4
+ * Wraps fetch with:
5
+ * - Bearer token injection (scoped plugin token)
6
+ * - JSON request serialisation + response deserialisation
7
+ * - RuntimeKError throw on any non-2xx response
8
+ *
9
+ * `fetchFn` is dependency-injected so tests supply a mock without monkey-
10
+ * patching globalThis.fetch.
11
+ */
12
+
13
+ import { bytesToBase64 } from "./base64.ts";
14
+ import {
15
+ checkBaseUrlTransport,
16
+ fetchWithRedirectPolicy,
17
+ redirectRefusal,
18
+ resolveInsecureHttpOptIn,
19
+ type RedirectRefusal,
20
+ } from "./insecure-http.ts";
21
+ import { RuntimeKError } from "./kerror.ts";
22
+ import type { ApiResponse, KErrorPayload } from "./types.ts";
23
+
24
+ export type FetchFn = typeof globalThis.fetch;
25
+
26
+ export type Transport = {
27
+ get<T>(path: string): Promise<ApiResponse<T>>;
28
+ /**
29
+ * `extraHeaders` — for the rare route that requires a caller-supplied credential
30
+ * OUTSIDE the standard Authorization bearer (e.g.'s
31
+ * `X-K9O-Compliance-Delegate`). Never used to override Authorization/Content-Type/
32
+ * Accept — those stay platform-controlled; extraHeaders is additive only.
33
+ */
34
+ post<T>(path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<ApiResponse<T>>;
35
+ /** A POST that also reports the HTTP status, for the route whose 201 and 200 mean different things. */
36
+ postWithStatus<T>(path: string, body?: unknown): Promise<{ status: number; body: ApiResponse<T> }>;
37
+ /**
38
+ * A POST whose 2xx answer is raw bytes, not a JSON envelope. Returns the body bytes and the response headers.
39
+ * A non-2xx answer is still the JSON KError body and throws a RuntimeKError; the plain-http and redirect policy apply.
40
+ */
41
+ postBytes(path: string, body?: unknown): Promise<{ status: number; bytes: Uint8Array; headers: Headers }>;
42
+ patch<T>(path: string, body?: unknown): Promise<ApiResponse<T>>;
43
+ delete_(path: string): Promise<void>;
44
+ /** Raw fetch through the platform egress proxy — returns the platform-proxied Response. */
45
+ proxyFetch(
46
+ projectSlug: string,
47
+ extensionSlug: string,
48
+ url: string,
49
+ options?: RequestInit,
50
+ ): Promise<Response>;
51
+ };
52
+
53
+ /**
54
+ * Encode a `fetch` request body for the JSON envelope the egress proxy receives.
55
+ * Strings pass through unchanged. Binary bodies are base64-encoded and flagged with
56
+ * `bodyEncoding: "base64"` so the proxy can restore the exact bytes; a plain `JSON.stringify`
57
+ * of a `Uint8Array` silently produces `{"0":1,...}`. Body types that cannot be carried
58
+ * faithfully (streams, Blob, FormData) throw instead of being corrupted.
59
+ */
60
+ export function encodeProxyBody(
61
+ body: RequestInit["body"],
62
+ ): { body?: string; bodyEncoding?: "base64" } {
63
+ if (body === undefined || body === null) return {};
64
+ if (typeof body === "string") return { body };
65
+ if (body instanceof URLSearchParams) return { body: body.toString() };
66
+ if (body instanceof ArrayBuffer) return { body: bytesToBase64(new Uint8Array(body)), bodyEncoding: "base64" };
67
+ if (ArrayBuffer.isView(body)) {
68
+ return { body: bytesToBase64(new Uint8Array(body.buffer, body.byteOffset, body.byteLength)), bodyEncoding: "base64" };
69
+ }
70
+ throw new TypeError(
71
+ "k9o.fetch supports string, URLSearchParams, ArrayBuffer and typed-array request bodies; convert Blob, FormData and streams to bytes first",
72
+ );
73
+ }
74
+
75
+ /** Response header the egress proxy sets on every pass-through of an upstream response. */
76
+ export const EGRESS_PROXIED_HEADER = "x-k9o-egress";
77
+
78
+ export type TransportOptions = {
79
+ /**
80
+ * Allow plain `http:` to a host that is not loopback. `true` or `false` wins over the `K9O_ALLOW_INSECURE_HTTP`
81
+ * environment variable (`1` or `true`); left unset, the environment decides. Never stored. A platform service sets it on
82
+ * the one client that needs it, not the environment process-wide.
83
+ */
84
+ allowInsecureHttp?: boolean;
85
+ };
86
+
87
+ const refusalError = (r: RedirectRefusal): RuntimeKError =>
88
+ new RuntimeKError(r.code, r.message, r.context, r.recommendation === null ? null : { hint: r.recommendation });
89
+
90
+ export function createTransport(
91
+ baseUrl: string,
92
+ pluginToken: string,
93
+ fetchFn: FetchFn = globalThis.fetch,
94
+ transportOptions: TransportOptions = {},
95
+ ): Transport {
96
+ // Plain http off loopback is refused when the client is built, unless the caller opts in on purpose.
97
+ const check = checkBaseUrlTransport(baseUrl, { allowInsecureHttp: transportOptions.allowInsecureHttp });
98
+ if (check.refusal !== null) {
99
+ throw new RuntimeKError(check.refusal.code, check.refusal.message, check.refusal.context, {
100
+ hint: check.refusal.recommendation,
101
+ });
102
+ }
103
+ const allowInsecureHttp = resolveInsecureHttpOptIn(transportOptions.allowInsecureHttp);
104
+ const headers = (): Record<string, string> => ({
105
+ Authorization: `Bearer ${pluginToken}`,
106
+ "Content-Type": "application/json",
107
+ Accept: "application/json",
108
+ });
109
+
110
+ /** Sends one request through the redirect policy and throws a RuntimeKError on any non-2xx answer. */
111
+ async function send(
112
+ method: string,
113
+ path: string,
114
+ body: unknown,
115
+ extraHeaders: Record<string, string> | undefined,
116
+ accept?: string,
117
+ ): Promise<Response> {
118
+ const url = `${baseUrl}${path}`;
119
+ const baseHeaders = accept === undefined ? headers() : { ...headers(), Accept: accept };
120
+ const init: RequestInit = {
121
+ method,
122
+ headers: extraHeaders === undefined ? baseHeaders : { ...baseHeaders, ...extraHeaders },
123
+ };
124
+ if (body !== undefined) {
125
+ init.body = JSON.stringify(body);
126
+ }
127
+ // Redirects are followed by hand: a cross-origin hop drops the bearer token and every other credential header.
128
+ const res = await fetchWithRedirectPolicy(
129
+ fetchFn,
130
+ url,
131
+ init as Parameters<typeof fetchWithRedirectPolicy>[2],
132
+ { allowInsecureHttp, makeError: refusalError },
133
+ );
134
+ if (!res.ok) {
135
+ const err = (await res.json().catch(() => ({
136
+ code: "UNKNOWN_ERROR",
137
+ message: `HTTP ${res.status}`,
138
+ context: {},
139
+ recommendation: null,
140
+ }))) as KErrorPayload;
141
+ throw new RuntimeKError(err.code, err.message, err.context, err.recommendation);
142
+ }
143
+ return res;
144
+ }
145
+
146
+ async function requestWithStatus<T>(
147
+ method: string,
148
+ path: string,
149
+ body?: unknown,
150
+ extraHeaders?: Record<string, string>,
151
+ ): Promise<{ status: number; body: T }> {
152
+ const res = await send(method, path, body, extraHeaders);
153
+ if (res.status === 204) {
154
+ return { status: 204, body: undefined as T };
155
+ }
156
+ return { status: res.status, body: (await res.json()) as T };
157
+ }
158
+
159
+ async function request<T>(
160
+ method: string,
161
+ path: string,
162
+ body?: unknown,
163
+ extraHeaders?: Record<string, string>,
164
+ ): Promise<T> {
165
+ return (await requestWithStatus<T>(method, path, body, extraHeaders)).body;
166
+ }
167
+
168
+ return {
169
+ get: <T>(path: string) => request<ApiResponse<T>>("GET", path),
170
+ post: <T>(path: string, body?: unknown, extraHeaders?: Record<string, string>) =>
171
+ request<ApiResponse<T>>("POST", path, body, extraHeaders),
172
+ postWithStatus: <T>(path: string, body?: unknown) =>
173
+ requestWithStatus<ApiResponse<T>>("POST", path, body),
174
+ async postBytes(path, body) {
175
+ const res = await send("POST", path, body, undefined, "application/octet-stream");
176
+ return { status: res.status, bytes: new Uint8Array(await res.arrayBuffer()), headers: res.headers };
177
+ },
178
+ patch: <T>(path: string, body?: unknown) =>
179
+ request<ApiResponse<T>>("PATCH", path, body),
180
+ delete_: (path: string) => request<void>("DELETE", path),
181
+
182
+ async proxyFetch(projectSlug, extensionSlug, url, options) {
183
+ const proxyPath = `/@${projectSlug}/extensions/${extensionSlug}/egress`;
184
+ // Headers may be a `Headers` instance or tuple array; JSON.stringify would drop both.
185
+ // `forEach`, not `Object.fromEntries(headers)`: a consumer compiling with lib DOM but not DOM.Iterable
186
+ // (k9o-salesforce) cannot iterate a `Headers`, and the SDK source is typechecked in the consumer.
187
+ let headerRecord: Record<string, string> | undefined;
188
+ if (options?.headers !== undefined) {
189
+ headerRecord = {};
190
+ const target = headerRecord;
191
+ new Headers(options.headers).forEach((value, key) => {
192
+ target[key] = value;
193
+ });
194
+ }
195
+ const proxyBody = {
196
+ url,
197
+ method: options?.method ?? "GET",
198
+ headers: headerRecord,
199
+ ...encodeProxyBody(options?.body),
200
+ };
201
+ // `redirect: "manual"`, never followed: a proxied UPSTREAM 3xx (marked below) is the caller's data and is returned as it is,
202
+ // and a 3xx the proxy endpoint itself sends is refused, so the bearer token is never sent on.
203
+ const res = await fetchFn(`${baseUrl}${proxyPath}`, {
204
+ method: "POST",
205
+ headers: headers(),
206
+ body: JSON.stringify(proxyBody),
207
+ redirect: "manual",
208
+ });
209
+ if (res.headers.get(EGRESS_PROXIED_HEADER) !== "proxied" && ((res.status >= 300 && res.status <= 399) || res.type === "opaqueredirect")) {
210
+ const location = res.headers.get("location");
211
+ let origin: string | null = null;
212
+ try {
213
+ origin = location === null ? null : new URL(location, baseUrl).origin;
214
+ } catch {
215
+ origin = null;
216
+ }
217
+ throw refusalError(redirectRefusal(res.status, origin, "not_a_redirect"));
218
+ }
219
+ // The proxy marks every pass-through of an UPSTREAM response with `x-k9o-egress: proxied`, so an
220
+ // upstream 4xx/5xx (an S3 SlowDown, a vendor 500) reaches the caller with its own status, body and
221
+ // headers. An unmarked non-2xx/3xx response was produced by the proxy itself (grant or binding
222
+ // denied, SSRF-blocked, timeout, size cap) and is thrown as a KError.
223
+ if (res.headers.get(EGRESS_PROXIED_HEADER) === "proxied" || res.ok) return res;
224
+ const err = (await res.json().catch(() => ({
225
+ code: "EGRESS_PROXY_ERROR",
226
+ message: `Egress proxy returned HTTP ${res.status}`,
227
+ context: {},
228
+ recommendation: null,
229
+ }))) as KErrorPayload;
230
+ throw new RuntimeKError(err.code, err.message, err.context, err.recommendation);
231
+ },
232
+ };
233
+ }
package/src/index.ts ADDED
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @k9o/extension-runtime — runtime SDK for extensions running inside the K9O sandbox.
3
+ *
4
+ * Primary export: `createExtensionClient()` — factory for dependency injection.
5
+ * Convenience export: `k9o` — singleton that reads context from env vars.
6
+ *
7
+ * KError: thrown on any platform error; catch with `instanceof KError`.
8
+ */
9
+
10
+ export type { TransportOptions } from "./http.ts";
11
+ export { createExtensionClient, type ExtensionClient, type CreateExtensionClientOptions } from "./client.ts";
12
+ export type { BffNamespace, BffHandler, BffRequest, BffResponse, BffOperator } from "./namespaces/bff.ts";
13
+ export type {
14
+ FunctionsNamespace,
15
+ FunctionHandler,
16
+ FunctionInvocationRequest,
17
+ FunctionDispatchResult,
18
+ } from "./namespaces/functions.ts";
19
+ export { routeExtensionInvocation, DISPATCH_KINDS, type DispatchKind, type DiscriminatorDeps, type RefuseReason } from "./bff-hook-discriminator.ts";
20
+ export {
21
+ makeHooks,
22
+ HOOK_EVENTS,
23
+ HookRejectedError,
24
+ type HooksNamespace,
25
+ type HookHandler,
26
+ type HookPayload,
27
+ type MonitorResult,
28
+ type CallDecided,
29
+ type CallDecidedHandler,
30
+ type CallDecidedOutcome,
31
+ } from "./namespaces/hooks.ts";
32
+ export { makeWebhookIngress, type WebhookIngressNamespace, type WebhookHandler, type WebhookDelivery } from "./namespaces/webhook-ingress.ts";
33
+ export { dispatchContextFromFrame, type DispatchContext } from "./dispatch-context.ts";
34
+ export { startInvokeServer, type InvokeServerHandle, type InvokeServerOptions } from "./invoke-server.ts";
35
+ export { toConditions } from "./namespaces/tables.ts";
36
+ export type {
37
+ TablesNamespace,
38
+ TablesUpsertOptions,
39
+ TablesUpdateOptions,
40
+ TablesQueryOptions,
41
+ TablesWriteResult,
42
+ TableRow,
43
+ TableFilter,
44
+ TableFilterOp,
45
+ TableCondition,
46
+ TableOrder,
47
+ } from "./namespaces/tables.ts";
48
+ export type {
49
+ StreamingNamespace,
50
+ StreamingTransport,
51
+ SubscribeOptions,
52
+ } from "./namespaces/streaming.ts";
53
+ export type {
54
+ AgentRuntime,
55
+ AuditEvent,
56
+ AuditReadOptions,
57
+ WriteProposal,
58
+ WriteProposalResult,
59
+ // `GenerateOptions` / `GenerateResult` from agent-runtime aliased to avoid
60
+ // collision with the `k9o.ai.generate()` types in ./types.ts.
61
+ // The binding shape is preserved verbatim on the AgentRuntime interface
62
+ // itself.
63
+ GenerateOptions as AgentGenerateOptions,
64
+ GenerateResult as AgentGenerateResult,
65
+ } from "./namespaces/ai-agent-runtime.ts";
66
+ export { warden_gate, type WardenDecision } from "./warden.ts";
67
+ export type {
68
+ VectorsNamespace,
69
+ VectorRow,
70
+ VectorsUpsertResult,
71
+ VectorsDeleteQuery,
72
+ VectorsDeleteResult,
73
+ VectorSearchQuery,
74
+ VectorSearchResult,
75
+ VectorSearchResultRow,
76
+ VectorsUpsertOptions,
77
+ } from "./namespaces/vectors.ts";
78
+ export type { FilesNamespace, FilesReadOptions, FilesReadResult } from "./namespaces/files.ts";
79
+ export type {
80
+ AuthMigrationsNamespace,
81
+ AuthMigrationsCreateRunBody,
82
+ AuthMigrationsCreateUsersOptions,
83
+ AuthMigrationsCreateUsersResult,
84
+ AuthMigrationRun,
85
+ AuthMigrationSource,
86
+ AuthMigrationPasswordHandling,
87
+ AuthMigrationUser,
88
+ AuthMigrationUserResult,
89
+ } from "./namespaces/auth-migrations.ts";
90
+ export {
91
+ AUTH_MIGRATIONS_MAX_USERS_PER_CALL,
92
+ AUTH_MIGRATIONS_HASH_EXPIRY_MAX_DAYS,
93
+ AUTH_MIGRATIONS_ROLLBACK_RETENTION_MAX_DAYS,
94
+ } from "./namespaces/auth-migrations.ts";
95
+ export { RuntimeKError as KError, RuntimeKError, QueuedWriteError } from "./kerror.ts";
96
+ export { isKError, assertKError } from "./guards.ts";
97
+ export type { SandboxContext } from "./types.ts";
98
+
99
+ /**
100
+ * Host-theme helpers live in `@k9o/extension-manifest`
101
+ * alongside `iframe-bridge` — the architecturally-correct package for
102
+ * iframe-side helpers. Spec's `@k9o/extension-runtime` import-path mention is
103
+ * a wording slip; the substance is unchanged (canonical authoring import
104
+ * remains `import { createHostTheme } from "@k9o/extension-manifest"`). Mirrored here
105
+ * for spec-import-path compliance now that the workspace dependency is
106
+ * configured — both import paths resolve to the same
107
+ * implementation, not a duplicate.
108
+ */
109
+ export {
110
+ createHostTheme,
111
+ HOST_THEME_PROPOSE_TIMEOUT_MS,
112
+ HOST_THEME_REJECT_REASONS,
113
+ type DocumentSink,
114
+ type HostTheme,
115
+ type HostThemeOptions,
116
+ type ProposeResult,
117
+ type ThemeIntent,
118
+ type ThemeIntentMessage,
119
+ type ThemeRejectReason,
120
+ type ThemeUpdatePayload,
121
+ } from "@k9o/extension-manifest";
122
+ export type { IdentityProviderConfig, IdentityProvidersNamespace, ListIdentityProvidersOptions } from "./namespaces/identity.ts";
123
+ export type {
124
+ Document,
125
+ DocumentFilter,
126
+ Collection,
127
+ AttributeMap,
128
+ IdentityClaims,
129
+ PolicyResult,
130
+ KiboEncryptResult,
131
+ KiboDecryptResult,
132
+ GenerateOptions,
133
+ GenerateResult,
134
+ EmbedOptions,
135
+ EmbedResult,
136
+ WorkflowTriggerResult,
137
+ WorkflowRunStatus,
138
+ Meta,
139
+ ApiResponse,
140
+ CredentialAttestationBundle,
141
+ } from "./types.ts";
142
+ export type {
143
+ CollectionSchema,
144
+ ProtectedColumn,
145
+ CollectionSchemaColumn,
146
+ CollectionSchemaIndex,
147
+ CollectionSchemaRelationship,
148
+ ColumnProtection,
149
+ } from "./namespaces/collections.ts";
150
+ export type { CredentialsNamespace, CredentialSendRequest, CredentialSendResult } from "./namespaces/credentials.ts";
151
+ export type { ComplianceNamespace } from "./namespaces/compliance.ts";
152
+ export type {
153
+ AnalyticsNamespace,
154
+ AnalyticsPartitionConstraint,
155
+ AnalyticsPartitionFilter,
156
+ AnalyticsPartitionScalar,
157
+ AnalyticsReadOptions,
158
+ AnalyticsReadPage,
159
+ AnalyticsReadSchemaColumn,
160
+ AnalyticsWriteOnError,
161
+ AnalyticsWriteOptions,
162
+ AnalyticsWriteResult,
163
+ } from "./namespaces/analytics.ts";