@skaile/workspaces 0.36.0 → 0.38.0

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 (116) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/{asset-feeds-PCLTE2W5.js → asset-feeds-W6JNAGNQ.js} +7 -7
  3. package/dist/{asset-feeds-PCLTE2W5.js.map → asset-feeds-W6JNAGNQ.js.map} +1 -1
  4. package/dist/asset-manager/index.js +5 -5
  5. package/dist/asset-manager/installer.js +4 -4
  6. package/dist/{chunk-WEQN6EWW.js → chunk-4A2LAEX6.js} +4 -4
  7. package/dist/{chunk-WEQN6EWW.js.map → chunk-4A2LAEX6.js.map} +1 -1
  8. package/dist/{chunk-O2OHGE4S.js → chunk-6KKNROBU.js} +2 -2
  9. package/dist/{chunk-O2OHGE4S.js.map → chunk-6KKNROBU.js.map} +1 -1
  10. package/dist/{chunk-LY5O73Q2.js → chunk-A26MZ2GW.js} +5 -5
  11. package/dist/{chunk-LY5O73Q2.js.map → chunk-A26MZ2GW.js.map} +1 -1
  12. package/dist/{chunk-XOBPOVFT.js → chunk-C54IAYEU.js} +3 -3
  13. package/dist/{chunk-XOBPOVFT.js.map → chunk-C54IAYEU.js.map} +1 -1
  14. package/dist/{chunk-EOCKR5TN.js → chunk-CBXZB3G5.js} +3 -3
  15. package/dist/{chunk-EOCKR5TN.js.map → chunk-CBXZB3G5.js.map} +1 -1
  16. package/dist/{chunk-5DPQ766L.js → chunk-CFCSDZYF.js} +3 -3
  17. package/dist/{chunk-5DPQ766L.js.map → chunk-CFCSDZYF.js.map} +1 -1
  18. package/dist/{chunk-JNH6TTIO.js → chunk-DQLRTCA2.js} +5 -5
  19. package/dist/{chunk-JNH6TTIO.js.map → chunk-DQLRTCA2.js.map} +1 -1
  20. package/dist/{chunk-2Q6OY3SU.js → chunk-FBIQ4QPF.js} +3 -3
  21. package/dist/{chunk-2Q6OY3SU.js.map → chunk-FBIQ4QPF.js.map} +1 -1
  22. package/dist/{chunk-YPRW2ROJ.js → chunk-GL3MUJ5L.js} +2 -2
  23. package/dist/{chunk-YPRW2ROJ.js.map → chunk-GL3MUJ5L.js.map} +1 -1
  24. package/dist/{chunk-I3TERDTR.js → chunk-HAXQAC6D.js} +2 -2
  25. package/dist/{chunk-I3TERDTR.js.map → chunk-HAXQAC6D.js.map} +1 -1
  26. package/dist/{chunk-56YT6CWS.js → chunk-HL66R2P2.js} +23 -18
  27. package/dist/chunk-HL66R2P2.js.map +1 -0
  28. package/dist/{chunk-ZE5WYJVU.js → chunk-KM6IWBDN.js} +6 -6
  29. package/dist/{chunk-ZE5WYJVU.js.map → chunk-KM6IWBDN.js.map} +1 -1
  30. package/dist/{chunk-FDLVPYSN.js → chunk-OW32SQU3.js} +181 -36
  31. package/dist/chunk-OW32SQU3.js.map +1 -0
  32. package/dist/{chunk-XT6AZWK3.js → chunk-P7CIT445.js} +18 -2
  33. package/dist/chunk-P7CIT445.js.map +1 -0
  34. package/dist/{chunk-MCQ4TJ3P.js → chunk-WLWHOA3S.js} +82 -6
  35. package/dist/chunk-WLWHOA3S.js.map +1 -0
  36. package/dist/cli/index.js +29 -29
  37. package/dist/connectors/config.js +4 -4
  38. package/dist/connectors/index.js +6 -6
  39. package/dist/connectors/rclone.js +1 -1
  40. package/dist/connectors/src/config.d.ts +3 -1
  41. package/dist/connectors/src/config.d.ts.map +1 -1
  42. package/dist/connectors/src/index.d.ts +1 -0
  43. package/dist/connectors/src/index.d.ts.map +1 -1
  44. package/dist/connectors/src/materialized-connectors.d.ts +8 -0
  45. package/dist/connectors/src/materialized-connectors.d.ts.map +1 -0
  46. package/dist/connectors/src/rclone-process-manager.d.ts.map +1 -1
  47. package/dist/core/index.js +3 -3
  48. package/dist/core/runtime-assets.js +2 -2
  49. package/dist/core/src/index.d.ts +1 -1
  50. package/dist/core/src/index.d.ts.map +1 -1
  51. package/dist/core/src/workspace-config.d.ts +6 -0
  52. package/dist/core/src/workspace-config.d.ts.map +1 -1
  53. package/dist/core/workspace-config.js +1 -1
  54. package/dist/deploy/index.js +3 -3
  55. package/dist/{ensure-sources-HMMEQEZC.js → ensure-sources-AGORTKJC.js} +5 -5
  56. package/dist/{ensure-sources-HMMEQEZC.js.map → ensure-sources-AGORTKJC.js.map} +1 -1
  57. package/dist/factory-assets/connectors/deploy.js +6 -6
  58. package/dist/factory-assets/connectors/devserver.js +6 -6
  59. package/dist/factory-assets/connectors/flow/adapter.js +6 -6
  60. package/dist/factory-assets/connectors/flow/engine.js +3 -3
  61. package/dist/factory-assets/connectors/flow/run-flow.js +7 -7
  62. package/dist/factory-assets/connectors/flow.js +6 -6
  63. package/dist/factory-assets/connectors/git.js +6 -6
  64. package/dist/factory-assets/connectors/gmail.js +6 -6
  65. package/dist/factory-assets/connectors/googledrive.js +6 -6
  66. package/dist/factory-assets/connectors/local.js +6 -6
  67. package/dist/factory-assets/connectors/mattermost.js +6 -6
  68. package/dist/factory-assets/connectors/memory.js +6 -6
  69. package/dist/factory-assets/connectors/minio.js +6 -6
  70. package/dist/factory-assets/connectors/postgres.js +6 -6
  71. package/dist/factory-assets/connectors/s3.js +6 -6
  72. package/dist/factory-assets/connectors/sharepoint.js +6 -6
  73. package/dist/factory-assets/connectors/sqlite.js +6 -6
  74. package/dist/factory-assets/connectors/static-server.js +6 -6
  75. package/dist/factory-assets/connectors/tunnel.js +6 -6
  76. package/dist/factory-assets/connectors/webdav.js +6 -6
  77. package/dist/factory-assets/connectors/xstate-store.js +6 -6
  78. package/dist/factory-assets/connectors/xstate.js +6 -6
  79. package/dist/{flows-O7OXGFIY.js → flows-BOJMGLRI.js} +3 -3
  80. package/dist/{flows-O7OXGFIY.js.map → flows-BOJMGLRI.js.map} +1 -1
  81. package/dist/library/index.js +3 -3
  82. package/dist/library/install.js +3 -3
  83. package/dist/{open-library-5WWTBHQD.js → open-library-WTN7QLN7.js} +6 -6
  84. package/dist/{open-library-5WWTBHQD.js.map → open-library-WTN7QLN7.js.map} +1 -1
  85. package/dist/{paths-UC3ZHLKC.js → paths-66ZDGXK3.js} +6 -6
  86. package/dist/{paths-UC3ZHLKC.js.map → paths-66ZDGXK3.js.map} +1 -1
  87. package/dist/{plugin-store-R2WLXRT3.js → plugin-store-BOQXW3XV.js} +5 -5
  88. package/dist/{plugin-store-R2WLXRT3.js.map → plugin-store-BOQXW3XV.js.map} +1 -1
  89. package/dist/runner/index.js +8 -8
  90. package/dist/runner/src/external-mcp.d.ts +5 -0
  91. package/dist/runner/src/external-mcp.d.ts.map +1 -1
  92. package/dist/runner/src/mcp-runtime-handlers.d.ts +26 -10
  93. package/dist/runner/src/mcp-runtime-handlers.d.ts.map +1 -1
  94. package/dist/runner/src/runner-capabilities.d.ts +26 -0
  95. package/dist/runner/src/runner-capabilities.d.ts.map +1 -1
  96. package/dist/runner/src/serve.d.ts.map +1 -1
  97. package/dist/runner/src/session-resource-handlers.d.ts +22 -12
  98. package/dist/runner/src/session-resource-handlers.d.ts.map +1 -1
  99. package/dist/sdk/asset-manager.js +5 -5
  100. package/dist/sdk/core.js +3 -3
  101. package/dist/sdk/flow.js +3 -3
  102. package/dist/sdk/index.js +8 -8
  103. package/dist/sdk/runner.js +8 -8
  104. package/dist/{setup-QQ3SNNWP.js → setup-JIGNL3O4.js} +5 -5
  105. package/dist/{setup-QQ3SNNWP.js.map → setup-JIGNL3O4.js.map} +1 -1
  106. package/dist/{store-client-4GKV4LOD.js → store-client-ODJJK5XS.js} +6 -6
  107. package/dist/{store-client-4GKV4LOD.js.map → store-client-ODJJK5XS.js.map} +1 -1
  108. package/dist/tui/index.js +8 -8
  109. package/dist/workspace-plugin/adapters/mcp.js +1 -1
  110. package/dist/workspace-plugin/adapters/omp.js +3 -3
  111. package/dist/workspace-plugin/index.js +1 -1
  112. package/package.json +1 -1
  113. package/dist/chunk-56YT6CWS.js.map +0 -1
  114. package/dist/chunk-FDLVPYSN.js.map +0 -1
  115. package/dist/chunk-MCQ4TJ3P.js.map +0 -1
  116. package/dist/chunk-XT6AZWK3.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { WorkspacePlugin } from './chunk-YPRW2ROJ.js';
