@skaile/workspaces 1.9.0 → 1.9.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/{asset-feeds-SS336LXB.js → asset-feeds-LD6QKJ2R.js} +4 -4
  3. package/dist/{asset-feeds-SS336LXB.js.map → asset-feeds-LD6QKJ2R.js.map} +1 -1
  4. package/dist/asset-manager/index.js +1 -1
  5. package/dist/{chunk-UNJGSISX.js → chunk-5F3GULZT.js} +3 -3
  6. package/dist/{chunk-UNJGSISX.js.map → chunk-5F3GULZT.js.map} +1 -1
  7. package/dist/{chunk-QY47VHNI.js → chunk-5LPARFB5.js} +2 -2
  8. package/dist/{chunk-QY47VHNI.js.map → chunk-5LPARFB5.js.map} +1 -1
  9. package/dist/{chunk-OMBYBUOF.js → chunk-6Q7CNVU3.js} +3 -3
  10. package/dist/{chunk-OMBYBUOF.js.map → chunk-6Q7CNVU3.js.map} +1 -1
  11. package/dist/{chunk-GKPUN2YQ.js → chunk-A2CDJRRH.js} +3 -3
  12. package/dist/{chunk-GKPUN2YQ.js.map → chunk-A2CDJRRH.js.map} +1 -1
  13. package/dist/{chunk-DTZ7JUZY.js → chunk-HGLQYLZB.js} +222 -191
  14. package/dist/chunk-HGLQYLZB.js.map +1 -0
  15. package/dist/{chunk-4DFBHEXQ.js → chunk-JCKGYBWY.js} +24 -16
  16. package/dist/chunk-JCKGYBWY.js.map +1 -0
  17. package/dist/{chunk-5DC744E3.js → chunk-JPKWPX5Q.js} +3 -3
  18. package/dist/{chunk-5DC744E3.js.map → chunk-JPKWPX5Q.js.map} +1 -1
  19. package/dist/{chunk-TJNEKDWS.js → chunk-MBGSJM7H.js} +6 -6
  20. package/dist/{chunk-TJNEKDWS.js.map → chunk-MBGSJM7H.js.map} +1 -1
  21. package/dist/{chunk-R5UMZEBH.js → chunk-SBU73P7R.js} +6 -6
  22. package/dist/{chunk-R5UMZEBH.js.map → chunk-SBU73P7R.js.map} +1 -1
  23. package/dist/{chunk-MWZGGCMF.js → chunk-VWSR6K7C.js} +2 -2
  24. package/dist/{chunk-MWZGGCMF.js.map → chunk-VWSR6K7C.js.map} +1 -1
  25. package/dist/cli/index.js +24 -24
  26. package/dist/connectors/index.js +1 -1
  27. package/dist/connectors/src/credential-helper-script.d.ts +8 -5
  28. package/dist/connectors/src/credential-helper-script.d.ts.map +1 -1
  29. package/dist/connectors/src/managed-gitconfig.d.ts +4 -2
  30. package/dist/connectors/src/managed-gitconfig.d.ts.map +1 -1
  31. package/dist/{ensure-sources-ELLWRQAT.js → ensure-sources-S6QBARWF.js} +4 -4
  32. package/dist/{ensure-sources-ELLWRQAT.js.map → ensure-sources-S6QBARWF.js.map} +1 -1
  33. package/dist/factory-assets/connectors/box.js +1 -1
  34. package/dist/factory-assets/connectors/deploy.js +1 -1
  35. package/dist/factory-assets/connectors/devserver.js +1 -1
  36. package/dist/factory-assets/connectors/flow/adapter.js +1 -1
  37. package/dist/factory-assets/connectors/flow/run-flow.js +2 -2
  38. package/dist/factory-assets/connectors/flow.js +1 -1
  39. package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
  40. package/dist/factory-assets/connectors/git.js +1 -1
  41. package/dist/factory-assets/connectors/gmail.js +1 -1
  42. package/dist/factory-assets/connectors/googledrive.js +1 -1
  43. package/dist/factory-assets/connectors/local.js +1 -1
  44. package/dist/factory-assets/connectors/mattermost.js +1 -1
  45. package/dist/factory-assets/connectors/memory.js +1 -1
  46. package/dist/factory-assets/connectors/minio.js +1 -1
  47. package/dist/factory-assets/connectors/postgres.js +1 -1
  48. package/dist/factory-assets/connectors/s3.js +1 -1
  49. package/dist/factory-assets/connectors/sharepoint.js +1 -1
  50. package/dist/factory-assets/connectors/sqlite.js +1 -1
  51. package/dist/factory-assets/connectors/static-server.js +1 -1
  52. package/dist/factory-assets/connectors/tunnel.js +1 -1
  53. package/dist/factory-assets/connectors/webdav.js +1 -1
  54. package/dist/factory-assets/connectors/xstate-store.js +1 -1
  55. package/dist/factory-assets/connectors/xstate.js +1 -1
  56. package/dist/{helpers-7Y4DTFR6.js → helpers-ZZZY7HUJ.js} +4 -4
  57. package/dist/{helpers-7Y4DTFR6.js.map → helpers-ZZZY7HUJ.js.map} +1 -1
  58. package/dist/{library-publish-7AH63NKA.js → library-publish-NCMIFF3V.js} +6 -6
  59. package/dist/{library-publish-7AH63NKA.js.map → library-publish-NCMIFF3V.js.map} +1 -1
  60. package/dist/{open-library-J2PRSM3J.js → open-library-VFS6WIO7.js} +5 -5
  61. package/dist/{open-library-J2PRSM3J.js.map → open-library-VFS6WIO7.js.map} +1 -1
  62. package/dist/{project-CSNHUQFK.js → project-SC7TVEQ6.js} +5 -5
  63. package/dist/{project-CSNHUQFK.js.map → project-SC7TVEQ6.js.map} +1 -1
  64. package/dist/runner/index.js +3 -3
  65. package/dist/runner/src/serve.d.ts.map +1 -1
  66. package/dist/runner/src/session-capability-wiring.d.ts +49 -0
  67. package/dist/runner/src/session-capability-wiring.d.ts.map +1 -0
  68. package/dist/runner/src/session-resource-handlers.d.ts +1 -2
  69. package/dist/runner/src/session-resource-handlers.d.ts.map +1 -1
  70. package/dist/sdk/asset-manager.js +1 -1
  71. package/dist/sdk/index.js +3 -3
  72. package/dist/sdk/runner.js +3 -3
  73. package/dist/{source-4YG45QO6.js → source-Z5HNLF6J.js} +6 -6
  74. package/dist/{source-4YG45QO6.js.map → source-Z5HNLF6J.js.map} +1 -1
  75. package/dist/{source-manifest-publish-RFU4YBC6.js → source-manifest-publish-FA2KLZJ6.js} +7 -7
  76. package/dist/{source-manifest-publish-RFU4YBC6.js.map → source-manifest-publish-FA2KLZJ6.js.map} +1 -1
  77. package/dist/tui/index.js +3 -3
  78. package/dist/workspace-plugin/index.js +1 -1
  79. package/package.json +1 -1
  80. package/dist/chunk-4DFBHEXQ.js.map +0 -1
  81. package/dist/chunk-DTZ7JUZY.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { WorkspacePlugin } from './chunk-MWZGGCMF.js';
