@skaile/workspaces 0.37.0 → 0.39.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 (73) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/asset-manager/index.js +1 -1
  3. package/dist/{chunk-3HR6IN5B.js → chunk-CMZWYMGD.js} +44 -15
  4. package/dist/chunk-CMZWYMGD.js.map +1 -0
  5. package/dist/{chunk-ZSFWJAFD.js → chunk-FZL6QOM7.js} +3 -3
  6. package/dist/{chunk-ZSFWJAFD.js.map → chunk-FZL6QOM7.js.map} +1 -1
  7. package/dist/{chunk-CCQ3EMJT.js → chunk-LJIE3PGF.js} +2 -2
  8. package/dist/{chunk-CCQ3EMJT.js.map → chunk-LJIE3PGF.js.map} +1 -1
  9. package/dist/{chunk-XT6AZWK3.js → chunk-P7CIT445.js} +18 -2
  10. package/dist/chunk-P7CIT445.js.map +1 -0
  11. package/dist/{chunk-DAEYSPOC.js → chunk-W23HDR6W.js} +117 -37
  12. package/dist/chunk-W23HDR6W.js.map +1 -0
  13. package/dist/{chunk-CC5ZHSHJ.js → chunk-WLWHOA3S.js} +81 -5
  14. package/dist/chunk-WLWHOA3S.js.map +1 -0
  15. package/dist/{chunk-RNFNWOKZ.js → chunk-WVWX76IB.js} +2 -2
  16. package/dist/{chunk-RNFNWOKZ.js.map → chunk-WVWX76IB.js.map} +1 -1
  17. package/dist/cli/index.js +7 -7
  18. package/dist/connectors/config.js +1 -1
  19. package/dist/connectors/index.js +3 -3
  20. package/dist/connectors/rclone.js +1 -1
  21. package/dist/connectors/src/config.d.ts +3 -1
  22. package/dist/connectors/src/config.d.ts.map +1 -1
  23. package/dist/connectors/src/connector-manager.d.ts +1 -1
  24. package/dist/connectors/src/connector-manager.d.ts.map +1 -1
  25. package/dist/connectors/src/connector-types.d.ts +5 -1
  26. package/dist/connectors/src/connector-types.d.ts.map +1 -1
  27. package/dist/connectors/src/index.d.ts +1 -0
  28. package/dist/connectors/src/index.d.ts.map +1 -1
  29. package/dist/connectors/src/materialized-connectors.d.ts +8 -0
  30. package/dist/connectors/src/materialized-connectors.d.ts.map +1 -0
  31. package/dist/connectors/src/rclone-process-manager.d.ts.map +1 -1
  32. package/dist/factory-assets/connectors/deploy.js +3 -3
  33. package/dist/factory-assets/connectors/devserver.js +3 -3
  34. package/dist/factory-assets/connectors/flow/adapter.js +3 -3
  35. package/dist/factory-assets/connectors/flow/run-flow.js +4 -4
  36. package/dist/factory-assets/connectors/flow.js +3 -3
  37. package/dist/factory-assets/connectors/git/driver.d.ts +3 -0
  38. package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
  39. package/dist/factory-assets/connectors/git.js +3 -3
  40. package/dist/factory-assets/connectors/gmail.js +3 -3
  41. package/dist/factory-assets/connectors/googledrive.js +3 -3
  42. package/dist/factory-assets/connectors/local.js +3 -3
  43. package/dist/factory-assets/connectors/mattermost.js +3 -3
  44. package/dist/factory-assets/connectors/memory.js +3 -3
  45. package/dist/factory-assets/connectors/minio.js +3 -3
  46. package/dist/factory-assets/connectors/postgres/adapter.d.ts.map +1 -1
  47. package/dist/factory-assets/connectors/postgres.js +3 -3
  48. package/dist/factory-assets/connectors/s3.js +3 -3
  49. package/dist/factory-assets/connectors/sharepoint.js +3 -3
  50. package/dist/factory-assets/connectors/sqlite.js +3 -3
  51. package/dist/factory-assets/connectors/static-server.js +3 -3
  52. package/dist/factory-assets/connectors/tunnel.js +3 -3
  53. package/dist/factory-assets/connectors/webdav.js +3 -3
  54. package/dist/factory-assets/connectors/xstate-store.js +3 -3
  55. package/dist/factory-assets/connectors/xstate.js +3 -3
  56. package/dist/runner/index.js +5 -5
  57. package/dist/runner/src/resource-handler.d.ts +6 -0
  58. package/dist/runner/src/resource-handler.d.ts.map +1 -1
  59. package/dist/runner/src/runner-capabilities.d.ts +8 -0
  60. package/dist/runner/src/runner-capabilities.d.ts.map +1 -1
  61. package/dist/runner/src/serve.d.ts.map +1 -1
  62. package/dist/runner/src/session-resource-handlers.d.ts +25 -12
  63. package/dist/runner/src/session-resource-handlers.d.ts.map +1 -1
  64. package/dist/sdk/asset-manager.js +1 -1
  65. package/dist/sdk/index.js +5 -5
  66. package/dist/sdk/runner.js +5 -5
  67. package/dist/tui/index.js +5 -5
  68. package/dist/workspace-plugin/index.js +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-3HR6IN5B.js.map +0 -1
  71. package/dist/chunk-CC5ZHSHJ.js.map +0 -1
  72. package/dist/chunk-DAEYSPOC.js.map +0 -1
  73. package/dist/chunk-XT6AZWK3.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { WorkspacePlugin } from './chunk-CCQ3EMJT.js';
