@staff0rd/assist 0.1205.2 → 0.1207.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/.build-files +109 -109
- package/dist/{addActivity-JBMTTLVR.js → addActivity-OP4CYYSE.js} +4 -4
- package/dist/{addPhase-IJTUEHSG.js → addPhase-A57QYJ5U.js} +8 -8
- package/dist/{advise-3QQ2PJML.js → advise-AO6UE45G.js} +7 -7
- package/dist/{ask-A22IMKEB.js → ask-OOGRM4DM.js} +5 -5
- package/dist/{askCheck-KCPWRFQL.js → askCheck-QJLMD6UG.js} +12 -12
- package/dist/{askDesign-XAU67FYK.js → askDesign-JT5G2UC4.js} +7 -7
- package/dist/{askQuestion-Y3RVZWA6.js → askQuestion-V2WHGTVT.js} +4 -4
- package/dist/{branch-TQIQ4DWM.js → branch-IX72TUM6.js} +6 -6
- package/dist/built-version +1 -1
- package/dist/{chunk-JMPS7M2H.js → chunk-26LZZNJO.js} +1 -1
- package/dist/{chunk-X2RAHZ75.js → chunk-2DXHHZYS.js} +1 -1
- package/dist/{chunk-LIW7VKTS.js → chunk-2EYYX7QG.js} +4 -3
- package/dist/{chunk-L3CPQJLB.js → chunk-2RAIER3I.js} +1 -1
- package/dist/{chunk-KW25SDKW.js → chunk-34ZLP7B7.js} +2 -2
- package/dist/{chunk-UZ6JWHII.js → chunk-45JSZ65Y.js} +1 -1
- package/dist/{chunk-OIQUXYW4.js → chunk-4H5BL7EP.js} +1 -1
- package/dist/{chunk-C42634QC.js → chunk-4ME27AII.js} +2 -2
- package/dist/{chunk-5JIMJOM6.js → chunk-4RKDRLTA.js} +1 -1
- package/dist/{chunk-SJZJRE2A.js → chunk-5EZFT2FY.js} +1 -1
- package/dist/{chunk-JLU5HZUK.js → chunk-5JSMDYCI.js} +1 -1
- package/dist/{chunk-EOZSVWJ5.js → chunk-67YN2FZY.js} +4 -4
- package/dist/{chunk-CI6PMW2K.js → chunk-6NWHG7HN.js} +1 -1
- package/dist/{chunk-MJJNSW7W.js → chunk-7RUOOWEW.js} +7 -7
- package/dist/{chunk-TBVNDD3J.js → chunk-BCURM5UO.js} +1 -1
- package/dist/{chunk-DNVJ5NCV.js → chunk-BE5EU5MQ.js} +8 -8
- package/dist/{chunk-KI4CFWBK.js → chunk-BUHPBUAO.js} +1 -1
- package/dist/{chunk-KUP7IHHO.js → chunk-CMGNAZL5.js} +1 -1
- package/dist/{chunk-IW72YNJY.js → chunk-DKEON5CG.js} +2 -2
- package/dist/{chunk-G3PWHI6R.js → chunk-E62SUE3E.js} +1 -1
- package/dist/{chunk-LWBI35ZN.js → chunk-I7C3L5U6.js} +2 -2
- package/dist/{chunk-DKLLBYDI.js → chunk-I7M7746P.js} +1 -1
- package/dist/{chunk-5ROERL77.js → chunk-IDZLQT6D.js} +2 -2
- package/dist/{chunk-S6W5RNKO.js → chunk-IYQOW4OC.js} +1 -1
- package/dist/{chunk-32E4VPXI.js → chunk-K4NS6CBX.js} +1 -1
- package/dist/{chunk-XRKN6SYT.js → chunk-K75HZP5Z.js} +1 -1
- package/dist/{chunk-VLHNUG6D.js → chunk-L4N2OSKX.js} +2 -0
- package/dist/{chunk-EE7PSI65.js → chunk-LIBIAVN3.js} +2 -2
- package/dist/{chunk-GMV2WGDO.js → chunk-LNKPSNU6.js} +1 -1
- package/dist/{chunk-NCUKLM37.js → chunk-M75HWQ5U.js} +2 -2
- package/dist/{chunk-HYY23KKM.js → chunk-MJLJCY6C.js} +4 -4
- package/dist/{chunk-N25OUARM.js → chunk-MXWAF4ZG.js} +1 -1
- package/dist/{chunk-5FYDMR36.js → chunk-N73DDGYQ.js} +1 -1
- package/dist/{chunk-V7KLQEG2.js → chunk-NCJFMM6R.js} +1 -1
- package/dist/{chunk-S2TTVGYO.js → chunk-OSJBB5GS.js} +1 -1
- package/dist/{chunk-4ULABTCG.js → chunk-OW4NYC3A.js} +2 -2
- package/dist/{chunk-F2JUYGQ7.js → chunk-OYGOASDH.js} +1 -1
- package/dist/{chunk-DOMHDQJP.js → chunk-QR3WJZ7O.js} +4 -4
- package/dist/{chunk-S7JW4HJZ.js → chunk-RWDHSHET.js} +1 -1
- package/dist/{chunk-RLERRRDD.js → chunk-SFFCDVBX.js} +1 -1
- package/dist/{chunk-Y6LCJ5IE.js → chunk-T2RR4PLI.js} +1 -1
- package/dist/{chunk-DRTG3MW5.js → chunk-TQ2MXR5W.js} +1 -1
- package/dist/{chunk-CCFQBCLE.js → chunk-U3AG7ZYI.js} +1 -1
- package/dist/{chunk-7ZPD5IME.js → chunk-UQ3KJ736.js} +1 -1
- package/dist/{chunk-PENX3NNT.js → chunk-WGWOUAR7.js} +195 -55
- package/dist/{chunk-YSUV5DXT.js → chunk-WTUDZWB7.js} +7 -7
- package/dist/{chunk-U66P6SNS.js → chunk-WX7AHMYM.js} +1 -1
- package/dist/{chunk-TA4XOADC.js → chunk-XPQDQHTN.js} +2 -2
- package/dist/{chunk-K5Q5SHKB.js → chunk-YBD2L7L6.js} +1 -1
- package/dist/{chunk-FAKMTFJ6.js → chunk-Z2KJ76DF.js} +2 -2
- package/dist/{cliHook-2EVKZ3ZF.js → cliHook-YJMC7AUI.js} +9 -9
- package/dist/{cliHookCheck-7RDNU5JI.js → cliHookCheck-UH526HM3.js} +4 -4
- package/dist/{codexHook-BKO3VKOY.js → codexHook-4TBSO3P6.js} +12 -12
- package/dist/commands/sessions/web/bundle.js +6 -6
- package/dist/{comment-EXGIXVBW.js → comment-F5XZZ4Y4.js} +6 -6
- package/dist/{commentIssue-HX2TKOI5.js → commentIssue-7FKBZ6EV.js} +5 -5
- package/dist/{commit-QD6E3OTY.js → commit-MGUM7BLU.js} +6 -6
- package/dist/{createIssue-XWYHF2L5.js → createIssue-4YO4IIOA.js} +4 -4
- package/dist/{doctorNodes-AF2WJ3HY.js → doctorNodes-75K7IIOK.js} +3 -3
- package/dist/{done-KXBKYOWE.js → done-ZIFECRL2.js} +7 -7
- package/dist/{edit-7GXC24BQ.js → edit-LPNKSYKK.js} +4 -4
- package/dist/{editHook-2DXZ5EHB.js → editHook-ABA5JEST.js} +9 -9
- package/dist/{editIssue-TRJS5KPU.js → editIssue-ZZRUDFPS.js} +4 -4
- package/dist/{editIssueComment-LJDKZAY7.js → editIssueComment-SQJYTTKE.js} +5 -5
- package/dist/{fixConflict-KGMJSITO.js → fixConflict-Q4XSJ6FH.js} +9 -9
- package/dist/{harnessFollowUps-DVRV2GGW.js → harnessFollowUps-TPBSRN6N.js} +1 -1
- package/dist/index.js +66 -66
- package/dist/{launchMode-OT7I23Q5.js → launchMode-Y7MHOM7C.js} +19 -19
- package/dist/{list-WBSYD672.js → list-W6R23QYV.js} +8 -8
- package/dist/{migrate-6U25EHIB.js → migrate-TYNM3UWT.js} +5 -5
- package/dist/{next-QIEHVVMI.js → next-KYXCCJB2.js} +18 -18
- package/dist/{phaseDone-W2HKXE2D.js → phaseDone-MI63EKAJ.js} +8 -8
- package/dist/{piHook-MAHA4KVO.js → piHook-ENH2YKJH.js} +9 -9
- package/dist/{postSlackMessage-HLPIBT3U.js → postSlackMessage-2NC4VT6H.js} +5 -5
- package/dist/{propose-BUUVMSPI.js → propose-YLESW3TM.js} +9 -9
- package/dist/{raise-R6OZDSFL.js → raise-NOVQP4TY.js} +4 -4
- package/dist/{refine-FXEZ3DRI.js → refine-P22CKVV3.js} +20 -20
- package/dist/{reply-O6BG4BCI.js → reply-EMO2C4HC.js} +5 -5
- package/dist/{restartNode-E5OSNXCL.js → restartNode-6WZN2BGV.js} +5 -5
- package/dist/{review-Y5BVWSCC.js → review-34RHNAF7.js} +13 -13
- package/dist/{reviewPrComments-XKKF7546.js → reviewPrComments-F5GM2MSA.js} +9 -9
- package/dist/{rewindPhase-MP4VW7R2.js → rewindPhase-2UWPEMDO.js} +11 -11
- package/dist/{rulesAdd-S6J3UGZG.js → rulesAdd-VUWCOGDD.js} +5 -5
- package/dist/{run-K6HIOS4R.js → run-FLD5NZS3.js} +16 -16
- package/dist/{run-FGPS4VHX.js → run-VA2WV5XR.js} +16 -16
- package/dist/{runDaemon-3BXEX5FG.js → runDaemon-JPDNTOIR.js} +2949 -3009
- package/dist/{runExtract-QTZCWJKP.js → runExtract-WXKXBRKK.js} +4 -4
- package/dist/{runParallelPhase-E57UAOE6.js → runParallelPhase-ZQAAEMA2.js} +80 -36
- package/dist/{runRefine-TPZ7VBK5.js → runRefine-M7IJL5W6.js} +20 -20
- package/dist/{scan-URR7C6AP.js → scan-RNKDVCCN.js} +6 -6
- package/dist/{schemaConfirm-66VXNCII.js → schemaConfirm-WQ6P7UM4.js} +4 -4
- package/dist/{schemaLock-443HDBLY.js → schemaLock-3KE3NKOC.js} +4 -4
- package/dist/{schemaUnlock-VHCIAGWZ.js → schemaUnlock-7J32EQK7.js} +4 -4
- package/dist/{search-G4BEEJKD.js → search-IGQ3BSZD.js} +8 -8
- package/dist/{show-WADTA2JE.js → show-52OX235Y.js} +5 -5
- package/dist/{show-2WZSRR34.js → show-HKSHW4SB.js} +6 -6
- package/dist/{signExtension-3KYY72FK.js → signExtension-EUAPM6DG.js} +1 -1
- package/dist/{slack-PGM3RJQ2.js → slack-QLY7GVYF.js} +5 -5
- package/dist/{updateNode-WIE7WPKF.js → updateNode-7SOKYQL4.js} +5 -5
- package/dist/{updatePlan-PU6HSSHC.js → updatePlan-6EVC5MIC.js} +9 -9
- package/dist/{web-JQEASEYY.js → web-FHHTROWE.js} +19 -19
- package/dist/{web-PZVGTC43.js → web-YSEP6467.js} +19 -19
- package/dist/{wontfix-H3CW7UED.js → wontfix-BLXCT4QP.js} +5 -5
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
lookupConversation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4ME27AII.js";
|
|
4
4
|
import {
|
|
5
5
|
harnessAdapter,
|
|
6
6
|
readTranscriptTail
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WGWOUAR7.js";
|
|
8
8
|
|
|
9
9
|
// src/commands/sessions/shared/targetConversationEvents.ts
|
|
10
10
|
async function targetConversationEvents(cwd, target) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backlogPhaseActivity,
|
|
3
3
|
recordPhaseSession
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-I7M7746P.js";
|
|
5
5
|
import {
|
|
6
6
|
resumeNudge
|
|
7
7
|
} from "./chunk-7NZOH4LN.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-ZYK7V4PG.js";
|
|
12
12
|
import {
|
|
13
13
|
preassignedId
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4H5BL7EP.js";
|
|
15
15
|
import {
|
|
16
16
|
emitActivity
|
|
17
17
|
} from "./chunk-3DNFNT2L.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./chunk-5ZQMQXEX.js";
|
|
27
27
|
import {
|
|
28
28
|
buildPhasePrompt
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-BUHPBUAO.js";
|
|
30
30
|
import {
|
|
31
31
|
getReady
|
|
32
32
|
} from "./chunk-VOQKEIEV.js";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
} from "./chunk-P6KSXCDA.js";
|
|
39
39
|
import {
|
|
40
40
|
harnessAdapter
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-WGWOUAR7.js";
|
|
42
42
|
import {
|
|
43
43
|
getSignalPath
|
|
44
44
|
} from "./chunk-P23ZWXGY.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatUnavailable,
|
|
3
3
|
resolveFeature
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NCJFMM6R.js";
|
|
5
5
|
import {
|
|
6
6
|
harnessAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WGWOUAR7.js";
|
|
8
8
|
import {
|
|
9
9
|
activeHarness
|
|
10
10
|
} from "./chunk-DZBQRJLT.js";
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
isDocsPath,
|
|
9
9
|
isSchemaPath,
|
|
10
10
|
mentionsDocsPath
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-U3AG7ZYI.js";
|
|
12
12
|
import {
|
|
13
13
|
isSchemaLocked
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2RAIER3I.js";
|
|
15
15
|
import {
|
|
16
16
|
findBuiltinDenyRaw,
|
|
17
17
|
findDeny,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
isApprovedRead,
|
|
22
22
|
resolvePermission,
|
|
23
23
|
splitCompound
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6NWHG7HN.js";
|
|
25
25
|
import {
|
|
26
26
|
inWebSession
|
|
27
27
|
} from "./chunk-HKGCLAZ7.js";
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
} from "./chunk-XJTXAL22.js";
|
|
34
34
|
import {
|
|
35
35
|
defersPreviewWait
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-E62SUE3E.js";
|
|
37
37
|
import {
|
|
38
38
|
askQuestionEnabled
|
|
39
39
|
} from "./chunk-IBPSXDUB.js";
|
|
@@ -18,12 +18,12 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
harnessCapability,
|
|
20
20
|
sdkAgentEnv
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-K4NS6CBX.js";
|
|
22
22
|
import {
|
|
23
23
|
harnessCapabilityDeclarations,
|
|
24
24
|
supported,
|
|
25
25
|
unsupported
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-L4N2OSKX.js";
|
|
27
27
|
import {
|
|
28
28
|
harnessLabel,
|
|
29
29
|
resolveHarness
|
|
@@ -2159,7 +2159,8 @@ function codexSandboxArgs() {
|
|
|
2159
2159
|
var SESSION_ENV_KEYS = [
|
|
2160
2160
|
"ASSIST_SESSION",
|
|
2161
2161
|
"ASSIST_SESSION_ID",
|
|
2162
|
-
"ASSIST_BACKLOG_ITEM_ID"
|
|
2162
|
+
"ASSIST_BACKLOG_ITEM_ID",
|
|
2163
|
+
sdkAgentEnv
|
|
2163
2164
|
];
|
|
2164
2165
|
function codexSessionEnvArgs(env) {
|
|
2165
2166
|
return SESSION_ENV_KEYS.flatMap((key) => [
|
|
@@ -2979,6 +2980,11 @@ function codexHookProbe() {
|
|
|
2979
2980
|
return status;
|
|
2980
2981
|
}
|
|
2981
2982
|
|
|
2983
|
+
// src/shared/codexSandboxMode.ts
|
|
2984
|
+
function codexSandboxMode(allowEdits) {
|
|
2985
|
+
return allowEdits === false ? "read-only" : "workspace-write";
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2982
2988
|
// src/shared/readCodexRulePerms.ts
|
|
2983
2989
|
import { existsSync as existsSync7, readdirSync as readdirSync3, readFileSync as readFileSync7 } from "fs";
|
|
2984
2990
|
import { join as join13 } from "path";
|
|
@@ -3086,16 +3092,18 @@ function neutralizeCodexSkillMentions(prompt) {
|
|
|
3086
3092
|
return prompt.replace(/\$(?=[a-z])/g, `$${WORD_JOINER}`);
|
|
3087
3093
|
}
|
|
3088
3094
|
|
|
3095
|
+
// src/shared/codexSkillPrompt.ts
|
|
3096
|
+
function codexSkillPrompt(skill, prompt) {
|
|
3097
|
+
return [skill && `$${skill}`, prompt && neutralizeCodexSkillMentions(prompt)].filter(Boolean).join(" ");
|
|
3098
|
+
}
|
|
3099
|
+
|
|
3089
3100
|
// src/shared/spawnCodex.ts
|
|
3090
3101
|
function spawnCodex2(prompt, options = {}) {
|
|
3091
3102
|
const cwd = options.cwd ?? process.cwd();
|
|
3092
3103
|
trustCodexProject(cwd);
|
|
3093
3104
|
const untrusted = prepareCodexHookTrust();
|
|
3094
3105
|
if (untrusted) console.error(untrusted);
|
|
3095
|
-
const text =
|
|
3096
|
-
options.skill && `$${options.skill}`,
|
|
3097
|
-
prompt && neutralizeCodexSkillMentions(prompt)
|
|
3098
|
-
].filter(Boolean).join(" ");
|
|
3106
|
+
const text = codexSkillPrompt(options.skill, prompt);
|
|
3099
3107
|
const override = options.model && !options.resumeSessionId ? { args: ["-m", options.model], env: {} } : buildHarnessCodexArgs();
|
|
3100
3108
|
return spawnInherit(
|
|
3101
3109
|
harnesses.codex.command,
|
|
@@ -3327,7 +3335,6 @@ function rejectConnectorRun(harness) {
|
|
|
3327
3335
|
}
|
|
3328
3336
|
|
|
3329
3337
|
// src/shared/harnessAdapters/codexAdapter.ts
|
|
3330
|
-
var sandbox = (allowEdits) => allowEdits === false ? "read-only" : "workspace-write";
|
|
3331
3338
|
var codexAdapter = {
|
|
3332
3339
|
kind: "codex",
|
|
3333
3340
|
label: harnessLabel("codex"),
|
|
@@ -3353,14 +3360,14 @@ var codexAdapter = {
|
|
|
3353
3360
|
permissionRules: readCodexRulePerms,
|
|
3354
3361
|
launchSkill: (skill, args, { cwd, allowEdits, model }) => spawnCodex2(args ?? "", {
|
|
3355
3362
|
cwd,
|
|
3356
|
-
sandbox:
|
|
3363
|
+
sandbox: codexSandboxMode(allowEdits),
|
|
3357
3364
|
skill,
|
|
3358
3365
|
model
|
|
3359
3366
|
}),
|
|
3360
|
-
launchPrompt: (prompt, { cwd, allowEdits, model }) => spawnCodex2(prompt, { cwd, sandbox:
|
|
3367
|
+
launchPrompt: (prompt, { cwd, allowEdits, model }) => spawnCodex2(prompt, { cwd, sandbox: codexSandboxMode(allowEdits), model }),
|
|
3361
3368
|
resume: (conversationId, nudge, { cwd, allowEdits }) => spawnCodex2(nudge, {
|
|
3362
3369
|
cwd,
|
|
3363
|
-
sandbox:
|
|
3370
|
+
sandbox: codexSandboxMode(allowEdits),
|
|
3364
3371
|
resumeSessionId: conversationId
|
|
3365
3372
|
}),
|
|
3366
3373
|
interactive: ({
|
|
@@ -3583,13 +3590,16 @@ function createSdkExit(emit, child) {
|
|
|
3583
3590
|
function sdkEventListeners() {
|
|
3584
3591
|
const listeners = [];
|
|
3585
3592
|
let resumed = false;
|
|
3593
|
+
let conversation;
|
|
3586
3594
|
return {
|
|
3587
3595
|
onEvent: (listener) => {
|
|
3588
3596
|
listeners.push(listener);
|
|
3589
3597
|
if (resumed) listener({ kind: "resumed" });
|
|
3598
|
+
if (conversation) listener(conversation);
|
|
3590
3599
|
},
|
|
3591
3600
|
emit: (event) => {
|
|
3592
3601
|
if (event.kind === "resumed") resumed = true;
|
|
3602
|
+
if (event.kind === "conversation") conversation = event;
|
|
3593
3603
|
for (const listener of listeners) listener(event);
|
|
3594
3604
|
}
|
|
3595
3605
|
};
|
|
@@ -3620,7 +3630,7 @@ function sdkSessionHandle(label, backgroundTasks) {
|
|
|
3620
3630
|
return {
|
|
3621
3631
|
handle,
|
|
3622
3632
|
emit: events.emit,
|
|
3623
|
-
/* why: held shell results join a message only as it reaches
|
|
3633
|
+
/* why: held shell results join a message only as it reaches the agent, so a
|
|
3624
3634
|
* message queued mid-turn still picks up output that finished after it. */
|
|
3625
3635
|
prefix: (text) => {
|
|
3626
3636
|
const blocks = prefixer?.();
|
|
@@ -4092,6 +4102,7 @@ function applyDrivenTurnEvent(event, control, turn, backgroundTasks) {
|
|
|
4092
4102
|
else if (event.kind === "elapsed") turn.setElapsed(event.seconds);
|
|
4093
4103
|
else if (event.kind === "suggestion")
|
|
4094
4104
|
control.emit({ kind: "suggestion", text: event.text });
|
|
4105
|
+
else if (event.kind === "conversation") control.emit(event);
|
|
4095
4106
|
else if (backgroundTasks)
|
|
4096
4107
|
control.emit({ kind: "background", tasks: event.tasks });
|
|
4097
4108
|
}
|
|
@@ -4138,6 +4149,19 @@ function startDrivenQuery(driver, context, turn, backgroundTasks) {
|
|
|
4138
4149
|
}
|
|
4139
4150
|
}
|
|
4140
4151
|
|
|
4152
|
+
// src/commands/sessions/daemon/sdk/workflowQueryEnv.ts
|
|
4153
|
+
function workflowQueryEnv(base, sessionId, launcherEnv2) {
|
|
4154
|
+
const env = {
|
|
4155
|
+
...sessionChildEnv(base, sessionId),
|
|
4156
|
+
// why: claude turns the Artifact tool off for SDK-driven runs unless this opts back in
|
|
4157
|
+
CLAUDE_CODE_ARTIFACT: base.CLAUDE_CODE_ARTIFACT ?? "1",
|
|
4158
|
+
[sdkAgentEnv]: "1"
|
|
4159
|
+
};
|
|
4160
|
+
if (!launcherEnv2) return env;
|
|
4161
|
+
const { ASSIST_ACTIVITY_ID: _activityId, ...rest } = env;
|
|
4162
|
+
return { ...rest, ...launcherEnv2 };
|
|
4163
|
+
}
|
|
4164
|
+
|
|
4141
4165
|
// src/commands/sessions/daemon/sdk/spawnDrivenSession.ts
|
|
4142
4166
|
function spawnDrivenSession(opts2, driver) {
|
|
4143
4167
|
refuseMissingCwd(opts2.cwd, opts2.sessionId);
|
|
@@ -4154,7 +4178,14 @@ function spawnDrivenSession(opts2, driver) {
|
|
|
4154
4178
|
const turn = createSdkTurnTracker(label, control, input.push);
|
|
4155
4179
|
if (opts2.prompt) turn.start(opts2.prompt);
|
|
4156
4180
|
abort.signal.addEventListener("abort", input.close);
|
|
4157
|
-
const context = {
|
|
4181
|
+
const context = {
|
|
4182
|
+
opts: opts2,
|
|
4183
|
+
label,
|
|
4184
|
+
abort,
|
|
4185
|
+
control,
|
|
4186
|
+
input: input.messages,
|
|
4187
|
+
childEnv: (base) => workflowQueryEnv(base, opts2.sessionId, opts2.launcherEnv)
|
|
4188
|
+
};
|
|
4158
4189
|
startDrivenQuery(driver, context, turn, backgroundTasks);
|
|
4159
4190
|
return control.process;
|
|
4160
4191
|
}
|
|
@@ -4381,27 +4412,11 @@ import { readFileSync as readFileSync8 } from "fs";
|
|
|
4381
4412
|
|
|
4382
4413
|
// src/commands/sessions/daemon/sdk/claude/spawnSdkChild.ts
|
|
4383
4414
|
import { spawn as spawn4 } from "child_process";
|
|
4384
|
-
|
|
4385
|
-
// src/commands/sessions/daemon/sdk/workflowQueryEnv.ts
|
|
4386
|
-
function workflowQueryEnv(base, sessionId, launcherEnv2) {
|
|
4387
|
-
const env = {
|
|
4388
|
-
...sessionChildEnv(base, sessionId),
|
|
4389
|
-
// why: claude turns the Artifact tool off for SDK-driven runs unless this opts back in
|
|
4390
|
-
CLAUDE_CODE_ARTIFACT: base.CLAUDE_CODE_ARTIFACT ?? "1",
|
|
4391
|
-
[sdkAgentEnv]: "1"
|
|
4392
|
-
};
|
|
4393
|
-
if (!launcherEnv2) return env;
|
|
4394
|
-
const { ASSIST_ACTIVITY_ID: _activityId, ...rest } = env;
|
|
4395
|
-
return { ...rest, ...launcherEnv2 };
|
|
4396
|
-
}
|
|
4397
|
-
|
|
4398
|
-
// src/commands/sessions/daemon/sdk/claude/spawnSdkChild.ts
|
|
4399
4415
|
var MAX_STDERR_LINE = 300;
|
|
4400
|
-
function spawnSdkChild(options, {
|
|
4401
|
-
const label = `session ${sessionId ?? "?"}`;
|
|
4416
|
+
function spawnSdkChild(options, { label, childEnv }, attach) {
|
|
4402
4417
|
const child = spawn4(options.command, options.args, {
|
|
4403
4418
|
cwd: options.cwd,
|
|
4404
|
-
env:
|
|
4419
|
+
env: childEnv(options.env),
|
|
4405
4420
|
stdio: ["pipe", "pipe", "pipe"],
|
|
4406
4421
|
signal: options.signal,
|
|
4407
4422
|
/* why: its own process group, so a kill also reaches the shell commands
|
|
@@ -4429,7 +4444,8 @@ function spawnSdkChild(options, { sessionId, launcherEnv: launcherEnv2 }, attach
|
|
|
4429
4444
|
}
|
|
4430
4445
|
|
|
4431
4446
|
// src/commands/sessions/daemon/sdk/claude/sdkQueryOptions.ts
|
|
4432
|
-
function sdkQueryOptions(
|
|
4447
|
+
function sdkQueryOptions(context, executable) {
|
|
4448
|
+
const { opts: opts2, abort, control } = context;
|
|
4433
4449
|
const append = opts2.appendSystemPromptFile ? readFileSync8(opts2.appendSystemPromptFile, "utf8") : void 0;
|
|
4434
4450
|
return {
|
|
4435
4451
|
cwd: opts2.cwd,
|
|
@@ -4437,7 +4453,7 @@ function sdkQueryOptions(opts2, executable, abort, control) {
|
|
|
4437
4453
|
permissionMode: "auto",
|
|
4438
4454
|
settings: ensureHooksSettings(),
|
|
4439
4455
|
pathToClaudeCodeExecutable: executable,
|
|
4440
|
-
spawnClaudeCodeProcess: (options) => spawnSdkChild(options,
|
|
4456
|
+
spawnClaudeCodeProcess: (options) => spawnSdkChild(options, context, control.attach),
|
|
4441
4457
|
abortController: abort,
|
|
4442
4458
|
model: opts2.model,
|
|
4443
4459
|
promptSuggestions: true,
|
|
@@ -4448,14 +4464,15 @@ function sdkQueryOptions(opts2, executable, abort, control) {
|
|
|
4448
4464
|
// src/commands/sessions/daemon/sdk/claude/claudeSdkDriver.ts
|
|
4449
4465
|
var claudeSdkDriver = {
|
|
4450
4466
|
harness: "claude-sdk",
|
|
4451
|
-
start: (
|
|
4467
|
+
start: (context) => {
|
|
4468
|
+
const { opts: opts2, label, control, input } = context;
|
|
4452
4469
|
const executable = resolveClaudeExecutable();
|
|
4453
4470
|
daemonLog(
|
|
4454
4471
|
`${label} sdk query starting: claude ${executable}, claude session ${opts2.conversationId ?? "unassigned"}, permission mode auto, cwd ${opts2.cwd ?? process.cwd()}`
|
|
4455
4472
|
);
|
|
4456
4473
|
const messages = query({
|
|
4457
4474
|
prompt: claudeUserMessages(input),
|
|
4458
|
-
options: sdkQueryOptions(
|
|
4475
|
+
options: sdkQueryOptions(context, executable)
|
|
4459
4476
|
});
|
|
4460
4477
|
if (opts2.resumeId) awaitResume(label, messages, control);
|
|
4461
4478
|
return {
|
|
@@ -4659,16 +4676,13 @@ exec ${args} "$@"
|
|
|
4659
4676
|
}
|
|
4660
4677
|
|
|
4661
4678
|
// src/commands/sessions/daemon/sdk/codex/codexSdkOptions.ts
|
|
4662
|
-
function codexSdkOptions(opts2) {
|
|
4679
|
+
function codexSdkOptions(opts2, childEnv) {
|
|
4680
|
+
const env = childEnv(process.env);
|
|
4663
4681
|
const model = resolveCodexModel(opts2.model);
|
|
4664
4682
|
const override = model ? { args: ["-m", model], env: {} } : buildHarnessCodexArgs();
|
|
4665
4683
|
const config = codexSdkConfig([
|
|
4666
4684
|
...override.args,
|
|
4667
|
-
...codexSessionEnvArgs(
|
|
4668
|
-
ASSIST_SESSION: "1",
|
|
4669
|
-
ASSIST_SESSION_ID: opts2.sessionId,
|
|
4670
|
-
ASSIST_BACKLOG_ITEM_ID: process.env.ASSIST_BACKLOG_ITEM_ID
|
|
4671
|
-
}),
|
|
4685
|
+
...codexSessionEnvArgs(env),
|
|
4672
4686
|
...codexSandboxArgs(),
|
|
4673
4687
|
...codexDeveloperInstructionsArgs(opts2.appendSystemPromptFile),
|
|
4674
4688
|
// why: no one can answer an approval prompt in a driven session, so escalations go to Codex's automatic reviewer
|
|
@@ -4679,15 +4693,12 @@ function codexSdkOptions(opts2) {
|
|
|
4679
4693
|
codex: {
|
|
4680
4694
|
codexPathOverride: codexSdkExecutable(),
|
|
4681
4695
|
configOverrides: config.configOverrides,
|
|
4682
|
-
env:
|
|
4683
|
-
...opts2.launcherEnv,
|
|
4684
|
-
...override.env
|
|
4685
|
-
})
|
|
4696
|
+
env: { ...env, ...override.env }
|
|
4686
4697
|
},
|
|
4687
4698
|
thread: {
|
|
4688
4699
|
model: config.model,
|
|
4689
4700
|
workingDirectory: opts2.cwd,
|
|
4690
|
-
sandboxMode:
|
|
4701
|
+
sandboxMode: codexSandboxMode(opts2.allowEdits),
|
|
4691
4702
|
approvalPolicy: "on-request",
|
|
4692
4703
|
skipGitRepoCheck: true,
|
|
4693
4704
|
additionalDirectories: config.additionalDirectories
|
|
@@ -4722,7 +4733,7 @@ function codexEventTurnEvents(event, label) {
|
|
|
4722
4733
|
return [{ kind: "activity", text: codexItemActivity(event.item) }];
|
|
4723
4734
|
case "thread.started":
|
|
4724
4735
|
daemonLog(`${label} codex thread started: ${event.thread_id}`);
|
|
4725
|
-
return [];
|
|
4736
|
+
return [{ kind: "conversation", id: event.thread_id }];
|
|
4726
4737
|
case "turn.failed":
|
|
4727
4738
|
daemonLog(`${label} codex turn failed: ${event.error.message}`);
|
|
4728
4739
|
return [];
|
|
@@ -4764,12 +4775,118 @@ function codexTurnEvents(input, runTurn, label) {
|
|
|
4764
4775
|
};
|
|
4765
4776
|
}
|
|
4766
4777
|
|
|
4778
|
+
// src/commands/sessions/shared/codex/codexRolloutUsage.ts
|
|
4779
|
+
import * as fs15 from "fs";
|
|
4780
|
+
|
|
4781
|
+
// src/commands/sessions/shared/codex/applyTokenInfo.ts
|
|
4782
|
+
function applyTokenInfo(usage, byId, conversationId, rawInfo) {
|
|
4783
|
+
if (!rawInfo || typeof rawInfo !== "object") return;
|
|
4784
|
+
const info = rawInfo;
|
|
4785
|
+
const last = info.last_token_usage;
|
|
4786
|
+
const cumulative = info.total_token_usage?.total_tokens;
|
|
4787
|
+
if (!last || typeof cumulative !== "number") return;
|
|
4788
|
+
const messageId = `codex:${conversationId}:${cumulative}`;
|
|
4789
|
+
byId.set(messageId, {
|
|
4790
|
+
messageId,
|
|
4791
|
+
inputTokens: Math.max(
|
|
4792
|
+
0,
|
|
4793
|
+
(last.input_tokens ?? 0) - (last.cached_input_tokens ?? 0)
|
|
4794
|
+
),
|
|
4795
|
+
outputTokens: last.output_tokens ?? 0
|
|
4796
|
+
});
|
|
4797
|
+
const contextWindow = info.model_context_window;
|
|
4798
|
+
if (contextWindow && typeof last.total_tokens === "number")
|
|
4799
|
+
usage.usedPct = Math.min(100, last.total_tokens / contextWindow * 100);
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
// src/commands/sessions/shared/codex/toRateLimits.ts
|
|
4803
|
+
var WINDOW_BY_MINUTES = {
|
|
4804
|
+
300: "five_hour",
|
|
4805
|
+
10080: "seven_day"
|
|
4806
|
+
};
|
|
4807
|
+
function toRateLimits(raw) {
|
|
4808
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
4809
|
+
const { primary, secondary } = raw;
|
|
4810
|
+
const rateLimits = {};
|
|
4811
|
+
for (const candidate of [primary, secondary]) {
|
|
4812
|
+
if (!candidate || typeof candidate !== "object") continue;
|
|
4813
|
+
const limit = candidate;
|
|
4814
|
+
const window = WINDOW_BY_MINUTES[limit.window_minutes ?? 0];
|
|
4815
|
+
if (!window || typeof limit.used_percent !== "number") continue;
|
|
4816
|
+
rateLimits[window] = {
|
|
4817
|
+
used_percentage: limit.used_percent,
|
|
4818
|
+
resets_at: limit.resets_at
|
|
4819
|
+
};
|
|
4820
|
+
}
|
|
4821
|
+
return Object.keys(rateLimits).length > 0 ? rateLimits : void 0;
|
|
4822
|
+
}
|
|
4823
|
+
|
|
4824
|
+
// src/commands/sessions/shared/codex/codexRolloutUsage.ts
|
|
4825
|
+
function codexRolloutUsage(lines) {
|
|
4826
|
+
const usage = { responses: [] };
|
|
4827
|
+
const byId = /* @__PURE__ */ new Map();
|
|
4828
|
+
let conversationId = "";
|
|
4829
|
+
for (const line of lines) {
|
|
4830
|
+
const entry = parseRolloutEntry(line);
|
|
4831
|
+
if (!entry) continue;
|
|
4832
|
+
conversationId ||= sessionMetaId(entry);
|
|
4833
|
+
const payload = tokenCountPayload(entry);
|
|
4834
|
+
if (!payload) continue;
|
|
4835
|
+
applyTokenInfo(usage, byId, conversationId, payload.info);
|
|
4836
|
+
usage.rateLimits = toRateLimits(payload.rate_limits) ?? usage.rateLimits;
|
|
4837
|
+
}
|
|
4838
|
+
usage.responses = [...byId.values()];
|
|
4839
|
+
return usage;
|
|
4840
|
+
}
|
|
4841
|
+
async function readCodexRolloutUsage(rolloutPath) {
|
|
4842
|
+
const content = await fs15.promises.readFile(rolloutPath, "utf8");
|
|
4843
|
+
return codexRolloutUsage(content.split("\n"));
|
|
4844
|
+
}
|
|
4845
|
+
function sessionMetaId(entry) {
|
|
4846
|
+
if (entry.type !== "session_meta") return "";
|
|
4847
|
+
return rolloutString(rolloutPayload(entry).session_id);
|
|
4848
|
+
}
|
|
4849
|
+
function tokenCountPayload(entry) {
|
|
4850
|
+
if (entry.type !== "event_msg") return void 0;
|
|
4851
|
+
const payload = rolloutPayload(entry);
|
|
4852
|
+
return payload.type === "token_count" ? payload : void 0;
|
|
4853
|
+
}
|
|
4854
|
+
|
|
4855
|
+
// src/commands/sessions/daemon/sdk/codex/recordCodexTurnUsage.ts
|
|
4856
|
+
async function recordCodexTurnUsage(label, sessionId, threadId, usage) {
|
|
4857
|
+
daemonLog(
|
|
4858
|
+
`${label} codex turn usage: thread ${threadId ?? "unknown"} in ${usage.input_tokens} (cached ${usage.cached_input_tokens}) out ${usage.output_tokens}`
|
|
4859
|
+
);
|
|
4860
|
+
const sink2 = sdkUsageSink();
|
|
4861
|
+
if (!sink2 || !sessionId || !threadId) return;
|
|
4862
|
+
try {
|
|
4863
|
+
const rollout = await findCodexRolloutPath(threadId);
|
|
4864
|
+
if (!rollout) {
|
|
4865
|
+
daemonLog(`${label} codex turn usage: no rollout for thread ${threadId}`);
|
|
4866
|
+
return;
|
|
4867
|
+
}
|
|
4868
|
+
sink2.session(sessionId, "codex", await readCodexRolloutUsage(rollout));
|
|
4869
|
+
} catch (error) {
|
|
4870
|
+
daemonLog(
|
|
4871
|
+
`${label} codex turn usage read failed: ${error instanceof Error ? error.message : String(error)}`
|
|
4872
|
+
);
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4876
|
+
// src/commands/sessions/daemon/sdk/codex/withCodexTurnUsage.ts
|
|
4877
|
+
async function* withCodexTurnUsage(events, onUsage) {
|
|
4878
|
+
for await (const event of events) {
|
|
4879
|
+
if (event.type === "turn.completed") onUsage(event.usage);
|
|
4880
|
+
yield event;
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4767
4884
|
// src/commands/sessions/daemon/sdk/codex/codexSdkDriver.ts
|
|
4768
4885
|
var codexSdkDriver = {
|
|
4769
4886
|
harness: "codex-sdk",
|
|
4770
|
-
start: ({ opts: opts2, label, abort, control, input }) => {
|
|
4887
|
+
start: ({ opts: opts2, label, abort, control, input, childEnv }) => {
|
|
4771
4888
|
prepareCodexLaunch(opts2.cwd);
|
|
4772
|
-
const options = codexSdkOptions(opts2);
|
|
4889
|
+
const options = codexSdkOptions(opts2, childEnv);
|
|
4773
4890
|
daemonLog(
|
|
4774
4891
|
`${label} codex sdk thread starting: codex ${options.codex.codexPathOverride ?? "bundled"}, thread ${opts2.resumeId ?? "new"}, sandbox ${options.thread.sandboxMode}, cwd ${opts2.cwd ?? process.cwd()}`
|
|
4775
4892
|
);
|
|
@@ -4778,9 +4895,12 @@ var codexSdkDriver = {
|
|
|
4778
4895
|
if (opts2.resumeId) awaitCodexResume(label, opts2.resumeId, control);
|
|
4779
4896
|
const turns = codexTurnEvents(
|
|
4780
4897
|
input,
|
|
4781
|
-
async (text, signal) => (
|
|
4782
|
-
|
|
4783
|
-
|
|
4898
|
+
async (text, signal) => withCodexTurnUsage(
|
|
4899
|
+
(await thread.runStreamed(text, {
|
|
4900
|
+
signal: AbortSignal.any([abort.signal, signal])
|
|
4901
|
+
})).events,
|
|
4902
|
+
(usage) => void recordCodexTurnUsage(label, opts2.sessionId, thread.id, usage)
|
|
4903
|
+
),
|
|
4784
4904
|
label
|
|
4785
4905
|
);
|
|
4786
4906
|
return { events: turns.events, interrupt: turns.interrupt };
|
|
@@ -4804,6 +4924,27 @@ var codexSdkAdapter = {
|
|
|
4804
4924
|
"intercept.fileWrite": codexHookProbe
|
|
4805
4925
|
},
|
|
4806
4926
|
detect: () => detectHarness("codex-sdk"),
|
|
4927
|
+
launchSkill: (skill, args, { cwd, allowEdits, model }) => launchSdkViaDaemon({
|
|
4928
|
+
harness: "codex-sdk",
|
|
4929
|
+
prompt: codexSkillPrompt(skill, args ?? ""),
|
|
4930
|
+
cwd,
|
|
4931
|
+
allowEdits,
|
|
4932
|
+
model
|
|
4933
|
+
}),
|
|
4934
|
+
launchPrompt: (prompt, { cwd, allowEdits, model }) => launchSdkViaDaemon({
|
|
4935
|
+
harness: "codex-sdk",
|
|
4936
|
+
prompt: codexSkillPrompt(void 0, prompt),
|
|
4937
|
+
cwd,
|
|
4938
|
+
allowEdits,
|
|
4939
|
+
model
|
|
4940
|
+
}),
|
|
4941
|
+
resume: (conversationId, nudge, { cwd, allowEdits }) => launchSdkViaDaemon({
|
|
4942
|
+
harness: "codex-sdk",
|
|
4943
|
+
prompt: codexSkillPrompt(void 0, nudge),
|
|
4944
|
+
cwd,
|
|
4945
|
+
allowEdits,
|
|
4946
|
+
resumeId: conversationId
|
|
4947
|
+
}),
|
|
4807
4948
|
interactive: ({
|
|
4808
4949
|
sessionId,
|
|
4809
4950
|
resumeId,
|
|
@@ -4866,16 +5007,15 @@ export {
|
|
|
4866
5007
|
noopDisposable,
|
|
4867
5008
|
sdkTerminalStub,
|
|
4868
5009
|
quoteForLog,
|
|
4869
|
-
setSdkUsageSink,
|
|
4870
5010
|
workflowQueryEnv,
|
|
5011
|
+
setSdkUsageSink,
|
|
4871
5012
|
resolveCodexModel,
|
|
4872
5013
|
discoverCodexRolloutPaths,
|
|
4873
5014
|
parseRolloutEntry,
|
|
4874
|
-
rolloutPayload,
|
|
4875
|
-
rolloutString,
|
|
4876
5015
|
codexRolloutMeta,
|
|
4877
5016
|
readCodexHeadLines,
|
|
4878
5017
|
codexAdapter,
|
|
5018
|
+
readCodexRolloutUsage,
|
|
4879
5019
|
piAdapter,
|
|
4880
5020
|
harnessAdapter
|
|
4881
5021
|
};
|