@senpiper/sp-agent 0.1.7 → 0.1.10
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/INSTALL.md +3 -4
- package/README.md +10 -10
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/distribution.d.ts +2 -2
- package/dist/distribution.d.ts.map +1 -1
- package/dist/distribution.js +2 -2
- package/dist/distribution.js.map +1 -1
- package/dist/extension-identity.generated.d.ts +3 -3
- package/dist/extension-identity.generated.d.ts.map +1 -1
- package/dist/extension-identity.generated.js +3 -3
- package/dist/extension-identity.generated.js.map +1 -1
- package/dist/runtime-cli.d.ts.map +1 -1
- package/dist/runtime-cli.js +1 -1
- package/dist/runtime-cli.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/node_modules/@senpiper/pi-coding-agent/dist/bundle/chunks/{chunk-BFHDVWYY.js → chunk-LUSUF4ZH.js} +1 -1
- package/node_modules/@senpiper/pi-coding-agent/dist/bundle/chunks/github-copilot.js +1 -1
- package/node_modules/@senpiper/pi-coding-agent/dist/bundle/cli.js +1 -1
- package/node_modules/@senpiper/pi-coding-agent/dist/bundle/index.js +1 -1
- package/node_modules/@senpiper/pi-coding-agent/dist/bundle/rpc-entry.js +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@senpiper/pi-coding-agent/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/TERMINAL_WEB_BRIDGE.md +4 -4
- package/node_modules/@senpiper/sp-agent-extensions/dist/cli-commands.d.ts +0 -6
- package/node_modules/@senpiper/sp-agent-extensions/dist/cli-commands.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/cli-commands.js +2 -81
- package/node_modules/@senpiper/sp-agent-extensions/dist/cli-commands.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/commands.d.ts +2 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/commands.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/commands.js +2 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/commands.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/extension.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/extension.js +2 -0
- package/node_modules/@senpiper/sp-agent-extensions/dist/extension.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/gateway.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/gateway.js +14 -3
- package/node_modules/@senpiper/sp-agent-extensions/dist/gateway.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/index.d.ts +0 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/index.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/index.js +0 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/index.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/interactions.d.ts +0 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/interactions.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/interactions.js +0 -3
- package/node_modules/@senpiper/sp-agent-extensions/dist/interactions.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/login-command.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/login-command.js +1 -11
- package/node_modules/@senpiper/sp-agent-extensions/dist/login-command.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/startup-header.d.ts +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/startup-header.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/startup-header.js +13 -2
- package/node_modules/@senpiper/sp-agent-extensions/dist/startup-header.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/terminal-web-bridge.d.ts.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/terminal-web-bridge.js +7 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/terminal-web-bridge.js.map +1 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/web-command.d.ts +5 -0
- package/node_modules/@senpiper/sp-agent-extensions/dist/web-command.d.ts.map +1 -0
- package/node_modules/@senpiper/sp-agent-extensions/dist/web-command.js +95 -0
- package/node_modules/@senpiper/sp-agent-extensions/dist/web-command.js.map +1 -0
- package/node_modules/@senpiper/sp-agent-extensions/package.json +1 -4
- package/package.json +3 -3
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-command.d.ts +0 -4
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-command.d.ts.map +0 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-command.js +0 -67
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-command.js.map +0 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-installation.d.ts +0 -14
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-installation.d.ts.map +0 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-installation.js +0 -32
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding-installation.js.map +0 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding.d.ts +0 -39
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding.d.ts.map +0 -1
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding.js +0 -311
- package/node_modules/@senpiper/sp-agent-extensions/dist/onboarding.js.map +0 -1
package/INSTALL.md
CHANGED
|
@@ -33,8 +33,8 @@ sp --health-check
|
|
|
33
33
|
sp-web --help
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
The version should match the release you installed, and the health check
|
|
37
|
+
should print `ok`.
|
|
38
38
|
|
|
39
39
|
### npm 12
|
|
40
40
|
|
|
@@ -67,8 +67,7 @@ Paste your gateway API key into the **masked API-key prompt**. Do not put the
|
|
|
67
67
|
key in a chat message, README, or shell command.
|
|
68
68
|
|
|
69
69
|
SP adds `/v1` to the supplied gateway URL, retrieves the available models,
|
|
70
|
-
and selects the first model.
|
|
71
|
-
skills to install. You can run `/onboarding` later.
|
|
70
|
+
and selects the first model.
|
|
72
71
|
|
|
73
72
|
Use `/model` in SP to choose another available model. To inspect the model
|
|
74
73
|
catalog from a separate terminal:
|
package/README.md
CHANGED
|
@@ -41,26 +41,26 @@ Set `SP_WEB_DISABLE=1` to run SP without automatically starting the web sidecar.
|
|
|
41
41
|
|
|
42
42
|
Build SP Web in a disposable copy of its repository, not a checkout running a development server. Pack the production build with `npm pack --ignore-scripts`.
|
|
43
43
|
|
|
44
|
-
Pass
|
|
44
|
+
Set the intended source versions before building. Pass the web tarball and its build lockfile to the SP release command. The dry run validates the web artifact, builds the SP tarball, and checks a clean global installation without publishing:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
|
-
|
|
48
|
-
--
|
|
49
|
-
--web-
|
|
47
|
+
node scripts/publish-sp-packages.mjs --dry-run \
|
|
48
|
+
--registry https://registry.npmjs.org \
|
|
49
|
+
--web-tarball /absolute/path/senpiper-sp-web-0.1.1.tgz \
|
|
50
|
+
--web-lockfile /absolute/path/web-build/package-lock.json \
|
|
51
|
+
--output /absolute/path/release-artifacts
|
|
50
52
|
```
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
Copy the exact validated web tarball into that output directory alongside the SP tarball. Keep exactly one tarball for each package there. Log in with an npm account that has write access to the `@senpiper` scope, then publish from an interactive terminal:
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
57
|
npm run login:sp:npm
|
|
56
58
|
npm whoami --registry https://registry.npmjs.org
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
--web-tarball /absolute/path/senpiper-sp-web-0.1.0.tgz \
|
|
60
|
-
--web-lockfile /absolute/path/web-build/package-lock.json
|
|
59
|
+
node scripts/publish-sp-npm-artifacts.mjs /absolute/path/release-artifacts --check
|
|
60
|
+
node scripts/publish-sp-npm-artifacts.mjs /absolute/path/release-artifacts
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
The
|
|
63
|
+
The artifact publisher checks registry hashes, publishes Web first and then SP, and verifies each published hash. Complete npm's interactive 2FA prompt when requested. `--check` checks artifacts and registry state without publishing. If interrupted, rerun with the same artifacts; matching published versions are verified and skipped. Do not rebuild between attempts. The private runtime and extension packages remain bundled and do not need separate public releases.
|
|
64
64
|
|
|
65
65
|
The private `packages/sp-web-contract` workspace only records the required web version for source development. It is not the web application and is never used as the release artifact.
|
|
66
66
|
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport { configureSpEnvironment } from \"./environment.ts\";\nimport { handleSpReleaseCommand } from \"./release-manager.ts\";\nimport { runSpRuntime } from \"./runtime-cli.ts\";\nimport { SP_AGENT_VERSION } from \"./version.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport { configureSpEnvironment } from \"./environment.ts\";\nimport { handleSpReleaseCommand } from \"./release-manager.ts\";\nimport { runSpRuntime } from \"./runtime-cli.ts\";\nimport { SP_AGENT_VERSION } from \"./version.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout Manage sp-gateway credentials\n sp update|rollback|repair Manage the active verified release\n sp --help Show this help\n sp-web Start the bundled browser workspace\n\nConfiguration: ~/.sp/agent (override with SP_CODING_AGENT_DIR)`);\n}\n\nasync function run() {\n\tconfigureSpEnvironment();\n\tprocess.title = \"sp\";\n\tconst args = process.argv.slice(2);\n\tif (args.length === 1 && (args[0] === \"--version\" || args[0] === \"-v\")) {\n\t\tconsole.log(SP_AGENT_VERSION);\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--help\" || args[0] === \"-h\")) {\n\t\tprintHelp();\n\t\treturn;\n\t}\n\tif (await handleSpReleaseCommand(args)) return;\n\tawait runSpRuntime(args);\n}\n\nrun().catch((error) => {\n\tconsole.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n\tprocess.exitCode = 1;\n});\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ Usage:
|
|
|
11
11
|
sp -p <prompt> Run a one-shot prompt
|
|
12
12
|
sp --mode json|rpc Select a machine-readable mode
|
|
13
13
|
sp --list-models List canonical sp-gateway models
|
|
14
|
-
sp login|logout
|
|
14
|
+
sp login|logout Manage sp-gateway credentials
|
|
15
15
|
sp update|rollback|repair Manage the active verified release
|
|
16
16
|
sp --help Show this help
|
|
17
17
|
sp-web Start the bundled browser workspace
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,SAAS,SAAS,GAAG;IACpB,OAAO,CAAC,GAAG,CAAC,YAAY,gBAAgB;;;;;;;;;;;;+DAYsB,CAAC,CAAC;AAAA,CAChE;AAED,KAAK,UAAU,GAAG,GAAG;IACpB,sBAAsB,EAAE,CAAC;IACzB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,OAAO;IACR,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,OAAO;IACR,CAAC;IACD,IAAI,MAAM,sBAAsB,CAAC,IAAI,CAAC;QAAE,OAAO;IAC/C,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;AAAA,CACzB;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAAA,CACrB,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { configureSpEnvironment } from \"./environment.ts\";\nimport { handleSpReleaseCommand } from \"./release-manager.ts\";\nimport { runSpRuntime } from \"./runtime-cli.ts\";\nimport { SP_AGENT_VERSION } from \"./version.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,SAAS,SAAS,GAAG;IACpB,OAAO,CAAC,GAAG,CAAC,YAAY,gBAAgB;;;;;;;;;;;;+DAYsB,CAAC,CAAC;AAAA,CAChE;AAED,KAAK,UAAU,GAAG,GAAG;IACpB,sBAAsB,EAAE,CAAC;IACzB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,OAAO;IACR,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,OAAO;IACR,CAAC;IACD,IAAI,MAAM,sBAAsB,CAAC,IAAI,CAAC;QAAE,OAAO;IAC/C,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;AAAA,CACzB;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAAA,CACrB,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { configureSpEnvironment } from \"./environment.ts\";\nimport { handleSpReleaseCommand } from \"./release-manager.ts\";\nimport { runSpRuntime } from \"./runtime-cli.ts\";\nimport { SP_AGENT_VERSION } from \"./version.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout Manage sp-gateway credentials\n sp update|rollback|repair Manage the active verified release\n sp --help Show this help\n sp-web Start the bundled browser workspace\n\nConfiguration: ~/.sp/agent (override with SP_CODING_AGENT_DIR)`);\n}\n\nasync function run() {\n\tconfigureSpEnvironment();\n\tprocess.title = \"sp\";\n\tconst args = process.argv.slice(2);\n\tif (args.length === 1 && (args[0] === \"--version\" || args[0] === \"-v\")) {\n\t\tconsole.log(SP_AGENT_VERSION);\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--help\" || args[0] === \"-h\")) {\n\t\tprintHelp();\n\t\treturn;\n\t}\n\tif (await handleSpReleaseCommand(args)) return;\n\tawait runSpRuntime(args);\n}\n\nrun().catch((error) => {\n\tconsole.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n\tprocess.exitCode = 1;\n});\n"]}
|
package/dist/distribution.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare function createSpExtensionRunnerOptions(extensions: readonly Exte
|
|
|
36
36
|
export declare function createSpMainOptions(): Promise<MainOptions>;
|
|
37
37
|
export declare const requiredExtension: {
|
|
38
38
|
readonly name: "@senpiper/sp-agent-extensions";
|
|
39
|
-
readonly version: "0.1.
|
|
40
|
-
readonly digest: "sha256:
|
|
39
|
+
readonly version: "0.1.4";
|
|
40
|
+
readonly digest: "sha256:f4211efa0ca9b8f37d2fa6b912a52f83bf96eda494c8e3de16cad2c307c4511f";
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=distribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAK9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAO5D,UAAU,yBAAyB;IAClC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,MAAM,WAAW,uBAAuB;IACvC,sBAAsB,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,gBAAgB,CAAC;IACjF,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,mBAAmB,EAAE,MAAM,OAAO,CAAC;IACnC,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,sBAAsB,EAAE,MAAM,CAAC;CAC/B;AAED,UAAU,kCAAkC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,4BAA6B,SAAQ,kCAAkC;IAChF,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D;AAoDD,wBAAgB,+BAA+B,CAAC,OAAO,GAAE,kCAAuC,QAqC/F;AAoBD,wBAAsB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,oCAqBrF;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,uBAAuB,GAAG,mBAAmB,CASnG;AAED,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,sBAAsB,CAevG;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,CAqBhE;AAED,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n\tExtension,\n\tExtensionFactory,\n\tExtensionRunnerOptions,\n\tMainOptions,\n\tModelProviderPolicy,\n} from \"@senpiper/pi-coding-agent\";\nimport type { TerminalWebBridgeOptions } from \"@senpiper/sp-agent-extensions\";\nimport { EMBEDDED_REQUIRED_EXTENSION_IDENTITY } from \"./extension-identity.generated.ts\";\nimport { createSpSessionManager } from \"./sdk.ts\";\nimport { spWriterLeases } from \"./writer-leases.ts\";\n\nexport { configureSpEnvironment } from \"./environment.ts\";\nexport { SP_AGENT_VERSION } from \"./version.ts\";\n\ndeclare const SP_AGENT_COMPILED: boolean;\n\nexport const REQUIRED_EXTENSION_OWNER = \"<inline:sp-agent>\";\n\ninterface PackageManifest {\n\tname?: string;\n\tversion?: string;\n}\n\ninterface EmbeddedExtensionIdentity {\n\trequired: { name: string; version: string };\n\tartifact: { name: string; version: string; digest: string };\n}\n\nexport interface RequiredExtensionModule {\n\tcreateSpAgentExtension: (options?: TerminalWebBridgeOptions) => ExtensionFactory;\n\thandleSpCommand: (args: string[]) => Promise<boolean>;\n\treadSpGatewayApiKey: () => unknown;\n\treadSpGatewayState: () => unknown;\n\tSP_GATEWAY_PROVIDER_ID: string;\n}\n\ninterface RequiredExtensionValidationOptions {\n\tcompiled?: boolean;\n\tembeddedIdentity?: EmbeddedExtensionIdentity;\n\tresolvedEntrypoint?: string;\n}\n\ninterface RequiredExtensionLoadOptions extends RequiredExtensionValidationOptions {\n\timportExtension?: (specifier: string) => Promise<unknown>;\n}\n\nfunction findPackageManifest(entrypoint: string) {\n\tlet directory = dirname(entrypoint);\n\tconst root = parse(directory).root;\n\twhile (directory !== root) {\n\t\tconst manifestPath = join(directory, \"package.json\");\n\t\tif (existsSync(manifestPath)) return manifestPath;\n\t\tdirectory = dirname(directory);\n\t}\n\treturn undefined;\n}\n\nfunction collectJavaScriptFiles(directory: string): string[] {\n\tconst files: string[] = [];\n\tfor (const entry of readdirSync(directory, { withFileTypes: true })) {\n\t\tconst path = join(directory, entry.name);\n\t\tif (entry.isDirectory()) files.push(...collectJavaScriptFiles(path));\n\t\telse if (entry.isFile() && entry.name.endsWith(\".js\")) files.push(path);\n\t}\n\treturn files.sort((left, right) => relative(directory, left).localeCompare(relative(directory, right)));\n}\n\nfunction digestArtifact(directory: string) {\n\tconst files = collectJavaScriptFiles(directory);\n\tif (files.length === 0) throw new Error(`Required extension artifact contains no JavaScript: ${directory}`);\n\tconst hash = createHash(\"sha256\");\n\tfor (const path of files) {\n\t\tconst artifactPath = relative(directory, path).replaceAll(\"\\\\\", \"/\");\n\t\tconst content = readFileSync(path);\n\t\thash.update(`${artifactPath}\\0${content.byteLength}\\0`);\n\t\thash.update(content);\n\t}\n\treturn `sha256:${hash.digest(\"hex\")}`;\n}\n\nfunction assertEmbeddedIdentity(identity: EmbeddedExtensionIdentity) {\n\tif (\n\t\tidentity.artifact.name !== identity.required.name ||\n\t\tidentity.artifact.version !== identity.required.version ||\n\t\t!/^sha256:[0-9a-f]{64}$/u.test(identity.artifact.digest)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Required extension build identity mismatch: expected ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction isCompiledExecutable() {\n\treturn typeof SP_AGENT_COMPILED !== \"undefined\" && SP_AGENT_COMPILED;\n}\n\nexport function assertRequiredExtensionIdentity(options: RequiredExtensionValidationOptions = {}) {\n\tconst identity = options.embeddedIdentity ?? EMBEDDED_REQUIRED_EXTENSION_IDENTITY;\n\tassertEmbeddedIdentity(identity);\n\tif (options.compiled ?? isCompiledExecutable()) return;\n\n\tconst resolved = options.resolvedEntrypoint ?? import.meta.resolve(identity.required.name);\n\tif (!resolved.startsWith(\"file:\")) {\n\t\tthrow new Error(`Cannot verify required extension ${identity.required.name}: ${resolved}`);\n\t}\n\tconst entrypoint = fileURLToPath(resolved);\n\tconst manifestPath = findPackageManifest(entrypoint);\n\tif (!manifestPath) {\n\t\tthrow new Error(`Cannot find the manifest for required extension ${identity.required.name}.`);\n\t}\n\tconst packageDirectory = dirname(manifestPath);\n\tconst entrypointRelativePath = relative(packageDirectory, entrypoint);\n\tif (\n\t\tentrypointRelativePath === \"\" ||\n\t\tentrypointRelativePath === \"..\" ||\n\t\tentrypointRelativePath.startsWith(\"../\") ||\n\t\tentrypointRelativePath.startsWith(\"..\\\\\") ||\n\t\tisAbsolute(entrypointRelativePath)\n\t) {\n\t\tthrow new Error(`Required extension entrypoint is outside its package: ${entrypoint}`);\n\t}\n\tconst manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as PackageManifest;\n\tif (manifest.name !== identity.required.name || manifest.version !== identity.required.version) {\n\t\tthrow new Error(\n\t\t\t`Required extension mismatch: expected ${identity.required.name}@${identity.required.version}, found ${manifest.name ?? \"unknown\"}@${manifest.version ?? \"unknown\"}.`,\n\t\t);\n\t}\n\tconst digest = digestArtifact(dirname(entrypoint));\n\tif (digest !== identity.artifact.digest) {\n\t\tthrow new Error(\n\t\t\t`Required extension authenticity check failed for ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction assertRequiredExtensionExports(value: unknown): asserts value is RequiredExtensionModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n\tconst module = value as Record<string, unknown>;\n\tif (\n\t\ttypeof module.createSpAgentExtension !== \"function\" ||\n\t\ttypeof module.handleSpCommand !== \"function\" ||\n\t\ttypeof module.readSpGatewayApiKey !== \"function\" ||\n\t\ttypeof module.readSpGatewayState !== \"function\" ||\n\t\ttypeof module.SP_GATEWAY_PROVIDER_ID !== \"string\"\n\t) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n}\n\nlet requiredExtensionPromise: Promise<RequiredExtensionModule> | undefined;\n\nexport async function loadRequiredExtension(options: RequiredExtensionLoadOptions = {}) {\n\tconst usesDefaultLoader = Object.keys(options).length === 0;\n\tif (usesDefaultLoader && requiredExtensionPromise) return requiredExtensionPromise;\n\n\tassertRequiredExtensionIdentity(options);\n\tconst compiled = options.compiled ?? isCompiledExecutable();\n\tconst specifier = compiled\n\t\t? EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name\n\t\t: (options.resolvedEntrypoint ?? import.meta.resolve(EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name));\n\tconst load = async () => {\n\t\tconst imported = options.importExtension\n\t\t\t? await options.importExtension(specifier)\n\t\t\t: compiled\n\t\t\t\t? await import(\"@senpiper/sp-agent-extensions\")\n\t\t\t\t: await import(specifier);\n\t\tassertRequiredExtensionExports(imported);\n\t\treturn imported;\n\t};\n\tconst promise = load();\n\tif (usesDefaultLoader) requiredExtensionPromise = promise;\n\treturn promise;\n}\n\nexport function createSpModelProviderPolicy(extension: RequiredExtensionModule): ModelProviderPolicy {\n\tconst configured = extension.readSpGatewayState() !== undefined;\n\tif (configured) extension.readSpGatewayApiKey();\n\treturn {\n\t\tallowedProviderIds: [extension.SP_GATEWAY_PROVIDER_ID],\n\t\trequiredProviderIds: configured ? [extension.SP_GATEWAY_PROVIDER_ID] : [],\n\t\tallowModelConfiguration: false,\n\t\tproviderOwners: { [extension.SP_GATEWAY_PROVIDER_ID]: REQUIRED_EXTENSION_OWNER },\n\t};\n}\n\nexport function createSpExtensionRunnerOptions(extensions: readonly Extension[]): ExtensionRunnerOptions {\n\tconst owner = extensions.find((extension) => extension.path === REQUIRED_EXTENSION_OWNER);\n\tif (!owner) throw new Error(\"Required SP extension did not load.\");\n\treturn {\n\t\tcommandOwnership: {\n\t\t\treservedCommandNames: [\"login\", \"onboarding\"],\n\t\t\towners: new Map([\n\t\t\t\t[\"login\", owner],\n\t\t\t\t[\"onboarding\", owner],\n\t\t\t]),\n\t\t},\n\t\tresourceOwnership: {\n\t\t\ttoolOwners: new Map([[\"ask_user_question\", owner]]),\n\t\t},\n\t};\n}\n\nexport async function createSpMainOptions(): Promise<MainOptions> {\n\tconst extension = await loadRequiredExtension();\n\tconst sessions = await createSpSessionManager();\n\treturn {\n\t\tsessionWriterLeaseProvider: spWriterLeases,\n\t\tonSessionHistoryRoot: (root, customSessionDir) => sessions.setHistoryRoot(root, customSessionDir),\n\t\tonSessionRuntime: (runtime) => sessions.attachRuntime(runtime),\n\t\textensionFactories: [\n\t\t\t{\n\t\t\t\tname: \"sp-agent\",\n\t\t\t\tfactory: extension.createSpAgentExtension({\n\t\t\t\t\tsessions,\n\t\t\t\t\twriterLeaseVersion: 1,\n\t\t\t\t\tonReady: (bridge) => sessions.trackBridge(bridge),\n\t\t\t\t}),\n\t\t\t},\n\t\t],\n\t\tincludeBuiltInExtensions: false,\n\t\tmodelProviderPolicy: createSpModelProviderPolicy(extension),\n\t\textensionRunnerOptionsResolver: createSpExtensionRunnerOptions,\n\t};\n}\n\nexport const requiredExtension = {\n\tname: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name,\n\tversion: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.version,\n\tdigest: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.artifact.digest,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"distribution.d.ts","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,mBAAmB,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAK9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAO5D,UAAU,yBAAyB;IAClC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,MAAM,WAAW,uBAAuB;IACvC,sBAAsB,EAAE,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,gBAAgB,CAAC;IACjF,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtD,mBAAmB,EAAE,MAAM,OAAO,CAAC;IACnC,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,sBAAsB,EAAE,MAAM,CAAC;CAC/B;AAED,UAAU,kCAAkC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,4BAA6B,SAAQ,kCAAkC;IAChF,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D;AAoDD,wBAAgB,+BAA+B,CAAC,OAAO,GAAE,kCAAuC,QAqC/F;AAoBD,wBAAsB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,oCAqBrF;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,uBAAuB,GAAG,mBAAmB,CASnG;AAED,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,sBAAsB,CAevG;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,CAqBhE;AAED,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n\tExtension,\n\tExtensionFactory,\n\tExtensionRunnerOptions,\n\tMainOptions,\n\tModelProviderPolicy,\n} from \"@senpiper/pi-coding-agent\";\nimport type { TerminalWebBridgeOptions } from \"@senpiper/sp-agent-extensions\";\nimport { EMBEDDED_REQUIRED_EXTENSION_IDENTITY } from \"./extension-identity.generated.ts\";\nimport { createSpSessionManager } from \"./sdk.ts\";\nimport { spWriterLeases } from \"./writer-leases.ts\";\n\nexport { configureSpEnvironment } from \"./environment.ts\";\nexport { SP_AGENT_VERSION } from \"./version.ts\";\n\ndeclare const SP_AGENT_COMPILED: boolean;\n\nexport const REQUIRED_EXTENSION_OWNER = \"<inline:sp-agent>\";\n\ninterface PackageManifest {\n\tname?: string;\n\tversion?: string;\n}\n\ninterface EmbeddedExtensionIdentity {\n\trequired: { name: string; version: string };\n\tartifact: { name: string; version: string; digest: string };\n}\n\nexport interface RequiredExtensionModule {\n\tcreateSpAgentExtension: (options?: TerminalWebBridgeOptions) => ExtensionFactory;\n\thandleSpCommand: (args: string[]) => Promise<boolean>;\n\treadSpGatewayApiKey: () => unknown;\n\treadSpGatewayState: () => unknown;\n\tSP_GATEWAY_PROVIDER_ID: string;\n}\n\ninterface RequiredExtensionValidationOptions {\n\tcompiled?: boolean;\n\tembeddedIdentity?: EmbeddedExtensionIdentity;\n\tresolvedEntrypoint?: string;\n}\n\ninterface RequiredExtensionLoadOptions extends RequiredExtensionValidationOptions {\n\timportExtension?: (specifier: string) => Promise<unknown>;\n}\n\nfunction findPackageManifest(entrypoint: string) {\n\tlet directory = dirname(entrypoint);\n\tconst root = parse(directory).root;\n\twhile (directory !== root) {\n\t\tconst manifestPath = join(directory, \"package.json\");\n\t\tif (existsSync(manifestPath)) return manifestPath;\n\t\tdirectory = dirname(directory);\n\t}\n\treturn undefined;\n}\n\nfunction collectJavaScriptFiles(directory: string): string[] {\n\tconst files: string[] = [];\n\tfor (const entry of readdirSync(directory, { withFileTypes: true })) {\n\t\tconst path = join(directory, entry.name);\n\t\tif (entry.isDirectory()) files.push(...collectJavaScriptFiles(path));\n\t\telse if (entry.isFile() && entry.name.endsWith(\".js\")) files.push(path);\n\t}\n\treturn files.sort((left, right) => relative(directory, left).localeCompare(relative(directory, right)));\n}\n\nfunction digestArtifact(directory: string) {\n\tconst files = collectJavaScriptFiles(directory);\n\tif (files.length === 0) throw new Error(`Required extension artifact contains no JavaScript: ${directory}`);\n\tconst hash = createHash(\"sha256\");\n\tfor (const path of files) {\n\t\tconst artifactPath = relative(directory, path).replaceAll(\"\\\\\", \"/\");\n\t\tconst content = readFileSync(path);\n\t\thash.update(`${artifactPath}\\0${content.byteLength}\\0`);\n\t\thash.update(content);\n\t}\n\treturn `sha256:${hash.digest(\"hex\")}`;\n}\n\nfunction assertEmbeddedIdentity(identity: EmbeddedExtensionIdentity) {\n\tif (\n\t\tidentity.artifact.name !== identity.required.name ||\n\t\tidentity.artifact.version !== identity.required.version ||\n\t\t!/^sha256:[0-9a-f]{64}$/u.test(identity.artifact.digest)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Required extension build identity mismatch: expected ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction isCompiledExecutable() {\n\treturn typeof SP_AGENT_COMPILED !== \"undefined\" && SP_AGENT_COMPILED;\n}\n\nexport function assertRequiredExtensionIdentity(options: RequiredExtensionValidationOptions = {}) {\n\tconst identity = options.embeddedIdentity ?? EMBEDDED_REQUIRED_EXTENSION_IDENTITY;\n\tassertEmbeddedIdentity(identity);\n\tif (options.compiled ?? isCompiledExecutable()) return;\n\n\tconst resolved = options.resolvedEntrypoint ?? import.meta.resolve(identity.required.name);\n\tif (!resolved.startsWith(\"file:\")) {\n\t\tthrow new Error(`Cannot verify required extension ${identity.required.name}: ${resolved}`);\n\t}\n\tconst entrypoint = fileURLToPath(resolved);\n\tconst manifestPath = findPackageManifest(entrypoint);\n\tif (!manifestPath) {\n\t\tthrow new Error(`Cannot find the manifest for required extension ${identity.required.name}.`);\n\t}\n\tconst packageDirectory = dirname(manifestPath);\n\tconst entrypointRelativePath = relative(packageDirectory, entrypoint);\n\tif (\n\t\tentrypointRelativePath === \"\" ||\n\t\tentrypointRelativePath === \"..\" ||\n\t\tentrypointRelativePath.startsWith(\"../\") ||\n\t\tentrypointRelativePath.startsWith(\"..\\\\\") ||\n\t\tisAbsolute(entrypointRelativePath)\n\t) {\n\t\tthrow new Error(`Required extension entrypoint is outside its package: ${entrypoint}`);\n\t}\n\tconst manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as PackageManifest;\n\tif (manifest.name !== identity.required.name || manifest.version !== identity.required.version) {\n\t\tthrow new Error(\n\t\t\t`Required extension mismatch: expected ${identity.required.name}@${identity.required.version}, found ${manifest.name ?? \"unknown\"}@${manifest.version ?? \"unknown\"}.`,\n\t\t);\n\t}\n\tconst digest = digestArtifact(dirname(entrypoint));\n\tif (digest !== identity.artifact.digest) {\n\t\tthrow new Error(\n\t\t\t`Required extension authenticity check failed for ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction assertRequiredExtensionExports(value: unknown): asserts value is RequiredExtensionModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n\tconst module = value as Record<string, unknown>;\n\tif (\n\t\ttypeof module.createSpAgentExtension !== \"function\" ||\n\t\ttypeof module.handleSpCommand !== \"function\" ||\n\t\ttypeof module.readSpGatewayApiKey !== \"function\" ||\n\t\ttypeof module.readSpGatewayState !== \"function\" ||\n\t\ttypeof module.SP_GATEWAY_PROVIDER_ID !== \"string\"\n\t) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n}\n\nlet requiredExtensionPromise: Promise<RequiredExtensionModule> | undefined;\n\nexport async function loadRequiredExtension(options: RequiredExtensionLoadOptions = {}) {\n\tconst usesDefaultLoader = Object.keys(options).length === 0;\n\tif (usesDefaultLoader && requiredExtensionPromise) return requiredExtensionPromise;\n\n\tassertRequiredExtensionIdentity(options);\n\tconst compiled = options.compiled ?? isCompiledExecutable();\n\tconst specifier = compiled\n\t\t? EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name\n\t\t: (options.resolvedEntrypoint ?? import.meta.resolve(EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name));\n\tconst load = async () => {\n\t\tconst imported = options.importExtension\n\t\t\t? await options.importExtension(specifier)\n\t\t\t: compiled\n\t\t\t\t? await import(\"@senpiper/sp-agent-extensions\")\n\t\t\t\t: await import(specifier);\n\t\tassertRequiredExtensionExports(imported);\n\t\treturn imported;\n\t};\n\tconst promise = load();\n\tif (usesDefaultLoader) requiredExtensionPromise = promise;\n\treturn promise;\n}\n\nexport function createSpModelProviderPolicy(extension: RequiredExtensionModule): ModelProviderPolicy {\n\tconst configured = extension.readSpGatewayState() !== undefined;\n\tif (configured) extension.readSpGatewayApiKey();\n\treturn {\n\t\tallowedProviderIds: [extension.SP_GATEWAY_PROVIDER_ID],\n\t\trequiredProviderIds: configured ? [extension.SP_GATEWAY_PROVIDER_ID] : [],\n\t\tallowModelConfiguration: false,\n\t\tproviderOwners: { [extension.SP_GATEWAY_PROVIDER_ID]: REQUIRED_EXTENSION_OWNER },\n\t};\n}\n\nexport function createSpExtensionRunnerOptions(extensions: readonly Extension[]): ExtensionRunnerOptions {\n\tconst owner = extensions.find((extension) => extension.path === REQUIRED_EXTENSION_OWNER);\n\tif (!owner) throw new Error(\"Required SP extension did not load.\");\n\treturn {\n\t\tcommandOwnership: {\n\t\t\treservedCommandNames: [\"login\", \"web\"],\n\t\t\towners: new Map([\n\t\t\t\t[\"login\", owner],\n\t\t\t\t[\"web\", owner],\n\t\t\t]),\n\t\t},\n\t\tresourceOwnership: {\n\t\t\ttoolOwners: new Map([[\"ask_user_question\", owner]]),\n\t\t},\n\t};\n}\n\nexport async function createSpMainOptions(): Promise<MainOptions> {\n\tconst extension = await loadRequiredExtension();\n\tconst sessions = await createSpSessionManager();\n\treturn {\n\t\tsessionWriterLeaseProvider: spWriterLeases,\n\t\tonSessionHistoryRoot: (root, customSessionDir) => sessions.setHistoryRoot(root, customSessionDir),\n\t\tonSessionRuntime: (runtime) => sessions.attachRuntime(runtime),\n\t\textensionFactories: [\n\t\t\t{\n\t\t\t\tname: \"sp-agent\",\n\t\t\t\tfactory: extension.createSpAgentExtension({\n\t\t\t\t\tsessions,\n\t\t\t\t\twriterLeaseVersion: 1,\n\t\t\t\t\tonReady: (bridge) => sessions.trackBridge(bridge),\n\t\t\t\t}),\n\t\t\t},\n\t\t],\n\t\tincludeBuiltInExtensions: false,\n\t\tmodelProviderPolicy: createSpModelProviderPolicy(extension),\n\t\textensionRunnerOptionsResolver: createSpExtensionRunnerOptions,\n\t};\n}\n\nexport const requiredExtension = {\n\tname: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name,\n\tversion: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.version,\n\tdigest: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.artifact.digest,\n} as const;\n"]}
|
package/dist/distribution.js
CHANGED
|
@@ -147,10 +147,10 @@ export function createSpExtensionRunnerOptions(extensions) {
|
|
|
147
147
|
throw new Error("Required SP extension did not load.");
|
|
148
148
|
return {
|
|
149
149
|
commandOwnership: {
|
|
150
|
-
reservedCommandNames: ["login", "
|
|
150
|
+
reservedCommandNames: ["login", "web"],
|
|
151
151
|
owners: new Map([
|
|
152
152
|
["login", owner],
|
|
153
|
-
["
|
|
153
|
+
["web", owner],
|
|
154
154
|
]),
|
|
155
155
|
},
|
|
156
156
|
resourceOwnership: {
|
package/dist/distribution.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,OAAO,EAAE,oCAAoC,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AA8B5D,SAAS,mBAAmB,CAAC,UAAkB,EAAE;IAChD,IAAI,SAAS,GAAG,OAAO,CA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E;YACnB;gBACC,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,SAAS,CAAC,sBAAsB,CAAC;oBACzC,QAAQ;oBACR,kBAAkB,EAAE,CAAC;oBACrB,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC;iBACjD,CAAC;aACF;SACD;QACD,wBAAwB,EAAE,KAAK;QAC/B,mBAAmB,EAAE,2BAA2B,CAAC,SAAS,CAAC;QAC3D,8BAA8B,EAAE,8BAA8B;KAC9D,CAAC;AAAA,CACF;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,IAAI,EAAE,oCAAoC,CAAC,QAAQ,CAAC,IAAI;IACxD,OAAO,EAAE,oCAAoC,CAAC,QAAQ,CAAC,OAAO;IAC9D,MAAM,EAAE,oCAAoC,CAAC,QAAQ,CAAC,MAAM;CACnD,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n\tExtension,\n\tExtensionFactory,\n\tExtensionRunnerOptions,\n\tMainOptions,\n\tModelProviderPolicy,\n} from \"@senpiper/pi-coding-agent\";\nimport type { TerminalWebBridgeOptions } from \"@senpiper/sp-agent-extensions\";\nimport { EMBEDDED_REQUIRED_EXTENSION_IDENTITY } from \"./extension-identity.generated.ts\";\nimport { createSpSessionManager } from \"./sdk.ts\";\nimport { spWriterLeases } from \"./writer-leases.ts\";\n\nexport { configureSpEnvironment } from \"./environment.ts\";\nexport { SP_AGENT_VERSION } from \"./version.ts\";\n\ndeclare const SP_AGENT_COMPILED: boolean;\n\nexport const REQUIRED_EXTENSION_OWNER = \"<inline:sp-agent>\";\n\ninterface PackageManifest {\n\tname?: string;\n\tversion?: string;\n}\n\ninterface EmbeddedExtensionIdentity {\n\trequired: { name: string; version: string };\n\tartifact: { name: string; version: string; digest: string };\n}\n\nexport interface RequiredExtensionModule {\n\tcreateSpAgentExtension: (options?: TerminalWebBridgeOptions) => ExtensionFactory;\n\thandleSpCommand: (args: string[]) => Promise<boolean>;\n\treadSpGatewayApiKey: () => unknown;\n\treadSpGatewayState: () => unknown;\n\tSP_GATEWAY_PROVIDER_ID: string;\n}\n\ninterface RequiredExtensionValidationOptions {\n\tcompiled?: boolean;\n\tembeddedIdentity?: EmbeddedExtensionIdentity;\n\tresolvedEntrypoint?: string;\n}\n\ninterface RequiredExtensionLoadOptions extends RequiredExtensionValidationOptions {\n\timportExtension?: (specifier: string) => Promise<unknown>;\n}\n\nfunction findPackageManifest(entrypoint: string) {\n\tlet directory = dirname(entrypoint);\n\tconst root = parse(directory).root;\n\twhile (directory !== root) {\n\t\tconst manifestPath = join(directory, \"package.json\");\n\t\tif (existsSync(manifestPath)) return manifestPath;\n\t\tdirectory = dirname(directory);\n\t}\n\treturn undefined;\n}\n\nfunction collectJavaScriptFiles(directory: string): string[] {\n\tconst files: string[] = [];\n\tfor (const entry of readdirSync(directory, { withFileTypes: true })) {\n\t\tconst path = join(directory, entry.name);\n\t\tif (entry.isDirectory()) files.push(...collectJavaScriptFiles(path));\n\t\telse if (entry.isFile() && entry.name.endsWith(\".js\")) files.push(path);\n\t}\n\treturn files.sort((left, right) => relative(directory, left).localeCompare(relative(directory, right)));\n}\n\nfunction digestArtifact(directory: string) {\n\tconst files = collectJavaScriptFiles(directory);\n\tif (files.length === 0) throw new Error(`Required extension artifact contains no JavaScript: ${directory}`);\n\tconst hash = createHash(\"sha256\");\n\tfor (const path of files) {\n\t\tconst artifactPath = relative(directory, path).replaceAll(\"\\\\\", \"/\");\n\t\tconst content = readFileSync(path);\n\t\thash.update(`${artifactPath}\\0${content.byteLength}\\0`);\n\t\thash.update(content);\n\t}\n\treturn `sha256:${hash.digest(\"hex\")}`;\n}\n\nfunction assertEmbeddedIdentity(identity: EmbeddedExtensionIdentity) {\n\tif (\n\t\tidentity.artifact.name !== identity.required.name ||\n\t\tidentity.artifact.version !== identity.required.version ||\n\t\t!/^sha256:[0-9a-f]{64}$/u.test(identity.artifact.digest)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Required extension build identity mismatch: expected ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction isCompiledExecutable() {\n\treturn typeof SP_AGENT_COMPILED !== \"undefined\" && SP_AGENT_COMPILED;\n}\n\nexport function assertRequiredExtensionIdentity(options: RequiredExtensionValidationOptions = {}) {\n\tconst identity = options.embeddedIdentity ?? EMBEDDED_REQUIRED_EXTENSION_IDENTITY;\n\tassertEmbeddedIdentity(identity);\n\tif (options.compiled ?? isCompiledExecutable()) return;\n\n\tconst resolved = options.resolvedEntrypoint ?? import.meta.resolve(identity.required.name);\n\tif (!resolved.startsWith(\"file:\")) {\n\t\tthrow new Error(`Cannot verify required extension ${identity.required.name}: ${resolved}`);\n\t}\n\tconst entrypoint = fileURLToPath(resolved);\n\tconst manifestPath = findPackageManifest(entrypoint);\n\tif (!manifestPath) {\n\t\tthrow new Error(`Cannot find the manifest for required extension ${identity.required.name}.`);\n\t}\n\tconst packageDirectory = dirname(manifestPath);\n\tconst entrypointRelativePath = relative(packageDirectory, entrypoint);\n\tif (\n\t\tentrypointRelativePath === \"\" ||\n\t\tentrypointRelativePath === \"..\" ||\n\t\tentrypointRelativePath.startsWith(\"../\") ||\n\t\tentrypointRelativePath.startsWith(\"..\\\\\") ||\n\t\tisAbsolute(entrypointRelativePath)\n\t) {\n\t\tthrow new Error(`Required extension entrypoint is outside its package: ${entrypoint}`);\n\t}\n\tconst manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as PackageManifest;\n\tif (manifest.name !== identity.required.name || manifest.version !== identity.required.version) {\n\t\tthrow new Error(\n\t\t\t`Required extension mismatch: expected ${identity.required.name}@${identity.required.version}, found ${manifest.name ?? \"unknown\"}@${manifest.version ?? \"unknown\"}.`,\n\t\t);\n\t}\n\tconst digest = digestArtifact(dirname(entrypoint));\n\tif (digest !== identity.artifact.digest) {\n\t\tthrow new Error(\n\t\t\t`Required extension authenticity check failed for ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction assertRequiredExtensionExports(value: unknown): asserts value is RequiredExtensionModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n\tconst module = value as Record<string, unknown>;\n\tif (\n\t\ttypeof module.createSpAgentExtension !== \"function\" ||\n\t\ttypeof module.handleSpCommand !== \"function\" ||\n\t\ttypeof module.readSpGatewayApiKey !== \"function\" ||\n\t\ttypeof module.readSpGatewayState !== \"function\" ||\n\t\ttypeof module.SP_GATEWAY_PROVIDER_ID !== \"string\"\n\t) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n}\n\nlet requiredExtensionPromise: Promise<RequiredExtensionModule> | undefined;\n\nexport async function loadRequiredExtension(options: RequiredExtensionLoadOptions = {}) {\n\tconst usesDefaultLoader = Object.keys(options).length === 0;\n\tif (usesDefaultLoader && requiredExtensionPromise) return requiredExtensionPromise;\n\n\tassertRequiredExtensionIdentity(options);\n\tconst compiled = options.compiled ?? isCompiledExecutable();\n\tconst specifier = compiled\n\t\t? EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name\n\t\t: (options.resolvedEntrypoint ?? import.meta.resolve(EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name));\n\tconst load = async () => {\n\t\tconst imported = options.importExtension\n\t\t\t? await options.importExtension(specifier)\n\t\t\t: compiled\n\t\t\t\t? await import(\"@senpiper/sp-agent-extensions\")\n\t\t\t\t: await import(specifier);\n\t\tassertRequiredExtensionExports(imported);\n\t\treturn imported;\n\t};\n\tconst promise = load();\n\tif (usesDefaultLoader) requiredExtensionPromise = promise;\n\treturn promise;\n}\n\nexport function createSpModelProviderPolicy(extension: RequiredExtensionModule): ModelProviderPolicy {\n\tconst configured = extension.readSpGatewayState() !== undefined;\n\tif (configured) extension.readSpGatewayApiKey();\n\treturn {\n\t\tallowedProviderIds: [extension.SP_GATEWAY_PROVIDER_ID],\n\t\trequiredProviderIds: configured ? [extension.SP_GATEWAY_PROVIDER_ID] : [],\n\t\tallowModelConfiguration: false,\n\t\tproviderOwners: { [extension.SP_GATEWAY_PROVIDER_ID]: REQUIRED_EXTENSION_OWNER },\n\t};\n}\n\nexport function createSpExtensionRunnerOptions(extensions: readonly Extension[]): ExtensionRunnerOptions {\n\tconst owner = extensions.find((extension) => extension.path === REQUIRED_EXTENSION_OWNER);\n\tif (!owner) throw new Error(\"Required SP extension did not load.\");\n\treturn {\n\t\tcommandOwnership: {\n\t\t\treservedCommandNames: [\"login\", \"onboarding\"],\n\t\t\towners: new Map([\n\t\t\t\t[\"login\", owner],\n\t\t\t\t[\"onboarding\", owner],\n\t\t\t]),\n\t\t},\n\t\tresourceOwnership: {\n\t\t\ttoolOwners: new Map([[\"ask_user_question\", owner]]),\n\t\t},\n\t};\n}\n\nexport async function createSpMainOptions(): Promise<MainOptions> {\n\tconst extension = await loadRequiredExtension();\n\tconst sessions = await createSpSessionManager();\n\treturn {\n\t\tsessionWriterLeaseProvider: spWriterLeases,\n\t\tonSessionHistoryRoot: (root, customSessionDir) => sessions.setHistoryRoot(root, customSessionDir),\n\t\tonSessionRuntime: (runtime) => sessions.attachRuntime(runtime),\n\t\textensionFactories: [\n\t\t\t{\n\t\t\t\tname: \"sp-agent\",\n\t\t\t\tfactory: extension.createSpAgentExtension({\n\t\t\t\t\tsessions,\n\t\t\t\t\twriterLeaseVersion: 1,\n\t\t\t\t\tonReady: (bridge) => sessions.trackBridge(bridge),\n\t\t\t\t}),\n\t\t\t},\n\t\t],\n\t\tincludeBuiltInExtensions: false,\n\t\tmodelProviderPolicy: createSpModelProviderPolicy(extension),\n\t\textensionRunnerOptionsResolver: createSpExtensionRunnerOptions,\n\t};\n}\n\nexport const requiredExtension = {\n\tname: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name,\n\tversion: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.version,\n\tdigest: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.artifact.digest,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"distribution.js","sourceRoot":"","sources":["../src/distribution.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,OAAO,EAAE,oCAAoC,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AA8B5D,SAAS,mBAAmB,CAAC,UAAkB,EAAE;IAChD,IAAI,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IACnC,OAAO,SAAS,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACrD,IAAI,UAAU,CAAC,YAAY,CAAC;YAAE,OAAO,YAAY,CAAC;QAClD,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,SAAS,CAAC;AAAA,CACjB;A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AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC,IAAI,EAAE,oCAAoC,CAAC,QAAQ,CAAC,IAAI;IACxD,OAAO,EAAE,oCAAoC,CAAC,QAAQ,CAAC,OAAO;IAC9D,MAAM,EAAE,oCAAoC,CAAC,QAAQ,CAAC,MAAM;CACnD,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, parse, relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n\tExtension,\n\tExtensionFactory,\n\tExtensionRunnerOptions,\n\tMainOptions,\n\tModelProviderPolicy,\n} from \"@senpiper/pi-coding-agent\";\nimport type { TerminalWebBridgeOptions } from \"@senpiper/sp-agent-extensions\";\nimport { EMBEDDED_REQUIRED_EXTENSION_IDENTITY } from \"./extension-identity.generated.ts\";\nimport { createSpSessionManager } from \"./sdk.ts\";\nimport { spWriterLeases } from \"./writer-leases.ts\";\n\nexport { configureSpEnvironment } from \"./environment.ts\";\nexport { SP_AGENT_VERSION } from \"./version.ts\";\n\ndeclare const SP_AGENT_COMPILED: boolean;\n\nexport const REQUIRED_EXTENSION_OWNER = \"<inline:sp-agent>\";\n\ninterface PackageManifest {\n\tname?: string;\n\tversion?: string;\n}\n\ninterface EmbeddedExtensionIdentity {\n\trequired: { name: string; version: string };\n\tartifact: { name: string; version: string; digest: string };\n}\n\nexport interface RequiredExtensionModule {\n\tcreateSpAgentExtension: (options?: TerminalWebBridgeOptions) => ExtensionFactory;\n\thandleSpCommand: (args: string[]) => Promise<boolean>;\n\treadSpGatewayApiKey: () => unknown;\n\treadSpGatewayState: () => unknown;\n\tSP_GATEWAY_PROVIDER_ID: string;\n}\n\ninterface RequiredExtensionValidationOptions {\n\tcompiled?: boolean;\n\tembeddedIdentity?: EmbeddedExtensionIdentity;\n\tresolvedEntrypoint?: string;\n}\n\ninterface RequiredExtensionLoadOptions extends RequiredExtensionValidationOptions {\n\timportExtension?: (specifier: string) => Promise<unknown>;\n}\n\nfunction findPackageManifest(entrypoint: string) {\n\tlet directory = dirname(entrypoint);\n\tconst root = parse(directory).root;\n\twhile (directory !== root) {\n\t\tconst manifestPath = join(directory, \"package.json\");\n\t\tif (existsSync(manifestPath)) return manifestPath;\n\t\tdirectory = dirname(directory);\n\t}\n\treturn undefined;\n}\n\nfunction collectJavaScriptFiles(directory: string): string[] {\n\tconst files: string[] = [];\n\tfor (const entry of readdirSync(directory, { withFileTypes: true })) {\n\t\tconst path = join(directory, entry.name);\n\t\tif (entry.isDirectory()) files.push(...collectJavaScriptFiles(path));\n\t\telse if (entry.isFile() && entry.name.endsWith(\".js\")) files.push(path);\n\t}\n\treturn files.sort((left, right) => relative(directory, left).localeCompare(relative(directory, right)));\n}\n\nfunction digestArtifact(directory: string) {\n\tconst files = collectJavaScriptFiles(directory);\n\tif (files.length === 0) throw new Error(`Required extension artifact contains no JavaScript: ${directory}`);\n\tconst hash = createHash(\"sha256\");\n\tfor (const path of files) {\n\t\tconst artifactPath = relative(directory, path).replaceAll(\"\\\\\", \"/\");\n\t\tconst content = readFileSync(path);\n\t\thash.update(`${artifactPath}\\0${content.byteLength}\\0`);\n\t\thash.update(content);\n\t}\n\treturn `sha256:${hash.digest(\"hex\")}`;\n}\n\nfunction assertEmbeddedIdentity(identity: EmbeddedExtensionIdentity) {\n\tif (\n\t\tidentity.artifact.name !== identity.required.name ||\n\t\tidentity.artifact.version !== identity.required.version ||\n\t\t!/^sha256:[0-9a-f]{64}$/u.test(identity.artifact.digest)\n\t) {\n\t\tthrow new Error(\n\t\t\t`Required extension build identity mismatch: expected ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction isCompiledExecutable() {\n\treturn typeof SP_AGENT_COMPILED !== \"undefined\" && SP_AGENT_COMPILED;\n}\n\nexport function assertRequiredExtensionIdentity(options: RequiredExtensionValidationOptions = {}) {\n\tconst identity = options.embeddedIdentity ?? EMBEDDED_REQUIRED_EXTENSION_IDENTITY;\n\tassertEmbeddedIdentity(identity);\n\tif (options.compiled ?? isCompiledExecutable()) return;\n\n\tconst resolved = options.resolvedEntrypoint ?? import.meta.resolve(identity.required.name);\n\tif (!resolved.startsWith(\"file:\")) {\n\t\tthrow new Error(`Cannot verify required extension ${identity.required.name}: ${resolved}`);\n\t}\n\tconst entrypoint = fileURLToPath(resolved);\n\tconst manifestPath = findPackageManifest(entrypoint);\n\tif (!manifestPath) {\n\t\tthrow new Error(`Cannot find the manifest for required extension ${identity.required.name}.`);\n\t}\n\tconst packageDirectory = dirname(manifestPath);\n\tconst entrypointRelativePath = relative(packageDirectory, entrypoint);\n\tif (\n\t\tentrypointRelativePath === \"\" ||\n\t\tentrypointRelativePath === \"..\" ||\n\t\tentrypointRelativePath.startsWith(\"../\") ||\n\t\tentrypointRelativePath.startsWith(\"..\\\\\") ||\n\t\tisAbsolute(entrypointRelativePath)\n\t) {\n\t\tthrow new Error(`Required extension entrypoint is outside its package: ${entrypoint}`);\n\t}\n\tconst manifest = JSON.parse(readFileSync(manifestPath, \"utf8\")) as PackageManifest;\n\tif (manifest.name !== identity.required.name || manifest.version !== identity.required.version) {\n\t\tthrow new Error(\n\t\t\t`Required extension mismatch: expected ${identity.required.name}@${identity.required.version}, found ${manifest.name ?? \"unknown\"}@${manifest.version ?? \"unknown\"}.`,\n\t\t);\n\t}\n\tconst digest = digestArtifact(dirname(entrypoint));\n\tif (digest !== identity.artifact.digest) {\n\t\tthrow new Error(\n\t\t\t`Required extension authenticity check failed for ${identity.required.name}@${identity.required.version}.`,\n\t\t);\n\t}\n}\n\nfunction assertRequiredExtensionExports(value: unknown): asserts value is RequiredExtensionModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n\tconst module = value as Record<string, unknown>;\n\tif (\n\t\ttypeof module.createSpAgentExtension !== \"function\" ||\n\t\ttypeof module.handleSpCommand !== \"function\" ||\n\t\ttypeof module.readSpGatewayApiKey !== \"function\" ||\n\t\ttypeof module.readSpGatewayState !== \"function\" ||\n\t\ttypeof module.SP_GATEWAY_PROVIDER_ID !== \"string\"\n\t) {\n\t\tthrow new Error(`Required extension ${requiredExtension.name}@${requiredExtension.version} is invalid.`);\n\t}\n}\n\nlet requiredExtensionPromise: Promise<RequiredExtensionModule> | undefined;\n\nexport async function loadRequiredExtension(options: RequiredExtensionLoadOptions = {}) {\n\tconst usesDefaultLoader = Object.keys(options).length === 0;\n\tif (usesDefaultLoader && requiredExtensionPromise) return requiredExtensionPromise;\n\n\tassertRequiredExtensionIdentity(options);\n\tconst compiled = options.compiled ?? isCompiledExecutable();\n\tconst specifier = compiled\n\t\t? EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name\n\t\t: (options.resolvedEntrypoint ?? import.meta.resolve(EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name));\n\tconst load = async () => {\n\t\tconst imported = options.importExtension\n\t\t\t? await options.importExtension(specifier)\n\t\t\t: compiled\n\t\t\t\t? await import(\"@senpiper/sp-agent-extensions\")\n\t\t\t\t: await import(specifier);\n\t\tassertRequiredExtensionExports(imported);\n\t\treturn imported;\n\t};\n\tconst promise = load();\n\tif (usesDefaultLoader) requiredExtensionPromise = promise;\n\treturn promise;\n}\n\nexport function createSpModelProviderPolicy(extension: RequiredExtensionModule): ModelProviderPolicy {\n\tconst configured = extension.readSpGatewayState() !== undefined;\n\tif (configured) extension.readSpGatewayApiKey();\n\treturn {\n\t\tallowedProviderIds: [extension.SP_GATEWAY_PROVIDER_ID],\n\t\trequiredProviderIds: configured ? [extension.SP_GATEWAY_PROVIDER_ID] : [],\n\t\tallowModelConfiguration: false,\n\t\tproviderOwners: { [extension.SP_GATEWAY_PROVIDER_ID]: REQUIRED_EXTENSION_OWNER },\n\t};\n}\n\nexport function createSpExtensionRunnerOptions(extensions: readonly Extension[]): ExtensionRunnerOptions {\n\tconst owner = extensions.find((extension) => extension.path === REQUIRED_EXTENSION_OWNER);\n\tif (!owner) throw new Error(\"Required SP extension did not load.\");\n\treturn {\n\t\tcommandOwnership: {\n\t\t\treservedCommandNames: [\"login\", \"web\"],\n\t\t\towners: new Map([\n\t\t\t\t[\"login\", owner],\n\t\t\t\t[\"web\", owner],\n\t\t\t]),\n\t\t},\n\t\tresourceOwnership: {\n\t\t\ttoolOwners: new Map([[\"ask_user_question\", owner]]),\n\t\t},\n\t};\n}\n\nexport async function createSpMainOptions(): Promise<MainOptions> {\n\tconst extension = await loadRequiredExtension();\n\tconst sessions = await createSpSessionManager();\n\treturn {\n\t\tsessionWriterLeaseProvider: spWriterLeases,\n\t\tonSessionHistoryRoot: (root, customSessionDir) => sessions.setHistoryRoot(root, customSessionDir),\n\t\tonSessionRuntime: (runtime) => sessions.attachRuntime(runtime),\n\t\textensionFactories: [\n\t\t\t{\n\t\t\t\tname: \"sp-agent\",\n\t\t\t\tfactory: extension.createSpAgentExtension({\n\t\t\t\t\tsessions,\n\t\t\t\t\twriterLeaseVersion: 1,\n\t\t\t\t\tonReady: (bridge) => sessions.trackBridge(bridge),\n\t\t\t\t}),\n\t\t\t},\n\t\t],\n\t\tincludeBuiltInExtensions: false,\n\t\tmodelProviderPolicy: createSpModelProviderPolicy(extension),\n\t\textensionRunnerOptionsResolver: createSpExtensionRunnerOptions,\n\t};\n}\n\nexport const requiredExtension = {\n\tname: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.name,\n\tversion: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.required.version,\n\tdigest: EMBEDDED_REQUIRED_EXTENSION_IDENTITY.artifact.digest,\n} as const;\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare const EMBEDDED_REQUIRED_EXTENSION_IDENTITY: {
|
|
2
2
|
readonly required: {
|
|
3
3
|
readonly name: "@senpiper/sp-agent-extensions";
|
|
4
|
-
readonly version: "0.1.
|
|
4
|
+
readonly version: "0.1.4";
|
|
5
5
|
};
|
|
6
6
|
readonly artifact: {
|
|
7
7
|
readonly name: "@senpiper/sp-agent-extensions";
|
|
8
|
-
readonly version: "0.1.
|
|
9
|
-
readonly digest: "sha256:
|
|
8
|
+
readonly version: "0.1.4";
|
|
9
|
+
readonly digest: "sha256:f4211efa0ca9b8f37d2fa6b912a52f83bf96eda494c8e3de16cad2c307c4511f";
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
//# sourceMappingURL=extension-identity.generated.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-identity.generated.d.ts","sourceRoot":"","sources":["../src/extension-identity.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUvC,CAAC","sourcesContent":["// Generated by scripts/generate-sp-extension-identity.mjs. Do not edit.\nexport const EMBEDDED_REQUIRED_EXTENSION_IDENTITY = {\n\trequired: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.
|
|
1
|
+
{"version":3,"file":"extension-identity.generated.d.ts","sourceRoot":"","sources":["../src/extension-identity.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,oCAAoC;;;;;;;;;;CAUvC,CAAC","sourcesContent":["// Generated by scripts/generate-sp-extension-identity.mjs. Do not edit.\nexport const EMBEDDED_REQUIRED_EXTENSION_IDENTITY = {\n\trequired: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.4\",\n\t},\n\tartifact: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.4\",\n\t\tdigest: \"sha256:f4211efa0ca9b8f37d2fa6b912a52f83bf96eda494c8e3de16cad2c307c4511f\",\n\t},\n} as const;\n"]}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
export const EMBEDDED_REQUIRED_EXTENSION_IDENTITY = {
|
|
3
3
|
required: {
|
|
4
4
|
name: "@senpiper/sp-agent-extensions",
|
|
5
|
-
version: "0.1.
|
|
5
|
+
version: "0.1.4",
|
|
6
6
|
},
|
|
7
7
|
artifact: {
|
|
8
8
|
name: "@senpiper/sp-agent-extensions",
|
|
9
|
-
version: "0.1.
|
|
10
|
-
digest: "sha256:
|
|
9
|
+
version: "0.1.4",
|
|
10
|
+
digest: "sha256:f4211efa0ca9b8f37d2fa6b912a52f83bf96eda494c8e3de16cad2c307c4511f",
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=extension-identity.generated.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-identity.generated.js","sourceRoot":"","sources":["../src/extension-identity.generated.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,CAAC,MAAM,oCAAoC,GAAG;IACnD,QAAQ,EAAE;QACT,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,OAAO;KAChB;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,yEAAyE;KACjF;CACQ,CAAC","sourcesContent":["// Generated by scripts/generate-sp-extension-identity.mjs. Do not edit.\nexport const EMBEDDED_REQUIRED_EXTENSION_IDENTITY = {\n\trequired: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.
|
|
1
|
+
{"version":3,"file":"extension-identity.generated.js","sourceRoot":"","sources":["../src/extension-identity.generated.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,CAAC,MAAM,oCAAoC,GAAG;IACnD,QAAQ,EAAE;QACT,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,OAAO;KAChB;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,+BAA+B;QACrC,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,yEAAyE;KACjF;CACQ,CAAC","sourcesContent":["// Generated by scripts/generate-sp-extension-identity.mjs. Do not edit.\nexport const EMBEDDED_REQUIRED_EXTENSION_IDENTITY = {\n\trequired: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.4\",\n\t},\n\tartifact: {\n\t\tname: \"@senpiper/sp-agent-extensions\",\n\t\tversion: \"0.1.4\",\n\t\tdigest: \"sha256:f4211efa0ca9b8f37d2fa6b912a52f83bf96eda494c8e3de16cad2c307c4511f\",\n\t},\n} as const;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-cli.d.ts","sourceRoot":"","sources":["../src/runtime-cli.ts"],"names":[],"mappings":"AAyBA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,iBAqBhD","sourcesContent":["import { main, SessionManager } from \"@senpiper/pi-coding-agent\";\nimport {\n\tconfigureSpEnvironment,\n\tcreateSpMainOptions,\n\tloadRequiredExtension,\n\tSP_AGENT_VERSION,\n} from \"./distribution.ts\";\nimport { createSpAgentSession } from \"./sdk.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout
|
|
1
|
+
{"version":3,"file":"runtime-cli.d.ts","sourceRoot":"","sources":["../src/runtime-cli.ts"],"names":[],"mappings":"AAyBA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,iBAqBhD","sourcesContent":["import { main, SessionManager } from \"@senpiper/pi-coding-agent\";\nimport {\n\tconfigureSpEnvironment,\n\tcreateSpMainOptions,\n\tloadRequiredExtension,\n\tSP_AGENT_VERSION,\n} from \"./distribution.ts\";\nimport { createSpAgentSession } from \"./sdk.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout Manage sp-gateway credentials\n sp update|rollback|repair Manage the active verified release\n sp --help Show this help\n sp-web Start the bundled browser workspace\n\nConfiguration: ~/.sp/agent (override with SP_CODING_AGENT_DIR)`);\n}\n\nexport async function runSpRuntime(args: string[]) {\n\tconfigureSpEnvironment();\n\tprocess.title = \"sp\";\n\tprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\tif (args.length === 1 && args[0] === \"--health-check\") {\n\t\tprocess.env.PI_OFFLINE = \"1\";\n\t\tawait createSpAgentSession({ sessionManager: SessionManager.inMemory() });\n\t\tconsole.log(\"ok\");\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--version\" || args[0] === \"-v\")) {\n\t\tconsole.log(SP_AGENT_VERSION);\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--help\" || args[0] === \"-h\")) {\n\t\tprintHelp();\n\t\treturn;\n\t}\n\tconst extension = await loadRequiredExtension();\n\tif (await extension.handleSpCommand(args)) return;\n\tawait main(args, await createSpMainOptions());\n}\n"]}
|
package/dist/runtime-cli.js
CHANGED
|
@@ -9,7 +9,7 @@ Usage:
|
|
|
9
9
|
sp -p <prompt> Run a one-shot prompt
|
|
10
10
|
sp --mode json|rpc Select a machine-readable mode
|
|
11
11
|
sp --list-models List canonical sp-gateway models
|
|
12
|
-
sp login|logout
|
|
12
|
+
sp login|logout Manage sp-gateway credentials
|
|
13
13
|
sp update|rollback|repair Manage the active verified release
|
|
14
14
|
sp --help Show this help
|
|
15
15
|
sp-web Start the bundled browser workspace
|
package/dist/runtime-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-cli.js","sourceRoot":"","sources":["../src/runtime-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;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AAC;AAAA,CAC9C","sourcesContent":["import { main, SessionManager } from \"@senpiper/pi-coding-agent\";\nimport {\n\tconfigureSpEnvironment,\n\tcreateSpMainOptions,\n\tloadRequiredExtension,\n\tSP_AGENT_VERSION,\n} from \"./distribution.ts\";\nimport { createSpAgentSession } from \"./sdk.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout
|
|
1
|
+
{"version":3,"file":"runtime-cli.js","sourceRoot":"","sources":["../src/runtime-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,SAAS,SAAS,GAAG;IACpB,OAAO,CAAC,GAAG,CAAC,YAAY,gBAAgB;;;;;;;;;;;;+DAYsB,CAAC,CAAC;AAAA,CAChE;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAc,EAAE;IAClD,sBAAsB,EAAE,CAAC;IACzB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,CAAC,EAAC,CAAC,CAA+B,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,EAAE,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;QAC7B,MAAM,oBAAoB,CAAC,EAAE,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO;IACR,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,OAAO;IACR,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,OAAO;IACR,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAChD,IAAI,MAAM,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC;QAAE,OAAO;IAClD,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,mBAAmB,EAAE,CAAC,CAAC;AAAA,CAC9C","sourcesContent":["import { main, SessionManager } from \"@senpiper/pi-coding-agent\";\nimport {\n\tconfigureSpEnvironment,\n\tcreateSpMainOptions,\n\tloadRequiredExtension,\n\tSP_AGENT_VERSION,\n} from \"./distribution.ts\";\nimport { createSpAgentSession } from \"./sdk.ts\";\n\nfunction printHelp() {\n\tconsole.log(`sp-agent ${SP_AGENT_VERSION}\n\nUsage:\n sp Start the interactive terminal\n sp -p <prompt> Run a one-shot prompt\n sp --mode json|rpc Select a machine-readable mode\n sp --list-models List canonical sp-gateway models\n sp login|logout Manage sp-gateway credentials\n sp update|rollback|repair Manage the active verified release\n sp --help Show this help\n sp-web Start the bundled browser workspace\n\nConfiguration: ~/.sp/agent (override with SP_CODING_AGENT_DIR)`);\n}\n\nexport async function runSpRuntime(args: string[]) {\n\tconfigureSpEnvironment();\n\tprocess.title = \"sp\";\n\tprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\tif (args.length === 1 && args[0] === \"--health-check\") {\n\t\tprocess.env.PI_OFFLINE = \"1\";\n\t\tawait createSpAgentSession({ sessionManager: SessionManager.inMemory() });\n\t\tconsole.log(\"ok\");\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--version\" || args[0] === \"-v\")) {\n\t\tconsole.log(SP_AGENT_VERSION);\n\t\treturn;\n\t}\n\tif (args.length === 1 && (args[0] === \"--help\" || args[0] === \"-h\")) {\n\t\tprintHelp();\n\t\treturn;\n\t}\n\tconst extension = await loadRequiredExtension();\n\tif (await extension.handleSpCommand(args)) return;\n\tawait main(args, await createSpMainOptions());\n}\n"]}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SP_AGENT_VERSION = "0.1.
|
|
1
|
+
export declare const SP_AGENT_VERSION = "0.1.10";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,WAAW,CAAC","sourcesContent":["export const SP_AGENT_VERSION = \"0.1.10\";\n"]}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SP_AGENT_VERSION = "0.1.
|
|
1
|
+
export const SP_AGENT_VERSION = "0.1.10";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC","sourcesContent":["export const SP_AGENT_VERSION = \"0.1.10\";\n"]}
|