instar 0.28.87 → 0.28.89
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 +56 -17
- package/dist/commands/server.js.map +1 -1
- package/dist/core/ProjectDigestCache.d.ts +58 -0
- package/dist/core/ProjectDigestCache.d.ts.map +1 -0
- package/dist/core/ProjectDigestCache.js +146 -0
- package/dist/core/ProjectDigestCache.js.map +1 -0
- package/dist/core/SessionRefresh.d.ts +108 -0
- package/dist/core/SessionRefresh.d.ts.map +1 -0
- package/dist/core/SessionRefresh.js +157 -0
- package/dist/core/SessionRefresh.js.map +1 -0
- package/dist/server/AgentServer.d.ts +1 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +1 -0
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/routes.d.ts +4 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +48 -0
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +58 -50
- package/src/templates/hooks/compaction-recovery.sh +50 -0
- package/src/templates/hooks/session-start.sh +50 -0
- package/upgrades/0.28.88.md +91 -0
- package/upgrades/0.28.89.md +31 -0
- package/upgrades/side-effects/0.28.87.md +13 -0
- package/upgrades/side-effects/project-scope-phase1a-pr3.md +477 -0
- package/upgrades/side-effects/session-self-refresh.md +382 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiQH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAw4CD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAw6JtE;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
|
@@ -270,6 +270,11 @@ let _projectDir = process.cwd();
|
|
|
270
270
|
let _sharedIntelligence = null;
|
|
271
271
|
let _selfKnowledgeTree = null;
|
|
272
272
|
let _slackAdapter = null;
|
|
273
|
+
// SessionRefresh — agent-initiated respawn. Module-scope so onRestartSession
|
|
274
|
+
// (defined outside startServer) can delegate to it once startServer wires it.
|
|
275
|
+
// Null until startServer constructs it; the Telegram /restart handler falls
|
|
276
|
+
// back to the inline kill+respawn path when null (e.g. early in boot).
|
|
277
|
+
let _sessionRefresh = null;
|
|
273
278
|
async function spawnSessionForTopic(sessionManager, telegram, sessionName, topicId, latestMessage, topicMemory, userProfile) {
|
|
274
279
|
const msg = latestMessage || 'Session started — send a message to continue.';
|
|
275
280
|
// If memory is elevated/critical and we have the reaper, try to free memory
|
|
@@ -538,25 +543,28 @@ function wireTelegramCallbacks(telegram, sessionManager, state, quotaTracker, ac
|
|
|
538
543
|
return false;
|
|
539
544
|
}
|
|
540
545
|
};
|
|
541
|
-
// /restart — kill session and respawn
|
|
546
|
+
// /restart — kill session and respawn. Delegates to SessionRefresh, the
|
|
547
|
+
// consolidated lifecycle owner: it routes the kill through
|
|
548
|
+
// sessionManager.killSession (which fires the kill hook so the UUID
|
|
549
|
+
// listener persists session.claudeSessionId), then spawns a fresh tmux
|
|
550
|
+
// running `claude --resume <uuid>`. Includes the rate guard against
|
|
551
|
+
// infinite-respawn loops.
|
|
552
|
+
//
|
|
553
|
+
// If SessionRefresh isn't wired yet (very narrow early-boot window
|
|
554
|
+
// before startServer reaches the construction point), we no-op with a
|
|
555
|
+
// warning instead of falling back to a broken inline path — the
|
|
556
|
+
// pre-PR inline kill bypassed sessionManager.killSession and so the
|
|
557
|
+
// kill hook never fired, meaning resume UUIDs were silently dropped.
|
|
558
|
+
// Routing exclusively through SessionRefresh fixes that latent issue.
|
|
542
559
|
telegram.onRestartSession = async (sessionName, topicId) => {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const uuid = _topicResumeMap.findUuidForSession(sessionName);
|
|
547
|
-
if (uuid) {
|
|
548
|
-
_topicResumeMap.save(topicId, uuid, sessionName);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
catch { /* best effort */ }
|
|
560
|
+
if (!_sessionRefresh) {
|
|
561
|
+
console.warn(`[telegram /restart] SessionRefresh not yet wired; deferring restart for sessionName=${sessionName} topicId=${topicId}`);
|
|
562
|
+
return;
|
|
552
563
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
564
|
+
const result = await _sessionRefresh.refreshSession({ sessionName, reason: 'telegram-/restart' });
|
|
565
|
+
if (!result.ok) {
|
|
566
|
+
console.warn(`[telegram /restart] SessionRefresh refused sessionName=${sessionName} code=${result.code}`);
|
|
556
567
|
}
|
|
557
|
-
catch { /* may already be dead */ }
|
|
558
|
-
// Respawn with thread history
|
|
559
|
-
await respawnSessionForTopic(sessionManager, telegram, sessionName, topicId, undefined, topicMemory);
|
|
560
568
|
};
|
|
561
569
|
// /sessions — list running sessions
|
|
562
570
|
telegram.onListSessions = () => {
|
|
@@ -5718,6 +5726,15 @@ export async function startServer(options) {
|
|
|
5718
5726
|
}
|
|
5719
5727
|
const { InitiativeTracker } = await import('../core/InitiativeTracker.js');
|
|
5720
5728
|
const initiativeTracker = new InitiativeTracker(config.stateDir);
|
|
5729
|
+
// Project-scope Phase 1.9 — wire the digest cache writer so every
|
|
5730
|
+
// project mutation re-renders `.instar/projects-digest.cache`. The
|
|
5731
|
+
// session-start + compaction-recovery hooks read this file directly
|
|
5732
|
+
// (≤50ms budget, no HTTP). First-start writes the file unconditionally
|
|
5733
|
+
// so the hooks always have something to read on a fresh install.
|
|
5734
|
+
const { ProjectDigestCache } = await import('../core/ProjectDigestCache.js');
|
|
5735
|
+
const projectDigestCache = new ProjectDigestCache(config.stateDir, initiativeTracker);
|
|
5736
|
+
initiativeTracker.setDigestCacheInvalidator(() => projectDigestCache.writeDigestCache());
|
|
5737
|
+
projectDigestCache.writeDigestCache();
|
|
5721
5738
|
// TaskFlow registry — opt-in via config.taskFlow.enabled (default: off in v1).
|
|
5722
5739
|
// Owns its own SQLite file under .instar/task-flows.db. The maintenance
|
|
5723
5740
|
// sweeper and due-waker start with the registry; both .unref() their timers
|
|
@@ -5800,7 +5817,29 @@ export async function startServer(options) {
|
|
|
5800
5817
|
divergenceChecker = undefined;
|
|
5801
5818
|
}
|
|
5802
5819
|
}
|
|
5803
|
-
|
|
5820
|
+
// SessionRefresh — agent-initiated session respawn. Requires a Telegram
|
|
5821
|
+
// adapter (v1 scope: Telegram-bound sessions only). The respawner closure
|
|
5822
|
+
// captures `topicMemory` by reference, so even if topicMemory is wired up
|
|
5823
|
+
// after this point it will be resolved at refresh-time.
|
|
5824
|
+
if (telegram) {
|
|
5825
|
+
const { SessionRefresh } = await import('../core/SessionRefresh.js');
|
|
5826
|
+
const telegramRef = telegram; // narrow for closure
|
|
5827
|
+
_sessionRefresh = new SessionRefresh({
|
|
5828
|
+
sessionManager,
|
|
5829
|
+
state,
|
|
5830
|
+
telegram: telegramRef,
|
|
5831
|
+
topicResumeMap: _topicResumeMap,
|
|
5832
|
+
respawner: async (sessionName, topicId, followUpPrompt) => {
|
|
5833
|
+
// killSession (called inside SessionRefresh) has already fired
|
|
5834
|
+
// beforeSessionKill (UUID persisted) and destroyed the tmux
|
|
5835
|
+
// session. respawnSessionForTopic spawns the new tmux running
|
|
5836
|
+
// `claude --resume <uuid>` and registers the topic mapping.
|
|
5837
|
+
await respawnSessionForTopic(sessionManager, telegramRef, sessionName, topicId, followUpPrompt, topicMemory);
|
|
5838
|
+
return telegramRef.getSessionForTopic(topicId) ?? sessionName;
|
|
5839
|
+
},
|
|
5840
|
+
});
|
|
5841
|
+
}
|
|
5842
|
+
const server = new AgentServer({ config, sessionManager, state, scheduler, telegram, relationships, feedback, feedbackAnomalyDetector, dispatches, updateChecker, autoUpdater, autoDispatcher, quotaTracker, quotaManager, publisher, viewer, tunnel, evolution, watchdog, topicMemory, triageNurse, projectMapper, coherenceGate: scopeVerifier, contextHierarchy, canonicalState, operationGate, sentinel, adaptiveTrust, memoryMonitor, orphanReaper, coherenceMonitor, commitmentTracker, semanticMemory, activitySentinel, messageRouter, summarySentinel, spawnManager, systemReviewer, capabilityMapper, selfKnowledgeTree, coverageAuditor, topicResumeMap: _topicResumeMap ?? undefined, sessionRefresh: _sessionRefresh ?? undefined, autonomyManager, trustElevationTracker, autonomousEvolution, coordinator: coordinator.enabled ? coordinator : undefined, localSigningKeyPem, whatsapp: whatsappAdapter, slack: slackAdapter, imessage: imessageAdapter, whatsappBusinessBackend, messageBridge, hookEventReceiver, worktreeMonitor, subagentTracker, instructionsVerifier, handshakeManager: threadlineHandshake, threadlineRouter, threadlineRelayClient, threadlineReplyWaiters, listenerManager: listenerManager ?? undefined, responseReviewGate, messagingToneGate, outboundDedupGate, telemetryHeartbeat, pasteManager, featureRegistry, discoveryEvaluator, unifiedTrust, liveConfig, sharedStateLedger, ledgerSessionRegistry, worktreeManager, oidcEnrolledRepos: parallelDevConfig?.oidcEnrolledRepos, initiativeTracker, proxyCoordinator, telegramBridgeConfig, telegramBridge: telegramBridge ?? undefined, threadlineObservability, workingMemory, taskFlowRegistry, threadlineFlowBridge });
|
|
5804
5843
|
await server.start();
|
|
5805
5844
|
void taskFlowSweeper;
|
|
5806
5845
|
void taskFlowDueWaker;
|