@sentry/junior 0.203.0 → 0.205.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-D4nu8MQV.js +17521 -0
- package/dist/agent-hooks-DXHpTJ4m.js +4042 -0
- package/dist/agent-runner-C04colea.js +678 -0
- package/dist/api/schema.d.ts +2736 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-Cb776lL8.d.ts +247 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9524 -11875
- package/dist/auth-pause-state-C2P3guS1.js +168 -0
- package/dist/catalog-runtime-CXw3asJD.js +7 -0
- package/dist/checkpoint-CrViJ8Ps.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-BOtJQ7Pc.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-BZRA6Pes.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-Bep34IB_.js +2661 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-B6lgWxCK.js +373 -0
- package/dist/executor-BlUhFL7_.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-DLMqIK74.js +63 -0
- package/dist/logging-BMJzdDlP.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-WwG5_Zgm.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CUbXq06G.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-T0tXE4zu.js +861 -0
- package/dist/registry-BA0__8ai.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-bvD1ORdv.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-BXYxfIUL.js +392 -0
- package/dist/sandbox-egress-signals-ngEPjSEW.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-DJOlYdBs.js +316 -0
- package/dist/spawn-h0R1bTEo.js +29 -0
- package/dist/stats-3YZn-Swi.js +2648 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CoXwd2eq.js +136 -0
- package/dist/task-runner-B2_mJZj0.js +639 -0
- package/dist/thread-state-CqZ1m-es.js +431 -0
- package/dist/turn-execution-fI6PZ0iI.js +47 -0
- package/dist/turn-lifecycle-CcnwrOcp.js +54 -0
- package/dist/usage-B5SfMb3H.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-DfWcvhuS.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-oD-oPrbO.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-Crbzlmzo.js +76 -0
- package/dist/web-input-BOuq3oKK.js +494 -0
- package/dist/work-B91LQKHr.js +509 -0
- package/dist/worker-BcRRTe6k.js +625 -0
- package/package.json +9 -9
- 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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { n as JuniorPluginSet } from "../plugins-BI9A1vKA.js";
|
|
2
|
+
//#region src/cli/chat.d.ts
|
|
3
|
+
export declare const CHAT_USAGE = "usage: junior chat\n junior chat -p <message>";
|
|
4
|
+
export type ChatCommandOptions = {
|
|
5
|
+
mode: "interactive";
|
|
6
|
+
} | {
|
|
7
|
+
message: string;
|
|
8
|
+
mode: "prompt";
|
|
9
|
+
};
|
|
10
|
+
export interface ChatIo {
|
|
11
|
+
error: (line: string) => Promise<void> | void;
|
|
12
|
+
input: NodeJS.ReadableStream;
|
|
13
|
+
output: NodeJS.WritableStream;
|
|
14
|
+
write: (text: string) => Promise<void> | void;
|
|
15
|
+
}
|
|
16
|
+
/** Run the local Junior chat command. */
|
|
17
|
+
export declare function runChat(argv: string[], io?: ChatIo, deps?: {
|
|
18
|
+
pluginSet?: JuniorPluginSet | null;
|
|
19
|
+
}): Promise<number>;
|
|
20
|
+
//#endregion
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,380 +1,273 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "../
|
|
4
|
-
import "
|
|
5
|
-
import "
|
|
6
|
-
import "
|
|
7
|
-
import "../chunk-PSJCGIGO.js";
|
|
8
|
-
import {
|
|
9
|
-
createAgentRunner
|
|
10
|
-
} from "../chunk-UE4GPWSD.js";
|
|
11
|
-
import "../chunk-5PDAG6O3.js";
|
|
12
|
-
import "../chunk-F4MGCZOX.js";
|
|
13
|
-
import "../chunk-2LYHWMR4.js";
|
|
14
|
-
import "../chunk-WLYVJCHV.js";
|
|
15
|
-
import "../chunk-XPDEYNQI.js";
|
|
16
|
-
import "../chunk-KIIEUXD3.js";
|
|
17
|
-
import "../chunk-DA2KGZZI.js";
|
|
18
|
-
import "../chunk-GMCB6W5Y.js";
|
|
19
|
-
import "../chunk-VZ7CSOX2.js";
|
|
20
|
-
import "../chunk-PDO5BLNM.js";
|
|
21
|
-
import "../chunk-UIE3R5XU.js";
|
|
22
|
-
import "../chunk-X6GDDWQH.js";
|
|
23
|
-
import "../chunk-NCEBK6PH.js";
|
|
24
|
-
import "../chunk-DKIJ2RP5.js";
|
|
25
|
-
import "../chunk-JAL3CH4G.js";
|
|
26
|
-
import "../chunk-7H2VZTWN.js";
|
|
27
|
-
import {
|
|
28
|
-
loadAppPluginSet
|
|
29
|
-
} from "../chunk-Y2CM7HXH.js";
|
|
30
|
-
import "../chunk-IZ5B5IHQ.js";
|
|
31
|
-
import "../chunk-3Y47VMHV.js";
|
|
32
|
-
import "../chunk-GKEOHJL5.js";
|
|
33
|
-
import "../chunk-IE2VPG7O.js";
|
|
34
|
-
import "../chunk-5AHX53NQ.js";
|
|
35
|
-
import "../chunk-P6KTRNVC.js";
|
|
36
|
-
import "../chunk-7NL7T6VU.js";
|
|
37
|
-
import "../chunk-VFUK3X5B.js";
|
|
38
|
-
import "../chunk-ENY6SKIU.js";
|
|
39
|
-
import "../chunk-NHJU2ZAL.js";
|
|
40
|
-
import "../chunk-PKEX2AQX.js";
|
|
41
|
-
import "../chunk-A5L27LE4.js";
|
|
42
|
-
import "../chunk-WCNQJKFT.js";
|
|
43
|
-
import "../chunk-7GWQ5S5R.js";
|
|
44
|
-
import "../chunk-CEMMLV5L.js";
|
|
45
|
-
import "../chunk-N7TMSOZH.js";
|
|
46
|
-
import "../chunk-DWPN6SCH.js";
|
|
47
|
-
import "../chunk-TXKUKMVO.js";
|
|
48
|
-
import "../chunk-WS7NAFTM.js";
|
|
49
|
-
import "../chunk-PEQXYSSE.js";
|
|
50
|
-
import "../chunk-WDZR3QQM.js";
|
|
51
|
-
|
|
52
|
-
// src/cli/chat.ts
|
|
53
|
-
import {
|
|
54
|
-
stdin as defaultStdin,
|
|
55
|
-
stderr as defaultStderr,
|
|
56
|
-
stdout as defaultStdout
|
|
57
|
-
} from "process";
|
|
58
|
-
import { randomUUID } from "crypto";
|
|
59
|
-
import * as readline from "readline/promises";
|
|
1
|
+
import { t as executeAgentRun } from "../agent-D4nu8MQV.js";
|
|
2
|
+
import { t as createAgentRunner } from "../agent-runner-C04colea.js";
|
|
3
|
+
import { t as loadAppPluginSet } from "../plugin-module-BKGOXca2.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6
|
+
import { stderr, stdin, stdout } from "node:process";
|
|
60
7
|
import { createJiti } from "jiti";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
import path from "path";
|
|
65
|
-
var LOCAL_CONVERSATION_ALIAS_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
8
|
+
import * as readline from "node:readline/promises";
|
|
9
|
+
//#region src/chat/local/conversation.ts
|
|
10
|
+
const LOCAL_CONVERSATION_ALIAS_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
66
11
|
function slugifyConversationAlias(alias) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return trimmed.toLowerCase().replaceAll(".", "-");
|
|
12
|
+
const trimmed = alias.trim();
|
|
13
|
+
if (!LOCAL_CONVERSATION_ALIAS_PATTERN.test(trimmed)) return;
|
|
14
|
+
return trimmed.toLowerCase().replaceAll(".", "-");
|
|
72
15
|
}
|
|
16
|
+
/** Hash the resolved cwd into the stable workspace segment of local conversation ids. */
|
|
73
17
|
function workspaceKey(cwd) {
|
|
74
|
-
|
|
18
|
+
return createHash("sha256").update(path.resolve(cwd)).digest("hex").slice(0, 12);
|
|
75
19
|
}
|
|
20
|
+
/** Normalize a local CLI conversation alias into the durable conversation id. */
|
|
76
21
|
function normalizeLocalConversationId(input) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
return `local:${workspaceKey(input.cwd ?? process.cwd())}:${slug}`;
|
|
22
|
+
const slug = slugifyConversationAlias(input.alias);
|
|
23
|
+
if (!slug) return;
|
|
24
|
+
return `local:${workspaceKey(input.cwd ?? process.cwd())}:${slug}`;
|
|
82
25
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/cli/chat.ts
|
|
28
|
+
/**
|
|
29
|
+
* Local chat CLI command.
|
|
30
|
+
*
|
|
31
|
+
* This module owns terminal argument parsing and output delivery for `junior
|
|
32
|
+
* chat`; the agent runtime stays behind the local runner, and invalid CLI input
|
|
33
|
+
* must fail before conversation state is created.
|
|
34
|
+
*/
|
|
35
|
+
const CHAT_USAGE = "usage: junior chat\n junior chat -p <message>";
|
|
36
|
+
const DEFAULT_IO = {
|
|
37
|
+
error: (line) => writeStream(stderr, `${line}\n`),
|
|
38
|
+
input: stdin,
|
|
39
|
+
output: stdout,
|
|
40
|
+
write: (text) => writeStream(stdout, text)
|
|
92
41
|
};
|
|
93
|
-
|
|
42
|
+
const localPluginLoader = createJiti(import.meta.url, { moduleCache: false });
|
|
94
43
|
var ChatOutputError = class extends Error {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
44
|
+
constructor(error) {
|
|
45
|
+
super(errorMessage(error));
|
|
46
|
+
this.name = "ChatOutputError";
|
|
47
|
+
}
|
|
99
48
|
};
|
|
100
49
|
function errorMessage(error) {
|
|
101
|
-
|
|
50
|
+
return error instanceof Error ? error.message : String(error);
|
|
102
51
|
}
|
|
52
|
+
/** Deliver text-only local replies. */
|
|
103
53
|
async function deliverReply(io, reply) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
54
|
+
try {
|
|
55
|
+
await io.write(formatReply(reply));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
throw new ChatOutputError(error);
|
|
58
|
+
}
|
|
109
59
|
}
|
|
110
60
|
async function reportStatus(io, status) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
61
|
+
try {
|
|
62
|
+
await io.error(status);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw new ChatOutputError(error);
|
|
65
|
+
}
|
|
116
66
|
}
|
|
117
67
|
function formatToolPayload(payload) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (rendered.length <= 500) {
|
|
123
|
-
return ` ${rendered}`;
|
|
124
|
-
}
|
|
125
|
-
return ` ${rendered.slice(0, 497)}...`;
|
|
68
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload) && Object.keys(payload).length === 0) return "";
|
|
69
|
+
const rendered = JSON.stringify(payload);
|
|
70
|
+
if (rendered.length <= 500) return ` ${rendered}`;
|
|
71
|
+
return ` ${rendered.slice(0, 497)}...`;
|
|
126
72
|
}
|
|
127
73
|
async function reportToolResult(io, result) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
await reportStatus(
|
|
136
|
-
io,
|
|
137
|
-
`tool: ${result.toolName} ok${formatToolPayload(result.result ?? {})}`
|
|
138
|
-
);
|
|
74
|
+
if (!result.ok) {
|
|
75
|
+
await reportStatus(io, `tool: ${result.toolName} error ${result.error ?? "Tool execution failed"}`);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await reportStatus(io, `tool: ${result.toolName} ok${formatToolPayload(result.result ?? {})}`);
|
|
139
79
|
}
|
|
140
80
|
function writeStream(stream, text) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
stream.write(text, (error) => {
|
|
83
|
+
if (error) {
|
|
84
|
+
reject(error);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
resolve();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
150
90
|
}
|
|
91
|
+
/** Keep local chat ephemeral by default; Redis is opt-in via an explicit adapter. */
|
|
151
92
|
function defaultStateAdapterForLocalChat() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
process.env.JUNIOR_STATE_ADAPTER = "memory";
|
|
93
|
+
if (process.env.JUNIOR_STATE_ADAPTER) return;
|
|
94
|
+
process.env.JUNIOR_STATE_ADAPTER = "memory";
|
|
156
95
|
}
|
|
96
|
+
/** Load the app plugin module so source-mode local chat matches server wiring. */
|
|
157
97
|
async function loadLocalPluginSet() {
|
|
158
|
-
|
|
159
|
-
process.cwd(),
|
|
160
|
-
async (moduleRef) => localPluginLoader.import(moduleRef.importPath)
|
|
161
|
-
);
|
|
98
|
+
return await loadAppPluginSet(process.cwd(), async (moduleRef) => localPluginLoader.import(moduleRef.importPath));
|
|
162
99
|
}
|
|
100
|
+
/** Configure plugin hooks after local chat has selected its state adapter. */
|
|
163
101
|
async function configureLocalChatPlugins(pluginSet) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
validationModule.validatePluginEgressCredentialHooks(
|
|
190
|
-
resolvedPluginSet?.registrations ?? []
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
databaseModule.getDb();
|
|
194
|
-
agentHooksModule.setPlugins(plugins);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
catalogRuntimeModule.pluginCatalogRuntime.setConfig(
|
|
197
|
-
previousPluginCatalogConfig
|
|
198
|
-
);
|
|
199
|
-
throw error;
|
|
200
|
-
}
|
|
102
|
+
const [pluginsModule, agentHooksModule, catalogRuntimeModule, validationModule, databaseModule] = await Promise.all([
|
|
103
|
+
import("../plugins-egKWjgue.js").then((n) => n.o),
|
|
104
|
+
import("../agent-hooks-DXHpTJ4m.js").then((n) => n.t),
|
|
105
|
+
import("../catalog-runtime-CXw3asJD.js").then((n) => n.t),
|
|
106
|
+
import("../validation-DfWcvhuS.js").then((n) => n.r),
|
|
107
|
+
import("../agent-hooks-DXHpTJ4m.js").then((n) => n.St)
|
|
108
|
+
]);
|
|
109
|
+
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
110
|
+
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
111
|
+
const pluginConfig = resolvedPluginSet ? pluginsModule.pluginCatalogConfigFromPluginSet(resolvedPluginSet) : pluginsModule.pluginCatalogConfigFromEnv();
|
|
112
|
+
const shouldValidatePluginCatalog = Boolean(pluginConfig) || Boolean(resolvedPluginSet?.registrations.length);
|
|
113
|
+
agentHooksModule.validatePlugins(plugins);
|
|
114
|
+
const previousPluginCatalogConfig = catalogRuntimeModule.pluginCatalogRuntime.setConfig(pluginConfig);
|
|
115
|
+
try {
|
|
116
|
+
if (shouldValidatePluginCatalog) {
|
|
117
|
+
catalogRuntimeModule.pluginCatalogRuntime.getSignature();
|
|
118
|
+
validationModule.validatePluginRegistrations(resolvedPluginSet?.registrations ?? []);
|
|
119
|
+
validationModule.validatePluginEgressCredentialHooks(resolvedPluginSet?.registrations ?? []);
|
|
120
|
+
}
|
|
121
|
+
databaseModule.getDb();
|
|
122
|
+
agentHooksModule.setPlugins(plugins);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
catalogRuntimeModule.pluginCatalogRuntime.setConfig(previousPluginCatalogConfig);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
201
127
|
}
|
|
202
128
|
function parseChatArgs(argv) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return void 0;
|
|
212
|
-
}
|
|
213
|
-
return { message, mode: "prompt" };
|
|
129
|
+
if (argv.length === 0) return { mode: "interactive" };
|
|
130
|
+
if (argv[0] !== "-p") return;
|
|
131
|
+
const message = argv.slice(1).join(" ").trim();
|
|
132
|
+
if (!message) return;
|
|
133
|
+
return {
|
|
134
|
+
message,
|
|
135
|
+
mode: "prompt"
|
|
136
|
+
};
|
|
214
137
|
}
|
|
215
138
|
function formatReply(reply) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
return `${lines.join("\n") || "[empty response]"}
|
|
222
|
-
`;
|
|
139
|
+
const lines = [];
|
|
140
|
+
const text = reply.text.trim();
|
|
141
|
+
if (text) lines.push(text);
|
|
142
|
+
return `${lines.join("\n") || "[empty response]"}\n`;
|
|
223
143
|
}
|
|
144
|
+
/** Create a fresh local conversation id for one CLI process invocation. */
|
|
224
145
|
function newRunConversationId() {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (!conversationId) {
|
|
229
|
-
throw new Error("Invalid local conversation name");
|
|
230
|
-
}
|
|
231
|
-
return conversationId;
|
|
146
|
+
const conversationId = normalizeLocalConversationId({ alias: `run-${randomUUID()}` });
|
|
147
|
+
if (!conversationId) throw new Error("Invalid local conversation name");
|
|
148
|
+
return conversationId;
|
|
232
149
|
}
|
|
233
150
|
function localDevServerUrl() {
|
|
234
|
-
|
|
151
|
+
return `http://127.0.0.1:${process.env.PORT?.trim() || "3000"}`;
|
|
235
152
|
}
|
|
153
|
+
/** Wire the shared local-turn setup so prompt and interactive runs stay identical. */
|
|
236
154
|
async function prepareLocalChatRun(io, pluginSet) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
await localConversationWork.drain();
|
|
300
|
-
} finally {
|
|
301
|
-
await oauthCallback.close();
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
conversationId: newRunConversationId(),
|
|
305
|
-
runLocalAgentTurn,
|
|
306
|
-
deps
|
|
307
|
-
};
|
|
155
|
+
defaultStateAdapterForLocalChat();
|
|
156
|
+
await configureLocalChatPlugins(pluginSet);
|
|
157
|
+
const { setExperimentalFeatures } = await import("../experimental-CIXf7Uye.js").then((n) => n.t);
|
|
158
|
+
setExperimentalFeatures({ subagents: true });
|
|
159
|
+
const { runLocalAgentTurn } = await import("../runner-BXYxfIUL.js");
|
|
160
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-WwG5_Zgm.js");
|
|
161
|
+
const { createLocalOAuthState } = await import("../oauth-relay-CdCnu80W.js").then((n) => n.t);
|
|
162
|
+
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-ngEPjSEW.js");
|
|
163
|
+
const { bindSpawnAgent } = await import("../spawn-h0R1bTEo.js").then((n) => n.n);
|
|
164
|
+
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-B91LQKHr.js").then((n) => n.a);
|
|
165
|
+
const { createLocalConversationWork } = await import("../conversation-work-C6y3T5Hx.js");
|
|
166
|
+
const { processConversationWork } = await import("../worker-BcRRTe6k.js").then((n) => n.n);
|
|
167
|
+
let agentRunner;
|
|
168
|
+
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
169
|
+
if (!agentRunner) throw new Error("Local agent runner is not ready");
|
|
170
|
+
const run = routeAgentInvocationWork({
|
|
171
|
+
fallbackWorker: async () => {
|
|
172
|
+
throw new Error("Local child queue received non-invocation work");
|
|
173
|
+
},
|
|
174
|
+
invocationWorker: createAgentInvocationWorker(agentRunner)
|
|
175
|
+
});
|
|
176
|
+
await processConversationWork(message, {
|
|
177
|
+
queue: localConversationWork.queue,
|
|
178
|
+
run
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
agentRunner = createAgentRunner(executeAgentRun, { bindSpawnAgent: (request) => bindSpawnAgent(request, { queue: localConversationWork.queue }) });
|
|
182
|
+
const oauthCallback = await startLocalOAuthCallbackServer(agentRunner);
|
|
183
|
+
const deps = {
|
|
184
|
+
agentRunner,
|
|
185
|
+
authorization: {
|
|
186
|
+
cancel: oauthCallback.cancelAuthorization,
|
|
187
|
+
createState: async () => await createLocalOAuthState(oauthCallback.port),
|
|
188
|
+
deliver: async (request) => {
|
|
189
|
+
oauthCallback.beginAuthorization(request.authorizationUrl);
|
|
190
|
+
await reportStatus(io, `${request.label}:\n${request.authorizationUrl}\n${request.completionText}`);
|
|
191
|
+
},
|
|
192
|
+
wait: oauthCallback.waitForAuthorization
|
|
193
|
+
},
|
|
194
|
+
sandboxEgressSignals: createLocalSandboxEgressSignalTransport(localDevServerUrl()),
|
|
195
|
+
deliverReply: async (reply) => {
|
|
196
|
+
await deliverReply(io, reply);
|
|
197
|
+
},
|
|
198
|
+
onStatus: async (status) => {
|
|
199
|
+
await reportStatus(io, status);
|
|
200
|
+
},
|
|
201
|
+
onToolResult: async (result) => {
|
|
202
|
+
await reportToolResult(io, result);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
close: async () => {
|
|
207
|
+
try {
|
|
208
|
+
await localConversationWork.drain();
|
|
209
|
+
} finally {
|
|
210
|
+
await oauthCallback.close();
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
conversationId: newRunConversationId(),
|
|
214
|
+
runLocalAgentTurn,
|
|
215
|
+
deps
|
|
216
|
+
};
|
|
308
217
|
}
|
|
309
218
|
async function runPrompt(options, io, pluginSet) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return result.outcome === "success" ? 0 : 1;
|
|
320
|
-
} finally {
|
|
321
|
-
await close();
|
|
322
|
-
}
|
|
219
|
+
const { close, conversationId, runLocalAgentTurn, deps } = await prepareLocalChatRun(io, pluginSet);
|
|
220
|
+
try {
|
|
221
|
+
return (await runLocalAgentTurn({
|
|
222
|
+
conversationId,
|
|
223
|
+
message: options.message
|
|
224
|
+
}, deps)).outcome === "success" ? 0 : 1;
|
|
225
|
+
} finally {
|
|
226
|
+
await close();
|
|
227
|
+
}
|
|
323
228
|
}
|
|
324
229
|
async function runInteractive(io, pluginSet) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
throw error;
|
|
351
|
-
}
|
|
352
|
-
await reportStatus(io, errorMessage(error));
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
} finally {
|
|
356
|
-
rl.close();
|
|
357
|
-
await close();
|
|
358
|
-
}
|
|
230
|
+
const { close, conversationId, runLocalAgentTurn, deps } = await prepareLocalChatRun(io, pluginSet);
|
|
231
|
+
const rl = readline.createInterface({
|
|
232
|
+
input: io.input,
|
|
233
|
+
output: io.output,
|
|
234
|
+
terminal: true
|
|
235
|
+
});
|
|
236
|
+
try {
|
|
237
|
+
while (true) {
|
|
238
|
+
const message = (await rl.question("junior> ")).trim();
|
|
239
|
+
if (!message) continue;
|
|
240
|
+
if (message === "/exit" || message === "/quit") break;
|
|
241
|
+
try {
|
|
242
|
+
await runLocalAgentTurn({
|
|
243
|
+
conversationId,
|
|
244
|
+
message
|
|
245
|
+
}, deps);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error instanceof ChatOutputError) throw error;
|
|
248
|
+
await reportStatus(io, errorMessage(error));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
} finally {
|
|
252
|
+
rl.close();
|
|
253
|
+
await close();
|
|
254
|
+
}
|
|
359
255
|
}
|
|
256
|
+
/** Run the local Junior chat command. */
|
|
360
257
|
async function runChat(argv, io = DEFAULT_IO, deps = {}) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
return 1;
|
|
375
|
-
}
|
|
258
|
+
const options = parseChatArgs(argv);
|
|
259
|
+
if (!options) {
|
|
260
|
+
await io.error(CHAT_USAGE);
|
|
261
|
+
return 1;
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
if (options.mode === "prompt") return await runPrompt(options, io, deps.pluginSet);
|
|
265
|
+
await runInteractive(io, deps.pluginSet);
|
|
266
|
+
return 0;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
await io.error(errorMessage(error));
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
376
271
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
runChat
|
|
380
|
-
};
|
|
272
|
+
//#endregion
|
|
273
|
+
export { CHAT_USAGE, runChat };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/cli/check.d.ts
|
|
2
|
+
export interface ValidationIo {
|
|
3
|
+
info: (line: string) => void;
|
|
4
|
+
warn: (line: string) => void;
|
|
5
|
+
error: (line: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function runCheck(rootDir?: string, io?: ValidationIo): Promise<void>;
|
|
8
|
+
//#endregion
|