1
+ import { WorkspacePlugin } from './chunk-GL3MUJ5L.js';
2
2
  import { WebSocketServerTransport } from './chunk-WQ7DE5UC.js';
3
3
  import { assembleSystemPrompt, buildCapabilitiesPromptSection } from './chunk-W3UDISS2.js';
4
4
  import { PROTOCOL_VERSION } from './chunk-TDSRLMDB.js';
@@ -6,12 +6,12 @@ import { EventNormalizer } from './chunk-5IXCNMMU.js';
6
6
  import { classifyClaudeSdkError } from './chunk-GAH4YRCI.js';
7
7
  import { createDriver } from './chunk-KM6DCR7A.js';
8
8
  import { deployCatalogEntry, undeployCatalogEntry } from './chunk-LV2HPH3C.js';
9
- import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, ConnectorStartupError, buildSdkConnectorTools } from './chunk-JNH6TTIO.js';
10
- import { loadConnectorDeclarations, SecretProviderChain, PreMintedSecretProvider, InMemorySecretProvider } from './chunk-MCQ4TJ3P.js';
9
+ import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, ConnectorStartupError, buildSdkConnectorTools } from './chunk-DQLRTCA2.js';
10
+ import { loadConnectorDeclarations, SecretProviderChain, PreMintedSecretProvider, InMemorySecretProvider, deriveSingleMaterializedConnectorDeclaration } from './chunk-WLWHOA3S.js';
11
11
  import { renderStimulusPrompt, buildOrchestratorPrompt } from './chunk-DEYYRFQU.js';
