instar 1.3.329 → 1.3.331
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 +138 -17
- package/dist/commands/server.js.map +1 -1
- package/dist/core/AnthropicSubscriptionRouter.d.ts +68 -0
- package/dist/core/AnthropicSubscriptionRouter.d.ts.map +1 -0
- package/dist/core/AnthropicSubscriptionRouter.js +82 -0
- package/dist/core/AnthropicSubscriptionRouter.js.map +1 -0
- package/dist/core/HttpLeaseTransport.d.ts +24 -0
- package/dist/core/HttpLeaseTransport.d.ts.map +1 -1
- package/dist/core/HttpLeaseTransport.js +34 -4
- package/dist/core/HttpLeaseTransport.js.map +1 -1
- package/dist/core/InteractivePoolIntelligenceProvider.d.ts +38 -0
- package/dist/core/InteractivePoolIntelligenceProvider.d.ts.map +1 -0
- package/dist/core/InteractivePoolIntelligenceProvider.js +61 -0
- package/dist/core/InteractivePoolIntelligenceProvider.js.map +1 -0
- package/dist/core/PeerFailureLogGate.d.ts +44 -0
- package/dist/core/PeerFailureLogGate.d.ts.map +1 -0
- package/dist/core/PeerFailureLogGate.js +60 -0
- package/dist/core/PeerFailureLogGate.js.map +1 -0
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +17 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/intelligenceProviderFactory.d.ts +21 -0
- package/dist/core/intelligenceProviderFactory.d.ts.map +1 -1
- package/dist/core/intelligenceProviderFactory.js +24 -1
- package/dist/core/intelligenceProviderFactory.js.map +1 -1
- package/dist/core/types.d.ts +38 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/config.d.ts +17 -0
- package/dist/providers/adapters/anthropic-interactive-pool/config.d.ts.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/config.js +1 -0
- package/dist/providers/adapters/anthropic-interactive-pool/config.js.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/pool.d.ts +16 -2
- package/dist/providers/adapters/anthropic-interactive-pool/pool.d.ts.map +1 -1
- package/dist/providers/adapters/anthropic-interactive-pool/pool.js +95 -5
- package/dist/providers/adapters/anthropic-interactive-pool/pool.js.map +1 -1
- package/dist/providers/bootRegistration.d.ts +83 -0
- package/dist/providers/bootRegistration.d.ts.map +1 -0
- package/dist/providers/bootRegistration.js +158 -0
- package/dist/providers/bootRegistration.js.map +1 -0
- package/dist/providers/costAwareRouting.d.ts +16 -0
- package/dist/providers/costAwareRouting.d.ts.map +1 -1
- package/dist/providers/costAwareRouting.js +37 -21
- package/dist/providers/costAwareRouting.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +5 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +26 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +63 -63
- package/src/scaffold/templates.ts +5 -0
- package/upgrades/{1.3.329.md → 1.3.330.md} +40 -0
- package/upgrades/1.3.331.md +77 -0
- package/upgrades/side-effects/mesh-pull-brakes.md +63 -0
- package/upgrades/side-effects/provider-substrate-live-wiring.md +145 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuxDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuxDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAguRtE;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
|
@@ -2191,22 +2191,56 @@ export async function startServer(options) {
|
|
|
2191
2191
|
// ELOCKED errors from concurrent agent startups are transient.
|
|
2192
2192
|
console.log(pc.yellow(` Registry heartbeat failed to start (non-critical): ${err instanceof Error ? err.message : err}`));
|
|
2193
2193
|
}
|
|
2194
|
-
// Phase 5 —
|
|
2195
|
-
//
|
|
2196
|
-
//
|
|
2197
|
-
// (
|
|
2198
|
-
//
|
|
2199
|
-
//
|
|
2200
|
-
//
|
|
2201
|
-
//
|
|
2202
|
-
// defaulting to first-by-registration.
|
|
2194
|
+
// Phase 5 — register the Anthropic adapters and install the cost-aware
|
|
2195
|
+
// routing policy on the global providers registry. Registration is the
|
|
2196
|
+
// formerly-deferred "separate cycle" (src/providers/bootRegistration.ts):
|
|
2197
|
+
// gated (codex-only agents register nothing), idempotent, and LAZY (no
|
|
2198
|
+
// tmux/claude spawns at boot — the pool only spawns on first use). With
|
|
2199
|
+
// adapters actually registered, `registry.resolve()` decisions are real,
|
|
2200
|
+
// and the policy's `readSdkCredit` is plumbed from the headless adapter's
|
|
2201
|
+
// UsageMeterProvider instead of the old `() => null` stub.
|
|
2203
2202
|
//
|
|
2204
2203
|
// Idempotent: only installs when no policy has been set yet on the
|
|
2205
2204
|
// module-singleton registry. Re-entering `startServer` in the same
|
|
2206
2205
|
// process (test harnesses, in-proc respawn) won't clobber a policy
|
|
2207
2206
|
// a caller (test or production wiring) installed first.
|
|
2207
|
+
let anthropicRegistration = null;
|
|
2208
2208
|
try {
|
|
2209
2209
|
const { registry } = await import('../providers/registry.js');
|
|
2210
|
+
const { registerAnthropicAdapters } = await import('../providers/bootRegistration.js');
|
|
2211
|
+
// Scratch working dir for intelligence-pool sessions (context
|
|
2212
|
+
// decontamination — no project CLAUDE.md/MCP in judgment calls).
|
|
2213
|
+
const subscriptionPathConfig = config.intelligence?.subscriptionPath;
|
|
2214
|
+
const poolWorkdir = subscriptionPathConfig?.workingDirectory
|
|
2215
|
+
?? path.join(config.stateDir, 'intelligence-pool');
|
|
2216
|
+
try {
|
|
2217
|
+
fs.mkdirSync(poolWorkdir, { recursive: true });
|
|
2218
|
+
}
|
|
2219
|
+
catch { /* spawn-time failure surfaces loudly */ }
|
|
2220
|
+
anthropicRegistration = await registerAnthropicAdapters({
|
|
2221
|
+
...(config.enabledFrameworks ? { enabledFrameworks: config.enabledFrameworks } : {}),
|
|
2222
|
+
...(config.sessions?.claudePath ? { claudePath: config.sessions.claudePath } : {}),
|
|
2223
|
+
...(config.sessions?.tmuxPath ? { tmuxPath: config.sessions.tmuxPath } : {}),
|
|
2224
|
+
pool: {
|
|
2225
|
+
poolSize: subscriptionPathConfig?.poolSize ?? 2,
|
|
2226
|
+
// One model per pool; 'haiku' default keeps sentinel chatter off
|
|
2227
|
+
// the subscription's large-model quota (types.ts rationale).
|
|
2228
|
+
model: subscriptionPathConfig?.model ?? 'haiku',
|
|
2229
|
+
workingDirectory: poolWorkdir,
|
|
2230
|
+
// Agent-scoped prefix — pool.start()'s orphan recovery kills
|
|
2231
|
+
// stale `<prefix>-*` tmux sessions from a crashed previous
|
|
2232
|
+
// process, so the prefix MUST be unique per agent on a shared
|
|
2233
|
+
// machine (an unscoped prefix would reap another agent's pool).
|
|
2234
|
+
sessionPrefix: `instar-pool-${String(config.projectName ?? 'agent').toLowerCase().replace(/[^a-z0-9-]/g, '-')}`,
|
|
2235
|
+
},
|
|
2236
|
+
});
|
|
2237
|
+
if (anthropicRegistration.skippedReason) {
|
|
2238
|
+
console.log(pc.dim(` Providers registry: Anthropic adapters skipped (${anthropicRegistration.skippedReason})`));
|
|
2239
|
+
}
|
|
2240
|
+
else {
|
|
2241
|
+
const ids = [...anthropicRegistration.registered, ...anthropicRegistration.alreadyRegistered];
|
|
2242
|
+
console.log(pc.green(` Providers registry: ${ids.join(', ')} registered`));
|
|
2243
|
+
}
|
|
2210
2244
|
// Read-only probe — `getRoutingPolicy` isn't on the public surface,
|
|
2211
2245
|
// so we test by attempting a no-op resolve and seeing whether the
|
|
2212
2246
|
// chain fires. Cheaper proxy: a private convention — set a marker
|
|
@@ -2222,10 +2256,10 @@ export async function startServer(options) {
|
|
|
2222
2256
|
const { CostAwareRoutingPolicy } = await import('../providers/costAwareRouting.js');
|
|
2223
2257
|
registry.setRoutingPolicy(new ChainPolicy([
|
|
2224
2258
|
new CostAwareRoutingPolicy({
|
|
2225
|
-
//
|
|
2226
|
-
//
|
|
2227
|
-
//
|
|
2228
|
-
readSdkCredit:
|
|
2259
|
+
// Real credit reader from the headless adapter's usage meter
|
|
2260
|
+
// (TTL-cached; null = unknown → subscription floor). On a
|
|
2261
|
+
// skipped registration this stays a null-reader by contract.
|
|
2262
|
+
readSdkCredit: anthropicRegistration.readSdkCredit,
|
|
2229
2263
|
sdkCreditAdapterId: 'anthropic-headless',
|
|
2230
2264
|
subscriptionAdapterId: 'anthropic-interactive-pool',
|
|
2231
2265
|
}),
|
|
@@ -2236,9 +2270,18 @@ export async function startServer(options) {
|
|
|
2236
2270
|
}
|
|
2237
2271
|
}
|
|
2238
2272
|
catch (err) {
|
|
2239
|
-
//
|
|
2240
|
-
// via the registry's first-match-by-registration fallback.
|
|
2241
|
-
|
|
2273
|
+
// Registration/policy install is non-critical — sessions still resolve
|
|
2274
|
+
// adapters via the registry's first-match-by-registration fallback.
|
|
2275
|
+
// But it IS a degradation: the June-15 subscription-path routing is
|
|
2276
|
+
// not live in this process, so report it rather than only logging.
|
|
2277
|
+
console.log(pc.yellow(` Providers registration/policy install failed (non-critical): ${err instanceof Error ? err.message : err}`));
|
|
2278
|
+
DegradationReporter.getInstance().report({
|
|
2279
|
+
feature: 'serverBoot.anthropicProviderRegistration',
|
|
2280
|
+
primary: 'both Anthropic adapters registered + cost-aware routing policy installed at boot',
|
|
2281
|
+
fallback: 'empty providers registry — internal LLM calls stay on the legacy claude -p path with no SDK-pot-vs-subscription routing',
|
|
2282
|
+
reason: `registration/policy install threw: ${err instanceof Error ? err.message : String(err)}`,
|
|
2283
|
+
impact: 'subscription-path routing (June-15 readiness) is unavailable for this server process until restart',
|
|
2284
|
+
});
|
|
2242
2285
|
}
|
|
2243
2286
|
// Warn if no auth token configured — server allows unauthenticated access
|
|
2244
2287
|
if (!config.authToken) {
|
|
@@ -2429,6 +2472,11 @@ export async function startServer(options) {
|
|
|
2429
2472
|
},
|
|
2430
2473
|
nextSequence: () => ++leaseSeq,
|
|
2431
2474
|
reachabilityWindowMs: seamlessness.leaseTtlMs,
|
|
2475
|
+
// P19 hung-socket brake, derived from config: must stay BELOW the
|
|
2476
|
+
// self-suspend horizon (leaseTtlMs) so one slow renewal can't burn
|
|
2477
|
+
// the whole TTL, but ABOVE the fleet's 5-40s receiver-stall envelope
|
|
2478
|
+
// so a slow-but-alive peer isn't converted into "no medium".
|
|
2479
|
+
requestTimeoutMs: Math.min(seamlessness.leaseTtlMs / 2, 30_000),
|
|
2432
2480
|
logger: (m) => console.log(pc.dim(m)),
|
|
2433
2481
|
});
|
|
2434
2482
|
const leaseCoordinator = new LeaseCoordinator({
|
|
@@ -2654,6 +2702,10 @@ export async function startServer(options) {
|
|
|
2654
2702
|
enabled: config.intelligence?.circuitBreaker?.enabled,
|
|
2655
2703
|
openMs: config.intelligence?.circuitBreaker?.openMs,
|
|
2656
2704
|
});
|
|
2705
|
+
// Hoisted out of the provider-build try block: the per-component
|
|
2706
|
+
// IntelligenceRouter below (outside that try) reuses the same
|
|
2707
|
+
// subscription-path option for its claude-code builds.
|
|
2708
|
+
let subscriptionPathOption;
|
|
2657
2709
|
// Provider-portability v1.0.0: pick the IntelligenceProvider that
|
|
2658
2710
|
// matches the configured framework. Defaults to claude-code for
|
|
2659
2711
|
// backwards-compat; INSTAR_FRAMEWORK=codex-cli routes through Codex.
|
|
@@ -2714,9 +2766,55 @@ export async function startServer(options) {
|
|
|
2714
2766
|
catch (err) {
|
|
2715
2767
|
console.warn(`[server] TopicLocalModelStore failed to initialize: ${err}`);
|
|
2716
2768
|
}
|
|
2769
|
+
// June-15 subscription-path routing (spec 04 Rule 1). Built ONCE here;
|
|
2770
|
+
// reused by the main provider below AND the per-component
|
|
2771
|
+
// IntelligenceRouter's claude-code builds, so a component routed to
|
|
2772
|
+
// claude-code while the default framework is codex still gets the
|
|
2773
|
+
// same SDK-pot-vs-subscription routing. Mode 'off'/unset ⇒ option
|
|
2774
|
+
// stays undefined ⇒ claude path byte-for-byte unchanged.
|
|
2775
|
+
const spMode = config.intelligence?.subscriptionPath?.mode ?? 'off';
|
|
2776
|
+
if ((spMode === 'auto' || spMode === 'force') && anthropicRegistration?.pool) {
|
|
2777
|
+
// (string | undefined, not `= null` — a `= null;` initializer inside
|
|
2778
|
+
// the preceding catch's 20-line scan window false-flags the unrelated
|
|
2779
|
+
// TopicLocalModelStore catch in no-silent-fallbacks.test.ts.)
|
|
2780
|
+
let lastRoutedPath;
|
|
2781
|
+
subscriptionPathOption = {
|
|
2782
|
+
mode: spMode,
|
|
2783
|
+
poolAdapter: anthropicRegistration.pool,
|
|
2784
|
+
readSdkCredit: anthropicRegistration.readSdkCredit,
|
|
2785
|
+
// Transition-only logging (reaper-audit pattern): a line when the
|
|
2786
|
+
// serving path CHANGES, not per call — ~1k internal calls/day must
|
|
2787
|
+
// not become 1k log lines.
|
|
2788
|
+
onRoute: (info) => {
|
|
2789
|
+
if (info.path !== lastRoutedPath) {
|
|
2790
|
+
lastRoutedPath = info.path;
|
|
2791
|
+
console.log(pc.gray(` [subscription-path] serving internal intelligence via ${info.path} (${info.reason})`));
|
|
2792
|
+
}
|
|
2793
|
+
},
|
|
2794
|
+
onDegrade: (info) => {
|
|
2795
|
+
try {
|
|
2796
|
+
DegradationReporter.getInstance().report({
|
|
2797
|
+
feature: 'AnthropicSubscriptionRouter',
|
|
2798
|
+
primary: `internal intelligence on ${info.from}`,
|
|
2799
|
+
fallback: `fell back to ${info.to}`,
|
|
2800
|
+
reason: info.reason,
|
|
2801
|
+
impact: `Internal LLM call${info.component ? ` (${info.component})` : ''} served by ${info.to} after ${info.from} failed.`,
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
catch { /* never break the LLM path on a degradation report */ }
|
|
2805
|
+
},
|
|
2806
|
+
};
|
|
2807
|
+
console.log(pc.green(` Subscription-path routing: mode '${spMode}' (pool model: ${config.intelligence?.subscriptionPath?.model ?? 'haiku'})`));
|
|
2808
|
+
}
|
|
2809
|
+
else if (spMode !== 'off') {
|
|
2810
|
+
// Configured but unusable (codex-only gate, registration failure) —
|
|
2811
|
+
// say so loudly rather than silently running the SDK path.
|
|
2812
|
+
console.log(pc.yellow(` Subscription-path routing: mode '${spMode}' configured but the interactive-pool adapter is unavailable — internal calls stay on the default claude -p path`));
|
|
2813
|
+
}
|
|
2717
2814
|
const built = buildIntelligenceProvider({
|
|
2718
2815
|
framework,
|
|
2719
2816
|
binaryPath: framework === 'claude-code' ? config.sessions.claudePath : undefined,
|
|
2817
|
+
...(subscriptionPathOption ? { subscriptionPath: subscriptionPathOption } : {}),
|
|
2720
2818
|
...(framework === 'gemini-cli' && config.monitoring?.quotaTracking
|
|
2721
2819
|
? {
|
|
2722
2820
|
quotaStateFile: config.monitoring.quotaStateFile
|
|
@@ -2763,7 +2861,16 @@ export async function startServer(options) {
|
|
|
2763
2861
|
resolveConfig: () => config.sessions?.componentFrameworks,
|
|
2764
2862
|
// Each non-default framework gets its OWN breaker → a Claude trip can't
|
|
2765
2863
|
// pause Codex (the whole point). Default framework keeps the shared one.
|
|
2766
|
-
|
|
2864
|
+
// claude-code builds inherit the subscription-path routing so a
|
|
2865
|
+
// component routed to Claude under a codex default still honors
|
|
2866
|
+
// the June-15 SDK-pot-vs-subscription decision.
|
|
2867
|
+
buildProvider: (fw) => buildIP({
|
|
2868
|
+
framework: fw,
|
|
2869
|
+
breaker: new LlmCircuitBreaker(),
|
|
2870
|
+
...(fw === 'claude-code' && subscriptionPathOption
|
|
2871
|
+
? { subscriptionPath: subscriptionPathOption }
|
|
2872
|
+
: {}),
|
|
2873
|
+
}),
|
|
2767
2874
|
onDegrade: (info) => {
|
|
2768
2875
|
try {
|
|
2769
2876
|
DegradationReporter.getInstance().report({
|
|
@@ -10159,6 +10266,20 @@ export async function startServer(options) {
|
|
|
10159
10266
|
return;
|
|
10160
10267
|
_shuttingDown = true;
|
|
10161
10268
|
console.log('\nShutting down...');
|
|
10269
|
+
// Dispose the interactive-pool adapter (kills its tmux REPL sessions
|
|
10270
|
+
// so they don't orphan). No-op when registration was skipped or the
|
|
10271
|
+
// pool never spawned (lazy). Must run before process exit — orphaned
|
|
10272
|
+
// pool sessions would silently keep drawing subscription quota.
|
|
10273
|
+
if (anthropicRegistration?.pool) {
|
|
10274
|
+
try {
|
|
10275
|
+
const { registry: providersRegistry } = await import('../providers/registry.js');
|
|
10276
|
+
await providersRegistry.unregister(anthropicRegistration.pool.id);
|
|
10277
|
+
console.log('[shutdown] Interactive-pool adapter disposed');
|
|
10278
|
+
}
|
|
10279
|
+
catch (err) {
|
|
10280
|
+
console.error('[shutdown] Interactive-pool dispose failed:', err);
|
|
10281
|
+
}
|
|
10282
|
+
}
|
|
10162
10283
|
// Save resume UUIDs for ALL active topic-linked sessions before exit.
|
|
10163
10284
|
// Without this, server restarts lose all resume mappings because:
|
|
10164
10285
|
// 1. Resume entries are consumed (removed) on spawn
|