1
+ import { WorkspacePlugin } from './chunk-VWSR6K7C.js';
2
2
  import { WebSocketServerTransport } from './chunk-WQ7DE5UC.js';
3
3
  import { assembleSystemPrompt, buildCapabilitiesPromptSection } from './chunk-W3UDISS2.js';
4
4
  import { EventNormalizer } from './chunk-HKX5VSWQ.js';
@@ -6,7 +6,7 @@ import { SUPPORTED_CLOUDS, CLOUD_SECRET_ENV_KEYS } from './chunk-ISQWMBKD.js';
6
6
  import { classifyClaudeSdkError } from './chunk-GAH4YRCI.js';
7
7
  import { createDriver } from './chunk-TNSCHS4I.js';
8
8
  import { deployCatalogEntry, undeployCatalogEntry } from './chunk-LV2HPH3C.js';
9
- import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, ConnectorStartupError, buildSdkConnectorTools } from './chunk-4DFBHEXQ.js';
9
+ import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, ConnectorStartupError, buildSdkConnectorTools } from './chunk-JCKGYBWY.js';
10
10
  import { loadConnectorDeclarations, SecretProviderChain, PreMintedSecretProvider, InMemorySecretProvider, resolvedConfigToDeclarations, deriveSingleMaterializedConnectorDeclaration } from './chunk-Y6FV73IH.js';
