@averyyy/pi-coding-agent 1.2.0-piclient.2 → 1.3.0-piclient.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/dist/bundle/chunks/anthropic-messages-3X7RGZOH.js +6 -0
- package/dist/bundle/chunks/{azure-openai-responses-ONC234KU.js → azure-openai-responses-NCLIAF3T.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +5 -2
- package/dist/bundle/chunks/chunk-62UE2F77.js +11 -0
- package/dist/bundle/chunks/{chunk-OK5HMGJH.js → chunk-AHZ6SVN5.js} +1 -1
- package/dist/bundle/chunks/{chunk-RUVBX4HZ.js → chunk-HYJBDAY7.js} +39 -38
- package/dist/bundle/chunks/{chunk-MCRRDQUQ.js → chunk-JBOKZR45.js} +10 -10
- package/dist/bundle/chunks/{chunk-QNH5RXIC.js → chunk-LPK46NYT.js} +2 -2
- package/dist/bundle/chunks/{chunk-TRDNDS6A.js → chunk-PYGXRV27.js} +5 -2
- package/dist/bundle/chunks/{chunk-KHMP74W7.js → chunk-UQE6EICI.js} +1 -1
- package/dist/bundle/chunks/{execute-G3X3GRKI.js → execute-ZWI524ZI.js} +3 -3
- package/dist/bundle/chunks/{google-generative-ai-OPRBPNHR.js → google-generative-ai-MQTWSDFG.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-VC2DWOR5.js → google-vertex-3SS26JHC.js} +1 -1
- package/dist/bundle/chunks/mistral-conversations-52JCPM2W.js +5 -0
- package/dist/bundle/chunks/{openai-codex-responses-NQKFQIGV.js → openai-codex-responses-2TJ4XIVX.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-NNHMY5BP.js → openai-completions-UPWOEWKS.js} +1 -1
- package/dist/bundle/chunks/openai-responses-PWAHY2XA.js +3 -0
- package/dist/bundle/chunks/{pi-messages-EMTA6VNL.js → pi-messages-CCIZT6RQ.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-PGCF2Z7J.js → virtual-modules-AOQNHCN5.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +4 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/list-models.js +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-services.js +2 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +5 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +16 -8
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +43 -63
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/template.js +21 -16
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/model-config.d.ts +24 -8
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-resolver.d.ts +56 -43
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +251 -356
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +8 -11
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/pi-client-runtime-update.d.ts +3 -1
- package/dist/core/pi-client-runtime-update.d.ts.map +1 -1
- package/dist/core/pi-client-runtime-update.js +11 -9
- package/dist/core/pi-client-runtime-update.js.map +1 -1
- package/dist/core/pi-server-client.d.ts.map +1 -1
- package/dist/core/pi-server-client.js +5 -3
- package/dist/core/pi-server-client.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +7 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +10 -18
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.js +4 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -0
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -0
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +11 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +2 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +4 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +2 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +21 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +7 -11
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +12 -0
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +109 -10
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -9
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +86 -25
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +9 -2
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/docs/cli.md +3 -3
- package/docs/codemode.md +2 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +4 -2
- package/docs/llama-cpp.md +1 -1
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/sessions.md +1 -1
- package/docs/settings.md +1 -0
- package/docs/usage.md +1 -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/minimal-mode.ts +4 -5
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/index.ts +4 -6
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +6 -6
- package/schemas/models.schema.json +5 -5
- package/schemas/settings.schema.json +18 -0
- package/dist/bundle/chunks/anthropic-messages-Y556A57W.js +0 -6
- package/dist/bundle/chunks/chunk-5UQLMALR.js +0 -11
- package/dist/bundle/chunks/mistral-conversations-JJ6S2EPK.js +0 -5
- package/dist/bundle/chunks/openai-responses-XDTCR5JC.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-share.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/session-share.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAa,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAGnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,UAAU,mBAAmB;IAC5B,OAAO,EAAE,YAAY,CAAC;IACtB,EAAE,EAAE,GAAG,CAAC;IACR,eAAe,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,oGAAoG;AACpG,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,SAAS,EAAE,MAAM,GACf,MAAM,EAAE,CAkBV;AAED,uEAAuE;AACvE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAInF;AAED,gFAAgF;AAChF,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"session-share.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/session-share.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAa,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAGnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,UAAU,mBAAmB;IAC5B,OAAO,EAAE,YAAY,CAAC;IACtB,EAAE,EAAE,GAAG,CAAC;IACR,eAAe,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,oGAAoG;AACpG,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,SAAS,EAAE,MAAM,GACf,MAAM,EAAE,CAkBV;AAED,uEAAuE;AACvE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAInF;AAED,gFAAgF;AAChF,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8C9E"}
|
|
@@ -47,8 +47,15 @@ export async function shareSession(context) {
|
|
|
47
47
|
context.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const destination = context.session.settingsManager.getSessionShareDestination();
|
|
51
|
+
if (destination !== "gist") {
|
|
52
|
+
if (await tryShareViaRadius(jsonlFile, context))
|
|
53
|
+
return;
|
|
54
|
+
if (destination === "radius") {
|
|
55
|
+
context.showError("Radius authentication is not configured. Run '/login radius' first.");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
52
59
|
try {
|
|
53
60
|
const authResult = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
|
|
54
61
|
if (authResult.status !== 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-share.js","sourceRoot":"","sources":["../../../src/modes/interactive/session-share.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,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,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,CAAC,UAAU,CAAC,cAAc,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,WAAW,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7G,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC5B,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,SAAS,CAAC,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QACzG,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,aAAa,CAAC,MAAsB,EAAE,OAA4B;IAC1E,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAChC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { spawn, spawnSync } from \"node:child_process\";\nimport * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { DEFAULT_RADIUS_GATEWAY } from \"@earendil-works/pi-ai/providers/radius-config\";\nimport { type Container, type EditorComponent, hyperlink, type TUI } from \"@earendil-works/pi-tui\";\nimport { getAuthCredential } from \"../../cli/auth-command.ts\";\nimport { getShareViewerUrl } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { exportSessionToJsonl } from \"../../core/session-export.ts\";\nimport { BorderedLoader } from \"./components/bordered-loader.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\ninterface SessionShareContext {\n\tsession: AgentSession;\n\tui: TUI;\n\teditorContainer: Container;\n\teditor: EditorComponent;\n\tshowStatus: (message: string) => void;\n\tshowError: (message: string) => void;\n}\n\n/** Trailing `pi.share` entry carrying the system prompt and tool schemas for the session viewer. */\nexport function createShareTrailingEntries(\n\tsession: AgentSession,\n\tparentId: string | null,\n\ttimestamp: string,\n): object[] {\n\treturn [\n\t\t{\n\t\t\ttype: \"custom\",\n\t\t\tcustomType: \"pi.share\",\n\t\t\tid: crypto.randomUUID().slice(0, 8),\n\t\t\tparentId,\n\t\t\ttimestamp,\n\t\t\tdata: {\n\t\t\t\tsystemPrompt: session.state.systemPrompt,\n\t\t\t\ttools: session.state.tools.map((tool) => ({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t})),\n\t\t\t},\n\t\t},\n\t];\n}\n\n/** Export the current branch with presentation metadata for Radius. */\nexport function exportSessionForShare(filePath: string, session: AgentSession): void {\n\texportSessionToJsonl(session.sessionManager, filePath, (parentId, timestamp) =>\n\t\tcreateShareTrailingEntries(session, parentId, timestamp),\n\t);\n}\n\n/** Share the current session through Radius, falling back to a private gist. */\nexport async function shareSession(context: SessionShareContext): Promise<void> {\n\tconst tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-share-\"));\n\tconst jsonlFile = path.join(tempDir, \"session.jsonl\");\n\tconst htmlFile = path.join(tempDir, \"session.html\");\n\n\ttry {\n\t\ttry {\n\t\t\texportSessionForShare(jsonlFile, context.session);\n\t\t} catch (error: unknown) {\n\t\t\tcontext.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\t\tif (await tryShareViaRadius(jsonlFile, context)) return;\n\n\t\ttry {\n\t\t\tconst authResult = spawnSync(\"gh\", [\"auth\", \"status\"], { encoding: \"utf-8\" });\n\t\t\tif (authResult.status !== 0) {\n\t\t\t\tcontext.showError(\"GitHub CLI is not logged in. Run 'gh auth login' first.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch {\n\t\t\tcontext.showError(\"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait context.session.exportToHtml(htmlFile, { themeName: theme.name });\n\t\t} catch (error: unknown) {\n\t\t\tcontext.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\t\tawait shareViaGist(htmlFile, context);\n\t} finally {\n\t\ttry {\n\t\t\tfs.rmSync(tempDir, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Ignore cleanup errors\n\t\t}\n\t}\n}\n\nasync function tryShareViaRadius(tmpFile: string, context: SessionShareContext): Promise<boolean> {\n\tconst provider = context.session.modelRuntime.getProvider(\"radius\");\n\tif (!provider) return false;\n\n\tconst token = getAuthCredential(\n\t\tawait context.session.modelRuntime.getAuth(\"radius\", { minOAuthValidityMs: 5 * 60_000 }),\n\t);\n\tif (!token) return false;\n\n\tconst loader = new BorderedLoader(context.ui, theme, \"Uploading to Radius...\");\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(loader);\n\tcontext.ui.setFocus(loader);\n\tcontext.ui.requestRender();\n\tloader.onAbort = () => {\n\t\trestoreEditor(loader, context);\n\t\tcontext.showStatus(\"Share cancelled\");\n\t};\n\n\ttry {\n\t\tconst body = fs.readFileSync(tmpFile);\n\t\tconst url = new URL(\"/v1/artifacts\", DEFAULT_RADIUS_GATEWAY);\n\t\turl.searchParams.set(\"visibility\", \"organization\");\n\t\turl.searchParams.set(\"title\", \"Pi session\");\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\"Content-Type\": \"application/x-ndjson\",\n\t\t\t\t\"Content-Length\": String(body.byteLength),\n\t\t\t},\n\t\t\tbody,\n\t\t\tsignal: loader.signal,\n\t\t});\n\t\tif (loader.signal.aborted) return true;\n\t\tconst json = (await response.json().catch(() => null)) as {\n\t\t\tartifact?: { canonical_url: string };\n\t\t\terror?: string;\n\t\t} | null;\n\t\tif (loader.signal.aborted) return true;\n\t\trestoreEditor(loader, context);\n\t\tif (!response.ok || !json?.artifact) {\n\t\t\tcontext.showError(\n\t\t\t\t`Failed to upload Radius artifact: ${json?.error || response.statusText || response.status}`,\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\t\tconst shareUrl = json.artifact.canonical_url;\n\t\tcontext.showStatus(`Share URL: ${hyperlink(shareUrl, shareUrl)}`);\n\t\treturn true;\n\t} catch (error: unknown) {\n\t\tif (!loader.signal.aborted) {\n\t\t\trestoreEditor(loader, context);\n\t\t\tcontext.showError(\n\t\t\t\t`Failed to upload Radius artifact: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n\nasync function shareViaGist(tmpFile: string, context: SessionShareContext): Promise<void> {\n\tconst loader = new BorderedLoader(context.ui, theme, \"Creating gist...\");\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(loader);\n\tcontext.ui.setFocus(loader);\n\tcontext.ui.requestRender();\n\n\tlet proc: ReturnType<typeof spawn> | null = null;\n\tloader.onAbort = () => {\n\t\tproc?.kill();\n\t\trestoreEditor(loader, context);\n\t\tcontext.showStatus(\"Share cancelled\");\n\t};\n\n\ttry {\n\t\tconst result = await new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve) => {\n\t\t\tproc = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile]);\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tproc.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n\t\t});\n\n\t\tif (loader.signal.aborted) return;\n\t\trestoreEditor(loader, context);\n\n\t\tif (result.code !== 0) {\n\t\t\tcontext.showError(`Failed to create gist: ${result.stderr?.trim() || \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gistUrl = result.stdout?.trim();\n\t\tconst gistId = gistUrl?.split(\"/\").pop();\n\t\tif (!gistId) {\n\t\t\tcontext.showError(\"Failed to parse gist ID from gh output\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst previewUrl = getShareViewerUrl(gistId);\n\t\tcontext.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\\nGist: ${hyperlink(gistUrl, gistUrl)}`);\n\t} catch (error: unknown) {\n\t\tif (!loader.signal.aborted) {\n\t\t\trestoreEditor(loader, context);\n\t\t\tcontext.showError(`Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t}\n\t}\n}\n\nfunction restoreEditor(loader: BorderedLoader, context: SessionShareContext): void {\n\tloader.dispose();\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(context.editor);\n\tcontext.ui.setFocus(context.editor);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-share.js","sourceRoot":"","sources":["../../../src/modes/interactive/session-share.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAwC,SAAS,EAAY,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,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AAO;QACR,CAAC;QAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC7C,OAAO,CAAC,UAAU,CAAC,cAAc,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,WAAW,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7G,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC5B,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,SAAS,CAAC,0BAA0B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QACzG,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAS,aAAa,CAAC,MAAsB,EAAE,OAA4B;IAC1E,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAChC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import { spawn, spawnSync } from \"node:child_process\";\nimport * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { DEFAULT_RADIUS_GATEWAY } from \"@earendil-works/pi-ai/providers/radius-config\";\nimport { type Container, type EditorComponent, hyperlink, type TUI } from \"@earendil-works/pi-tui\";\nimport { getAuthCredential } from \"../../cli/auth-command.ts\";\nimport { getShareViewerUrl } from \"../../config.ts\";\nimport type { AgentSession } from \"../../core/agent-session.ts\";\nimport { exportSessionToJsonl } from \"../../core/session-export.ts\";\nimport { BorderedLoader } from \"./components/bordered-loader.ts\";\nimport { theme } from \"./theme/theme.ts\";\n\ninterface SessionShareContext {\n\tsession: AgentSession;\n\tui: TUI;\n\teditorContainer: Container;\n\teditor: EditorComponent;\n\tshowStatus: (message: string) => void;\n\tshowError: (message: string) => void;\n}\n\n/** Trailing `pi.share` entry carrying the system prompt and tool schemas for the session viewer. */\nexport function createShareTrailingEntries(\n\tsession: AgentSession,\n\tparentId: string | null,\n\ttimestamp: string,\n): object[] {\n\treturn [\n\t\t{\n\t\t\ttype: \"custom\",\n\t\t\tcustomType: \"pi.share\",\n\t\t\tid: crypto.randomUUID().slice(0, 8),\n\t\t\tparentId,\n\t\t\ttimestamp,\n\t\t\tdata: {\n\t\t\t\tsystemPrompt: session.state.systemPrompt,\n\t\t\t\ttools: session.state.tools.map((tool) => ({\n\t\t\t\t\tname: tool.name,\n\t\t\t\t\tdescription: tool.description,\n\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t})),\n\t\t\t},\n\t\t},\n\t];\n}\n\n/** Export the current branch with presentation metadata for Radius. */\nexport function exportSessionForShare(filePath: string, session: AgentSession): void {\n\texportSessionToJsonl(session.sessionManager, filePath, (parentId, timestamp) =>\n\t\tcreateShareTrailingEntries(session, parentId, timestamp),\n\t);\n}\n\n/** Share the current session through Radius, falling back to a private gist. */\nexport async function shareSession(context: SessionShareContext): Promise<void> {\n\tconst tempDir = fs.mkdtempSync(path.join(os.tmpdir(), \"pi-share-\"));\n\tconst jsonlFile = path.join(tempDir, \"session.jsonl\");\n\tconst htmlFile = path.join(tempDir, \"session.html\");\n\n\ttry {\n\t\ttry {\n\t\t\texportSessionForShare(jsonlFile, context.session);\n\t\t} catch (error: unknown) {\n\t\t\tcontext.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\t\tconst destination = context.session.settingsManager.getSessionShareDestination();\n\t\tif (destination !== \"gist\") {\n\t\t\tif (await tryShareViaRadius(jsonlFile, context)) return;\n\t\t\tif (destination === \"radius\") {\n\t\t\t\tcontext.showError(\"Radius authentication is not configured. Run '/login radius' first.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst authResult = spawnSync(\"gh\", [\"auth\", \"status\"], { encoding: \"utf-8\" });\n\t\t\tif (authResult.status !== 0) {\n\t\t\t\tcontext.showError(\"GitHub CLI is not logged in. Run 'gh auth login' first.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch {\n\t\t\tcontext.showError(\"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait context.session.exportToHtml(htmlFile, { themeName: theme.name });\n\t\t} catch (error: unknown) {\n\t\t\tcontext.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\t\tawait shareViaGist(htmlFile, context);\n\t} finally {\n\t\ttry {\n\t\t\tfs.rmSync(tempDir, { recursive: true, force: true });\n\t\t} catch {\n\t\t\t// Ignore cleanup errors\n\t\t}\n\t}\n}\n\nasync function tryShareViaRadius(tmpFile: string, context: SessionShareContext): Promise<boolean> {\n\tconst provider = context.session.modelRuntime.getProvider(\"radius\");\n\tif (!provider) return false;\n\n\tconst token = getAuthCredential(\n\t\tawait context.session.modelRuntime.getAuth(\"radius\", { minOAuthValidityMs: 5 * 60_000 }),\n\t);\n\tif (!token) return false;\n\n\tconst loader = new BorderedLoader(context.ui, theme, \"Uploading to Radius...\");\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(loader);\n\tcontext.ui.setFocus(loader);\n\tcontext.ui.requestRender();\n\tloader.onAbort = () => {\n\t\trestoreEditor(loader, context);\n\t\tcontext.showStatus(\"Share cancelled\");\n\t};\n\n\ttry {\n\t\tconst body = fs.readFileSync(tmpFile);\n\t\tconst url = new URL(\"/v1/artifacts\", DEFAULT_RADIUS_GATEWAY);\n\t\turl.searchParams.set(\"visibility\", \"organization\");\n\t\turl.searchParams.set(\"title\", \"Pi session\");\n\t\tconst response = await fetch(url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${token}`,\n\t\t\t\t\"Content-Type\": \"application/x-ndjson\",\n\t\t\t\t\"Content-Length\": String(body.byteLength),\n\t\t\t},\n\t\t\tbody,\n\t\t\tsignal: loader.signal,\n\t\t});\n\t\tif (loader.signal.aborted) return true;\n\t\tconst json = (await response.json().catch(() => null)) as {\n\t\t\tartifact?: { canonical_url: string };\n\t\t\terror?: string;\n\t\t} | null;\n\t\tif (loader.signal.aborted) return true;\n\t\trestoreEditor(loader, context);\n\t\tif (!response.ok || !json?.artifact) {\n\t\t\tcontext.showError(\n\t\t\t\t`Failed to upload Radius artifact: ${json?.error || response.statusText || response.status}`,\n\t\t\t);\n\t\t\treturn true;\n\t\t}\n\t\tconst shareUrl = json.artifact.canonical_url;\n\t\tcontext.showStatus(`Share URL: ${hyperlink(shareUrl, shareUrl)}`);\n\t\treturn true;\n\t} catch (error: unknown) {\n\t\tif (!loader.signal.aborted) {\n\t\t\trestoreEditor(loader, context);\n\t\t\tcontext.showError(\n\t\t\t\t`Failed to upload Radius artifact: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n}\n\nasync function shareViaGist(tmpFile: string, context: SessionShareContext): Promise<void> {\n\tconst loader = new BorderedLoader(context.ui, theme, \"Creating gist...\");\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(loader);\n\tcontext.ui.setFocus(loader);\n\tcontext.ui.requestRender();\n\n\tlet proc: ReturnType<typeof spawn> | null = null;\n\tloader.onAbort = () => {\n\t\tproc?.kill();\n\t\trestoreEditor(loader, context);\n\t\tcontext.showStatus(\"Share cancelled\");\n\t};\n\n\ttry {\n\t\tconst result = await new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve) => {\n\t\t\tproc = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile]);\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tproc.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n\t\t});\n\n\t\tif (loader.signal.aborted) return;\n\t\trestoreEditor(loader, context);\n\n\t\tif (result.code !== 0) {\n\t\t\tcontext.showError(`Failed to create gist: ${result.stderr?.trim() || \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\n\t\tconst gistUrl = result.stdout?.trim();\n\t\tconst gistId = gistUrl?.split(\"/\").pop();\n\t\tif (!gistId) {\n\t\t\tcontext.showError(\"Failed to parse gist ID from gh output\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst previewUrl = getShareViewerUrl(gistId);\n\t\tcontext.showStatus(`Share URL: ${hyperlink(previewUrl, previewUrl)}\\nGist: ${hyperlink(gistUrl, gistUrl)}`);\n\t} catch (error: unknown) {\n\t\tif (!loader.signal.aborted) {\n\t\t\trestoreEditor(loader, context);\n\t\t\tcontext.showError(`Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t}\n\t}\n}\n\nfunction restoreEditor(loader: BorderedLoader, context: SessionShareContext): void {\n\tloader.dispose();\n\tcontext.editorContainer.clear();\n\tcontext.editorContainer.addChild(context.editor);\n\tcontext.ui.setFocus(context.editor);\n}\n"]}
|
package/docs/cli.md
CHANGED
|
@@ -63,13 +63,13 @@ See [Choose a Model](models.md) for model selection and [Providers](providers.md
|
|
|
63
63
|
- `--provider <name>`<br>
|
|
64
64
|
Restricts `--model` lookup to one provider. It requires `--model`.
|
|
65
65
|
- `--model <pattern>`<br>
|
|
66
|
-
Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix.
|
|
66
|
+
Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix. If several providers match, Pi prefers the one with credentials, otherwise it asks for `--provider`.
|
|
67
67
|
- `--api-key <key>`<br>
|
|
68
|
-
Uses a non-persistent API-key override. It requires a model selected through `--model` or `--models`.
|
|
68
|
+
Uses a non-persistent API-key override. It requires a model selected through `--model` or `--models`. It does not choose between providers that offer the same model.
|
|
69
69
|
- `--thinking <level>`<br>
|
|
70
70
|
Sets `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. It overrides a `--model` suffix and is clamped to the model's capabilities.
|
|
71
71
|
- `--models <patterns>`<br>
|
|
72
|
-
Sets a comma-separated scope for startup and cycling. It accepts exact IDs, fuzzy matches, case-insensitive globs, and optional `:<thinking>` suffixes.
|
|
72
|
+
Sets a comma-separated scope for startup and cycling. It accepts exact IDs, fuzzy matches, case-insensitive globs, and optional `:<thinking>` suffixes. A model offered by several providers is added for each, with a warning.
|
|
73
73
|
- `--list-models [search]`<br>
|
|
74
74
|
Lists available models, optionally filtered by a fuzzy search, then exits.
|
|
75
75
|
|
package/docs/codemode.md
CHANGED
|
@@ -224,5 +224,7 @@ for (const block of result.output) {
|
|
|
224
224
|
## Limits
|
|
225
225
|
|
|
226
226
|
- A script's VM has 256 MB of memory. Running out throws `InternalError: out of memory`; filter or aggregate large data instead of accumulating it.
|
|
227
|
+
- On Bun, stopping a script or reaching its deadline ends the call promptly, but a built-in that does not poll QuickJS's interrupt handler can keep computing in its worker until it returns.
|
|
228
|
+
- At most two codemode workers may be alive across all sessions in one pi process. A cancelled worker occupies its slot until it exits. At capacity, new scripts fail immediately without starting another worker; retry after an existing worker exits.
|
|
227
229
|
- A script that waits on a promise that can never settle (no tool call pending) fails immediately, since there are no timers.
|
|
228
230
|
- Scripts cannot start other `codemode` scripts.
|
package/docs/docs.json
CHANGED
package/docs/extensions.md
CHANGED
|
@@ -119,7 +119,7 @@ Handlers are awaited in stream order, so slow handlers delay stream consumption.
|
|
|
119
119
|
|
|
120
120
|
<a id="cache_warming_decision"></a>
|
|
121
121
|
|
|
122
|
-
`cache_warming_decision` can override an idle prompt-cache refresh with `{ action: "warm" }` or `{ action: "stop" }`. The last handler that returns an action wins.
|
|
122
|
+
`cache_warming_decision` can override an idle prompt-cache refresh with `{ action: "warm" }` or `{ action: "stop" }`. The last handler that returns an action wins. A failed handler stops cache warming and exposes the error in `/session`.
|
|
123
123
|
|
|
124
124
|
Tool calls from one assistant message can run in parallel.
|
|
125
125
|
Do not assume a sibling call or result exists when another tool event runs.
|
|
@@ -260,7 +260,9 @@ Keep tool and event behavior independent from rendering so non-interactive modes
|
|
|
260
260
|
|
|
261
261
|
### Errors and cleanup
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
Errors in `input`, `context`, `context_with_system`, `before_agent_start`, `before_provider_request`, and `before_provider_headers` stop the affected request. Pi reports the original error and stops that handler chain before calling the provider. Notification handler errors are reported while notification dispatch continues.
|
|
264
|
+
|
|
265
|
+
A `tool_call` handler failure blocks the tool; a tool execution failure becomes an error result for the model. `pi.exec()` rejects when the command cannot start and returns a nonzero exit code when a signal terminates the child.
|
|
264
266
|
|
|
265
267
|
Release resources in `session_shutdown` even when normal operation attempted cleanup.
|
|
266
268
|
Keep cleanup idempotent because cancellation, reload, session replacement, and process exit can converge on the same path.
|
package/docs/llama-cpp.md
CHANGED
|
@@ -41,7 +41,7 @@ A single-file model can sit directly in the model directory. Put multimodal and
|
|
|
41
41
|
└── large-model-Q4_K_M-00003-of-00003.gguf
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Restart the router after manually adding files. For per-model context sizes and other options, use [llama.cpp model presets](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md#model-presets).
|
|
44
|
+
Restart the router after manually adding files. For per-model context sizes and other options, use [llama.cpp model presets](https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md#model-presets). For settings tuned to a specific NVIDIA GPU and model, see [Run Pi with NVIDIA RTX and llama.cpp](nvidia-rtx-llama-cpp.md).
|
|
45
45
|
|
|
46
46
|
## Configure Pi
|
|
47
47
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Run Pi with NVIDIA RTX and llama.cpp
|
|
2
|
+
|
|
3
|
+
[NVIDIA Local AI Inference Recipes](https://nvidia.github.io/local-ai-inference-recipes/index.html) provides llama.cpp settings tuned for specific NVIDIA hardware and models. Each recipe gives a single-model `llama-server` command. Pi works with the llama.cpp router, which can serve and manage several models, so this guide converts the recipe command into a router preset.
|
|
4
|
+
|
|
5
|
+
The examples below use Windows PowerShell. See [Local Models with llama.cpp](llama-cpp.md) for Pi's complete router and model-management reference.
|
|
6
|
+
|
|
7
|
+
## Before you begin
|
|
8
|
+
|
|
9
|
+
1. Open the [recipe catalog](https://nvidia.github.io/local-ai-inference-recipes/index.html), select your hardware, operating system, and model, then choose **llama.cpp**. Check the prerequisites and memory requirements. Keep the recipe's launch command for the conversion below.
|
|
10
|
+
2. Install llama.cpp with the recipe's setup instructions. The recipe's settings depend on its build, for example CUDA support or speculative decoding options.
|
|
11
|
+
3. Run `llama-server --help` and check that it lists `--models-preset`. Without it, the build cannot load the recipe as a router preset. Use a newer build that still meets the recipe's requirements.
|
|
12
|
+
4. Install Pi with the [Quickstart](quickstart.md). On native Windows, also see [Run Pi on Windows](windows.md).
|
|
13
|
+
|
|
14
|
+
## Convert the recipe to a preset
|
|
15
|
+
|
|
16
|
+
A preset lists the settings for one or more models. Each section name becomes the model ID shown in Pi. Save the preset next to `llama-server`, or pass its full path when starting the router.
|
|
17
|
+
|
|
18
|
+
Convert each option from the recipe command into one preset line:
|
|
19
|
+
|
|
20
|
+
- Remove the leading dashes: `--ctx-size 65536` becomes `ctx-size = 65536`.
|
|
21
|
+
- Write options without a value as `true`: `--jinja` becomes `jinja = true`.
|
|
22
|
+
- Remove quotes and PowerShell line-continuation backticks around values.
|
|
23
|
+
- Leave out `--host` and `--port`. They belong on the router command line.
|
|
24
|
+
- Add `load-on-startup = true` so the router loads the model when it starts.
|
|
25
|
+
- Replace short model-file options with their long preset keys:
|
|
26
|
+
|
|
27
|
+
| Recipe option | Preset key |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `-hf` | `hf-repo` |
|
|
30
|
+
| `-hff` | `hf-file` |
|
|
31
|
+
| `-hfrd` | `hf-repo-draft` |
|
|
32
|
+
| `--spec-draft-model` | `spec-draft-model` |
|
|
33
|
+
|
|
34
|
+
For example, this recipe command:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
llama-server.exe -hf "unsloth/Qwen3.8-27B-GGUF" `
|
|
38
|
+
-hff "Qwen3.8-27B-UD-Q4_K_M.gguf" `
|
|
39
|
+
-hfrd "z-lab/Qwen3.8-27B-DFlash2-GGUF" `
|
|
40
|
+
--spec-draft-model "Qwen3.8-27B-DFlash2-Q4_K_M.gguf" `
|
|
41
|
+
--no-mmproj `
|
|
42
|
+
--host 127.0.0.1 `
|
|
43
|
+
--port 9931 `
|
|
44
|
+
--batch-size 4096 `
|
|
45
|
+
--ubatch-size 1024 `
|
|
46
|
+
--ctx-size 65536 `
|
|
47
|
+
--parallel 1 `
|
|
48
|
+
-ngl 999 `
|
|
49
|
+
--jinja `
|
|
50
|
+
--chat-template-kwargs '{"preserve_thinking":true}' `
|
|
51
|
+
--spec-type draft-dflash `
|
|
52
|
+
--spec-draft-n-max 7 `
|
|
53
|
+
--spec-draft-backend-sampling
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
becomes `qwen3.8-27b.ini`:
|
|
57
|
+
|
|
58
|
+
```ini
|
|
59
|
+
version = 1
|
|
60
|
+
|
|
61
|
+
[qwen3.8-27b]
|
|
62
|
+
load-on-startup = true
|
|
63
|
+
hf-repo = unsloth/Qwen3.8-27B-GGUF
|
|
64
|
+
hf-file = Qwen3.8-27B-UD-Q4_K_M.gguf
|
|
65
|
+
hf-repo-draft = z-lab/Qwen3.8-27B-DFlash2-GGUF
|
|
66
|
+
spec-draft-model = Qwen3.8-27B-DFlash2-Q4_K_M.gguf
|
|
67
|
+
no-mmproj = true
|
|
68
|
+
batch-size = 4096
|
|
69
|
+
ubatch-size = 1024
|
|
70
|
+
ctx-size = 65536
|
|
71
|
+
parallel = 1
|
|
72
|
+
ngl = 999
|
|
73
|
+
jinja = true
|
|
74
|
+
chat-template-kwargs = {"preserve_thinking":true}
|
|
75
|
+
spec-type = draft-dflash
|
|
76
|
+
spec-draft-n-max = 7
|
|
77
|
+
spec-draft-backend-sampling = true
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Start the router
|
|
81
|
+
|
|
82
|
+
Open PowerShell in the llama.cpp folder and run:
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
.\llama-server.exe --models-preset qwen3.8-27b.ini --host 127.0.0.1 --port 8080
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
If the recipe requires a Hugging Face token, set `$env:HF_TOKEN` in the same PowerShell window before starting the router. On its first start, the router downloads the model files.
|
|
89
|
+
|
|
90
|
+
Use the [router health checks](llama-cpp.md#troubleshooting) to confirm that the server is ready. In Windows PowerShell, use `curl.exe` rather than `curl`, which PowerShell maps to a different command. The model is ready when `/models` lists `qwen3.8-27b` with the status `loaded`.
|
|
91
|
+
|
|
92
|
+
## Use the model in Pi
|
|
93
|
+
|
|
94
|
+
Follow [Configure Pi](llama-cpp.md#configure-pi) and connect to `http://127.0.0.1:8080`. The preset section name is the model ID, so select `qwen3.8-27b` in `/model` for this example.
|
|
95
|
+
|
|
96
|
+
NVIDIA recipe memory settings assume that only the selected model uses the GPU. If `/llama` shows other loaded models, unload them before using the recipe model.
|
package/docs/sessions.md
CHANGED
|
@@ -55,7 +55,7 @@ Use `--session` when you already know the session path or ID. Use `--fork` to cr
|
|
|
55
55
|
|
|
56
56
|
## Export or share a session
|
|
57
57
|
|
|
58
|
-
Use `/export` to write the current session as HTML or JSONL. Use `/share` to upload it and get a viewer link. Pi uses a Radius artifact when Radius authentication is configured; otherwise, it uses a private GitHub gist.
|
|
58
|
+
Use `/export` to write the current session as HTML or JSONL. Use `/share` to upload it and get a viewer link. By default, Pi uses a Radius artifact when Radius authentication is configured; otherwise, it uses a private GitHub gist. Set [`sessionShareDestination`](settings.md#sessions-and-context) to `gist` or `radius` to force one destination.
|
|
59
59
|
|
|
60
60
|
Review exported or shared sessions first. They can contain prompts, model responses, tool arguments, command output, file contents, and extension messages.
|
|
61
61
|
|
package/docs/settings.md
CHANGED
|
@@ -64,6 +64,7 @@ CLI tool options override this setting for one invocation. `--tools` with only `
|
|
|
64
64
|
| Setting | Type | Default | Description |
|
|
65
65
|
|---|---|---|---|
|
|
66
66
|
| `sessionDir` | string | Agent session directory | Session storage directory. Relative paths resolve from the working directory. `PI_CODING_AGENT_SESSION_DIR` and `--session-dir` override this setting. |
|
|
67
|
+
| `sessionShareDestination` | `"auto" \| "gist" \| "radius"` | `"auto"` | Destination used by `/share`. `auto` uses Radius when authenticated and otherwise creates a GitHub gist. `gist` always uses a gist. `radius` requires Radius authentication and never falls back to a gist. |
|
|
67
68
|
|
|
68
69
|
### Compaction
|
|
69
70
|
|
package/docs/usage.md
CHANGED
|
@@ -79,7 +79,7 @@ Use `!!` when you want to run a command without sending its output to the model.
|
|
|
79
79
|
|
|
80
80
|
Press `Ctrl+X` or run `/copy` to copy the last assistant response. Use `/export` to save the session as HTML or JSONL.
|
|
81
81
|
|
|
82
|
-
Use `/share` to upload the session and get a viewer link.
|
|
82
|
+
Use `/share` to upload the session and get a viewer link. By default, Radius authentication makes the artifact visible to your Radius organization; otherwise, Pi creates a private GitHub gist through the GitHub CLI. The [`sessionShareDestination`](settings.md#sessions-and-context) setting can force either destination. Review the session first because it can contain prompts, tool output, file contents, and credentials exposed during the conversation.
|
|
83
83
|
|
|
84
84
|
## Adjust the terminal
|
|
85
85
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.3.0",
|
|
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.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-gondolin",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.3.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
createLsToolDefinition,
|
|
26
26
|
createReadToolDefinition,
|
|
27
27
|
createWriteToolDefinition,
|
|
28
|
+
formatReadLineRange,
|
|
28
29
|
} from "@earendil-works/pi-coding-agent";
|
|
29
30
|
import { Text } from "@earendil-works/pi-tui";
|
|
30
31
|
import { homedir } from "os";
|
|
@@ -65,11 +66,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
65
66
|
const path = shortenPath(args.path || "");
|
|
66
67
|
let pathDisplay = path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
const endLine = args.limit !== undefined ? startLine + args.limit - 1 : "";
|
|
72
|
-
pathDisplay += theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
69
|
+
const lineRange = formatReadLineRange(args.offset, args.limit);
|
|
70
|
+
if (lineRange) {
|
|
71
|
+
pathDisplay += theme.fg("warning", lineRange);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
return new Text(`${theme.fg("toolTitle", theme.bold("read"))} ${pathDisplay}`, 0, 0);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.3.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -22,6 +22,7 @@ import { StringEnum } from "@earendil-works/pi-ai";
|
|
|
22
22
|
import {
|
|
23
23
|
CONFIG_DIR_NAME,
|
|
24
24
|
type ExtensionAPI,
|
|
25
|
+
formatReadLineRange,
|
|
25
26
|
getAgentDir,
|
|
26
27
|
getMarkdownTheme,
|
|
27
28
|
withFileMutationQueue,
|
|
@@ -87,13 +88,10 @@ function formatToolCall(
|
|
|
87
88
|
case "read": {
|
|
88
89
|
const rawPath = (args.file_path || args.path || "...") as string;
|
|
89
90
|
const filePath = shortenPath(rawPath);
|
|
90
|
-
const
|
|
91
|
-
const limit = args.limit as number | undefined;
|
|
91
|
+
const lineRange = formatReadLineRange(args.offset, args.limit);
|
|
92
92
|
let text = themeFg("accent", filePath);
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
const endLine = limit !== undefined ? startLine + limit - 1 : "";
|
|
96
|
-
text += themeFg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
93
|
+
if (lineRange) {
|
|
94
|
+
text += themeFg("warning", lineRange);
|
|
97
95
|
}
|
|
98
96
|
return themeFg("muted", "read ") + text;
|
|
99
97
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.3.0",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@averyyy/pi-coding-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-piclient.1",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"prepublishOnly": "npm run clean && npm run build"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.
|
|
51
|
-
"@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.
|
|
52
|
-
"@earendil-works/pi-codemode": "
|
|
53
|
-
"@earendil-works/pi-mcp": "
|
|
54
|
-
"@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.
|
|
50
|
+
"@earendil-works/pi-agent-core": "npm:@averyyy/pi-agent-core@1.3.0-piclient.1",
|
|
51
|
+
"@earendil-works/pi-ai": "npm:@averyyy/pi-ai@1.3.0-piclient.1",
|
|
52
|
+
"@earendil-works/pi-codemode": "1.3.0",
|
|
53
|
+
"@earendil-works/pi-mcp": "1.3.0",
|
|
54
|
+
"@earendil-works/pi-tui": "npm:@averyyy/pi-tui@1.3.0-piclient.1",
|
|
55
55
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
56
56
|
"brace-expansion": "5.0.12",
|
|
57
57
|
"chalk": "6.0.0",
|
|
@@ -1003,6 +1003,11 @@
|
|
|
1003
1003
|
"description": "Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter.",
|
|
1004
1004
|
"default": false
|
|
1005
1005
|
},
|
|
1006
|
+
"supportsMidConvoEffort": {
|
|
1007
|
+
"type": "boolean",
|
|
1008
|
+
"description": "Whether thinking level changes are sent inside the conversation instead of changing the request's effort, so a change keeps the prompt cache. Used by the anthropic-messages and openai-responses APIs.",
|
|
1009
|
+
"default": false
|
|
1010
|
+
},
|
|
1006
1011
|
"supportsMaxOutputTokens": {
|
|
1007
1012
|
"type": "boolean",
|
|
1008
1013
|
"description": "Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it.",
|
|
@@ -1038,11 +1043,6 @@
|
|
|
1038
1043
|
"description": "Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly.",
|
|
1039
1044
|
"default": false
|
|
1040
1045
|
},
|
|
1041
|
-
"supportsMidConvoEffort": {
|
|
1042
|
-
"type": "boolean",
|
|
1043
|
-
"description": "Whether the exact model transport supports effort-only system messages and thinking binding controls.",
|
|
1044
|
-
"default": false
|
|
1045
|
-
},
|
|
1046
1046
|
"supportsMidConvoToolChanges": {
|
|
1047
1047
|
"type": "boolean",
|
|
1048
1048
|
"description": "Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages.",
|
|
@@ -50,6 +50,24 @@
|
|
|
50
50
|
],
|
|
51
51
|
"default": "auto"
|
|
52
52
|
},
|
|
53
|
+
"sessionShareDestination": {
|
|
54
|
+
"anyOf": [
|
|
55
|
+
{
|
|
56
|
+
"type": "string",
|
|
57
|
+
"const": "auto"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"type": "string",
|
|
61
|
+
"const": "gist"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"type": "string",
|
|
65
|
+
"const": "radius"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"description": "Destination used by /share. \"auto\" uses Radius when authenticated and otherwise creates a GitHub gist.",
|
|
69
|
+
"default": "auto"
|
|
70
|
+
},
|
|
53
71
|
"steeringMode": {
|
|
54
72
|
"anyOf": [
|
|
55
73
|
{
|