@arnilo/prism 0.0.1

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 (106) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +139 -0
  4. package/dist/agents.d.ts +5 -0
  5. package/dist/agents.js +439 -0
  6. package/dist/cli-runner.d.ts +33 -0
  7. package/dist/cli-runner.js +167 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.js +10 -0
  10. package/dist/compaction.d.ts +9 -0
  11. package/dist/compaction.js +67 -0
  12. package/dist/config.d.ts +17 -0
  13. package/dist/config.js +69 -0
  14. package/dist/contracts.d.ts +670 -0
  15. package/dist/contracts.js +2 -0
  16. package/dist/contributions.d.ts +35 -0
  17. package/dist/contributions.js +47 -0
  18. package/dist/credentials.d.ts +22 -0
  19. package/dist/credentials.js +63 -0
  20. package/dist/extensions.d.ts +25 -0
  21. package/dist/extensions.js +131 -0
  22. package/dist/index.d.ts +47 -0
  23. package/dist/index.js +28 -0
  24. package/dist/input.d.ts +57 -0
  25. package/dist/input.js +225 -0
  26. package/dist/manifests.d.ts +28 -0
  27. package/dist/manifests.js +108 -0
  28. package/dist/middleware.d.ts +15 -0
  29. package/dist/middleware.js +49 -0
  30. package/dist/mock-provider.d.ts +6 -0
  31. package/dist/mock-provider.js +14 -0
  32. package/dist/models.d.ts +8 -0
  33. package/dist/models.js +25 -0
  34. package/dist/node/config.d.ts +9 -0
  35. package/dist/node/config.js +51 -0
  36. package/dist/node/session-store-jsonl.d.ts +17 -0
  37. package/dist/node/session-store-jsonl.js +134 -0
  38. package/dist/node/settings.d.ts +7 -0
  39. package/dist/node/settings.js +26 -0
  40. package/dist/node/trust.d.ts +13 -0
  41. package/dist/node/trust.js +56 -0
  42. package/dist/provider-events.d.ts +15 -0
  43. package/dist/provider-events.js +30 -0
  44. package/dist/provider-packages.d.ts +4 -0
  45. package/dist/provider-packages.js +12 -0
  46. package/dist/provider-request-policy.d.ts +9 -0
  47. package/dist/provider-request-policy.js +49 -0
  48. package/dist/providers/openai-compatible.d.ts +9 -0
  49. package/dist/providers/openai-compatible.js +197 -0
  50. package/dist/providers.d.ts +8 -0
  51. package/dist/providers.js +25 -0
  52. package/dist/redaction.d.ts +11 -0
  53. package/dist/redaction.js +68 -0
  54. package/dist/resources.d.ts +5 -0
  55. package/dist/resources.js +30 -0
  56. package/dist/retry.d.ts +11 -0
  57. package/dist/retry.js +48 -0
  58. package/dist/rpc.d.ts +18 -0
  59. package/dist/rpc.js +187 -0
  60. package/dist/security.d.ts +51 -0
  61. package/dist/security.js +60 -0
  62. package/dist/session-stores.d.ts +25 -0
  63. package/dist/session-stores.js +116 -0
  64. package/dist/settings.d.ts +3 -0
  65. package/dist/settings.js +26 -0
  66. package/dist/skills.d.ts +8 -0
  67. package/dist/skills.js +34 -0
  68. package/dist/system-prompts.d.ts +6 -0
  69. package/dist/system-prompts.js +47 -0
  70. package/dist/testing/provider-conformance.d.ts +36 -0
  71. package/dist/testing/provider-conformance.js +164 -0
  72. package/dist/tools.d.ts +25 -0
  73. package/dist/tools.js +109 -0
  74. package/docs/agent-session-runtime.md +167 -0
  75. package/docs/api-page-template.md +32 -0
  76. package/docs/cli-rpc.md +140 -0
  77. package/docs/compaction-and-retry.md +177 -0
  78. package/docs/compaction-llm.md +108 -0
  79. package/docs/compaction-observational-memory.md +123 -0
  80. package/docs/configuration-and-manifests.md +142 -0
  81. package/docs/context-and-skills.md +113 -0
  82. package/docs/contribution-registries.md +118 -0
  83. package/docs/credentials-and-redaction.md +122 -0
  84. package/docs/extensions.md +139 -0
  85. package/docs/index.md +56 -0
  86. package/docs/input-and-prompt-assembly.md +168 -0
  87. package/docs/middleware-hooks.md +123 -0
  88. package/docs/node-filesystem-config.md +85 -0
  89. package/docs/node-jsonl-session-store.md +81 -0
  90. package/docs/provider-conformance.md +109 -0
  91. package/docs/provider-layer.md +172 -0
  92. package/docs/provider-packages.md +171 -0
  93. package/docs/providers/kimi.md +110 -0
  94. package/docs/providers/openai-compatible.md +125 -0
  95. package/docs/providers/openai.md +131 -0
  96. package/docs/providers/opencode-go.md +103 -0
  97. package/docs/providers/openrouter.md +105 -0
  98. package/docs/providers/zai.md +108 -0
  99. package/docs/public-contracts.md +375 -0
  100. package/docs/release-and-install.md +141 -0
  101. package/docs/resource-loading.md +97 -0
  102. package/docs/session-stores-and-branching.md +119 -0
  103. package/docs/settings-auth-trust-security.md +73 -0
  104. package/docs/system-prompts.md +116 -0
  105. package/docs/tools.md +151 -0
  106. package/package.json +93 -0
