@astralyn/pi 1.0.3 → 1.0.5
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 +34 -0
- package/dist/bundle/chunks/{anthropic-messages-YET4T7BO.js → anthropic-messages-YIOJIMVL.js} +1 -1
- package/dist/bundle/chunks/azure-openai-responses-LDW4FGAQ.js +2 -0
- package/dist/bundle/chunks/{chunk-MPDALHNJ.js → chunk-57XI7YJH.js} +1 -1
- package/dist/bundle/chunks/{chunk-SVJ7OGEB.js → chunk-A6ALEEY5.js} +1 -1
- package/dist/bundle/chunks/chunk-D3ZCGC4T.js +2 -0
- package/dist/bundle/chunks/{chunk-N2LEX5CU.js → chunk-HDHRZ7GT.js} +1 -1
- package/dist/bundle/chunks/{chunk-Q7TDQ5LT.js → chunk-IE3Z7ESB.js} +184 -79
- package/dist/bundle/chunks/{chunk-IZ3S3GDX.js → chunk-IFELM7MW.js} +1 -1
- package/dist/bundle/chunks/chunk-RZ2V53SP.js +2 -0
- package/dist/bundle/chunks/{chunk-V66VGGOM.js → chunk-TCQ4HHQD.js} +1 -1
- package/dist/bundle/chunks/chunk-TXJO4AJ7.js +11 -0
- package/dist/bundle/chunks/{chunk-NY3CWK44.js → chunk-UCXU7KLO.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-QI46LUZ6.js → cloudflare-workers-ai-system-one-OWU5SM6J.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +99 -4
- package/dist/bundle/chunks/{google-generative-ai-YTZCSHQN.js → google-generative-ai-S5A5IBU4.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-OTFZJJXQ.js → google-vertex-UBRQFDB4.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-ELH4V4TY.js → mistral-conversations-A2N5FSOV.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-OLVTU4UA.js → openai-codex-responses-Q6JHCWLE.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-53M2KJ67.js → openai-completions-H4VMO7AU.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-4ABDEL4Z.js → openai-responses-G4PGNM2H.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-RREJAKWB.js → typesafe-system-one-KYKKNU3E.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-46MSJGKO.js +2 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +18 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +26 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +44 -12
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -7
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -4
- package/dist/core/mcp-servers.d.ts +8 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +30 -7
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -3
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +9 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +9 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +6 -11
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +18 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +51 -9
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +1 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +9 -2
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +13 -5
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -4
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +3 -4
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +4 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +22 -5
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +2 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +6 -10
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +42 -6
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/output-files.d.ts +17 -0
- package/dist/utils/output-files.d.ts.map +1 -0
- package/dist/utils/output-files.js +30 -0
- package/dist/utils/output-files.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/codemode.md +6 -5
- package/docs/extensions.md +1 -1
- package/docs/keybindings.md +7 -7
- package/docs/mcp.md +3 -1
- package/docs/providers.md +5 -1
- package/docs/settings.md +1 -1
- package/docs/usage.md +15 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +54 -54
- package/package.json +11 -11
- package/dist/bundle/chunks/azure-openai-responses-SBLL5YN3.js +0 -2
- package/dist/bundle/chunks/chunk-G4RY3GN7.js +0 -11
- package/dist/bundle/chunks/chunk-TRHTWM3C.js +0 -2
- package/dist/bundle/chunks/virtual-modules-UUHBXSJB.js +0 -2
package/docs/keybindings.md
CHANGED
|
@@ -36,8 +36,8 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `super+
|
|
|
36
36
|
| `tui.editor.cursorRight` | `right`, `ctrl+f` | Move cursor right |
|
|
37
37
|
| `tui.editor.cursorWordLeft` | `alt+left`, `ctrl+left`, `alt+b` | Move cursor word left |
|
|
38
38
|
| `tui.editor.cursorWordRight` | `alt+right`, `ctrl+right`, `alt+f` | Move cursor word right |
|
|
39
|
-
| `tui.editor.cursorLineStart` | `home`, `ctrl+
|
|
40
|
-
| `tui.editor.cursorLineEnd` | `end`, `ctrl+
|
|
39
|
+
| `tui.editor.cursorLineStart` | `home`, `ctrl+a` | Move to line start |
|
|
40
|
+
| `tui.editor.cursorLineEnd` | `end`, `ctrl+e` | Move to line end |
|
|
41
41
|
| `tui.editor.jumpForward` | `ctrl+]` | Jump forward to character |
|
|
42
42
|
| `tui.editor.jumpBackward` | `ctrl+alt+]` | Jump backward to character |
|
|
43
43
|
| `tui.editor.pageUp` | `pageUp`, `ctrl+pageUp` | Scroll up by page |
|
|
@@ -90,12 +90,12 @@ These actions apply when interactive mode uses `--tui-mode fullscreen` and targe
|
|
|
90
90
|
|
|
91
91
|
Hold Alt while scrolling the mouse wheel for five-times-faster scrolling. Hovering over autocomplete or settings lists keeps their selection and scroll position unchanged; click an item to select it.
|
|
92
92
|
|
|
93
|
-
Fullscreen transcript bindings take precedence over editor bindings
|
|
93
|
+
Fullscreen transcript bindings take precedence over editor bindings using the same key. `pageUp` and `pageDown` therefore control the transcript in fullscreen mode while their `ctrl` variants keep controlling the editor; `home` and `end` always control the editor, while `ctrl+home` and `ctrl+end` control the transcript in fullscreen mode. Outside fullscreen mode, all of these keys control the editor.
|
|
94
94
|
|
|
95
95
|
| Key | Default mode | Fullscreen mode |
|
|
96
96
|
|-----|--------------|-----------------|
|
|
97
|
-
| `home`, `end` | Editor |
|
|
98
|
-
| `ctrl+home`, `ctrl+end` | Editor |
|
|
97
|
+
| `home`, `end` | Editor | Editor |
|
|
98
|
+
| `ctrl+home`, `ctrl+end` | Editor | Transcript |
|
|
99
99
|
| `pageUp`, `pageDown` | Editor | Transcript |
|
|
100
100
|
| `ctrl+pageUp`, `ctrl+pageDown` | Editor | Editor |
|
|
101
101
|
|
|
@@ -115,8 +115,8 @@ This routing remains configurable through the ordinary action bindings. For exam
|
|
|
115
115
|
| `tui.altScreen.searchNext` | `enter`, `ctrl+g` | Select the next search match while searching |
|
|
116
116
|
| `tui.altScreen.searchPrevious` | `shift+enter`, `ctrl+shift+g` | Select the previous search match while searching |
|
|
117
117
|
| `tui.altScreen.searchClose` | `escape` | Close transcript search |
|
|
118
|
-
| `tui.altScreen.top` | `home` | Scroll to the beginning of the transcript |
|
|
119
|
-
| `tui.altScreen.bottom` | `end` | Scroll to the transcript end and follow new output |
|
|
118
|
+
| `tui.altScreen.top` | `ctrl+home` | Scroll to the beginning of the transcript |
|
|
119
|
+
| `tui.altScreen.bottom` | `ctrl+end` | Scroll to the transcript end and follow new output |
|
|
120
120
|
|
|
121
121
|
### Application
|
|
122
122
|
|
package/docs/mcp.md
CHANGED
|
@@ -225,6 +225,8 @@ Pi activates `codemode` when a server with `codemode` exposure connects. It acti
|
|
|
225
225
|
|
|
226
226
|
Tools with `codemode` or `deferred` exposure can be reached through either indirect mechanism: codemode scripts can call them, and `tool_search` can load them. Codemode calls do not depend on the active tool set, so they remain available after `/tree`, resume, and fork. Tools loaded by `tool_search` are recorded in the transcript and remain declared on that branch.
|
|
227
227
|
|
|
228
|
+
`--tools` does not remove MCP tools unless one of its entries starts with `mcp__`; `pi --tools read,codemode,'mcp__radius__*'` keeps only the tools of `radius`. `--exclude-tools` accepts the same patterns, and `--no-mcp` disables MCP for one run (see [Tools](usage.md#tool-options)).
|
|
229
|
+
|
|
228
230
|
To keep `codemode` active without MCP servers, add `"defaultTools": ["+codemode"]` to [settings](settings.md#tools). To prevent automatic codemode activation, set `"autoEnableCodemode": false` beside `mcpServers`. A project value overrides the user-level value. Pi warns once when neither `codemode` nor `tool_search` is active and non-direct tools cannot be called.
|
|
229
231
|
|
|
230
232
|
Text results over 20 KB reach the model with their middle removed around a `…N chars truncated…` marker. The full text is saved to a temporary file named in the result. Codemode scripts receive the complete result and can reduce it before returning output to the model.
|
|
@@ -261,7 +263,7 @@ Changes to enabled state or exposure apply only to the current session. A file-c
|
|
|
261
263
|
|
|
262
264
|
### Replace the built-in MCP support
|
|
263
265
|
|
|
264
|
-
An installed extension that registers `/mcp`, such as `pi-mcp-adapter`, replaces the built-in MCP support for sessions. Pi then does not read `mcp.json` or connect its servers in a session, and `/mcp` belongs to the extension. Remove the extension to restore the built-in behavior. To disable built-in MCP support without a replacement, disable `mcp` under Built-in in `pi config`,
|
|
266
|
+
An installed extension that registers `/mcp`, such as `pi-mcp-adapter`, replaces the built-in MCP support for sessions. Pi then does not read `mcp.json` or connect its servers in a session, and `/mcp` belongs to the extension. Remove the extension to restore the built-in behavior. To disable built-in MCP support without a replacement, disable `mcp` under Built-in in `pi config`, set `"extensions": ["-builtin:mcp"]` in [settings](settings.md#resources), or pass `--no-mcp` to disable it for one run.
|
|
265
267
|
|
|
266
268
|
An extension that registers `codemode` or `tool_search` similarly replaces the built-in tool with that name. Shell-level `pi mcp` commands always use the built-in implementation.
|
|
267
269
|
|
package/docs/providers.md
CHANGED
|
@@ -83,7 +83,7 @@ pi
|
|
|
83
83
|
|----------|----------------------|------------------|
|
|
84
84
|
| Anthropic | `ANTHROPIC_API_KEY` | `anthropic` |
|
|
85
85
|
| Ant Ling | `ANT_LING_API_KEY` | `ant-ling` |
|
|
86
|
-
| Azure OpenAI
|
|
86
|
+
| Azure OpenAI | `AZURE_OPENAI_API_KEY` | `azure` |
|
|
87
87
|
| OpenAI | `OPENAI_API_KEY` | `openai` |
|
|
88
88
|
| DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
|
|
89
89
|
| NVIDIA NIM | `NVIDIA_API_KEY` | `nvidia` |
|
|
@@ -218,6 +218,10 @@ export AZURE_OPENAI_API_VERSION=2024-02-01
|
|
|
218
218
|
export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-4=my-gpt4,gpt-4o=my-gpt4o
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
+
The `auth.json` key for this provider is `azure`, renamed from `azure-openai-responses`; rename it in `models.json` and `settings.json` as well. The `AZURE_OPENAI_*` environment variables are unchanged.
|
|
222
|
+
|
|
223
|
+
The `azure` provider serves both Azure OpenAI Responses deployments and Azure AI Foundry Chat Completions deployments (for example `azure/deepseek-v4-pro`).
|
|
224
|
+
|
|
221
225
|
### Amazon Bedrock
|
|
222
226
|
|
|
223
227
|
Use `/login amazon-bedrock` to store a Bedrock API key, or configure one of the ambient AWS credential sources below:
|
package/docs/settings.md
CHANGED
|
@@ -301,7 +301,7 @@ On Windows, select `powershell` instead of `bash`, or include both:
|
|
|
301
301
|
}
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
An empty array starts with no built-in tools while preserving extension and SDK custom tools. `--tools` replaces this behavior with
|
|
304
|
+
An empty array starts with no built-in tools while preserving extension and SDK custom tools. `--tools` replaces this behavior with an allowlist of names or `*` patterns that keeps MCP tools unless an entry starts with `mcp__`, `--no-tools` disables all tools including MCP tools, and `--no-builtin-tools` disables the built-in defaults. `--exclude-tools` filters the resulting list and accepts the same patterns. A project `defaultTools` array replaces the global array.
|
|
305
305
|
|
|
306
306
|
### Sessions
|
|
307
307
|
|
package/docs/usage.md
CHANGED
|
@@ -209,19 +209,28 @@ cat README.md | pi -p "Summarize this text"
|
|
|
209
209
|
|
|
210
210
|
| Option | Description |
|
|
211
211
|
|--------|-------------|
|
|
212
|
-
| `--tools <list>`, `-t <list>` | Allowlist specific built-in, extension, and custom tools |
|
|
213
|
-
| `--exclude-tools <list>`, `-xt <list>` | Disable
|
|
212
|
+
| `--tools <list>`, `-t <list>` | Allowlist specific built-in, extension, and custom tools; entries are names or `*` patterns, and MCP tools are kept unless an entry starts with `mcp__` |
|
|
213
|
+
| `--exclude-tools <list>`, `-xt <list>` | Disable tools by name or `*` pattern, MCP tools included |
|
|
214
214
|
| `--no-builtin-tools`, `-nbt` | Disable built-in tools but keep extension/custom tools enabled |
|
|
215
|
-
| `--no-tools`, `-nt` | Disable all tools |
|
|
215
|
+
| `--no-tools`, `-nt` | Disable all tools, MCP tools included |
|
|
216
216
|
|
|
217
217
|
Built-in tools: `read`, `bash`, `powershell` (Windows), `edit`, `write`, `grep`, `find`, `ls`.
|
|
218
218
|
|
|
219
|
+
`--tools` selects the tools declared to the model. It does not remove MCP tools, whose reach is set by their [exposure](mcp.md#control-tool-exposure): `pi --tools read,codemode` keeps every MCP tool callable from codemode scripts. An MCP tool that no entry names or matches is never declared directly, whatever its exposure; only `tool_search`, if listed, can load it. Once an entry starts with `mcp__`, `--tools` filters MCP tools too, so this keeps only the tools of the `radius` server:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
pi --tools read,bash,codemode,'mcp__radius__*'
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The MCP resource tools (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`) count as MCP tools. To remove MCP tools, use `--exclude-tools 'mcp__*'` or `--no-mcp`.
|
|
226
|
+
|
|
219
227
|
### Resource Options
|
|
220
228
|
|
|
221
229
|
| Option | Description |
|
|
222
230
|
|--------|-------------|
|
|
223
231
|
| `-e`, `--extension <source>` | Load an extension from path, npm, git, or `builtin:<name>`; repeatable |
|
|
224
232
|
| `--no-extensions` | Disable discovered, configured, and built-in extensions; explicit `-e` entries still load |
|
|
233
|
+
| `--no-mcp` | Disable built-in MCP support for this run: no servers connect, and there are no MCP tools or `/mcp`; does not affect an extension that replaces the built-in MCP support |
|
|
225
234
|
| `--skill <path>` | Load a skill; repeatable |
|
|
226
235
|
| `--no-skills` | Disable skill discovery |
|
|
227
236
|
| `--prompt-template <path>` | Load a prompt template; repeatable |
|
|
@@ -298,6 +307,9 @@ pi --models "claude-*,gpt-4o"
|
|
|
298
307
|
# Read-only mode
|
|
299
308
|
pi --tools read,grep,find,ls -p "Review the code"
|
|
300
309
|
|
|
310
|
+
# Codemode with only the tools of one MCP server
|
|
311
|
+
pi --tools read,bash,codemode,'mcp__radius__*'
|
|
312
|
+
|
|
301
313
|
# Disable one extension or built-in tool while keeping the rest available
|
|
302
314
|
pi --exclude-tools ask_question
|
|
303
315
|
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-gondolin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralyn/pi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@astralyn/pi",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@earendil-works/chord": "1.0.
|
|
13
|
-
"@earendil-works/pi-agent-core": "1.0.
|
|
14
|
-
"@earendil-works/pi-ai": "1.0.
|
|
15
|
-
"@earendil-works/pi-codemode": "1.0.
|
|
16
|
-
"@earendil-works/pi-mcp": "1.0.
|
|
17
|
-
"@earendil-works/pi-tui": "1.0.
|
|
12
|
+
"@earendil-works/chord": "1.0.4",
|
|
13
|
+
"@earendil-works/pi-agent-core": "1.0.4",
|
|
14
|
+
"@earendil-works/pi-ai": "1.0.4",
|
|
15
|
+
"@earendil-works/pi-codemode": "1.0.4",
|
|
16
|
+
"@earendil-works/pi-mcp": "1.0.4",
|
|
17
|
+
"@earendil-works/pi-tui": "1.0.4",
|
|
18
18
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
19
19
|
"chalk": "6.0.0",
|
|
20
20
|
"cross-spawn": "7.0.6",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@anthropic-ai/sandbox-runtime": "0.0.26",
|
|
40
40
|
"@anthropic-ai/sdk": "0.52.0",
|
|
41
41
|
"@biomejs/biome": "2.3.5",
|
|
42
|
-
"@earendil-works/pi-client": "1.0.
|
|
43
|
-
"@earendil-works/pi-durable": "1.0.
|
|
44
|
-
"@earendil-works/pi-protocol": "1.0.
|
|
45
|
-
"@earendil-works/pi-server": "1.0.
|
|
42
|
+
"@earendil-works/pi-client": "1.0.4",
|
|
43
|
+
"@earendil-works/pi-durable": "1.0.4",
|
|
44
|
+
"@earendil-works/pi-protocol": "1.0.4",
|
|
45
|
+
"@earendil-works/pi-server": "1.0.4",
|
|
46
46
|
"@types/cross-spawn": "6.0.6",
|
|
47
47
|
"@types/hosted-git-info": "3.0.5",
|
|
48
48
|
"@types/ms": "2.1.0",
|
|
@@ -630,9 +630,9 @@
|
|
|
630
630
|
}
|
|
631
631
|
},
|
|
632
632
|
"node_modules/@earendil-works/chord": {
|
|
633
|
-
"version": "1.0.
|
|
634
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.
|
|
635
|
-
"integrity": "sha512-
|
|
633
|
+
"version": "1.0.4",
|
|
634
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.4.tgz",
|
|
635
|
+
"integrity": "sha512-d2JZw2utoa/reoSmL07O71wsXiMDhIlnnxTb4LCNV+Oq8Evj2rGLvjVuYrlXZGbXUr0IDNfvd1RT/utCY1UhkQ==",
|
|
636
636
|
"license": "MIT",
|
|
637
637
|
"dependencies": {
|
|
638
638
|
"esbuild": "0.28.2"
|
|
@@ -642,12 +642,12 @@
|
|
|
642
642
|
}
|
|
643
643
|
},
|
|
644
644
|
"node_modules/@earendil-works/pi-agent-core": {
|
|
645
|
-
"version": "1.0.
|
|
646
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.
|
|
647
|
-
"integrity": "sha512
|
|
645
|
+
"version": "1.0.4",
|
|
646
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.4.tgz",
|
|
647
|
+
"integrity": "sha512-/xGICE+N/+G9N7KfYFSxlE8G8fQcBlLHKiY+j1Ehz9vvb1zhvGneWosFK56d2qmA5oteafeG7yKr2nqU4ed9ig==",
|
|
648
648
|
"license": "MIT",
|
|
649
649
|
"dependencies": {
|
|
650
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
650
|
+
"@earendil-works/pi-ai": "^1.0.4",
|
|
651
651
|
"typebox": "1.3.27"
|
|
652
652
|
},
|
|
653
653
|
"engines": {
|
|
@@ -655,14 +655,14 @@
|
|
|
655
655
|
}
|
|
656
656
|
},
|
|
657
657
|
"node_modules/@earendil-works/pi-ai": {
|
|
658
|
-
"version": "1.0.
|
|
659
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.
|
|
660
|
-
"integrity": "sha512
|
|
658
|
+
"version": "1.0.4",
|
|
659
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.4.tgz",
|
|
660
|
+
"integrity": "sha512-/Eu5R0gfor6wcmRcVyOmulUiZmsHJ0bKu5wXXnpCoSHF3y4FnW4fgnjRlLjNza8NJWXdvW5Uew90Zukx7Sh2rw==",
|
|
661
661
|
"license": "MIT",
|
|
662
662
|
"dependencies": {
|
|
663
663
|
"@anthropic-ai/sdk": "0.129.0",
|
|
664
664
|
"@aws-sdk/client-bedrock-runtime": "3.1127.0",
|
|
665
|
-
"@earendil-works/pi-telemetry": "^1.0.
|
|
665
|
+
"@earendil-works/pi-telemetry": "^1.0.4",
|
|
666
666
|
"@google/genai": "2.21.0",
|
|
667
667
|
"@smithy/node-http-handler": "4.12.1",
|
|
668
668
|
"http-proxy-agent": "9.1.0",
|
|
@@ -700,23 +700,23 @@
|
|
|
700
700
|
}
|
|
701
701
|
},
|
|
702
702
|
"node_modules/@earendil-works/pi-client": {
|
|
703
|
-
"version": "1.0.
|
|
704
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-client/-/pi-client-1.0.
|
|
705
|
-
"integrity": "sha512-
|
|
703
|
+
"version": "1.0.4",
|
|
704
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-client/-/pi-client-1.0.4.tgz",
|
|
705
|
+
"integrity": "sha512-c+hB+VE+K+2990do99wk4m+R7RvRt7A/Wb9JOHWM3c+vCFqZqo8VdU65a+P/hUZp2cVhoxFnzFZsDf9yqaGvUA==",
|
|
706
706
|
"dev": true,
|
|
707
707
|
"license": "MIT",
|
|
708
708
|
"dependencies": {
|
|
709
|
-
"@earendil-works/chord": "^1.0.
|
|
710
|
-
"@earendil-works/pi-protocol": "^1.0.
|
|
709
|
+
"@earendil-works/chord": "^1.0.4",
|
|
710
|
+
"@earendil-works/pi-protocol": "^1.0.4"
|
|
711
711
|
},
|
|
712
712
|
"engines": {
|
|
713
713
|
"node": ">=22.19.0"
|
|
714
714
|
}
|
|
715
715
|
},
|
|
716
716
|
"node_modules/@earendil-works/pi-codemode": {
|
|
717
|
-
"version": "1.0.
|
|
718
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.
|
|
719
|
-
"integrity": "sha512-
|
|
717
|
+
"version": "1.0.4",
|
|
718
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.4.tgz",
|
|
719
|
+
"integrity": "sha512-e198pjBsdEQJ/RCjJ9ZeYIjRaQYWUgtoZbPCmJ57auuOsiRsBXeSZ1aiWtTah0/7gx97WIOD1XqHvgRU0gOXtg==",
|
|
720
720
|
"license": "MIT",
|
|
721
721
|
"dependencies": {
|
|
722
722
|
"quickjs-wasi": "3.6.2"
|
|
@@ -726,14 +726,14 @@
|
|
|
726
726
|
}
|
|
727
727
|
},
|
|
728
728
|
"node_modules/@earendil-works/pi-durable": {
|
|
729
|
-
"version": "1.0.
|
|
730
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-durable/-/pi-durable-1.0.
|
|
731
|
-
"integrity": "sha512-
|
|
729
|
+
"version": "1.0.4",
|
|
730
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-durable/-/pi-durable-1.0.4.tgz",
|
|
731
|
+
"integrity": "sha512-i22unyhavxrTF/KS/JcBOKprQRgepufOIztnqBKZXJCWbEHsXDzcINtjmmBSbFB/3S+4FWIl3eJ5FMbRe33Ybg==",
|
|
732
732
|
"dev": true,
|
|
733
733
|
"license": "MIT",
|
|
734
734
|
"dependencies": {
|
|
735
|
-
"@earendil-works/chord": "^1.0.
|
|
736
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
735
|
+
"@earendil-works/chord": "^1.0.4",
|
|
736
|
+
"@earendil-works/pi-ai": "^1.0.4",
|
|
737
737
|
"diff": "8.0.4",
|
|
738
738
|
"typebox": "1.3.27"
|
|
739
739
|
},
|
|
@@ -742,9 +742,9 @@
|
|
|
742
742
|
}
|
|
743
743
|
},
|
|
744
744
|
"node_modules/@earendil-works/pi-mcp": {
|
|
745
|
-
"version": "1.0.
|
|
746
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-mcp/-/pi-mcp-1.0.
|
|
747
|
-
"integrity": "sha512-
|
|
745
|
+
"version": "1.0.4",
|
|
746
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-mcp/-/pi-mcp-1.0.4.tgz",
|
|
747
|
+
"integrity": "sha512-I6SqOqrKED+XrjkkFIXY7Ze38QtXtjojPJlQsJ2v5soCPV4QI1bNxXDwQaqzZ2a+6pNN8meWrRw1qkSMbPy9QQ==",
|
|
748
748
|
"license": "MIT",
|
|
749
749
|
"dependencies": {
|
|
750
750
|
"cross-spawn": "7.0.6"
|
|
@@ -754,13 +754,13 @@
|
|
|
754
754
|
}
|
|
755
755
|
},
|
|
756
756
|
"node_modules/@earendil-works/pi-protocol": {
|
|
757
|
-
"version": "1.0.
|
|
758
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-protocol/-/pi-protocol-1.0.
|
|
759
|
-
"integrity": "sha512-
|
|
757
|
+
"version": "1.0.4",
|
|
758
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-protocol/-/pi-protocol-1.0.4.tgz",
|
|
759
|
+
"integrity": "sha512-GJ1ieSJdguV3VaO5fXD+LEm6w1Rx0HKk7P1g8I6ZelmiGpmQAYOneUZaCUhAz5BeC6FpyUFzBb+AOo0Npfxtvw==",
|
|
760
760
|
"dev": true,
|
|
761
761
|
"license": "MIT",
|
|
762
762
|
"dependencies": {
|
|
763
|
-
"@earendil-works/chord": "^1.0.
|
|
763
|
+
"@earendil-works/chord": "^1.0.4",
|
|
764
764
|
"typebox": "1.3.27"
|
|
765
765
|
},
|
|
766
766
|
"engines": {
|
|
@@ -768,32 +768,32 @@
|
|
|
768
768
|
}
|
|
769
769
|
},
|
|
770
770
|
"node_modules/@earendil-works/pi-server": {
|
|
771
|
-
"version": "1.0.
|
|
772
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-server/-/pi-server-1.0.
|
|
773
|
-
"integrity": "sha512-
|
|
771
|
+
"version": "1.0.4",
|
|
772
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-server/-/pi-server-1.0.4.tgz",
|
|
773
|
+
"integrity": "sha512-9kQipVdjVMhprBzw/plrimPPDETNfFD7E2N8n1LBoLS7rcX+5js2hmUBJZPddmFnxNQgFeAgTgFH8bsCiWmlqw==",
|
|
774
774
|
"dev": true,
|
|
775
775
|
"license": "MIT",
|
|
776
776
|
"dependencies": {
|
|
777
|
-
"@earendil-works/chord": "^1.0.
|
|
778
|
-
"@earendil-works/pi-protocol": "^1.0.
|
|
777
|
+
"@earendil-works/chord": "^1.0.4",
|
|
778
|
+
"@earendil-works/pi-protocol": "^1.0.4"
|
|
779
779
|
},
|
|
780
780
|
"engines": {
|
|
781
781
|
"node": ">=22.19.0"
|
|
782
782
|
}
|
|
783
783
|
},
|
|
784
784
|
"node_modules/@earendil-works/pi-telemetry": {
|
|
785
|
-
"version": "1.0.
|
|
786
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.
|
|
787
|
-
"integrity": "sha512-
|
|
785
|
+
"version": "1.0.4",
|
|
786
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.4.tgz",
|
|
787
|
+
"integrity": "sha512-DL2eXXtnL5/VQkuQd97fL57GXTG1/zKHtMmDsrv8tGeJ5EgYYTWvzy44dqbYL0lD0Z22v/NOwqU3PHO75HVrqA==",
|
|
788
788
|
"license": "MIT",
|
|
789
789
|
"engines": {
|
|
790
790
|
"node": ">=22.19.0"
|
|
791
791
|
}
|
|
792
792
|
},
|
|
793
793
|
"node_modules/@earendil-works/pi-tui": {
|
|
794
|
-
"version": "1.0.
|
|
795
|
-
"resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.
|
|
796
|
-
"integrity": "sha512-
|
|
794
|
+
"version": "1.0.4",
|
|
795
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.4.tgz",
|
|
796
|
+
"integrity": "sha512-TgvDJohtxvG3XWQID5w6bwEyBocywdG0F9yHZtP+Ywvtiq9RgeSMbeB8quUobk7/4ko6IvFOQo45AqIqNVr8Rg==",
|
|
797
797
|
"license": "MIT",
|
|
798
798
|
"dependencies": {
|
|
799
799
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astralyn/pi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"prepublishOnly": "npm run clean && npm run build"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@earendil-works/chord": "1.0.
|
|
66
|
-
"@earendil-works/pi-agent-core": "1.0.
|
|
67
|
-
"@earendil-works/pi-ai": "1.0.
|
|
68
|
-
"@earendil-works/pi-codemode": "1.0.
|
|
69
|
-
"@earendil-works/pi-mcp": "1.0.
|
|
70
|
-
"@earendil-works/pi-tui": "1.0.
|
|
65
|
+
"@earendil-works/chord": "1.0.4",
|
|
66
|
+
"@earendil-works/pi-agent-core": "1.0.4",
|
|
67
|
+
"@earendil-works/pi-ai": "1.0.4",
|
|
68
|
+
"@earendil-works/pi-codemode": "1.0.4",
|
|
69
|
+
"@earendil-works/pi-mcp": "1.0.4",
|
|
70
|
+
"@earendil-works/pi-tui": "1.0.4",
|
|
71
71
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
72
72
|
"chalk": "6.0.0",
|
|
73
73
|
"cross-spawn": "7.0.6",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"@anthropic-ai/sandbox-runtime": "0.0.26",
|
|
90
90
|
"@anthropic-ai/sdk": "0.52.0",
|
|
91
91
|
"@biomejs/biome": "2.3.5",
|
|
92
|
-
"@earendil-works/pi-client": "1.0.
|
|
93
|
-
"@earendil-works/pi-durable": "1.0.
|
|
94
|
-
"@earendil-works/pi-protocol": "1.0.
|
|
95
|
-
"@earendil-works/pi-server": "1.0.
|
|
92
|
+
"@earendil-works/pi-client": "1.0.4",
|
|
93
|
+
"@earendil-works/pi-durable": "1.0.4",
|
|
94
|
+
"@earendil-works/pi-protocol": "1.0.4",
|
|
95
|
+
"@earendil-works/pi-server": "1.0.4",
|
|
96
96
|
"@types/cross-spawn": "6.0.6",
|
|
97
97
|
"@types/hosted-git-info": "3.0.5",
|
|
98
98
|
"@types/ms": "2.1.0",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{convertResponsesMessages,convertResponsesTools,processResponsesStream}from"./chunk-NY3CWK44.js";import{clampOpenAIPromptCacheKey}from"./chunk-APKJ4JGA.js";import{AzureOpenAI}from"./chunk-OO6DJ3CL.js";import{formatProviderError,normalizeProviderError}from"./chunk-FEZ5RM2B.js";import"./chunk-WWBSZG5V.js";import{retryProviderRequest}from"./chunk-GIG5IHES.js";import{buildBaseOptions,createGrammarToolInputProperties,getPiUserAgent,resolveSamplingParams}from"./chunk-SVJ7OGEB.js";import"./chunk-UP6RLTHQ.js";import{headersToRecord}from"./chunk-GCKVOFWP.js";import{getProviderEnvValue}from"./chunk-5FDOJRDS.js";import"./chunk-5B3S5DVL.js";import"./chunk-MPDALHNJ.js";import{clampThinkingLevel,getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-G4RY3GN7.js";import{AssistantMessageEventStream}from"./chunk-JI4WGISU.js";import"./chunk-4L3WN2XY.js";var DEFAULT_AZURE_API_VERSION="v1",AZURE_TOOL_CALL_PROVIDERS=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),OPENAI_RESPONSES_MIN_OUTPUT_TOKENS=16;function parseDeploymentNameMap(value){let map=new Map;if(!value)return map;for(let entry of value.split(",")){let trimmed=entry.trim();if(!trimmed)continue;let[modelId,deploymentName]=trimmed.split("=",2);!modelId||!deploymentName||map.set(modelId.trim(),deploymentName.trim())}return map}function resolveDeploymentName(model,options){return options?.azureDeploymentName?options.azureDeploymentName:parseDeploymentNameMap(getProviderEnvValue("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",options?.env)).get(model.id)||model.id}function formatAzureOpenAIError(error){return formatProviderError(normalizeProviderError(error),"Azure OpenAI API error")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,model.compat?.supportsMidConvoSystemMessages);return(async()=>{let deploymentName=resolveDeploymentName(model,options),output={role:"assistant",content:[],api:"azure-openai-responses",provider:model.provider,model:model.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let client=createClient(model,apiKey,options),grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages),model.compat?.supportsOpenAIGrammarTools??!1),params=buildParams(model,normalizedContext,options,deploymentName,grammarToolInputProperties),nextParams=await options?.onPayload?.(params,model);nextParams!==void 0&&(params=nextParams);let requestOptions={...options?.signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},maxRetries:0},{data:openaiStream,response}=await retryProviderRequest(()=>client.responses.create(params,requestOptions).withResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});if(await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output}),await processResponsesStream(openaiStream,output,stream2,model,{onProviderStreamEvent:options?.onProviderStreamEvent,grammarToolInputProperties}),options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){for(let block of output.content)delete block.index,delete block.partialJson,delete block.customInput;output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=formatAzureOpenAIError(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2},streamSimple=(model,context,options)=>{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let base={...buildBaseOptions(model,context,options,apiKey),toolChoice:options?.toolChoice},clampedReasoning=options?.reasoning?clampThinkingLevel(model,options.reasoning):void 0;return stream(model,context,{...base,reasoningEffort:clampedReasoning==="off"?void 0:clampedReasoning})};function normalizeAzureBaseUrl(baseUrl){let trimmed=baseUrl.trim().replace(/\/+$/,""),url;try{url=new URL(trimmed)}catch{throw new Error(`Invalid Azure OpenAI base URL: ${baseUrl}`)}let isAzureHost=url.hostname.endsWith(".openai.azure.com")||url.hostname.endsWith(".cognitiveservices.azure.com")||url.hostname.endsWith(".ai.azure.com"),normalizedPath=url.pathname.replace(/\/+$/,"");return isAzureHost&&(normalizedPath===""||normalizedPath==="/"||normalizedPath==="/openai"||normalizedPath==="/openai/v1/responses")&&(url.pathname="/openai/v1",url.search=""),url.toString().replace(/\/+$/,"")}function buildDefaultBaseUrl(resourceName){return`https://${resourceName}.openai.azure.com/openai/v1`}function resolveAzureConfig(model,options){let apiVersion=options?.azureApiVersion||getProviderEnvValue("AZURE_OPENAI_API_VERSION",options?.env)||DEFAULT_AZURE_API_VERSION,baseUrl=options?.azureBaseUrl?.trim()||getProviderEnvValue("AZURE_OPENAI_BASE_URL",options?.env)?.trim()||void 0,resourceName=options?.azureResourceName||getProviderEnvValue("AZURE_OPENAI_RESOURCE_NAME",options?.env),resolvedBaseUrl=baseUrl;if(!resolvedBaseUrl&&resourceName&&(resolvedBaseUrl=buildDefaultBaseUrl(resourceName)),!resolvedBaseUrl&&model.baseUrl&&(resolvedBaseUrl=model.baseUrl),!resolvedBaseUrl)throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:normalizeAzureBaseUrl(resolvedBaseUrl),apiVersion}}function createClient(model,apiKey,options){let headers={"User-Agent":getPiUserAgent(),...model.headers};options?.headers&&Object.assign(headers,options.headers);let{baseUrl,apiVersion}=resolveAzureConfig(model,options);return new AzureOpenAI({apiKey,apiVersion,dangerouslyAllowBrowser:!0,fetch:options?.fetch,defaultHeaders:headers,baseURL:baseUrl})}function buildParams(model,context,options,deploymentName,grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(context.messages),model.compat?.supportsOpenAIGrammarTools??!1)){let supportsAdditionalTools=model.compat?.supportsAdditionalTools??!1,supportsToolSearch=model.compat?.supportsToolSearch??!1,transcriptTools=resolveTranscriptTools(context.messages,supportsAdditionalTools||supportsToolSearch),messages=convertResponsesMessages(model,context,AZURE_TOOL_CALL_PROVIDERS,{grammarToolInputProperties,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools,supportsToolSearch,toolOptions:{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1}}),params={model:deploymentName,input:messages,stream:!0,prompt_cache_key:clampOpenAIPromptCacheKey(options?.sessionId),store:!1};options?.maxTokens&&(params.max_output_tokens=Math.max(options.maxTokens,OPENAI_RESPONSES_MIN_OUTPUT_TOKENS)),options?.temperature!==void 0&&(params.temperature=options?.temperature),transcriptTools.requestTools.length>0&&(params.tools=convertResponsesTools(transcriptTools.requestTools,{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1})),options?.toolChoice!==void 0&&(params.tool_choice=options.toolChoice);let reasoningEffort=options?.reasoningEffort??(options?.reasoningSummary?"medium":void 0);if(model.reasoning)if(reasoningEffort){let effort=options?.reasoningEffort?model.thinkingLevelMap?.[options.reasoningEffort]??options.reasoningEffort:reasoningEffort;params.reasoning={effort,summary:options?.reasoningSummary||"auto"},params.include=["reasoning.encrypted_content"]}else model.thinkingLevelMap?.off!==null&&(params.reasoning={effort:model.thinkingLevelMap?.off??"none"});let samplingParams=resolveSamplingParams(model,reasoningEffort??"off",options?.samplingParams);return samplingParams&&Object.assign(params,samplingParams),params}export{stream,streamSimple};
|