11
11
  import { renderStimulusPrompt, buildOrchestratorPrompt } from './chunk-DEYYRFQU.js';
12
12
  import { PROTOCOL_VERSION } from './chunk-XJOPAGZX.js';
@@ -3292,6 +3292,137 @@ function rewriteFileChangedPath(event, cwd, mounts) {
3292
3292
  }
3293
3293
  return event;
3294
3294
  }
3295
+ function parseFleetHealthBody(body) {
3296
+ const trimmed = body.trim().toLowerCase();
3297
+ if (trimmed === "healthy") return "healthy";
3298
+ if (trimmed === "degraded") return "degraded";
3299
+ return "error";
3300
+ }
3301
+ async function dispatchFleetHealthFlag(dir, fileName, manager, log) {
3302
+ if (!manager) return;
3303
+ const connectorId = fileName;
3304
+ if (!connectorId || connectorId.startsWith(".")) return;
3305
+ let verdict;
3306
+ try {
3307
+ verdict = parseFleetHealthBody(await readFile(join(dir, connectorId), "utf8"));
3308
+ } catch {
3309
+ verdict = "error";
3310
+ }
3311
+ try {
3312
+ await manager.reportFleetHealth(connectorId, verdict);
3313
+ log.debug("fleet-health flag dispatched", { connectorId, verdict });
3314
+ } catch (err) {
3315
+ log.warn("fleet-health flag dispatch failed", {
3316
+ connectorId,
3317
+ error: err instanceof Error ? err.message : String(err)
3318
+ });
3319
+ }
3320
+ }
3321
+
3322
+ // runner/src/refresh-flag-dispatcher.ts
3323
+ async function dispatchRefreshToExposedGitMounts(manager, log) {
3324
+ if (!manager) return;
3325
+ let gitConnectors;
3326
+ try {
3327
+ gitConnectors = manager.listGitConnectors();
3328
+ } catch (err) {
3329
+ log.warn("listGitConnectors failed during refresh-flag dispatch", {
3330
+ error: err instanceof Error ? err.message : String(err)
3331
+ });
3332
+ return;
3333
+ }
3334
+ const eligible = gitConnectors.filter(
3335
+ (m) => m.exposeAccessToken === true && m.auth === "backend"
3336
+ );
3337
+ if (eligible.length === 0) {
3338
+ log.debug("refresh-flag fired but no eligible git connectors (Tier-2 backend) found");
3339
+ return;
3340
+ }
3341
+ log.info("refresh-flag fired -- dispatching backend mediation", {
3342
+ connectorIds: eligible.map((m) => m.id)
3343
+ });
3344
+ await Promise.all(
3345
+ eligible.map(async (m) => {
3346
+ try {
3347
+ const entry = manager.get(m.id);
3348
+ if (typeof entry.connector.refreshExposedCredential !== "function") {
3349
+ log.debug("connector lacks refreshExposedCredential -- skipping", {
3350
+ connectorId: m.id
3351
+ });
3352
+ return;
3353
+ }
3354
+ await entry.connector.refreshExposedCredential(m.id, entry.handle);
3355
+ } catch (err) {
3356
+ log.warn("refresh-flag dispatch failed for connector", {
3357
+ connectorId: m.id,
3358
+ error: err instanceof Error ? err.message : String(err)
3359
+ });
3360
+ }
3361
+ })
3362
+ );
3363
+ }
3364
+ var CLAUDE_CODE_CREDENTIALS_KEY = "CLAUDE_CODE_CREDENTIALS_JSON";
3365
+ async function writeClaudeCodeCredentialsFile(home, json) {
3366
+ const claudeDir = join(home, ".claude");
3367
+ await mkdir(claudeDir, { recursive: true, mode: 448 });
3368
+ const finalPath = join(claudeDir, ".credentials.json");
3369
+ const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`;
3370
+ await writeFile(tmpPath, json, { mode: 384 });
3371
+ await rename(tmpPath, finalPath);
3372
+ return finalPath;
3373
+ }
3374
+ async function mergeAndRewriteCredentialsFile(home, accessToken, expiresAt) {
3375
+ const credPath = join(home, ".claude", ".credentials.json");
3376
+ let merged = {};
3377
+ if (existsSync(credPath)) {
3378
+ try {
3379
+ merged = JSON.parse(readFileSync(credPath, "utf-8"));
3380
+ } catch {
3381
+ merged = {};
3382
+ }
3383
+ }
3384
+ const oauthBlock = merged.claudeAiOauth ?? {};
3385
+ oauthBlock.accessToken = accessToken;
3386
+ if (expiresAt) oauthBlock.expiresAt = expiresAt;
3387
+ merged.claudeAiOauth = oauthBlock;
3388
+ merged.accessToken = accessToken;
3389
+ return writeClaudeCodeCredentialsFile(home, JSON.stringify(merged));
3390
+ }
3391
+ function extractClaudeAiOauthExpiresAt(json) {
3392
+ let parsed;
3393
+ try {
3394
+ parsed = JSON.parse(json);
3395
+ } catch {
3396
+ return null;
3397
+ }
3398
+ if (!parsed || typeof parsed !== "object") return null;
3399
+ const obj = parsed;
3400
+ const oauth = obj.claudeAiOauth;
3401
+ const raw = oauth?.expiresAt ?? obj.expiresAt;
3402
+ if (raw == null) return null;
3403
+ if (typeof raw === "string") {
3404
+ const t = Date.parse(raw);
3405
+ return Number.isFinite(t) ? new Date(t).toISOString() : null;
3406
+ }
3407
+ if (typeof raw === "number" && Number.isFinite(raw)) {
3408
+ return new Date(raw).toISOString();
3409
+ }
3410
+ return null;
3411
+ }
3412
+ function readCurrentClaudeAccessToken(home) {
3413
+ const credPath = join(home, ".claude", ".credentials.json");
3414
+ if (!existsSync(credPath)) return null;
3415
+ let parsed;
3416
+ try {
3417
+ parsed = JSON.parse(readFileSync(credPath, "utf-8"));
3418
+ } catch {
3419
+ return null;
3420
+ }
3421
+ if (!parsed || typeof parsed !== "object") return null;
3422
+ const obj = parsed;
3423
+ const raw = obj.claudeAiOauth?.accessToken ?? obj.accessToken;
3424
+ return typeof raw === "string" && raw.length > 0 ? raw : null;
3425
+ }
3295
3426
 
3296
3427
  // runner/src/lifecycle-handler.ts
3297
3428
  function buildLifecycleHandler(deps) {
@@ -3534,75 +3665,6 @@ function buildMcpRuntimeHandlers(deps) {
3534
3665
  }
3535
3666
  };
3536
3667
  }
3537
- function parseFleetHealthBody(body) {
3538
- const trimmed = body.trim().toLowerCase();
3539
- if (trimmed === "healthy") return "healthy";
3540
- if (trimmed === "degraded") return "degraded";
3541
- return "error";
3542
- }
3543
- async function dispatchFleetHealthFlag(dir, fileName, manager, log) {
3544
- if (!manager) return;
3545
- const connectorId = fileName;
3546
- if (!connectorId || connectorId.startsWith(".")) return;
3547
- let verdict;
3548
- try {
3549
- verdict = parseFleetHealthBody(await readFile(join(dir, connectorId), "utf8"));
3550
- } catch {
3551
- verdict = "error";
3552
- }
3553
- try {
3554
- await manager.reportFleetHealth(connectorId, verdict);
3555
- log.debug("fleet-health flag dispatched", { connectorId, verdict });
3556
- } catch (err) {
3557
- log.warn("fleet-health flag dispatch failed", {
3558
- connectorId,
3559
- error: err instanceof Error ? err.message : String(err)
3560
- });
3561
- }
3562
- }
3563
-
3564
- // runner/src/refresh-flag-dispatcher.ts
3565
- async function dispatchRefreshToExposedGitMounts(manager, log) {
3566
- if (!manager) return;
3567
- let gitConnectors;
3568
- try {
3569
- gitConnectors = manager.listGitConnectors();
3570
- } catch (err) {
3571
- log.warn("listGitConnectors failed during refresh-flag dispatch", {
3572
- error: err instanceof Error ? err.message : String(err)
3573
- });
3574
- return;
3575
- }
3576
- const eligible = gitConnectors.filter(
3577
- (m) => m.exposeAccessToken === true && m.auth === "backend"
3578
- );
3579
- if (eligible.length === 0) {
3580
- log.debug("refresh-flag fired but no eligible git connectors (Tier-2 backend) found");
3581
- return;
3582
- }
3583
- log.info("refresh-flag fired -- dispatching backend mediation", {
3584
- connectorIds: eligible.map((m) => m.id)
3585
- });
3586
- await Promise.all(
3587
- eligible.map(async (m) => {
3588
- try {
3589
- const entry = manager.get(m.id);
3590
- if (typeof entry.connector.refreshExposedCredential !== "function") {
3591
- log.debug("connector lacks refreshExposedCredential -- skipping", {
3592
- connectorId: m.id
3593
- });
3594
- return;
3595
- }
3596
- await entry.connector.refreshExposedCredential(m.id, entry.handle);
3597
- } catch (err) {
3598
- log.warn("refresh-flag dispatch failed for connector", {
3599
- connectorId: m.id,
3600
- error: err instanceof Error ? err.message : String(err)
3601
- });
3602
- }
3603
- })
3604
- );
3605
- }
3606
3668
  var RUNNER_CAP_ORIGIN = { kind: "framework" };
3607
3669
  function notImplemented(name) {
3608
3670
  return {
@@ -3823,67 +3885,68 @@ function buildRunnerCapabilities(handlers) {
3823
3885
  })
3824
3886
  ];
3825
3887
  }
3826
- var CLAUDE_CODE_CREDENTIALS_KEY = "CLAUDE_CODE_CREDENTIALS_JSON";
3827
- async function writeClaudeCodeCredentialsFile(home, json) {
3828
- const claudeDir = join(home, ".claude");
3829
- await mkdir(claudeDir, { recursive: true, mode: 448 });
3830
- const finalPath = join(claudeDir, ".credentials.json");
3831
- const tmpPath = `${finalPath}.tmp.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`;
3832
- await writeFile(tmpPath, json, { mode: 384 });
3833
- await rename(tmpPath, finalPath);
3834
- return finalPath;
3835
- }
3836
- async function mergeAndRewriteCredentialsFile(home, accessToken, expiresAt) {
3837
- const credPath = join(home, ".claude", ".credentials.json");
3838
- let merged = {};
3839
- if (existsSync(credPath)) {
3840
- try {
3841
- merged = JSON.parse(readFileSync(credPath, "utf-8"));
3842
- } catch {
3843
- merged = {};
3844
- }
3845
- }
3846
- const oauthBlock = merged.claudeAiOauth ?? {};
3847
- oauthBlock.accessToken = accessToken;
3848
- if (expiresAt) oauthBlock.expiresAt = expiresAt;
3849
- merged.claudeAiOauth = oauthBlock;
3850
- merged.accessToken = accessToken;
3851
- return writeClaudeCodeCredentialsFile(home, JSON.stringify(merged));
3852
- }
3853
- function extractClaudeAiOauthExpiresAt(json) {
3854
- let parsed;
3855
- try {
3856
- parsed = JSON.parse(json);
3857
- } catch {
3858
- return null;
3859
- }
3860
- if (!parsed || typeof parsed !== "object") return null;
3861
- const obj = parsed;
3862
- const oauth = obj.claudeAiOauth;
3863
- const raw = oauth?.expiresAt ?? obj.expiresAt;
3864
- if (raw == null) return null;
3865
- if (typeof raw === "string") {
3866
- const t = Date.parse(raw);
3867
- return Number.isFinite(t) ? new Date(t).toISOString() : null;
3868
- }
3869
- if (typeof raw === "number" && Number.isFinite(raw)) {
3870
- return new Date(raw).toISOString();
3871
- }
3872
- return null;
3873
- }
3874
- function readCurrentClaudeAccessToken(home) {
3875
- const credPath = join(home, ".claude", ".credentials.json");
3876
- if (!existsSync(credPath)) return null;
3877
- let parsed;
3878
- try {
3879
- parsed = JSON.parse(readFileSync(credPath, "utf-8"));
3880
- } catch {
3881
- return null;
3888
+
3889
+ // runner/src/session-capability-wiring.ts
3890
+ function wireSessionCapabilities(deps) {
3891
+ const {
3892
+ capabilityRegistry,
3893
+ remoteCapabilityInvoker,
3894
+ getResourceManager,
3895
+ getPreMintedSecrets,
3896
+ emitResourcesAvailable,
3897
+ driverPicksUpToolsLive,
3898
+ getOrCreateMcpManager,
3899
+ getCompactionOrchestrator,
3900
+ getProjectDir,
3901
+ attachSkillInstance,
3902
+ log
3903
+ } = deps;
3904
+ capabilityRegistry.setRemoteInvoker(remoteCapabilityInvoker);
3905
+ const { attachConnectorInstance, ...resourceCaps } = buildSessionResourceHandlers({
3906
+ getResourceManager,
3907
+ getPreMintedSecrets,
3908
+ emitResourcesAvailable,
3909
+ log,
3910
+ getProjectDir
3911
+ });
3912
+ const mcpHandlers = buildMcpRuntimeHandlers({
3913
+ getOrCreateMcpManager,
3914
+ getPreMintedSecrets: () => getPreMintedSecrets() ?? null,
3915
+ driverPicksUpToolsLive,
3916
+ emitResourcesAvailable,
3917
+ log,
3918
+ getProjectDir
3919
+ });
3920
+ const runnerCaps = buildRunnerCapabilities({
3921
+ ...resourceCaps,
3922
+ ...mcpHandlers,
3923
+ // attach_instance routes by kind: skills stage-then-fast-restart,
3924
+ // connectors materialize-then-connect; everything else stays on the
3925
+ // MCP attach path.
3926
+ attachInstance: async (input) => {
3927
+ if (input.kind === "skill") {
3928
+ return attachSkillInstance(input.name);
3929
+ }
3930
+ if (input.kind === "connector") {
3931
+ return attachConnectorInstance(input.name, input.preMintedToken);
3932
+ }
3933
+ return mcpHandlers.attachInstance ? mcpHandlers.attachInstance(input) : {
3934
+ ok: false,
3935
+ code: "not_implemented",
3936
+ message: "attach_instance handler not configured"
3937
+ };
3938
+ },
3939
+ // setLogLevel left undefined (the cap self-falls-back to getLogStore);
3940
+ // setState remains a stub (not resource hot-plug).
3941
+ lifecycle: buildLifecycleHandler({
3942
+ getCompactionOrchestrator,
3943
+ getResourceManager,
3944
+ log
3945
+ })
3946
+ });
3947
+ for (const cap of runnerCaps) {
3948
+ capabilityRegistry.register(cap, "agent");
3882
3949
  }
3883
- if (!parsed || typeof parsed !== "object") return null;
3884
- const obj = parsed;
3885
- const raw = obj.claudeAiOauth?.accessToken ?? obj.accessToken;
3886
- return typeof raw === "string" && raw.length > 0 ? raw : null;
3887
3950
  }
3888
3951
 
3889
3952
  // runner/src/session-stimulus.ts
@@ -4536,6 +4599,15 @@ async function startAgentServer(opts) {
4536
4599
  captureBakedMcpServers();
4537
4600
  }
4538
4601
  let resourceManager = secretsMode === "env" ? agentSession.resourceManager : null;
4602
+ const driverPicksUpToolsLive = () => agentSession?.driverType !== "claude-sdk";
4603
+ const emitResourcesAvailable = () => sendEvent(
4604
+ buildResourcesAvailablePayload(
4605
+ resourceManager,
4606
+ agentSession?.getExternalMcpManager(),
4607
+ driverPicksUpToolsLive(),
4608
+ bakedMcpServerIds
4609
+ )
4610
+ );
4539
4611
  if (secretsMode === "env") {
4540
4612
  if (!agentSession.provider) {
4541
4613
  log(
@@ -5000,6 +5072,7 @@ async function startAgentServer(opts) {
5000
5072
  cloudSecrets,
5001
5073
  fallbackConnectorDeclarations
5002
5074
  );
5075
+ let needsWireFallbackRecreate = false;
5003
5076
  if (!agentSession) {
5004
5077
  agentSession = await createAgentSession(sessionConfig);
5005
5078
  emitSystemPromptComposed(agentSession, sendEvent);
@@ -5007,72 +5080,30 @@ async function startAgentServer(opts) {
5007
5080
  driver = agentSession.driver;
5008
5081
  rebuildCompactionOrchestrator();
5009
5082
  registerSessionComposition(agentSession);
5010
- const driverPicksUpToolsLive = () => agentSession?.driverType !== "claude-sdk";
5011
- const emitResourcesAvailable = () => sendEvent(
5012
- buildResourcesAvailablePayload(
5013
- resourceManager,
5014
- agentSession?.getExternalMcpManager(),
5015
- driverPicksUpToolsLive(),
5016
- bakedMcpServerIds
5017
- )
5018
- );
5019
5083
  captureBakedMcpServers();
5020
5084
  emitResourcesAvailable();
5021
5085
  agentSession.startWatching();
5022
- capabilityRegistry.setRemoteInvoker(remoteCapabilityInvoker);
5023
- const { attachConnectorInstance, ...resourceCaps } = buildSessionResourceHandlers({
5024
- getResourceManager: () => resourceManager,
5025
- getPreMintedSecrets: () => preMintedSecrets,
5026
- emitResourcesAvailable,
5027
- log,
5028
- getProjectDir: () => opts.projectDir
5029
- });
5030
- const mcpHandlers = buildMcpRuntimeHandlers({
5031
- getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
5032
- getPreMintedSecrets: () => preMintedSecrets ?? null,
5033
- driverPicksUpToolsLive,
5034
- emitResourcesAvailable,
5035
- log,
5036
- getProjectDir: () => opts.projectDir
5037
- });
5038
- const runnerCaps = buildRunnerCapabilities({
5039
- ...resourceCaps,
5040
- ...mcpHandlers,
5041
- // attach_instance routes by kind: skills stage-then-fast-restart,
5042
- // connectors materialize-then-connect; everything else stays on the
5043
- // MCP attach path.
5044
- attachInstance: async (input) => {
5045
- if (input.kind === "skill") {
5046
- return attachSkillInstance(input.name);
5047
- }
5048
- if (input.kind === "connector") {
5049
- return attachConnectorInstance(input.name, input.preMintedToken);
5050
- }
5051
- return mcpHandlers.attachInstance ? mcpHandlers.attachInstance(input) : {
5052
- ok: false,
5053
- code: "not_implemented",
5054
- message: "attach_instance handler not configured"
5055
- };
5056
- },
5057
- // setLogLevel left undefined (the cap self-falls-back to getLogStore);
5058
- // setState remains a stub (not resource hot-plug).
5059
- lifecycle: buildLifecycleHandler({
5060
- getCompactionOrchestrator: () => compactionOrchestrator,
5061
- getResourceManager: () => resourceManager,
5062
- log
5063
- })
5064
- });
5065
- for (const cap of runnerCaps) {
5066
- capabilityRegistry.register(cap, "agent");
5067
- }
5068
5086
  log("[serve] session built from session_init envelope");
5069
5087
  } else if ((fallbackConnectorDeclarations?.length ?? 0) > 0 && !agentSession.resourceManager) {
5070
5088
  log(
5071
5089
  `[serve] session_init: recreating eagerly-built session to apply ${fallbackConnectorDeclarations.length} wire connector declaration(s) (no disk declarations)`
5072
5090
  );
5073
- return { needsWireFallbackRecreate: true };
5091
+ needsWireFallbackRecreate = true;
5074
5092
  }
5075
- return { needsWireFallbackRecreate: false };
5093
+ wireSessionCapabilities({
5094
+ capabilityRegistry,
5095
+ remoteCapabilityInvoker,
5096
+ getResourceManager: () => resourceManager,
5097
+ getPreMintedSecrets: () => preMintedSecrets,
5098
+ emitResourcesAvailable,
5099
+ driverPicksUpToolsLive,
5100
+ getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
5101
+ getCompactionOrchestrator: () => compactionOrchestrator,
5102
+ getProjectDir: () => opts.projectDir,
5103
+ attachSkillInstance,
5104
+ log
5105
+ });
5106
+ return { needsWireFallbackRecreate };
5076
5107
  }
5077
5108
  async function recreateAgentSession(overrides) {
5078
5109
  const disposedManager = agentSession.resourceManager;
@@ -5659,7 +5690,7 @@ async function startAgentServer(opts) {
5659
5690
  }
5660
5691
  async function handleDebug(cmd) {
5661
5692
  if (!await awaitSessionReadyOrFail()) return;
5662
- log(`[serve] debug query=${cmd.query}`);
5693
+ serverLog.debug(`[serve] debug query=${cmd.query}`);
5663
5694
  let result;
5664
5695
  try {
5665
5696
  result = await computeDebugResult(cmd);
@@ -6009,5 +6040,5 @@ function touchSession(state) {
6009
6040
  }
6010
6041
 
6011
6042
  export { CLAUDE_CODE_CREDENTIALS_KEY, COMPILE_MANIFEST_FILENAME, CapabilityRegistry, DEFAULT_CAPABILITY_CALL_TIMEOUT_MS, DEFAULT_COALESCE_MS, MarkdownStreamer, PreInitRingSink, agentDefinitionExists, bootstrapCapabilityRegistry, bootstrapRunnerLogStore, buildAgentResources, buildClientCapabilityHandler, buildConnectorTokenMediator, buildContextSection, buildEnvironmentSection, buildResourcesAvailablePayload, builtinCapabilities, capabilityLogInstance, clearPreInitRingSink, clearSession, compileComposition, computeCapabilitySignature, connectorRefreshKind, createAgentSession, createSessionStimulusBus, defineCapability, deleteSession, dispatchRunnerCapabilityInvocation, emitSystemPromptComposed, ensureGitConfigInclude, extractClaudeAiOauthExpiresAt, getPreInitRingSink, handleMountResourceRequest, handleResourceRequest, installPreInitRingSink, listSessions, loadAgentManifest, loadCompileManifest, loadCompileManifestFromDir, loadSession, loadSessionById, mcpAuthSecretKey, newSession, pickRepointedManager, planFlowMutate, registerCompositionCapabilities, rejectCapabilityOnApprovalDeny, resetRunnerLogStore, resolveAgentComposition, resolveAgentMixins, resolveBinding, resolveCapabilityCallTimeoutMs, resolveCapabilityResult, resolveComposition, resolveMixin, runAgentChat, saveSession, setCurrentSession, startAgentServer, touchSession, writeClaudeCodeCredentialsFile };
6012
- //# sourceMappingURL=chunk-DTZ7JUZY.js.map
6013
- //# sourceMappingURL=chunk-DTZ7JUZY.js.map
6043
+ //# sourceMappingURL=chunk-HGLQYLZB.js.map
6044
+ //# sourceMappingURL=chunk-HGLQYLZB.js.map