@sentry/junior 0.203.0 → 0.204.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/agent-CMyTD4DD.js +17509 -0
- package/dist/agent-hooks-Bbcp9e33.js +4040 -0
- package/dist/agent-runner-DNb1A49M.js +678 -0
- package/dist/api/schema.d.ts +2728 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-B1TOqBI8.d.ts +246 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9522 -11875
- package/dist/auth-pause-state-DosEalIG.js +168 -0
- package/dist/catalog-runtime-BReos-D4.js +7 -0
- package/dist/checkpoint-CNrPyRJN.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-nGCW1OTG.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-B4voFRSm.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-kXr1hvO1.js +2660 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-DWfSihcH.js +373 -0
- package/dist/executor-DcMSlI5c.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-Drn_LXlM.js +63 -0
- package/dist/logging-BzAk1S_s.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-JiftokvA.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CWmSdZVg.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-CrT5nXbw.js +861 -0
- package/dist/registry-DH1xUo2N.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-CZHnfxaS.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-CZV2sC46.js +392 -0
- package/dist/sandbox-egress-signals-bHZfmhbd.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-CIcDQSgM.js +316 -0
- package/dist/spawn-DdkUFRmq.js +29 -0
- package/dist/stats-DTUbAb88.js +2634 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CJIR4RF7.js +136 -0
- package/dist/task-runner-D-O3A-Cp.js +639 -0
- package/dist/thread-state-CRc9jTJS.js +431 -0
- package/dist/turn-execution-BkinIdJF.js +47 -0
- package/dist/turn-lifecycle-DQV19VTW.js +54 -0
- package/dist/usage-D3EbSO7w.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-C2CR-OX3.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-DxcWdoKa.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-RMBxAR_t.js +76 -0
- package/dist/web-input-3EPfpf55.js +494 -0
- package/dist/work-fGofI7Op.js +509 -0
- package/dist/worker-CsOLq-mR.js +625 -0
- package/package.json +8 -8
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
package/dist/chunk-4KSSKTQ5.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
coerceThreadConversationState,
|
|
3
|
-
getPersistedThreadState,
|
|
4
|
-
persistThreadStateById
|
|
5
|
-
} from "./chunk-ASTEMBKJ.js";
|
|
6
|
-
import {
|
|
7
|
-
clearPendingAuth,
|
|
8
|
-
markTurnClosed,
|
|
9
|
-
markTurnCompleted
|
|
10
|
-
} from "./chunk-5PDAG6O3.js";
|
|
11
|
-
import {
|
|
12
|
-
hydrateConversationMessages,
|
|
13
|
-
markConversationMessage
|
|
14
|
-
} from "./chunk-F4MGCZOX.js";
|
|
15
|
-
import {
|
|
16
|
-
buildDeterministicTurnId
|
|
17
|
-
} from "./chunk-DA2KGZZI.js";
|
|
18
|
-
import {
|
|
19
|
-
ProviderError,
|
|
20
|
-
findProviderError,
|
|
21
|
-
getProviderErrorAttributes,
|
|
22
|
-
getProviderErrorUserMessage
|
|
23
|
-
} from "./chunk-ENY6SKIU.js";
|
|
24
|
-
import {
|
|
25
|
-
parseSlackMessageTs
|
|
26
|
-
} from "./chunk-N7TMSOZH.js";
|
|
27
|
-
import {
|
|
28
|
-
buildTurnFailureResponse
|
|
29
|
-
} from "./chunk-WS7NAFTM.js";
|
|
30
|
-
|
|
31
|
-
// src/chat/runtime/delivered-turn-state.ts
|
|
32
|
-
function buildDeliveredTurnStatePatch(args) {
|
|
33
|
-
const conversation = structuredClone(args.conversation);
|
|
34
|
-
clearPendingAuth(conversation, args.sessionId);
|
|
35
|
-
markConversationMessage(conversation, args.userMessageId, {
|
|
36
|
-
replied: true,
|
|
37
|
-
skippedReason: void 0
|
|
38
|
-
});
|
|
39
|
-
markTurnCompleted({
|
|
40
|
-
conversation,
|
|
41
|
-
nowMs: Date.now(),
|
|
42
|
-
sessionId: args.sessionId
|
|
43
|
-
});
|
|
44
|
-
return {
|
|
45
|
-
conversation,
|
|
46
|
-
sandboxRef: args.reply.sandboxRef
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/chat/interruption-marker.ts
|
|
51
|
-
var INTERRUPTED_MARKER = "\n\n[Response interrupted before completion]";
|
|
52
|
-
function getInterruptionMarker() {
|
|
53
|
-
return INTERRUPTED_MARKER;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/chat/services/turn-failure-response.ts
|
|
57
|
-
function requireTurnFailureEventId(eventId, eventName) {
|
|
58
|
-
if (!eventId) {
|
|
59
|
-
throw new Error(`Sentry did not return an event ID for ${eventName}`);
|
|
60
|
-
}
|
|
61
|
-
return eventId;
|
|
62
|
-
}
|
|
63
|
-
function getExecutionFailureReason(reply) {
|
|
64
|
-
const errorMessage = reply.diagnostics.errorMessage?.trim();
|
|
65
|
-
if (errorMessage) {
|
|
66
|
-
return errorMessage;
|
|
67
|
-
}
|
|
68
|
-
if (reply.diagnostics.toolErrorCount > 0) {
|
|
69
|
-
return `${reply.diagnostics.toolErrorCount} tool result error(s)`;
|
|
70
|
-
}
|
|
71
|
-
if (reply.diagnostics.assistantMessageCount > 0) {
|
|
72
|
-
return "assistant returned no text";
|
|
73
|
-
}
|
|
74
|
-
return "empty assistant turn";
|
|
75
|
-
}
|
|
76
|
-
function getTurnFailureReason(reply) {
|
|
77
|
-
if (reply.diagnostics.outcome === "success") {
|
|
78
|
-
return void 0;
|
|
79
|
-
}
|
|
80
|
-
if (reply.diagnostics.outcome === "provider_error") {
|
|
81
|
-
return findProviderError(reply.diagnostics.providerError)?.kind ?? "unknown";
|
|
82
|
-
}
|
|
83
|
-
if (reply.diagnostics.toolErrorCount > 0) {
|
|
84
|
-
return "tool_errors";
|
|
85
|
-
}
|
|
86
|
-
if (reply.diagnostics.usedPrimaryText && reply.diagnostics.assistantMessageCount > 0) {
|
|
87
|
-
return "suppressed_output";
|
|
88
|
-
}
|
|
89
|
-
return "empty_output";
|
|
90
|
-
}
|
|
91
|
-
function getFailureCapture(reply) {
|
|
92
|
-
if (reply.diagnostics.outcome === "provider_error") {
|
|
93
|
-
const providerError = findProviderError(reply.diagnostics.providerError);
|
|
94
|
-
return {
|
|
95
|
-
eventName: "agent.turn.provider_error",
|
|
96
|
-
error: reply.diagnostics.providerError ?? new Error(
|
|
97
|
-
reply.diagnostics.errorMessage ?? "Provider error without explicit message"
|
|
98
|
-
),
|
|
99
|
-
attributes: providerError ? getProviderErrorAttributes(providerError) : {},
|
|
100
|
-
body: "Agent turn failed with provider error"
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const failureReason = getExecutionFailureReason(reply);
|
|
104
|
-
return {
|
|
105
|
-
eventName: "agent.turn.execution.failed",
|
|
106
|
-
error: new Error(`Agent turn execution failure: ${failureReason}`),
|
|
107
|
-
attributes: {
|
|
108
|
-
"app.ai.execution_failure_reason": failureReason
|
|
109
|
-
},
|
|
110
|
-
body: "Agent turn completed with execution failure"
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function getAgentTurnDiagnosticsAttributes(reply) {
|
|
114
|
-
return {
|
|
115
|
-
"app.ai.outcome": reply.diagnostics.outcome,
|
|
116
|
-
"app.ai.assistant_messages": reply.diagnostics.assistantMessageCount,
|
|
117
|
-
"app.ai.tool_results": reply.diagnostics.toolResultCount,
|
|
118
|
-
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
119
|
-
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
120
|
-
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
121
|
-
...reply.diagnostics.reasoningLevel ? {
|
|
122
|
-
"gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel
|
|
123
|
-
} : void 0,
|
|
124
|
-
...reply.diagnostics.stopReason ? {
|
|
125
|
-
"gen_ai.response.finish_reasons": [reply.diagnostics.stopReason]
|
|
126
|
-
} : void 0,
|
|
127
|
-
...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : void 0
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function finalizeFailedTurnReplyWithEvent(args) {
|
|
131
|
-
if (args.reply.diagnostics.outcome === "success") {
|
|
132
|
-
return { reply: args.reply };
|
|
133
|
-
}
|
|
134
|
-
const failureReason = getTurnFailureReason(args.reply);
|
|
135
|
-
const capture = getFailureCapture(args.reply);
|
|
136
|
-
const eventId = requireTurnFailureEventId(
|
|
137
|
-
args.logException(capture.error, capture.eventName, {
|
|
138
|
-
...getAgentTurnDiagnosticsAttributes(args.reply),
|
|
139
|
-
...args.attributes,
|
|
140
|
-
...capture.attributes,
|
|
141
|
-
...failureReason ? { "app.ai.failure_reason": failureReason } : void 0
|
|
142
|
-
}),
|
|
143
|
-
capture.eventName
|
|
144
|
-
);
|
|
145
|
-
const providerPartialText = args.reply.diagnostics.outcome === "provider_error" && args.reply.diagnostics.assistantMessageCount > 0 ? args.reply.text.trim() : "";
|
|
146
|
-
const providerUserMessage = args.reply.diagnostics.providerError instanceof ProviderError ? getProviderErrorUserMessage(args.reply.diagnostics.providerError) : "";
|
|
147
|
-
const failureText = providerUserMessage ? `${providerUserMessage} Reference: \`event_id=${eventId}\`.` : buildTurnFailureResponse(eventId);
|
|
148
|
-
return {
|
|
149
|
-
eventId,
|
|
150
|
-
...failureReason ? { failureReason } : void 0,
|
|
151
|
-
reply: {
|
|
152
|
-
...args.reply,
|
|
153
|
-
text: providerPartialText ? `${providerPartialText}${getInterruptionMarker()}` : failureText
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/chat/runtime/turn-user-message.ts
|
|
159
|
-
function getTurnUserMessage(conversation, sessionId) {
|
|
160
|
-
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
|
|
161
|
-
const message = conversation.messages[index];
|
|
162
|
-
if (message?.role !== "user") {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
if (buildDeterministicTurnId(message.id) === sessionId) {
|
|
166
|
-
return message;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return void 0;
|
|
170
|
-
}
|
|
171
|
-
function getTurnUserMessageId(conversation, sessionId) {
|
|
172
|
-
return getTurnUserMessage(conversation, sessionId)?.id;
|
|
173
|
-
}
|
|
174
|
-
function getTurnUserSlackMessageTs(message) {
|
|
175
|
-
return parseSlackMessageTs(message?.meta?.slackTs);
|
|
176
|
-
}
|
|
177
|
-
function getTurnUserReplyAttachmentContext(message) {
|
|
178
|
-
const inboundAttachmentCount = message?.meta?.attachmentCount ?? 0;
|
|
179
|
-
const imageAttachmentCount = message?.meta?.imageAttachmentCount ?? 0;
|
|
180
|
-
const imagesHydrated = message?.meta?.imagesHydrated === true;
|
|
181
|
-
return {
|
|
182
|
-
...inboundAttachmentCount > 0 ? { inboundAttachmentCount } : void 0,
|
|
183
|
-
...!imagesHydrated && imageAttachmentCount > 0 ? { omittedImageAttachmentCount: imageAttachmentCount } : void 0
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// src/chat/runtime/auth-pause-state.ts
|
|
188
|
-
function completeAuthPauseTurn(args) {
|
|
189
|
-
markConversationMessage(
|
|
190
|
-
args.conversation,
|
|
191
|
-
getTurnUserMessageId(args.conversation, args.sessionId),
|
|
192
|
-
{
|
|
193
|
-
replied: true,
|
|
194
|
-
skippedReason: void 0
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
markTurnClosed({
|
|
198
|
-
conversation: args.conversation,
|
|
199
|
-
nowMs: Date.now(),
|
|
200
|
-
sessionId: args.sessionId
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
async function persistAuthPauseTurnState(args) {
|
|
204
|
-
const currentState = await getPersistedThreadState(args.threadStateId);
|
|
205
|
-
const conversation = coerceThreadConversationState(currentState);
|
|
206
|
-
await hydrateConversationMessages({
|
|
207
|
-
conversation,
|
|
208
|
-
conversationId: args.threadStateId
|
|
209
|
-
});
|
|
210
|
-
completeAuthPauseTurn({
|
|
211
|
-
conversation,
|
|
212
|
-
sessionId: args.sessionId
|
|
213
|
-
});
|
|
214
|
-
await persistThreadStateById(args.threadStateId, { conversation });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export {
|
|
218
|
-
buildDeliveredTurnStatePatch,
|
|
219
|
-
getTurnUserMessage,
|
|
220
|
-
getTurnUserMessageId,
|
|
221
|
-
getTurnUserSlackMessageTs,
|
|
222
|
-
getTurnUserReplyAttachmentContext,
|
|
223
|
-
getInterruptionMarker,
|
|
224
|
-
requireTurnFailureEventId,
|
|
225
|
-
getAgentTurnDiagnosticsAttributes,
|
|
226
|
-
finalizeFailedTurnReplyWithEvent,
|
|
227
|
-
completeAuthPauseTurn,
|
|
228
|
-
persistAuthPauseTurnState
|
|
229
|
-
};
|
package/dist/chunk-4UO6FK4G.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// src/cli/run.ts
|
|
2
|
-
var CLI_USAGE = "usage: junior init <dir>\n junior snapshot create\n junior check [dir]\n junior upgrade\n junior chat\n junior chat -p <message>";
|
|
3
|
-
var DEFAULT_IO = {
|
|
4
|
-
error: console.error
|
|
5
|
-
};
|
|
6
|
-
function normalizeCliArgv(argv) {
|
|
7
|
-
return argv[0] === "--" ? argv.slice(1) : argv;
|
|
8
|
-
}
|
|
9
|
-
async function runCli(argv, handlers, io = DEFAULT_IO) {
|
|
10
|
-
const [command, subcommand, ...rest] = normalizeCliArgv(argv);
|
|
11
|
-
if (command === "chat") {
|
|
12
|
-
return await handlers.runChat(
|
|
13
|
-
subcommand === void 0 ? [] : [subcommand, ...rest]
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
if (command === "init") {
|
|
17
|
-
if (!subcommand || rest.length > 0) {
|
|
18
|
-
io.error(CLI_USAGE);
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
await handlers.runInit(subcommand);
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
if (command === "snapshot" && subcommand === "create") {
|
|
25
|
-
if (rest.length > 0) {
|
|
26
|
-
io.error(CLI_USAGE);
|
|
27
|
-
return 1;
|
|
28
|
-
}
|
|
29
|
-
await handlers.runSnapshotCreate();
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
if (command === "check") {
|
|
33
|
-
if (rest.length > 0) {
|
|
34
|
-
io.error(CLI_USAGE);
|
|
35
|
-
return 1;
|
|
36
|
-
}
|
|
37
|
-
await handlers.runCheck(subcommand);
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
if (command === "upgrade") {
|
|
41
|
-
if (subcommand || rest.length > 0) {
|
|
42
|
-
io.error(CLI_USAGE);
|
|
43
|
-
return 1;
|
|
44
|
-
}
|
|
45
|
-
await handlers.runUpgrade();
|
|
46
|
-
return 0;
|
|
47
|
-
}
|
|
48
|
-
if (command && handlers.runPluginCommand) {
|
|
49
|
-
const exitCode = await handlers.runPluginCommand(
|
|
50
|
-
command,
|
|
51
|
-
subcommand === void 0 ? [] : [subcommand, ...rest]
|
|
52
|
-
);
|
|
53
|
-
if (exitCode !== void 0) {
|
|
54
|
-
return exitCode;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
io.error(CLI_USAGE);
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
CLI_USAGE,
|
|
63
|
-
runCli
|
|
64
|
-
};
|