charness 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/agent-plugin/skills/charness-orchestration/SKILL.md +6 -0
- package/dist/apiRetryKick.d.ts +15 -5
- package/dist/apiRetryKick.d.ts.map +1 -1
- package/dist/apiRetryKick.js +13 -8
- package/dist/apiRetryKick.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +47 -20
- package/dist/bot.js.map +1 -1
- package/dist/connectors/jira/answerSink.d.ts.map +1 -1
- package/dist/connectors/jira/answerSink.js +3 -1
- package/dist/connectors/jira/answerSink.js.map +1 -1
- package/dist/requests/requestHeader.d.ts.map +1 -1
- package/dist/requests/requestHeader.js +30 -6
- package/dist/requests/requestHeader.js.map +1 -1
- package/dist/requests/sessionTurnProbe.d.ts +6 -1
- package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
- package/dist/requests/sessionTurnProbe.js +4 -0
- package/dist/requests/sessionTurnProbe.js.map +1 -1
- package/dist/requests/types.d.ts +18 -4
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +13 -1
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +69 -8
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +63 -2
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +67 -36
- package/dist/requests/wakeUpRules.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +30 -1
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +72 -14
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/shutdown.d.ts +12 -0
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +11 -0
- package/dist/shutdown.js.map +1 -1
- package/dist/utils/limitSwitchPlan.d.ts +51 -14
- package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
- package/dist/utils/limitSwitchPlan.js +33 -15
- package/dist/utils/limitSwitchPlan.js.map +1 -1
- package/dist/utils/workingSignals.d.ts +10 -0
- package/dist/utils/workingSignals.d.ts.map +1 -1
- package/dist/utils/workingSignals.js +22 -3
- package/dist/utils/workingSignals.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/shutdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;
|
|
1
|
+
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAkHH,4CAsGC;AAtND;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,KAAK,CAAC;AAoEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACI,KAAK,UAAU,gBAAgB,CAAC,IAAkB;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,2BAAmB,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,6BAA6B,CAAC,CAAC;IAEnD,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,MAAM,UAAU,GAAG,CAAC,IAAY,EAAQ,EAAE;QACxC,IAAI,aAAa;YAAE,OAAO;QAC1B,aAAa,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC;YACH,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QAAC,OA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AAE,UAAU,CAAC,CAAC;QACnE,qEAAqE;QACrE,sEAAsE;QACtE,4DAA4D;QAC5D,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;IAC/D,IAAI,cAAc;QAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAEjD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC1B,GAAG,CACD,mCAAmC,UAAU,oBAAoB;YAC/D,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,UAAU,CAAC,CAAC,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description The pure decision behind «a conversation hit its usage limit — may it move on, and where to»
|
|
3
3
|
* (`bot.ts` `planFallbackSwitch` wires it): the candidates (the operator's fallback chain, or, with none, the ranking of the
|
|
4
|
-
* signed-in Claude accounts — `utils/claudeLimitSwitch.ts`), then auto / offer / none (`decideFallbackSwitch`), and the
|
|
5
|
-
* wait with nothing to switch to
|
|
4
|
+
* signed-in Claude accounts — `utils/claudeLimitSwitch.ts`), then auto / offer / none (`decideFallbackSwitch`), and the rung a
|
|
5
|
+
* wait with nothing to switch to is aimed at.
|
|
6
6
|
*
|
|
7
7
|
* WHO it applies to. A Telegram topic takes all of it. A conversation of another platform (a Jira issue; no `checkIsTelegramKey`)
|
|
8
|
-
* takes the AUTOMATIC
|
|
8
|
+
* takes the AUTOMATIC moves between Claude accounts only: the chain's Claude rungs (an OpenCode rung is a cross-backend hand-over
|
|
9
9
|
* that has no surface outside Telegram; a list with no Claude rung restricts no account, as for agents —
|
|
10
|
-
* `getClaudeLaunchChainScope`), never the offer (its «🔁 Switch to …» buttons are a topic's)
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* `getClaudeLaunchChainScope`), never the offer (its «🔁 Switch to …» buttons are a topic's). With no account free it waits for
|
|
11
|
+
* the Claude account whose limit resets EARLIEST and the retry kick moves it there — the same automatic move, made later. With
|
|
12
|
+
* auto-switch OFF it waits for its own account's reset — also when the switch is turned OFF during such a wait
|
|
13
|
+
* (`decideAimedWaitEnd`) — and on OpenCode it has nothing to decide.
|
|
13
14
|
*
|
|
14
15
|
* No I/O, no `Date.now()`: the caller passes the clock and the detection, so every rule is unit-tested.
|
|
15
16
|
*/
|
|
16
17
|
import { type FallbackChainEntry, type FallbackDetection, type FallbackSwitchPlan } from './fallbackChain';
|
|
17
18
|
/**
|
|
18
|
-
* @description Whether
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* @description Whether the rung `rung` can take part in a usage-limit move at all — as the one a conversation runs on when the limit
|
|
20
|
+
* hits (does it lead to a switch decision), or as the one it moves onto, now or when a wait aimed at it ends: in a Telegram topic any
|
|
21
|
+
* rung, elsewhere only a Claude account — a hand-over to OpenCode has no surface outside Telegram. (The caller has already dropped a
|
|
22
|
+
* conversation with no rung to leave — a terminal, no agent, an OpenCode server on its default model.)
|
|
21
23
|
*/
|
|
22
|
-
export declare function checkIsLimitSwitchPossible(isTelegram: boolean,
|
|
24
|
+
export declare function checkIsLimitSwitchPossible(isTelegram: boolean, rung: FallbackChainEntry): boolean;
|
|
25
|
+
/** The rung a usage-limit wait is re-aimed at — the one whose limit resets first — and when that limit ends. */
|
|
26
|
+
export interface LimitWaitTarget {
|
|
27
|
+
entry: FallbackChainEntry;
|
|
28
|
+
untilMs: number;
|
|
29
|
+
}
|
|
23
30
|
export interface LimitSwitchDecision {
|
|
24
31
|
plan: FallbackSwitchPlan;
|
|
25
32
|
/**
|
|
26
|
-
* When `plan` is `none`:
|
|
27
|
-
*
|
|
28
|
-
*
|
|
33
|
+
* When `plan` is `none`: ANOTHER rung whose limit resets EARLIEST (`pickEarliestResetRung`), so the armed wait ends there and the
|
|
34
|
+
* retry kick moves the conversation onto it; `null` when the conversation's own rung resets first (or within a minute of the first)
|
|
35
|
+
* or no other one names a reset. Picked from the operator's chain (outside Telegram its Claude rungs), else the signed-in
|
|
36
|
+
* SUBSCRIPTIONS (an account billed to API credits never ends a wait by itself). Always `null` when the plan is not `none`, and
|
|
37
|
+
* outside Telegram with auto-switch OFF: there the wait's end moves the conversation by itself, which that switch forbids.
|
|
29
38
|
*/
|
|
30
|
-
|
|
39
|
+
waitTarget: LimitWaitTarget | null;
|
|
31
40
|
}
|
|
32
41
|
/**
|
|
33
42
|
* @description What the usage limit of the rung `from` leads to. `chain` is the operator's fallback chain as stored (empty = none);
|
|
@@ -41,4 +50,32 @@ export declare function decideLimitSwitch(input: {
|
|
|
41
50
|
isAutoSwitchEnabled: boolean;
|
|
42
51
|
nowMs: number;
|
|
43
52
|
}): LimitSwitchDecision;
|
|
53
|
+
/** What the end of a usage-limit wait aimed at another rung does ({@link decideAimedWaitEnd}). */
|
|
54
|
+
export type AimedWaitEnd =
|
|
55
|
+
/** Move the conversation onto the rung the wait was aimed at. */
|
|
56
|
+
{
|
|
57
|
+
action: 'move';
|
|
58
|
+
}
|
|
59
|
+
/** Stay, and wait again until the conversation's own account is back (`untilMs`). */
|
|
60
|
+
| {
|
|
61
|
+
action: 'waitOwnReset';
|
|
62
|
+
untilMs: number;
|
|
63
|
+
}
|
|
64
|
+
/** Stay, and resume here now: its own account names no reset still ahead. */
|
|
65
|
+
| {
|
|
66
|
+
action: 'resumeHere';
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* @description What the end of a usage-limit wait aimed at another rung (the retry record's `resumeOn`) does. A topic moves there
|
|
70
|
+
* whatever its switch says: its aimed wait is armed with auto-switch OFF too. Outside Telegram only the automatic switch moves a
|
|
71
|
+
* conversation, and the wait was aimed only while it was ON: turned OFF since, the conversation stays on its own account — waiting
|
|
72
|
+
* again until that account is back (`ownLimitedUntilMs`, its limit mark) while that lies ahead, rather than resuming into a limit
|
|
73
|
+
* it is known to hit; resumed now when its account names no reset ahead.
|
|
74
|
+
*/
|
|
75
|
+
export declare function decideAimedWaitEnd(input: {
|
|
76
|
+
isTelegram: boolean;
|
|
77
|
+
isAutoSwitchEnabled: boolean;
|
|
78
|
+
ownLimitedUntilMs: number | null;
|
|
79
|
+
nowMs: number;
|
|
80
|
+
}): AimedWaitEnd;
|
|
44
81
|
//# sourceMappingURL=limitSwitchPlan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limitSwitchPlan.d.ts","sourceRoot":"","sources":["../../src/utils/limitSwitchPlan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"limitSwitchPlan.d.ts","sourceRoot":"","sources":["../../src/utils/limitSwitchPlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAEjG;AAED,gHAAgH;AAChH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,kBAAkB,CAAC;IACzB;;;;;;OAMG;IACH,UAAU,EAAE,eAAe,GAAG,IAAI,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,KAAK,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,mBAAmB,CAoBtB;AAED,kGAAkG;AAClG,MAAM,MAAM,YAAY;AACtB,iEAAiE;AAC/D;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;AACpB,qFAAqF;GACnF;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AAC7C,6EAA6E;GAC3E;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,CAAC;AAE7B;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,mBAAmB,EAAE,OAAO,CAAC;IAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,YAAY,CAI9J"}
|
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @description The pure decision behind «a conversation hit its usage limit — may it move on, and where to»
|
|
4
4
|
* (`bot.ts` `planFallbackSwitch` wires it): the candidates (the operator's fallback chain, or, with none, the ranking of the
|
|
5
|
-
* signed-in Claude accounts — `utils/claudeLimitSwitch.ts`), then auto / offer / none (`decideFallbackSwitch`), and the
|
|
6
|
-
* wait with nothing to switch to
|
|
5
|
+
* signed-in Claude accounts — `utils/claudeLimitSwitch.ts`), then auto / offer / none (`decideFallbackSwitch`), and the rung a
|
|
6
|
+
* wait with nothing to switch to is aimed at.
|
|
7
7
|
*
|
|
8
8
|
* WHO it applies to. A Telegram topic takes all of it. A conversation of another platform (a Jira issue; no `checkIsTelegramKey`)
|
|
9
|
-
* takes the AUTOMATIC
|
|
9
|
+
* takes the AUTOMATIC moves between Claude accounts only: the chain's Claude rungs (an OpenCode rung is a cross-backend hand-over
|
|
10
10
|
* that has no surface outside Telegram; a list with no Claude rung restricts no account, as for agents —
|
|
11
|
-
* `getClaudeLaunchChainScope`), never the offer (its «🔁 Switch to …» buttons are a topic's)
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* `getClaudeLaunchChainScope`), never the offer (its «🔁 Switch to …» buttons are a topic's). With no account free it waits for
|
|
12
|
+
* the Claude account whose limit resets EARLIEST and the retry kick moves it there — the same automatic move, made later. With
|
|
13
|
+
* auto-switch OFF it waits for its own account's reset — also when the switch is turned OFF during such a wait
|
|
14
|
+
* (`decideAimedWaitEnd`) — and on OpenCode it has nothing to decide.
|
|
14
15
|
*
|
|
15
16
|
* No I/O, no `Date.now()`: the caller passes the clock and the detection, so every rule is unit-tested.
|
|
16
17
|
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.checkIsLimitSwitchPossible = checkIsLimitSwitchPossible;
|
|
19
20
|
exports.decideLimitSwitch = decideLimitSwitch;
|
|
21
|
+
exports.decideAimedWaitEnd = decideAimedWaitEnd;
|
|
20
22
|
const claudeLimitSwitch_1 = require("./claudeLimitSwitch");
|
|
21
23
|
const fallbackChain_1 = require("./fallbackChain");
|
|
22
24
|
/**
|
|
23
|
-
* @description Whether
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* @description Whether the rung `rung` can take part in a usage-limit move at all — as the one a conversation runs on when the limit
|
|
26
|
+
* hits (does it lead to a switch decision), or as the one it moves onto, now or when a wait aimed at it ends: in a Telegram topic any
|
|
27
|
+
* rung, elsewhere only a Claude account — a hand-over to OpenCode has no surface outside Telegram. (The caller has already dropped a
|
|
28
|
+
* conversation with no rung to leave — a terminal, no agent, an OpenCode server on its default model.)
|
|
26
29
|
*/
|
|
27
|
-
function checkIsLimitSwitchPossible(isTelegram,
|
|
28
|
-
return isTelegram ||
|
|
30
|
+
function checkIsLimitSwitchPossible(isTelegram, rung) {
|
|
31
|
+
return isTelegram || rung.backend === 'claude';
|
|
29
32
|
}
|
|
30
33
|
/**
|
|
31
34
|
* @description What the usage limit of the rung `from` leads to. `chain` is the operator's fallback chain as stored (empty = none);
|
|
@@ -33,7 +36,7 @@ function checkIsLimitSwitchPossible(isTelegram, from) {
|
|
|
33
36
|
*/
|
|
34
37
|
function decideLimitSwitch(input) {
|
|
35
38
|
const { isTelegram, from, detection, nowMs } = input;
|
|
36
|
-
const explicit =
|
|
39
|
+
const explicit = input.chain.filter((entry) => checkIsLimitSwitchPossible(isTelegram, entry));
|
|
37
40
|
// Without a configured chain a Claude conversation falls back to the within-Claude ranking (the soonest weekly reset first).
|
|
38
41
|
const ranked = explicit.length === 0 && from.backend === 'claude'
|
|
39
42
|
? (0, claudeLimitSwitch_1.pickClaudeLimitSwitchCandidates)({ profiles: detection.claudeProfiles, currentName: from.profile, model: from.model, nowMs })
|
|
@@ -42,13 +45,28 @@ function decideLimitSwitch(input) {
|
|
|
42
45
|
const candidates = (0, fallbackChain_1.pickFallbackCandidates)({ chain: ranked, current: from, detection, nowMs });
|
|
43
46
|
const decided = (0, fallbackChain_1.decideFallbackSwitch)({ candidates, isAutoSwitchEnabled: input.isAutoSwitchEnabled });
|
|
44
47
|
const plan = !isTelegram && decided.action === 'offer' ? { action: 'none' } : decided;
|
|
45
|
-
if (plan.action !== 'none' || !isTelegram)
|
|
46
|
-
return { plan,
|
|
48
|
+
if (plan.action !== 'none' || (!isTelegram && !input.isAutoSwitchEnabled))
|
|
49
|
+
return { plan, waitTarget: null };
|
|
47
50
|
const implicit = from.backend === 'claude'
|
|
48
51
|
? detection.claudeProfiles
|
|
49
52
|
.filter((profile) => profile.loggedIn !== false && profile.billing !== 'api')
|
|
50
53
|
.map((profile) => ({ backend: 'claude', profile: profile.name, model: null }))
|
|
51
54
|
: [];
|
|
52
|
-
|
|
55
|
+
const waitRungs = explicit.length > 0 ? explicit : implicit;
|
|
56
|
+
const found = waitRungs.length > 0 ? (0, fallbackChain_1.pickEarliestResetRung)({ chain: waitRungs, current: from, detection, nowMs }) : null;
|
|
57
|
+
return { plan, waitTarget: found && !found.isCurrent ? { entry: found.entry, untilMs: found.untilMs } : null };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @description What the end of a usage-limit wait aimed at another rung (the retry record's `resumeOn`) does. A topic moves there
|
|
61
|
+
* whatever its switch says: its aimed wait is armed with auto-switch OFF too. Outside Telegram only the automatic switch moves a
|
|
62
|
+
* conversation, and the wait was aimed only while it was ON: turned OFF since, the conversation stays on its own account — waiting
|
|
63
|
+
* again until that account is back (`ownLimitedUntilMs`, its limit mark) while that lies ahead, rather than resuming into a limit
|
|
64
|
+
* it is known to hit; resumed now when its account names no reset ahead.
|
|
65
|
+
*/
|
|
66
|
+
function decideAimedWaitEnd(input) {
|
|
67
|
+
if (input.isTelegram || input.isAutoSwitchEnabled)
|
|
68
|
+
return { action: 'move' };
|
|
69
|
+
const untilMs = input.ownLimitedUntilMs;
|
|
70
|
+
return untilMs !== null && Number.isFinite(untilMs) && untilMs > input.nowMs ? { action: 'waitOwnReset', untilMs } : { action: 'resumeHere' };
|
|
53
71
|
}
|
|
54
72
|
//# sourceMappingURL=limitSwitchPlan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limitSwitchPlan.js","sourceRoot":"","sources":["../../src/utils/limitSwitchPlan.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"limitSwitchPlan.js","sourceRoot":"","sources":["../../src/utils/limitSwitchPlan.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAkBH,gEAEC;AAwBD,8CA2BC;AAkBD,gDAIC;AA3FD,2DAAsE;AACtE,mDAOyB;AAEzB;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,UAAmB,EAAE,IAAwB;IACtF,OAAO,UAAU,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC;AACjD,CAAC;AAoBD;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAOjC;IACC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,0BAA0B,CAAC,UAAU,EA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 export type WorkingSignal = {
|
|
|
37
37
|
export declare function describeWorkingSignal(signal: WorkingSignal): string;
|
|
38
38
|
/** @description The signals in the words of the bot's log, comma-separated (`busy turn, unconsumed input 2`). */
|
|
39
39
|
export declare function describeWorkingSignals(signals: readonly WorkingSignal[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* @description Whether the agent waits on its own pending work — a background command or sub-agent, a session job (a `ScheduleWakeup`,
|
|
42
|
+
* a `CronCreate`), a finished task's turn on its way — whose end starts its next turn by itself.
|
|
43
|
+
*/
|
|
44
|
+
export declare function checkHasOwnPendingWork(signals: readonly WorkingSignal[]): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @description Whether the agent's own work still runs — a background command or sub-agent, a session job — not only the notice of
|
|
47
|
+
* a task that already ended ({@link checkHasOwnPendingWork} counts that too).
|
|
48
|
+
*/
|
|
49
|
+
export declare function checkHasOwnLastingWork(signals: readonly WorkingSignal[]): boolean;
|
|
40
50
|
/** @description The reason the person is told when an idle compaction is skipped because the process was held. */
|
|
41
51
|
export type IdleHeldNoticeReason = 'backgroundWork' | 'unconsumedInput';
|
|
42
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workingSignals.d.ts","sourceRoot":"","sources":["../../src/utils/workingSignals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB;AAC9B,qHAAqH;AACnH;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC5C,mFAAmF;GACjF;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC1C,sHAAsH;GACpH;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE;AAC9B,sHAAsH;GACpH;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AAC5C,oFAAoF;GAClF;IAAE,IAAI,EA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sB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAEhF;AAKD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAEjF;AAKD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAEjF;AAED,kHAAkH;AAClH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,oBAAoB,GAAG,IAAI,CAItG"}
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.describeWorkingSignal = describeWorkingSignal;
|
|
10
10
|
exports.describeWorkingSignals = describeWorkingSignals;
|
|
11
|
+
exports.checkHasOwnPendingWork = checkHasOwnPendingWork;
|
|
12
|
+
exports.checkHasOwnLastingWork = checkHasOwnLastingWork;
|
|
11
13
|
exports.getIdleHeldNoticeReason = getIdleHeldNoticeReason;
|
|
12
14
|
/** @description The signal in the words of the bot's log, naming its figure when it has one (`unconsumed input 2`). */
|
|
13
15
|
function describeWorkingSignal(signal) {
|
|
@@ -24,6 +26,24 @@ function describeWorkingSignal(signal) {
|
|
|
24
26
|
function describeWorkingSignals(signals) {
|
|
25
27
|
return signals.map(describeWorkingSignal).join(', ');
|
|
26
28
|
}
|
|
29
|
+
/** The signals of the agent's OWN pending work: each ends by itself and starts the agent's next turn. */
|
|
30
|
+
const ownPendingWorkKinds = new Set(['backgroundTasks', 'scheduledJobs', 'taskTurnOnItsWay']);
|
|
31
|
+
/**
|
|
32
|
+
* @description Whether the agent waits on its own pending work — a background command or sub-agent, a session job (a `ScheduleWakeup`,
|
|
33
|
+
* a `CronCreate`), a finished task's turn on its way — whose end starts its next turn by itself.
|
|
34
|
+
*/
|
|
35
|
+
function checkHasOwnPendingWork(signals) {
|
|
36
|
+
return signals.some((signal) => ownPendingWorkKinds.has(signal.kind));
|
|
37
|
+
}
|
|
38
|
+
/** The signals of the agent's own work that is still RUNNING: a finished task's turn on its way is not — that work is over. */
|
|
39
|
+
const ownLastingWorkKinds = new Set(['backgroundTasks', 'scheduledJobs']);
|
|
40
|
+
/**
|
|
41
|
+
* @description Whether the agent's own work still runs — a background command or sub-agent, a session job — not only the notice of
|
|
42
|
+
* a task that already ended ({@link checkHasOwnPendingWork} counts that too).
|
|
43
|
+
*/
|
|
44
|
+
function checkHasOwnLastingWork(signals) {
|
|
45
|
+
return signals.some((signal) => ownLastingWorkKinds.has(signal.kind));
|
|
46
|
+
}
|
|
27
47
|
/**
|
|
28
48
|
* @description Which reason the topic's notice gives for a process held at the idle mark: the agent's own background work first
|
|
29
49
|
* (it is what survives a quiet topic for hours), then a message it has not taken in. `null` — no line — when only a running turn
|
|
@@ -31,10 +51,9 @@ function describeWorkingSignals(signals) {
|
|
|
31
51
|
* compaction is in flight (it is the very thing the idle mark would have done).
|
|
32
52
|
*/
|
|
33
53
|
function getIdleHeldNoticeReason(signals) {
|
|
34
|
-
|
|
35
|
-
if (kinds.has('backgroundTasks') || kinds.has('scheduledJobs') || kinds.has('taskTurnOnItsWay'))
|
|
54
|
+
if (checkHasOwnPendingWork(signals))
|
|
36
55
|
return 'backgroundWork';
|
|
37
|
-
if (
|
|
56
|
+
if (signals.some((signal) => signal.kind === 'unconsumedInput'))
|
|
38
57
|
return 'unconsumedInput';
|
|
39
58
|
return null;
|
|
40
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workingSignals.js","sourceRoot":"","sources":["../../src/utils/workingSignals.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmBH,sDASC;AAGD,wDAEC;AAWD,
|
|
1
|
+
{"version":3,"file":"workingSignals.js","sourceRoot":"","sources":["../../src/utils/workingSignals.ts"],"names":[],"mappings":";AAAA;;;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,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC;AAKD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,OAAiC;IACvE,IAAI,sBAAsB,CAAC,OAAO,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAC7D,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAC1F,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "charness",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "charness",
|
|
9
|
-
"version": "4.3.
|
|
9
|
+
"version": "4.3.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
12
12
|
"abort-controller": "^3.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "charness",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"author": "Sergei Solo",
|
|
6
6
|
"description": "Harness for running Claude Code / OpenCode agents in the cloud or on your laptop, controlled from Telegram or Jira.",
|