stitchkit 0.59.0 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +102 -0
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -0
- package/dist/agent-runtime.js +143 -46
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-zk5zn2nh.js → index-3nwng7hs.js} +287 -38
- package/dist/tools/cli-args.d.ts +16 -0
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-command.d.ts +16 -0
- package/dist/tools/cli-command.d.ts.map +1 -1
- package/dist/tools/cli-policy.d.ts +22 -0
- package/dist/tools/cli-policy.d.ts.map +1 -0
- package/dist/tools/cli.d.ts +2 -1
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools.d.ts +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +1 -1
- package/llms-full.txt +92 -14
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAGlB,KAAK,OAAO,EACb,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,qBA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,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACjE,KAAK,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AA8ED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,KAAK,SAAS,OAAO,EAC/D,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,GACzC,YAAY,CAAC,OAAO,CAAC,CA6lCvB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type AgentMessage, type AgentRun, type AgentSnapshot, type AgentTerminalReason } from './schemas';
|
|
2
|
+
import type { AgentRuntimeStore, AgentStoreMutationResult } from './store';
|
|
3
|
+
export declare class AgentRuntimeConflictError extends Error {
|
|
4
|
+
constructor(operation: string);
|
|
5
|
+
}
|
|
6
|
+
export declare function appliedSnapshot(result: AgentStoreMutationResult, operation: string): {
|
|
7
|
+
schemaVersion: 1;
|
|
8
|
+
conversationId: string;
|
|
9
|
+
version: number;
|
|
10
|
+
messages: {
|
|
11
|
+
schemaVersion: 1;
|
|
12
|
+
id: string;
|
|
13
|
+
conversationId: string;
|
|
14
|
+
runId?: string | undefined;
|
|
15
|
+
role: "assistant" | "summary" | "system" | "user";
|
|
16
|
+
status: "committed" | "completed" | "failed" | "interrupted" | "streaming";
|
|
17
|
+
parts: ({
|
|
18
|
+
type: "text";
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "reasoning";
|
|
22
|
+
text: string;
|
|
23
|
+
provider?: {
|
|
24
|
+
schemaVersion: number;
|
|
25
|
+
provider: string;
|
|
26
|
+
data: Record<string, import("zod").JSONType>;
|
|
27
|
+
} | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
type: "file";
|
|
30
|
+
mediaType: string;
|
|
31
|
+
reference: string;
|
|
32
|
+
filename?: string | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
type: "source";
|
|
35
|
+
sourceId: string;
|
|
36
|
+
url?: string | undefined;
|
|
37
|
+
title?: string | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
type: "tool-call";
|
|
40
|
+
callId: string;
|
|
41
|
+
toolName: string;
|
|
42
|
+
input: import("zod").JSONType;
|
|
43
|
+
provider?: {
|
|
44
|
+
schemaVersion: number;
|
|
45
|
+
provider: string;
|
|
46
|
+
data: Record<string, import("zod").JSONType>;
|
|
47
|
+
} | undefined;
|
|
48
|
+
} | {
|
|
49
|
+
type: "tool-result";
|
|
50
|
+
callId: string;
|
|
51
|
+
toolName: string;
|
|
52
|
+
outcome: "error" | "interrupted" | "success";
|
|
53
|
+
output?: import("zod").JSONType | undefined;
|
|
54
|
+
} | {
|
|
55
|
+
type: "provider";
|
|
56
|
+
envelope: {
|
|
57
|
+
schemaVersion: number;
|
|
58
|
+
provider: string;
|
|
59
|
+
data: Record<string, import("zod").JSONType>;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
type: "control";
|
|
63
|
+
reason: "run-interrupted" | "stale-run";
|
|
64
|
+
})[];
|
|
65
|
+
metadata?: Record<string, import("zod").JSONType> | undefined;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
}[];
|
|
69
|
+
runs: {
|
|
70
|
+
schemaVersion: 1;
|
|
71
|
+
id: string;
|
|
72
|
+
conversationId: string;
|
|
73
|
+
inputMessageIds: string[];
|
|
74
|
+
assistantMessageId: string;
|
|
75
|
+
state: "abandoned" | "cancelled" | "completed" | "failed" | "interrupt_requested" | "interrupted" | "queued" | "running";
|
|
76
|
+
revision: number;
|
|
77
|
+
ownerId?: string | undefined;
|
|
78
|
+
fencingToken?: number | undefined;
|
|
79
|
+
terminalReason?: "abandoned" | "cancelled" | "interrupted" | "policy_stop" | "provider_failure" | "shutdown" | "success" | "timeout" | "tool_failure" | undefined;
|
|
80
|
+
terminalPolicyName?: string | undefined;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
updatedAt: string;
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
interface TerminalCommitCandidate {
|
|
86
|
+
run: AgentRun;
|
|
87
|
+
assistant: AgentMessage;
|
|
88
|
+
reason: AgentTerminalReason;
|
|
89
|
+
policyName?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface AgentTerminalCommitResolution extends TerminalCommitCandidate {
|
|
92
|
+
snapshot: AgentSnapshot;
|
|
93
|
+
committedByCaller: boolean;
|
|
94
|
+
}
|
|
95
|
+
export declare function commitAgentRunTerminal(input: {
|
|
96
|
+
store: AgentRuntimeStore;
|
|
97
|
+
runtimeEpoch: string;
|
|
98
|
+
candidate: TerminalCommitCandidate;
|
|
99
|
+
now: () => Date;
|
|
100
|
+
}): Promise<AgentTerminalCommitResolution>;
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=terminal-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-commit.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/terminal-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE3E,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,YAAY,SAAS,EAAE,MAAM,EAG5B;CACF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGlF;AAED,UAAU,uBAAuB;IAC/B,GAAG,EAAE,QAAQ,CAAC;IACd,SAAS,EAAE,YAAY,CAAC;IACxB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAUD,MAAM,WAAW,6BAA8B,SAAQ,uBAAuB;IAC5E,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAuED,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IAClD,KAAK,EAAE,iBAAiB,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,uBAAuB,CAAC;IACnC,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4CzC"}
|
package/dist/agent-runtime.js
CHANGED
|
@@ -900,6 +900,8 @@ import {
|
|
|
900
900
|
streamText
|
|
901
901
|
} from "ai";
|
|
902
902
|
import { z as z5 } from "zod";
|
|
903
|
+
|
|
904
|
+
// src/agent-runtime/terminal-commit.ts
|
|
903
905
|
class AgentRuntimeConflictError extends Error {
|
|
904
906
|
constructor(operation) {
|
|
905
907
|
super(`Agent runtime store conflict during ${operation}`);
|
|
@@ -911,6 +913,94 @@ function appliedSnapshot(result, operation) {
|
|
|
911
913
|
return result.snapshot;
|
|
912
914
|
throw new AgentRuntimeConflictError(operation);
|
|
913
915
|
}
|
|
916
|
+
function terminalMessageStatus(reason) {
|
|
917
|
+
if (reason === "success" || reason === "policy_stop")
|
|
918
|
+
return "completed";
|
|
919
|
+
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
920
|
+
return "interrupted";
|
|
921
|
+
}
|
|
922
|
+
return "failed";
|
|
923
|
+
}
|
|
924
|
+
function canonicalTerminal(snapshot, runId, retainedAssistant) {
|
|
925
|
+
const run = snapshot.runs.find((candidate) => candidate.id === runId);
|
|
926
|
+
if (!run?.terminalReason)
|
|
927
|
+
return;
|
|
928
|
+
const assistant = snapshot.messages.find((message) => message.id === run.assistantMessageId) ?? retainedAssistant;
|
|
929
|
+
if (snapshot.conversationId !== run.conversationId || !assistant || assistant.id !== run.assistantMessageId || assistant.conversationId !== run.conversationId || assistant.runId !== run.id || assistant.role !== "assistant" || assistant.status !== terminalMessageStatus(run.terminalReason)) {
|
|
930
|
+
throw new AgentRuntimeConflictError("terminal result projection");
|
|
931
|
+
}
|
|
932
|
+
return {
|
|
933
|
+
snapshot,
|
|
934
|
+
run,
|
|
935
|
+
assistant,
|
|
936
|
+
reason: run.terminalReason,
|
|
937
|
+
committedByCaller: false,
|
|
938
|
+
...run.terminalPolicyName && { policyName: run.terminalPolicyName }
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
function interruptedCandidate(candidate, run, now) {
|
|
942
|
+
const hasInterruptControl = candidate.assistant.parts.some((part) => part.type === "control" && part.reason === "run-interrupted");
|
|
943
|
+
const parts = hasInterruptControl ? candidate.assistant.parts : [
|
|
944
|
+
...candidate.assistant.parts,
|
|
945
|
+
AgentMessagePartSchema.parse({ type: "control", reason: "run-interrupted" })
|
|
946
|
+
];
|
|
947
|
+
return {
|
|
948
|
+
run,
|
|
949
|
+
assistant: AgentMessageSchema.parse({
|
|
950
|
+
...candidate.assistant,
|
|
951
|
+
status: "interrupted",
|
|
952
|
+
parts,
|
|
953
|
+
updatedAt: now().toISOString()
|
|
954
|
+
}),
|
|
955
|
+
reason: "interrupted"
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function canRetryTerminal(current, previous, runtimeEpoch) {
|
|
959
|
+
return (current.state === "running" || current.state === "interrupt_requested") && current.ownerId === runtimeEpoch && current.fencingToken === previous.fencingToken;
|
|
960
|
+
}
|
|
961
|
+
async function commitAgentRunTerminal(input) {
|
|
962
|
+
let candidate = input.candidate;
|
|
963
|
+
while (true) {
|
|
964
|
+
const committed = await input.store.commitRunTerminal({
|
|
965
|
+
conversationId: candidate.run.conversationId,
|
|
966
|
+
runId: candidate.run.id,
|
|
967
|
+
expectedRevision: candidate.run.revision,
|
|
968
|
+
ownerId: input.runtimeEpoch,
|
|
969
|
+
...candidate.run.fencingToken !== undefined && {
|
|
970
|
+
fencingToken: candidate.run.fencingToken
|
|
971
|
+
},
|
|
972
|
+
assistant: candidate.assistant,
|
|
973
|
+
reason: candidate.reason,
|
|
974
|
+
...candidate.policyName && { policyName: candidate.policyName }
|
|
975
|
+
});
|
|
976
|
+
if (committed.outcome === "applied") {
|
|
977
|
+
const terminal2 = canonicalTerminal(committed.snapshot, candidate.run.id);
|
|
978
|
+
if (!terminal2)
|
|
979
|
+
throw new AgentRuntimeConflictError("terminal result projection");
|
|
980
|
+
return { ...terminal2, committedByCaller: true };
|
|
981
|
+
}
|
|
982
|
+
if (committed.outcome === "duplicate") {
|
|
983
|
+
const terminal2 = canonicalTerminal(committed.snapshot, candidate.run.id, committed.assistant);
|
|
984
|
+
if (!terminal2)
|
|
985
|
+
throw new AgentRuntimeConflictError("terminal result projection");
|
|
986
|
+
return terminal2;
|
|
987
|
+
}
|
|
988
|
+
if (committed.outcome !== "conflict") {
|
|
989
|
+
throw new AgentRuntimeConflictError("terminal commit");
|
|
990
|
+
}
|
|
991
|
+
const latest = await input.store.loadSnapshot(candidate.run.conversationId);
|
|
992
|
+
const terminal = canonicalTerminal(latest, candidate.run.id);
|
|
993
|
+
if (terminal)
|
|
994
|
+
return terminal;
|
|
995
|
+
const current = latest.runs.find((run) => run.id === candidate.run.id);
|
|
996
|
+
if (!current || !canRetryTerminal(current, candidate.run, input.runtimeEpoch)) {
|
|
997
|
+
throw new AgentRuntimeConflictError("terminal commit");
|
|
998
|
+
}
|
|
999
|
+
candidate = current.state === "interrupt_requested" ? interruptedCandidate(candidate, current, input.now) : { ...candidate, run: current };
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/agent-runtime/runtime.ts
|
|
914
1004
|
function findRun(runs, runId) {
|
|
915
1005
|
const run = runs.find((candidate) => candidate.id === runId);
|
|
916
1006
|
if (!run)
|
|
@@ -1547,59 +1637,66 @@ function createAgentRuntime(config) {
|
|
|
1547
1637
|
parts,
|
|
1548
1638
|
updatedAt: now().toISOString()
|
|
1549
1639
|
});
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1640
|
+
const terminal = await commitAgentRunTerminal({
|
|
1641
|
+
store: config.store,
|
|
1642
|
+
runtimeEpoch,
|
|
1643
|
+
candidate: {
|
|
1644
|
+
run,
|
|
1645
|
+
assistant,
|
|
1646
|
+
reason: terminalReason,
|
|
1647
|
+
...terminalPolicyName && { policyName: terminalPolicyName }
|
|
1648
|
+
},
|
|
1649
|
+
now
|
|
1650
|
+
});
|
|
1651
|
+
snapshot = terminal.snapshot;
|
|
1652
|
+
run = terminal.run;
|
|
1653
|
+
assistant = terminal.assistant;
|
|
1654
|
+
terminalReason = terminal.reason;
|
|
1655
|
+
terminalPolicyName = terminal.policyName;
|
|
1656
|
+
const terminalMetrics = terminal.committedByCaller ? {
|
|
1562
1657
|
partial: false,
|
|
1563
1658
|
durationMs: performance.now() - runStartedAt,
|
|
1564
1659
|
...usage && { usage },
|
|
1565
1660
|
...firstOutputAt !== undefined && { ttftMs: firstOutputAt - runStartedAt }
|
|
1566
|
-
};
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1661
|
+
} : undefined;
|
|
1662
|
+
if (terminalMetrics) {
|
|
1663
|
+
config.observe?.emit({
|
|
1664
|
+
schemaVersion: 1,
|
|
1665
|
+
eventId: agentDurableEventId("terminal", run.id, snapshot.version),
|
|
1666
|
+
type: "run-terminal",
|
|
1667
|
+
conversationId: run.conversationId,
|
|
1668
|
+
runId: run.id,
|
|
1669
|
+
traceId: trace?.traceId ?? generateId(),
|
|
1670
|
+
spanId: trace?.spanId ?? generateId(),
|
|
1671
|
+
...trace?.parentSpanId && { parentSpanId: trace.parentSpanId },
|
|
1672
|
+
state: run.state,
|
|
1673
|
+
terminalReason,
|
|
1674
|
+
...selectedModel && { modelId: selectedModel.descriptor.modelId },
|
|
1675
|
+
durationMs: terminalMetrics.durationMs,
|
|
1676
|
+
...usage && { usage },
|
|
1677
|
+
...internalCause !== undefined && { internalCause },
|
|
1678
|
+
...firstOutputAt !== undefined && { ttftMs: firstOutputAt - runStartedAt },
|
|
1679
|
+
emittedAt: now().toISOString()
|
|
1680
|
+
});
|
|
1681
|
+
await publish({
|
|
1682
|
+
type: "terminal",
|
|
1683
|
+
eventId: agentDurableEventId("terminal", run.id, snapshot.version),
|
|
1684
|
+
conversationId: run.conversationId,
|
|
1685
|
+
runId: run.id,
|
|
1686
|
+
snapshotVersion: snapshot.version,
|
|
1687
|
+
reason: terminalReason,
|
|
1688
|
+
...terminalPolicyName && { policyName: terminalPolicyName },
|
|
1689
|
+
message: assistant,
|
|
1690
|
+
metrics: terminalMetrics,
|
|
1691
|
+
emittedAt: now().toISOString()
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1597
1694
|
return {
|
|
1598
1695
|
run,
|
|
1599
1696
|
message: assistant,
|
|
1600
1697
|
reason: terminalReason,
|
|
1601
1698
|
snapshotVersion: snapshot.version,
|
|
1602
|
-
metrics: terminalMetrics,
|
|
1699
|
+
...terminalMetrics && { metrics: terminalMetrics },
|
|
1603
1700
|
...terminalPolicyName && { policyName: terminalPolicyName }
|
|
1604
1701
|
};
|
|
1605
1702
|
};
|
|
@@ -2175,7 +2272,7 @@ function terminalState(reason) {
|
|
|
2175
2272
|
return "abandoned";
|
|
2176
2273
|
return "failed";
|
|
2177
2274
|
}
|
|
2178
|
-
function
|
|
2275
|
+
function terminalMessageStatus2(reason) {
|
|
2179
2276
|
if (reason === "success" || reason === "policy_stop")
|
|
2180
2277
|
return "completed";
|
|
2181
2278
|
if (reason === "interrupted" || reason === "cancelled" || reason === "shutdown") {
|
|
@@ -2343,7 +2440,7 @@ function reduceStore(current, operation) {
|
|
|
2343
2440
|
}
|
|
2344
2441
|
if (operation.type === "terminal" && run) {
|
|
2345
2442
|
const input = operation.input;
|
|
2346
|
-
if (run.revision !== input.expectedRevision || run.state !== "running" && run.state !== "interrupt_requested" || run.ownerId !== input.ownerId || input.fencingToken !== undefined && run.fencingToken !== input.fencingToken || input.assistant.runId !== run.id || input.assistant.id !== run.assistantMessageId || input.assistant.conversationId !== run.conversationId || input.assistant.role !== "assistant" || input.assistant.status !==
|
|
2443
|
+
if (run.revision !== input.expectedRevision || run.state !== "running" && run.state !== "interrupt_requested" || run.ownerId !== input.ownerId || input.fencingToken !== undefined && run.fencingToken !== input.fencingToken || input.assistant.runId !== run.id || input.assistant.id !== run.assistantMessageId || input.assistant.conversationId !== run.conversationId || input.assistant.role !== "assistant" || input.assistant.status !== terminalMessageStatus2(input.reason)) {
|
|
2347
2444
|
return conflict(run.revision);
|
|
2348
2445
|
}
|
|
2349
2446
|
const next = AgentRunSchema.parse({
|
package/dist/cli.d.ts
CHANGED
|
@@ -20,5 +20,6 @@ export { type CliConfig, type CliSurfaceSource, createCli } from './tools/cli';
|
|
|
20
20
|
export { type CliRunOptions, type ParsedCliArgs, parseCliArgs } from './tools/cli-args';
|
|
21
21
|
export { type CliCommandContext, type CliCommandDefinition, type CliCommandDefinitionBase, type CliCommandDefinitionWithOutput, type CliCommandDefinitionWithoutOutput, defineCliCommand, } from './tools/cli-command';
|
|
22
22
|
export { type CliWriters, DEFAULT_EXIT_CODES, type EmitOptions, type ExitCodeMap, emitResult, } from './tools/cli-format';
|
|
23
|
+
export type { CliPresentationPolicyConfig } from './tools/cli-policy';
|
|
23
24
|
export { type CliWaitConfig, type PollParams, pollUntilDone } from './tools/cli-wait';
|
|
24
25
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACtC,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,UAAU,EACf,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACnC,KAAK,iCAAiC,EACtC,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,UAAU,EACf,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -182,6 +182,105 @@ var NUMERIC_VALUE = /^-(\d+\.?\d*|\.\d+)$/;
|
|
|
182
182
|
var BOOL_OPTIONS = new Set(["json", "wait", "quiet", "dry-run", "help"]);
|
|
183
183
|
var VALUE_OPTIONS = new Set(["wait-timeout", "output-dir"]);
|
|
184
184
|
var RESERVED_CLI_OPTIONS = new Set([...BOOL_OPTIONS, ...VALUE_OPTIONS]);
|
|
185
|
+
function classifyLongOptionToken(token) {
|
|
186
|
+
if (!token.startsWith("--") || token === "--")
|
|
187
|
+
return;
|
|
188
|
+
const equals = token.indexOf("=");
|
|
189
|
+
const name = equals >= 0 ? token.slice(2, equals) : token.slice(2);
|
|
190
|
+
return {
|
|
191
|
+
name,
|
|
192
|
+
value: equals >= 0 ? token.slice(equals + 1) : undefined,
|
|
193
|
+
inline: equals >= 0,
|
|
194
|
+
globalKind: BOOL_OPTIONS.has(name) ? "boolean" : VALUE_OPTIONS.has(name) ? "value" : undefined
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function routeCliArgv(argv, defaultCommand) {
|
|
198
|
+
if (defaultCommand === undefined) {
|
|
199
|
+
const [command, ...commandArgv] = argv;
|
|
200
|
+
return { command, commandArgv, topLevelHelp: false, version: false };
|
|
201
|
+
}
|
|
202
|
+
const globals = [];
|
|
203
|
+
let index = 0;
|
|
204
|
+
while (index < argv.length) {
|
|
205
|
+
const token = argv[index];
|
|
206
|
+
if (token === undefined)
|
|
207
|
+
break;
|
|
208
|
+
if (token === "--") {
|
|
209
|
+
return {
|
|
210
|
+
commandArgv: [],
|
|
211
|
+
topLevelHelp: false,
|
|
212
|
+
version: false,
|
|
213
|
+
error: 'A command is required before "--"'
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
if (token === "--help" || token === "-h") {
|
|
217
|
+
return { commandArgv: [], topLevelHelp: true, version: false };
|
|
218
|
+
}
|
|
219
|
+
if (token === "--version" || token === "version") {
|
|
220
|
+
return { commandArgv: [], topLevelHelp: false, version: true };
|
|
221
|
+
}
|
|
222
|
+
if (!token.startsWith("-") || token === "-") {
|
|
223
|
+
return {
|
|
224
|
+
command: token,
|
|
225
|
+
commandArgv: [...globals, ...argv.slice(index + 1)],
|
|
226
|
+
topLevelHelp: false,
|
|
227
|
+
version: false
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (!token.startsWith("--")) {
|
|
231
|
+
return {
|
|
232
|
+
command: defaultCommand,
|
|
233
|
+
commandArgv: [...globals, ...argv.slice(index)],
|
|
234
|
+
topLevelHelp: false,
|
|
235
|
+
version: false
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
const option = classifyLongOptionToken(token);
|
|
239
|
+
if (!option) {
|
|
240
|
+
return {
|
|
241
|
+
command: defaultCommand,
|
|
242
|
+
commandArgv: [...globals, ...argv.slice(index)],
|
|
243
|
+
topLevelHelp: false,
|
|
244
|
+
version: false
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (option.globalKind === "boolean") {
|
|
248
|
+
globals.push(token);
|
|
249
|
+
index += 1;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (option.globalKind === "value") {
|
|
253
|
+
globals.push(token);
|
|
254
|
+
if (!option.inline) {
|
|
255
|
+
const value = argv[index + 1];
|
|
256
|
+
if (value === "--help" || value === "-h") {
|
|
257
|
+
return { commandArgv: [], topLevelHelp: true, version: false };
|
|
258
|
+
}
|
|
259
|
+
if (value === "--version" || value === "version") {
|
|
260
|
+
return { commandArgv: [], topLevelHelp: false, version: true };
|
|
261
|
+
}
|
|
262
|
+
if (value !== undefined)
|
|
263
|
+
globals.push(value);
|
|
264
|
+
index += value === undefined ? 1 : 2;
|
|
265
|
+
} else {
|
|
266
|
+
index += 1;
|
|
267
|
+
}
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
command: defaultCommand,
|
|
272
|
+
commandArgv: [...globals, ...argv.slice(index)],
|
|
273
|
+
topLevelHelp: false,
|
|
274
|
+
version: false
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
command: defaultCommand,
|
|
279
|
+
commandArgv: globals,
|
|
280
|
+
topLevelHelp: false,
|
|
281
|
+
version: false
|
|
282
|
+
};
|
|
283
|
+
}
|
|
185
284
|
|
|
186
285
|
class CliArgumentError extends Error {
|
|
187
286
|
name = "CliArgumentError";
|
|
@@ -383,14 +482,38 @@ function parseCliArgs(argv, schema, config = {}) {
|
|
|
383
482
|
continue;
|
|
384
483
|
}
|
|
385
484
|
if (!tok.startsWith("--")) {
|
|
386
|
-
|
|
485
|
+
const match = /^-([A-Za-z])(?:=(.*))?$/.exec(tok);
|
|
486
|
+
const alias = match?.[1];
|
|
487
|
+
const field = alias === undefined ? undefined : config.optionAliases?.get(alias);
|
|
488
|
+
if (!alias || !field)
|
|
489
|
+
throw new CliArgumentError(`Unknown option "${tok}"`);
|
|
490
|
+
const inline = match?.[2];
|
|
491
|
+
const info2 = fields.get(field);
|
|
492
|
+
if (info2?.kind === "boolean") {
|
|
493
|
+
boolFlags.set(field, inline === undefined ? true : parseReservedBool(field, inline));
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
let value2 = inline;
|
|
497
|
+
if (value2 === undefined) {
|
|
498
|
+
const next = argv[i + 1];
|
|
499
|
+
if (next !== undefined && (!next.startsWith("-") || NUMERIC_VALUE.test(next))) {
|
|
500
|
+
value2 = next;
|
|
501
|
+
i++;
|
|
502
|
+
} else {
|
|
503
|
+
throw new CliArgumentError(`--${field} requires a value`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
pushFlag(field, value2);
|
|
507
|
+
continue;
|
|
387
508
|
}
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
509
|
+
const option = classifyLongOptionToken(tok);
|
|
510
|
+
if (!option)
|
|
511
|
+
throw new CliArgumentError(`Unknown option "${tok}"`);
|
|
512
|
+
const { name } = option;
|
|
513
|
+
let { value } = option;
|
|
391
514
|
if (name.length === 0)
|
|
392
515
|
throw new CliArgumentError("Invalid empty option name");
|
|
393
|
-
if (
|
|
516
|
+
if (option.globalKind === "boolean") {
|
|
394
517
|
const enabled = value === undefined ? true : parseReservedBool(name, value);
|
|
395
518
|
if (name === "dry-run")
|
|
396
519
|
options.dryRun = enabled;
|
|
@@ -404,13 +527,13 @@ function parseCliArgs(argv, schema, config = {}) {
|
|
|
404
527
|
options.help = enabled;
|
|
405
528
|
continue;
|
|
406
529
|
}
|
|
407
|
-
if (
|
|
530
|
+
if (option.globalKind === "value") {
|
|
408
531
|
const next = argv[i + 1];
|
|
409
532
|
value = value ?? next;
|
|
410
533
|
if (value === undefined || value.startsWith("-") && !NUMERIC_VALUE.test(value)) {
|
|
411
534
|
throw new CliArgumentError(`--${name} requires a value`);
|
|
412
535
|
}
|
|
413
|
-
if (
|
|
536
|
+
if (!option.inline)
|
|
414
537
|
i++;
|
|
415
538
|
if (name === "wait-timeout") {
|
|
416
539
|
const timeout = Number(value);
|
|
@@ -452,7 +575,7 @@ function parseCliArgs(argv, schema, config = {}) {
|
|
|
452
575
|
pushFlag(name, value);
|
|
453
576
|
}
|
|
454
577
|
const toolArgs = {};
|
|
455
|
-
const fillable = [...fields.entries()].filter(([, info]) => info.kind !== "boolean").map(([name]) => name);
|
|
578
|
+
const fillable = config.positionals === undefined ? [...fields.entries()].filter(([, info]) => info.kind !== "boolean").map(([name]) => name) : [...config.positionals];
|
|
456
579
|
let pi = 0;
|
|
457
580
|
for (const key of fillable) {
|
|
458
581
|
if (pi >= positionals.length)
|
|
@@ -501,6 +624,27 @@ function parseCliArgs(argv, schema, config = {}) {
|
|
|
501
624
|
function defineCliCommand(definition) {
|
|
502
625
|
return definition;
|
|
503
626
|
}
|
|
627
|
+
function prepareCliCommandEmission(definition, result, options) {
|
|
628
|
+
if (!result.ok || definition.output === undefined) {
|
|
629
|
+
return { result, successExitCode: 0 };
|
|
630
|
+
}
|
|
631
|
+
try {
|
|
632
|
+
const successExitCode = definition.exitCode?.(result.data) ?? 0;
|
|
633
|
+
if (!Number.isSafeInteger(successExitCode) || successExitCode < 0 || successExitCode > 255) {
|
|
634
|
+
throw new Error("CLI success exit code must be an integer from 0 to 255");
|
|
635
|
+
}
|
|
636
|
+
const presentation = definition.present?.({ result: result.data, options });
|
|
637
|
+
if (presentation !== undefined && typeof presentation !== "string") {
|
|
638
|
+
throw new Error("CLI result presenter must return a string");
|
|
639
|
+
}
|
|
640
|
+
return { result, presentation, successExitCode };
|
|
641
|
+
} catch (error) {
|
|
642
|
+
return {
|
|
643
|
+
result: toolResultFromError(new Error("CLI result policy failed", { cause: error })),
|
|
644
|
+
successExitCode: 0
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
}
|
|
504
648
|
function cliCommandPresentationSchema(definition) {
|
|
505
649
|
return buildToolPresentationSchema({
|
|
506
650
|
inputSchema: definition.input,
|
|
@@ -1032,6 +1176,86 @@ async function writeDownload(root, target, data) {
|
|
|
1032
1176
|
await writeFile(target, data);
|
|
1033
1177
|
}
|
|
1034
1178
|
|
|
1179
|
+
// src/tools/cli-policy.ts
|
|
1180
|
+
var SHORT_ALIAS = /^[A-Za-z]$/;
|
|
1181
|
+
var RESERVED_SHORT_OPTIONS = new Set(["h"]);
|
|
1182
|
+
function fieldMap(descriptor) {
|
|
1183
|
+
return new Map(jsonSchemaFields(descriptor.presentationSchema).map((field) => [field.name, field]));
|
|
1184
|
+
}
|
|
1185
|
+
function resolveAliases(command, descriptor, configured) {
|
|
1186
|
+
if (!configured)
|
|
1187
|
+
return new Map;
|
|
1188
|
+
const fields = fieldMap(descriptor);
|
|
1189
|
+
const aliases = new Map;
|
|
1190
|
+
for (const [alias, target] of Object.entries(configured)) {
|
|
1191
|
+
if (!SHORT_ALIAS.test(alias)) {
|
|
1192
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "${alias}" must be one ASCII letter`);
|
|
1193
|
+
}
|
|
1194
|
+
if (RESERVED_SHORT_OPTIONS.has(alias)) {
|
|
1195
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" is reserved`);
|
|
1196
|
+
}
|
|
1197
|
+
if (isUnsafeKey(target) || !fields.has(target)) {
|
|
1198
|
+
throw new Error(`[stitchkit] CLI command "${command}" alias "-${alias}" targets unknown field "${target}"`);
|
|
1199
|
+
}
|
|
1200
|
+
const existing = aliases.get(target);
|
|
1201
|
+
if (existing !== undefined) {
|
|
1202
|
+
throw new Error(`[stitchkit] CLI command "${command}" field "${target}" has multiple aliases: -${existing}, -${alias}`);
|
|
1203
|
+
}
|
|
1204
|
+
aliases.set(target, alias);
|
|
1205
|
+
}
|
|
1206
|
+
return aliases;
|
|
1207
|
+
}
|
|
1208
|
+
function resolvePositionals(command, descriptor, configured) {
|
|
1209
|
+
if (configured === undefined)
|
|
1210
|
+
return;
|
|
1211
|
+
const fields = fieldMap(descriptor);
|
|
1212
|
+
const kinds = describeSchemaFields(descriptor.argumentSchema);
|
|
1213
|
+
const seen = new Set;
|
|
1214
|
+
let optionalSeen = false;
|
|
1215
|
+
for (const name of configured) {
|
|
1216
|
+
const field = fields.get(name);
|
|
1217
|
+
if (isUnsafeKey(name) || !field || !kinds.has(name)) {
|
|
1218
|
+
throw new Error(`[stitchkit] CLI command "${command}" positional targets unknown field "${name}"`);
|
|
1219
|
+
}
|
|
1220
|
+
if (seen.has(name)) {
|
|
1221
|
+
throw new Error(`[stitchkit] CLI command "${command}" repeats positional field "${name}"`);
|
|
1222
|
+
}
|
|
1223
|
+
if (kinds.get(name)?.kind === "boolean") {
|
|
1224
|
+
throw new Error(`[stitchkit] CLI command "${command}" boolean field "${name}" cannot be positional`);
|
|
1225
|
+
}
|
|
1226
|
+
if (optionalSeen && field.required) {
|
|
1227
|
+
throw new Error(`[stitchkit] CLI command "${command}" required positional "${name}" cannot follow an optional positional`);
|
|
1228
|
+
}
|
|
1229
|
+
if (!field.required)
|
|
1230
|
+
optionalSeen = true;
|
|
1231
|
+
seen.add(name);
|
|
1232
|
+
}
|
|
1233
|
+
return [...configured];
|
|
1234
|
+
}
|
|
1235
|
+
function applyCliPresentationPolicy(command, descriptor, config) {
|
|
1236
|
+
const base = { ...descriptor, aliases: new Map };
|
|
1237
|
+
const configuredAliases = config.optionAliases && Object.hasOwn(config.optionAliases, command) ? config.optionAliases[command] : undefined;
|
|
1238
|
+
const configuredPositionals = config.positionals && Object.hasOwn(config.positionals, command) ? config.positionals[command] : undefined;
|
|
1239
|
+
return {
|
|
1240
|
+
...base,
|
|
1241
|
+
aliases: resolveAliases(command, base, configuredAliases),
|
|
1242
|
+
positionals: resolvePositionals(command, base, configuredPositionals)
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1245
|
+
function assertCliPoliciesResolved(commands, config) {
|
|
1246
|
+
const configuredNames = new Set([
|
|
1247
|
+
...Object.keys(config.optionAliases ?? {}),
|
|
1248
|
+
...Object.keys(config.positionals ?? {})
|
|
1249
|
+
]);
|
|
1250
|
+
if (config.defaultCommand !== undefined)
|
|
1251
|
+
configuredNames.add(config.defaultCommand);
|
|
1252
|
+
for (const name of configuredNames) {
|
|
1253
|
+
if (!commands.has(name)) {
|
|
1254
|
+
throw new Error(`[stitchkit] CLI policy targets unavailable command "${name}"`);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1035
1259
|
// src/tools/surface.ts
|
|
1036
1260
|
function collectToolSurface({
|
|
1037
1261
|
surface,
|
|
@@ -1149,17 +1373,17 @@ function collectPassthrough(toolArgs, field, knownKeys) {
|
|
|
1149
1373
|
const base = passthroughBase(toolArgs[field]);
|
|
1150
1374
|
toolArgs[field] = base ? { ...base, ...bag } : bag;
|
|
1151
1375
|
}
|
|
1152
|
-
function renderTopHelp(name, version, commands) {
|
|
1376
|
+
function renderTopHelp(name, version, commands, defaultCommand) {
|
|
1153
1377
|
const lines = [
|
|
1154
1378
|
`${name} ${version}`,
|
|
1155
1379
|
"",
|
|
1156
|
-
`Usage: ${name} <command> [args] [--flags]`,
|
|
1380
|
+
`Usage: ${name} ${defaultCommand ? "[command]" : "<command>"} [args] [--flags]`,
|
|
1157
1381
|
"",
|
|
1158
1382
|
"Commands:"
|
|
1159
1383
|
];
|
|
1160
1384
|
const width = Math.max(0, ...[...commands.keys()].map((key) => key.length));
|
|
1161
1385
|
for (const [command, descriptor] of commands) {
|
|
1162
|
-
lines.push(` ${padRight(command, width)} ${summarize(descriptor.description)}`);
|
|
1386
|
+
lines.push(` ${padRight(command, width)} ${summarize(descriptor.description)}${command === defaultCommand ? " (default)" : ""}`);
|
|
1163
1387
|
}
|
|
1164
1388
|
lines.push("", "Global options:");
|
|
1165
1389
|
const optWidth = Math.max(...GLOBAL_OPTIONS.map(([flag]) => flag.length));
|
|
@@ -1174,9 +1398,8 @@ function renderCommandHelp(name, command, descriptor) {
|
|
|
1174
1398
|
const fields = jsonSchemaFields(descriptor.presentationSchema);
|
|
1175
1399
|
const fieldsByName = new Map(fields.map((field) => [field.name, field]));
|
|
1176
1400
|
const positionals = [];
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
continue;
|
|
1401
|
+
const positionalNames = descriptor.positionals ?? [...describeSchemaFields(descriptor.argumentSchema)].filter(([, info]) => info.kind !== "boolean").map(([fieldName]) => fieldName);
|
|
1402
|
+
for (const fieldName of positionalNames) {
|
|
1180
1403
|
const field = fieldsByName.get(fieldName);
|
|
1181
1404
|
if (field)
|
|
1182
1405
|
positionals.push(field);
|
|
@@ -1195,10 +1418,9 @@ function renderCommandHelp(name, command, descriptor) {
|
|
|
1195
1418
|
lines.push("Arguments:");
|
|
1196
1419
|
const labels = new Map(fields.map((field) => {
|
|
1197
1420
|
const positional = positionalSyntax.get(field.name);
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
];
|
|
1421
|
+
const alias = descriptor.aliases.get(field.name);
|
|
1422
|
+
const option = alias ? `-${alias}, --${field.name}` : `--${field.name}`;
|
|
1423
|
+
return [field.name, positional ? `${positional} | ${option}` : option];
|
|
1202
1424
|
}));
|
|
1203
1425
|
const width = Math.max(...fields.map((field) => labels.get(field.name)?.length ?? 0));
|
|
1204
1426
|
for (const f of fields) {
|
|
@@ -1227,7 +1449,7 @@ function nativeDescriptor(definition) {
|
|
|
1227
1449
|
presentationSchema: cliCommandPresentationSchema(definition)
|
|
1228
1450
|
};
|
|
1229
1451
|
}
|
|
1230
|
-
function assertCommandShape(name, descriptor, exists) {
|
|
1452
|
+
function assertCommandShape(name, descriptor, exists, passthroughField) {
|
|
1231
1453
|
assertUniqueToolName(name, exists, "CLI command");
|
|
1232
1454
|
if (name === "help" || name === "version") {
|
|
1233
1455
|
throw new Error(`[stitchkit] CLI command "${name}" is reserved`);
|
|
@@ -1236,13 +1458,18 @@ function assertCommandShape(name, descriptor, exists) {
|
|
|
1236
1458
|
if (conflicting.length > 0) {
|
|
1237
1459
|
throw new Error(`[stitchkit] CLI command "${name}" declares reserved option field(s): ${conflicting.join(", ")}`);
|
|
1238
1460
|
}
|
|
1461
|
+
if (passthroughField !== undefined && descriptor.aliases.has(passthroughField)) {
|
|
1462
|
+
throw new Error(`[stitchkit] CLI command "${name}" cannot alias passthrough field "${passthroughField}"`);
|
|
1463
|
+
}
|
|
1239
1464
|
}
|
|
1240
1465
|
async function prepareInvocation(command, commandArgv, descriptor, config, readStdin) {
|
|
1241
1466
|
let parsed;
|
|
1242
1467
|
try {
|
|
1243
1468
|
parsed = parseCliArgs(commandArgv, descriptor.argumentSchema, {
|
|
1244
1469
|
allowUnknown: config.passthrough?.[command] !== undefined,
|
|
1245
|
-
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name)
|
|
1470
|
+
knownFields: jsonSchemaFields(descriptor.presentationSchema).map((field) => field.name),
|
|
1471
|
+
optionAliases: new Map([...descriptor.aliases].map(([field, alias]) => [alias, field])),
|
|
1472
|
+
positionals: descriptor.positionals
|
|
1246
1473
|
});
|
|
1247
1474
|
} catch (error) {
|
|
1248
1475
|
if (!(error instanceof CliArgumentError))
|
|
@@ -1253,8 +1480,14 @@ async function prepareInvocation(command, commandArgv, descriptor, config, readS
|
|
|
1253
1480
|
const firstUnset = jsonSchemaFields(descriptor.presentationSchema).find((field) => field.required && !(field.name in toolArgs) && field.schema.type !== "boolean");
|
|
1254
1481
|
if (firstUnset) {
|
|
1255
1482
|
const piped = await readStdin();
|
|
1256
|
-
if (piped !== null)
|
|
1257
|
-
|
|
1483
|
+
if (piped !== null) {
|
|
1484
|
+
if (descriptor.positionals === undefined) {
|
|
1485
|
+
toolArgs[firstUnset.name] = piped;
|
|
1486
|
+
} else {
|
|
1487
|
+
const stdinArgs = parseCliArgs([`--${firstUnset.name}`, piped], descriptor.argumentSchema);
|
|
1488
|
+
toolArgs[firstUnset.name] = stdinArgs.toolArgs[firstUnset.name];
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1258
1491
|
}
|
|
1259
1492
|
const passthroughField = config.passthrough?.[command];
|
|
1260
1493
|
if (passthroughField) {
|
|
@@ -1306,13 +1539,19 @@ async function createCli(config) {
|
|
|
1306
1539
|
const nativeCommands = new Map;
|
|
1307
1540
|
const nativeHelp = new Map;
|
|
1308
1541
|
for (const definition of config.commands ?? []) {
|
|
1309
|
-
const descriptor2 = nativeDescriptor(definition);
|
|
1310
|
-
assertCommandShape(definition.name, descriptor2, nativeCommands.has(definition.name));
|
|
1542
|
+
const descriptor2 = applyCliPresentationPolicy(definition.name, nativeDescriptor(definition), config);
|
|
1543
|
+
assertCommandShape(definition.name, descriptor2, nativeCommands.has(definition.name), config.passthrough?.[definition.name]);
|
|
1311
1544
|
nativeCommands.set(definition.name, definition);
|
|
1312
1545
|
nativeHelp.set(definition.name, descriptor2);
|
|
1313
1546
|
}
|
|
1314
|
-
const
|
|
1315
|
-
if (
|
|
1547
|
+
const route = routeCliArgv(argv, config.defaultCommand);
|
|
1548
|
+
if (route.error) {
|
|
1549
|
+
stderr(`${route.error}
|
|
1550
|
+
`);
|
|
1551
|
+
return exit(2);
|
|
1552
|
+
}
|
|
1553
|
+
const { command, commandArgv } = route;
|
|
1554
|
+
if (route.version || command === "--version" || command === "version") {
|
|
1316
1555
|
stdout(`${config.name} ${config.version}
|
|
1317
1556
|
`);
|
|
1318
1557
|
return exit(0);
|
|
@@ -1360,13 +1599,20 @@ async function createCli(config) {
|
|
|
1360
1599
|
return exit(0);
|
|
1361
1600
|
}
|
|
1362
1601
|
const result2 = await executeCliCommand(native, toolArgs2, options2, { stdout, stderr }, config.coerceJsonArgs ?? true);
|
|
1363
|
-
const
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1602
|
+
const emission = prepareCliCommandEmission(native, result2, options2);
|
|
1603
|
+
let emittedExitCode;
|
|
1604
|
+
if (emission.result.ok && emission.presentation !== undefined) {
|
|
1605
|
+
stdout(emission.presentation);
|
|
1606
|
+
emittedExitCode = 0;
|
|
1607
|
+
} else {
|
|
1608
|
+
emittedExitCode = emitResult(emission.result, { stdout, stderr }, {
|
|
1609
|
+
json: options2.json,
|
|
1610
|
+
toolName: command,
|
|
1611
|
+
errorHint: config.errorHint,
|
|
1612
|
+
exitCodes: { ...DEFAULT_EXIT_CODES, ...config.exitCodes }
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
return exit(emission.result.ok ? emission.successExitCode : emittedExitCode);
|
|
1370
1616
|
}
|
|
1371
1617
|
let authPromise;
|
|
1372
1618
|
const resolveIdentity = () => {
|
|
@@ -1384,17 +1630,18 @@ async function createCli(config) {
|
|
|
1384
1630
|
surface: { services, runtimeTools },
|
|
1385
1631
|
transport: "CLI"
|
|
1386
1632
|
})) {
|
|
1387
|
-
const descriptor2 = managedDescriptor(mountable);
|
|
1388
|
-
assertCommandShape(mountable.name, descriptor2, help.has(mountable.name));
|
|
1633
|
+
const descriptor2 = applyCliPresentationPolicy(mountable.name, managedDescriptor(mountable), config);
|
|
1634
|
+
assertCommandShape(mountable.name, descriptor2, help.has(mountable.name), config.passthrough?.[mountable.name]);
|
|
1389
1635
|
tools.set(mountable.name, mountable);
|
|
1390
1636
|
help.set(mountable.name, descriptor2);
|
|
1391
1637
|
}
|
|
1638
|
+
assertCliPoliciesResolved(help, config);
|
|
1392
1639
|
return { auth, help, tools };
|
|
1393
1640
|
};
|
|
1394
|
-
const topLevelHelp = command === undefined || command === "help" || command === "--help" || command === "-h";
|
|
1641
|
+
const topLevelHelp = route.topLevelHelp || command === undefined || command === "help" || command === "--help" || command === "-h";
|
|
1395
1642
|
const managed = await buildManagedSurface(!topLevelHelp && !helpRequested);
|
|
1396
1643
|
if (topLevelHelp) {
|
|
1397
|
-
stdout(renderTopHelp(config.name, config.version, managed.help));
|
|
1644
|
+
stdout(renderTopHelp(config.name, config.version, managed.help, config.defaultCommand));
|
|
1398
1645
|
return exit(0);
|
|
1399
1646
|
}
|
|
1400
1647
|
const tool = managed.tools.get(command);
|
|
@@ -1403,7 +1650,9 @@ async function createCli(config) {
|
|
|
1403
1650
|
`);
|
|
1404
1651
|
return exit(1);
|
|
1405
1652
|
}
|
|
1406
|
-
const descriptor =
|
|
1653
|
+
const descriptor = managed.help.get(command);
|
|
1654
|
+
if (!descriptor)
|
|
1655
|
+
throw new Error("[stitchkit] managed CLI descriptor invariant failed");
|
|
1407
1656
|
if (helpRequested) {
|
|
1408
1657
|
stdout(renderCommandHelp(config.name, command, descriptor));
|
|
1409
1658
|
return exit(0);
|
package/dist/tools/cli-args.d.ts
CHANGED
|
@@ -41,6 +41,13 @@ export interface ParsedCliArgs {
|
|
|
41
41
|
/** The CLI-behaviour flags. */
|
|
42
42
|
options: CliRunOptions;
|
|
43
43
|
}
|
|
44
|
+
export interface CliArgvRoute {
|
|
45
|
+
command?: string;
|
|
46
|
+
commandArgv: string[];
|
|
47
|
+
topLevelHelp: boolean;
|
|
48
|
+
version: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
44
51
|
type FieldKind = 'boolean' | 'number' | 'bigint' | 'date' | 'string' | 'enum' | 'array' | 'object' | 'other';
|
|
45
52
|
interface FieldInfo {
|
|
46
53
|
kind: FieldKind;
|
|
@@ -48,6 +55,13 @@ interface FieldInfo {
|
|
|
48
55
|
elementKind?: FieldKind;
|
|
49
56
|
}
|
|
50
57
|
export declare const RESERVED_CLI_OPTIONS: Set<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Select a command without duplicating the framework-global option grammar.
|
|
60
|
+
* With no default configured this returns the historical first-token routing
|
|
61
|
+
* byte-for-byte. With a default, recognised leading globals may precede an
|
|
62
|
+
* explicit command; a remaining option token belongs to the default command.
|
|
63
|
+
*/
|
|
64
|
+
export declare function routeCliArgv(argv: string[], defaultCommand?: string): CliArgvRoute;
|
|
51
65
|
export declare class CliArgumentError extends Error {
|
|
52
66
|
name: string;
|
|
53
67
|
}
|
|
@@ -71,6 +85,8 @@ export declare function describeSchemaFields(schema: z.ZodType | undefined): Map
|
|
|
71
85
|
export declare function parseCliArgs(argv: string[], schema: z.ZodType | undefined, config?: {
|
|
72
86
|
allowUnknown?: boolean;
|
|
73
87
|
knownFields?: readonly string[];
|
|
88
|
+
optionAliases?: ReadonlyMap<string, string>;
|
|
89
|
+
positionals?: readonly string[];
|
|
74
90
|
}): ParsedCliArgs;
|
|
75
91
|
export {};
|
|
76
92
|
//# sourceMappingURL=cli-args.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,+BAA+B;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,KAAK,SAAS,GACV,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AAEZ,UAAU,SAAS;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,uEAAuE;IACvE,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AAOD,eAAO,MAAM,oBAAoB,aAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB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AAS,EAC7B,MAAM,GAAE;IACN,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,GACL,aAAa,CAwMf"}
|
|
@@ -14,15 +14,31 @@ export interface CliCommandDefinitionBase<TInput extends ZodObject> {
|
|
|
14
14
|
export interface CliCommandDefinitionWithOutput<TInput extends ZodObject, TOutput extends ZodType> extends CliCommandDefinitionBase<TInput> {
|
|
15
15
|
output: TOutput;
|
|
16
16
|
handler: (context: CliCommandContext<TInput>) => z.output<TOutput> | Promise<z.output<TOutput>>;
|
|
17
|
+
/** Pure post-validation stdout presentation; returned bytes are written verbatim once. */
|
|
18
|
+
present?: (context: {
|
|
19
|
+
result: z.output<TOutput>;
|
|
20
|
+
options: Readonly<CliRunOptions>;
|
|
21
|
+
}) => string;
|
|
22
|
+
/** Process exit code for a successfully validated result. */
|
|
23
|
+
exitCode?: (result: z.output<TOutput>) => number;
|
|
17
24
|
}
|
|
18
25
|
export interface CliCommandDefinitionWithoutOutput<TInput extends ZodObject> extends CliCommandDefinitionBase<TInput> {
|
|
19
26
|
output?: never;
|
|
27
|
+
present?: never;
|
|
28
|
+
exitCode?: never;
|
|
20
29
|
handler: (context: CliCommandContext<TInput>) => void | Promise<void>;
|
|
21
30
|
}
|
|
22
31
|
export type CliCommandDefinition = CliCommandDefinitionWithOutput<ZodObject, ZodType> | CliCommandDefinitionWithoutOutput<ZodObject>;
|
|
23
32
|
/** Typed identity helper for one transport-local executable command. */
|
|
24
33
|
export declare function defineCliCommand<TInput extends ZodObject, TOutput extends ZodType>(definition: CliCommandDefinitionWithOutput<TInput, TOutput>): CliCommandDefinitionWithOutput<TInput, TOutput>;
|
|
25
34
|
export declare function defineCliCommand<TInput extends ZodObject>(definition: CliCommandDefinitionWithoutOutput<TInput>): CliCommandDefinitionWithoutOutput<TInput>;
|
|
35
|
+
export interface PreparedCliCommandEmission {
|
|
36
|
+
result: ToolResult;
|
|
37
|
+
presentation?: string;
|
|
38
|
+
successExitCode: number;
|
|
39
|
+
}
|
|
40
|
+
/** Apply native-only presentation policy after canonical output validation. */
|
|
41
|
+
export declare function prepareCliCommandEmission(definition: CliCommandDefinition, result: ToolResult, options: Readonly<CliRunOptions>): PreparedCliCommandEmission;
|
|
26
42
|
export declare function cliCommandPresentationSchema(definition: CliCommandDefinition): Record<string, unknown>;
|
|
27
43
|
/** Execute a CLI-only definition without inventing a tool operation identity. */
|
|
28
44
|
export declare function executeCliCommand(definition: CliCommandDefinition, rawArgs: Record<string, unknown>, options: CliRunOptions, writers: CliWriters, coerceJson: boolean): Promise<ToolResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-command.d.ts","sourceRoot":"","sources":["../../src/tools/cli-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,WAAW,CAAC;AAGjE,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,SAAS,CAAE,SAAQ,UAAU;IAC7E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB,CAAC,MAAM,SAAS,SAAS;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,8BAA8B,CAC7C,MAAM,SAAS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,yBAAyB,CACvC,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC/B,0BAA0B,CAwB5B;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED,iFAAiF;AACjF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,UAAU,CAAC,CAmCrB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describeSchemaFields } from './cli-args';
|
|
2
|
+
export interface CliPresentationPolicyConfig {
|
|
3
|
+
/** Command selected when argv contains no explicit command. */
|
|
4
|
+
defaultCommand?: string;
|
|
5
|
+
/** Exact command-scoped short option aliases (`{ logs: { f: 'follow' } }`). */
|
|
6
|
+
optionAliases?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
7
|
+
/** Exact ordered argv-positional fields per command; an empty array disables positionals. */
|
|
8
|
+
positionals?: Readonly<Record<string, readonly string[]>>;
|
|
9
|
+
}
|
|
10
|
+
export interface CliCommandPresentation {
|
|
11
|
+
description: string;
|
|
12
|
+
argumentSchema: Parameters<typeof describeSchemaFields>[0];
|
|
13
|
+
presentationSchema: Record<string, unknown>;
|
|
14
|
+
/** Canonical field name → one short alias. */
|
|
15
|
+
aliases: ReadonlyMap<string, string>;
|
|
16
|
+
/** `undefined` retains automatic non-boolean schema order. */
|
|
17
|
+
positionals?: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export declare function applyCliPresentationPolicy(command: string, descriptor: Omit<CliCommandPresentation, 'aliases' | 'positionals'>, config: CliPresentationPolicyConfig): CliCommandPresentation;
|
|
20
|
+
/** Validate name-keyed policies only when the complete managed surface has resolved. */
|
|
21
|
+
export declare function assertCliPoliciesResolved(commands: ReadonlyMap<string, CliCommandPresentation>, config: CliPresentationPolicyConfig): void;
|
|
22
|
+
//# sourceMappingURL=cli-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-policy.d.ts","sourceRoot":"","sources":["../../src/tools/cli-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,6FAA6F;IAC7F,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,8CAA8C;IAC9C,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,8DAA8D;IAC9D,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAkFD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,aAAa,CAAC,EACnE,MAAM,EAAE,2BAA2B,GAClC,sBAAsB,CAexB;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACrD,MAAM,EAAE,2BAA2B,GAClC,IAAI,CAWN"}
|
package/dist/tools/cli.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ServiceDef, StitchLogger } from '../server/types';
|
|
2
2
|
import { type CliCommandDefinition } from './cli-command';
|
|
3
3
|
import { type ExitCodeMap } from './cli-format';
|
|
4
|
+
import { type CliPresentationPolicyConfig } from './cli-policy';
|
|
4
5
|
import { type CliWaitConfig } from './cli-wait';
|
|
5
6
|
import { type ErrorHintFn, type ToolCallHooks, type ToolLifecycle } from './execute';
|
|
6
7
|
import type { RuntimeToolDefinition } from './runtime-tool';
|
|
7
8
|
export type CliSurfaceSource<TAuth, TValue> = readonly TValue[] | ((auth: Awaited<TAuth> | undefined) => readonly TValue[]);
|
|
8
|
-
export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>> {
|
|
9
|
+
export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>> extends CliPresentationPolicyConfig {
|
|
9
10
|
/** Program name — shown in help and unknown-command messages. */
|
|
10
11
|
name: string;
|
|
11
12
|
/** Program version — printed by `--version`. */
|
package/dist/tools/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/tools/cli.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/tools/cli.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQhE,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAsB,KAAK,WAAW,EAAc,MAAM,cAAc,CAAC;AAChF,OAAO,EAIL,KAAK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S,CAC7B,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA+RnD"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { type AdaptedContractAsyncOperationConfig, type AdaptedContractAsyncOper
|
|
|
6
6
|
export { type CliConfig, type CliSurfaceSource, createCli } from './tools/cli';
|
|
7
7
|
export { type CliCommandContext, type CliCommandDefinition, type CliCommandDefinitionBase, type CliCommandDefinitionWithOutput, type CliCommandDefinitionWithoutOutput, defineCliCommand, } from './tools/cli-command';
|
|
8
8
|
export type { ExitCodeMap } from './tools/cli-format';
|
|
9
|
+
export type { CliPresentationPolicyConfig } from './tools/cli-policy';
|
|
9
10
|
export type { CliWaitConfig } from './tools/cli-wait';
|
|
10
11
|
export { coerceJsonArgs } from './tools/coerce';
|
|
11
12
|
export { type DefineDownloadToolConfig, defineDownloadTool, } from './tools/define-download-tool';
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EACL,KAAK,mCAAmC,EACxC,KAAK,sCAAsC,EAC3C,KAAK,qCAAqC,EAC1C,KAAK,oCAAoC,EACzC,KAAK,8BA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AM,mBAAmB,CAAC"}
|
package/dist/tools.js
CHANGED
package/llms-full.txt
CHANGED
|
@@ -3570,8 +3570,13 @@ Durably queued records rejected from the local queue remain recoverable through
|
|
|
3570
3570
|
|
|
3571
3571
|
Use `await runtime.interrupt({ conversationId, runId })` when the interruption
|
|
3572
3572
|
must be durable: it first commits `interrupt_requested`, then aborts the local
|
|
3573
|
-
coordinator signal.
|
|
3574
|
-
|
|
3573
|
+
coordinator signal. If provider completion races that revision change, the terminal path reloads
|
|
3574
|
+
the canonical snapshot. An already-terminal winner settles the ticket directly; a still-owned
|
|
3575
|
+
`interrupt_requested` run is committed as `interrupted`, and unrelated aggregate-head conflicts
|
|
3576
|
+
remain retriable while the run is active with the same owner and fencing token. A stale owner or
|
|
3577
|
+
fencing token remains a conflict. Only the execution that applies the terminal mutation emits the
|
|
3578
|
+
terminal event and operator metrics; a loser settles from canonical state without republishing it.
|
|
3579
|
+
`runtime.stop(key)` is the process-local signal-only escape hatch.
|
|
3575
3580
|
|
|
3576
3581
|
## Store operations
|
|
3577
3582
|
|
|
@@ -3879,6 +3884,32 @@ validation, dry-run, error envelopes and exit mapping, but deliberately have no
|
|
|
3879
3884
|
fake service/action/scope/method identity, lifecycle or tool hooks and never
|
|
3880
3885
|
appear in MCP/Agent manifests.
|
|
3881
3886
|
|
|
3887
|
+
A native command with a declared output may also own its final terminal
|
|
3888
|
+
presentation and successful process status. Both callbacks receive the exact
|
|
3889
|
+
Zod output type and run only after output validation; help, dry-run and failed
|
|
3890
|
+
validation never invoke them:
|
|
3891
|
+
|
|
3892
|
+
```ts
|
|
3893
|
+
const doctor = defineCliCommand({
|
|
3894
|
+
name: 'doctor',
|
|
3895
|
+
description: 'Inspect local health',
|
|
3896
|
+
input: z.object({}),
|
|
3897
|
+
output: z.object({ status: z.enum(['ok', 'degraded']) }),
|
|
3898
|
+
handler: () => ({ status: 'degraded' }),
|
|
3899
|
+
present: ({ result, options }) =>
|
|
3900
|
+
options.json ? `${JSON.stringify(result)}\n` : `STATUS ${result.status}\n`,
|
|
3901
|
+
exitCode: (result) => result.status === 'degraded' ? 1 : 0,
|
|
3902
|
+
})
|
|
3903
|
+
```
|
|
3904
|
+
|
|
3905
|
+
`present` returns the exact stdout bytes, which Stitchkit writes once. Without
|
|
3906
|
+
it the canonical JSON output is unchanged. `exitCode` classifies a successfully
|
|
3907
|
+
validated result and must return an integer in `0..255`; failed `ToolResult`
|
|
3908
|
+
envelopes and the application-wide `exitCodes` mapping remain authoritative for
|
|
3909
|
+
failures. A throwing callback, invalid status or non-string presenter becomes a
|
|
3910
|
+
normalized `INTERNAL_SERVER_ERROR`, never partial success output. Void native
|
|
3911
|
+
commands cannot declare either callback.
|
|
3912
|
+
|
|
3882
3913
|
`--version`, a selected native command and its command help run before
|
|
3883
3914
|
`resolveAuth`, services, context or runtime-tool factories. Top-level help is
|
|
3884
3915
|
also credential-free when managed surfaces are static. A dynamic factory must
|
|
@@ -3905,9 +3936,52 @@ string, the schema says what it should be:
|
|
|
3905
3936
|
| `z.object({...})` | `--opts '{"k":"v"}'` (JSON) or `--opts.k v` |
|
|
3906
3937
|
| `.optional()` / `.default()` | not required |
|
|
3907
3938
|
|
|
3908
|
-
|
|
3909
|
-
`myapp generate "a fox"` is
|
|
3910
|
-
|
|
3939
|
+
Without presentation configuration, positional arguments fill non-boolean
|
|
3940
|
+
fields in declaration order, so `myapp generate "a fox"` is
|
|
3941
|
+
`--prompt "a fox"`. A piped value fills the first required unset field:
|
|
3942
|
+
`echo "a fox" | myapp generate`.
|
|
3943
|
+
|
|
3944
|
+
For a stable shell grammar, declare the default command, short aliases and the
|
|
3945
|
+
exact positional fields on `createCli`:
|
|
3946
|
+
|
|
3947
|
+
```ts
|
|
3948
|
+
await createCli({
|
|
3949
|
+
name: 'myapp',
|
|
3950
|
+
version: '1.0.0',
|
|
3951
|
+
services,
|
|
3952
|
+
commands: [doctor],
|
|
3953
|
+
defaultCommand: 'logs',
|
|
3954
|
+
optionAliases: {
|
|
3955
|
+
logs: { f: 'follow', n: 'lines' },
|
|
3956
|
+
},
|
|
3957
|
+
positionals: {
|
|
3958
|
+
logs: ['target'], // `lines` is option-only
|
|
3959
|
+
doctor: [], // no argv positionals
|
|
3960
|
+
},
|
|
3961
|
+
})
|
|
3962
|
+
```
|
|
3963
|
+
|
|
3964
|
+
Now `myapp`, `myapp --json` and `myapp logs --json` select `logs`;
|
|
3965
|
+
`myapp -f -n 100 --target api` maps to
|
|
3966
|
+
`logs --follow --lines 100 --target api`. A leading non-option token remains an
|
|
3967
|
+
explicit command so typos stay loud rather than becoming ambiguous default
|
|
3968
|
+
positionals; use an explicit `myapp logs api` when passing positionals. Leading
|
|
3969
|
+
framework globals may precede that explicit command. Top-level `--help`, `-h`
|
|
3970
|
+
and `--version` never execute the default, and top-level help marks it.
|
|
3971
|
+
|
|
3972
|
+
Aliases are command-local, one ASCII letter and validated against the resolved
|
|
3973
|
+
command schema. `-f` / `-f=false` are boolean forms; values accept `-n 100` and
|
|
3974
|
+
`-n=100`. Arrays accumulate across short and long forms. `-h` is reserved,
|
|
3975
|
+
bundles such as `-fn`, attached values such as `-n100`, `--no-f` and unknown
|
|
3976
|
+
short flags are rejected. Canonical `--no-follow` remains available.
|
|
3977
|
+
|
|
3978
|
+
`positionals` replaces automatic schema-order selection only for the named
|
|
3979
|
+
command. An empty array disables argv positionals. Fields remain available as
|
|
3980
|
+
long/short options and stdin still fills the first required unset field with the
|
|
3981
|
+
same schema-aware coercion. Unknown, duplicate or boolean targets and a required
|
|
3982
|
+
positional after an optional/default positional fail when that command surface
|
|
3983
|
+
resolves. Native dispatch retains its lazy credential-free boundary; dynamic
|
|
3984
|
+
managed policies validate when their identity-dependent surface resolves.
|
|
3911
3985
|
|
|
3912
3986
|
The advertised schema is never mutated — a CLI call validates against the exact
|
|
3913
3987
|
same Zod schema an HTTP or MCP call does.
|
|
@@ -3932,10 +4006,12 @@ diagnostics remain ordinary stderr text. This keeps stdout pipeable and
|
|
|
3932
4006
|
`VALIDATION_ERROR → 1`, `UNAUTHORIZED → 2`, `FORBIDDEN → 3`, `NOT_FOUND → 4`,
|
|
3933
4007
|
…) — override per app with `exitCodes`.
|
|
3934
4008
|
|
|
3935
|
-
Per-command help derives the positional form from the same
|
|
3936
|
-
argv parser. For example, a required `action` and optional `profile` render as
|
|
4009
|
+
Per-command help derives the positional form from the same resolved policy as
|
|
4010
|
+
the argv parser. For example, a required `action` and optional `profile` render as
|
|
3937
4011
|
`Usage: myapp skill <action> [profile] [--flags]`; the argument table also shows
|
|
3938
4012
|
`<action> | --action` and `[profile] | --profile`. Boolean fields remain flags.
|
|
4013
|
+
Declared aliases render beside their canonical options, for example
|
|
4014
|
+
`-n, --lines`.
|
|
3939
4015
|
|
|
3940
4016
|
## `--wait` — background-friendly generation
|
|
3941
4017
|
|
|
@@ -8060,7 +8136,7 @@ Server-only optional application runtime. See the
|
|
|
8060
8136
|
|
|
8061
8137
|
| Export | Kind | Summary |
|
|
8062
8138
|
|--------|------|---------|
|
|
8063
|
-
| `createAgentRuntime` | function | compose durable acceptance, stream loop, checkpoints, coordination, managed tools and terminal publication |
|
|
8139
|
+
| `createAgentRuntime` | function | compose durable acceptance, stream loop, checkpoints, coordination, managed tools and winner-only terminal publication; reconciles same-owner terminal/interrupt/head CAS races before releasing the lane |
|
|
8064
8140
|
| `defineAgentProtocol` | function | declare and validate context, input metadata and canonical message parts |
|
|
8065
8141
|
| `AgentMessageSchema` / `AgentRunSchema` / `AgentSnapshotSchema` | schema | versioned canonical engine records |
|
|
8066
8142
|
| `AgentRuntimeStore` | _type_ | aggregate CAS transaction boundary for message, run and compaction mutations |
|
|
@@ -8265,7 +8341,7 @@ payload.
|
|
|
8265
8341
|
| `createRuntimeToolFactory` | function | bind shared identity and Zod-validated per-call context for runtime tools — [guide](../guide/mcp-and-agents.md#pathless-runtime-tools-and-multimodal-results) |
|
|
8266
8342
|
| `createToolInvoker` | function | compile an exposure-aware in-process dispatcher over the canonical tool runner — [guide](../guide/mcp-and-agents.md#in-process-calls--createtoolinvoker) |
|
|
8267
8343
|
| `createCli` | function | a command-line program from contracts — [guide](../guide/cli.md) (also on `stitchkit/cli`) |
|
|
8268
|
-
| `defineCliCommand` | function | define one typed CLI-only command with
|
|
8344
|
+
| `defineCliCommand` | function | define one typed CLI-only command with optional post-validation `present` and successful `exitCode` policy — [guide](../guide/cli.md#native-binary-commands) (also on `stitchkit/cli`) |
|
|
8269
8345
|
| `createToolkit` | function | context-typed tool mounts — [guide](../guide/cli.md#typed-context) |
|
|
8270
8346
|
| `mountViewFile` | function | a native multimodal "view file" MCP tool |
|
|
8271
8347
|
| `resolveMedia` | function | resolve a media reference for a tool result |
|
|
@@ -8322,11 +8398,12 @@ payload.
|
|
|
8322
8398
|
| `RuntimeToolTransport` | _type_ | runtime exposure: `'MCP' \| 'AGENT' \| 'CLI'`; omission still means MCP+Agent only |
|
|
8323
8399
|
| `AgentMountConfig` | _type_ | config for `mountAgent` |
|
|
8324
8400
|
| `AgentContext` | _type_ | the context merged into agent tool handlers |
|
|
8325
|
-
| `CliConfig` | _type_ | config for `createCli` |
|
|
8401
|
+
| `CliConfig` | _type_ | config for `createCli`, including program-level `defaultCommand` selection and command-scoped `optionAliases` / `positionals` policy |
|
|
8402
|
+
| `CliPresentationPolicyConfig` | _type_ | reusable default-command, short-alias and explicit-positional policy inherited by `CliConfig` |
|
|
8326
8403
|
| `CliSurfaceSource` | _type_ | static managed surface or identity-dependent surface factory for `createCli` |
|
|
8327
8404
|
| `CliCommandDefinition` | _type_ | Zod-first CLI-only command union |
|
|
8328
8405
|
| `CliCommandDefinitionBase` | _type_ | native command name, description and input schema |
|
|
8329
|
-
| `CliCommandDefinitionWithOutput` | _type_ | native command with declared output schema
|
|
8406
|
+
| `CliCommandDefinitionWithOutput` | _type_ | native command with declared output schema, validated handler result and typed optional `present` / `exitCode` callbacks |
|
|
8330
8407
|
| `CliCommandDefinitionWithoutOutput` | _type_ | void native command with no output schema |
|
|
8331
8408
|
| `CliCommandContext` | _type_ | parsed native command input, global options and injected writers |
|
|
8332
8409
|
| `CliWaitConfig` | _type_ | `--wait` polling config |
|
|
@@ -8590,16 +8667,17 @@ SDK nor the `ai` peer.
|
|
|
8590
8667
|
| Export | Kind | Summary |
|
|
8591
8668
|
|--------|------|---------|
|
|
8592
8669
|
| `createCli` | function | build and run a CLI from contracts — [guide](../guide/cli.md) |
|
|
8593
|
-
| `defineCliCommand` | function | define one Zod-typed CLI-only executable command |
|
|
8670
|
+
| `defineCliCommand` | function | define one Zod-typed CLI-only executable command with optional validated-result presentation/exit policy |
|
|
8594
8671
|
| `parseCliArgs` | function | argv → typed tool args against a schema (advanced) |
|
|
8595
8672
|
| `pollUntilDone` | function | the generic `--wait` poller (advanced) |
|
|
8596
8673
|
| `emitResult` | function | write a pretty or compact `ToolResult` record to stdout/stderr + exit code (advanced) |
|
|
8597
8674
|
| `DEFAULT_EXIT_CODES` | const | the default `ToolResult.code` → exit-code map |
|
|
8598
|
-
| `CliConfig` | _type_ | config for `createCli` |
|
|
8675
|
+
| `CliConfig` | _type_ | config for `createCli`; `defaultCommand`, `optionAliases` and `positionals` define the shared command presentation policy |
|
|
8676
|
+
| `CliPresentationPolicyConfig` | _type_ | shared command presentation-policy subset of `CliConfig` |
|
|
8599
8677
|
| `CliSurfaceSource` | _type_ | static service/runtime array or identity-dependent factory |
|
|
8600
8678
|
| `CliCommandDefinition` | _type_ | native command definition union |
|
|
8601
8679
|
| `CliCommandDefinitionBase` | _type_ | native command name, description and input schema |
|
|
8602
|
-
| `CliCommandDefinitionWithOutput` | _type_ | native command with validated declared output |
|
|
8680
|
+
| `CliCommandDefinitionWithOutput` | _type_ | native command with validated declared output and typed optional `present` / successful `exitCode` callbacks |
|
|
8603
8681
|
| `CliCommandDefinitionWithoutOutput` | _type_ | native void command without an output contract |
|
|
8604
8682
|
| `CliCommandContext` | _type_ | parsed input, global options and stdout/stderr writers |
|
|
8605
8683
|
| `CliRunOptions` | _type_ | parsed global flags (`--json` compacts success/error records, `--wait`, …) |
|
package/package.json
CHANGED