12
- import { resolveSettings, resolveApiKey, providerEnvKey } from './chunk-2Q6OY3SU.js';
13
- import { resolveRuntimeAssets } from './chunk-5DPQ766L.js';
14
- import { resolveSkWorkspaceConfig, resolveAgentDir, stageMaterializedSkills, loadMcpServerDeclarations, COMPACTION_DEFAULTS, validateAssetRecipeAttr } from './chunk-56YT6CWS.js';
12
+ import { resolveSettings, resolveApiKey, providerEnvKey } from './chunk-FBIQ4QPF.js';
13
+ import { resolveRuntimeAssets } from './chunk-CFCSDZYF.js';
14
+ import { resolveSkWorkspaceConfig, resolveAgentDir, stageMaterializedSkills, loadMcpServerDeclarations, COMPACTION_DEFAULTS, validateAssetRecipeAttr, deriveSingleMaterializedMcpDeclaration } from './chunk-HL66R2P2.js';
15
15
  import { parseAssetRef } from './chunk-BM7XANVN.js';
16
16
  import { resolveDriverPaths } from './chunk-K5GBV4SA.js';
17
17
  import { getLogStore, resolveLogStoreConfig, createLogStoreFromConfig, OnLogBridgeSink, WsLogSink, registerLogStore, resetLogStore, createLogger } from './chunk-JB35MVBN.js';