1
+ import { WorkspacePlugin } from './chunk-LJIE3PGF.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,8 +6,8 @@ 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-3HR6IN5B.js';
10
- import { loadConnectorDeclarations, SecretProviderChain, PreMintedSecretProvider, InMemorySecretProvider } from './chunk-CC5ZHSHJ.js';
9
+ import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, ConnectorStartupError, buildSdkConnectorTools } from './chunk-CMZWYMGD.js';
10
+ import { loadConnectorDeclarations, SecretProviderChain, PreMintedSecretProvider, InMemorySecretProvider, deriveSingleMaterializedConnectorDeclaration } from './chunk-WLWHOA3S.js';
11
11
  import { renderStimulusPrompt, buildOrchestratorPrompt } from './chunk-DEYYRFQU.js';
12
12
  import { resolveSettings, resolveApiKey, providerEnvKey } from './chunk-FBIQ4QPF.js';
13
13
  import { resolveRuntimeAssets } from './chunk-CFCSDZYF.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';
@@ -2400,6 +2400,12 @@ async function handleResourceRequest(command, manager, emit) {
2400
2400
  function getMimeType(filename) {
2401
2401
  return mime.getType(filename) ?? "application/octet-stream";
2402
2402
  }
2403
+ var HTML_CLOSE_TAG_RE = /<\/html>/i;
2404
+ function stripStaleHtmlTail(content, contentType) {
2405
+ if (!contentType.toLowerCase().startsWith("text/html")) return content;
2406
+ const m = HTML_CLOSE_TAG_RE.exec(content);
2407
+ return m ? content.slice(0, m.index + m[0].length) : content;
2408
+ }
2403
2409
  function isBinaryFile(filePath) {
2404
2410
  try {
2405
2411
  const fd = openSync(filePath, "r");
@@ -2459,7 +2465,7 @@ function handleMountResourceRequest(command, manager, emit) {
2459
2465
  };
2460
2466
  } else {
2461
2467
  data = {
2462
- data: readFileSync(targetPath, "utf-8"),
2468
+ data: stripStaleHtmlTail(readFileSync(targetPath, "utf-8"), contentType),
2463
2469
  contentType,
2464
2470
  encoding: "utf-8"
2465
2471
  };
@@ -2949,8 +2955,6 @@ function buildLifecycleHandler(deps) {
2949
2955
  return { ok: true };
2950
2956
  };
2951
2957
  }
2952
-
2953
- // runner/src/session-resource-handlers.ts
2954
2958
  function asDeclaration(declaration) {
2955
2959
  if (declaration !== null && typeof declaration === "object" && typeof declaration.id === "string" && typeof declaration.driver === "string") {
2956
2960
  return declaration;
@@ -2961,7 +2965,7 @@ function toPreMinted(token) {
2961
2965
  return { ok: true, token: token.token, expiresAt: token.expiresAt ?? null };
2962
2966
  }
2963
2967
  function buildSessionResourceHandlers(deps) {
2964
- const { getResourceManager, getPreMintedSecrets, emitResourcesAvailable, log } = deps;
2968
+ const { getResourceManager, getPreMintedSecrets, emitResourcesAvailable, log, getProjectDir } = deps;
2965
2969
  async function add(kind, input) {
2966
2970
  const rm = getResourceManager();
2967
2971
  if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
@@ -2970,11 +2974,19 @@ function buildSessionResourceHandlers(deps) {
2970
2974
  return { ok: false, code: "invalid_declaration", message: "declaration missing id/driver" };
2971
2975
  }
2972
2976
  if (input.preMintedToken) {
2973
- getPreMintedSecrets()?.set(kind, decl.id, toPreMinted(input.preMintedToken));
2977
+ const ps = getPreMintedSecrets();
2978
+ if (ps) ps.set(kind, decl.id, toPreMinted(input.preMintedToken));
2979
+ else
2980
+ log(
2981
+ `[session-resource] preMintedToken provided but secret store not ready \u2014 ${kind}:${decl.id}`
2982
+ );
2974
2983
  }
2975
2984
  try {
2976
2985
  await rm.connect(decl);
2977
2986
  } catch (err) {
2987
+ if (input.preMintedToken) {
2988
+ getPreMintedSecrets()?.unset(kind, decl.id);
2989
+ }
2978
2990
  const message = err instanceof Error ? err.message : String(err);
2979
2991
  log(`[session-resource] runner.add_${kind} failed for ${decl.id}: ${message}`);
2980
2992
  return { ok: false, code: "connect_failed", message };
@@ -2983,9 +2995,58 @@ function buildSessionResourceHandlers(deps) {
2983
2995
  log(`[session-resource] runner.add_${kind} connected ${decl.id}`);
2984
2996
  return { ok: true, id: decl.id };
2985
2997
  }
2998
+ async function attachConnectorInstance(name, preMintedToken) {
2999
+ if (!name) {
3000
+ return { ok: false, code: "invalid_input", message: "name is required" };
3001
+ }
3002
+ if (name.includes("/") || name.includes("\\") || name.includes("..")) {
3003
+ return {
3004
+ ok: false,
3005
+ code: "invalid_input",
3006
+ message: "name must not contain path separators or traversal segments"
3007
+ };
3008
+ }
3009
+ const projectDir = getProjectDir?.();
3010
+ if (!projectDir) {
3011
+ return { ok: false, code: "no_project_dir", message: "getProjectDir not configured" };
3012
+ }
3013
+ const root = join(projectDir, ".skaile/assets/connector");
3014
+ const decl = deriveSingleMaterializedConnectorDeclaration(root, name);
3015
+ if (!decl) {
3016
+ return {
3017
+ ok: false,
3018
+ code: "not_materialized",
3019
+ message: `no materialized connector at ${join(root, name)}`
3020
+ };
3021
+ }
3022
+ const rm = getResourceManager();
3023
+ if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
3024
+ if (preMintedToken) {
3025
+ const ps = getPreMintedSecrets();
3026
+ if (ps) ps.set("connector", decl.id, toPreMinted(preMintedToken));
3027
+ else
3028
+ log(
3029
+ `[session-resource] preMintedToken provided but secret store not ready \u2014 connector:${decl.id}`
3030
+ );
3031
+ }
3032
+ try {
3033
+ await rm.connect(decl);
3034
+ } catch (err) {
3035
+ if (preMintedToken) {
3036
+ getPreMintedSecrets()?.unset("connector", decl.id);
3037
+ }
3038
+ const message = err instanceof Error ? err.message : String(err);
3039
+ log(`[session-resource] runner.attach_instance connector failed for ${decl.id}: ${message}`);
3040
+ return { ok: false, code: "connector_connect_failed", message };
3041
+ }
3042
+ emitResourcesAvailable();
3043
+ log(`[session-resource] runner.attach_instance connected connector ${decl.id}`);
3044
+ return { ok: true, id: decl.id, live: true, toolCount: 0 };
3045
+ }
2986
3046
  return {
2987
3047
  addConnector: (input) => add("connector", input),
2988
3048
  addMount: (input) => add("mount", input),
3049
+ attachConnectorInstance,
2989
3050
  removeResource: async (input) => {
2990
3051
  const rm = getResourceManager();
2991
3052
  if (!rm) return { ok: false, code: "no_session", message: "session resources not ready" };
@@ -3201,7 +3262,8 @@ var addMcpServerInputSchema = z5.strictObject({
3201
3262
  });
3202
3263
  var attachInstanceInputSchema = z5.strictObject({
3203
3264
  kind: z5.string(),
3204
- name: z5.string()
3265
+ name: z5.string(),
3266
+ preMintedToken: preMintedTokenSchema
3205
3267
  });
3206
3268
  var removeResourceInput = z5.strictObject({
3207
3269
  id: z5.string()
@@ -3292,7 +3354,11 @@ function buildRunnerCapabilities(handlers) {
3292
3354
  input: attachInstanceInputSchema,
3293
3355
  handler: async (input) => {
3294
3356
  if (!handlers.attachInstance) return notImplemented("runner.attach_instance");
3295
- return handlers.attachInstance({ kind: input.kind, name: input.name });
3357
+ return handlers.attachInstance({
3358
+ kind: input.kind,
3359
+ name: input.name,
3360
+ preMintedToken: input.preMintedToken
3361
+ });
3296
3362
  }
3297
3363
  }),
3298
3364
  defineCapability({
@@ -4226,11 +4292,15 @@ async function startAgentServer(opts) {
4226
4292
  }
4227
4293
  const fleetHealthDir = join(opts.projectDir, ".skaile", "fleet-health");
4228
4294
  try {
4229
- mkdirSync(fleetHealthDir, { recursive: true });
4295
+ mkdirSync(fleetHealthDir, { recursive: true, mode: 1528 });
4296
+ chmodSync(fleetHealthDir, 1528);
4230
4297
  } catch (err) {
4231
- serverLog.warn("failed to pre-create fleet-health dir \u2014 platform health signal disabled", {
4232
- error: err instanceof Error ? err.message : String(err)
4233
- });
4298
+ serverLog.warn(
4299
+ "failed to pre-create/chmod fleet-health dir \u2014 platform health signal may be degraded",
4300
+ {
4301
+ error: err instanceof Error ? err.message : String(err)
4302
+ }
4303
+ );
4234
4304
  }
4235
4305
  let fleetHealthWatcher = null;
4236
4306
  try {
@@ -4360,26 +4430,36 @@ async function startAgentServer(opts) {
4360
4430
  emitResourcesAvailable();
4361
4431
  agentSession.startWatching();
4362
4432
  capabilityRegistry.setRemoteInvoker(remoteCapabilityInvoker);
4433
+ const { attachConnectorInstance, ...resourceCaps } = buildSessionResourceHandlers({
4434
+ getResourceManager: () => resourceManager,
4435
+ getPreMintedSecrets: () => preMintedSecrets,
4436
+ emitResourcesAvailable,
4437
+ log,
4438
+ getProjectDir: () => opts.projectDir
4439
+ });
4440
+ const mcpHandlers = buildMcpRuntimeHandlers({
4441
+ getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
4442
+ getPreMintedSecrets: () => preMintedSecrets ?? null,
4443
+ driverPicksUpToolsLive,
4444
+ emitResourcesAvailable,
4445
+ log,
4446
+ getProjectDir: () => opts.projectDir
4447
+ });
4363
4448
  const runnerCaps = buildRunnerCapabilities({
4364
- // Resource hot-plug handlers, wired to the live session's
4365
- // ConnectorManager + PreMintedSecretProvider via getters because
4366
- // both are lazily (re)assigned in this scope.
4367
- ...buildSessionResourceHandlers({
4368
- getResourceManager: () => resourceManager,
4369
- getPreMintedSecrets: () => preMintedSecrets,
4370
- emitResourcesAvailable,
4371
- log
4372
- }),
4373
- // runner.add_mcp_server + runner.attach_instance — wired to the live
4374
- // session's lazily-created ExternalMcpManager + PreMintedSecretProvider.
4375
- ...buildMcpRuntimeHandlers({
4376
- getOrCreateMcpManager: () => agentSession?.getOrCreateExternalMcpManager() ?? null,
4377
- getPreMintedSecrets: () => preMintedSecrets ?? null,
4378
- driverPicksUpToolsLive,
4379
- emitResourcesAvailable,
4380
- log,
4381
- getProjectDir: () => opts.projectDir
4382
- }),
4449
+ ...resourceCaps,
4450
+ ...mcpHandlers,
4451
+ // attach_instance routes by kind: connectors take the materialize-then-
4452
+ // connect path; everything else stays on the MCP attach path.
4453
+ attachInstance: async (input) => {
4454
+ if (input.kind === "connector") {
4455
+ return attachConnectorInstance(input.name, input.preMintedToken);
4456
+ }
4457
+ return mcpHandlers.attachInstance ? mcpHandlers.attachInstance(input) : {
4458
+ ok: false,
4459
+ code: "not_implemented",
4460
+ message: "attach_instance handler not configured"
4461
+ };
4462
+ },
4383
4463
  // setLogLevel left undefined (the cap self-falls-back to getLogStore);
4384
4464
  // setState remains a stub (not resource hot-plug).
4385
4465
  lifecycle: buildLifecycleHandler({
@@ -5271,6 +5351,6 @@ function touchSession(state) {
5271
5351
  return { ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
5272
5352
  }
5273
5353
 
5274
- 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 };
5275
- //# sourceMappingURL=chunk-DAEYSPOC.js.map
5276
- //# sourceMappingURL=chunk-DAEYSPOC.js.map
5354
+ 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, stripStaleHtmlTail, touchSession, writeClaudeCodeCredentialsFile };
5355
+ //# sourceMappingURL=chunk-W23HDR6W.js.map
5356
+ //# sourceMappingURL=chunk-W23HDR6W.js.map