@@ -0,0 +1,131 @@
1
+ # OpenAI provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-openai` provides explicit, side-effect-free setup for the OpenAI
6
+ Responses API (`createOpenAIResponsesProvider`) and OpenAI Codex
7
+ subscription Responses (`createOpenAICodexProvider`), plus a Codex OAuth provider
8
+ implementing RFC 7636 PKCE browser/device-code login.
9
+
10
+ The package registers providers, model metadata, and `api_key` / `oauth` auth
11
+ methods through `createExtensionKernel().load([...])` — no
12
+ hidden globals, no automatic provider/model resolution.
13
+
14
+ ## When to use it
15
+
16
+ Use it when a host app wants OpenAI Responses or Codex-backed runs through
17
+ Prism's `AgentSession` runtime, or needs a Codex OAuth login flow (ChatGPT
18
+ Plus/Pro/Codex subscription).
19
+
20
+ Do not use it for Chat Completions-only endpoints (use
21
+ [`@arnilo/prism/providers/openai-compatible`](openai-compatible.md) instead), automatic
22
+ credential discovery, or real-network tests.
23
+
24
+ ## Inputs / request
25
+
26
+ ```ts
27
+ import { createOpenAIProviderPackage } from "@arnilo/prism-provider-openai";
28
+
29
+ createOpenAIProviderPackage(options: OpenAIProviderPackageOptions): ProviderPackage
30
+ ```
31
+
32
+ | Field | Type | Purpose |
33
+ | --- | --- | --- |
34
+ | `apiKey` | `CredentialValueSource` | Direct/callback/resolver source for the Responses API key. |
35
+ | `codexAccessToken` | `CredentialValueSource` | Access token for the Codex subscription backend. |
36
+ | `fetch` | `typeof fetch` | Optional fetch implementation for tests/hosts. |
37
+ | `baseUrl` | `string` | Overrides `https://api.openai.com/v1`. |
38
+ | `codexBaseUrl` | `string` | Overrides `https://chatgpt.com/backend-api/codex`. |
39
+
40
+ `ProviderRequest.options.sessionId`, `cacheKey`, `cacheRetention`, `headers`,
41
+ `compat`, and `extra` map to request headers/payload fields.
42
+
43
+ ## Outputs / response / events
44
+
45
+ | Surface | Behavior |
46
+ | --- | --- |
47
+ | Provider stream | Prism text, thinking (downgraded to text), `tool_call` deltas/finals, `usage`, `done`, redacted `error` events. |
48
+ | Block preservation | Text, thinking (downgraded), assistant `tool_call` → `function_call` input items, `tool_result` → `function_call_output` input items, images when `capabilities.input` includes `"image"`. |
49
+ | Auth methods | `api_key` for `openai`; `oauth` for `openai-codex`. |
50
+
51
+ Unsupported block placements or unclaimed images fail before `fetch`.
52
+
53
+ ## Request/response example
54
+
55
+ Responses request body (Codex subscription shape, abbreviated):
56
+
57
+ ```json
58
+ {
59
+ "model": "gpt-5-codex",
60
+ "instructions": "You are a coding agent.",
61
+ "input": [{ "type": "message", "role": "user", "content": [{ "type": "input_text", "text": "Hello" }] }],
62
+ "stream": true
63
+ }
64
+ ```
65
+
66
+ OAuth authorize URL (PKCE, `S256`):
67
+
68
+ ```
69
+ https://auth.openai.com/authorize?response_type=code&client_id=...&code_challenge=<base64url(SHA-256(verifier))>&code_challenge_method=S256&redirect_uri=<redirect>&scope=<scope>
70
+ ```
71
+
72
+ ## Implementation example
73
+
74
+ ```ts
75
+ import { createExtensionKernel, createEnvCredentialResolver } from "@arnilo/prism";
76
+ import { createOpenAIProviderPackage } from "@arnilo/prism-provider-openai";
77
+
78
+ const kernel = createExtensionKernel();
79
+ await kernel.load([
80
+ createOpenAIProviderPackage({
81
+ apiKey: createEnvCredentialResolver({ OPENAI_API_KEY: "fake" }, { openai: "OPENAI_API_KEY" }),
82
+ }),
83
+ ]);
84
+ ```
85
+
86
+ OAuth login (caller-supplied callbacks, mocked in tests):
87
+
88
+ ```ts
89
+ import { createOpenAICodexOAuthProvider, createPkceVerifier, computeS256Challenge } from "@arnilo/prism-provider-openai";
90
+
91
+ const oauth = createOpenAICodexOAuthProvider({
92
+ redirectUri: "http://localhost:1455/auth/callback",
93
+ scope: "openai.chatgpt",
94
+ // callbacks supplied/brand-owned
95
+ });
96
+ const verifier = createPkceVerifier();
97
+ const challenge = computeS256Challenge(verifier);
98
+ ```
99
+
100
+ ## Extension and configuration notes
101
+
102
+ - `createOpenAIProviderPackage` wires the API-key Responses backend and the Codex
103
+ OAuth backend separately via `baseUrl` and `codexBaseUrl`; a Codex OAuth access
104
+ token never silently hits the plain `/v1` endpoint.
105
+ - `OpenAICodexOAuthOptions.redirectUri` and `scope` are forwarded to the authorize
106
+ URL; `scope` is also sent on the device-code POST body when supplied.
107
+ - Hosts/apps control model selection, credential resolution, and cache policy per
108
+ run/model through `RunOptions` and `ModelConfig.compat`.
109
+ - OAuth browser/device-code flows run only when the caller explicitly invokes the
110
+ OAuth provider.
111
+
112
+ ## Security and performance notes
113
+
114
+ - No network calls during import, setup, build, or default tests.
115
+ - No automatic environment, file, keychain, or shell credential lookup; Prism never
116
+ reads `process.env` on its own.
117
+ - API keys/access tokens are resolved per request from caller-supplied values or
118
+ resolvers; OAuth errors redact known token values (`[REDACTED]`).
119
+ - The PKCE verifier is exchanged at the token endpoint, never sent on the authorize
120
+ URL.
121
+ - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
122
+ provider-specific env names; default `npm test` is network-free.
123
+
124
+ ## Related APIs
125
+
126
+ - [Provider packages](../provider-packages.md): `defineProviderPackage`, auth
127
+ methods, request/cache policies, model compat metadata.
128
+ - [Credentials and redaction](../credentials-and-redaction.md):
129
+ `createEnvCredentialResolver`, `resolveCredentialValue`, `redactSecrets`.
130
+ - [OpenAI-compatible provider](openai-compatible.md): Chat Completions-only adapter.
131
+ - [Provider conformance](../provider-conformance.md): network-free adapter tests.
@@ -0,0 +1,103 @@
1
+ # OpenCode Go provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-opencode-go` provides explicit, side-effect-free setup for the
6
+ OpenCode Go API-key provider using Prism model metadata and
7
+ OpenAI-compatible/Anthropic-compatible routes with `x-opencode-session`
8
+ cache/session headers.
9
+
10
+ The package registers a provider, default model metadata, and an `api_key` auth
11
+ method through `createExtensionKernel().load([...])`.
12
+
13
+ ## When to use it
14
+
15
+ Use it when a host app wants to run an OpenAI-compatible or Anthropic-compatible
16
+ OpenCode Go endpoint through Prism's `AgentSession` runtime with per-request
17
+ session/cache headers.
18
+
19
+ Do not use it for automatic credential discovery, catalog fetches, or
20
+ real-network tests.
21
+
22
+ ## Inputs / request
23
+
24
+ ```ts
25
+ import { createOpenCodeGoProviderPackage } from "@arnilo/prism-provider-opencode-go";
26
+
27
+ createOpenCodeGoProviderPackage(options: OpenCodeGoProviderPackageOptions): ProviderPackage
28
+ ```
29
+
30
+ | Field | Type | Purpose |
31
+ | --- | --- | --- |
32
+ | `apiKey` | `CredentialValueSource` | Direct/callback/resolver API-key source. |
33
+ | `fetch` | `typeof fetch` | Optional fetch implementation for tests/hosts. |
34
+ | `baseUrl` | `string` | Overrides the OpenCode Go base URL. |
35
+ | `models` | `readonly ModelConfig[]` | Overrides `openCodeGoModels` defaults. |
36
+
37
+ `ProviderRequest.options.sessionId` maps to the `x-opencode-session` header;
38
+ `cacheKey`/`cacheRetention` map to OpenCode cache retention.
39
+
40
+ ## Outputs / response / events
41
+
42
+ | Surface | Behavior |
43
+ | --- | --- |
44
+ | Provider stream | Prism text, thinking, tool-call delta/final, `usage`, `done`, redacted `error`. |
45
+ | Session/cache | `x-opencode-session` and cache headers added before `generate()`. |
46
+ | Auth method | `api_key` for `opencode-go`, credential name `apiKey`. |
47
+
48
+ ## Request/response example
49
+
50
+ Example headers added before fetch:
51
+
52
+ ```json
53
+ {
54
+ "Authorization": "Bearer <resolved-key>",
55
+ "x-opencode-session": "<ProviderRequest.options.sessionId>"
56
+ }
57
+ ```
58
+
59
+ ## Implementation example
60
+
61
+ ```ts
62
+ import { createExtensionKernel } from "@arnilo/prism";
63
+ import { createOpenCodeGoProviderPackage } from "@arnilo/prism-provider-opencode-go";
64
+
65
+ const kernel = createExtensionKernel();
66
+ await kernel.load([createOpenCodeGoProviderPackage({ apiKey: "fake-opencode-key" })]);
67
+ ```
68
+
69
+ Override model metadata:
70
+
71
+ ```ts
72
+ import { createOpenCodeGoProviderPackage, openCodeGoModels } from "@arnilo/prism-provider-opencode-go";
73
+
74
+ await kernel.load([
75
+ createOpenCodeGoProviderPackage({ apiKey: "fake", models: openCodeGoModels }),
76
+ ]);
77
+ ```
78
+
79
+ ## Extension and configuration notes
80
+
81
+ - Hosts choose base URL, model list, credential source, and `fetch` impl.
82
+ - The serializer is inherited from the OpenAI-compatible route; Anthropic-compatible
83
+ routes preserve `tool_use`/`tool_result` blocks.
84
+ - Package contributes models via the extension `api` and an `api_key` auth method.
85
+
86
+ ## Security and performance notes
87
+
88
+ - No network calls during import, setup, build, or default tests.
89
+ - No automatic environment, file, keychain, or shell credential lookup.
90
+ - API keys are resolved per request from caller-supplied values or resolvers and
91
+ redacted from errors.
92
+ - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
93
+ provider-specific env names; default tests are network-free.
94
+
95
+ ## Related APIs
96
+
97
+ - [Provider packages](../provider-packages.md): `defineProviderPackage`,
98
+ `ModelConfig`, request/cache policies.
99
+ - [Credentials and redaction](../credentials-and-redaction.md):
100
+ `resolveCredentialValue`, `redactSecrets`.
101
+ - [OpenAI-compatible provider](openai-compatible.md): underlying Chat Completions
102
+ adapter.
103
+ - [Provider conformance](../provider-conformance.md): network-free adapter tests.
@@ -0,0 +1,105 @@
1
+ # OpenRouter provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-openrouter` provides explicit, side-effect-free setup for the
6
+ OpenRouter API-key provider with app-controlled model catalog and per-model cache
7
+ policy/routing overrides.
8
+
9
+ The package registers a provider, caller-supplied model metadata, and an
10
+ `api_key` auth method through `createExtensionKernel().load([...])`. Apps control the model catalog instead of
11
+ accepting a fetched or hard-coded one.
12
+
13
+ ## When to use it
14
+
15
+ Use it when a host app wants OpenRouter routing passthrough, reasoning controls,
16
+ and per-model cache policy through Prism's `AgentSession` runtime, and needs to
17
+ override cache behavior per model rather than accept a single hard-coded policy.
18
+
19
+ Do not use it for catalog fetches, automatic credential discovery, or
20
+ real-network tests.
21
+
22
+ ## Inputs / request
23
+
24
+ ```ts
25
+ import { createOpenRouterProviderPackage, defineOpenRouterModel } from "@arnilo/prism-provider-openrouter";
26
+
27
+ createOpenRouterProviderPackage(options: OpenRouterProviderPackageOptions): ProviderPackage
28
+ defineOpenRouterModel(config: OpenRouterModelConfig): OpenRouterModelConfig
29
+ ```
30
+
31
+ | Field | Type | Purpose |
32
+ | --- | --- | --- |
33
+ | `apiKey` | `CredentialValueSource` | Direct/callback/resolver API-key source. |
34
+ | `fetch` | `typeof fetch` | Optional fetch implementation for tests/hosts. |
35
+ | `baseUrl` | `string` | Overrides the OpenRouter base URL. |
36
+ | `appUrl` | `string` | App URL for attribution `HTTP-Referer` header. |
37
+ | `appTitle` | `string` | App title for the `X-Title` attribution header. |
38
+ | `models` | `readonly ModelConfig[]` | App-supplied model catalog (no default fetch). |
39
+
40
+ `OpenRouterModelConfig.compat.openRouterRouting` controls routing order,
41
+ `data_collection`, reasoning, and per-model cache policy overrides.
42
+
43
+ ## Outputs / response / events
44
+
45
+ | Surface | Behavior |
46
+ | --- | --- |
47
+ | Provider stream | Prism text, thinking, tool-call delta/final, `usage` (with cache read/write mapped), `done`, redacted `error`. |
48
+ | Attribution | `HTTP-Referer`/`X-Title` headers sent only when `appUrl`/`appTitle` are supplied. |
49
+ | Auth method | `api_key` for `openrouter`, credential name `apiKey`. |
50
+
51
+ ## Request/response example
52
+
53
+ Per-model routing override:
54
+
55
+ ```json
56
+ {
57
+ "model": "anthropic/claude-sonnet-4",
58
+ "routing": { "order": ["anthropic"], "data_collection": "deny" }
59
+ }
60
+ ```
61
+
62
+ ## Implementation example
63
+
64
+ ```ts
65
+ import { createExtensionKernel } from "@arnilo/prism";
66
+ import { createOpenRouterProviderPackage, defineOpenRouterModel } from "@arnilo/prism-provider-openrouter";
67
+
68
+ const sonnet = defineOpenRouterModel({
69
+ model: "anthropic/claude-sonnet-4",
70
+ compat: { openRouterRouting: { order: ["anthropic"], data_collection: "deny" } },
71
+ });
72
+
73
+ const kernel = createExtensionKernel();
74
+ await kernel.load([
75
+ createOpenRouterProviderPackage({ apiKey: "fake-openrouter-key", models: [sonnet] }),
76
+ ]);
77
+ ```
78
+
79
+ ## Extension and configuration notes
80
+
81
+ - Apps supply the model catalog via `models`; no catalog is fetched during setup.
82
+ - `defineOpenRouterModel` lets apps override cache policy and routing per model.
83
+ - Hosts choose base URL, attribution, credential source, and `fetch` impl.
84
+ - Package contributes models and an `api_key` auth method.
85
+
86
+ ## Security and performance notes
87
+
88
+ - No catalog fetch during setup; no automatic environment, file, keychain, or shell
89
+ credential lookup.
90
+ - API keys are resolved per request from caller-supplied values or resolvers and
91
+ redacted from errors.
92
+ - Attribution headers are sent only when `appUrl`/`appTitle` are supplied — no
93
+ hidden app identity.
94
+ - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
95
+ provider-specific env names; default tests are network-free.
96
+
97
+ ## Related APIs
98
+
99
+ - [Provider packages](../provider-packages.md): `defineProviderPackage`,
100
+ `ModelConfig`/`compat`, cache policy, request policies.
101
+ - [Credentials and redaction](../credentials-and-redaction.md):
102
+ `resolveCredentialValue`, `redactSecrets`.
103
+ - [Provider layer](../provider-layer.md): `ProviderRequest.options` and usage
104
+ mapping.
105
+ - [Provider conformance](../provider-conformance.md): network-free adapter tests.
@@ -0,0 +1,108 @@
1
+ # ZAI provider package
2
+
3
+ ## What it does
4
+
5
+ `@arnilo/prism-provider-zai` provides explicit, side-effect-free setup for the ZAI GLM
6
+ API-key provider using Prism's OpenAI-compatible route with the
7
+ `thinkingFormat: "zai"` model-compat setting, developer-role fallback, and
8
+ GLM tool-stream quirks.
9
+
10
+ The package registers a provider, default model metadata, and an `api_key` auth
11
+ method through `createExtensionKernel().load([...])`.
12
+
13
+ ## When to use it
14
+
15
+ Use it when a host app wants to run the ZAI GLM endpoint through Prism's
16
+ `AgentSession` runtime with ZAI-specific thinking/tool-stream handling.
17
+
18
+ Do not use it for automatic credential discovery, catalog fetches, or
19
+ real-network tests.
20
+
21
+ ## Inputs / request
22
+
23
+ ```ts
24
+ import { createZaiProviderPackage } from "@arnilo/prism-provider-zai";
25
+
26
+ createZaiProviderPackage(options: ZaiProviderPackageOptions): ProviderPackage
27
+ defineZaiModel(config: ZaiModelConfig): ZaiModelConfig
28
+ ```
29
+
30
+ | Field | Type | Purpose |
31
+ | --- | --- | --- |
32
+ | `apiKey` | `CredentialValueSource` | Direct/callback/resolver API-key source. |
33
+ | `fetch` | `typeof fetch` | Optional fetch implementation for tests/hosts. |
34
+ | `baseUrl` | `string` | Overrides the ZAI base URL. |
35
+ | `id` | `string` | Overrides the provider id (default `zai`). |
36
+ | `models` | `readonly ModelConfig[]` | Overrides `zaiModels` defaults. |
37
+
38
+ `ModelConfig.compat.thinkingFormat: "zai"` enables ZAI thinking handling;
39
+ `developerRoleFallback` controls developer-role fallback.
40
+
41
+ ## Outputs / response / events
42
+
43
+ | Surface | Behavior |
44
+ | --- | --- |
45
+ | Provider stream | Prism text, thinking (preserved only when `model.compat.preserveThinking` is true, otherwise downgraded to text), tool-call delta/final, `usage`, `done`, redacted `error`. |
46
+ | Block preservation | Text, thinking, assistant `tool_call` → `tool_calls`, `tool_result` → role `tool` messages, images when `capabilities.input` includes `"image"`. |
47
+ | Auth method | `api_key` for the configured provider id, credential name `apiKey`. |
48
+
49
+ Unsupported block placements or unclaimed images fail before fetch.
50
+
51
+ ## Request/response example
52
+
53
+ Example request body (OpenAI-compatible Chat Completions shape):
54
+
55
+ ```json
56
+ {
57
+ "model": "glm-4.6",
58
+ "messages": [{ "role": "user", "content": "Hello" }],
59
+ "stream": true
60
+ }
61
+ ```
62
+
63
+ ## Implementation example
64
+
65
+ ```ts
66
+ import { createExtensionKernel } from "@arnilo/prism";
67
+ import { createZaiProviderPackage } from "@arnilo/prism-provider-zai";
68
+
69
+ const kernel = createExtensionKernel();
70
+ await kernel.load([createZaiProviderPackage({ apiKey: "fake-zai-key" })]);
71
+ ```
72
+
73
+ Override the provider id and models:
74
+
75
+ ```ts
76
+ import { createZaiProviderPackage, defineZaiModel, zaiModels } from "@arnilo/prism-provider-zai";
77
+
78
+ await kernel.load([
79
+ createZaiProviderPackage({ id: "zai", apiKey: "fake", models: zaiModels }),
80
+ ]);
81
+ ```
82
+
83
+ ## Extension and configuration notes
84
+
85
+ - Hosts choose base URL, provider id, model list, credential source, and `fetch`
86
+ impl.
87
+ - `defineZaiModel` lets apps set ZAI-specific `compat` (thinking format, developer
88
+ fallback).
89
+ - Package contributes models via the extension `api` and an `api_key` auth method.
90
+
91
+ ## Security and performance notes
92
+
93
+ - No network calls during import, setup, build, or default tests.
94
+ - No automatic environment, file, keychain, or shell credential lookup.
95
+ - API keys are resolved per request from caller-supplied values or resolvers and
96
+ redacted from errors.
97
+ - Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
98
+ provider-specific env names; default tests are network-free.
99
+
100
+ ## Related APIs
101
+
102
+ - [Provider packages](../provider-packages.md): `defineProviderPackage`,
103
+ `ModelConfig`/`compat`, thinking formats.
104
+ - [Credentials and redaction](../credentials-and-redaction.md):
105
+ `resolveCredentialValue`, `redactSecrets`.
106
+ - [OpenAI-compatible provider](openai-compatible.md): underlying Chat Completions
107
+ adapter.
108
+ - [Provider conformance](../provider-conformance.md): network-free adapter tests.