instar 1.3.533 → 1.3.534
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +98 -2
- package/dist/commands/server.js.map +1 -1
- package/dist/core/EscalationHintStore.d.ts +60 -0
- package/dist/core/EscalationHintStore.d.ts.map +1 -0
- package/dist/core/EscalationHintStore.js +163 -0
- package/dist/core/EscalationHintStore.js.map +1 -0
- package/dist/core/ModelTierEscalation.d.ts +10 -0
- package/dist/core/ModelTierEscalation.d.ts.map +1 -1
- package/dist/core/ModelTierEscalation.js +4 -0
- package/dist/core/ModelTierEscalation.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +15 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/TopicProfileTransferCarrier.d.ts +27 -0
- package/dist/core/TopicProfileTransferCarrier.d.ts.map +1 -1
- package/dist/core/TopicProfileTransferCarrier.js +24 -1
- package/dist/core/TopicProfileTransferCarrier.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +1 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/AgentServer.d.ts +10 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +26 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +6 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +47 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +64 -64
- package/src/scaffold/templates.ts +1 -0
- package/upgrades/1.3.534.md +44 -0
- package/upgrades/side-effects/ws53-escalation-rides-topic.md +52 -0
- package/upgrades/1.3.533.md +0 -25
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[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C;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAm3CD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,cAAc,EAC9B,YAAY,CAAC,EAAE,YAAY,EAC3B,WAAW,CAAC,EAAE,WAAW,EACzB,WAAW,CAAC,EAAE,WAAW,EACzB,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,EAGvE,UAAU,CAAC,EAAE,MAAM,OAAO,8BAA8B,EAAE,WAAW,GAAG,IAAI,EAK5E,qBAAqB,CAAC,EAAE,MAAM,OAAO,gCAAgC,EAAE,kBAAkB,GAAG,IAAI,EAKhG,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GACpD,IAAI,CA8eN;AA2lBD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAo1atE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
|
package/dist/commands/server.js
CHANGED
|
@@ -21,7 +21,7 @@ import { parseProfileTrigger, platformMessageIdFrom } from '../core/topicProfile
|
|
|
21
21
|
import { TopicProfileOrchestrator, resolvedToApplied, } from '../core/TopicProfileOrchestrator.js';
|
|
22
22
|
import { CodexResumeMap } from '../core/CodexResumeMap.js';
|
|
23
23
|
import { paneIdleWithEmptyInput } from '../core/ModelSwapService.js';
|
|
24
|
-
import { escalatedModelIds } from '../core/ModelTierEscalation.js';
|
|
24
|
+
import { escalatedModelIds, normalizeTierEscalationConfig } from '../core/ModelTierEscalation.js';
|
|
25
25
|
import { activeAutonomousJobs } from '../core/AutonomousSessions.js';
|
|
26
26
|
import { TopicProfileTransferCarrier, createTopicProfilePullHandler } from '../core/TopicProfileTransferCarrier.js';
|
|
27
27
|
import { closeAllSqlite } from '../core/SqliteRegistry.js';
|
|
@@ -461,6 +461,15 @@ let _topicProfileConfirmSlots = null;
|
|
|
461
461
|
let _profileLegacyRespawn = null;
|
|
462
462
|
/** §8 disclosure hook — bound in wireTelegramCallbacks (platform adapter send). */
|
|
463
463
|
let _profileDisclose = null;
|
|
464
|
+
/**
|
|
465
|
+
* WS5.3 (escalation-rides-topic) — the destination re-admit driver. Given a
|
|
466
|
+
* topic key whose resumed session just spawned, RE-ADMIT through the LOCAL
|
|
467
|
+
* EscalationGovernor (via ModelSwapService.swap → admit, the SAME chokepoint a
|
|
468
|
+
* fresh escalation uses). A trigger carry, NEVER a tier grant: the governor
|
|
469
|
+
* re-decides under every cost guard, and a refusal leaves the session default.
|
|
470
|
+
* Gated on tierEscalation.enabled && ridesTopic (read live). Bound in
|
|
471
|
+
* startServer(); null ⇒ WS5.3 unwired ⇒ a no-op. Fire-and-forget. */
|
|
472
|
+
let _driveEscalationReadmit = null;
|
|
464
473
|
/** Topic Profile §8 (TOPIC-PROFILE-SPEC): the orchestration core — debounce
|
|
465
474
|
* slots, idle-gated kill/respawn, resume-writer gates, §10.4 breaker, §14
|
|
466
475
|
* dry-run regime. Constructed in startServer() beside the write surface. */
|
|
@@ -850,6 +859,27 @@ spawnOpts) {
|
|
|
850
859
|
}
|
|
851
860
|
catch { /* @silent-fallback-ok: recordSpawnSuccess is breaker-reset bookkeeping — a failure leaves a slightly-stale breaker count that the next attributable failure/success corrects; never fails the spawn (TOPIC-PROFILE-SPEC §10.4) */ }
|
|
852
861
|
}
|
|
862
|
+
// WS5.3 (escalation-rides-topic) — LOCAL hint consume. When the topic was
|
|
863
|
+
// transferred TO this machine via the live-swap topology (the hint was filed
|
|
864
|
+
// on THIS machine's hint store by the /pool/transfer source leg, target==self),
|
|
865
|
+
// no cross-machine pull fires — so consume the local hint here, right after the
|
|
866
|
+
// resumed session spawned, and re-admit through the LOCAL governor. consume()
|
|
867
|
+
// is consume-once + TTL-bounded; a no-hint topic is a strict no-op. The cross-
|
|
868
|
+
// machine arm is handled by the topic-profile pull's onEscalationHintLanded.
|
|
869
|
+
// A trigger carry, NEVER a tier grant — _driveEscalationReadmit re-decides via
|
|
870
|
+
// the governor admit() chain (and itself gates on enabled && ridesTopic).
|
|
871
|
+
try {
|
|
872
|
+
const localHint = _agentServerRef?.getEscalationHintStore()?.consume(String(topicId)) ?? null;
|
|
873
|
+
if (localHint && _driveEscalationReadmit) {
|
|
874
|
+
_driveEscalationReadmit(topicId, localHint);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
catch (err) {
|
|
878
|
+
// @silent-fallback-ok — the local re-admit is fire-and-forget enrichment of
|
|
879
|
+
// a resumed transferred session; a consume/driver error must never fail the
|
|
880
|
+
// spawn. Worst case the session stays default-tier (the safe direction).
|
|
881
|
+
console.warn(`[spawnSessionForTopic] WS5.3 local escalation re-admit failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
|
|
882
|
+
}
|
|
853
883
|
// Proactive UUID save — schedule discovery after spawn.
|
|
854
884
|
// ONLY uses authoritative claudeSessionId from hook events.
|
|
855
885
|
// Never falls back to mtime-based JSONL scan — that can pick up a UUID from
|
|
@@ -13396,7 +13426,27 @@ export async function startServer(options) {
|
|
|
13396
13426
|
'topic-profile-pull': (cmd) => {
|
|
13397
13427
|
if (!_topicProfileStore)
|
|
13398
13428
|
return { ok: false, reason: 'topic-profile disabled' };
|
|
13399
|
-
return createTopicProfilePullHandler({
|
|
13429
|
+
return createTopicProfilePullHandler({
|
|
13430
|
+
store: _topicProfileStore,
|
|
13431
|
+
// WS5.3 — peek (not consume) the source's ephemeral escalation
|
|
13432
|
+
// hint so it rides the SAME authenticated acquire pull. Gated
|
|
13433
|
+
// on the live config; undefined-safe ⇒ no hint when unwired.
|
|
13434
|
+
escalationHintPeek: (topicKey) => {
|
|
13435
|
+
try {
|
|
13436
|
+
const teCfg = normalizeTierEscalationConfig(config.models?.tierEscalation);
|
|
13437
|
+
if (!teCfg.enabled || !teCfg.ridesTopic)
|
|
13438
|
+
return null;
|
|
13439
|
+
return _agentServerRef?.getEscalationHintStore()?.peek(topicKey) ?? null;
|
|
13440
|
+
}
|
|
13441
|
+
catch {
|
|
13442
|
+
// @silent-fallback-ok — a peek error ⇒ no hint served ⇒ the
|
|
13443
|
+
// destination re-evaluates escalation only on a fresh trigger
|
|
13444
|
+
// (default tier meantime — the safe direction). Never fails
|
|
13445
|
+
// the profile pull serve.
|
|
13446
|
+
return null;
|
|
13447
|
+
}
|
|
13448
|
+
},
|
|
13449
|
+
})(cmd);
|
|
13400
13450
|
},
|
|
13401
13451
|
// COMMITMENTS-COHERENCE-SPEC §3.4 — owner-side apply for the
|
|
13402
13452
|
// owner-routed mutation. opKey window first (replay returns the
|
|
@@ -13840,6 +13890,12 @@ export async function startServer(options) {
|
|
|
13840
13890
|
if (sysTopic)
|
|
13841
13891
|
void telegram.sendToTopic(sysTopic, text).catch(() => { });
|
|
13842
13892
|
},
|
|
13893
|
+
// WS5.3 — a pull landing carried an escalation hint for a topic
|
|
13894
|
+
// this machine now owns. Drive the re-admit through the LOCAL
|
|
13895
|
+
// governor (a trigger carry, never a tier grant). Fire-and-forget.
|
|
13896
|
+
onEscalationHintLanded: (topicKey, hint) => {
|
|
13897
|
+
_driveEscalationReadmit?.(topicKey, hint);
|
|
13898
|
+
},
|
|
13843
13899
|
logger: (m) => console.log(pc.dim(` [topic-profile-pull] ${m}`)),
|
|
13844
13900
|
});
|
|
13845
13901
|
// §5.3(e) drain: the slow retry tick (10 min) — retries pending
|
|
@@ -15017,6 +15073,46 @@ export async function startServer(options) {
|
|
|
15017
15073
|
// wired before the server existed; from here on inbound binds use the
|
|
15018
15074
|
// server's own store instance.
|
|
15019
15075
|
_agentServerRef = server;
|
|
15076
|
+
// ── WS5.3 (escalation-rides-topic) destination re-admit driver ──
|
|
15077
|
+
// Bound here (after the AgentServer exists) so it can reach the SAME
|
|
15078
|
+
// ModelSwapService the /sessions/:name/model-swap route uses. Re-admission
|
|
15079
|
+
// is `swap(name, 'escalated')` — which runs the FULL governor admit() chain
|
|
15080
|
+
// (every cost guard, dwell/TTL, suppress consult). The hint never grants a
|
|
15081
|
+
// tier: it only decides whether to ASK. A refusal (any guard) leaves the
|
|
15082
|
+
// session on its default tier — exactly as a fresh escalation would be
|
|
15083
|
+
// refused. Gated LIVE on tierEscalation.enabled && ridesTopic; null-safe.
|
|
15084
|
+
_driveEscalationReadmit = (topicKey, hint) => {
|
|
15085
|
+
try {
|
|
15086
|
+
const teCfg = normalizeTierEscalationConfig(config.models?.tierEscalation);
|
|
15087
|
+
if (!teCfg.enabled || !teCfg.ridesTopic)
|
|
15088
|
+
return; // dark ⇒ strict no-op
|
|
15089
|
+
const swap = server.getModelTierSwap();
|
|
15090
|
+
if (!swap)
|
|
15091
|
+
return;
|
|
15092
|
+
const topicNum = Number(topicKey);
|
|
15093
|
+
if (!Number.isFinite(topicNum))
|
|
15094
|
+
return;
|
|
15095
|
+
const sessionName = telegram?.getSessionForTopic?.(topicNum) ?? null;
|
|
15096
|
+
if (!sessionName)
|
|
15097
|
+
return; // no resumed session yet ⇒ nothing to re-admit
|
|
15098
|
+
// Serialize through the topic's single-writer lock (same as the
|
|
15099
|
+
// model-swap route) so the re-admit can never interleave with a
|
|
15100
|
+
// profile-triggered kill/respawn on the same topic.
|
|
15101
|
+
const orch = _topicProfileOrchestrator;
|
|
15102
|
+
const perform = () => swap.swap(sessionName, 'escalated');
|
|
15103
|
+
const run = orch ? orch.runExclusive(topicNum, perform) : perform();
|
|
15104
|
+
void Promise.resolve(run).catch((err) => {
|
|
15105
|
+
console.warn(`[ws5.3 re-admit] topic ${topicNum} (trigger=${hint.trigger}) re-admit failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
15106
|
+
});
|
|
15107
|
+
}
|
|
15108
|
+
catch (err) {
|
|
15109
|
+
// @silent-fallback-ok — the re-admit is fire-and-forget enrichment of a
|
|
15110
|
+
// resumed transferred session; a driver error must never fail the spawn
|
|
15111
|
+
// or transfer. Worst case the session stays default-tier (the safe
|
|
15112
|
+
// direction). Logged, never thrown.
|
|
15113
|
+
console.warn(`[ws5.3 re-admit] driver error: ${err instanceof Error ? err.message : String(err)}`);
|
|
15114
|
+
}
|
|
15115
|
+
};
|
|
15020
15116
|
// ── Topic Profile §8 orchestrator (TOPIC-PROFILE-SPEC) ──
|
|
15021
15117
|
// Constructed HERE (after the AgentServer) because two of its ports late-bind
|
|
15022
15118
|
// off the server: the §9 EscalationGovernor (server.getEscalationGovernor())
|