@agentproto/driver-agent-cli 2.2.2 → 2.3.0
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/{chunk-ZXVIBZ4S.mjs → chunk-774L5IO5.mjs} +105 -13
- package/dist/chunk-774L5IO5.mjs.map +1 -0
- package/dist/index.d.ts +36 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.mjs +2 -2
- package/dist/{schema-BGmDJ1ZC.d.ts → schema-BjnfZku5.d.ts} +26 -2
- package/package.json +1 -1
- package/dist/chunk-ZXVIBZ4S.mjs.map +0 -1
|
@@ -324,7 +324,7 @@ var printConfigSchema = z.object({
|
|
|
324
324
|
flag: z.string(),
|
|
325
325
|
kind: z.enum(["value", "boolean"])
|
|
326
326
|
}).strict().optional(),
|
|
327
|
-
event_schema: z.enum(["claude-stream-json", "mastra-jsonl", "antigravity-stream-json"]).optional()
|
|
327
|
+
event_schema: z.enum(["claude-stream-json", "mastra-jsonl", "antigravity-stream-json", "jcode-ndjson"]).optional()
|
|
328
328
|
}).strict().optional();
|
|
329
329
|
var agentCliFrontmatterSchema = z.object({
|
|
330
330
|
name: z.string().min(1).max(80),
|
|
@@ -722,6 +722,7 @@ function createPrintSession(opts) {
|
|
|
722
722
|
throw new Error("print-arm: child has no stdout pipe");
|
|
723
723
|
let capturedSessionId = "";
|
|
724
724
|
const mastraState = eventSchema === "mastra-jsonl" ? createMastraMapperState() : void 0;
|
|
725
|
+
const jcodeState = eventSchema === "jcode-ndjson" ? createJcodeMapperState() : void 0;
|
|
725
726
|
const rl = createInterface({ input: child.stdout, crlfDelay: Infinity });
|
|
726
727
|
const queue = new EventQueue();
|
|
727
728
|
rl.on("line", (line) => {
|
|
@@ -735,7 +736,7 @@ function createPrintSession(opts) {
|
|
|
735
736
|
const csid = captureSessionId(evt, eventSchema);
|
|
736
737
|
if (csid) capturedSessionId = csid;
|
|
737
738
|
const sid = capturedSessionId || sessionId || "";
|
|
738
|
-
const mapped = mapEvent(evt, sid, stderrLines, eventSchema, mastraState);
|
|
739
|
+
const mapped = mapEvent(evt, sid, stderrLines, eventSchema, mastraState, jcodeState);
|
|
739
740
|
if (Array.isArray(mapped)) {
|
|
740
741
|
for (const m of mapped) queue.push(m);
|
|
741
742
|
} else if (mapped) {
|
|
@@ -749,7 +750,7 @@ function createPrintSession(opts) {
|
|
|
749
750
|
const exitCode = await waitForExit(child);
|
|
750
751
|
if (capturedSessionId) sessionId = capturedSessionId;
|
|
751
752
|
if (exitCode !== 0 && exitCode !== null) {
|
|
752
|
-
const binLabel = eventSchema === "mastra-jsonl" ? "mastracode" : eventSchema === "antigravity-stream-json" ? "agy" : "claude";
|
|
753
|
+
const binLabel = eventSchema === "mastra-jsonl" ? "mastracode" : eventSchema === "antigravity-stream-json" ? "agy" : eventSchema === "jcode-ndjson" ? "jcode" : "claude";
|
|
753
754
|
const errEvt = {
|
|
754
755
|
kind: "error",
|
|
755
756
|
error: {
|
|
@@ -898,9 +899,13 @@ function captureSessionId(evt, schema) {
|
|
|
898
899
|
if (evt.type === "result" && typeof evt.threadId === "string" && evt.threadId)
|
|
899
900
|
return evt.threadId;
|
|
900
901
|
return null;
|
|
902
|
+
case "jcode-ndjson":
|
|
903
|
+
if ((evt.type === "start" || evt.type === "done") && typeof evt.session_id === "string" && evt.session_id)
|
|
904
|
+
return evt.session_id;
|
|
905
|
+
return null;
|
|
901
906
|
}
|
|
902
907
|
}
|
|
903
|
-
function mapEvent(evt, sessionId, stderrLines, schema, mastraState) {
|
|
908
|
+
function mapEvent(evt, sessionId, stderrLines, schema, mastraState, jcodeState) {
|
|
904
909
|
switch (schema) {
|
|
905
910
|
case "claude-stream-json":
|
|
906
911
|
return mapClaudeEvent(evt, sessionId, stderrLines);
|
|
@@ -912,6 +917,8 @@ function mapEvent(evt, sessionId, stderrLines, schema, mastraState) {
|
|
|
912
917
|
}
|
|
913
918
|
return mapMastraEvent(evt, sessionId, stderrLines, mastraState);
|
|
914
919
|
}
|
|
920
|
+
case "jcode-ndjson":
|
|
921
|
+
return mapJcodeEvent(evt, sessionId, jcodeState ?? createJcodeMapperState());
|
|
915
922
|
default:
|
|
916
923
|
return mapClaudeEvent(evt, sessionId, stderrLines);
|
|
917
924
|
}
|
|
@@ -1047,6 +1054,74 @@ function mapAntigravityUsage(usage, sessionId) {
|
|
|
1047
1054
|
...tokensOut !== void 0 ? { tokensOut } : {}
|
|
1048
1055
|
};
|
|
1049
1056
|
}
|
|
1057
|
+
function createJcodeMapperState() {
|
|
1058
|
+
return {};
|
|
1059
|
+
}
|
|
1060
|
+
function mapJcodeEvent(evt, sessionId, state) {
|
|
1061
|
+
switch (evt.type) {
|
|
1062
|
+
case "text_delta":
|
|
1063
|
+
return typeof evt.text === "string" ? { kind: "text-delta", sessionId, text: evt.text } : null;
|
|
1064
|
+
case "tool_start":
|
|
1065
|
+
state.pending = {
|
|
1066
|
+
id: typeof evt.id === "string" ? evt.id : "",
|
|
1067
|
+
name: typeof evt.name === "string" ? evt.name : "?",
|
|
1068
|
+
input: ""
|
|
1069
|
+
};
|
|
1070
|
+
return null;
|
|
1071
|
+
case "tool_input":
|
|
1072
|
+
if (state.pending && typeof evt.delta === "string")
|
|
1073
|
+
state.pending.input += evt.delta;
|
|
1074
|
+
return null;
|
|
1075
|
+
case "tool_exec":
|
|
1076
|
+
return flushPendingJcodeCall(state, sessionId);
|
|
1077
|
+
case "tool_done": {
|
|
1078
|
+
const call = flushPendingJcodeCall(state, sessionId);
|
|
1079
|
+
const result = {
|
|
1080
|
+
kind: "tool-result",
|
|
1081
|
+
sessionId,
|
|
1082
|
+
toolCallId: typeof evt.id === "string" ? evt.id : "",
|
|
1083
|
+
result: evt.output ?? null,
|
|
1084
|
+
isError: evt.error !== null && evt.error !== void 0
|
|
1085
|
+
};
|
|
1086
|
+
return call ? [call, result] : result;
|
|
1087
|
+
}
|
|
1088
|
+
case "tokens": {
|
|
1089
|
+
const tokensIn = typeof evt.input === "number" ? evt.input : void 0;
|
|
1090
|
+
const tokensOut = typeof evt.output === "number" ? evt.output : void 0;
|
|
1091
|
+
if (tokensIn === void 0 && tokensOut === void 0) return null;
|
|
1092
|
+
return {
|
|
1093
|
+
kind: "usage_update",
|
|
1094
|
+
sessionId,
|
|
1095
|
+
size: 0,
|
|
1096
|
+
used: 0,
|
|
1097
|
+
...tokensIn !== void 0 ? { tokensIn } : {},
|
|
1098
|
+
...tokensOut !== void 0 ? { tokensOut } : {}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
case "done":
|
|
1102
|
+
return { kind: "turn-end", sessionId, reason: "completed" };
|
|
1103
|
+
default:
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function flushPendingJcodeCall(state, sessionId) {
|
|
1108
|
+
const pending = state.pending;
|
|
1109
|
+
state.pending = void 0;
|
|
1110
|
+
if (!pending) return null;
|
|
1111
|
+
let args;
|
|
1112
|
+
try {
|
|
1113
|
+
args = JSON.parse(pending.input);
|
|
1114
|
+
} catch {
|
|
1115
|
+
args = { raw: pending.input };
|
|
1116
|
+
}
|
|
1117
|
+
return {
|
|
1118
|
+
kind: "tool-call",
|
|
1119
|
+
sessionId,
|
|
1120
|
+
toolCallId: pending.id,
|
|
1121
|
+
toolName: pending.name,
|
|
1122
|
+
arguments: args
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1050
1125
|
function createMastraMapperState() {
|
|
1051
1126
|
return { lastTextLength: 0 };
|
|
1052
1127
|
}
|
|
@@ -1684,12 +1759,26 @@ function createAgentCliRuntime(definition) {
|
|
|
1684
1759
|
const isolateClaudeCodeConfig = definition.id === "claude-code";
|
|
1685
1760
|
let claudeConfigDir;
|
|
1686
1761
|
if (isolateClaudeCodeConfig) {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1762
|
+
if (opts?.configDir) {
|
|
1763
|
+
claudeConfigDir = opts.configDir;
|
|
1764
|
+
mkdirSync(claudeConfigDir, { recursive: true });
|
|
1765
|
+
} else {
|
|
1766
|
+
claudeConfigDir = mkdtempSync(
|
|
1767
|
+
join(tmpdir(), "agentproto-claude-config-")
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
const globalConfigPath = join(claudeConfigDir, ".claude.json");
|
|
1771
|
+
let priorGlobalConfig = {};
|
|
1772
|
+
try {
|
|
1773
|
+
const parsed = JSON.parse(readFileSync(globalConfigPath, "utf8"));
|
|
1774
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
1775
|
+
priorGlobalConfig = parsed;
|
|
1776
|
+
}
|
|
1777
|
+
} catch {
|
|
1778
|
+
}
|
|
1690
1779
|
writeFileSync(
|
|
1691
|
-
|
|
1692
|
-
JSON.stringify({ mcpServers: {} })
|
|
1780
|
+
globalConfigPath,
|
|
1781
|
+
JSON.stringify({ ...priorGlobalConfig, mcpServers: {} })
|
|
1693
1782
|
);
|
|
1694
1783
|
const isolatedSettings = {
|
|
1695
1784
|
attribution: { commit: "", pr: "", sessionUrl: false }
|
|
@@ -1745,8 +1834,11 @@ function createAgentCliRuntime(definition) {
|
|
|
1745
1834
|
});
|
|
1746
1835
|
});
|
|
1747
1836
|
if (spawnFailure) {
|
|
1837
|
+
const isEnoent = spawnFailure.code === "ENOENT";
|
|
1838
|
+
const enoentHint = isEnoent ? `
|
|
1839
|
+
'${execBin}' was not found on the daemon's PATH. If it works in your own terminal, the daemon's environment may be stale \u2014 try \`agentproto daemon restart\`.` : "";
|
|
1748
1840
|
throw new Error(
|
|
1749
|
-
`agent-cli '${definition.id}': failed to spawn '${execBin} ${execArgs.join(" ")}': ${spawnFailure.message}`
|
|
1841
|
+
`agent-cli '${definition.id}': failed to spawn '${execBin} ${execArgs.join(" ")}': ${spawnFailure.message}${enoentHint}`
|
|
1750
1842
|
);
|
|
1751
1843
|
}
|
|
1752
1844
|
spawned.on("error", (err) => {
|
|
@@ -1908,6 +2000,6 @@ function filterStringEnv(env) {
|
|
|
1908
2000
|
return out;
|
|
1909
2001
|
}
|
|
1910
2002
|
|
|
1911
|
-
export { LEGACY_GATEWAY_MODE_IDS, LEGACY_POSTURE_MODE_IDS, RuntimeConfigError, agentCliFrontmatterSchema, applyModelCommand, autoAllowPermissionHandler, composeSpawn, createAcpProtocolArm, createAgentCliRuntime, createArmSessionControls, createMastraMapperState, createPrintSession, createProprietaryProtocolArm, defineAgentCli, inferLegacyModeKind, isLegacyExtractedModeId, mapMastraEvent, planModePermissionHandler, promptTurn, resolveContinuationStrategy, runtimeConfigSchema, toFileBasedMcpServers };
|
|
1912
|
-
//# sourceMappingURL=chunk-
|
|
1913
|
-
//# sourceMappingURL=chunk-
|
|
2003
|
+
export { LEGACY_GATEWAY_MODE_IDS, LEGACY_POSTURE_MODE_IDS, RuntimeConfigError, agentCliFrontmatterSchema, applyModelCommand, autoAllowPermissionHandler, composeSpawn, createAcpProtocolArm, createAgentCliRuntime, createArmSessionControls, createJcodeMapperState, createMastraMapperState, createPrintSession, createProprietaryProtocolArm, defineAgentCli, inferLegacyModeKind, isLegacyExtractedModeId, mapJcodeEvent, mapMastraEvent, planModePermissionHandler, promptTurn, resolveContinuationStrategy, runtimeConfigSchema, toFileBasedMcpServers };
|
|
2004
|
+
//# sourceMappingURL=chunk-774L5IO5.mjs.map
|
|
2005
|
+
//# sourceMappingURL=chunk-774L5IO5.mjs.map
|