oh-my-opencode 3.17.12 → 3.17.13
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/README.ja.md +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/README.ru.md +1 -1
- package/README.zh-cn.md +1 -1
- package/dist/cli/index.js +20343 -20454
- package/dist/features/background-agent/manager.d.ts +13 -9
- package/dist/features/background-agent/types.d.ts +12 -12
- package/dist/features/background-agent/wait-for-task-session.d.ts +1 -1
- package/dist/features/team-mode/resolve-caller-team-lead.d.ts +8 -0
- package/dist/hooks/ralph-loop/loop-session-recovery.d.ts +7 -0
- package/dist/hooks/session-notification-scheduler.d.ts +2 -4
- package/dist/hooks/session-notification-utils.d.ts +1 -0
- package/dist/index.js +555 -325
- package/dist/shared/posthog-activity-state.d.ts +0 -5
- package/dist/shared/posthog.d.ts +0 -5
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -3003,6 +3003,7 @@ function truncateDescription(description, maxLength = 120) {
|
|
|
3003
3003
|
var require_constants = __commonJS((exports, module) => {
|
|
3004
3004
|
var WIN_SLASH = "\\\\/";
|
|
3005
3005
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
3006
|
+
var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
3006
3007
|
var DOT_LITERAL = "\\.";
|
|
3007
3008
|
var PLUS_LITERAL = "\\+";
|
|
3008
3009
|
var QMARK_LITERAL = "\\?";
|
|
@@ -3053,6 +3054,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
3053
3054
|
SEP: "\\"
|
|
3054
3055
|
};
|
|
3055
3056
|
var POSIX_REGEX_SOURCE = {
|
|
3057
|
+
__proto__: null,
|
|
3056
3058
|
alnum: "a-zA-Z0-9",
|
|
3057
3059
|
alpha: "a-zA-Z",
|
|
3058
3060
|
ascii: "\\x00-\\x7F",
|
|
@@ -3069,6 +3071,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
3069
3071
|
xdigit: "A-Fa-f0-9"
|
|
3070
3072
|
};
|
|
3071
3073
|
module.exports = {
|
|
3074
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
3072
3075
|
MAX_LENGTH: 1024 * 64,
|
|
3073
3076
|
POSIX_REGEX_SOURCE,
|
|
3074
3077
|
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
@@ -3546,6 +3549,213 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
3546
3549
|
var syntaxError = (type2, char) => {
|
|
3547
3550
|
return `Missing ${type2}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
3548
3551
|
};
|
|
3552
|
+
var splitTopLevel = (input) => {
|
|
3553
|
+
const parts = [];
|
|
3554
|
+
let bracket = 0;
|
|
3555
|
+
let paren = 0;
|
|
3556
|
+
let quote = 0;
|
|
3557
|
+
let value = "";
|
|
3558
|
+
let escaped = false;
|
|
3559
|
+
for (const ch of input) {
|
|
3560
|
+
if (escaped === true) {
|
|
3561
|
+
value += ch;
|
|
3562
|
+
escaped = false;
|
|
3563
|
+
continue;
|
|
3564
|
+
}
|
|
3565
|
+
if (ch === "\\") {
|
|
3566
|
+
value += ch;
|
|
3567
|
+
escaped = true;
|
|
3568
|
+
continue;
|
|
3569
|
+
}
|
|
3570
|
+
if (ch === '"') {
|
|
3571
|
+
quote = quote === 1 ? 0 : 1;
|
|
3572
|
+
value += ch;
|
|
3573
|
+
continue;
|
|
3574
|
+
}
|
|
3575
|
+
if (quote === 0) {
|
|
3576
|
+
if (ch === "[") {
|
|
3577
|
+
bracket++;
|
|
3578
|
+
} else if (ch === "]" && bracket > 0) {
|
|
3579
|
+
bracket--;
|
|
3580
|
+
} else if (bracket === 0) {
|
|
3581
|
+
if (ch === "(") {
|
|
3582
|
+
paren++;
|
|
3583
|
+
} else if (ch === ")" && paren > 0) {
|
|
3584
|
+
paren--;
|
|
3585
|
+
} else if (ch === "|" && paren === 0) {
|
|
3586
|
+
parts.push(value);
|
|
3587
|
+
value = "";
|
|
3588
|
+
continue;
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
value += ch;
|
|
3593
|
+
}
|
|
3594
|
+
parts.push(value);
|
|
3595
|
+
return parts;
|
|
3596
|
+
};
|
|
3597
|
+
var isPlainBranch = (branch) => {
|
|
3598
|
+
let escaped = false;
|
|
3599
|
+
for (const ch of branch) {
|
|
3600
|
+
if (escaped === true) {
|
|
3601
|
+
escaped = false;
|
|
3602
|
+
continue;
|
|
3603
|
+
}
|
|
3604
|
+
if (ch === "\\") {
|
|
3605
|
+
escaped = true;
|
|
3606
|
+
continue;
|
|
3607
|
+
}
|
|
3608
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
3609
|
+
return false;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
return true;
|
|
3613
|
+
};
|
|
3614
|
+
var normalizeSimpleBranch = (branch) => {
|
|
3615
|
+
let value = branch.trim();
|
|
3616
|
+
let changed = true;
|
|
3617
|
+
while (changed === true) {
|
|
3618
|
+
changed = false;
|
|
3619
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
3620
|
+
value = value.slice(2, -1);
|
|
3621
|
+
changed = true;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
if (!isPlainBranch(value)) {
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
return value.replace(/\\(.)/g, "$1");
|
|
3628
|
+
};
|
|
3629
|
+
var hasRepeatedCharPrefixOverlap = (branches) => {
|
|
3630
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
3631
|
+
for (let i2 = 0;i2 < values.length; i2++) {
|
|
3632
|
+
for (let j = i2 + 1;j < values.length; j++) {
|
|
3633
|
+
const a = values[i2];
|
|
3634
|
+
const b = values[j];
|
|
3635
|
+
const char = a[0];
|
|
3636
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
3637
|
+
continue;
|
|
3638
|
+
}
|
|
3639
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
3640
|
+
return true;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
return false;
|
|
3645
|
+
};
|
|
3646
|
+
var parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
3647
|
+
if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
let bracket = 0;
|
|
3651
|
+
let paren = 0;
|
|
3652
|
+
let quote = 0;
|
|
3653
|
+
let escaped = false;
|
|
3654
|
+
for (let i2 = 1;i2 < pattern.length; i2++) {
|
|
3655
|
+
const ch = pattern[i2];
|
|
3656
|
+
if (escaped === true) {
|
|
3657
|
+
escaped = false;
|
|
3658
|
+
continue;
|
|
3659
|
+
}
|
|
3660
|
+
if (ch === "\\") {
|
|
3661
|
+
escaped = true;
|
|
3662
|
+
continue;
|
|
3663
|
+
}
|
|
3664
|
+
if (ch === '"') {
|
|
3665
|
+
quote = quote === 1 ? 0 : 1;
|
|
3666
|
+
continue;
|
|
3667
|
+
}
|
|
3668
|
+
if (quote === 1) {
|
|
3669
|
+
continue;
|
|
3670
|
+
}
|
|
3671
|
+
if (ch === "[") {
|
|
3672
|
+
bracket++;
|
|
3673
|
+
continue;
|
|
3674
|
+
}
|
|
3675
|
+
if (ch === "]" && bracket > 0) {
|
|
3676
|
+
bracket--;
|
|
3677
|
+
continue;
|
|
3678
|
+
}
|
|
3679
|
+
if (bracket > 0) {
|
|
3680
|
+
continue;
|
|
3681
|
+
}
|
|
3682
|
+
if (ch === "(") {
|
|
3683
|
+
paren++;
|
|
3684
|
+
continue;
|
|
3685
|
+
}
|
|
3686
|
+
if (ch === ")") {
|
|
3687
|
+
paren--;
|
|
3688
|
+
if (paren === 0) {
|
|
3689
|
+
if (requireEnd === true && i2 !== pattern.length - 1) {
|
|
3690
|
+
return;
|
|
3691
|
+
}
|
|
3692
|
+
return {
|
|
3693
|
+
type: pattern[0],
|
|
3694
|
+
body: pattern.slice(2, i2),
|
|
3695
|
+
end: i2
|
|
3696
|
+
};
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
};
|
|
3701
|
+
var getStarExtglobSequenceOutput = (pattern) => {
|
|
3702
|
+
let index = 0;
|
|
3703
|
+
const chars = [];
|
|
3704
|
+
while (index < pattern.length) {
|
|
3705
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
3706
|
+
if (!match || match.type !== "*") {
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3709
|
+
const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
|
|
3710
|
+
if (branches.length !== 1) {
|
|
3711
|
+
return;
|
|
3712
|
+
}
|
|
3713
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
3714
|
+
if (!branch || branch.length !== 1) {
|
|
3715
|
+
return;
|
|
3716
|
+
}
|
|
3717
|
+
chars.push(branch);
|
|
3718
|
+
index += match.end + 1;
|
|
3719
|
+
}
|
|
3720
|
+
if (chars.length < 1) {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
3724
|
+
return `${source}*`;
|
|
3725
|
+
};
|
|
3726
|
+
var repeatedExtglobRecursion = (pattern) => {
|
|
3727
|
+
let depth = 0;
|
|
3728
|
+
let value = pattern.trim();
|
|
3729
|
+
let match = parseRepeatedExtglob(value);
|
|
3730
|
+
while (match) {
|
|
3731
|
+
depth++;
|
|
3732
|
+
value = match.body.trim();
|
|
3733
|
+
match = parseRepeatedExtglob(value);
|
|
3734
|
+
}
|
|
3735
|
+
return depth;
|
|
3736
|
+
};
|
|
3737
|
+
var analyzeRepeatedExtglob = (body, options) => {
|
|
3738
|
+
if (options.maxExtglobRecursion === false) {
|
|
3739
|
+
return { risky: false };
|
|
3740
|
+
}
|
|
3741
|
+
const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants5.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
3742
|
+
const branches = splitTopLevel(body).map((branch) => branch.trim());
|
|
3743
|
+
if (branches.length > 1) {
|
|
3744
|
+
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
|
|
3745
|
+
return { risky: true };
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
for (const branch of branches) {
|
|
3749
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
3750
|
+
if (safeOutput) {
|
|
3751
|
+
return { risky: true, safeOutput };
|
|
3752
|
+
}
|
|
3753
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
3754
|
+
return { risky: true };
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
return { risky: false };
|
|
3758
|
+
};
|
|
3549
3759
|
var parse3 = (input, options) => {
|
|
3550
3760
|
if (typeof input !== "string") {
|
|
3551
3761
|
throw new TypeError("Expected a string");
|
|
@@ -3677,6 +3887,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
3677
3887
|
token.prev = prev;
|
|
3678
3888
|
token.parens = state3.parens;
|
|
3679
3889
|
token.output = state3.output;
|
|
3890
|
+
token.startIndex = state3.index;
|
|
3891
|
+
token.tokensIndex = tokens.length;
|
|
3680
3892
|
const output = (opts.capture ? "(" : "") + token.open;
|
|
3681
3893
|
increment("parens");
|
|
3682
3894
|
push({ type: type2, value: value2, output: state3.output ? "" : ONE_CHAR });
|
|
@@ -3684,6 +3896,26 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
3684
3896
|
extglobs.push(token);
|
|
3685
3897
|
};
|
|
3686
3898
|
const extglobClose = (token) => {
|
|
3899
|
+
const literal = input.slice(token.startIndex, state3.index + 1);
|
|
3900
|
+
const body = input.slice(token.startIndex + 2, state3.index);
|
|
3901
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
3902
|
+
if ((token.type === "plus" || token.type === "star") && analysis.risky) {
|
|
3903
|
+
const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
|
|
3904
|
+
const open = tokens[token.tokensIndex];
|
|
3905
|
+
open.type = "text";
|
|
3906
|
+
open.value = literal;
|
|
3907
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
3908
|
+
for (let i2 = token.tokensIndex + 1;i2 < tokens.length; i2++) {
|
|
3909
|
+
tokens[i2].value = "";
|
|
3910
|
+
tokens[i2].output = "";
|
|
3911
|
+
delete tokens[i2].suffix;
|
|
3912
|
+
}
|
|
3913
|
+
state3.output = token.output + open.output;
|
|
3914
|
+
state3.backtrack = true;
|
|
3915
|
+
push({ type: "paren", extglob: true, value, output: "" });
|
|
3916
|
+
decrement("parens");
|
|
3917
|
+
return;
|
|
3918
|
+
}
|
|
3687
3919
|
let output = token.close + (opts.capture ? ")" : "");
|
|
3688
3920
|
let rest;
|
|
3689
3921
|
if (token.type === "negate") {
|
|
@@ -19339,13 +19571,11 @@ var AGENT_RESTRICTIONS = {
|
|
|
19339
19571
|
},
|
|
19340
19572
|
metis: {
|
|
19341
19573
|
write: false,
|
|
19342
|
-
edit: false
|
|
19343
|
-
task: false
|
|
19574
|
+
edit: false
|
|
19344
19575
|
},
|
|
19345
19576
|
momus: {
|
|
19346
19577
|
write: false,
|
|
19347
|
-
edit: false
|
|
19348
|
-
task: false
|
|
19578
|
+
edit: false
|
|
19349
19579
|
},
|
|
19350
19580
|
"multimodal-looker": {
|
|
19351
19581
|
read: true
|
|
@@ -67193,8 +67423,9 @@ function createContextWindowMonitorHook(_ctx, modelCacheState) {
|
|
|
67193
67423
|
if (actualUsagePercentage < CONTEXT_WARNING_THRESHOLD)
|
|
67194
67424
|
return;
|
|
67195
67425
|
remindedSessions.add(sessionID);
|
|
67196
|
-
const
|
|
67197
|
-
const
|
|
67426
|
+
const clampedPercentage = Math.min(Math.max(actualUsagePercentage, 0), 1);
|
|
67427
|
+
const usedPct = (clampedPercentage * 100).toFixed(1);
|
|
67428
|
+
const remainingPct = ((1 - clampedPercentage) * 100).toFixed(1);
|
|
67198
67429
|
const usedTokens = totalInputTokens.toLocaleString();
|
|
67199
67430
|
const limitTokens = actualLimit.toLocaleString();
|
|
67200
67431
|
output.output += `
|
|
@@ -67349,8 +67580,12 @@ var getAfplayPath = createCommandFinder("afplay");
|
|
|
67349
67580
|
var getPaplayPath = createCommandFinder("paplay");
|
|
67350
67581
|
var getAplayPath = createCommandFinder("aplay");
|
|
67351
67582
|
var getTerminalNotifierPath = createCommandFinder("terminal-notifier");
|
|
67583
|
+
var getCmuxPath = createCommandFinder("cmux");
|
|
67352
67584
|
function startBackgroundCheck2(platform) {
|
|
67353
67585
|
if (platform === "darwin") {
|
|
67586
|
+
getCmuxPath().catch((error) => {
|
|
67587
|
+
logBackgroundCheckError("cmux", error);
|
|
67588
|
+
});
|
|
67354
67589
|
getOsascriptPath().catch((error) => {
|
|
67355
67590
|
logBackgroundCheckError("osascript", error);
|
|
67356
67591
|
});
|
|
@@ -67423,6 +67658,13 @@ function getDefaultSoundPath(platform2) {
|
|
|
67423
67658
|
async function sendSessionNotification(ctx, platform2, title, message) {
|
|
67424
67659
|
switch (platform2) {
|
|
67425
67660
|
case "darwin": {
|
|
67661
|
+
const cmuxPath = await getCmuxPath();
|
|
67662
|
+
if (cmuxPath) {
|
|
67663
|
+
try {
|
|
67664
|
+
await ctx.$`${cmuxPath} notify --title ${title} --body ${message}`.quiet();
|
|
67665
|
+
break;
|
|
67666
|
+
} catch {}
|
|
67667
|
+
}
|
|
67426
67668
|
const terminalNotifierPath = await getTerminalNotifierPath();
|
|
67427
67669
|
if (terminalNotifierPath) {
|
|
67428
67670
|
const bundleId = process.env.__CFBundleIdentifier;
|
|
@@ -67654,9 +67896,9 @@ function createIdleNotificationScheduler(options) {
|
|
|
67654
67896
|
return;
|
|
67655
67897
|
}
|
|
67656
67898
|
notifiedSessions.add(sessionID);
|
|
67657
|
-
await options.send(options.ctx,
|
|
67899
|
+
await options.send(options.ctx, sessionID);
|
|
67658
67900
|
if (options.config.playSound && options.config.soundPath) {
|
|
67659
|
-
await options.playSound(options.ctx, options.
|
|
67901
|
+
await options.playSound(options.ctx, options.config.soundPath);
|
|
67660
67902
|
}
|
|
67661
67903
|
} finally {
|
|
67662
67904
|
executingNotifications.delete(sessionID);
|
|
@@ -67746,10 +67988,10 @@ function createSessionNotification(ctx, config = {}) {
|
|
|
67746
67988
|
let defaultSoundPath = mergedConfig.soundPath;
|
|
67747
67989
|
const scheduler = createIdleNotificationScheduler({
|
|
67748
67990
|
ctx,
|
|
67749
|
-
platform: "unsupported",
|
|
67750
67991
|
config: mergedConfig,
|
|
67751
67992
|
hasIncompleteTodos,
|
|
67752
|
-
send: async (hookCtx,
|
|
67993
|
+
send: async (hookCtx, sessionID) => {
|
|
67994
|
+
const platform2 = ensureNotificationPlatform();
|
|
67753
67995
|
if (typeof hookCtx.client.session.get !== "function" && typeof hookCtx.client.session.messages !== "function") {
|
|
67754
67996
|
await sendSessionNotification(hookCtx, platform2, mergedConfig.title, mergedConfig.message);
|
|
67755
67997
|
return;
|
|
@@ -67761,7 +68003,10 @@ function createSessionNotification(ctx, config = {}) {
|
|
|
67761
68003
|
});
|
|
67762
68004
|
await sendSessionNotification(hookCtx, platform2, content.title, content.message);
|
|
67763
68005
|
},
|
|
67764
|
-
playSound:
|
|
68006
|
+
playSound: async (hookCtx, soundPath) => {
|
|
68007
|
+
const platform2 = ensureNotificationPlatform();
|
|
68008
|
+
await playSessionNotificationSound(hookCtx, platform2, soundPath);
|
|
68009
|
+
}
|
|
67765
68010
|
});
|
|
67766
68011
|
const QUESTION_TOOLS = new Set(["question", "ask_user_question", "askuserquestion"]);
|
|
67767
68012
|
const PERMISSION_EVENTS = new Set(["permission.ask", "permission.asked", "permission.updated", "permission.requested"]);
|
|
@@ -74560,6 +74805,7 @@ async function runBunInstallWithDetails(options) {
|
|
|
74560
74805
|
try {
|
|
74561
74806
|
const proc = spawnWithWindowsHide(["bun", "install"], {
|
|
74562
74807
|
cwd: cacheDir,
|
|
74808
|
+
env: process.env,
|
|
74563
74809
|
stdout: outputMode,
|
|
74564
74810
|
stderr: outputMode
|
|
74565
74811
|
});
|
|
@@ -76173,7 +76419,7 @@ IF COMPLEX - DO NOT STRUGGLE ALONE. Consult specialists:
|
|
|
76173
76419
|
|
|
76174
76420
|
SYNTHESIZE findings before proceeding.
|
|
76175
76421
|
---
|
|
76176
|
-
MANDATORY delegate_task params: ALWAYS include load_skills
|
|
76422
|
+
MANDATORY delegate_task params: ALWAYS include load_skills and run_in_background when calling delegate_task. Evaluate available skills before dispatch - pass task-appropriate skills when relevant, pass [] ONLY when no skill matches the task domain.
|
|
76177
76423
|
Example: delegate_task(subagent_type="explore", prompt="...", run_in_background=true, load_skills=[])`
|
|
76178
76424
|
}
|
|
76179
76425
|
];
|
|
@@ -87795,7 +88041,7 @@ Task ID: ${task.id}
|
|
|
87795
88041
|
Description: ${task.description}
|
|
87796
88042
|
Agent: ${task.agent}
|
|
87797
88043
|
Status: ${task.status}
|
|
87798
|
-
Session ID: ${task.
|
|
88044
|
+
Session ID: ${task.sessionId ?? "N/A"}
|
|
87799
88045
|
|
|
87800
88046
|
Thinking summary (first ${THINKING_SUMMARY_MAX_CHARS} chars):
|
|
87801
88047
|
${summaryText}
|
|
@@ -87944,7 +88190,7 @@ function createUnstableAgentBabysitterHook(ctx, options) {
|
|
|
87944
88190
|
const lastReminderAt = reminderCooldowns.get(task.id);
|
|
87945
88191
|
if (lastReminderAt && now - lastReminderAt < COOLDOWN_MS)
|
|
87946
88192
|
continue;
|
|
87947
|
-
const summary = task.
|
|
88193
|
+
const summary = task.sessionId ? await getThinkingSummary(ctx, task.sessionId) : null;
|
|
87948
88194
|
const reminder = buildReminder(task, summary, idleMs);
|
|
87949
88195
|
const { agent, model, tools } = await resolveMainSessionTarget(ctx, mainSessionID);
|
|
87950
88196
|
try {
|
|
@@ -96264,7 +96510,7 @@ ${truncated}
|
|
|
96264
96510
|
| Agent | ${task.agent} |
|
|
96265
96511
|
| Status | **${task.status}** |
|
|
96266
96512
|
| ${durationLabel} | ${duration} |
|
|
96267
|
-
| Session ID | \`${task.
|
|
96513
|
+
| Session ID | \`${task.sessionId}\` |${progressSection}
|
|
96268
96514
|
${statusNote}
|
|
96269
96515
|
## Original Prompt
|
|
96270
96516
|
|
|
@@ -96296,11 +96542,11 @@ function extractToolResultText(part) {
|
|
|
96296
96542
|
return [];
|
|
96297
96543
|
}
|
|
96298
96544
|
async function formatFullSession(task, client2, options) {
|
|
96299
|
-
if (!task.
|
|
96545
|
+
if (!task.sessionId) {
|
|
96300
96546
|
return formatTaskStatus(task);
|
|
96301
96547
|
}
|
|
96302
96548
|
const messagesResult = await client2.session.messages({
|
|
96303
|
-
path: { id: task.
|
|
96549
|
+
path: { id: task.sessionId }
|
|
96304
96550
|
});
|
|
96305
96551
|
const errorMessage = getErrorMessage4(messagesResult);
|
|
96306
96552
|
if (errorMessage) {
|
|
@@ -96351,7 +96597,7 @@ async function formatFullSession(task, client2, options) {
|
|
|
96351
96597
|
lines.push(`Task ID: ${task.id}`);
|
|
96352
96598
|
lines.push(`Description: ${task.description}`);
|
|
96353
96599
|
lines.push(`Status: ${task.status}`);
|
|
96354
|
-
lines.push(`Session ID: ${task.
|
|
96600
|
+
lines.push(`Session ID: ${task.sessionId}`);
|
|
96355
96601
|
lines.push(`Total messages: ${normalizedMessages.length}`);
|
|
96356
96602
|
lines.push(`Returned: ${visibleMessages.length}`);
|
|
96357
96603
|
lines.push(`Has more: ${hasMore ? "true" : "false"}`);
|
|
@@ -96471,11 +96717,11 @@ function getTimeString(value) {
|
|
|
96471
96717
|
return typeof value === "string" ? value : "";
|
|
96472
96718
|
}
|
|
96473
96719
|
async function formatTaskResult(task, client2) {
|
|
96474
|
-
if (!task.
|
|
96720
|
+
if (!task.sessionId) {
|
|
96475
96721
|
return `Error: Task has no sessionID`;
|
|
96476
96722
|
}
|
|
96477
96723
|
const messagesResult = await client2.session.messages({
|
|
96478
|
-
path: { id: task.
|
|
96724
|
+
path: { id: task.sessionId }
|
|
96479
96725
|
});
|
|
96480
96726
|
const errorMessage = getErrorMessage4(messagesResult);
|
|
96481
96727
|
if (errorMessage) {
|
|
@@ -96488,7 +96734,7 @@ async function formatTaskResult(task, client2) {
|
|
|
96488
96734
|
Task ID: ${task.id}
|
|
96489
96735
|
Description: ${task.description}
|
|
96490
96736
|
Duration: ${formatDuration(task.startedAt ?? new Date, task.completedAt)}
|
|
96491
|
-
Session ID: ${task.
|
|
96737
|
+
Session ID: ${task.sessionId}
|
|
96492
96738
|
|
|
96493
96739
|
---
|
|
96494
96740
|
|
|
@@ -96501,7 +96747,7 @@ Session ID: ${task.sessionID}
|
|
|
96501
96747
|
Task ID: ${task.id}
|
|
96502
96748
|
Description: ${task.description}
|
|
96503
96749
|
Duration: ${formatDuration(task.startedAt ?? new Date, task.completedAt)}
|
|
96504
|
-
Session ID: ${task.
|
|
96750
|
+
Session ID: ${task.sessionId}
|
|
96505
96751
|
|
|
96506
96752
|
---
|
|
96507
96753
|
|
|
@@ -96519,13 +96765,13 @@ Session ID: ${task.sessionID}
|
|
|
96519
96765
|
Task ID: ${task.id}
|
|
96520
96766
|
Description: ${task.description}
|
|
96521
96767
|
Duration: ${formatDuration(task.startedAt ?? new Date, task.completedAt)}
|
|
96522
|
-
Session ID: ${task.
|
|
96768
|
+
Session ID: ${task.sessionId}
|
|
96523
96769
|
|
|
96524
96770
|
---
|
|
96525
96771
|
|
|
96526
96772
|
Session error: ${sessionError}`;
|
|
96527
96773
|
}
|
|
96528
|
-
const newMessages = consumeNewMessages(task.
|
|
96774
|
+
const newMessages = consumeNewMessages(task.sessionId, sortedMessages);
|
|
96529
96775
|
if (newMessages.length === 0) {
|
|
96530
96776
|
const duration2 = formatDuration(task.startedAt ?? new Date, task.completedAt);
|
|
96531
96777
|
return `Task Result
|
|
@@ -96533,7 +96779,7 @@ Session error: ${sessionError}`;
|
|
|
96533
96779
|
Task ID: ${task.id}
|
|
96534
96780
|
Description: ${task.description}
|
|
96535
96781
|
Duration: ${duration2}
|
|
96536
|
-
Session ID: ${task.
|
|
96782
|
+
Session ID: ${task.sessionId}
|
|
96537
96783
|
|
|
96538
96784
|
---
|
|
96539
96785
|
|
|
@@ -96571,7 +96817,7 @@ Session ID: ${task.sessionID}
|
|
|
96571
96817
|
Task ID: ${task.id}
|
|
96572
96818
|
Description: ${task.description}
|
|
96573
96819
|
Duration: ${duration}
|
|
96574
|
-
Session ID: ${task.
|
|
96820
|
+
Session ID: ${task.sessionId}
|
|
96575
96821
|
|
|
96576
96822
|
---
|
|
96577
96823
|
|
|
@@ -96673,7 +96919,7 @@ function createBackgroundOutput(manager, client2) {
|
|
|
96673
96919
|
agent: task.agent,
|
|
96674
96920
|
category: task.category,
|
|
96675
96921
|
description: task.description,
|
|
96676
|
-
...task.
|
|
96922
|
+
...task.sessionId ? { sessionId: task.sessionId, taskId: task.sessionId } : {}
|
|
96677
96923
|
}
|
|
96678
96924
|
};
|
|
96679
96925
|
await publishToolMetadata(ctx, meta);
|
|
@@ -96719,7 +96965,7 @@ function createBackgroundOutput(manager, client2) {
|
|
|
96719
96965
|
return didTimeoutWhileActive ? appendTimeoutNote(output, timeoutMs) : output;
|
|
96720
96966
|
}
|
|
96721
96967
|
if (resolvedTask.status === "completed") {
|
|
96722
|
-
recordBackgroundOutputConsumption(ctx.sessionID, ctx.messageID, resolvedTask.
|
|
96968
|
+
recordBackgroundOutputConsumption(ctx.sessionID, ctx.messageID, resolvedTask.sessionId);
|
|
96723
96969
|
return await formatTaskResult(resolvedTask, client2);
|
|
96724
96970
|
}
|
|
96725
96971
|
if (resolvedTask.status === "error" || resolvedTask.status === "cancelled" || resolvedTask.status === "interrupt") {
|
|
@@ -96767,7 +97013,7 @@ function createBackgroundCancel(manager, _client) {
|
|
|
96767
97013
|
id: task2.id,
|
|
96768
97014
|
description: task2.description,
|
|
96769
97015
|
status: originalStatus === "pending" ? "pending" : "running",
|
|
96770
|
-
sessionID: task2.
|
|
97016
|
+
sessionID: task2.sessionId
|
|
96771
97017
|
});
|
|
96772
97018
|
}
|
|
96773
97019
|
const tableRows = cancelledInfo.map((t) => `| \`${t.id}\` | ${t.description} | ${t.status} | ${t.sessionID ? `\`${t.sessionID}\`` : "(not started)"} |`).join(`
|
|
@@ -96818,7 +97064,7 @@ Status: ${task.status}`;
|
|
|
96818
97064
|
|
|
96819
97065
|
Task ID: ${task.id}
|
|
96820
97066
|
Description: ${task.description}
|
|
96821
|
-
Session ID: ${task.
|
|
97067
|
+
Session ID: ${task.sessionId}
|
|
96822
97068
|
Status: ${task.status}`;
|
|
96823
97069
|
} catch (error) {
|
|
96824
97070
|
return `[ERROR] Error cancelling task: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -96955,8 +97201,8 @@ async function executeBackground(args, toolContext, manager, client2, fallbackCh
|
|
|
96955
97201
|
description: args.description,
|
|
96956
97202
|
prompt: args.prompt,
|
|
96957
97203
|
agent: args.subagent_type,
|
|
96958
|
-
|
|
96959
|
-
|
|
97204
|
+
parentSessionId: toolContext.sessionID,
|
|
97205
|
+
parentMessageId: toolContext.messageID,
|
|
96960
97206
|
parentAgent,
|
|
96961
97207
|
parentTools: getSessionTools(toolContext.sessionID),
|
|
96962
97208
|
model,
|
|
@@ -96965,7 +97211,7 @@ async function executeBackground(args, toolContext, manager, client2, fallbackCh
|
|
|
96965
97211
|
const WAIT_FOR_SESSION_INTERVAL_MS = 50;
|
|
96966
97212
|
const WAIT_FOR_SESSION_TIMEOUT_MS = 30000;
|
|
96967
97213
|
const waitStart = Date.now();
|
|
96968
|
-
let sessionId = task.
|
|
97214
|
+
let sessionId = task.sessionId;
|
|
96969
97215
|
while (!sessionId && Date.now() - waitStart < WAIT_FOR_SESSION_TIMEOUT_MS) {
|
|
96970
97216
|
const updated = manager.getTask(task.id);
|
|
96971
97217
|
if (updated?.status === "error" || updated?.status === "cancelled" || updated?.status === "interrupt") {
|
|
@@ -96973,7 +97219,7 @@ async function executeBackground(args, toolContext, manager, client2, fallbackCh
|
|
|
96973
97219
|
|
|
96974
97220
|
Task ID: ${task.id}`;
|
|
96975
97221
|
}
|
|
96976
|
-
sessionId = updated?.
|
|
97222
|
+
sessionId = updated?.sessionId;
|
|
96977
97223
|
if (sessionId) {
|
|
96978
97224
|
break;
|
|
96979
97225
|
}
|
|
@@ -98332,13 +98578,13 @@ ${args.prompt}` : args.prompt;
|
|
|
98332
98578
|
const task = await manager.resume({
|
|
98333
98579
|
sessionId: taskID,
|
|
98334
98580
|
prompt: effectivePrompt,
|
|
98335
|
-
|
|
98336
|
-
|
|
98581
|
+
parentSessionId: parentContext.sessionID,
|
|
98582
|
+
parentMessageId: parentContext.messageID,
|
|
98337
98583
|
parentModel: parentContext.model,
|
|
98338
98584
|
parentAgent: parentContext.agent,
|
|
98339
98585
|
parentTools: getSessionTools(parentContext.sessionID)
|
|
98340
98586
|
});
|
|
98341
|
-
const sessionId = task.
|
|
98587
|
+
const sessionId = task.sessionId;
|
|
98342
98588
|
const backgroundTaskId = task.id;
|
|
98343
98589
|
const resolvedModel = resolveMetadataModel(task.model, parentContext.model);
|
|
98344
98590
|
const bgContMeta = {
|
|
@@ -98829,8 +99075,8 @@ async function executeUnstableAgentTask(args, ctx, executorCtx, parentContext, a
|
|
|
98829
99075
|
description: args.description,
|
|
98830
99076
|
prompt: effectivePrompt,
|
|
98831
99077
|
agent: agentToUse,
|
|
98832
|
-
|
|
98833
|
-
|
|
99078
|
+
parentSessionId: parentContext.sessionID,
|
|
99079
|
+
parentMessageId: parentContext.messageID,
|
|
98834
99080
|
parentModel: parentContext.model,
|
|
98835
99081
|
parentAgent: parentContext.agent,
|
|
98836
99082
|
parentTools: getSessionTools(parentContext.sessionID),
|
|
@@ -98843,7 +99089,7 @@ async function executeUnstableAgentTask(args, ctx, executorCtx, parentContext, a
|
|
|
98843
99089
|
launchedTaskID = task.id;
|
|
98844
99090
|
const timing = getTimingConfig();
|
|
98845
99091
|
const waitStart = Date.now();
|
|
98846
|
-
let sessionID = task.
|
|
99092
|
+
let sessionID = task.sessionId;
|
|
98847
99093
|
while (!sessionID && Date.now() - waitStart < timing.WAIT_FOR_SESSION_TIMEOUT_MS) {
|
|
98848
99094
|
if (ctx.abort?.aborted) {
|
|
98849
99095
|
cleanupReason = "Parent aborted while waiting for unstable task session start";
|
|
@@ -98853,7 +99099,7 @@ Task ID: ${task.id}`;
|
|
|
98853
99099
|
}
|
|
98854
99100
|
await new Promise((resolve21) => setTimeout(resolve21, timing.WAIT_FOR_SESSION_INTERVAL_MS));
|
|
98855
99101
|
const updated = manager.getTask(task.id);
|
|
98856
|
-
sessionID = updated?.
|
|
99102
|
+
sessionID = updated?.sessionId;
|
|
98857
99103
|
}
|
|
98858
99104
|
if (!sessionID) {
|
|
98859
99105
|
cleanupReason = "Unstable task session start timed out before session became available";
|
|
@@ -99048,7 +99294,7 @@ function continueSessionSetup(args) {
|
|
|
99048
99294
|
if (updated.status === "error" || updated.status === "cancelled" || updated.status === "interrupt") {
|
|
99049
99295
|
return;
|
|
99050
99296
|
}
|
|
99051
|
-
const sessionId = updated.
|
|
99297
|
+
const sessionId = updated.sessionId;
|
|
99052
99298
|
if (!sessionId) {
|
|
99053
99299
|
continue;
|
|
99054
99300
|
}
|
|
@@ -99070,7 +99316,7 @@ async function waitForBackgroundSessionStart(args) {
|
|
|
99070
99316
|
if (updated?.status === "error" || updated?.status === "cancelled" || updated?.status === "interrupt") {
|
|
99071
99317
|
return;
|
|
99072
99318
|
}
|
|
99073
|
-
sessionId = updated?.
|
|
99319
|
+
sessionId = updated?.sessionId;
|
|
99074
99320
|
if (sessionId) {
|
|
99075
99321
|
return sessionId;
|
|
99076
99322
|
}
|
|
@@ -99092,8 +99338,8 @@ async function executeBackgroundTask(args, ctx, executorCtx, parentContext, agen
|
|
|
99092
99338
|
description: args.description,
|
|
99093
99339
|
prompt: effectivePrompt,
|
|
99094
99340
|
agent: normalizedAgent,
|
|
99095
|
-
|
|
99096
|
-
|
|
99341
|
+
parentSessionId: parentContext.sessionID,
|
|
99342
|
+
parentMessageId: parentContext.messageID,
|
|
99097
99343
|
parentModel: parentContext.model,
|
|
99098
99344
|
parentAgent: parentContext.agent,
|
|
99099
99345
|
parentTools: getSessionTools(parentContext.sessionID),
|
|
@@ -99107,7 +99353,7 @@ async function executeBackgroundTask(args, ctx, executorCtx, parentContext, agen
|
|
|
99107
99353
|
const timing = getTimingConfig();
|
|
99108
99354
|
let sessionId = await waitForBackgroundSessionStart({
|
|
99109
99355
|
taskId: task.id,
|
|
99110
|
-
initialSessionId: task.
|
|
99356
|
+
initialSessionId: task.sessionId,
|
|
99111
99357
|
manager,
|
|
99112
99358
|
timing,
|
|
99113
99359
|
abortSignal: ctx.abort,
|
|
@@ -103742,14 +103988,14 @@ function formatDuration3(start, end) {
|
|
|
103742
103988
|
|
|
103743
103989
|
// src/features/background-agent/background-task-notification-template.ts
|
|
103744
103990
|
function formatAttemptModel(attempt) {
|
|
103745
|
-
if (attempt.
|
|
103746
|
-
return `${attempt.
|
|
103991
|
+
if (attempt.providerId && attempt.modelId) {
|
|
103992
|
+
return `${attempt.providerId}/${attempt.modelId}`;
|
|
103747
103993
|
}
|
|
103748
|
-
if (attempt.
|
|
103749
|
-
return attempt.
|
|
103994
|
+
if (attempt.modelId) {
|
|
103995
|
+
return attempt.modelId;
|
|
103750
103996
|
}
|
|
103751
|
-
if (attempt.
|
|
103752
|
-
return attempt.
|
|
103997
|
+
if (attempt.providerId) {
|
|
103998
|
+
return attempt.providerId;
|
|
103753
103999
|
}
|
|
103754
104000
|
return "unknown-model";
|
|
103755
104001
|
}
|
|
@@ -103759,7 +104005,7 @@ function formatAttemptTimeline(task) {
|
|
|
103759
104005
|
}
|
|
103760
104006
|
const lines = task.attempts.map((attempt) => {
|
|
103761
104007
|
const attemptLines = [
|
|
103762
|
-
` - Attempt ${attempt.attemptNumber} \u2014 ${attempt.status.toUpperCase()} \u2014 ${formatAttemptModel(attempt)} \u2014 ${attempt.
|
|
104008
|
+
` - Attempt ${attempt.attemptNumber} \u2014 ${attempt.status.toUpperCase()} \u2014 ${formatAttemptModel(attempt)} \u2014 ${attempt.sessionId ?? "unknown"}`
|
|
103763
104009
|
];
|
|
103764
104010
|
if (attempt.status !== "completed" && attempt.error) {
|
|
103765
104011
|
attemptLines.push(` Error: ${attempt.error}`);
|
|
@@ -103862,23 +104108,23 @@ async function abortWithTimeout(client2, sessionID, timeoutMs = 1e4) {
|
|
|
103862
104108
|
// src/features/background-agent/attempt-lifecycle.ts
|
|
103863
104109
|
function toAttemptModel(model) {
|
|
103864
104110
|
return {
|
|
103865
|
-
|
|
103866
|
-
|
|
104111
|
+
providerId: model?.providerID,
|
|
104112
|
+
modelId: model?.modelID,
|
|
103867
104113
|
variant: model?.variant
|
|
103868
104114
|
};
|
|
103869
104115
|
}
|
|
103870
104116
|
function toTaskModel(attempt) {
|
|
103871
|
-
if (!attempt.
|
|
104117
|
+
if (!attempt.providerId || !attempt.modelId) {
|
|
103872
104118
|
return;
|
|
103873
104119
|
}
|
|
103874
104120
|
return {
|
|
103875
|
-
providerID: attempt.
|
|
103876
|
-
modelID: attempt.
|
|
104121
|
+
providerID: attempt.providerId,
|
|
104122
|
+
modelID: attempt.modelId,
|
|
103877
104123
|
...attempt.variant ? { variant: attempt.variant } : {}
|
|
103878
104124
|
};
|
|
103879
104125
|
}
|
|
103880
104126
|
function getAttemptIndex(task, attemptID) {
|
|
103881
|
-
return task.attempts?.findIndex((attempt) => attempt.
|
|
104127
|
+
return task.attempts?.findIndex((attempt) => attempt.attemptId === attemptID) ?? -1;
|
|
103882
104128
|
}
|
|
103883
104129
|
function getAttempt(task, attemptID) {
|
|
103884
104130
|
const index = getAttemptIndex(task, attemptID);
|
|
@@ -103899,9 +104145,9 @@ function ensureCurrentAttempt(task, model = task.model) {
|
|
|
103899
104145
|
return existingAttempt;
|
|
103900
104146
|
}
|
|
103901
104147
|
const attempt = {
|
|
103902
|
-
|
|
104148
|
+
attemptId: `att_${crypto.randomUUID().slice(0, 8)}`,
|
|
103903
104149
|
attemptNumber: (task.attempts?.length ?? 0) + 1,
|
|
103904
|
-
|
|
104150
|
+
sessionId: task.sessionId,
|
|
103905
104151
|
...toAttemptModel(model),
|
|
103906
104152
|
status: task.status,
|
|
103907
104153
|
error: task.error,
|
|
@@ -103909,7 +104155,7 @@ function ensureCurrentAttempt(task, model = task.model) {
|
|
|
103909
104155
|
completedAt: task.completedAt
|
|
103910
104156
|
};
|
|
103911
104157
|
task.attempts = [...task.attempts ?? [], attempt];
|
|
103912
|
-
task.currentAttemptID = attempt.
|
|
104158
|
+
task.currentAttemptID = attempt.attemptId;
|
|
103913
104159
|
return attempt;
|
|
103914
104160
|
}
|
|
103915
104161
|
function projectTaskFromCurrentAttempt(task) {
|
|
@@ -103918,7 +104164,7 @@ function projectTaskFromCurrentAttempt(task) {
|
|
|
103918
104164
|
return task;
|
|
103919
104165
|
}
|
|
103920
104166
|
task.status = currentAttempt.status;
|
|
103921
|
-
task.
|
|
104167
|
+
task.sessionId = currentAttempt.sessionId;
|
|
103922
104168
|
task.startedAt = currentAttempt.startedAt;
|
|
103923
104169
|
task.completedAt = currentAttempt.completedAt;
|
|
103924
104170
|
task.error = currentAttempt.error;
|
|
@@ -103927,15 +104173,15 @@ function projectTaskFromCurrentAttempt(task) {
|
|
|
103927
104173
|
}
|
|
103928
104174
|
function startAttempt(task, model) {
|
|
103929
104175
|
const attempt = {
|
|
103930
|
-
|
|
104176
|
+
attemptId: `att_${crypto.randomUUID().slice(0, 8)}`,
|
|
103931
104177
|
attemptNumber: (task.attempts?.length ?? 0) + 1,
|
|
103932
104178
|
...toAttemptModel(model),
|
|
103933
104179
|
status: "pending"
|
|
103934
104180
|
};
|
|
103935
104181
|
task.attempts = [...task.attempts ?? [], attempt];
|
|
103936
|
-
task.currentAttemptID = attempt.
|
|
104182
|
+
task.currentAttemptID = attempt.attemptId;
|
|
103937
104183
|
task.status = "pending";
|
|
103938
|
-
task.
|
|
104184
|
+
task.sessionId = undefined;
|
|
103939
104185
|
task.startedAt = undefined;
|
|
103940
104186
|
task.completedAt = undefined;
|
|
103941
104187
|
task.error = undefined;
|
|
@@ -103951,13 +104197,13 @@ function bindAttemptSession(task, attemptID, sessionID, model) {
|
|
|
103951
104197
|
if (!attempt || isTerminalStatus(attempt.status)) {
|
|
103952
104198
|
return;
|
|
103953
104199
|
}
|
|
103954
|
-
attempt.
|
|
104200
|
+
attempt.sessionId = sessionID;
|
|
103955
104201
|
attempt.status = "running";
|
|
103956
104202
|
attempt.startedAt = new Date;
|
|
103957
104203
|
attempt.completedAt = undefined;
|
|
103958
104204
|
attempt.error = undefined;
|
|
103959
|
-
attempt.
|
|
103960
|
-
attempt.
|
|
104205
|
+
attempt.providerId = model?.providerID ?? attempt.providerId;
|
|
104206
|
+
attempt.modelId = model?.modelID ?? attempt.modelId;
|
|
103961
104207
|
attempt.variant = model?.variant ?? attempt.variant;
|
|
103962
104208
|
return getCurrentAttempt(projectTaskFromCurrentAttempt(task));
|
|
103963
104209
|
}
|
|
@@ -103982,7 +104228,7 @@ function scheduleRetryAttempt(task, failedAttemptID, nextModel, error) {
|
|
|
103982
104228
|
return startAttempt(task, nextModel);
|
|
103983
104229
|
}
|
|
103984
104230
|
function findAttemptBySession(task, sessionID) {
|
|
103985
|
-
return task.attempts?.find((attempt) => attempt.
|
|
104231
|
+
return task.attempts?.find((attempt) => attempt.sessionId === sessionID);
|
|
103986
104232
|
}
|
|
103987
104233
|
|
|
103988
104234
|
// src/features/background-agent/fallback-retry-handler.ts
|
|
@@ -104061,7 +104307,7 @@ async function tryFallbackRetry(args) {
|
|
|
104061
104307
|
clearTimeout(idleTimer);
|
|
104062
104308
|
idleDeferralTimers.delete(task.id);
|
|
104063
104309
|
}
|
|
104064
|
-
const previousSessionID = task.
|
|
104310
|
+
const previousSessionID = task.sessionId;
|
|
104065
104311
|
const previousModel = task.model;
|
|
104066
104312
|
const transformedModelId = transformModelForProvider(providerID, nextFallback.model);
|
|
104067
104313
|
const nextModel = {
|
|
@@ -104070,7 +104316,7 @@ async function tryFallbackRetry(args) {
|
|
|
104070
104316
|
variant: nextFallback.variant
|
|
104071
104317
|
};
|
|
104072
104318
|
task.attemptCount = selectedAttemptCount;
|
|
104073
|
-
const failedAttemptID = ensureCurrentAttempt(task, previousModel).
|
|
104319
|
+
const failedAttemptID = ensureCurrentAttempt(task, previousModel).attemptId;
|
|
104074
104320
|
const nextAttempt = failedAttemptID ? scheduleRetryAttempt(task, failedAttemptID, nextModel, errorInfo.message) : undefined;
|
|
104075
104321
|
if (!nextAttempt) {
|
|
104076
104322
|
return false;
|
|
@@ -104096,8 +104342,8 @@ async function tryFallbackRetry(args) {
|
|
|
104096
104342
|
description: task.description,
|
|
104097
104343
|
prompt: task.prompt,
|
|
104098
104344
|
agent: task.agent,
|
|
104099
|
-
|
|
104100
|
-
|
|
104345
|
+
parentSessionId: task.parentSessionId,
|
|
104346
|
+
parentMessageId: task.parentMessageId,
|
|
104101
104347
|
parentModel: task.parentModel,
|
|
104102
104348
|
parentAgent: task.parentAgent,
|
|
104103
104349
|
parentTools: task.parentTools,
|
|
@@ -104109,7 +104355,7 @@ async function tryFallbackRetry(args) {
|
|
|
104109
104355
|
if (previousSessionID) {
|
|
104110
104356
|
await abortWithTimeout(client2, previousSessionID).catch(() => {});
|
|
104111
104357
|
}
|
|
104112
|
-
queue.push({ task, input: retryInput, attemptID: nextAttempt.
|
|
104358
|
+
queue.push({ task, input: retryInput, attemptID: nextAttempt.attemptId });
|
|
104113
104359
|
queuesByKey.set(key, queue);
|
|
104114
104360
|
processKey(key);
|
|
104115
104361
|
return true;
|
|
@@ -104521,7 +104767,7 @@ async function checkAndInterruptStaleTasks(args) {
|
|
|
104521
104767
|
if (task.status !== "running")
|
|
104522
104768
|
continue;
|
|
104523
104769
|
const startedAt = task.startedAt;
|
|
104524
|
-
const sessionID = task.
|
|
104770
|
+
const sessionID = task.sessionId;
|
|
104525
104771
|
if (!startedAt || !sessionID)
|
|
104526
104772
|
continue;
|
|
104527
104773
|
const sessionStatus = sessionStatuses?.[sessionID]?.type;
|
|
@@ -104728,16 +104974,16 @@ function resolveMessagePartInfo(properties) {
|
|
|
104728
104974
|
return properties;
|
|
104729
104975
|
}
|
|
104730
104976
|
function formatAttemptModelSummary(attempt) {
|
|
104731
|
-
if (!attempt?.
|
|
104977
|
+
if (!attempt?.providerId || !attempt.modelId) {
|
|
104732
104978
|
return;
|
|
104733
104979
|
}
|
|
104734
|
-
return `${attempt.
|
|
104980
|
+
return `${attempt.providerId}/${attempt.modelId}`;
|
|
104735
104981
|
}
|
|
104736
104982
|
function getPreviousAttempt(task, attemptID) {
|
|
104737
104983
|
if (!attemptID || !task.attempts || task.attempts.length === 0) {
|
|
104738
104984
|
return;
|
|
104739
104985
|
}
|
|
104740
|
-
const attemptIndex = task.attempts.findIndex((attempt) => attempt.
|
|
104986
|
+
const attemptIndex = task.attempts.findIndex((attempt) => attempt.attemptId === attemptID);
|
|
104741
104987
|
if (attemptIndex <= 0) {
|
|
104742
104988
|
return;
|
|
104743
104989
|
}
|
|
@@ -104783,18 +105029,20 @@ class BackgroundManager {
|
|
|
104783
105029
|
preStartDescendantReservations;
|
|
104784
105030
|
enableParentSessionNotifications;
|
|
104785
105031
|
modelFallbackControllerAccessor;
|
|
105032
|
+
loggedSessionStatusUnavailable = false;
|
|
104786
105033
|
taskHistory = new TaskHistory;
|
|
104787
105034
|
cachedCircuitBreakerSettings;
|
|
104788
|
-
constructor(
|
|
105035
|
+
constructor(config2) {
|
|
105036
|
+
const { pluginContext, ...options } = config2;
|
|
104789
105037
|
this.tasks = new Map;
|
|
104790
105038
|
this.tasksByParentSession = new Map;
|
|
104791
105039
|
this.notifications = new Map;
|
|
104792
105040
|
this.pendingNotifications = new Map;
|
|
104793
105041
|
this.pendingByParent = new Map;
|
|
104794
|
-
this.client =
|
|
104795
|
-
this.directory =
|
|
104796
|
-
this.concurrencyManager = new ConcurrencyManager(
|
|
104797
|
-
this.config =
|
|
105042
|
+
this.client = pluginContext.client;
|
|
105043
|
+
this.directory = pluginContext.directory;
|
|
105044
|
+
this.concurrencyManager = new ConcurrencyManager(options.config);
|
|
105045
|
+
this.config = options.config;
|
|
104798
105046
|
this.tmuxEnabled = options?.tmuxConfig?.enabled ?? false;
|
|
104799
105047
|
this.onSubagentSessionCreated = options?.onSubagentSessionCreated;
|
|
104800
105048
|
this.onShutdown = options?.onShutdown;
|
|
@@ -104869,30 +105117,30 @@ class BackgroundManager {
|
|
|
104869
105117
|
if (!this.preStartDescendantReservations.delete(task.id)) {
|
|
104870
105118
|
return;
|
|
104871
105119
|
}
|
|
104872
|
-
if (!task.
|
|
105120
|
+
if (!task.rootSessionId) {
|
|
104873
105121
|
return;
|
|
104874
105122
|
}
|
|
104875
|
-
this.unregisterRootDescendant(task.
|
|
105123
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
104876
105124
|
}
|
|
104877
105125
|
addTask(task) {
|
|
104878
105126
|
this.tasks.set(task.id, task);
|
|
104879
|
-
if (!task.
|
|
105127
|
+
if (!task.parentSessionId) {
|
|
104880
105128
|
return;
|
|
104881
105129
|
}
|
|
104882
|
-
const taskIDs = this.tasksByParentSession.get(task.
|
|
105130
|
+
const taskIDs = this.tasksByParentSession.get(task.parentSessionId) ?? new Set;
|
|
104883
105131
|
taskIDs.add(task.id);
|
|
104884
|
-
this.tasksByParentSession.set(task.
|
|
105132
|
+
this.tasksByParentSession.set(task.parentSessionId, taskIDs);
|
|
104885
105133
|
}
|
|
104886
105134
|
removeTask(task) {
|
|
104887
105135
|
this.tasks.delete(task.id);
|
|
104888
|
-
this.removeTaskFromParentIndex(task.id, task.
|
|
105136
|
+
this.removeTaskFromParentIndex(task.id, task.parentSessionId);
|
|
104889
105137
|
}
|
|
104890
105138
|
updateTaskParent(task, parentSessionID) {
|
|
104891
|
-
if (task.
|
|
105139
|
+
if (task.parentSessionId === parentSessionID) {
|
|
104892
105140
|
return;
|
|
104893
105141
|
}
|
|
104894
|
-
this.removeTaskFromParentIndex(task.id, task.
|
|
104895
|
-
task.
|
|
105142
|
+
this.removeTaskFromParentIndex(task.id, task.parentSessionId);
|
|
105143
|
+
task.parentSessionId = parentSessionID;
|
|
104896
105144
|
const taskIDs = this.tasksByParentSession.get(parentSessionID) ?? new Set;
|
|
104897
105145
|
taskIDs.add(task.id);
|
|
104898
105146
|
this.tasksByParentSession.set(parentSessionID, taskIDs);
|
|
@@ -104915,15 +105163,15 @@ class BackgroundManager {
|
|
|
104915
105163
|
agent: input.agent,
|
|
104916
105164
|
model: input.model,
|
|
104917
105165
|
description: input.description,
|
|
104918
|
-
parentSessionID: input.
|
|
105166
|
+
parentSessionID: input.parentSessionId
|
|
104919
105167
|
});
|
|
104920
105168
|
if (!input.agent || input.agent.trim() === "") {
|
|
104921
105169
|
throw new Error("Agent parameter is required");
|
|
104922
105170
|
}
|
|
104923
|
-
const spawnReservation = await this.reserveSubagentSpawn(input.
|
|
105171
|
+
const spawnReservation = await this.reserveSubagentSpawn(input.parentSessionId);
|
|
104924
105172
|
try {
|
|
104925
105173
|
log("[background-agent] spawn guard passed", {
|
|
104926
|
-
parentSessionID: input.
|
|
105174
|
+
parentSessionID: input.parentSessionId,
|
|
104927
105175
|
rootSessionID: spawnReservation.spawnContext.rootSessionID,
|
|
104928
105176
|
childDepth: spawnReservation.spawnContext.childDepth,
|
|
104929
105177
|
descendantCount: spawnReservation.descendantCount
|
|
@@ -104932,13 +105180,13 @@ class BackgroundManager {
|
|
|
104932
105180
|
id: `bg_${crypto.randomUUID().slice(0, 8)}`,
|
|
104933
105181
|
status: "pending",
|
|
104934
105182
|
queuedAt: new Date,
|
|
104935
|
-
|
|
105183
|
+
rootSessionId: spawnReservation.spawnContext.rootSessionID,
|
|
104936
105184
|
description: input.description,
|
|
104937
105185
|
prompt: input.prompt,
|
|
104938
105186
|
agent: input.agent,
|
|
104939
105187
|
spawnDepth: spawnReservation.spawnContext.childDepth,
|
|
104940
|
-
|
|
104941
|
-
|
|
105188
|
+
parentSessionId: input.parentSessionId,
|
|
105189
|
+
parentMessageId: input.parentMessageId,
|
|
104942
105190
|
parentModel: input.parentModel,
|
|
104943
105191
|
parentAgent: input.parentAgent,
|
|
104944
105192
|
parentTools: input.parentTools,
|
|
@@ -104949,15 +105197,15 @@ class BackgroundManager {
|
|
|
104949
105197
|
};
|
|
104950
105198
|
const firstAttempt = startAttempt(task, input.model);
|
|
104951
105199
|
this.addTask(task);
|
|
104952
|
-
this.taskHistory.record(input.
|
|
104953
|
-
if (input.
|
|
104954
|
-
const pending = this.pendingByParent.get(input.
|
|
105200
|
+
this.taskHistory.record(input.parentSessionId, { id: task.id, agent: input.agent, description: input.description, status: "pending", category: input.category });
|
|
105201
|
+
if (input.parentSessionId) {
|
|
105202
|
+
const pending = this.pendingByParent.get(input.parentSessionId) ?? new Set;
|
|
104955
105203
|
pending.add(task.id);
|
|
104956
|
-
this.pendingByParent.set(input.
|
|
105204
|
+
this.pendingByParent.set(input.parentSessionId, pending);
|
|
104957
105205
|
}
|
|
104958
105206
|
const key = this.getConcurrencyKeyFromInput(input);
|
|
104959
105207
|
const queue = this.queuesByKey.get(key) ?? [];
|
|
104960
|
-
queue.push({ task, input, attemptID: firstAttempt.
|
|
105208
|
+
queue.push({ task, input, attemptID: firstAttempt.attemptId });
|
|
104961
105209
|
this.queuesByKey.set(key, queue);
|
|
104962
105210
|
log("[background-agent] Task queued:", { taskId: task.id, key, queueLength: queue.length });
|
|
104963
105211
|
const toastManager = getTaskToastManager();
|
|
@@ -105017,11 +105265,11 @@ class BackgroundManager {
|
|
|
105017
105265
|
this.concurrencyManager.release(key);
|
|
105018
105266
|
}
|
|
105019
105267
|
removeTaskToastTracking(item.task.id);
|
|
105020
|
-
if (item.task.
|
|
105021
|
-
await this.abortSessionWithLogging(item.task.
|
|
105268
|
+
if (item.task.sessionId) {
|
|
105269
|
+
await this.abortSessionWithLogging(item.task.sessionId, "startTask error cleanup");
|
|
105022
105270
|
}
|
|
105023
105271
|
this.markForNotification(item.task);
|
|
105024
|
-
this.enqueueNotificationForParent(item.task.
|
|
105272
|
+
this.enqueueNotificationForParent(item.task.parentSessionId, () => this.notifyParentSession(item.task)).catch((err) => {
|
|
105025
105273
|
log("[background-agent] Failed to notify on startTask error:", err);
|
|
105026
105274
|
});
|
|
105027
105275
|
}
|
|
@@ -105032,7 +105280,7 @@ class BackgroundManager {
|
|
|
105032
105280
|
}
|
|
105033
105281
|
async startTask(item) {
|
|
105034
105282
|
const { task, input } = item;
|
|
105035
|
-
const attemptID = item.attemptID ?? ensureCurrentAttempt(task, input.model).
|
|
105283
|
+
const attemptID = item.attemptID ?? ensureCurrentAttempt(task, input.model).attemptId;
|
|
105036
105284
|
log("[background-agent] Starting task:", {
|
|
105037
105285
|
taskId: task.id,
|
|
105038
105286
|
agent: input.agent,
|
|
@@ -105040,7 +105288,7 @@ class BackgroundManager {
|
|
|
105040
105288
|
});
|
|
105041
105289
|
const concurrencyKey = this.getConcurrencyKeyFromInput(input);
|
|
105042
105290
|
const parentSession = await this.client.session.get({
|
|
105043
|
-
path: { id: input.
|
|
105291
|
+
path: { id: input.parentSessionId },
|
|
105044
105292
|
query: { directory: this.directory }
|
|
105045
105293
|
}).catch((err) => {
|
|
105046
105294
|
log(`[background-agent] Failed to get parent session: ${err}`);
|
|
@@ -105050,7 +105298,7 @@ class BackgroundManager {
|
|
|
105050
105298
|
log(`[background-agent] Parent dir: ${parentSession?.data?.directory}, using: ${parentDirectory}`);
|
|
105051
105299
|
const createResult = await this.client.session.create({
|
|
105052
105300
|
body: {
|
|
105053
|
-
parentID: input.
|
|
105301
|
+
parentID: input.parentSessionId,
|
|
105054
105302
|
title: `${input.description} (@${input.agent} subagent)`,
|
|
105055
105303
|
...input.sessionPermission ? { permission: input.sessionPermission } : {}
|
|
105056
105304
|
},
|
|
@@ -105077,13 +105325,13 @@ class BackgroundManager {
|
|
|
105077
105325
|
tmuxEnabled: this.tmuxEnabled,
|
|
105078
105326
|
isInsideTmux: isInsideTmux(),
|
|
105079
105327
|
sessionID,
|
|
105080
|
-
parentID: input.
|
|
105328
|
+
parentID: input.parentSessionId
|
|
105081
105329
|
});
|
|
105082
105330
|
if (this.onSubagentSessionCreated && this.tmuxEnabled && isInsideTmux()) {
|
|
105083
105331
|
log("[background-agent] Invoking tmux callback NOW", { sessionID });
|
|
105084
105332
|
await this.onSubagentSessionCreated({
|
|
105085
105333
|
sessionID,
|
|
105086
|
-
parentID: input.
|
|
105334
|
+
parentID: input.parentSessionId,
|
|
105087
105335
|
title: input.description
|
|
105088
105336
|
}).catch((err) => {
|
|
105089
105337
|
log("[background-agent] Failed to spawn tmux pane:", err);
|
|
@@ -105096,8 +105344,8 @@ class BackgroundManager {
|
|
|
105096
105344
|
if (this.tasks.get(task.id)?.status === "cancelled") {
|
|
105097
105345
|
await this.abortSessionWithLogging(sessionID, "cancelled during tmux setup");
|
|
105098
105346
|
subagentSessions.delete(sessionID);
|
|
105099
|
-
if (task.
|
|
105100
|
-
this.unregisterRootDescendant(task.
|
|
105347
|
+
if (task.rootSessionId) {
|
|
105348
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
105101
105349
|
}
|
|
105102
105350
|
this.concurrencyManager.release(concurrencyKey);
|
|
105103
105351
|
return;
|
|
@@ -105106,8 +105354,8 @@ class BackgroundManager {
|
|
|
105106
105354
|
if (!boundAttempt) {
|
|
105107
105355
|
await this.abortSessionWithLogging(sessionID, "stale attempt binding cleanup");
|
|
105108
105356
|
subagentSessions.delete(sessionID);
|
|
105109
|
-
if (task.
|
|
105110
|
-
this.unregisterRootDescendant(task.
|
|
105357
|
+
if (task.rootSessionId) {
|
|
105358
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
105111
105359
|
}
|
|
105112
105360
|
this.concurrencyManager.release(concurrencyKey);
|
|
105113
105361
|
return;
|
|
@@ -105121,8 +105369,8 @@ class BackgroundManager {
|
|
|
105121
105369
|
if (task.retryNotification) {
|
|
105122
105370
|
const attemptNumber = boundAttempt.attemptNumber;
|
|
105123
105371
|
const retrySessionUrl = buildLocalSessionUrl(parentDirectory, sessionID);
|
|
105124
|
-
const previousAttempt = getPreviousAttempt(task, boundAttempt.
|
|
105125
|
-
const failedSessionID = previousAttempt?.
|
|
105372
|
+
const previousAttempt = getPreviousAttempt(task, boundAttempt.attemptId);
|
|
105373
|
+
const failedSessionID = previousAttempt?.sessionId ?? task.retryNotification.previousSessionID;
|
|
105126
105374
|
const failedSessionLine = failedSessionID ? `
|
|
105127
105375
|
- Failed session: \`${failedSessionID}\`` : "";
|
|
105128
105376
|
const failedModel = formatAttemptModelSummary(previousAttempt) ?? task.retryNotification.failedModel;
|
|
@@ -105132,7 +105380,7 @@ class BackgroundManager {
|
|
|
105132
105380
|
const failedErrorLine = failedError ? `
|
|
105133
105381
|
- Error: ${failedError}` : "";
|
|
105134
105382
|
const retryModel = formatAttemptModelSummary(boundAttempt) ?? task.retryNotification.nextModel;
|
|
105135
|
-
this.queuePendingNotification(task.
|
|
105383
|
+
this.queuePendingNotification(task.parentSessionId, `<system-reminder>
|
|
105136
105384
|
[BACKGROUND TASK RETRY SESSION READY]
|
|
105137
105385
|
**ID:** \`${task.id}\`
|
|
105138
105386
|
**Description:** ${task.description}
|
|
@@ -105145,7 +105393,7 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105145
105393
|
</system-reminder>`);
|
|
105146
105394
|
task.retryNotification = undefined;
|
|
105147
105395
|
}
|
|
105148
|
-
this.taskHistory.record(input.
|
|
105396
|
+
this.taskHistory.record(input.parentSessionId, { id: task.id, sessionID, agent: input.agent, description: input.description, status: "running", category: input.category, startedAt: task.startedAt });
|
|
105149
105397
|
this.startPolling();
|
|
105150
105398
|
log("[background-agent] Launching task:", { taskId: task.id, sessionID, agent: input.agent });
|
|
105151
105399
|
const toastManager = getTaskToastManager();
|
|
@@ -105235,8 +105483,8 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105235
105483
|
existingTask.error = terminalError;
|
|
105236
105484
|
existingTask.completedAt = new Date;
|
|
105237
105485
|
}
|
|
105238
|
-
if (existingTask.
|
|
105239
|
-
this.unregisterRootDescendant(existingTask.
|
|
105486
|
+
if (existingTask.rootSessionId) {
|
|
105487
|
+
this.unregisterRootDescendant(existingTask.rootSessionId);
|
|
105240
105488
|
}
|
|
105241
105489
|
if (existingTask.concurrencyKey) {
|
|
105242
105490
|
this.concurrencyManager.release(existingTask.concurrencyKey);
|
|
@@ -105245,7 +105493,7 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105245
105493
|
removeTaskToastTracking(existingTask.id);
|
|
105246
105494
|
await this.abortSessionWithLogging(sessionID, "launch error cleanup");
|
|
105247
105495
|
this.markForNotification(existingTask);
|
|
105248
|
-
this.enqueueNotificationForParent(existingTask.
|
|
105496
|
+
this.enqueueNotificationForParent(existingTask.parentSessionId, () => this.notifyParentSession(existingTask)).catch((err) => {
|
|
105249
105497
|
log("[background-agent] Failed to notify on error:", err);
|
|
105250
105498
|
});
|
|
105251
105499
|
}
|
|
@@ -105259,7 +105507,7 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105259
105507
|
if (!taskIDs) {
|
|
105260
105508
|
const result = [];
|
|
105261
105509
|
for (const task of this.tasks.values()) {
|
|
105262
|
-
if (task.
|
|
105510
|
+
if (task.parentSessionId === sessionID) {
|
|
105263
105511
|
result.push(task);
|
|
105264
105512
|
}
|
|
105265
105513
|
}
|
|
@@ -105279,8 +105527,8 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105279
105527
|
const directChildren = this.getTasksByParentSession(sessionID);
|
|
105280
105528
|
for (const child of directChildren) {
|
|
105281
105529
|
result.push(child);
|
|
105282
|
-
if (child.
|
|
105283
|
-
const descendants = this.getAllDescendantTasks(child.
|
|
105530
|
+
if (child.sessionId) {
|
|
105531
|
+
const descendants = this.getAllDescendantTasks(child.sessionId);
|
|
105284
105532
|
result.push(...descendants);
|
|
105285
105533
|
}
|
|
105286
105534
|
}
|
|
@@ -105288,7 +105536,7 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105288
105536
|
}
|
|
105289
105537
|
findBySession(sessionID) {
|
|
105290
105538
|
for (const task of this.tasks.values()) {
|
|
105291
|
-
if (task.
|
|
105539
|
+
if (task.sessionId === sessionID) {
|
|
105292
105540
|
return task;
|
|
105293
105541
|
}
|
|
105294
105542
|
if (findAttemptBySession(task, sessionID)) {
|
|
@@ -105307,13 +105555,13 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105307
105555
|
return {
|
|
105308
105556
|
task,
|
|
105309
105557
|
attemptID: undefined,
|
|
105310
|
-
isCurrent: task.
|
|
105558
|
+
isCurrent: task.sessionId === sessionID
|
|
105311
105559
|
};
|
|
105312
105560
|
}
|
|
105313
105561
|
return {
|
|
105314
105562
|
task,
|
|
105315
|
-
attemptID: attempt.
|
|
105316
|
-
isCurrent: task.currentAttemptID === attempt.
|
|
105563
|
+
attemptID: attempt.attemptId,
|
|
105564
|
+
isCurrent: task.currentAttemptID === attempt.attemptId
|
|
105317
105565
|
};
|
|
105318
105566
|
}
|
|
105319
105567
|
getConcurrencyKeyFromInput(input) {
|
|
@@ -105325,10 +105573,10 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105325
105573
|
async trackTask(input) {
|
|
105326
105574
|
const existingTask = this.tasks.get(input.taskId);
|
|
105327
105575
|
if (existingTask) {
|
|
105328
|
-
const parentChanged = input.
|
|
105576
|
+
const parentChanged = input.parentSessionId !== existingTask.parentSessionId;
|
|
105329
105577
|
if (parentChanged) {
|
|
105330
105578
|
this.cleanupPendingByParent(existingTask);
|
|
105331
|
-
this.updateTaskParent(existingTask, input.
|
|
105579
|
+
this.updateTaskParent(existingTask, input.parentSessionId);
|
|
105332
105580
|
}
|
|
105333
105581
|
if (input.parentAgent !== undefined) {
|
|
105334
105582
|
existingTask.parentAgent = input.parentAgent;
|
|
@@ -105336,18 +105584,18 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105336
105584
|
if (!existingTask.concurrencyGroup) {
|
|
105337
105585
|
existingTask.concurrencyGroup = input.concurrencyKey ?? existingTask.agent;
|
|
105338
105586
|
}
|
|
105339
|
-
if (existingTask.
|
|
105340
|
-
subagentSessions.add(existingTask.
|
|
105587
|
+
if (existingTask.sessionId) {
|
|
105588
|
+
subagentSessions.add(existingTask.sessionId);
|
|
105341
105589
|
}
|
|
105342
105590
|
this.startPolling();
|
|
105343
105591
|
if (existingTask.status === "pending" || existingTask.status === "running") {
|
|
105344
|
-
const pending = this.pendingByParent.get(input.
|
|
105592
|
+
const pending = this.pendingByParent.get(input.parentSessionId) ?? new Set;
|
|
105345
105593
|
pending.add(existingTask.id);
|
|
105346
|
-
this.pendingByParent.set(input.
|
|
105594
|
+
this.pendingByParent.set(input.parentSessionId, pending);
|
|
105347
105595
|
} else if (!parentChanged) {
|
|
105348
105596
|
this.cleanupPendingByParent(existingTask);
|
|
105349
105597
|
}
|
|
105350
|
-
log("[background-agent] External task already registered:", { taskId: existingTask.id, sessionID: existingTask.
|
|
105598
|
+
log("[background-agent] External task already registered:", { taskId: existingTask.id, sessionID: existingTask.sessionId, status: existingTask.status });
|
|
105351
105599
|
return existingTask;
|
|
105352
105600
|
}
|
|
105353
105601
|
const concurrencyGroup = input.concurrencyKey ?? input.agent ?? "task";
|
|
@@ -105356,9 +105604,9 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105356
105604
|
}
|
|
105357
105605
|
const task = {
|
|
105358
105606
|
id: input.taskId,
|
|
105359
|
-
|
|
105360
|
-
|
|
105361
|
-
|
|
105607
|
+
sessionId: input.sessionId,
|
|
105608
|
+
parentSessionId: input.parentSessionId,
|
|
105609
|
+
parentMessageId: "",
|
|
105362
105610
|
description: input.description,
|
|
105363
105611
|
prompt: "",
|
|
105364
105612
|
agent: input.agent || "task",
|
|
@@ -105373,15 +105621,15 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105373
105621
|
concurrencyGroup
|
|
105374
105622
|
};
|
|
105375
105623
|
this.addTask(task);
|
|
105376
|
-
subagentSessions.add(input.
|
|
105624
|
+
subagentSessions.add(input.sessionId);
|
|
105377
105625
|
this.startPolling();
|
|
105378
|
-
this.taskHistory.record(input.
|
|
105379
|
-
if (input.
|
|
105380
|
-
const pending = this.pendingByParent.get(input.
|
|
105626
|
+
this.taskHistory.record(input.parentSessionId, { id: task.id, sessionID: input.sessionId, agent: input.agent || "task", description: input.description, status: "running", startedAt: task.startedAt });
|
|
105627
|
+
if (input.parentSessionId) {
|
|
105628
|
+
const pending = this.pendingByParent.get(input.parentSessionId) ?? new Set;
|
|
105381
105629
|
pending.add(task.id);
|
|
105382
|
-
this.pendingByParent.set(input.
|
|
105630
|
+
this.pendingByParent.set(input.parentSessionId, pending);
|
|
105383
105631
|
}
|
|
105384
|
-
log("[background-agent] Registered external task:", { taskId: task.id, sessionID: input.
|
|
105632
|
+
log("[background-agent] Registered external task:", { taskId: task.id, sessionID: input.sessionId });
|
|
105385
105633
|
return task;
|
|
105386
105634
|
}
|
|
105387
105635
|
async resume(input) {
|
|
@@ -105389,13 +105637,13 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105389
105637
|
if (!existingTask) {
|
|
105390
105638
|
throw new Error(`Task not found for session: ${input.sessionId}`);
|
|
105391
105639
|
}
|
|
105392
|
-
if (!existingTask.
|
|
105640
|
+
if (!existingTask.sessionId) {
|
|
105393
105641
|
throw new Error(`Task has no sessionID: ${existingTask.id}`);
|
|
105394
105642
|
}
|
|
105395
105643
|
if (existingTask.status === "running") {
|
|
105396
105644
|
log("[background-agent] Resume skipped - task already running:", {
|
|
105397
105645
|
taskId: existingTask.id,
|
|
105398
|
-
sessionID: existingTask.
|
|
105646
|
+
sessionID: existingTask.sessionId
|
|
105399
105647
|
});
|
|
105400
105648
|
return existingTask;
|
|
105401
105649
|
}
|
|
@@ -105411,8 +105659,8 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105411
105659
|
existingTask.status = "running";
|
|
105412
105660
|
existingTask.completedAt = undefined;
|
|
105413
105661
|
existingTask.error = undefined;
|
|
105414
|
-
this.updateTaskParent(existingTask, input.
|
|
105415
|
-
existingTask.
|
|
105662
|
+
this.updateTaskParent(existingTask, input.parentSessionId);
|
|
105663
|
+
existingTask.parentMessageId = input.parentMessageId;
|
|
105416
105664
|
existingTask.parentModel = input.parentModel;
|
|
105417
105665
|
existingTask.parentAgent = input.parentAgent;
|
|
105418
105666
|
if (input.parentTools) {
|
|
@@ -105426,13 +105674,13 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105426
105674
|
lastUpdate: new Date
|
|
105427
105675
|
};
|
|
105428
105676
|
this.startPolling();
|
|
105429
|
-
if (existingTask.
|
|
105430
|
-
subagentSessions.add(existingTask.
|
|
105677
|
+
if (existingTask.sessionId) {
|
|
105678
|
+
subagentSessions.add(existingTask.sessionId);
|
|
105431
105679
|
}
|
|
105432
|
-
if (input.
|
|
105433
|
-
const pending = this.pendingByParent.get(input.
|
|
105680
|
+
if (input.parentSessionId) {
|
|
105681
|
+
const pending = this.pendingByParent.get(input.parentSessionId) ?? new Set;
|
|
105434
105682
|
pending.add(existingTask.id);
|
|
105435
|
-
this.pendingByParent.set(input.
|
|
105683
|
+
this.pendingByParent.set(input.parentSessionId, pending);
|
|
105436
105684
|
}
|
|
105437
105685
|
const toastManager = getTaskToastManager();
|
|
105438
105686
|
if (toastManager) {
|
|
@@ -105443,9 +105691,9 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105443
105691
|
isBackground: true
|
|
105444
105692
|
});
|
|
105445
105693
|
}
|
|
105446
|
-
log("[background-agent] Resuming task:", { taskId: existingTask.id, sessionID: existingTask.
|
|
105694
|
+
log("[background-agent] Resuming task:", { taskId: existingTask.id, sessionID: existingTask.sessionId });
|
|
105447
105695
|
log("[background-agent] Resuming task - calling prompt (fire-and-forget) with:", {
|
|
105448
|
-
sessionID: existingTask.
|
|
105696
|
+
sessionID: existingTask.sessionId,
|
|
105449
105697
|
agent: existingTask.agent,
|
|
105450
105698
|
model: existingTask.model,
|
|
105451
105699
|
promptLength: input.prompt.length
|
|
@@ -105456,10 +105704,10 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105456
105704
|
} : undefined;
|
|
105457
105705
|
const resumeVariant = existingTask.model?.variant;
|
|
105458
105706
|
if (existingTask.model) {
|
|
105459
|
-
applySessionPromptParams(existingTask.
|
|
105707
|
+
applySessionPromptParams(existingTask.sessionId, existingTask.model);
|
|
105460
105708
|
}
|
|
105461
105709
|
this.client.session.promptAsync({
|
|
105462
|
-
path: { id: existingTask.
|
|
105710
|
+
path: { id: existingTask.sessionId },
|
|
105463
105711
|
body: {
|
|
105464
105712
|
agent: existingTask.agent,
|
|
105465
105713
|
...resumeModel ? { model: resumeModel } : {},
|
|
@@ -105471,7 +105719,7 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105471
105719
|
question: false,
|
|
105472
105720
|
...getAgentToolRestrictions(existingTask.agent)
|
|
105473
105721
|
};
|
|
105474
|
-
setSessionTools(existingTask.
|
|
105722
|
+
setSessionTools(existingTask.sessionId, tools);
|
|
105475
105723
|
return tools;
|
|
105476
105724
|
})(),
|
|
105477
105725
|
parts: [createInternalAgentTextPart(input.prompt)]
|
|
@@ -105489,19 +105737,19 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105489
105737
|
const errorMessage = errorInfo.message ?? (error instanceof Error ? error.message : String(error));
|
|
105490
105738
|
existingTask.error = errorMessage;
|
|
105491
105739
|
existingTask.completedAt = new Date;
|
|
105492
|
-
if (existingTask.
|
|
105493
|
-
this.unregisterRootDescendant(existingTask.
|
|
105740
|
+
if (existingTask.rootSessionId) {
|
|
105741
|
+
this.unregisterRootDescendant(existingTask.rootSessionId);
|
|
105494
105742
|
}
|
|
105495
105743
|
if (existingTask.concurrencyKey) {
|
|
105496
105744
|
this.concurrencyManager.release(existingTask.concurrencyKey);
|
|
105497
105745
|
existingTask.concurrencyKey = undefined;
|
|
105498
105746
|
}
|
|
105499
105747
|
removeTaskToastTracking(existingTask.id);
|
|
105500
|
-
if (existingTask.
|
|
105501
|
-
await this.abortSessionWithLogging(existingTask.
|
|
105748
|
+
if (existingTask.sessionId) {
|
|
105749
|
+
await this.abortSessionWithLogging(existingTask.sessionId, "resume error cleanup");
|
|
105502
105750
|
}
|
|
105503
105751
|
this.markForNotification(existingTask);
|
|
105504
|
-
this.enqueueNotificationForParent(existingTask.
|
|
105752
|
+
this.enqueueNotificationForParent(existingTask.parentSessionId, () => this.notifyParentSession(existingTask)).catch((err) => {
|
|
105505
105753
|
log("[background-agent] Failed to notify on resume error:", err);
|
|
105506
105754
|
});
|
|
105507
105755
|
});
|
|
@@ -105743,23 +105991,23 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105743
105991
|
const parentSessionsToClear = new Set;
|
|
105744
105992
|
const deletedSessionIDs = new Set([sessionID]);
|
|
105745
105993
|
for (const task of tasksToCancel.values()) {
|
|
105746
|
-
if (task.
|
|
105747
|
-
deletedSessionIDs.add(task.
|
|
105994
|
+
if (task.sessionId) {
|
|
105995
|
+
deletedSessionIDs.add(task.sessionId);
|
|
105748
105996
|
}
|
|
105749
105997
|
}
|
|
105750
105998
|
for (const task of tasksToCancel.values()) {
|
|
105751
|
-
parentSessionsToClear.add(task.
|
|
105999
|
+
parentSessionsToClear.add(task.parentSessionId);
|
|
105752
106000
|
if (task.status === "running" || task.status === "pending") {
|
|
105753
106001
|
this.cancelTask(task.id, {
|
|
105754
106002
|
source: "session.deleted",
|
|
105755
106003
|
reason: "Session deleted"
|
|
105756
106004
|
}).then(() => {
|
|
105757
|
-
if (deletedSessionIDs.has(task.
|
|
105758
|
-
this.pendingNotifications.delete(task.
|
|
106005
|
+
if (deletedSessionIDs.has(task.parentSessionId)) {
|
|
106006
|
+
this.pendingNotifications.delete(task.parentSessionId);
|
|
105759
106007
|
}
|
|
105760
106008
|
}).catch((err) => {
|
|
105761
|
-
if (deletedSessionIDs.has(task.
|
|
105762
|
-
this.pendingNotifications.delete(task.
|
|
106009
|
+
if (deletedSessionIDs.has(task.parentSessionId)) {
|
|
106010
|
+
this.pendingNotifications.delete(task.parentSessionId);
|
|
105763
106011
|
}
|
|
105764
106012
|
log("[background-agent] Failed to cancel task on session.deleted:", { taskId: task.id, error: err });
|
|
105765
106013
|
});
|
|
@@ -105794,8 +106042,8 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105794
106042
|
}
|
|
105795
106043
|
async handleSessionErrorEvent(args) {
|
|
105796
106044
|
const { task, errorInfo, errorMessage, errorName } = args;
|
|
105797
|
-
if (!task.fallbackChain && task.
|
|
105798
|
-
const sessionFallbackChain = this.modelFallbackControllerAccessor?.getSessionFallbackChain(task.
|
|
106045
|
+
if (!task.fallbackChain && task.sessionId) {
|
|
106046
|
+
const sessionFallbackChain = this.modelFallbackControllerAccessor?.getSessionFallbackChain(task.sessionId);
|
|
105799
106047
|
if (sessionFallbackChain?.length) {
|
|
105800
106048
|
task.fallbackChain = sessionFallbackChain;
|
|
105801
106049
|
}
|
|
@@ -105826,10 +106074,10 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105826
106074
|
task.error = errorMsg;
|
|
105827
106075
|
task.completedAt = new Date;
|
|
105828
106076
|
}
|
|
105829
|
-
if (task.
|
|
105830
|
-
this.unregisterRootDescendant(task.
|
|
106077
|
+
if (task.rootSessionId) {
|
|
106078
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
105831
106079
|
}
|
|
105832
|
-
this.taskHistory.record(task.
|
|
106080
|
+
this.taskHistory.record(task.parentSessionId, { id: task.id, sessionID: task.sessionId, agent: task.agent, description: task.description, status: "error", category: task.category, startedAt: task.startedAt, completedAt: task.completedAt });
|
|
105833
106081
|
if (task.concurrencyKey) {
|
|
105834
106082
|
this.concurrencyManager.release(task.concurrencyKey);
|
|
105835
106083
|
task.concurrencyKey = undefined;
|
|
@@ -105851,16 +106099,16 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105851
106099
|
toastManager.removeTask(task.id);
|
|
105852
106100
|
}
|
|
105853
106101
|
this.scheduleTaskRemoval(task.id);
|
|
105854
|
-
if (task.
|
|
105855
|
-
SessionCategoryRegistry.remove(task.
|
|
106102
|
+
if (task.sessionId) {
|
|
106103
|
+
SessionCategoryRegistry.remove(task.sessionId);
|
|
105856
106104
|
}
|
|
105857
106105
|
this.markForNotification(task);
|
|
105858
|
-
this.enqueueNotificationForParent(task.
|
|
106106
|
+
this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task)).catch((err) => {
|
|
105859
106107
|
log("[background-agent] Error in notifyParentSession for errored task:", { taskId: task.id, error: err });
|
|
105860
106108
|
});
|
|
105861
106109
|
}
|
|
105862
106110
|
tryFallbackRetry(task, errorInfo, source) {
|
|
105863
|
-
const previousSessionID = task.
|
|
106111
|
+
const previousSessionID = task.sessionId;
|
|
105864
106112
|
const result = tryFallbackRetry({
|
|
105865
106113
|
task,
|
|
105866
106114
|
errorInfo,
|
|
@@ -105872,17 +106120,17 @@ The fallback retry session is now created and can be inspected directly.
|
|
|
105872
106120
|
processKey: (key) => this.processKey(key),
|
|
105873
106121
|
onRetrying: ({ task: task2, source: source2 }) => {
|
|
105874
106122
|
const currentAttempt = getCurrentAttempt(task2);
|
|
105875
|
-
const previousAttempt = getPreviousAttempt(task2, currentAttempt?.
|
|
106123
|
+
const previousAttempt = getPreviousAttempt(task2, currentAttempt?.attemptId);
|
|
105876
106124
|
const sourceText = source2 ? ` via ${source2}` : "";
|
|
105877
|
-
const failedSessionLine = previousAttempt?.
|
|
105878
|
-
- Failed session: \`${previousAttempt.
|
|
106125
|
+
const failedSessionLine = previousAttempt?.sessionId ? `
|
|
106126
|
+
- Failed session: \`${previousAttempt.sessionId}\`` : "";
|
|
105879
106127
|
const failedModel = formatAttemptModelSummary(previousAttempt);
|
|
105880
106128
|
const failedModelLine = failedModel ? `
|
|
105881
106129
|
- Failed model: \`${failedModel}\`` : "";
|
|
105882
106130
|
const failedErrorLine = previousAttempt?.error ? `
|
|
105883
106131
|
- Error: ${previousAttempt.error}` : "";
|
|
105884
106132
|
const nextModel = formatAttemptModelSummary(currentAttempt);
|
|
105885
|
-
this.queuePendingNotification(task2.
|
|
106133
|
+
this.queuePendingNotification(task2.parentSessionId, `<system-reminder>
|
|
105886
106134
|
[BACKGROUND TASK RETRYING]
|
|
105887
106135
|
**ID:** \`${task2.id}\`
|
|
105888
106136
|
**Description:** ${task2.description}${sourceText}${failedSessionLine}${failedModelLine}${failedErrorLine}${nextModel ? `
|
|
@@ -105902,9 +106150,9 @@ The task was re-queued on a fallback model after a retryable failure.
|
|
|
105902
106150
|
});
|
|
105903
106151
|
}
|
|
105904
106152
|
markForNotification(task) {
|
|
105905
|
-
const queue = this.notifications.get(task.
|
|
106153
|
+
const queue = this.notifications.get(task.parentSessionId) ?? [];
|
|
105906
106154
|
queue.push(task);
|
|
105907
|
-
this.notifications.set(task.
|
|
106155
|
+
this.notifications.set(task.parentSessionId, queue);
|
|
105908
106156
|
}
|
|
105909
106157
|
getPendingNotifications(sessionID) {
|
|
105910
106158
|
return this.notifications.get(sessionID) ?? [];
|
|
@@ -105982,13 +106230,13 @@ ${originalText}`;
|
|
|
105982
106230
|
}
|
|
105983
106231
|
}
|
|
105984
106232
|
cleanupPendingByParent(task) {
|
|
105985
|
-
if (!task.
|
|
106233
|
+
if (!task.parentSessionId)
|
|
105986
106234
|
return;
|
|
105987
|
-
const pending = this.pendingByParent.get(task.
|
|
106235
|
+
const pending = this.pendingByParent.get(task.parentSessionId);
|
|
105988
106236
|
if (pending) {
|
|
105989
106237
|
pending.delete(task.id);
|
|
105990
106238
|
if (pending.size === 0) {
|
|
105991
|
-
this.pendingByParent.delete(task.
|
|
106239
|
+
this.pendingByParent.delete(task.parentSessionId);
|
|
105992
106240
|
}
|
|
105993
106241
|
}
|
|
105994
106242
|
}
|
|
@@ -106011,8 +106259,8 @@ ${originalText}`;
|
|
|
106011
106259
|
const task = this.tasks.get(taskId);
|
|
106012
106260
|
if (!task)
|
|
106013
106261
|
return;
|
|
106014
|
-
if (task.
|
|
106015
|
-
const siblings = this.getTasksByParentSession(task.
|
|
106262
|
+
if (task.parentSessionId) {
|
|
106263
|
+
const siblings = this.getTasksByParentSession(task.parentSessionId);
|
|
106016
106264
|
const runningOrPendingSiblings = siblings.filter((sibling) => sibling.id !== taskId && (sibling.status === "running" || sibling.status === "pending"));
|
|
106017
106265
|
const completedAtTimestamp = task.completedAt?.getTime();
|
|
106018
106266
|
const reachedTaskTtl = completedAtTimestamp !== undefined && Date.now() - completedAtTimestamp >= TASK_TTL_MS;
|
|
@@ -106023,10 +106271,10 @@ ${originalText}`;
|
|
|
106023
106271
|
}
|
|
106024
106272
|
this.clearNotificationsForTask(taskId);
|
|
106025
106273
|
this.removeTask(task);
|
|
106026
|
-
this.clearTaskHistoryWhenParentTasksGone(task.
|
|
106027
|
-
if (task.
|
|
106028
|
-
subagentSessions.delete(task.
|
|
106029
|
-
SessionCategoryRegistry.remove(task.
|
|
106274
|
+
this.clearTaskHistoryWhenParentTasksGone(task.parentSessionId);
|
|
106275
|
+
if (task.sessionId) {
|
|
106276
|
+
subagentSessions.delete(task.sessionId);
|
|
106277
|
+
SessionCategoryRegistry.remove(task.sessionId);
|
|
106030
106278
|
}
|
|
106031
106279
|
log("[background-agent] Removed completed task from memory:", taskId);
|
|
106032
106280
|
}, TASK_CLEANUP_DELAY_MS);
|
|
@@ -106065,10 +106313,10 @@ ${originalText}`;
|
|
|
106065
106313
|
task.error = reason;
|
|
106066
106314
|
}
|
|
106067
106315
|
}
|
|
106068
|
-
if (wasRunning && task.
|
|
106069
|
-
this.unregisterRootDescendant(task.
|
|
106316
|
+
if (wasRunning && task.rootSessionId) {
|
|
106317
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
106070
106318
|
}
|
|
106071
|
-
this.taskHistory.record(task.
|
|
106319
|
+
this.taskHistory.record(task.parentSessionId, { id: task.id, sessionID: task.sessionId, agent: task.agent, description: task.description, status: "cancelled", category: task.category, startedAt: task.startedAt, completedAt: task.completedAt });
|
|
106072
106320
|
if (task.concurrencyKey) {
|
|
106073
106321
|
this.concurrencyManager.release(task.concurrencyKey);
|
|
106074
106322
|
task.concurrencyKey = undefined;
|
|
@@ -106083,9 +106331,9 @@ ${originalText}`;
|
|
|
106083
106331
|
clearTimeout(idleTimer);
|
|
106084
106332
|
this.idleDeferralTimers.delete(task.id);
|
|
106085
106333
|
}
|
|
106086
|
-
if (abortSession && task.
|
|
106087
|
-
await this.abortSessionWithLogging(task.
|
|
106088
|
-
SessionCategoryRegistry.remove(task.
|
|
106334
|
+
if (abortSession && task.sessionId) {
|
|
106335
|
+
await this.abortSessionWithLogging(task.sessionId, `task cancellation (${source})`);
|
|
106336
|
+
SessionCategoryRegistry.remove(task.sessionId);
|
|
106089
106337
|
}
|
|
106090
106338
|
removeTaskToastTracking(task.id);
|
|
106091
106339
|
if (options?.skipNotification) {
|
|
@@ -106096,7 +106344,7 @@ ${originalText}`;
|
|
|
106096
106344
|
}
|
|
106097
106345
|
this.markForNotification(task);
|
|
106098
106346
|
try {
|
|
106099
|
-
await this.enqueueNotificationForParent(task.
|
|
106347
|
+
await this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task));
|
|
106100
106348
|
log(`[background-agent] Task cancelled via ${source}:`, task.id);
|
|
106101
106349
|
} catch (err) {
|
|
106102
106350
|
log("[background-agent] Error in notifyParentSession for cancelled task:", { taskId: task.id, error: err });
|
|
@@ -106148,9 +106396,9 @@ ${originalText}`;
|
|
|
106148
106396
|
task.status = "completed";
|
|
106149
106397
|
task.completedAt = new Date;
|
|
106150
106398
|
}
|
|
106151
|
-
this.taskHistory.record(task.
|
|
106152
|
-
if (task.
|
|
106153
|
-
this.unregisterRootDescendant(task.
|
|
106399
|
+
this.taskHistory.record(task.parentSessionId, { id: task.id, sessionID: task.sessionId, agent: task.agent, description: task.description, status: "completed", category: task.category, startedAt: task.startedAt, completedAt: task.completedAt });
|
|
106400
|
+
if (task.rootSessionId) {
|
|
106401
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
106154
106402
|
}
|
|
106155
106403
|
removeTaskToastTracking(task.id);
|
|
106156
106404
|
if (task.concurrencyKey) {
|
|
@@ -106163,12 +106411,12 @@ ${originalText}`;
|
|
|
106163
106411
|
clearTimeout(idleTimer);
|
|
106164
106412
|
this.idleDeferralTimers.delete(task.id);
|
|
106165
106413
|
}
|
|
106166
|
-
if (task.
|
|
106167
|
-
await this.abortSessionWithLogging(task.
|
|
106168
|
-
SessionCategoryRegistry.remove(task.
|
|
106414
|
+
if (task.sessionId) {
|
|
106415
|
+
await this.abortSessionWithLogging(task.sessionId, `task completion (${source})`);
|
|
106416
|
+
SessionCategoryRegistry.remove(task.sessionId);
|
|
106169
106417
|
}
|
|
106170
106418
|
try {
|
|
106171
|
-
await this.enqueueNotificationForParent(task.
|
|
106419
|
+
await this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task));
|
|
106172
106420
|
log(`[background-agent] Task completed via ${source}:`, task.id);
|
|
106173
106421
|
} catch (err) {
|
|
106174
106422
|
log("[background-agent] Error in notifyParentSession:", { taskId: task.id, error: err });
|
|
@@ -106186,17 +106434,17 @@ ${originalText}`;
|
|
|
106186
106434
|
duration
|
|
106187
106435
|
});
|
|
106188
106436
|
}
|
|
106189
|
-
if (!this.completedTaskSummaries.has(task.
|
|
106190
|
-
this.completedTaskSummaries.set(task.
|
|
106437
|
+
if (!this.completedTaskSummaries.has(task.parentSessionId)) {
|
|
106438
|
+
this.completedTaskSummaries.set(task.parentSessionId, []);
|
|
106191
106439
|
}
|
|
106192
|
-
this.completedTaskSummaries.get(task.
|
|
106440
|
+
this.completedTaskSummaries.get(task.parentSessionId).push({
|
|
106193
106441
|
id: task.id,
|
|
106194
106442
|
description: task.description,
|
|
106195
106443
|
status: task.status,
|
|
106196
106444
|
error: task.error,
|
|
106197
106445
|
attempts: cloneAttempts(task)
|
|
106198
106446
|
});
|
|
106199
|
-
const pendingSet = this.pendingByParent.get(task.
|
|
106447
|
+
const pendingSet = this.pendingByParent.get(task.parentSessionId);
|
|
106200
106448
|
let allComplete = false;
|
|
106201
106449
|
let remainingCount = 0;
|
|
106202
106450
|
if (pendingSet) {
|
|
@@ -106204,15 +106452,15 @@ ${originalText}`;
|
|
|
106204
106452
|
remainingCount = pendingSet.size;
|
|
106205
106453
|
allComplete = remainingCount === 0;
|
|
106206
106454
|
if (allComplete) {
|
|
106207
|
-
this.pendingByParent.delete(task.
|
|
106455
|
+
this.pendingByParent.delete(task.parentSessionId);
|
|
106208
106456
|
}
|
|
106209
106457
|
} else {
|
|
106210
|
-
remainingCount = Array.from(this.tasks.values()).filter((t) => t.
|
|
106458
|
+
remainingCount = Array.from(this.tasks.values()).filter((t) => t.parentSessionId === task.parentSessionId && t.id !== task.id && (t.status === "running" || t.status === "pending")).length;
|
|
106211
106459
|
allComplete = remainingCount === 0;
|
|
106212
106460
|
}
|
|
106213
|
-
const completedTasks = allComplete ? this.completedTaskSummaries.get(task.
|
|
106461
|
+
const completedTasks = allComplete ? this.completedTaskSummaries.get(task.parentSessionId) ?? [{ id: task.id, description: task.description, status: task.status, error: task.error, attempts: cloneAttempts(task) }] : [];
|
|
106214
106462
|
if (allComplete) {
|
|
106215
|
-
this.completedTaskSummaries.delete(task.
|
|
106463
|
+
this.completedTaskSummaries.delete(task.parentSessionId);
|
|
106216
106464
|
}
|
|
106217
106465
|
const statusText = task.status === "completed" ? "COMPLETED" : task.status === "interrupt" ? "INTERRUPTED" : task.status === "error" ? "ERROR" : "CANCELLED";
|
|
106218
106466
|
const notification2 = buildBackgroundTaskNotificationText({
|
|
@@ -106229,9 +106477,9 @@ ${originalText}`;
|
|
|
106229
106477
|
let promptContext = null;
|
|
106230
106478
|
if (this.enableParentSessionNotifications) {
|
|
106231
106479
|
try {
|
|
106232
|
-
const messagesResp = await this.client.session.messages({ path: { id: task.
|
|
106480
|
+
const messagesResp = await this.client.session.messages({ path: { id: task.parentSessionId } });
|
|
106233
106481
|
const messages = normalizeSDKResponse(messagesResp, []);
|
|
106234
|
-
promptContext = resolvePromptContextFromSessionMessages(messages, task.
|
|
106482
|
+
promptContext = resolvePromptContextFromSessionMessages(messages, task.parentSessionId);
|
|
106235
106483
|
const normalizedTools = isRecord15(promptContext?.tools) ? normalizePromptTools(promptContext.tools) : undefined;
|
|
106236
106484
|
if (promptContext?.agent || promptContext?.model || normalizedTools) {
|
|
106237
106485
|
agent = promptContext?.agent ?? task.parentAgent;
|
|
@@ -106242,16 +106490,16 @@ ${originalText}`;
|
|
|
106242
106490
|
if (isAbortedSessionError(error)) {
|
|
106243
106491
|
log("[background-agent] Parent session aborted while loading messages; using messageDir fallback:", {
|
|
106244
106492
|
taskId: task.id,
|
|
106245
|
-
parentSessionID: task.
|
|
106493
|
+
parentSessionID: task.parentSessionId
|
|
106246
106494
|
});
|
|
106247
106495
|
}
|
|
106248
|
-
const messageDir = join95(MESSAGE_STORAGE, task.
|
|
106249
|
-
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.
|
|
106496
|
+
const messageDir = join95(MESSAGE_STORAGE, task.parentSessionId);
|
|
106497
|
+
const currentMessage = messageDir ? findNearestMessageExcludingCompaction(messageDir, task.parentSessionId) : null;
|
|
106250
106498
|
agent = currentMessage?.agent ?? task.parentAgent;
|
|
106251
106499
|
model = currentMessage?.model?.providerID && currentMessage?.model?.modelID ? { providerID: currentMessage.model.providerID, modelID: currentMessage.model.modelID } : undefined;
|
|
106252
106500
|
tools = normalizePromptTools(currentMessage?.tools) ?? tools;
|
|
106253
106501
|
}
|
|
106254
|
-
const resolvedTools = resolveInheritedPromptTools(task.
|
|
106502
|
+
const resolvedTools = resolveInheritedPromptTools(task.parentSessionId, tools);
|
|
106255
106503
|
log("[background-agent] notifyParentSession context:", {
|
|
106256
106504
|
taskId: task.id,
|
|
106257
106505
|
resolvedAgent: agent,
|
|
@@ -106262,7 +106510,7 @@ ${originalText}`;
|
|
|
106262
106510
|
const variant = promptContext?.model?.variant;
|
|
106263
106511
|
try {
|
|
106264
106512
|
await this.client.session.promptAsync({
|
|
106265
|
-
path: { id: task.
|
|
106513
|
+
path: { id: task.parentSessionId },
|
|
106266
106514
|
body: {
|
|
106267
106515
|
noReply: !shouldReply,
|
|
106268
106516
|
...agent !== undefined ? { agent } : {},
|
|
@@ -106282,9 +106530,9 @@ ${originalText}`;
|
|
|
106282
106530
|
if (isAbortedSessionError(error)) {
|
|
106283
106531
|
log("[background-agent] Parent session aborted while sending notification; continuing cleanup:", {
|
|
106284
106532
|
taskId: task.id,
|
|
106285
|
-
parentSessionID: task.
|
|
106533
|
+
parentSessionID: task.parentSessionId
|
|
106286
106534
|
});
|
|
106287
|
-
this.queuePendingNotification(task.
|
|
106535
|
+
this.queuePendingNotification(task.parentSessionId, notification2);
|
|
106288
106536
|
} else {
|
|
106289
106537
|
log("[background-agent] Failed to send notification:", error);
|
|
106290
106538
|
}
|
|
@@ -106292,7 +106540,7 @@ ${originalText}`;
|
|
|
106292
106540
|
} else {
|
|
106293
106541
|
log("[background-agent] Parent session notifications disabled, skipping prompt injection:", {
|
|
106294
106542
|
taskId: task.id,
|
|
106295
|
-
parentSessionID: task.
|
|
106543
|
+
parentSessionID: task.parentSessionId
|
|
106296
106544
|
});
|
|
106297
106545
|
}
|
|
106298
106546
|
if (task.status !== "running" && task.status !== "pending") {
|
|
@@ -106317,10 +106565,10 @@ ${originalText}`;
|
|
|
106317
106565
|
task.status = "error";
|
|
106318
106566
|
task.error = errorMessage;
|
|
106319
106567
|
task.completedAt = new Date;
|
|
106320
|
-
if (!wasPending && task.
|
|
106321
|
-
this.unregisterRootDescendant(task.
|
|
106568
|
+
if (!wasPending && task.rootSessionId) {
|
|
106569
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
106322
106570
|
}
|
|
106323
|
-
this.taskHistory.record(task.
|
|
106571
|
+
this.taskHistory.record(task.parentSessionId, { id: task.id, sessionID: task.sessionId, agent: task.agent, description: task.description, status: "error", category: task.category, startedAt: task.startedAt, completedAt: task.completedAt });
|
|
106324
106572
|
if (task.concurrencyKey) {
|
|
106325
106573
|
this.concurrencyManager.release(task.concurrencyKey);
|
|
106326
106574
|
task.concurrencyKey = undefined;
|
|
@@ -106351,20 +106599,20 @@ ${originalText}`;
|
|
|
106351
106599
|
}
|
|
106352
106600
|
this.cleanupPendingByParent(task);
|
|
106353
106601
|
this.markForNotification(task);
|
|
106354
|
-
this.enqueueNotificationForParent(task.
|
|
106602
|
+
this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task)).catch((err) => {
|
|
106355
106603
|
log("[background-agent] Error in notifyParentSession for stale-pruned task:", { taskId: task.id, error: err });
|
|
106356
106604
|
});
|
|
106357
106605
|
}
|
|
106358
106606
|
});
|
|
106359
106607
|
}
|
|
106360
|
-
async checkAndInterruptStaleTasks(allStatuses
|
|
106608
|
+
async checkAndInterruptStaleTasks(allStatuses) {
|
|
106361
106609
|
await checkAndInterruptStaleTasks({
|
|
106362
106610
|
tasks: this.tasks.values(),
|
|
106363
106611
|
client: this.client,
|
|
106364
106612
|
directory: this.directory,
|
|
106365
106613
|
config: this.config,
|
|
106366
106614
|
concurrencyManager: this.concurrencyManager,
|
|
106367
|
-
notifyParentSession: (task) => this.enqueueNotificationForParent(task.
|
|
106615
|
+
notifyParentSession: (task) => this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task)),
|
|
106368
106616
|
sessionStatuses: allStatuses
|
|
106369
106617
|
});
|
|
106370
106618
|
}
|
|
@@ -106379,10 +106627,10 @@ ${originalText}`;
|
|
|
106379
106627
|
task.error = errorMessage;
|
|
106380
106628
|
task.completedAt = new Date;
|
|
106381
106629
|
}
|
|
106382
|
-
if (task.
|
|
106383
|
-
this.unregisterRootDescendant(task.
|
|
106630
|
+
if (task.rootSessionId) {
|
|
106631
|
+
this.unregisterRootDescendant(task.rootSessionId);
|
|
106384
106632
|
}
|
|
106385
|
-
this.taskHistory.record(task.
|
|
106633
|
+
this.taskHistory.record(task.parentSessionId, { id: task.id, sessionID: task.sessionId, agent: task.agent, description: task.description, status: "error", category: task.category, startedAt: task.startedAt, completedAt: task.completedAt });
|
|
106386
106634
|
if (task.concurrencyKey) {
|
|
106387
106635
|
this.concurrencyManager.release(task.concurrencyKey);
|
|
106388
106636
|
task.concurrencyKey = undefined;
|
|
@@ -106401,11 +106649,11 @@ ${originalText}`;
|
|
|
106401
106649
|
this.clearNotificationsForTask(task.id);
|
|
106402
106650
|
removeTaskToastTracking(task.id);
|
|
106403
106651
|
this.scheduleTaskRemoval(task.id);
|
|
106404
|
-
if (task.
|
|
106405
|
-
SessionCategoryRegistry.remove(task.
|
|
106652
|
+
if (task.sessionId) {
|
|
106653
|
+
SessionCategoryRegistry.remove(task.sessionId);
|
|
106406
106654
|
}
|
|
106407
106655
|
this.markForNotification(task);
|
|
106408
|
-
this.enqueueNotificationForParent(task.
|
|
106656
|
+
this.enqueueNotificationForParent(task.parentSessionId, () => this.notifyParentSession(task)).catch((err) => {
|
|
106409
106657
|
log("[background-agent] Error in notifyParentSession for crashed task:", { taskId: task.id, error: err });
|
|
106410
106658
|
});
|
|
106411
106659
|
}
|
|
@@ -106415,17 +106663,35 @@ ${originalText}`;
|
|
|
106415
106663
|
this.pollingInFlight = true;
|
|
106416
106664
|
try {
|
|
106417
106665
|
this.pruneStaleTasksAndNotifications();
|
|
106418
|
-
|
|
106419
|
-
const
|
|
106666
|
+
let allStatuses;
|
|
106667
|
+
const sessionStatusMethod = this.client?.session?.status;
|
|
106668
|
+
if (typeof sessionStatusMethod !== "function") {
|
|
106669
|
+
if (!this.loggedSessionStatusUnavailable) {
|
|
106670
|
+
log("[background-agent] Unable to poll session statuses:", {
|
|
106671
|
+
reason: "session.status unavailable"
|
|
106672
|
+
});
|
|
106673
|
+
this.loggedSessionStatusUnavailable = true;
|
|
106674
|
+
}
|
|
106675
|
+
} else {
|
|
106676
|
+
try {
|
|
106677
|
+
const statusResult = await this.client.session.status();
|
|
106678
|
+
allStatuses = normalizeSDKResponse(statusResult, {});
|
|
106679
|
+
} catch (error) {
|
|
106680
|
+
if (!this.loggedSessionStatusUnavailable) {
|
|
106681
|
+
log("[background-agent] Error polling session statuses:", { error });
|
|
106682
|
+
this.loggedSessionStatusUnavailable = true;
|
|
106683
|
+
}
|
|
106684
|
+
}
|
|
106685
|
+
}
|
|
106420
106686
|
await this.checkAndInterruptStaleTasks(allStatuses);
|
|
106421
106687
|
for (const task of this.tasks.values()) {
|
|
106422
106688
|
if (task.status !== "running")
|
|
106423
106689
|
continue;
|
|
106424
|
-
const sessionID = task.
|
|
106690
|
+
const sessionID = task.sessionId;
|
|
106425
106691
|
if (!sessionID)
|
|
106426
106692
|
continue;
|
|
106427
106693
|
try {
|
|
106428
|
-
const sessionStatus = allStatuses[sessionID];
|
|
106694
|
+
const sessionStatus = allStatuses?.[sessionID];
|
|
106429
106695
|
if (sessionStatus?.type === "retry") {
|
|
106430
106696
|
const retryMessage = typeof sessionStatus.message === "string" ? sessionStatus.message : undefined;
|
|
106431
106697
|
const errorInfo = { name: "SessionRetry", message: retryMessage };
|
|
@@ -106453,7 +106719,10 @@ ${originalText}`;
|
|
|
106453
106719
|
sessionStatus: sessionStatus.type
|
|
106454
106720
|
});
|
|
106455
106721
|
}
|
|
106456
|
-
|
|
106722
|
+
if (allStatuses === undefined) {
|
|
106723
|
+
continue;
|
|
106724
|
+
}
|
|
106725
|
+
const sessionGoneFromStatus = allStatuses !== undefined && !sessionStatus;
|
|
106457
106726
|
const sessionGoneThresholdReached = sessionGoneFromStatus && (task.consecutiveMissedPolls ?? 0) >= MIN_SESSION_GONE_POLLS;
|
|
106458
106727
|
const completionSource = sessionStatus?.type === "idle" ? "polling (idle status)" : "polling (session gone from status)";
|
|
106459
106728
|
const hasValidOutput = await this.validateSessionHasOutput(sessionID);
|
|
@@ -106498,13 +106767,13 @@ ${originalText}`;
|
|
|
106498
106767
|
const trackedSessionIDs = new Set;
|
|
106499
106768
|
const abortRequests = [];
|
|
106500
106769
|
for (const task of this.tasks.values()) {
|
|
106501
|
-
if (task.
|
|
106502
|
-
trackedSessionIDs.add(task.
|
|
106770
|
+
if (task.sessionId) {
|
|
106771
|
+
trackedSessionIDs.add(task.sessionId);
|
|
106503
106772
|
}
|
|
106504
|
-
if (task.status === "running" && task.
|
|
106773
|
+
if (task.status === "running" && task.sessionId) {
|
|
106505
106774
|
abortRequests.push({
|
|
106506
|
-
sessionID: task.
|
|
106507
|
-
promise: abortWithTimeout(this.client, task.
|
|
106775
|
+
sessionID: task.sessionId,
|
|
106776
|
+
promise: abortWithTimeout(this.client, task.sessionId)
|
|
106508
106777
|
});
|
|
106509
106778
|
}
|
|
106510
106779
|
}
|
|
@@ -118830,8 +119099,7 @@ call_omo_agent(subagent_type="librarian", prompt="I'm looking for proven impleme
|
|
|
118830
119099
|
var metisRestrictions = createAgentToolRestrictions([
|
|
118831
119100
|
"write",
|
|
118832
119101
|
"edit",
|
|
118833
|
-
"apply_patch"
|
|
118834
|
-
"task"
|
|
119102
|
+
"apply_patch"
|
|
118835
119103
|
]);
|
|
118836
119104
|
function createMetisAgent(model) {
|
|
118837
119105
|
return {
|
|
@@ -120348,8 +120616,7 @@ function createMomusAgent(model) {
|
|
|
120348
120616
|
const restrictions = createAgentToolRestrictions([
|
|
120349
120617
|
"write",
|
|
120350
120618
|
"edit",
|
|
120351
|
-
"apply_patch"
|
|
120352
|
-
"task"
|
|
120619
|
+
"apply_patch"
|
|
120353
120620
|
]);
|
|
120354
120621
|
const base = {
|
|
120355
120622
|
description: "Expert reviewer for evaluating work plans against rigorous clarity, verifiability, and completeness standards. (Momus - OhMyOpenCode)",
|
|
@@ -121840,7 +122107,7 @@ function resolvePromptAppend(promptAppend, configDir) {
|
|
|
121840
122107
|
filePath,
|
|
121841
122108
|
projectRoot
|
|
121842
122109
|
});
|
|
121843
|
-
return `[WARNING: Path rejected: ${promptAppend}]`;
|
|
122110
|
+
return `[WARNING: Path rejected: ${promptAppend} (resolved outside project root ${projectRoot}; file:// prompts must reside within the project boundary)]`;
|
|
121844
122111
|
}
|
|
121845
122112
|
if (!existsSync91(filePath)) {
|
|
121846
122113
|
return `[WARNING: Could not resolve file URI: ${promptAppend}]`;
|
|
@@ -126715,7 +126982,9 @@ function createManagers(args) {
|
|
|
126715
126982
|
});
|
|
126716
126983
|
}
|
|
126717
126984
|
});
|
|
126718
|
-
const backgroundManager = new deps.BackgroundManagerClass(
|
|
126985
|
+
const backgroundManager = new deps.BackgroundManagerClass({
|
|
126986
|
+
pluginContext: ctx,
|
|
126987
|
+
config: pluginConfig.background_task,
|
|
126719
126988
|
tmuxConfig,
|
|
126720
126989
|
onSubagentSessionCreated: async (event) => {
|
|
126721
126990
|
log("[create-managers] onSubagentSessionCreated callback received", {
|
|
@@ -127829,11 +128098,24 @@ function createChatMessageHandler3(args) {
|
|
|
127829
128098
|
}
|
|
127830
128099
|
|
|
127831
128100
|
// src/plugin/messages-transform.ts
|
|
128101
|
+
init_logger();
|
|
128102
|
+
async function runMessagesTransformHookSafely(hookName, handler, input, output) {
|
|
128103
|
+
if (!handler)
|
|
128104
|
+
return;
|
|
128105
|
+
try {
|
|
128106
|
+
await Promise.resolve(handler(input, output));
|
|
128107
|
+
} catch (error) {
|
|
128108
|
+
log("[messages-transform] hook execution failed", {
|
|
128109
|
+
hook: hookName,
|
|
128110
|
+
error
|
|
128111
|
+
});
|
|
128112
|
+
}
|
|
128113
|
+
}
|
|
127832
128114
|
function createMessagesTransformHandler(args) {
|
|
127833
128115
|
return async (input, output) => {
|
|
127834
|
-
await args.hooks.contextInjectorMessagesTransform?.["experimental.chat.messages.transform"]
|
|
127835
|
-
await args.hooks.thinkingBlockValidator?.["experimental.chat.messages.transform"]
|
|
127836
|
-
await args.hooks.toolPairValidator?.["experimental.chat.messages.transform"]
|
|
128116
|
+
await runMessagesTransformHookSafely("contextInjectorMessagesTransform", args.hooks.contextInjectorMessagesTransform?.["experimental.chat.messages.transform"], input, output);
|
|
128117
|
+
await runMessagesTransformHookSafely("thinkingBlockValidator", args.hooks.thinkingBlockValidator?.["experimental.chat.messages.transform"], input, output);
|
|
128118
|
+
await runMessagesTransformHookSafely("toolPairValidator", args.hooks.toolPairValidator?.["experimental.chat.messages.transform"], input, output);
|
|
127837
128119
|
};
|
|
127838
128120
|
}
|
|
127839
128121
|
|
|
@@ -133505,7 +133787,7 @@ class PostHog extends PostHogBackendClient {
|
|
|
133505
133787
|
// package.json
|
|
133506
133788
|
var package_default = {
|
|
133507
133789
|
name: "oh-my-opencode",
|
|
133508
|
-
version: "3.17.
|
|
133790
|
+
version: "3.17.13",
|
|
133509
133791
|
description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
133510
133792
|
main: "./dist/index.js",
|
|
133511
133793
|
types: "dist/index.d.ts",
|
|
@@ -133573,7 +133855,7 @@ var package_default = {
|
|
|
133573
133855
|
"js-yaml": "^4.1.1",
|
|
133574
133856
|
"jsonc-parser": "^3.3.1",
|
|
133575
133857
|
picocolors: "^1.1.1",
|
|
133576
|
-
picomatch: "^4.0.
|
|
133858
|
+
picomatch: "^4.0.4",
|
|
133577
133859
|
"posthog-node": "^5.29.2",
|
|
133578
133860
|
"vscode-jsonrpc": "^8.2.0"
|
|
133579
133861
|
},
|
|
@@ -133585,17 +133867,17 @@ var package_default = {
|
|
|
133585
133867
|
zod: "^4.3.0"
|
|
133586
133868
|
},
|
|
133587
133869
|
optionalDependencies: {
|
|
133588
|
-
"oh-my-opencode-darwin-arm64": "3.17.
|
|
133589
|
-
"oh-my-opencode-darwin-x64": "3.17.
|
|
133590
|
-
"oh-my-opencode-darwin-x64-baseline": "3.17.
|
|
133591
|
-
"oh-my-opencode-linux-arm64": "3.17.
|
|
133592
|
-
"oh-my-opencode-linux-arm64-musl": "3.17.
|
|
133593
|
-
"oh-my-opencode-linux-x64": "3.17.
|
|
133594
|
-
"oh-my-opencode-linux-x64-baseline": "3.17.
|
|
133595
|
-
"oh-my-opencode-linux-x64-musl": "3.17.
|
|
133596
|
-
"oh-my-opencode-linux-x64-musl-baseline": "3.17.
|
|
133597
|
-
"oh-my-opencode-windows-x64": "3.17.
|
|
133598
|
-
"oh-my-opencode-windows-x64-baseline": "3.17.
|
|
133870
|
+
"oh-my-opencode-darwin-arm64": "3.17.13",
|
|
133871
|
+
"oh-my-opencode-darwin-x64": "3.17.13",
|
|
133872
|
+
"oh-my-opencode-darwin-x64-baseline": "3.17.13",
|
|
133873
|
+
"oh-my-opencode-linux-arm64": "3.17.13",
|
|
133874
|
+
"oh-my-opencode-linux-arm64-musl": "3.17.13",
|
|
133875
|
+
"oh-my-opencode-linux-x64": "3.17.13",
|
|
133876
|
+
"oh-my-opencode-linux-x64-baseline": "3.17.13",
|
|
133877
|
+
"oh-my-opencode-linux-x64-musl": "3.17.13",
|
|
133878
|
+
"oh-my-opencode-linux-x64-musl-baseline": "3.17.13",
|
|
133879
|
+
"oh-my-opencode-windows-x64": "3.17.13",
|
|
133880
|
+
"oh-my-opencode-windows-x64-baseline": "3.17.13"
|
|
133599
133881
|
},
|
|
133600
133882
|
overrides: {},
|
|
133601
133883
|
trustedDependencies: [
|
|
@@ -133674,21 +133956,6 @@ function getPostHogActivityCaptureState(now = new Date) {
|
|
|
133674
133956
|
captureDaily
|
|
133675
133957
|
};
|
|
133676
133958
|
}
|
|
133677
|
-
function getPluginLoadedCaptureState(now = new Date) {
|
|
133678
|
-
const state3 = readPostHogActivityState();
|
|
133679
|
-
const dayUTC = getUtcDayString(now);
|
|
133680
|
-
const capturePluginLoaded = state3.lastPluginLoadedDayUTC !== dayUTC;
|
|
133681
|
-
if (capturePluginLoaded) {
|
|
133682
|
-
writePostHogActivityState({
|
|
133683
|
-
...state3,
|
|
133684
|
-
lastPluginLoadedDayUTC: dayUTC
|
|
133685
|
-
});
|
|
133686
|
-
}
|
|
133687
|
-
return {
|
|
133688
|
-
dayUTC,
|
|
133689
|
-
capturePluginLoaded
|
|
133690
|
-
};
|
|
133691
|
-
}
|
|
133692
133959
|
|
|
133693
133960
|
// src/shared/posthog.ts
|
|
133694
133961
|
var activityStateProviderOverride = null;
|
|
@@ -133698,12 +133965,6 @@ function resolveActivityState() {
|
|
|
133698
133965
|
var DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
|
|
133699
133966
|
var DEFAULT_POSTHOG_API_KEY = "phc_CFJhj5HyvA62QPhvyaUCtaq23aUfznnijg5VaaGkNk74";
|
|
133700
133967
|
var NO_OP_POSTHOG = {
|
|
133701
|
-
capture: () => {
|
|
133702
|
-
return;
|
|
133703
|
-
},
|
|
133704
|
-
captureException: () => {
|
|
133705
|
-
return;
|
|
133706
|
-
},
|
|
133707
133968
|
trackActive: () => {
|
|
133708
133969
|
return;
|
|
133709
133970
|
},
|
|
@@ -133777,21 +134038,6 @@ function createPostHogClient(source, options) {
|
|
|
133777
134038
|
}
|
|
133778
134039
|
const sharedProperties = getSharedProperties(source);
|
|
133779
134040
|
return {
|
|
133780
|
-
capture: (message) => {
|
|
133781
|
-
configuredClient.capture({
|
|
133782
|
-
...message,
|
|
133783
|
-
properties: {
|
|
133784
|
-
...sharedProperties,
|
|
133785
|
-
...message.properties
|
|
133786
|
-
}
|
|
133787
|
-
});
|
|
133788
|
-
},
|
|
133789
|
-
captureException: (error, distinctId, additionalProperties) => {
|
|
133790
|
-
configuredClient.captureException(error, distinctId, {
|
|
133791
|
-
...sharedProperties,
|
|
133792
|
-
...additionalProperties
|
|
133793
|
-
});
|
|
133794
|
-
},
|
|
133795
134041
|
trackActive: (distinctId, reason) => {
|
|
133796
134042
|
const activityState = resolveActivityState();
|
|
133797
134043
|
if (activityState.captureDaily) {
|
|
@@ -133800,6 +134046,7 @@ function createPostHogClient(source, options) {
|
|
|
133800
134046
|
event: "omo_daily_active",
|
|
133801
134047
|
properties: {
|
|
133802
134048
|
...sharedProperties,
|
|
134049
|
+
$process_person_profile: false,
|
|
133803
134050
|
day_utc: activityState.dayUTC,
|
|
133804
134051
|
reason
|
|
133805
134052
|
}
|
|
@@ -133839,23 +134086,6 @@ var serverPlugin = async (input, _options) => {
|
|
|
133839
134086
|
try {
|
|
133840
134087
|
posthog.trackActive(distinctId, "plugin_loaded");
|
|
133841
134088
|
} catch {}
|
|
133842
|
-
let pluginLoadedCaptureState = null;
|
|
133843
|
-
try {
|
|
133844
|
-
pluginLoadedCaptureState = getPluginLoadedCaptureState();
|
|
133845
|
-
} catch {}
|
|
133846
|
-
if (pluginLoadedCaptureState?.capturePluginLoaded) {
|
|
133847
|
-
try {
|
|
133848
|
-
posthog.capture({
|
|
133849
|
-
distinctId,
|
|
133850
|
-
event: "plugin_loaded",
|
|
133851
|
-
properties: {
|
|
133852
|
-
entry_point: "plugin",
|
|
133853
|
-
has_openclaw: !!pluginConfig.openclaw,
|
|
133854
|
-
tmux_enabled: isTmuxIntegrationEnabled(pluginConfig)
|
|
133855
|
-
}
|
|
133856
|
-
});
|
|
133857
|
-
} catch {}
|
|
133858
|
-
}
|
|
133859
134089
|
if (pluginConfig.openclaw) {
|
|
133860
134090
|
await initializeOpenClaw(pluginConfig.openclaw);
|
|
133861
134091
|
}
|