@shawnstack/quickforge 1.3.18 → 1.3.19
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/README.md +10 -10
- package/bin/quickforge.mjs +258 -49
- package/dist/assets/anthropic-Bj3HAZgj.js +39 -0
- package/dist/assets/azure-openai-responses-IdZZrSrI.js +1 -0
- package/dist/assets/github-copilot-headers-CMb2BbzT.js +1 -0
- package/dist/assets/google-Brt_lS1J.js +1 -0
- package/dist/assets/{google-shared-XhYUKiGZ.js → google-shared-CLc4ziON.js} +3 -3
- package/dist/assets/google-vertex-B6HsoZ34.js +1 -0
- package/dist/assets/{index-Dm7aEWvT.js → index-D0CVLdX_.js} +525 -489
- package/dist/assets/index-D0W9hAl_.css +3 -0
- package/dist/assets/{mistral-DxhS4Wkn.js → mistral-CenXqwPz.js} +3 -3
- package/dist/assets/openai-codex-responses-D9ffGwbj.js +7 -0
- package/dist/assets/openai-completions-eWdeSGBG.js +5 -0
- package/dist/assets/openai-responses-Cavpmjeu.js +1 -0
- package/dist/assets/{openai-responses-shared-f_P3e1nz.js → openai-responses-shared-DF3ZGaUx.js} +5 -3
- package/dist/assets/transform-messages-CmnxG9RB.js +1 -0
- package/dist/index.html +2 -2
- package/node_modules/@anthropic-ai/sdk/CHANGELOG.md +34 -0
- package/node_modules/@anthropic-ai/sdk/bin/migration-config.json +185 -0
- package/node_modules/@anthropic-ai/sdk/package.json +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.js +5 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs +5 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.js +11 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/index.js +11 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/index.mjs +5 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.js +130 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.mjs +126 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-stores.js +145 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-stores.mjs +140 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.js +81 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.mjs +77 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/tools/memory/node.js +12 -5
- package/node_modules/@anthropic-ai/sdk/tools/memory/node.mjs +12 -5
- package/node_modules/@anthropic-ai/sdk/version.js +1 -1
- package/node_modules/@anthropic-ai/sdk/version.mjs +1 -1
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +5 -5
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +12 -6
- package/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js +12 -6
- package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@mariozechner/pi-agent-core/README.md +14 -0
- package/node_modules/@mariozechner/pi-agent-core/dist/agent-loop.js +9 -0
- package/node_modules/@mariozechner/pi-agent-core/dist/agent.js +1 -1
- package/node_modules/@mariozechner/pi-agent-core/package.json +2 -2
- package/node_modules/@mariozechner/pi-ai/README.md +20 -31
- package/node_modules/@mariozechner/pi-ai/dist/env-api-keys.js +7 -0
- package/node_modules/@mariozechner/pi-ai/dist/index.js +2 -0
- package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +2420 -1213
- package/node_modules/@mariozechner/pi-ai/dist/models.js +28 -20
- package/node_modules/@mariozechner/pi-ai/dist/providers/amazon-bedrock.js +11 -11
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +43 -26
- package/node_modules/@mariozechner/pi-ai/dist/providers/azure-openai-responses.js +12 -6
- package/node_modules/@mariozechner/pi-ai/dist/providers/cloudflare.js +10 -3
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-shared.js +4 -13
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +4 -3
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +4 -3
- package/node_modules/@mariozechner/pi-ai/dist/providers/mistral.js +8 -7
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-codex-responses.js +296 -41
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +169 -153
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses-shared.js +14 -1
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-responses.js +22 -8
- package/node_modules/@mariozechner/pi-ai/dist/providers/register-builtins.js +0 -18
- package/node_modules/@mariozechner/pi-ai/dist/providers/simple-options.js +1 -0
- package/node_modules/@mariozechner/pi-ai/dist/session-resources.js +22 -0
- package/node_modules/@mariozechner/pi-ai/dist/utils/diagnostics.js +25 -0
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/index.js +0 -10
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/openai-codex.js +25 -14
- package/node_modules/@mariozechner/pi-ai/dist/utils/overflow.js +14 -0
- package/node_modules/@mariozechner/pi-ai/package.json +2 -6
- package/package.json +3 -3
- package/server/agent-manager.mjs +279 -12
- package/server/auto-compaction.mjs +1 -2
- package/server/conversation-compaction.mjs +0 -5
- package/server/index.mjs +1 -0
- package/server/routes/static.mjs +1 -0
- package/server/routes/tools.mjs +3 -1
- package/server/session-utils.mjs +6 -1
- package/server/share-store.mjs +27 -4
- package/server/subagents.mjs +101 -0
- package/server/system-prompt.mjs +30 -1
- package/server/tools/definitions.mjs +18 -0
- package/server/tools/index.mjs +1013 -911
- package/dist/assets/anthropic-Ck2DxOfr.js +0 -39
- package/dist/assets/azure-openai-responses-DIoz5q4Z.js +0 -1
- package/dist/assets/github-copilot-headers-CrI0CIJ7.js +0 -1
- package/dist/assets/google-Dau-4ve_.js +0 -1
- package/dist/assets/google-gemini-cli-DttMmbGb.js +0 -2
- package/dist/assets/google-vertex-BeukMl44.js +0 -1
- package/dist/assets/index-DgJVElbv.css +0 -3
- package/dist/assets/openai-codex-responses-X3sTzNAa.js +0 -7
- package/dist/assets/openai-completions-CRB9Vm0w.js +0 -5
- package/dist/assets/openai-responses-DXluu3oi.js +0 -1
- package/dist/assets/transform-messages-CV4kCtBB.js +0 -1
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +0 -201
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +0 -62
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +0 -156
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +0 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +0 -16
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +0 -80
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +0 -11
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +0 -10
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +0 -4
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +0 -5
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +0 -7
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +0 -8
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +0 -69
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-gemini-cli.js +0 -779
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/google-antigravity.js +0 -377
- package/node_modules/@mariozechner/pi-ai/dist/utils/oauth/google-gemini-cli.js +0 -482
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/xml-builder",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.26",
|
|
4
4
|
"description": "XML utilities for the AWS SDK",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@nodable/entities": "2.1.0",
|
|
7
6
|
"@smithy/types": "^4.14.2",
|
|
8
7
|
"fast-xml-parser": "5.7.3",
|
|
9
8
|
"tslib": "^2.6.2"
|
|
@@ -55,6 +54,7 @@
|
|
|
55
54
|
"directory": "packages-internal/xml-builder"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
57
|
+
"@nodable/entities": "2.1.0",
|
|
58
58
|
"@tsconfig/recommended": "1.0.1",
|
|
59
59
|
"concurrently": "7.0.0",
|
|
60
60
|
"downlevel-dts": "0.10.1",
|
|
@@ -112,6 +112,20 @@ The `beforeToolCall` hook runs after `tool_execution_start` and validated argume
|
|
|
112
112
|
|
|
113
113
|
Tools can also return `terminate: true` to hint that the automatic follow-up LLM call should be skipped. The loop only stops early when every finalized tool result in that batch sets `terminate: true`. Mixed batches continue normally.
|
|
114
114
|
|
|
115
|
+
Low-level loop callers can set `shouldStopAfterTurn` to stop gracefully after the current turn completes:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const stream = agentLoop(prompts, context, {
|
|
119
|
+
model,
|
|
120
|
+
convertToLlm,
|
|
121
|
+
shouldStopAfterTurn: async ({ message, toolResults, context, newMessages }) => {
|
|
122
|
+
return shouldCompactBeforeNextTurn(context.messages);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`shouldStopAfterTurn` runs after `turn_end` is emitted and after the assistant response and any tool executions have completed normally. If it returns `true`, the loop emits `agent_end` and exits before polling steering or follow-up queues, and before starting another LLM call. It does not abort the provider stream, does not cancel running tools, and does not alter the assistant message stop reason.
|
|
128
|
+
|
|
115
129
|
When you use the `Agent` class, assistant `message_end` processing is treated as a barrier before tool preflight begins. That means `beforeToolCall` sees agent state that already includes the assistant message that requested the tool call.
|
|
116
130
|
|
|
117
131
|
### continue() Event Sequence
|
|
@@ -121,6 +121,15 @@ async function runLoop(currentContext, newMessages, config, signal, emit, stream
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
await emit({ type: "turn_end", message, toolResults });
|
|
124
|
+
if (await config.shouldStopAfterTurn?.({
|
|
125
|
+
message,
|
|
126
|
+
toolResults,
|
|
127
|
+
context: currentContext,
|
|
128
|
+
newMessages,
|
|
129
|
+
})) {
|
|
130
|
+
await emit({ type: "agent_end", messages: newMessages });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
124
133
|
pendingMessages = (await config.getSteeringMessages?.()) || [];
|
|
125
134
|
}
|
|
126
135
|
// Agent would stop here. Check for follow-up messages.
|
|
@@ -121,7 +121,7 @@ export class Agent {
|
|
|
121
121
|
this.followUpQueue = new PendingMessageQueue(options.followUpMode ?? "one-at-a-time");
|
|
122
122
|
this.sessionId = options.sessionId;
|
|
123
123
|
this.thinkingBudgets = options.thinkingBudgets;
|
|
124
|
-
this.transport = options.transport ?? "
|
|
124
|
+
this.transport = options.transport ?? "auto";
|
|
125
125
|
this.maxRetryDelayMs = options.maxRetryDelayMs;
|
|
126
126
|
this.toolExecution = options.toolExecution ?? "parallel";
|
|
127
127
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mariozechner/pi-agent-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.1",
|
|
4
4
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"prepublishOnly": "npm run clean && npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@mariozechner/pi-ai": "^0.
|
|
20
|
+
"@mariozechner/pi-ai": "^0.73.1",
|
|
21
21
|
"typebox": "^1.1.24"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
@@ -57,19 +57,19 @@ Unified LLM API with automatic model discovery, provider configuration, token an
|
|
|
57
57
|
- **Mistral**
|
|
58
58
|
- **Groq**
|
|
59
59
|
- **Cerebras**
|
|
60
|
+
- **Cloudflare AI Gateway**
|
|
60
61
|
- **Cloudflare Workers AI**
|
|
61
62
|
- **xAI**
|
|
62
63
|
- **OpenRouter**
|
|
63
64
|
- **Vercel AI Gateway**
|
|
64
65
|
- **MiniMax**
|
|
65
66
|
- **GitHub Copilot** (requires OAuth, see below)
|
|
66
|
-
- **Google Gemini CLI** (requires OAuth, see below)
|
|
67
|
-
- **Antigravity** (requires OAuth, see below)
|
|
68
67
|
- **Amazon Bedrock**
|
|
69
68
|
- **OpenCode Zen**
|
|
70
69
|
- **OpenCode Go**
|
|
71
70
|
- **Fireworks** (uses Anthropic-compatible API)
|
|
72
71
|
- **Kimi For Coding** (Moonshot AI, uses Anthropic-compatible API)
|
|
72
|
+
- **Xiaomi MiMo** (uses Anthropic-compatible API; defaults to API billing endpoint, with separate Token Plan providers for `cn`/`ams`/`sgp` regions)
|
|
73
73
|
- **Any OpenAI-compatible API**: Ollama, vLLM, LM Studio, etc.
|
|
74
74
|
|
|
75
75
|
## Installation
|
|
@@ -383,6 +383,8 @@ All streaming events emitted during assistant message generation:
|
|
|
383
383
|
| `done` | Stream complete | `reason`: Stop reason ("stop", "length", "toolUse"), `message`: Final assistant message |
|
|
384
384
|
| `error` | Error occurred | `reason`: Error type ("error" or "aborted"), `error`: AssistantMessage with partial content |
|
|
385
385
|
|
|
386
|
+
Streaming events for different content blocks are not guaranteed to be contiguous. Providers may emit deltas for text, thinking, and tool calls in the same upstream chunk, and pi may surface corresponding events interleaved, for example `text_start`, `text_delta`, `toolcall_start`, `text_delta`, `toolcall_delta`. Consumers must use `contentIndex` to associate each delta/end event with its block and must not assume that a block's `*_start`/`*_delta`/`*_end` sequence is uninterrupted by events for other blocks.
|
|
387
|
+
|
|
386
388
|
## Image Input
|
|
387
389
|
|
|
388
390
|
Models with vision capabilities can process images. You can check if a model supports images via the `input` property. If you pass images to a non-vision model, they are silently ignored.
|
|
@@ -446,7 +448,7 @@ if (model.reasoning) {
|
|
|
446
448
|
const response = await completeSimple(model, {
|
|
447
449
|
messages: [{ role: 'user', content: 'Solve: 2x + 5 = 13' }]
|
|
448
450
|
}, {
|
|
449
|
-
reasoning: 'medium' // 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
451
|
+
reasoning: 'medium' // 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
|
|
450
452
|
});
|
|
451
453
|
|
|
452
454
|
// Access thinking and text blocks
|
|
@@ -630,7 +632,6 @@ The library uses a registry of API implementations. Built-in APIs include:
|
|
|
630
632
|
|
|
631
633
|
- **`anthropic-messages`**: Anthropic Messages API (`streamAnthropic`, `AnthropicOptions`)
|
|
632
634
|
- **`google-generative-ai`**: Google Generative AI API (`streamGoogle`, `GoogleOptions`)
|
|
633
|
-
- **`google-gemini-cli`**: Google Cloud Code Assist API (`streamGoogleGeminiCli`, `GoogleGeminiCliOptions`)
|
|
634
635
|
- **`google-vertex`**: Google Vertex AI API (`streamGoogleVertex`, `GoogleVertexOptions`)
|
|
635
636
|
- **`mistral-conversations`**: Mistral Conversations API (`streamMistral`, `MistralOptions`)
|
|
636
637
|
- **`openai-completions`**: OpenAI Chat Completions API (`streamOpenAICompletions`, `OpenAICompletionsOptions`)
|
|
@@ -822,6 +823,8 @@ const response = await stream(ollamaModel, context, {
|
|
|
822
823
|
|
|
823
824
|
Some OpenAI-compatible servers do not understand the `developer` role used for reasoning-capable models. For those providers, set `compat.supportsDeveloperRole` to `false` so the system prompt is sent as a `system` message instead. If the server also does not support `reasoning_effort`, set `compat.supportsReasoningEffort` to `false` too.
|
|
824
825
|
|
|
826
|
+
Use model-level `thinkingLevelMap` to describe model-specific thinking controls. Keys are pi thinking levels (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`). Missing keys use provider defaults, string values are sent to the provider, and `null` marks a level unsupported.
|
|
827
|
+
|
|
825
828
|
This commonly applies to Ollama, vLLM, SGLang, and similar OpenAI-compatible servers. You can set `compat` at the provider level or per model.
|
|
826
829
|
|
|
827
830
|
```typescript
|
|
@@ -836,6 +839,13 @@ const ollamaReasoningModel: Model<'openai-completions'> = {
|
|
|
836
839
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
837
840
|
contextWindow: 131072,
|
|
838
841
|
maxTokens: 32000,
|
|
842
|
+
thinkingLevelMap: {
|
|
843
|
+
minimal: null,
|
|
844
|
+
low: null,
|
|
845
|
+
medium: null,
|
|
846
|
+
high: 'high',
|
|
847
|
+
xhigh: null,
|
|
848
|
+
},
|
|
839
849
|
compat: {
|
|
840
850
|
supportsDeveloperRole: false,
|
|
841
851
|
supportsReasoningEffort: false,
|
|
@@ -1029,6 +1039,7 @@ In Node.js environments, you can set environment variables to avoid passing API
|
|
|
1029
1039
|
| Mistral | `MISTRAL_API_KEY` |
|
|
1030
1040
|
| Groq | `GROQ_API_KEY` |
|
|
1031
1041
|
| Cerebras | `CEREBRAS_API_KEY` |
|
|
1042
|
+
| Cloudflare AI Gateway | `CLOUDFLARE_API_KEY` + `CLOUDFLARE_ACCOUNT_ID` + `CLOUDFLARE_GATEWAY_ID` |
|
|
1032
1043
|
| Cloudflare Workers AI | `CLOUDFLARE_API_KEY` + `CLOUDFLARE_ACCOUNT_ID` |
|
|
1033
1044
|
| xAI | `XAI_API_KEY` |
|
|
1034
1045
|
| Fireworks | `FIREWORKS_API_KEY` |
|
|
@@ -1038,6 +1049,10 @@ In Node.js environments, you can set environment variables to avoid passing API
|
|
|
1038
1049
|
| MiniMax | `MINIMAX_API_KEY` |
|
|
1039
1050
|
| OpenCode Zen / OpenCode Go | `OPENCODE_API_KEY` |
|
|
1040
1051
|
| Kimi For Coding | `KIMI_API_KEY` |
|
|
1052
|
+
| Xiaomi MiMo (API billing) | `XIAOMI_API_KEY` |
|
|
1053
|
+
| Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` |
|
|
1054
|
+
| Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` |
|
|
1055
|
+
| Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` |
|
|
1041
1056
|
| GitHub Copilot | `COPILOT_GITHUB_TOKEN` or `GH_TOKEN` or `GITHUB_TOKEN` |
|
|
1042
1057
|
|
|
1043
1058
|
When set, the library automatically uses these keys:
|
|
@@ -1053,27 +1068,6 @@ const response = await complete(model, context, {
|
|
|
1053
1068
|
});
|
|
1054
1069
|
```
|
|
1055
1070
|
|
|
1056
|
-
#### Antigravity Version Override
|
|
1057
|
-
|
|
1058
|
-
Set `PI_AI_ANTIGRAVITY_VERSION` to override the Antigravity User-Agent version when Google updates their requirements:
|
|
1059
|
-
|
|
1060
|
-
```bash
|
|
1061
|
-
export PI_AI_ANTIGRAVITY_VERSION="1.23.0"
|
|
1062
|
-
```
|
|
1063
|
-
|
|
1064
|
-
#### Cache Retention
|
|
1065
|
-
|
|
1066
|
-
Set `PI_CACHE_RETENTION=long` to extend prompt cache retention:
|
|
1067
|
-
|
|
1068
|
-
| Provider | Default | With `PI_CACHE_RETENTION=long` |
|
|
1069
|
-
|----------|---------|-------------------------------|
|
|
1070
|
-
| Anthropic | 5 minutes | 1 hour |
|
|
1071
|
-
| OpenAI | in-memory | 24 hours |
|
|
1072
|
-
|
|
1073
|
-
This only affects direct API calls to `api.anthropic.com` and `api.openai.com`. Proxies and other providers are unaffected.
|
|
1074
|
-
|
|
1075
|
-
> **Note**: Extended cache retention may increase costs for Anthropic (cache writes are charged at a higher rate). OpenAI's 24h retention has no additional cost.
|
|
1076
|
-
|
|
1077
1071
|
### Checking Environment Variables
|
|
1078
1072
|
|
|
1079
1073
|
```typescript
|
|
@@ -1090,8 +1084,6 @@ Several providers require OAuth authentication instead of static API keys:
|
|
|
1090
1084
|
- **Anthropic** (Claude Pro/Max subscription)
|
|
1091
1085
|
- **OpenAI Codex** (ChatGPT Plus/Pro subscription, access to GPT-5.x Codex models)
|
|
1092
1086
|
- **GitHub Copilot** (Copilot subscription)
|
|
1093
|
-
- **Google Gemini CLI** (Gemini 2.0/2.5 via Google Cloud Code Assist; free tier or paid subscription)
|
|
1094
|
-
- **Antigravity** (Free Gemini 3, Claude, GPT-OSS via Google Cloud)
|
|
1095
1087
|
|
|
1096
1088
|
For paid Cloud Code Assist subscriptions, set `GOOGLE_CLOUD_PROJECT` or `GOOGLE_CLOUD_PROJECT_ID` to your project ID.
|
|
1097
1089
|
|
|
@@ -1159,14 +1151,13 @@ import {
|
|
|
1159
1151
|
loginOpenAICodex,
|
|
1160
1152
|
loginGitHubCopilot,
|
|
1161
1153
|
loginGeminiCli,
|
|
1162
|
-
loginAntigravity,
|
|
1163
1154
|
|
|
1164
1155
|
// Token management
|
|
1165
1156
|
refreshOAuthToken, // (provider, credentials) => new credentials
|
|
1166
1157
|
getOAuthApiKey, // (provider, credentialsMap) => { newCredentials, apiKey } | null
|
|
1167
1158
|
|
|
1168
1159
|
// Types
|
|
1169
|
-
type OAuthProvider,
|
|
1160
|
+
type OAuthProvider,
|
|
1170
1161
|
type OAuthCredentials,
|
|
1171
1162
|
} from '@mariozechner/pi-ai/oauth';
|
|
1172
1163
|
```
|
|
@@ -1228,8 +1219,6 @@ const response = await complete(model, {
|
|
|
1228
1219
|
|
|
1229
1220
|
**GitHub Copilot**: If you get "The requested model is not supported" error, enable the model manually in VS Code: open Copilot Chat, click the model selector, select the model (warning icon), and click "Enable".
|
|
1230
1221
|
|
|
1231
|
-
**Google Gemini CLI / Antigravity**: These use Google Cloud OAuth. The `apiKey` returned by `getOAuthApiKey()` is a JSON string containing both the token and project ID, which the library handles automatically.
|
|
1232
|
-
|
|
1233
1222
|
## Development
|
|
1234
1223
|
|
|
1235
1224
|
### Adding a New Provider
|
|
@@ -99,12 +99,19 @@ function getApiKeyEnvVars(provider) {
|
|
|
99
99
|
mistral: "MISTRAL_API_KEY",
|
|
100
100
|
minimax: "MINIMAX_API_KEY",
|
|
101
101
|
"minimax-cn": "MINIMAX_CN_API_KEY",
|
|
102
|
+
moonshotai: "MOONSHOT_API_KEY",
|
|
103
|
+
"moonshotai-cn": "MOONSHOT_API_KEY",
|
|
102
104
|
huggingface: "HF_TOKEN",
|
|
103
105
|
fireworks: "FIREWORKS_API_KEY",
|
|
104
106
|
opencode: "OPENCODE_API_KEY",
|
|
105
107
|
"opencode-go": "OPENCODE_API_KEY",
|
|
106
108
|
"kimi-coding": "KIMI_API_KEY",
|
|
107
109
|
"cloudflare-workers-ai": "CLOUDFLARE_API_KEY",
|
|
110
|
+
"cloudflare-ai-gateway": "CLOUDFLARE_API_KEY",
|
|
111
|
+
xiaomi: "XIAOMI_API_KEY",
|
|
112
|
+
"xiaomi-token-plan-cn": "XIAOMI_TOKEN_PLAN_CN_API_KEY",
|
|
113
|
+
"xiaomi-token-plan-ams": "XIAOMI_TOKEN_PLAN_AMS_API_KEY",
|
|
114
|
+
"xiaomi-token-plan-sgp": "XIAOMI_TOKEN_PLAN_SGP_API_KEY",
|
|
108
115
|
};
|
|
109
116
|
const envVar = envMap[provider];
|
|
110
117
|
return envVar ? [envVar] : undefined;
|
|
@@ -4,8 +4,10 @@ export * from "./env-api-keys.js";
|
|
|
4
4
|
export * from "./models.js";
|
|
5
5
|
export * from "./providers/faux.js";
|
|
6
6
|
export * from "./providers/register-builtins.js";
|
|
7
|
+
export * from "./session-resources.js";
|
|
7
8
|
export * from "./stream.js";
|
|
8
9
|
export * from "./types.js";
|
|
10
|
+
export * from "./utils/diagnostics.js";
|
|
9
11
|
export * from "./utils/event-stream.js";
|
|
10
12
|
export * from "./utils/json-parse.js";
|
|
11
13
|
export * from "./utils/overflow.js";
|