@anhlp/alp-runtime 0.0.1-beta.8 → 0.0.1-beta.9
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/dist/claude-transport.js +7 -4
- package/package.json +3 -3
- package/src/claude-transport.ts +13 -3
package/dist/claude-transport.js
CHANGED
|
@@ -12,8 +12,10 @@ import { inputLimitError, POUR_VARS, VAR_NAME } from "./input-limits.js";
|
|
|
12
12
|
import { claudeToolDetail, resultText } from "./tool-detail.js";
|
|
13
13
|
import { CLOSE_REASONS, GATE_KINDS, TASK_STATUSES, TASK_TYPES } from "@anhlp/alp-core/tasks";
|
|
14
14
|
import { commandDecision } from "@anhlp/alp-core/permissions";
|
|
15
|
+
import { isScript, nativeDaemon, nodeExecutable } from "@anhlp/alp-core/packaged";
|
|
15
16
|
var CLAUDE_SDK = ["@anthropic-ai", "claude-agent-sdk"].join("/");
|
|
16
|
-
var claudeSdk = () => import(CLAUDE_SDK);
|
|
17
|
+
var claudeSdk = () => nativeDaemon()?.modules.claudeAgentSdk?.() ?? import(CLAUDE_SDK);
|
|
18
|
+
var scriptExecutable = (command) => nativeDaemon() && (isScript(command) || /\.(ts|tsx|jsx)$/i.test(command)) ? { executable: nodeExecutable() } : {};
|
|
17
19
|
var bounded = (schema, limits) => z.preprocess((value, ctx) => {
|
|
18
20
|
const error = inputLimitError(value, limits);
|
|
19
21
|
if (error) ctx.addIssue({ code: "custom", message: error });
|
|
@@ -430,7 +432,7 @@ var ClaudeTransport = class {
|
|
|
430
432
|
async probeModels(signal) {
|
|
431
433
|
const { query } = await claudeSdk();
|
|
432
434
|
if (signal?.aborted) throw new Error("aborted");
|
|
433
|
-
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command } });
|
|
435
|
+
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command, ...scriptExecutable(this.command) } });
|
|
434
436
|
const stop = () => probe.close();
|
|
435
437
|
signal?.addEventListener("abort", stop);
|
|
436
438
|
try {
|
|
@@ -445,7 +447,7 @@ var ClaudeTransport = class {
|
|
|
445
447
|
async probeUsage() {
|
|
446
448
|
if (this.closed) return void 0;
|
|
447
449
|
const { query } = await claudeSdk();
|
|
448
|
-
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command } });
|
|
450
|
+
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command, ...scriptExecutable(this.command) } });
|
|
449
451
|
try {
|
|
450
452
|
return await probe.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: true });
|
|
451
453
|
} finally {
|
|
@@ -669,7 +671,8 @@ var ClaudeTransport = class {
|
|
|
669
671
|
includePartialMessages: true,
|
|
670
672
|
...from ? { resume: from.resume, ...from.fork ? { forkSession: true, sessionId: this.threadId } : {}, ...from.at ? { resumeSessionAt: from.at } : {} } : { sessionId: this.threadId },
|
|
671
673
|
// Explicit native path avoids SDK optional binaries inside Electron app.asar.
|
|
672
|
-
pathToClaudeCodeExecutable: this.command
|
|
674
|
+
pathToClaudeCodeExecutable: this.command,
|
|
675
|
+
...scriptExecutable(this.command)
|
|
673
676
|
};
|
|
674
677
|
this.bootFailure = new Promise((_, reject) => {
|
|
675
678
|
this.rejectBoot = reject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anhlp/alp-runtime",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ALP runtime module",
|
|
6
6
|
"files": [
|
|
@@ -230,8 +230,8 @@
|
|
|
230
230
|
"node": ">=22.12"
|
|
231
231
|
},
|
|
232
232
|
"dependencies": {
|
|
233
|
-
"@anhlp/alp-core": "0.0.1-beta.
|
|
234
|
-
"@anhlp/alp-protocol": "0.0.1-beta.
|
|
233
|
+
"@anhlp/alp-core": "0.0.1-beta.9",
|
|
234
|
+
"@anhlp/alp-protocol": "0.0.1-beta.9",
|
|
235
235
|
"@anthropic-ai/claude-agent-sdk": "^0.3.292",
|
|
236
236
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
237
237
|
"@agentclientprotocol/sdk": "1.7.0",
|
package/src/claude-transport.ts
CHANGED
|
@@ -11,12 +11,21 @@ import { inputLimitError, POUR_VARS, VAR_NAME, type InputLimits } from './input-
|
|
|
11
11
|
import { claudeToolDetail, resultText } from './tool-detail.js';
|
|
12
12
|
import { CLOSE_REASONS, GATE_KINDS, TASK_STATUSES, TASK_TYPES } from '@anhlp/alp-core/tasks';
|
|
13
13
|
import { commandDecision } from '@anhlp/alp-core/permissions';
|
|
14
|
+
import { isScript, nativeDaemon, nodeExecutable } from '@anhlp/alp-core/packaged';
|
|
14
15
|
|
|
15
16
|
// Keep the Claude SDK behind the runtime boundary. Paseo inspects static
|
|
16
17
|
// imports while compiling plugin entrypoints, including their declaration
|
|
17
18
|
// graph; the SDK is a daemon-only optional runtime dependency.
|
|
19
|
+
// The native alpd (t-81b0.9) carries the SDK inside its executable: there is no node_modules to import
|
|
20
|
+
// it from by name, so its entry registers it.
|
|
18
21
|
const CLAUDE_SDK = ['@anthropic-ai', 'claude-agent-sdk'].join('/');
|
|
19
|
-
const claudeSdk = (): Promise<any> => import(CLAUDE_SDK);
|
|
22
|
+
const claudeSdk = (): Promise<any> => nativeDaemon()?.modules.claudeAgentSdk?.() ?? import(CLAUDE_SDK);
|
|
23
|
+
/**
|
|
24
|
+
* A JavaScript `claude` (a test's fake, an npm install's cli.js) runs under Node. The SDK would pick
|
|
25
|
+
* `bun` inside the native alpd, so name the Node there.
|
|
26
|
+
*/
|
|
27
|
+
// The SDK treats .js/.mjs/.cjs/.ts/.tsx/.jsx as scripts.
|
|
28
|
+
const scriptExecutable = (command: string): { executable?: any } => nativeDaemon() && (isScript(command) || /\.(ts|tsx|jsx)$/i.test(command)) ? { executable: nodeExecutable() } : {};
|
|
20
29
|
|
|
21
30
|
type SDKUserMessage = any;
|
|
22
31
|
type SDKMessage = any;
|
|
@@ -547,7 +556,7 @@ export class ClaudeTransport {
|
|
|
547
556
|
async probeModels(signal?: AbortSignal) {
|
|
548
557
|
const { query } = await claudeSdk();
|
|
549
558
|
if (signal?.aborted) throw new Error('aborted');
|
|
550
|
-
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command } }) as ClaudeQuery;
|
|
559
|
+
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command, ...scriptExecutable(this.command) } }) as ClaudeQuery;
|
|
551
560
|
// A probe that outlives its bound is closed, so a hanging Claude process never stays behind.
|
|
552
561
|
const stop = () => probe.close();
|
|
553
562
|
signal?.addEventListener('abort', stop);
|
|
@@ -564,7 +573,7 @@ export class ClaudeTransport {
|
|
|
564
573
|
private async probeUsage() {
|
|
565
574
|
if (this.closed) return undefined;
|
|
566
575
|
const { query } = await claudeSdk();
|
|
567
|
-
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command } }) as ClaudeQuery;
|
|
576
|
+
const probe = query({ prompt: new InputQueue(), options: { cwd: this.cwd, env: this.env, settingSources: [], persistSession: false, strictMcpConfig: true, mcpServers: {}, pathToClaudeCodeExecutable: this.command, ...scriptExecutable(this.command) } }) as ClaudeQuery;
|
|
568
577
|
try {
|
|
569
578
|
return await probe.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: true });
|
|
570
579
|
} finally {
|
|
@@ -812,6 +821,7 @@ export class ClaudeTransport {
|
|
|
812
821
|
...(from ? { resume: from.resume, ...(from.fork ? { forkSession: true, sessionId: this.threadId } : {}), ...(from.at ? { resumeSessionAt: from.at } : {}) } : { sessionId: this.threadId }),
|
|
813
822
|
// Explicit native path avoids SDK optional binaries inside Electron app.asar.
|
|
814
823
|
pathToClaudeCodeExecutable: this.command,
|
|
824
|
+
...scriptExecutable(this.command),
|
|
815
825
|
};
|
|
816
826
|
|
|
817
827
|
this.bootFailure = new Promise<never>((_, reject) => { this.rejectBoot = reject; });
|