@astralyn/pi 1.0.3 → 1.0.4
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 +18 -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-Q7TDQ5LT.js → chunk-23OTKHCH.js} +52 -52
- package/dist/bundle/chunks/{chunk-MPDALHNJ.js → chunk-57XI7YJH.js} +1 -1
- package/dist/bundle/chunks/{chunk-N2LEX5CU.js → chunk-73WG7F7N.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-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 +0 -1
- 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-IJTAY26N.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/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/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/keybindings.d.ts +4 -4
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.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/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +49 -8
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.js +1 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +4 -9
- package/dist/extensions/mcp/tools.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/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/docs/codemode.md +3 -3
- package/docs/keybindings.md +7 -7
- package/docs/providers.md +5 -1
- 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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output files: files pi writes so the model can use output it was not shown in full, such as the
|
|
3
|
+
* full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.
|
|
4
|
+
* Every output file is created here, so where they are stored can change in one place. Today they
|
|
5
|
+
* go to the OS temp directory.
|
|
6
|
+
*/
|
|
7
|
+
import { type WriteStream } from "node:fs";
|
|
8
|
+
/** A new, unused path: `<dir>/<prefix>-<random hex><extension>`. `extension` includes the dot. */
|
|
9
|
+
export declare function createOutputFilePath(prefix: string, extension: string): string;
|
|
10
|
+
/** Write `data` to a new output file and return its path. */
|
|
11
|
+
export declare function writeOutputFile(prefix: string, extension: string, data: string | Uint8Array): Promise<string>;
|
|
12
|
+
/** Open a new output file for streamed output. */
|
|
13
|
+
export declare function createOutputFileStream(prefix: string, extension: string): {
|
|
14
|
+
path: string;
|
|
15
|
+
stream: WriteStream;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=output-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-files.d.ts","sourceRoot":"","sources":["../../src/utils/output-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAQ9D,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,6DAA6D;AAC7D,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAKnH;AAED,kDAAkD;AAClD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAG/G"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output files: files pi writes so the model can use output it was not shown in full, such as the
|
|
3
|
+
* full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.
|
|
4
|
+
* Every output file is created here, so where they are stored can change in one place. Today they
|
|
5
|
+
* go to the OS temp directory.
|
|
6
|
+
*/
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { createWriteStream } from "node:fs";
|
|
9
|
+
import { writeFile } from "node:fs/promises";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
/** Output can carry private data, so only the user may read the files. */
|
|
13
|
+
const OUTPUT_FILE_MODE = 0o600;
|
|
14
|
+
/** A new, unused path: `<dir>/<prefix>-<random hex><extension>`. `extension` includes the dot. */
|
|
15
|
+
export function createOutputFilePath(prefix, extension) {
|
|
16
|
+
return join(tmpdir(), `${prefix}-${randomBytes(8).toString("hex")}${extension}`);
|
|
17
|
+
}
|
|
18
|
+
/** Write `data` to a new output file and return its path. */
|
|
19
|
+
export async function writeOutputFile(prefix, extension, data) {
|
|
20
|
+
const path = createOutputFilePath(prefix, extension);
|
|
21
|
+
// `wx` never follows a link someone else placed at the path.
|
|
22
|
+
await writeFile(path, data, { mode: OUTPUT_FILE_MODE, flag: "wx" });
|
|
23
|
+
return path;
|
|
24
|
+
}
|
|
25
|
+
/** Open a new output file for streamed output. */
|
|
26
|
+
export function createOutputFileStream(prefix, extension) {
|
|
27
|
+
const path = createOutputFilePath(prefix, extension);
|
|
28
|
+
return { path, stream: createWriteStream(path, { mode: OUTPUT_FILE_MODE, flags: "wx" }) };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=output-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-files.js","sourceRoot":"","sources":["../../src/utils/output-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,kGAAkG;AAClG,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,SAAiB;IACrE,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,SAAiB,EAAE,IAAyB;IACjG,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,6DAA6D;IAC7D,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACb,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,SAAiB;IACvE,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC3F,CAAC","sourcesContent":["/**\n * Output files: files pi writes so the model can use output it was not shown in full, such as the\n * full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.\n * Every output file is created here, so where they are stored can change in one place. Today they\n * go to the OS temp directory.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Output can carry private data, so only the user may read the files. */\nconst OUTPUT_FILE_MODE = 0o600;\n\n/** A new, unused path: `<dir>/<prefix>-<random hex><extension>`. `extension` includes the dot. */\nexport function createOutputFilePath(prefix: string, extension: string): string {\n\treturn join(tmpdir(), `${prefix}-${randomBytes(8).toString(\"hex\")}${extension}`);\n}\n\n/** Write `data` to a new output file and return its path. */\nexport async function writeOutputFile(prefix: string, extension: string, data: string | Uint8Array): Promise<string> {\n\tconst path = createOutputFilePath(prefix, extension);\n\t// `wx` never follows a link someone else placed at the path.\n\tawait writeFile(path, data, { mode: OUTPUT_FILE_MODE, flag: \"wx\" });\n\treturn path;\n}\n\n/** Open a new output file for streamed output. */\nexport function createOutputFileStream(prefix: string, extension: string): { path: string; stream: WriteStream } {\n\tconst path = createOutputFilePath(prefix, extension);\n\treturn { path, stream: createWriteStream(path, { mode: OUTPUT_FILE_MODE, flags: \"wx\" }) };\n}\n"]}
|
package/docs/codemode.md
CHANGED
|
@@ -23,7 +23,7 @@ The result starts with `Script completed` or `Script failed`, the wall time, and
|
|
|
23
23
|
|---|---|
|
|
24
24
|
| `tools.<name>(args)` | Call a tool. See [Call tools](#call-tools). |
|
|
25
25
|
| `text(value)` | Add a text item to the output. Strings are added as is, other values as JSON. |
|
|
26
|
-
| `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. |
|
|
26
|
+
| `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. Each image is also saved to a temp file, and the result names the path before the image. |
|
|
27
27
|
| `console.log(...)` | Like `text()`; `info`, `warn`, `error`, and `debug` do the same. |
|
|
28
28
|
| `return value` | A top-level `return` adds the value like `text()`. |
|
|
29
29
|
| `exit()` | End the script successfully. |
|
|
@@ -54,7 +54,7 @@ While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) dec
|
|
|
54
54
|
|
|
55
55
|
`store(key, value)` keeps a JSON value under a string key for later `codemode` calls; storing `undefined` deletes the key. `load(key)` returns the value, or `undefined`. Writes are kept only when the script succeeds: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path.
|
|
56
56
|
|
|
57
|
-
The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()
|
|
57
|
+
The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()`, which also saves them to a temp file.
|
|
58
58
|
|
|
59
59
|
## Models
|
|
60
60
|
|
|
@@ -185,7 +185,7 @@ type TextBlock = { type: "text"; text: string };
|
|
|
185
185
|
type ImageBlock = { type: "image"; data: string; mimeType: string };
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text.
|
|
188
|
+
Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text. `image()` also saves each image to a temp file and puts its path in the result, so a later turn can copy or move the file.
|
|
189
189
|
|
|
190
190
|
```js
|
|
191
191
|
// @options: {"timeout_ms": 300000}
|
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/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:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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.3",
|
|
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.3",
|
|
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.3",
|
|
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.3",
|
|
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.3",
|
|
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.3",
|
|
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.3",
|
|
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.4",
|
|
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.4",
|
|
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.3",
|
|
13
|
+
"@earendil-works/pi-agent-core": "1.0.3",
|
|
14
|
+
"@earendil-works/pi-ai": "1.0.3",
|
|
15
|
+
"@earendil-works/pi-codemode": "1.0.3",
|
|
16
|
+
"@earendil-works/pi-mcp": "1.0.3",
|
|
17
|
+
"@earendil-works/pi-tui": "1.0.3",
|
|
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.3",
|
|
43
|
+
"@earendil-works/pi-durable": "1.0.3",
|
|
44
|
+
"@earendil-works/pi-protocol": "1.0.3",
|
|
45
|
+
"@earendil-works/pi-server": "1.0.3",
|
|
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.3",
|
|
634
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.3.tgz",
|
|
635
|
+
"integrity": "sha512-H5pKMs3S1z2q4V7NkDGKDFzOMW+OkzdsnGxxj5wNJUANG03VKj29UVmc1xnnnf0FAc03COHYNxwgNApO0nt0fg==",
|
|
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.3",
|
|
646
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.3.tgz",
|
|
647
|
+
"integrity": "sha512-lnvi2PJYaq8mDLzwWBttNqfxrLS63SSMONUJnTCypdvt/flmNJchXwWXsXUOJ5Yhe/mN+iHkrXu696lWZZ8o+w==",
|
|
648
648
|
"license": "MIT",
|
|
649
649
|
"dependencies": {
|
|
650
|
-
"@earendil-works/pi-ai": "^1.0.
|
|
650
|
+
"@earendil-works/pi-ai": "^1.0.3",
|
|
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.3",
|
|
659
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.3.tgz",
|
|
660
|
+
"integrity": "sha512-p+/EUrbmfT0xWOtL/NJRtWOsyzcKKFSyiivHLDBMG0DUVpHdaIykd5jFibq0YZDFGBN/nv61zdOelMb+ylPfSg==",
|
|
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.3",
|
|
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.3",
|
|
704
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-client/-/pi-client-1.0.3.tgz",
|
|
705
|
+
"integrity": "sha512-9kV6FL2wpAIH9skwhgMJLZzcOtNwy2lgQpNmdVfSr1Q6nvx1/T4uENI6AsIRNI6XNlZYEObEjL4zIApAsEKQ4g==",
|
|
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.3",
|
|
710
|
+
"@earendil-works/pi-protocol": "^1.0.3"
|
|
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.3",
|
|
718
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.3.tgz",
|
|
719
|
+
"integrity": "sha512-/rgWAXA9PhuFm0+j6N5FVvvWrAwt1LnhmbjA3Hy5+Q033XUHgh0YCMGAmU76S90ocr0Vfxm50ddYT/O76T5OGQ==",
|
|
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.3",
|
|
730
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-durable/-/pi-durable-1.0.3.tgz",
|
|
731
|
+
"integrity": "sha512-ARA+YQcqiQJz2pqxLL2ZA4ayZoulSDu1cMCMIYiKBnByTryGVfBhkEv6pT+QOP+3NgXzs0zPi3FpvyuSJ9harg==",
|
|
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.3",
|
|
736
|
+
"@earendil-works/pi-ai": "^1.0.3",
|
|
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.3",
|
|
746
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-mcp/-/pi-mcp-1.0.3.tgz",
|
|
747
|
+
"integrity": "sha512-ZAhL/g0rpjyKtcKzD0jSDk7sFIrMCQocmKtpAE1F9eRnI5fGGVWUyiZwALG/Tn1sagzxFbSqtc29zGx5OvDDGA==",
|
|
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.3",
|
|
758
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-protocol/-/pi-protocol-1.0.3.tgz",
|
|
759
|
+
"integrity": "sha512-MzZiuOrNptFbSYxqYeBIQEm8v5dT7I2JcQicVi38GWYM2ChgBmUk9RaNCJrULo6yo5/WQt85s4puURDCSnxRBQ==",
|
|
760
760
|
"dev": true,
|
|
761
761
|
"license": "MIT",
|
|
762
762
|
"dependencies": {
|
|
763
|
-
"@earendil-works/chord": "^1.0.
|
|
763
|
+
"@earendil-works/chord": "^1.0.3",
|
|
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.3",
|
|
772
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-server/-/pi-server-1.0.3.tgz",
|
|
773
|
+
"integrity": "sha512-iJrvnN1SR+nTbWt/K9jAZYfqczZF2K18XqLTLcgHaO/fh3OE5vzb12YA90wkJfv4/i7rfRglkucWLrG9d8e1eg==",
|
|
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.3",
|
|
778
|
+
"@earendil-works/pi-protocol": "^1.0.3"
|
|
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.3",
|
|
786
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.3.tgz",
|
|
787
|
+
"integrity": "sha512-Li4YamN09x9zzCquPbtEL2AQmwqv3Vn3sNOYqG0DRg24fjiMfntCsb7QKbejCXZssTAyaN+hutLl6O0UnJDrfg==",
|
|
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.3",
|
|
795
|
+
"resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.3.tgz",
|
|
796
|
+
"integrity": "sha512-C7b8Y+7iz+/oPEZUJubv6NPm3M/4ziq0hjQ2jhqMNpBwcXeqDMYKL2FYP90t2b5S1IoGc2io47dj5ZlIC1IZWg==",
|
|
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.4",
|
|
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.3",
|
|
66
|
+
"@earendil-works/pi-agent-core": "1.0.3",
|
|
67
|
+
"@earendil-works/pi-ai": "1.0.3",
|
|
68
|
+
"@earendil-works/pi-codemode": "1.0.3",
|
|
69
|
+
"@earendil-works/pi-mcp": "1.0.3",
|
|
70
|
+
"@earendil-works/pi-tui": "1.0.3",
|
|
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.3",
|
|
93
|
+
"@earendil-works/pi-durable": "1.0.3",
|
|
94
|
+
"@earendil-works/pi-protocol": "1.0.3",
|
|
95
|
+
"@earendil-works/pi-server": "1.0.3",
|
|
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};
|