@agentproto/driver-agent-cli 2.1.0 → 2.2.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-QL3CS6E4.mjs → chunk-TFB4QYOT.mjs} +118 -8
- package/dist/chunk-TFB4QYOT.mjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/manifest/index.d.ts +2 -2
- package/dist/manifest/index.mjs +2 -2
- package/dist/{schema-PGrcCZqt.d.ts → schema-BGmDJ1ZC.d.ts} +11 -2
- package/package.json +3 -3
- package/dist/chunk-QL3CS6E4.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"]).optional()
|
|
327
|
+
event_schema: z.enum(["claude-stream-json", "mastra-jsonl", "antigravity-stream-json"]).optional()
|
|
328
328
|
}).strict().optional();
|
|
329
329
|
var agentCliFrontmatterSchema = z.object({
|
|
330
330
|
name: z.string().min(1).max(80),
|
|
@@ -720,7 +720,11 @@ function createPrintSession(opts) {
|
|
|
720
720
|
if (csid) capturedSessionId = csid;
|
|
721
721
|
const sid = capturedSessionId || sessionId || "";
|
|
722
722
|
const mapped = mapEvent(evt, sid, stderrLines, eventSchema, mastraState);
|
|
723
|
-
if (
|
|
723
|
+
if (Array.isArray(mapped)) {
|
|
724
|
+
for (const m of mapped) queue.push(m);
|
|
725
|
+
} else if (mapped) {
|
|
726
|
+
queue.push(mapped);
|
|
727
|
+
}
|
|
724
728
|
});
|
|
725
729
|
rl.once("close", () => queue.end());
|
|
726
730
|
for await (const mapped of queue) {
|
|
@@ -729,7 +733,7 @@ function createPrintSession(opts) {
|
|
|
729
733
|
const exitCode = await waitForExit(child);
|
|
730
734
|
if (capturedSessionId) sessionId = capturedSessionId;
|
|
731
735
|
if (exitCode !== 0 && exitCode !== null) {
|
|
732
|
-
const binLabel = eventSchema === "mastra-jsonl" ? "mastracode" : "claude";
|
|
736
|
+
const binLabel = eventSchema === "mastra-jsonl" ? "mastracode" : eventSchema === "antigravity-stream-json" ? "agy" : "claude";
|
|
733
737
|
const errEvt = {
|
|
734
738
|
kind: "error",
|
|
735
739
|
error: {
|
|
@@ -864,6 +868,16 @@ function captureSessionId(evt, schema) {
|
|
|
864
868
|
if (evt.type === "result" && typeof evt.session_id === "string" && evt.session_id)
|
|
865
869
|
return evt.session_id;
|
|
866
870
|
return null;
|
|
871
|
+
case "antigravity-stream-json": {
|
|
872
|
+
if (evt.event === "init" && typeof evt.conversation_id === "string" && evt.conversation_id)
|
|
873
|
+
return evt.conversation_id;
|
|
874
|
+
if (evt.event === "result") {
|
|
875
|
+
const r = evt.result;
|
|
876
|
+
if (typeof r?.conversation_id === "string" && r.conversation_id)
|
|
877
|
+
return r.conversation_id;
|
|
878
|
+
}
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
867
881
|
case "mastra-jsonl":
|
|
868
882
|
if (evt.type === "result" && typeof evt.threadId === "string" && evt.threadId)
|
|
869
883
|
return evt.threadId;
|
|
@@ -874,6 +888,8 @@ function mapEvent(evt, sessionId, stderrLines, schema, mastraState) {
|
|
|
874
888
|
switch (schema) {
|
|
875
889
|
case "claude-stream-json":
|
|
876
890
|
return mapClaudeEvent(evt, sessionId, stderrLines);
|
|
891
|
+
case "antigravity-stream-json":
|
|
892
|
+
return mapAntigravityEvent(evt, sessionId, stderrLines);
|
|
877
893
|
case "mastra-jsonl": {
|
|
878
894
|
if (!mastraState) {
|
|
879
895
|
return mapClaudeEvent(evt, sessionId, stderrLines);
|
|
@@ -928,6 +944,93 @@ function mapClaudeEvent(evt, sessionId, stderrLines) {
|
|
|
928
944
|
return null;
|
|
929
945
|
}
|
|
930
946
|
}
|
|
947
|
+
function mapAntigravityEvent(evt, sessionId, stderrLines) {
|
|
948
|
+
switch (evt.event) {
|
|
949
|
+
case "step_update": {
|
|
950
|
+
const su = evt.step_update;
|
|
951
|
+
if (!su) return null;
|
|
952
|
+
const stepType = su.step_type;
|
|
953
|
+
if (stepType === "agent_response" && typeof su.text_delta === "string" && su.text_delta) {
|
|
954
|
+
return { kind: "text-delta", sessionId, text: su.text_delta };
|
|
955
|
+
}
|
|
956
|
+
if (stepType === "tool" && su.state === "DONE") {
|
|
957
|
+
const ti = su.tool_info;
|
|
958
|
+
const toolName = typeof su.tool_name === "string" && su.tool_name ? su.tool_name : typeof ti?.name === "string" && ti.name ? ti.name : "?";
|
|
959
|
+
const toolCallId = typeof su.step_index === "number" ? `step-${su.step_index}` : "";
|
|
960
|
+
const err = ti?.error;
|
|
961
|
+
const call = {
|
|
962
|
+
kind: "tool-call",
|
|
963
|
+
sessionId,
|
|
964
|
+
toolCallId,
|
|
965
|
+
toolName,
|
|
966
|
+
arguments: ti?.parameters ?? {}
|
|
967
|
+
};
|
|
968
|
+
const result = {
|
|
969
|
+
kind: "tool-result",
|
|
970
|
+
sessionId,
|
|
971
|
+
toolCallId,
|
|
972
|
+
result: err ? typeof err.message === "string" ? err.message : err : ti?.output ?? null,
|
|
973
|
+
isError: !!err
|
|
974
|
+
};
|
|
975
|
+
return [call, result];
|
|
976
|
+
}
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
case "result": {
|
|
980
|
+
const r = evt.result;
|
|
981
|
+
if (!r) return null;
|
|
982
|
+
const status = typeof r.status === "string" ? r.status : "";
|
|
983
|
+
const out = [];
|
|
984
|
+
const usage = mapAntigravityUsage(r.usage, sessionId);
|
|
985
|
+
if (usage) out.push(usage);
|
|
986
|
+
if (status === "ERROR" || status === "INVALID") {
|
|
987
|
+
out.push({
|
|
988
|
+
kind: "error",
|
|
989
|
+
sessionId,
|
|
990
|
+
error: {
|
|
991
|
+
message: typeof r.error === "string" && r.error ? r.error : `agy run ended with status ${status || "ERROR"}`,
|
|
992
|
+
...stderrLines.length ? { data: { stderr: stderrLines.join("\n") } } : {}
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
} else {
|
|
996
|
+
out.push({
|
|
997
|
+
kind: "turn-end",
|
|
998
|
+
sessionId,
|
|
999
|
+
reason: mapAntigravityStatus(status)
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
return out.length ? out : null;
|
|
1003
|
+
}
|
|
1004
|
+
// init and any unknown event carry no host-facing StreamEvent.
|
|
1005
|
+
default:
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
function mapAntigravityStatus(raw) {
|
|
1010
|
+
switch (raw) {
|
|
1011
|
+
case "CANCELED":
|
|
1012
|
+
case "INTERRUPTED":
|
|
1013
|
+
return "cancelled";
|
|
1014
|
+
// SUCCESS, WAITING, RUNNING (or anything else non-error): the turn ended.
|
|
1015
|
+
default:
|
|
1016
|
+
return "completed";
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function mapAntigravityUsage(usage, sessionId) {
|
|
1020
|
+
if (usage === null || typeof usage !== "object") return null;
|
|
1021
|
+
const u = usage;
|
|
1022
|
+
const tokensIn = typeof u.input_tokens === "number" ? u.input_tokens : void 0;
|
|
1023
|
+
const tokensOut = typeof u.output_tokens === "number" ? u.output_tokens : void 0;
|
|
1024
|
+
if (tokensIn === void 0 && tokensOut === void 0) return null;
|
|
1025
|
+
return {
|
|
1026
|
+
kind: "usage_update",
|
|
1027
|
+
sessionId,
|
|
1028
|
+
size: 0,
|
|
1029
|
+
used: 0,
|
|
1030
|
+
...tokensIn !== void 0 ? { tokensIn } : {},
|
|
1031
|
+
...tokensOut !== void 0 ? { tokensOut } : {}
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
931
1034
|
function createMastraMapperState() {
|
|
932
1035
|
return { lastTextLength: 0 };
|
|
933
1036
|
}
|
|
@@ -1558,15 +1661,22 @@ function createAgentCliRuntime(definition) {
|
|
|
1558
1661
|
opts?.posture,
|
|
1559
1662
|
config?.mode
|
|
1560
1663
|
);
|
|
1664
|
+
const isolateClaudeCodeConfig = definition.id === "claude-code";
|
|
1561
1665
|
let claudeConfigDir;
|
|
1562
|
-
if (
|
|
1666
|
+
if (isolateClaudeCodeConfig) {
|
|
1563
1667
|
claudeConfigDir = mkdtempSync(
|
|
1564
1668
|
join(tmpdir(), "agentproto-claude-config-")
|
|
1565
1669
|
);
|
|
1566
1670
|
writeFileSync(
|
|
1567
|
-
join(claudeConfigDir, "
|
|
1568
|
-
JSON.stringify({
|
|
1671
|
+
join(claudeConfigDir, ".claude.json"),
|
|
1672
|
+
JSON.stringify({ mcpServers: {} })
|
|
1569
1673
|
);
|
|
1674
|
+
if (permissionMode) {
|
|
1675
|
+
writeFileSync(
|
|
1676
|
+
join(claudeConfigDir, "settings.json"),
|
|
1677
|
+
JSON.stringify({ permissions: { defaultMode: permissionMode } })
|
|
1678
|
+
);
|
|
1679
|
+
}
|
|
1570
1680
|
env.CLAUDE_CONFIG_DIR = claudeConfigDir;
|
|
1571
1681
|
}
|
|
1572
1682
|
if (definition.protocol === "print") {
|
|
@@ -1758,5 +1868,5 @@ function filterStringEnv(env) {
|
|
|
1758
1868
|
}
|
|
1759
1869
|
|
|
1760
1870
|
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 };
|
|
1761
|
-
//# sourceMappingURL=chunk-
|
|
1762
|
-
//# sourceMappingURL=chunk-
|
|
1871
|
+
//# sourceMappingURL=chunk-TFB4QYOT.mjs.map
|
|
1872
|
+
//# sourceMappingURL=chunk-TFB4QYOT.mjs.map
|