@@ -19,7 +19,7 @@ import { __require } from './chunk-NSBPE2FW.js';
19
19
  import pc from 'picocolors';
20
20
  import { Marked } from 'marked';
21
21
  import { markedTerminal } from 'marked-terminal';
22
- import { readdirSync, existsSync, readFileSync, unlinkSync, mkdirSync, writeFileSync, statSync, watch, openSync, readSync, closeSync } from 'fs';
22
+ import { readdirSync, existsSync, readFileSync, unlinkSync, mkdirSync, writeFileSync, statSync, watch, chmodSync, openSync, readSync, closeSync } from 'fs';
23
23
  import path4, { join, resolve, relative, sep, isAbsolute, dirname, basename } from 'path';
24
24
  import { homedir } from 'os';
25
25
  import * as z5 from 'zod';
@@ -882,6 +882,14 @@ function validateSubstitutedPaths(command, args) {
882
882
  }
883
883
 
884
884
  // runner/src/external-mcp.ts
885
+ var McpServerAlreadyRegisteredError = class extends Error {
886
+ constructor(id) {
887
+ super(`MCP server '${id}' is already registered`);
888
+ this.id = id;
889
+ this.name = "McpServerAlreadyRegisteredError";
890
+ }
891
+ id;
892
+ };
885
893
  function resolveRecordSecrets(record, secrets) {
886
894
  if (!secrets) return record;
887
895
  const resolved = {};
@@ -1086,7 +1094,7 @@ var ExternalMcpManager = class {
1086
1094
  */
1087
1095
  async addServer(decl) {
1088
1096
  if (this.servers.some((s) => s.id === decl.id)) {
1089
- throw new Error(`MCP server '${decl.id}' is already registered`);
1097
+ throw new McpServerAlreadyRegisteredError(decl.id);
1090
1098
  }
1091
1099
  const client = await this.connectWithReauth(decl);
1092
1100
  const server = { id: decl.id, decl, client, toolNames: [] };
@@ -2941,8 +2949,16 @@ function buildLifecycleHandler(deps) {
2941
2949
  return { ok: true };
2942
2950
  };
2943
2951
  }
2944
-
2945
- // runner/src/session-resource-handlers.ts
2952
+ function readResolvedConnectorSecret(instancePath, id) {
2953
+ if (!existsSync(instancePath)) return void 0;
2954
+ try {
2955
+ const parsed = JSON.parse(readFileSync(instancePath, "utf8"));
2956
+ const value = parsed.resolvedSecrets?.[`connector:${id}`];
2957
+ return typeof value === "string" ? value : void 0;
2958
+ } catch {
2959
+ return void 0;
2960
+ }
2961
+ }
2946
2962
  function asDeclaration(declaration) {
2947
2963
  if (declaration !== null && typeof declaration === "object" && typeof declaration.id === "string" && typeof declaration.driver === "string") {
2948
2964
  return declaration;
@@ -2953,7 +2969,7 @@ function toPreMinted(token) {
2953
2969
  return { ok: true, token: token.token, expiresAt: token.expiresAt ?? null };
2954
2970
  }
2955
2971
  function buildSessionResourceHandlers(deps) {
2956
- const { getResourceManager, getPreMintedSecrets, emitResourcesAvailable, log } = deps;
2972
+ const { getResourceManager, getPreMintedSecrets, emitResourcesAvailable, log, getProjectDir } = deps;
2957
2973
  async function add(kind, input) {
2958
2974
  const rm = getResourceManager();
2959
2975
  if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
@@ -2967,6 +2983,9 @@ function buildSessionResourceHandlers(deps) {
2967
2983
  try {
2968
2984
  await rm.connect(decl);
2969
2985
  } catch (err) {
2986
+ if (input.preMintedToken) {
2987
+ getPreMintedSecrets()?.unset(kind, decl.id);
2988
+ }
2970
2989
  const message = err instanceof Error ? err.message : String(err);
2971
2990
  log(`[session-resource] runner.add_${kind} failed for ${decl.id}: ${message}`);
2972
2991
  return { ok: false, code: "connect_failed", message };
@@ -2975,9 +2994,52 @@ function buildSessionResourceHandlers(deps) {
2975
2994
  log(`[session-resource] runner.add_${kind} connected ${decl.id}`);
2976
2995
  return { ok: true, id: decl.id };
2977
2996
  }
2997
+ async function attachConnectorInstance(name) {
2998
+ if (!name) {
2999
+ return { ok: false, code: "invalid_input", message: "name is required" };
3000
+ }
3001
+ if (name.includes("/") || name.includes("\\") || name.includes("..")) {
3002
+ return {
3003
+ ok: false,
3004
+ code: "invalid_input",
3005
+ message: "name must not contain path separators or traversal segments"
3006
+ };
3007
+ }
3008
+ const projectDir = getProjectDir?.();
3009
+ if (!projectDir) {
3010
+ return { ok: false, code: "no_project_dir", message: "getProjectDir not configured" };
3011
+ }
3012
+ const root = join(projectDir, ".skaile/assets/connector");
3013
+ const decl = deriveSingleMaterializedConnectorDeclaration(root, name);
3014
+ if (!decl) {
3015
+ return {
3016
+ ok: false,
3017
+ code: "not_materialized",
3018
+ message: `no materialized connector at ${join(root, name)}`
3019
+ };
3020
+ }
3021
+ const rm = getResourceManager();
3022
+ if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
3023
+ const token = readResolvedConnectorSecret(join(root, name, ".instance.json"), decl.id);
3024
+ if (token !== void 0) {
3025
+ getPreMintedSecrets()?.set("connector", decl.id, { ok: true, token, expiresAt: null });
3026
+ }
3027
+ try {
3028
+ await rm.connect(decl);
3029
+ } catch (err) {
3030
+ getPreMintedSecrets()?.unset("connector", decl.id);
3031
+ const message = err instanceof Error ? err.message : String(err);
3032
+ log(`[session-resource] runner.attach_instance connector failed for ${decl.id}: ${message}`);
3033
+ return { ok: false, code: "connector_connect_failed", message };
3034
+ }
3035
+ emitResourcesAvailable();
3036
+ log(`[session-resource] runner.attach_instance connected connector ${decl.id}`);
3037
+ return { ok: true, id: decl.id, live: true, toolCount: 0 };
3038
+ }
2978
3039
  return {
2979
3040
  addConnector: (input) => add("connector", input),
2980
3041
  addMount: (input) => add("mount", input),
3042
+ attachConnectorInstance,
2981
3043
  removeResource: async (input) => {
2982
3044
  const rm = getResourceManager();
2983
3045
  if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
@@ -3040,7 +3102,57 @@ function buildMcpRuntimeHandlers(deps) {
3040
3102
  } catch (err) {
3041
3103
  deps.getPreMintedSecrets()?.unset("mcp", decl.id);
3042
3104
  const message = err instanceof Error ? err.message : String(err);
3043
- const code = message.includes("already registered") ? "mcp_already_registered" : "mcp_connect_failed";
3105
+ const code = err instanceof McpServerAlreadyRegisteredError ? "mcp_already_registered" : "mcp_connect_failed";
3106
+ return { ok: false, code, message };
3107
+ }
3108
+ },
3109
+ attachInstance: async (input) => {
3110
+ if (input.kind !== "mcp-server") {
3111
+ return {
3112
+ ok: false,
3113
+ code: "unsupported_kind",
3114
+ message: `attach_instance supports mcp-server only; '${input.kind}' is not yet supported`
3115
+ };
3116
+ }
3117
+ if (!input.name) {
3118
+ return { ok: false, code: "invalid_input", message: "name is required" };
3119
+ }
3120
+ if (input.name.includes("/") || input.name.includes("\\") || input.name.includes("..")) {
3121
+ return {
3122
+ ok: false,
3123
+ code: "invalid_input",
3124
+ message: "name must not contain path separators or traversal segments"
3125
+ };
3126
+ }
3127
+ if (!deps.getProjectDir) {
3128
+ return { ok: false, code: "no_project_dir", message: "getProjectDir not configured" };
3129
+ }
3130
+ const subDir = join(deps.getProjectDir(), ".skaile/assets/mcp-server", input.name);
3131
+ const decl = deriveSingleMaterializedMcpDeclaration(subDir, input.name);
3132
+ if (!decl) {
3133
+ return {
3134
+ ok: false,
3135
+ code: "not_materialized",
3136
+ message: `no materialized mcp-server at ${subDir}`
3137
+ };
3138
+ }
3139
+ const mgr = deps.getOrCreateMcpManager();
3140
+ if (!mgr) return { ok: false, code: "no_session", message: "session resources not ready" };
3141
+ try {
3142
+ const { toolNames } = await mgr.addServer(decl);
3143
+ deps.emitResourcesAvailable();
3144
+ deps.log(
3145
+ `[mcp-runtime] runner.attach_instance connected ${decl.id} (${toolNames.length} tools)`
3146
+ );
3147
+ return {
3148
+ ok: true,
3149
+ id: decl.id,
3150
+ live: deps.driverPicksUpToolsLive(),
3151
+ toolCount: toolNames.length
3152
+ };
3153
+ } catch (err) {
3154
+ const message = err instanceof Error ? err.message : String(err);
3155
+ const code = err instanceof McpServerAlreadyRegisteredError ? "mcp_already_registered" : "mcp_connect_failed";
3044
3156
  return { ok: false, code, message };
3045
3157
  }
3046
3158
  }
@@ -3141,6 +3253,10 @@ var addMcpServerInputSchema = z5.strictObject({
3141
3253
  declaration: requiredUnknown,
3142
3254
  preMintedToken: preMintedTokenSchema
3143
3255
  });
3256
+ var attachInstanceInputSchema = z5.strictObject({
3257
+ kind: z5.string(),
3258
+ name: z5.string()
3259
+ });
3144
3260
  var removeResourceInput = z5.strictObject({
3145
3261
  id: z5.string()
3146
3262
  });
@@ -3219,6 +3335,20 @@ function buildRunnerCapabilities(handlers) {
3219
3335
  });
3220
3336
  }
3221
3337
  }),
3338
+ defineCapability({
3339
+ name: "runner.attach_instance",
3340
+ displayName: "Attach instance",
3341
+ description: "Materialize-then-attach-by-ref: the platform writes the asset to .skaile/assets/ then invokes this cap; the runner self-derives the declaration from disk and attaches it live.",
3342
+ side: "agent",
3343
+ origin: RUNNER_CAP_ORIGIN,
3344
+ audience: ["runtime"],
3345
+ kind: "effect",
3346
+ input: attachInstanceInputSchema,
3347
+ handler: async (input) => {
3348
+ if (!handlers.attachInstance) return notImplemented("runner.attach_instance");
3349
+ return handlers.attachInstance({ kind: input.kind, name: input.name });
3350
+ }
3351
+ }),
3222
3352
  defineCapability({
3223
3353
  name: "runner.remove_resource",
3224
3354
  displayName: "Remove resource",
@@ -4150,11 +4280,15 @@ async function startAgentServer(opts) {
4150
4280
  }
4151
4281
  const fleetHealthDir = join(opts.projectDir, ".skaile", "fleet-health");
4152
4282
  try {
4153
- mkdirSync(fleetHealthDir, { recursive: true });
4283
+ mkdirSync(fleetHealthDir, { recursive: true, mode: 1528 });
4284
+ chmodSync(fleetHealthDir, 1528);
4154
4285
  } catch (err) {
4155
- serverLog.warn("failed to pre-create fleet-health dir \u2014 platform health signal disabled", {
4156
- error: err instanceof Error ? err.message : String(err)
4157
- });
4286
+ serverLog.warn(
4287
+ "failed to pre-create/chmod fleet-health dir \u2014 platform health signal may be degraded",
4288
+ {
4289
+ error: err instanceof Error ? err.message : String(err)
4290
+ }
4291
+ );
4158
4292
  }
4159
4293
  let fleetHealthWatcher = null;
4160
4294
  try {
@@ -4284,25 +4418,36 @@ async function startAgentServer(opts) {
4284
4418
  emitResourcesAvailable();
4285
4419
  agentSession.startWatching();
4286
4420
  capabilityRegistry.setRemoteInvoker(remoteCapabilityInvoker);
4421
+ const { attachConnectorInstance, ...resourceCaps } = buildSessionResourceHandlers({
4422
+ getResourceManager: () => resourceManager,
4423
+ getPreMintedSecrets: () => preMintedSecrets,
4424
+ emitResourcesAvailable,
4425
+ log,
4426
+ getProjectDir: () => opts.projectDir
4427
+ });
4428
+ const mcpHandlers = buildMcpRuntimeHandlers({
4429
+ getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
4430
+ getPreMintedSecrets: () => preMintedSecrets ?? null,
4431
+ driverPicksUpToolsLive,
4432
+ emitResourcesAvailable,
4433
+ log,
4434
+ getProjectDir: () => opts.projectDir
4435
+ });
4287
4436
  const runnerCaps = buildRunnerCapabilities({
4288
- // Resource hot-plug handlers, wired to the live session's
4289
- // ConnectorManager + PreMintedSecretProvider via getters because
4290
- // both are lazily (re)assigned in this scope.
4291
- ...buildSessionResourceHandlers({
4292
- getResourceManager: () => resourceManager,
4293
- getPreMintedSecrets: () => preMintedSecrets,
4294
- emitResourcesAvailable,
4295
- log
4296
- }),
4297
- // runner.add_mcp_server — wired to the live session's lazily-created
4298
- // ExternalMcpManager + PreMintedSecretProvider.
4299
- ...buildMcpRuntimeHandlers({
4300
- getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
4301
- getPreMintedSecrets: () => preMintedSecrets ?? null,
4302
- driverPicksUpToolsLive,
4303
- emitResourcesAvailable,
4304
- log
4305
- }),
4437
+ ...resourceCaps,
4438
+ ...mcpHandlers,
4439
+ // attach_instance routes by kind: connectors take the materialize-then-
4440
+ // connect path; everything else stays on the MCP attach path.
4441
+ attachInstance: async (input) => {
4442
+ if (input.kind === "connector") {
4443
+ return attachConnectorInstance(input.name);
4444
+ }
4445
+ return mcpHandlers.attachInstance ? mcpHandlers.attachInstance(input) : {
4446
+ ok: false,
4447
+ code: "not_implemented",
4448
+ message: "attach_instance handler not configured"
4449
+ };
4450
+ },
4306
4451
  // setLogLevel left undefined (the cap self-falls-back to getLogStore);
4307
4452
  // setState remains a stub (not resource hot-plug).
4308
4453
  lifecycle: buildLifecycleHandler({
@@ -5195,5 +5340,5 @@ function touchSession(state) {
5195
5340
  }
5196
5341
 
5197
5342
  export { CLAUDE_CODE_CREDENTIALS_KEY, COMPILE_MANIFEST_FILENAME, CapabilityRegistry, DEFAULT_CAPABILITY_CALL_TIMEOUT_MS, DEFAULT_COALESCE_MS, MarkdownStreamer, PreInitRingSink, agentDefinitionExists, bootstrapCapabilityRegistry, bootstrapRunnerLogStore, buildAgentResources, buildClientCapabilityHandler, buildContextSection, buildEnvironmentSection, buildResourcesAvailablePayload, builtinCapabilities, clearPreInitRingSink, clearSession, compileComposition, computeCapabilitySignature, createAgentSession, createSessionStimulusBus, defineCapability, deleteSession, dispatchRunnerCapabilityInvocation, emitSystemPromptComposed, ensureGitConfigInclude, extractClaudeAiOauthExpiresAt, getPreInitRingSink, handleMountResourceRequest, handleResourceRequest, installPreInitRingSink, listSessions, loadAgentManifest, loadCompileManifest, loadCompileManifestFromDir, loadSession, loadSessionById, mcpAuthSecretKey, newSession, registerCompositionCapabilities, rejectCapabilityOnApprovalDeny, resetRunnerLogStore, resolveAgentComposition, resolveAgentMixins, resolveBinding, resolveCapabilityCallTimeoutMs, resolveCapabilityResult, resolveComposition, resolveMixin, runAgentChat, saveSession, setCurrentSession, startAgentServer, touchSession, writeClaudeCodeCredentialsFile };
5198
- //# sourceMappingURL=chunk-FDLVPYSN.js.map
5199
- //# sourceMappingURL=chunk-FDLVPYSN.js.map
5343
+ //# sourceMappingURL=chunk-OW32SQU3.js.map
5344
+ //# sourceMappingURL=chunk-OW32SQU3.js.map