@schlenkr/ragents 0.1.11 → 0.1.13

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 (64) hide show
  1. package/README.md +1 -1
  2. package/apps/server/src/access-projection.ts +2 -2
  3. package/apps/server/src/plugin-build/build.ts +7 -7
  4. package/apps/server/src/profile/bundle-manifest.ts +11 -11
  5. package/apps/server/src/profile/plugin-discovery.ts +2 -2
  6. package/apps/server/src/provider.ts +1 -1
  7. package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-BfNSGxjB.js → highlighted-body-KPVGNVTW-CpPi6QLr.js} +1 -1
  8. package/apps/web/dist/assets/{main-D6bsKcIK.js → main-DJmCHGzM.js} +1 -1
  9. package/apps/web/dist/assets/{mermaid-HWGCJPDP-DROEqEeg.js → mermaid-HWGCJPDP-q-mf1kLN.js} +2 -2
  10. package/apps/web/dist/assets/{runPanel-Dumuuqry.js → runPanel-nk_aMxSn.js} +1 -1
  11. package/apps/web/dist/host-web.json +1 -1
  12. package/apps/web/dist/index.html +2 -2
  13. package/apps/web/dist/run-panel.html +2 -2
  14. package/apps/web/src/chat/QuasselHost.tsx +1 -1
  15. package/bundles/ragents.activity/ragents-bundle.json +3 -3
  16. package/bundles/ragents.actor-programs/ragents-bundle.json +3 -3
  17. package/bundles/ragents.ask/ragents-bundle.json +3 -3
  18. package/bundles/ragents.browser/ragents-bundle.json +3 -3
  19. package/bundles/ragents.documents/ragents-bundle.json +3 -3
  20. package/bundles/ragents.lsp-fsharp/ragents-bundle.json +3 -3
  21. package/bundles/ragents.lsp-roslyn/ragents-bundle.json +3 -3
  22. package/bundles/ragents.lsp-typescript/ragents-bundle.json +3 -3
  23. package/bundles/ragents.model-relay/ragents-bundle.json +3 -3
  24. package/bundles/ragents.orchestration/ragents-bundle.json +3 -3
  25. package/bundles/ragents.orchestration/web/classes.json +1 -1
  26. package/bundles/ragents.orchestration/web/index.js +1 -1
  27. package/bundles/ragents.orchestration/web/index.js.map +2 -2
  28. package/bundles/ragents.overseer/ragents-bundle.json +3 -3
  29. package/bundles/ragents.processes/ragents-bundle.json +3 -3
  30. package/bundles/ragents.product/ragents-bundle.json +3 -3
  31. package/bundles/ragents.profile-distribution/ragents-bundle.json +3 -3
  32. package/bundles/ragents.reference/ragents-bundle.json +3 -3
  33. package/bundles/ragents.todo/ragents-bundle.json +3 -3
  34. package/bundles/ragents.todo/server/index.js +0 -3
  35. package/bundles/ragents.todo/server/index.js.map +2 -2
  36. package/bundles/ragents.todo/web/classes.json +1 -1
  37. package/bundles/ragents.todo/web/index.js +1 -1
  38. package/bundles/ragents.todo/web/index.js.map +2 -2
  39. package/bundles/ragents.transcript/ragents-bundle.json +3 -3
  40. package/bundles/ragents.watch/ragents-bundle.json +3 -3
  41. package/bundles/ragents.workspace/ragents-bundle.json +3 -3
  42. package/bundles/ragents.workspace/server/index.js +4 -4
  43. package/bundles/ragents.workspace/server/index.js.map +2 -2
  44. package/bundles/ragents.workspace/web/classes.json +1 -1
  45. package/bundles/ragents.workspace/web/index.js +1 -1
  46. package/bundles/ragents.workspace/web/index.js.map +2 -2
  47. package/package.json +2 -2
  48. package/packages/ai/src/providers/openrouter.models.ts +2 -2
  49. package/packages/ragents/src/runtime/journal-storage.ts +1 -1
  50. package/packages/workspace-executor/src/contributions.ts +10 -10
  51. package/packages/workspace-executor/src/executor.ts +1 -1
  52. package/packages/workspace-executor/src/files.ts +1 -1
  53. package/packages/workspace-executor/src/index.ts +1 -1
  54. package/packages/workspace-executor/src/language-server/host.ts +1 -1
  55. package/packages/workspace-executor/src/language-server/workspace-solutions.ts +1 -1
  56. package/plugins/ragents.orchestration/web/ActorChat.tsx +1 -1
  57. package/plugins/ragents.orchestration/web/ActorChatControls.tsx +0 -1
  58. package/plugins/ragents.todo/contract.ts +0 -3
  59. package/plugins/ragents.workspace/client/workspace-client.ts +9 -9
  60. package/plugins/ragents.workspace/contract.ts +1 -1
  61. package/plugins/ragents.workspace/server/clients.ts +9 -9
  62. package/scripts/package/build-package.ts +3 -3
  63. package/scripts/package/ragents.mjs +1 -1
  64. package/scripts/remote/connect.ts +4 -4
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../plugins/ragents.workspace/server/index.ts", "../../../plugins/ragents.workspace/server/shell-platform.ts", "../../../plugins/ragents.workspace/server/workspace-tool-naming.ts", "../../../plugins/ragents.workspace/contract.ts", "../../../plugins/ragents.workspace/server/binding.ts", "../../../plugins/ragents.workspace/server/browse-route.ts", "../../../plugins/ragents.workspace/server/clients.ts", "../../../plugins/ragents.workspace/server/config.ts", "../../../plugins/ragents.workspace/server/runtime.ts"],
4
- "sourcesContent": ["import path from \"node:path\";\nimport { DomainError, type JsonValue, type RAgentsPlugin, type RunState } from \"@ragents/engine\";\nimport { documentStoreToken } from \"@ragents/host/ragents/document-store.js\";\nimport { workspaceResolverToken, workspaceRuntimeToken, type WorkspaceResolver } from \"@ragents/host/ragents/workspace-runtime.js\";\nimport { sandboxServicesToken } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport {\n executorContributionsToken,\n hostAddressToken,\n runtimeProviderToken,\n runGuardToken,\n runWorkspaceProviderToken,\n workspaceGuardToken,\n} from \"@ragents/host/ragents/host-services.js\";\nimport { pluginAsset } from \"@ragents/host/plugin-support/plugin-folder.js\";\nimport { ServerProcessSandbox } from \"@ragents/host/plugin-support/process-sandbox.js\";\nimport { ripgrepAvailable } from \"@ragents/workspace-executor\";\nimport type { PluginModule } from \"@ragents/host/plugin-support/plugin-module.js\";\nimport { boundToTools, handlebarsPrompt } from \"@ragents/host/plugin-support/prompt.js\";\nimport { shellPlatformPrompt } from \"./shell-platform.js\";\nimport { agentWorkspaceToolNames } from \"./workspace-tool-naming.js\";\nimport { startOptionScope } from \"@ragents/host/ragents/start-option-state.js\";\nimport { WORKSPACE_BINDING_OPTION_ID, WORKSPACE_METADATA_ID } from \"../contract.js\";\nimport { bindingOf, executorShellChapter, sessionMetadataOf, workspaceBindingOption, workspaceLocation, workspaceOwnerOf } from \"./binding.js\";\nimport { createBrowseChannel, createBrowseMethods } from \"./browse-route.js\";\nimport { clientMethods, WorkspaceClientRegistry } from \"./clients.js\";\nimport { bashSetting, bashTimeoutSetting, PROCESS_SANDBOX_OFF, processSandboxSetting, rgSetting, workspaceConfigDescriptors } from \"./config.js\";\nimport { RunWorkspaceRuntime } from \"./runtime.js\";\n\nconst warnWithoutSandbox = (): void => {\n console.warn(`Process sandbox turned off (${PROCESS_SANDBOX_OFF}): run processes run on the server without a sandbox.`);\n};\n\nconst ragentsWorkspacePlugin = (skillPaths: () => Promise<readonly string[]>): RAgentsPlugin => ({\n manifest: { id: \"ragents.workspace\" },\n register: (host) => {\n const sessionWorkspaceFor = host.service(runWorkspaceProviderToken);\n const orchestration = host.service(runtimeProviderToken);\n const runState = (runId: string): RunState | null => {\n try {\n return orchestration().state(runId);\n } catch (error) {\n if (error instanceof DomainError && error.code === \"run-not-found\") return null;\n throw error;\n }\n };\n const documentsFor = (runId: string): Promise<string | undefined> =>\n host.optionalService(documentStoreToken)?.directoryFor(runId) ?? Promise.resolve(undefined);\n const documentsRoot = async (runId: string): Promise<string> => {\n const directory = await documentsFor(runId);\n if (!directory) throw new Error(\"This profile has no file store; the plugin ragents.documents is missing\");\n return directory;\n };\n const contributions = host.service(executorContributionsToken);\n const clients = new WorkspaceClientRegistry(contributions);\n const contribution = (): WorkspaceResolver | undefined => host.optionalService(workspaceResolverToken);\n host.config(...workspaceConfigDescriptors);\n const sandboxSetting = processSandboxSetting();\n const processSandbox = sandboxSetting.enabled\n ? new ServerProcessSandbox({\n network: sandboxSetting.network,\n serverAddress: host.service(hostAddressToken)(),\n dataDirectory: path.dirname(host.storage.sessionsRoot),\n disableSetting: PROCESS_SANDBOX_OFF,\n })\n : undefined;\n const bash = bashSetting();\n const rg = rgSetting();\n const bashTimeoutSeconds = bashTimeoutSetting();\n const serverTools = { ripgrep: ripgrepAvailable(rg, process.env) };\n const runtime = new RunWorkspaceRuntime({\n clients,\n contributions: contributions.map((contribution) => contribution.parts),\n ...(processSandbox ? { processSandbox } : {}),\n ...(bash === undefined ? {} : { bash }),\n ...(rg === undefined ? {} : { rg }),\n ...(bashTimeoutSeconds === undefined ? {} : { bashTimeoutSeconds }),\n globalDirectory: host.storage.root(),\n sessionDirectory: (runId, ...segments) => host.storage.session(runId, ...segments),\n storageRootFor: (runId) => path.join(host.storage.sessionsRoot, runId),\n sessionsDirectoryPattern: path.join(host.storage.sessionsRoot, \"{runId}\", \"plugins\", host.manifest.id),\n sessionWorkspaceFor,\n skillPaths,\n resolver: contribution,\n runState,\n storeBinding: (runId, binding) => {\n const state = orchestration().state(runId);\n orchestration().replacePluginState(\n { actorId: state.ownerId, commandId: `workspace-binding:${runId}:${state.revision}` },\n runId,\n { pluginId: WORKSPACE_BINDING_OPTION_ID, scope: startOptionScope, state: binding as unknown as JsonValue },\n );\n },\n });\n host.provide(workspaceRuntimeToken, runtime);\n host.provide(sandboxServicesToken, runtime.sandbox);\n host.functions(runtime.sandbox.workspaceTools());\n const rules = handlebarsPrompt(\"ragents.workspace.prompt\", 100, pluginAsset(\"ragents.workspace\", \"prompt.hbs\"));\n host.prompts(\n boundToTools({\n ...rules,\n delivery: \"initial\",\n // The rules apply to the host's workspaces; a contributed kind describes its own.\n render: (context) => contribution()?.kind ? \"\" : rules.render(context),\n }, ...agentWorkspaceToolNames),\n shellPlatformPrompt(\"ragents.workspace.shell.prompt\", 102, serverTools, (runId) => {\n const state = runState(runId);\n return executorShellChapter(clients, workspaceOwnerOf(state), bindingOf(state), serverTools);\n }),\n );\n const browseOptions = {\n ensureSession: host.service(runGuardToken),\n ensureWorkspaceAccess: host.service(workspaceGuardToken),\n execute: runtime.sandbox.execute.bind(runtime.sandbox),\n documentsFor: documentsRoot,\n locationOf: (runId: string, location: string) => workspaceLocation(bindingOf(runState(runId)), location),\n };\n host.methods(...createBrowseMethods(browseOptions), ...clientMethods(clients));\n host.channels(createBrowseChannel(browseOptions));\n host.startOptions(workspaceBindingOption(clients, contribution));\n host.sessionMetadata({ id: WORKSPACE_METADATA_ID, describe: ({ runId }) => sessionMetadataOf(runState(runId), contribution()) });\n host.lifecycle({\n id: \"ragents.workspace.lifecycle\",\n initialize: () => processSandbox ? processSandbox.start() : warnWithoutSandbox(),\n stopSession: ({ runId }) => runtime.stopSession(runId),\n deleteSession: ({ runId }) => runtime.deleteSession(runId),\n shutdown: async () => {\n await runtime.shutdown();\n await processSandbox?.stop();\n },\n });\n },\n});\n\nexport const plugin: PluginModule = {\n create: (host) => ragentsWorkspacePlugin(() => host.skills.global()),\n};\n", "import type { PromptContribution } from \"@ragents/engine\";\nimport { shellPlatformText, type ShellTools } from \"@ragents/workspace-executor\";\nimport { boundToTools } from \"@ragents/host/plugin-support/prompt.js\";\n\nexport const shellPlatformChapter = (platform: NodeJS.Platform, tools: ShellTools): string =>\n `## Shell platform\\n\\n${shellPlatformText(platform, tools)}`;\n\n/** Without a value, the platform and tools of the server apply; `chapterFor` names those of the executor that runs the run. */\nexport const shellPlatformPrompt = (\n id: string,\n order: number,\n serverTools: ShellTools,\n chapterFor?: (runId: string) => string,\n): PromptContribution => boundToTools({\n id,\n order,\n delivery: \"initial\",\n render: () => shellPlatformChapter(process.platform, serverTools),\n ...(chapterFor ? { renderForRun: chapterFor } : {}),\n}, \"bash\");\n", "import type { WorkspaceToolNaming } from \"@ragents/engine\";\n\nconst workspaceToolTable = {\n manual: { read: [], write: [], execute: [] },\n script: { read: [], write: [], execute: [] },\n agent: { read: [\"read\"], write: [\"edit\", \"write\"], execute: [\"bash\"] },\n} as const;\n\nexport const sandboxToolNaming: WorkspaceToolNaming = {\n agentToolNames: (driver) => workspaceToolTable[driver],\n};\n\nexport const agentWorkspaceToolNames: readonly string[] = [\n ...workspaceToolTable.agent.read,\n ...workspaceToolTable.agent.write,\n ...workspaceToolTable.agent.execute,\n];\n", "import { Type } from \"typebox\";\nimport { openJson } from \"@ragents/engine/src/http/contracts\";\nimport { defineChannel, defineOperation } from \"@ragents/engine/src/rpc/contract\";\n\nexport const WORKSPACE_PLUGIN_ID = \"ragents.workspace\";\n\nexport const BROWSE_ROOTS = [\"workspace\", \"files\"] as const;\nexport type BrowseRoot = typeof BROWSE_ROOTS[number];\n\nexport interface BrowseEntry {\n name: string;\n kind: \"directory\" | \"file\";\n size: number;\n modifiedAt: string;\n}\n\nexport interface BrowseListing {\n root: BrowseRoot;\n /** Where the root is; on a workstation with its label. */\n location: string;\n path: string;\n entries: BrowseEntry[];\n truncated: boolean;\n}\n\nexport type BrowsePreview =\n | { root: BrowseRoot; path: string; size: number; previewable: true; content: string }\n | { root: BrowseRoot; path: string; size: number; previewable: false; reason: string };\n\nexport const WORKSPACE_BINDING_OPTION_ID = \"ragents.workspace.binding\";\n\nexport const WORKSPACE_METADATA_ID = \"ragents.workspace\";\n\n/** On which machine the workspace of a run is: the server or a workstation whose label the binding records. */\nexport type WorkspaceMachine = \"server\" | { client: string; label: string };\n\n/** An existing folder that the run neither creates nor deletes. */\nexport type ExistingWorkspaceFolder = {\n path: string;\n};\n\n/** The new folder per run on a workstation; the binding records its path there from the moment it is chosen. */\nexport type FreshWorkstationFolder = {\n path: string;\n fresh: true;\n};\n\n/** Which folder: a new one per run or an existing one; for `fresh` on the server, the host creates one per run in its storage. */\nexport type WorkspaceFolder = \"fresh\" | ExistingWorkspaceFolder | FreshWorkstationFolder;\n\n/** Where and in which folder a run works; frozen into the journal as a start option at the start. */\nexport type WorkspaceBinding = {\n machine: WorkspaceMachine;\n folder: WorkspaceFolder;\n};\n\nexport const freshServerBinding = (): WorkspaceBinding => ({ machine: \"server\", folder: \"fresh\" });\n\nexport const WORKSPACE_CLIENT_ID_PATTERN = /^[A-Za-z0-9_-]{8,64}$/;\n\n/** What a workstation says about itself at sign-in. */\nexport interface WorkspaceClientDescription {\n label: string;\n hostname: string;\n platform: string;\n folders: string[];\n /** Where the workstation creates the new folders per run, one subfolder per run named with its ID. */\n runsDirectory: string;\n /** Whether the workstation's bash finds rg; the prompt adjusts the search accordingly. */\n ripgrep: boolean;\n}\n\nexport interface WorkspaceClientInfo extends WorkspaceClientDescription {\n id: string;\n}\n\n/** What the new folder per run is called on each machine: the empty folder or a plugin's contribution; null where there is none. */\nexport interface FreshWorkspaceLabels {\n server: string;\n client: string | null;\n}\n\nexport interface WorkspaceBindingPresentation {\n kind: \"workspace-binding\";\n clients: WorkspaceClientInfo[];\n fresh: FreshWorkspaceLabels;\n /** Whether an existing folder of the server machine may be bound. */\n serverFolders: boolean;\n}\n\nexport interface WorkspaceSessionMetadata {\n binding: WorkspaceBinding;\n summary: string;\n}\n\nconst clientId = Type.String({ pattern: \"^[A-Za-z0-9_-]{8,64}$\", description: \"Stable ID of the workstation\" });\n\nconst executorVersion = Type.String({ minLength: 1, maxLength: 64, description: \"Version of the executor that the workstation brings\" });\n\n/** The ID of a plugin; a workstation looks for its bundle under exactly this name, so it cannot contain a path. */\nexport const PLUGIN_ID_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;\n\nconst executorContributions = Type.Array(Type.Object({\n plugin: Type.String({ pattern: PLUGIN_ID_PATTERN.source, maxLength: 128, description: \"ID of the plugin\" }),\n stand: Type.String({ pattern: \"^[0-9a-f]{64}$\", description: \"SHA-256 of the contribution file\" }),\n}, { additionalProperties: false }), { maxItems: 64, description: \"The plugins' contributions to the executor, in the order of the server's plugin list\" });\n\nconst clientDescription = {\n label: Type.String({ minLength: 1, maxLength: 120 }),\n hostname: Type.String({ minLength: 1 }),\n platform: Type.String({ minLength: 1 }),\n folders: Type.Array(Type.String({ minLength: 1 }), { maxItems: 32 }),\n runsDirectory: Type.String({ minLength: 1, description: \"Absolute folder under which the workstation creates the new folders per run\" }),\n ripgrep: Type.Boolean({ description: \"Whether the workstation's bash finds rg\" }),\n};\n\nexport const clientInfoSchema = Type.Object({\n id: Type.String(),\n ...clientDescription,\n}, { additionalProperties: false });\n\n/** The sign-in as a workstation with the server's executor sends it. */\nexport const clientRegistrationSchema = Type.Object({\n id: clientId,\n ...clientDescription,\n executor: executorVersion,\n contributions: executorContributions,\n}, { additionalProperties: false });\n\n/** A workstation with a different executor does not know the shape of this version; the server rejects it by its version, not by its shape. */\nconst otherExecutorRegistration = Type.Object({ label: clientDescription.label, executor: executorVersion }, {\n description: \"Sign-in with a different executor version in any shape; the server rejects it with workspace-executor-version\",\n});\n\nconst absolutePath = Type.String({ minLength: 1, description: \"Absolute path in the bound folder\" });\n\n/** Not an operation of a module: releases what the workstation's executor holds for the run. */\nexport const WORKSPACE_CLIENT_STOP_OPERATION = \"stop\";\n\n/** The one operation the server calls on the workstation; progress is the JSON value of the operation, for bash { text }. */\nexport const workspaceClientContracts = {\n execute: defineOperation({\n id: \"ragents.workspace.client.execute\",\n description: \"Run an operation of the executor on the workstation, such as a tool, a file query, or the process display; the result is its value, progress its JSON value. stop releases what the workstation holds for the run.\",\n implementedBy: \"client\",\n input: Type.Object({\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"ID of the run\" }),\n operation: Type.String({ minLength: 1, maxLength: 64, description: \"Name of the operation, such as read, bash, roslyn_open, files.list, or stop\" }),\n toolCallId: Type.Optional(Type.String({ minLength: 1, maxLength: 200, description: \"Only for a tool call of the model\" })),\n cwd: absolutePath,\n env: Type.Record(Type.String(), Type.String(), { description: \"What the server contributes: run marker and git rules of the sandbox\" }),\n input: Type.Unknown({ description: \"The input of the operation\" }),\n }, { additionalProperties: false }),\n result: Type.Object({ value: Type.Unknown() }, { additionalProperties: false }),\n }),\n} as const;\n\nconst browseTarget = {\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"ID of the run\" }),\n root: Type.Union([Type.Literal(\"workspace\"), Type.Literal(\"files\")]),\n path: Type.String({ description: \"Path below the root; empty is the root itself\" }),\n};\n\n/** The sign-in of a workstation binds the calling connection; the server calls back through it. */\nexport const workspaceContracts = {\n browse: {\n list: defineOperation({\n id: \"ragents.workspace.browse.list\",\n description: \"List a directory in the workspace or in the file store of a run.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n input: Type.Object(browseTarget, { additionalProperties: false }),\n result: openJson<BrowseListing>(\"BrowseListing\"),\n }),\n preview: defineOperation({\n id: \"ragents.workspace.browse.preview\",\n description: \"Preview a file as text; files that are too large or binary state the reason instead.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n input: Type.Object(browseTarget, { additionalProperties: false }),\n result: openJson<BrowsePreview>(\"BrowsePreview\"),\n }),\n },\n channels: {\n browse: defineChannel({\n id: \"ragents.workspace.browse\",\n description: \"Reports every change below the observed root of a run.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n params: Type.Object({ runId: browseTarget.runId, root: browseTarget.root }, { additionalProperties: false }),\n message: Type.Object({ changed: Type.Literal(true) }, { additionalProperties: false }),\n }),\n },\n clients: {\n list: defineOperation({\n id: \"ragents.workspace.clients.list\",\n description: \"The caller's signed-in workstations; other users' workstations do not appear even with runs.read.all.\",\n rights: [\"runs.read\"],\n input: Type.Object({}, { additionalProperties: false }),\n result: Type.Array(clientInfoSchema),\n }),\n contributions: defineOperation({\n id: \"ragents.workspace.clients.contributions\",\n description: \"The plugins' contributions to the executor that a workstation loads before sign-in and reports back with it. A workstation with a different executor version fails on its version; other fields do not matter.\",\n rights: [\"runs.write\"],\n input: Type.Object({ label: clientDescription.label, executor: executorVersion }),\n result: executorContributions,\n }),\n register: defineOperation({\n id: \"ragents.workspace.clients.register\",\n description: \"Sign in a workstation or renew its folders; the connection of this request becomes its return path and needs an event stream. A workstation with a different executor version fails on its version before the rest of the shape matters.\",\n rights: [\"runs.write\"],\n input: Type.Union([clientRegistrationSchema, otherExecutorRegistration]),\n result: clientInfoSchema,\n }),\n unregister: defineOperation({\n id: \"ragents.workspace.clients.unregister\",\n description: \"Sign out one of your own workstations; open tasks fail.\",\n rights: [\"runs.write\"],\n input: Type.Object({ id: clientId }, { additionalProperties: false }),\n result: Type.Null(),\n }),\n },\n} as const;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst hasExactly = (value: Record<string, unknown>, keys: readonly string[]): boolean =>\n Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));\n\nconst isMachine = (value: unknown): value is WorkspaceMachine =>\n value === \"server\" || (isRecord(value) && hasExactly(value, [\"client\", \"label\"])\n && typeof value.client === \"string\" && WORKSPACE_CLIENT_ID_PATTERN.test(value.client) && typeof value.label === \"string\");\n\nconst isFolder = (value: unknown): value is WorkspaceFolder => {\n if (value === \"fresh\") return true;\n if (!isRecord(value) || typeof value.path !== \"string\" || value.path.length === 0) return false;\n return hasExactly(value, [\"path\"]) || (hasExactly(value, [\"path\", \"fresh\"]) && value.fresh === true);\n};\n\n/** A new folder with a path exists only on a workstation; on the server the host creates it itself. */\nexport const isWorkspaceBinding = (value: unknown): value is WorkspaceBinding =>\n isRecord(value) && hasExactly(value, [\"machine\", \"folder\"]) && isMachine(value.machine) && isFolder(value.folder)\n && !(value.machine === \"server\" && typeof value.folder === \"object\" && \"fresh\" in value.folder);\n\nexport const isFreshFolder = (folder: WorkspaceFolder): folder is \"fresh\" | FreshWorkstationFolder =>\n folder === \"fresh\" || \"fresh\" in folder;\n\n/** The shape before machine and folder were separated, `{ kind: \"fresh\" | \"path\" | \"client\" }`, mapped unambiguously to the current one. */\nconst fromKind = (value: Record<string, unknown>): unknown => {\n switch (value.kind) {\n case \"fresh\": return hasExactly(value, [\"kind\"]) ? freshServerBinding() : undefined;\n case \"path\": return hasExactly(value, [\"kind\", \"path\"]) ? { machine: \"server\", folder: { path: value.path } } : undefined;\n case \"client\": return hasExactly(value, [\"kind\", \"client\", \"label\", \"path\"])\n ? { machine: { client: value.client, label: value.label }, folder: { path: value.path } }\n : undefined;\n default: return undefined;\n }\n};\n\n/** The stored binding; older, immutable journals carry the shape with `kind`, and only here is it mapped. */\nexport const storedWorkspaceBinding = (value: unknown): WorkspaceBinding | undefined => {\n if (isWorkspaceBinding(value)) return value;\n const mapped = isRecord(value) && Object.hasOwn(value, \"kind\") ? fromKind(value) : undefined;\n return isWorkspaceBinding(mapped) ? mapped : undefined;\n};\n\nexport const FRESH_WORKSPACE_LABEL = \"Empty folder per run\";\n\n/** What the new folder per run is called on the binding's machine; without a contribution there, the empty folder. */\nconst freshLabelOf = (binding: WorkspaceBinding, labels: FreshWorkspaceLabels): string =>\n (binding.machine === \"server\" ? labels.server : labels.client) ?? FRESH_WORKSPACE_LABEL;\n\nexport const workspaceBindingSummary = (binding: WorkspaceBinding, labels: FreshWorkspaceLabels): string => {\n const { machine, folder } = binding;\n const fresh = freshLabelOf(binding, labels);\n const where = folder === \"fresh\" ? fresh : \"fresh\" in folder ? `${folder.path} (${fresh})` : folder.path;\n return machine === \"server\" ? where : `${machine.label}: ${where}`;\n};\n", "import { statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { Type } from \"typebox\";\nimport { DomainError, type JsonValue, type RunState, type StartOptionContribution } from \"@ragents/engine\";\nimport type { ShellTools } from \"@ragents/workspace-executor\";\nimport { shellPlatformChapter } from \"./shell-platform.js\";\nimport { storedStartOption } from \"@ragents/host/ragents/start-option-state.js\";\nimport type { WorkspaceResolver } from \"@ragents/host/ragents/workspace-runtime.js\";\nimport {\n freshServerBinding,\n FRESH_WORKSPACE_LABEL,\n isFreshFolder,\n isWorkspaceBinding,\n storedWorkspaceBinding,\n WORKSPACE_BINDING_OPTION_ID,\n workspaceBindingSummary,\n type ExistingWorkspaceFolder,\n type FreshWorkspaceLabels,\n type FreshWorkstationFolder,\n type WorkspaceBinding,\n type WorkspaceBindingPresentation,\n type WorkspaceClientInfo,\n type WorkspaceSessionMetadata,\n} from \"../contract.js\";\nimport type { WorkspaceClientRegistry } from \"./clients.js\";\n\nconst machineSchema = Type.Union([\n Type.Literal(\"server\"),\n Type.Object({ client: Type.String({ minLength: 8, maxLength: 64 }), label: Type.String() }, { additionalProperties: false }),\n]);\n\nconst folderSchema = Type.Union([\n Type.Literal(\"fresh\"),\n Type.Object({ path: Type.String({ minLength: 1 }), fresh: Type.Optional(Type.Literal(true)) }, { additionalProperties: false }),\n]);\n\nconst bindingSchema = Type.Object({ machine: machineSchema, folder: folderSchema }, { additionalProperties: false });\n\n/** A run on a workstation with its ID, label, and the folder there; `fresh` then already carries its path. */\nexport type WorkstationBinding = {\n machine: { client: string; label: string };\n folder: ExistingWorkspaceFolder | FreshWorkstationFolder;\n};\n\nconst insideFolder = (folder: string, candidate: string): boolean => {\n const separator = folder.includes(\"\\\\\") ? \"\\\\\" : \"/\";\n const root = folder.endsWith(separator) ? folder.slice(0, -separator.length) : folder;\n return candidate === root || candidate.startsWith(root + separator);\n};\n\n/** The folder of a run below the folder in which a workstation creates the new folders per run; with its separator. */\nexport const workstationRunFolder = (runsDirectory: string, runId: string): string => {\n const separator = runsDirectory.includes(\"\\\\\") ? \"\\\\\" : \"/\";\n const root = runsDirectory.endsWith(separator) ? runsDirectory.slice(0, -separator.length) : runsDirectory;\n return `${root}${separator}${runId}`;\n};\n\n/** The binding of a run; without a stored choice the new folder on the server, an unreadable one blocks the run with a cause. */\nexport const bindingOf = (state: RunState | null): WorkspaceBinding => {\n const stored = storedStartOption(state, WORKSPACE_BINDING_OPTION_ID);\n if (stored === undefined) return freshServerBinding();\n const binding = storedWorkspaceBinding(stored);\n if (!binding || (binding.machine !== \"server\" && binding.folder === \"fresh\")) {\n throw new Error(`The stored workspace binding is invalid: ${JSON.stringify(stored)}`);\n }\n return binding;\n};\n\nexport const isWorkstationBinding = (binding: WorkspaceBinding): binding is WorkstationBinding =>\n binding.machine !== \"server\" && binding.folder !== \"fresh\";\n\n/** A run uses only workstations of its owner, a run without an owner only those signed in without a user. */\nexport const workspaceOwnerOf = (state: RunState | null): string | null => state?.ownerUserId ?? null;\n\n/** The existing folder on the server machine that the run is bound to; a new folder and a workstation are not there. */\nexport const boundServerDirectory = (state: RunState | null): string | null => {\n const { machine, folder } = bindingOf(state);\n return machine === \"server\" && folder !== \"fresh\" ? folder.path : null;\n};\n\n/** An existing folder of this server; the same check as when choosing the start option. */\nexport const serverDirectoryFolder = (directory: string): ExistingWorkspaceFolder => {\n if (!path.isAbsolute(directory)) throw new DomainError(\"workspace-path-relative\", \"The folder must be an absolute path.\", 400);\n const resolved = path.resolve(directory);\n if (!statSync(resolved, { throwIfNoEntry: false })?.isDirectory()) {\n throw new DomainError(\"workspace-path-missing\", `The folder ${resolved} does not exist on the server.`, 400);\n }\n return { path: resolved };\n};\n\n/** The bash of a run runs on the executor of its binding; the prompt therefore names its platform and tools, not those of the server. */\nexport const executorShellChapter = (\n registry: WorkspaceClientRegistry,\n owner: string | null,\n binding: WorkspaceBinding,\n serverTools: ShellTools,\n): string => {\n const { machine } = binding;\n if (machine === \"server\") return shellPlatformChapter(process.platform, serverTools);\n const client = registry.info(owner, machine.client);\n return client\n ? shellPlatformChapter(client.platform as NodeJS.Platform, { ripgrep: client.ripgrep })\n : `## Shell platform\\n\\nThe workstation ${machine.label} that holds this project is not registered right now, `\n + \"so the platform of its shell is unknown; the workspace tools fail until it connects again.\";\n};\n\n/** Where the root of a run is, in words: on a workstation with its label, otherwise the path itself. */\nexport const workspaceLocation = (binding: WorkspaceBinding, location: string): string =>\n binding.machine === \"server\" ? location : `Workstation ${binding.machine.label}: ${location}`;\n\n/** The contribution provides the new folder per run as soon as there is one; on a workstation only if it explicitly can there. */\nexport const freshLabels = (contribution: WorkspaceResolver | undefined): FreshWorkspaceLabels => ({\n server: contribution?.kind?.label ?? FRESH_WORKSPACE_LABEL,\n client: contribution ? contribution.workstation?.label ?? null : FRESH_WORKSPACE_LABEL,\n});\n\nexport const sessionMetadataOf = (state: RunState | null, contribution: WorkspaceResolver | undefined): WorkspaceSessionMetadata => {\n const binding = bindingOf(state);\n return { binding, summary: workspaceBindingSummary(binding, freshLabels(contribution)) };\n};\n\nconst unsupported = (message: string): DomainError => new DomainError(\"workspace-binding-unsupported\", message, 400);\n\n/** A workstation of the acting user that offers the folder; a new folder per run gets its path there below its folder for runs. */\nconst workstationBinding = (\n client: WorkspaceClientInfo,\n folder: WorkspaceBinding[\"folder\"],\n runId: string,\n labels: FreshWorkspaceLabels,\n): WorkstationBinding => {\n const machine = { client: client.id, label: client.label };\n if (isFreshFolder(folder)) {\n if (labels.client === null) {\n throw unsupported(`A new folder per run exists here only on the server (${labels.server}); choose one there or an existing folder of the workstation.`);\n }\n return { machine, folder: { path: workstationRunFolder(client.runsDirectory, runId), fresh: true } };\n }\n if (!client.folders.some((offered) => insideFolder(offered, folder.path))) {\n throw new DomainError(\"workspace-client-folder\", `The workstation ${client.label} does not offer the folder ${folder.path}.`, 400);\n }\n return { machine, folder: { path: folder.path } };\n};\n\nexport const workspaceBindingOption = (\n registry: WorkspaceClientRegistry,\n contribution: () => WorkspaceResolver | undefined,\n): StartOptionContribution => ({\n id: WORKSPACE_BINDING_OPTION_ID,\n schema: bindingSchema,\n selectable: () => true,\n defaultValue: () => freshServerBinding(),\n accept: (value, { runId, userId }) => {\n if (!isWorkspaceBinding(value)) throw new DomainError(\"workspace-binding-invalid\", \"The workspace binding has no valid format.\", 400);\n const labels = freshLabels(contribution());\n const { machine, folder } = value;\n if (machine === \"server\") {\n if (folder === \"fresh\") return freshServerBinding();\n if (\"fresh\" in folder) throw new DomainError(\"workspace-binding-invalid\", \"On the server, the host creates the new folder per run; it has no chosen path.\", 400);\n if (!(contribution()?.kind?.serverFolders ?? true)) {\n throw unsupported(`An existing folder on the server machine is not a binding here; choose ${labels.server} or a workstation.`);\n }\n return { machine, folder: serverDirectoryFolder(folder.path) };\n }\n const client = registry.info(userId, machine.client);\n if (!client) throw new DomainError(\"workspace-client-disconnected\", `The workstation ${machine.label || machine.client} is not connected.`, 409);\n return workstationBinding(client, folder, runId, labels);\n },\n describe: (_value, { userId }) => {\n const presentation: WorkspaceBindingPresentation = {\n kind: \"workspace-binding\",\n clients: registry.list(userId),\n fresh: freshLabels(contribution()),\n serverFolders: contribution()?.kind?.serverFolders ?? true,\n };\n return presentation as unknown as JsonValue;\n },\n ownerOnly: (value) => {\n const binding = storedWorkspaceBinding(value);\n return binding !== undefined && binding.machine !== \"server\";\n },\n});\n", "import {\n implement,\n implementChannel,\n type AccessContext,\n type ChannelContribution,\n type MethodContribution,\n} from \"@ragents/engine\";\nimport {\n FILE_OPERATIONS,\n listDirectory,\n readTextFile,\n watchDirectory,\n type FileListing,\n type FileText,\n type FileWatchProgress,\n} from \"@ragents/workspace-executor\";\nimport { withDomainCause, type SandboxServices } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport {\n workspaceContracts,\n type BrowseListing,\n type BrowsePreview,\n type BrowseRoot,\n} from \"../contract.js\";\n\nexport interface BrowseOptions {\n ensureSession: (runId: string) => void;\n /** The workspace of a run that only its owner operates is with the owner; the server's file store is not. */\n ensureWorkspaceAccess: (access: AccessContext, runId: string) => void;\n /** The workspace is reachable only through the run's executor, wherever it is. */\n execute: SandboxServices[\"execute\"];\n /** The file store is on the server and does not belong to the workspace. */\n documentsFor: (runId: string) => Promise<string>;\n /** What the root of a run is called, for example with the label of its workstation. */\n locationOf: (runId: string, location: string) => string;\n}\n\nconst onServer = async <T>(operation: () => Promise<T>): Promise<T> => {\n try {\n return await operation();\n } catch (error) {\n throw withDomainCause(error);\n }\n};\n\nconst listingOf = async (options: BrowseOptions, runId: string, root: BrowseRoot, target: string): Promise<BrowseListing> => {\n if (root === \"files\") {\n const listing = await onServer(async () => listDirectory(await options.documentsFor(runId), target));\n return { root, ...listing };\n }\n const listing = await options.execute(runId, FILE_OPERATIONS.list, { path: target }) as FileListing;\n return { root, ...listing, location: options.locationOf(runId, listing.location) };\n};\n\nconst previewOf = async (options: BrowseOptions, runId: string, root: BrowseRoot, target: string): Promise<BrowsePreview> => {\n const text = root === \"files\"\n ? await onServer(async () => readTextFile(await options.documentsFor(runId), target))\n : await options.execute(runId, FILE_OPERATIONS.read, { path: target }) as FileText;\n return { root, ...text };\n};\n\nconst ensureRoot = (options: BrowseOptions, access: AccessContext, runId: string, root: BrowseRoot): void => {\n if (root === \"workspace\") options.ensureWorkspaceAccess(access, runId);\n else options.ensureSession(runId);\n};\n\nexport const createBrowseMethods = (options: BrowseOptions): MethodContribution[] => [\n implement(workspaceContracts.browse.list, ({ runId, root, path: target }, { access }) => {\n ensureRoot(options, access, runId, root);\n return listingOf(options, runId, root, target);\n }),\n implement(workspaceContracts.browse.preview, ({ runId, root, path: target }, { access }) => {\n ensureRoot(options, access, runId, root);\n return previewOf(options, runId, root, target);\n }),\n];\n\n/** After a running watch ends, for example because the workstation was gone, the channel retries at this interval. */\nconst WATCH_RETRY_MS = 5_000;\n\n/** Watches the workspace at the run's executor until aborted; once the watch is established the channel is open, and when it ends, it starts a new one. */\nconst watchWorkspace = (options: BrowseOptions, runId: string, changed: () => void): Promise<() => void> =>\n new Promise((ready, failed) => {\n const controller = new AbortController();\n let opened = false;\n let retry: NodeJS.Timeout | undefined;\n const stop = (): void => {\n controller.abort();\n clearTimeout(retry);\n };\n const start = (): void => {\n let watching = false;\n const ended = (error?: unknown): void => {\n if (controller.signal.aborted) return;\n if (!opened) {\n failed(error ?? new Error(\"The workspace watch ended before it was established\"));\n return;\n }\n // When a running watch ends, the view reloads and shows the cause; once the next one is established, it reloads again.\n if (watching) changed();\n retry = setTimeout(start, WATCH_RETRY_MS);\n };\n options.execute(runId, FILE_OPERATIONS.watch, {}, {\n signal: controller.signal,\n untilAborted: true,\n onProgress: (value) => {\n if ((value as FileWatchProgress).kind === \"changed\") changed();\n else if (!watching) {\n watching = true;\n if (opened) changed();\n else {\n opened = true;\n ready(stop);\n }\n }\n },\n }).then(() => ended(), ended);\n };\n start();\n });\n\nexport const createBrowseChannel = (options: BrowseOptions): ChannelContribution =>\n implementChannel(workspaceContracts.channels.browse, async ({ runId, root }, emit, { access }) => {\n ensureRoot(options, access, runId, root);\n const changed = (): void => emit({ changed: true });\n if (root === \"workspace\") return watchWorkspace(options, runId, changed);\n return onServer(async () => watchDirectory(await options.documentsFor(runId), { onChange: changed, onError: changed }));\n });\n", "import { Value } from \"typebox/value\";\nimport {\n DomainError,\n RPC_ERROR_CODES,\n RpcError,\n implement,\n schemaComplaints,\n type AccessContext,\n type MethodConnection,\n type MethodContribution,\n} from \"@ragents/engine\";\nimport {\n WORKSPACE_EXECUTOR_VERSION,\n sandboxRunEnvironment,\n type ExecutorContributionStand,\n type WorkspaceExecuteOptions,\n type WorkspaceExecutor,\n} from \"@ragents/workspace-executor\";\nimport {\n WORKSPACE_CLIENT_STOP_OPERATION,\n clientRegistrationSchema,\n workspaceClientContracts,\n workspaceContracts,\n type WorkspaceClientDescription,\n type WorkspaceClientInfo,\n} from \"../contract.js\";\n\ninterface ClientEntry {\n readonly info: WorkspaceClientInfo;\n readonly owner: string | null;\n readonly connection: MethodConnection;\n readonly release: () => void;\n /** The open calls through this sign-in; if a new connection replaces it, they fail immediately. */\n readonly calls: Set<AbortController>;\n /** The stops currently being delivered through this sign-in, per run. */\n readonly stops: Map<string, Promise<void>>;\n}\n\n/** The only limit against a hanging workstation; the executor has its own timeouts. */\nconst CLIENT_TIMEOUT_MS = 15 * 60 * 1000;\n\n/** This is how long cleanup (stop, `whenReachable`) waits for the workstation; it stays below the plugins' stop limit. */\nconst CLEANUP_TIMEOUT_MS = 10_000;\n\n/** After this long, the server retries a pending stop as long as the workstation is signed in. */\nconst STOP_RETRY_MS = 30_000;\n\nexport const ownerOf = (access: AccessContext): string | null => access.user?.id ?? null;\n\n/** A watch runs until aborted, cleanup briefly; everything else waits for the safety limit plus the duration the call itself requests. */\nconst timeoutFor = (options: WorkspaceExecuteOptions): { timeoutMs?: number } => {\n if (options.untilAborted) return {};\n if (options.whenReachable) return { timeoutMs: CLEANUP_TIMEOUT_MS };\n return { timeoutMs: CLIENT_TIMEOUT_MS + (options.durationMs ?? 0) };\n};\n\nconst disconnected = (label: string, detail: string): DomainError =>\n new DomainError(\"workspace-client-disconnected\", `The workstation ${label} lost the connection: ${detail}`, 409);\n\n/** If the connection breaks in the middle of a call, the cause must name the workstation, not the server; a domain error stays one. */\nconst withClientCause = (cause: unknown, label: string): unknown => {\n if (!(cause instanceof RpcError)) return cause;\n if (cause.code === RPC_ERROR_CODES.connectionClosed) return disconnected(label, cause.message);\n if (cause.code === RPC_ERROR_CODES.timeout) {\n return new DomainError(\"workspace-client-timeout\", `The workstation ${label} did not respond: ${cause.message}`, 504);\n }\n if (cause.code === RPC_ERROR_CODES.application && cause.domainCode !== undefined && cause.status !== undefined) {\n return new DomainError(cause.domainCode, cause.message, cause.status);\n }\n return cause;\n};\n\n/** The workstation was not there or did not respond in time; a domain error does not count. */\nconst unreached = (cause: unknown): boolean =>\n cause instanceof DomainError && (cause.code === \"workspace-client-disconnected\" || cause.code === \"workspace-client-timeout\");\n\nconst messageOf = (cause: unknown): string => cause instanceof Error ? cause.message : String(cause);\n\n/** A workstation is identified only by owner and ID; two users with the same ID share nothing. */\nconst keyOf = (owner: string | null, id: string): string => JSON.stringify([owner, id]);\n\n/** Server and workstation need the same executor; the message says which of the two is too old. */\nconst assertExecutor = (label: string, executor: string): void => {\n if (executor === WORKSPACE_EXECUTOR_VERSION) return;\n const action = Number(executor) > Number(WORKSPACE_EXECUTOR_VERSION)\n ? \"Update the server to the workstation's version.\"\n : \"Update the RAgents extension in VS Code or the package @schlenkr/ragents on the workstation.\";\n throw new DomainError(\n \"workspace-executor-version\",\n `The workstation ${label} brings executor ${executor}, the server requires ${WORKSPACE_EXECUTOR_VERSION}. ${action}`,\n 409,\n );\n};\n\nconst described = (contributions: readonly ExecutorContributionStand[]): string =>\n contributions.map(({ plugin, stand }) => `${plugin} (${stand.slice(0, 12)})`).join(\", \") || \"none\";\n\n/** A workstation runs what the server's plugins contribute; with other contributions the same tools would behave differently there than on the server. */\nconst assertContributions = (label: string, expected: readonly ExecutorContributionStand[], given: readonly ExecutorContributionStand[]): void => {\n const key = (entry: ExecutorContributionStand): string => `${entry.plugin}\\0${entry.stand}`;\n const same = expected.length === given.length && expected.every((entry) => given.some((other) => key(other) === key(entry)));\n if (same) return;\n throw new DomainError(\n \"workspace-executor-contributions\",\n `The workstation ${label} brings the executor contributions ${described(given)}, the server requires ${described(expected)}. `\n + \"The workstation queries them with ragents.workspace.clients.contributions and then signs in again.\",\n 409,\n );\n};\n\n/** Over the network, the server accepts workstations only from signed-in users; without users there would be only one owner for all access. */\nexport const assertMayRegister = (access: AccessContext, local: boolean): void => {\n if (local || (access.enabled && access.user !== null)) return;\n throw new DomainError(\n \"workspace-client-login-required\",\n \"This server has no user sign-in; it therefore accepts a workstation only over a loopback connection \"\n + \"(such as http://127.0.0.1 on its own machine). Over the network, a workstation needs a profile with users.\",\n 403,\n );\n};\n\n/** Knows the signed-in workstations per owner, holds per client the connection through which the server calls it back, and the stops that have not reached it. */\nexport class WorkspaceClientRegistry {\n /** What the server's plugins contribute to the executor; every workstation must carry exactly these contributions. */\n readonly contributions: readonly ExecutorContributionStand[];\n readonly #clients = new Map<string, ClientEntry>();\n /** Stops that have not reached the workstation yet, per workstation and run with the folder of the binding. */\n readonly #pendingStops = new Map<string, Map<string, string>>();\n readonly #stopRetries = new Map<string, NodeJS.Timeout>();\n\n constructor(contributions: readonly ExecutorContributionStand[]) {\n this.contributions = contributions.map(({ plugin, stand }) => ({ plugin, stand }));\n }\n\n async register(\n id: string,\n description: WorkspaceClientDescription,\n executor: string,\n contributions: readonly ExecutorContributionStand[],\n connection: MethodConnection,\n ): Promise<WorkspaceClientInfo> {\n if (connection.streamless) {\n throw new DomainError(\"stream-required\", \"The sign-in of a workstation needs an event stream.\", 409);\n }\n assertExecutor(description.label, executor);\n assertContributions(description.label, this.contributions, contributions);\n const owner = connection.userId;\n const key = keyOf(owner, id);\n const previous = this.#clients.get(key);\n previous?.release();\n const info: WorkspaceClientInfo = { ...description, id };\n const renewed = previous?.connection === connection;\n const entry: ClientEntry = {\n info,\n owner,\n connection,\n release: connection.onClose(() => this.#disconnected(key, connection)),\n calls: renewed ? previous.calls : new Set(),\n stops: renewed ? previous.stops : new Map(),\n };\n this.#clients.set(key, entry);\n if (previous && !renewed) this.#abandon(previous);\n this.#deliverPendingStops(key);\n return info;\n }\n\n /** Only the connection that holds the entry signs it out; a sign-out without an entry is not an error after a disconnect. */\n unregister(owner: string | null, id: string, connection: MethodConnection): void {\n const key = keyOf(owner, id);\n const entry = this.#clients.get(key);\n if (entry?.connection !== connection) return;\n this.#remove(key, entry);\n }\n\n list(owner: string | null): WorkspaceClientInfo[] {\n return [...this.#clients.values()].filter((entry) => entry.owner === owner).map((entry) => entry.info);\n }\n\n info(owner: string | null, id: string): WorkspaceClientInfo | undefined {\n return this.#clients.get(keyOf(owner, id))?.info;\n }\n\n /** The runs whose stop has not reached this workstation yet. */\n pendingStops(owner: string | null, id: string): readonly string[] {\n return this.#pendingRuns(keyOf(owner, id));\n }\n\n /** The executor of a bound run: the same interface as in the server, only through the connection of its owner's workstation. */\n executorFor(owner: string | null, id: string, label: string, cwd: string): WorkspaceExecutor {\n const key = keyOf(owner, id);\n const call = async (runId: string, operation: string, input: unknown, options: WorkspaceExecuteOptions): Promise<unknown> => {\n if (options.untilAborted && !options.signal) throw new Error(`The operation ${operation} runs until aborted and needs an abort signal for that`);\n if (this.#pendingStops.get(key)?.has(runId)) {\n // Cleanup alongside a pending stop is done by that stop; everything else waits until it is delivered.\n if (options.whenReachable) return null;\n if (this.#clients.has(key)) await this.#deliverStop(key, runId);\n }\n const entry = this.#clients.get(key);\n if (!entry) {\n if (options.whenReachable) return null;\n throw new DomainError(\"workspace-client-disconnected\", `The workstation ${label} is not connected.`, 409);\n }\n try {\n return await this.#send(entry, runId, operation, input, cwd, options);\n } catch (cause) {\n if (options.whenReachable && unreached(cause)) return null;\n throw cause;\n }\n };\n return {\n version: WORKSPACE_EXECUTOR_VERSION,\n execute: (runId, operation, input, options = {}) => call(runId, operation, input, options),\n stopRun: async (runId) => {\n this.#pendingStopsOf(key).set(runId, cwd);\n await this.#deliverStop(key, runId);\n },\n shutdown: async () => undefined,\n };\n }\n\n shutdown(): void {\n for (const entry of this.#clients.values()) {\n entry.release();\n this.#abandon(entry);\n }\n this.#clients.clear();\n for (const timer of this.#stopRetries.values()) clearTimeout(timer);\n this.#stopRetries.clear();\n this.#pendingStops.clear();\n }\n\n /** A disconnected workstation leaves the registry; a later sign-in over a new connection stays. */\n #disconnected(key: string, connection: MethodConnection): void {\n const entry = this.#clients.get(key);\n if (entry?.connection !== connection) return;\n this.#remove(key, entry);\n }\n\n #remove(key: string, entry: ClientEntry): void {\n entry.release();\n this.#clients.delete(key);\n this.#abandon(entry);\n }\n\n /** A connection that nobody holds anymore gets no more answers delivered; its open calls fail immediately. */\n #abandon(entry: ClientEntry): void {\n for (const controller of entry.calls) controller.abort();\n entry.calls.clear();\n }\n\n async #send(\n entry: ClientEntry,\n runId: string,\n operation: string,\n input: unknown,\n cwd: string,\n options: WorkspaceExecuteOptions,\n ): Promise<unknown> {\n const label = entry.info.label;\n const abandoned = new AbortController();\n entry.calls.add(abandoned);\n const signal = options.signal ? AbortSignal.any([options.signal, abandoned.signal]) : abandoned.signal;\n try {\n const { value } = await Promise.race([\n entry.connection.call(\n workspaceClientContracts.execute,\n {\n runId,\n operation,\n ...(options.toolCallId ? { toolCallId: options.toolCallId } : {}),\n cwd,\n env: sandboxRunEnvironment(runId),\n input,\n },\n {\n signal,\n ...timeoutFor(options),\n ...(options.onProgress ? { onProgress: options.onProgress } : {}),\n },\n ),\n new Promise<never>((_settle, fail) => abandoned.signal.addEventListener(\"abort\", () =>\n fail(disconnected(label, \"a new connection replaced the sign-in\")), { once: true })),\n ]);\n return value;\n } catch (cause) {\n throw withClientCause(cause, label);\n } finally {\n entry.calls.delete(abandoned);\n }\n }\n\n #pendingStopsOf(key: string): Map<string, string> {\n const known = this.#pendingStops.get(key);\n if (known) return known;\n const created = new Map<string, string>();\n this.#pendingStops.set(key, created);\n return created;\n }\n\n /** Delivers a pending stop; if it does not reach the workstation, it stays pending and the next sign-in catches up on it. */\n #deliverStop(key: string, runId: string): Promise<void> {\n const entry = this.#clients.get(key);\n const cwd = this.#pendingStops.get(key)?.get(runId);\n if (cwd === undefined) return Promise.resolve();\n if (!entry) {\n console.warn(`The stop of run ${runId} reaches its workstation only at its next sign-in.`);\n return Promise.resolve();\n }\n const running = entry.stops.get(runId);\n if (running) return running;\n const delivery = this.#send(entry, runId, WORKSPACE_CLIENT_STOP_OPERATION, null, cwd, { whenReachable: true })\n .then(() => this.#stopDelivered(key, runId, cwd), (cause: unknown) => {\n if (!unreached(cause)) {\n this.#stopDelivered(key, runId, cwd);\n throw cause;\n }\n console.warn(`The stop of run ${runId} did not reach the workstation ${entry.info.label} and stays pending: ${messageOf(cause)}`);\n this.#retryStops(key);\n })\n .finally(() => entry.stops.delete(runId));\n entry.stops.set(runId, delivery);\n return delivery;\n }\n\n #stopDelivered(key: string, runId: string, cwd: string): void {\n const pending = this.#pendingStops.get(key);\n if (pending?.get(runId) === cwd) pending.delete(runId);\n if (pending?.size === 0) this.#pendingStops.delete(key);\n }\n\n #deliverPendingStops(key: string): void {\n for (const runId of this.#pendingRuns(key)) {\n void this.#deliverStop(key, runId).catch((cause: unknown) =>\n console.warn(`The delayed stop of run ${runId} failed: ${messageOf(cause)}`));\n }\n }\n\n #pendingRuns(key: string): readonly string[] {\n return [...this.#pendingStops.get(key)?.keys() ?? []];\n }\n\n /** A workstation that stays signed in but does not respond gets its pending stops again later. */\n #retryStops(key: string): void {\n if (this.#stopRetries.has(key)) return;\n const timer = setTimeout(() => {\n this.#stopRetries.delete(key);\n if (this.#clients.has(key)) this.#deliverPendingStops(key);\n }, STOP_RETRY_MS);\n timer.unref();\n this.#stopRetries.set(key, timer);\n }\n}\n\nexport const clientMethods = (registry: WorkspaceClientRegistry): MethodContribution[] => [\n implement(workspaceContracts.clients.list, (_input, { access }) => registry.list(ownerOf(access))),\n implement(workspaceContracts.clients.contributions, ({ label, executor }, { access, local }) => {\n assertMayRegister(access, local);\n assertExecutor(label, executor);\n return registry.contributions.map((entry) => ({ ...entry }));\n }),\n implement(workspaceContracts.clients.register, (input, { access, connection, local }) => {\n assertMayRegister(access, local);\n // Version first: a workstation with a different one does not know the shape of this version; with this one, the shape applies fully.\n assertExecutor(input.label, input.executor);\n if (!Value.Check(clientRegistrationSchema, input)) {\n throw new RpcError(RPC_ERROR_CODES.invalidParams,\n `Invalid input for ${workspaceContracts.clients.register.id}: ${schemaComplaints(clientRegistrationSchema, input, \"params\")}`);\n }\n const { id, executor, contributions, ...description } = input;\n return registry.register(id, description, executor, contributions, connection);\n }),\n implement(workspaceContracts.clients.unregister, ({ id }, { access, connection }) => {\n registry.unregister(ownerOf(access), id, connection);\n return null;\n }),\n];\n", "import { declaredEnvironment } from \"@ragents/host/plugin-support/plugin-config.js\";\nimport { PROCESS_SANDBOX_DEFAULT_NETWORK } from \"@ragents/host/plugin-support/process-sandbox.js\";\n\nexport const workspaceConfigDescriptors = [\n { key: \"PROCESS_SANDBOX\", source: \"environment\" },\n { key: \"PROCESS_SANDBOX_NETWORK\", source: \"environment\" },\n { key: \"RAGENTS_BASH\", source: \"environment\" },\n { key: \"RAGENTS_RG\", source: \"environment\" },\n { key: \"RAGENTS_BASH_TIMEOUT_SECONDS\", source: \"environment\" },\n] as const;\n\nconst env = declaredEnvironment(workspaceConfigDescriptors);\n\nexport interface ProcessSandboxSetting {\n readonly enabled: boolean;\n readonly network: readonly string[];\n}\n\n/** This is how the operator turns off the process sandbox in the profile file. */\nexport const PROCESS_SANDBOX_OFF = 'PROCESS_SANDBOX: \"off\" in the ragents.workspace section';\n\n/** Without a value the sandbox is on; it can only be turned off explicitly with \"off\". */\nexport const processSandboxSetting = (): ProcessSandboxSetting => {\n const mode = env.optional(\"PROCESS_SANDBOX\") ?? \"on\";\n if (mode !== \"on\" && mode !== \"off\") {\n throw new Error(`PROCESS_SANDBOX in the ragents.workspace section is \"on\" or \"off\", not \"${mode}\"`);\n }\n const network = env.optional(\"PROCESS_SANDBOX_NETWORK\") === undefined\n ? PROCESS_SANDBOX_DEFAULT_NETWORK\n : env.list(\"PROCESS_SANDBOX_NETWORK\");\n return { enabled: mode === \"on\", network };\n};\n\n/** The bash with which the executor of this server starts the bash tool; on Windows the VS Code extension sets it for its local host. */\nexport const bashSetting = (): string | undefined => env.optional(\"RAGENTS_BASH\") || undefined;\n\n/** The rg that the executor of this server puts at the front of the bash PATH; the VS Code extension sets it for its local host. */\nexport const rgSetting = (): string | undefined => env.optional(\"RAGENTS_RG\") || undefined;\n\n/** The bash timeout in seconds for calls without their own; the tool rejects more than the largest a call may name at startup. */\nexport const bashTimeoutSetting = (): number | undefined =>\n env.optional(\"RAGENTS_BASH_TIMEOUT_SECONDS\") ? env.positiveNumber(\"RAGENTS_BASH_TIMEOUT_SECONDS\", \"\") : undefined;\n", "import { mkdir, realpath } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { JsonValue, RunState, WorkspaceToolNaming } from \"@ragents/engine\";\nimport { DomainError } from \"@ragents/engine\";\nimport {\n RUN_FOLDER_OPERATIONS,\n type RunFolderCreated,\n type SandboxHomeEnvironment,\n type WorkspaceExecuteOptions,\n type WorkspaceExecutor,\n type WorkspaceExecutorParts,\n} from \"@ragents/workspace-executor\";\nimport type {\n SessionWorkspace,\n WorkspaceFolderStep,\n WorkspacePlacement,\n WorkspaceResolver,\n WorkspaceRuntime,\n WorkspaceRuntimeDescription,\n WorkspaceTransfer,\n WorkstationFolderContext,\n} from \"@ragents/host/ragents/workspace-runtime.js\";\nimport { storedStartOption } from \"@ragents/host/ragents/start-option-state.js\";\nimport { sandboxToolNaming } from \"./workspace-tool-naming.js\";\nimport { WorkspaceSandboxHost, type ServerRootDescription } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport type { RunProcessSandboxes } from \"@ragents/host/plugin-support/process-sandbox.js\";\nimport { FRESH_WORKSPACE_LABEL, isFreshFolder, type ExistingWorkspaceFolder, type WorkspaceBinding } from \"../contract.js\";\nimport {\n bindingOf,\n boundServerDirectory,\n isWorkstationBinding,\n serverDirectoryFolder,\n workspaceOwnerOf,\n type WorkstationBinding,\n} from \"./binding.js\";\nimport type { WorkspaceClientRegistry } from \"./clients.js\";\n\nexport interface RunWorkspaceRuntimeOptions {\n globalDirectory: string;\n sessionDirectory: (runId: string, ...segments: string[]) => string;\n /** The storage boundary of a run; within it, private work files belong to its account. */\n storageRootFor: (runId: string) => string;\n sessionsDirectoryPattern: string;\n sessionWorkspaceFor: (runId: string) => Promise<SessionWorkspace>;\n skillPaths: () => Promise<readonly string[]>;\n resolver: () => WorkspaceResolver | undefined;\n runState: (runId: string) => RunState | null;\n storeBinding: (runId: string, binding: WorkspaceBinding) => void;\n clients: WorkspaceClientRegistry;\n /** What the profile's plugins contribute to the server's executor; the workstations load the same contributions themselves. */\n contributions: readonly WorkspaceExecutorParts[];\n /** The server's process sandbox; without it, the server's processes run without one. */\n processSandbox?: RunProcessSandboxes;\n /** The server's bash from RAGENTS_BASH; required on Windows for the bash tool. */\n bash?: string;\n /** The server's rg from RAGENTS_RG; without a value, one in the PATH applies. */\n rg?: string;\n /** The bash timeout from RAGENTS_BASH_TIMEOUT_SECONDS; without a value, that of the tool. */\n bashTimeoutSeconds?: number;\n}\n\nconst runNotStarted = (): DomainError => new DomainError(\n \"run-not-started\",\n \"The run has not started yet; the working directory is created with the first message.\",\n 409,\n);\n\nconst lookAround = \"Look around in it before you say anything about the project.\";\n\nconst serverProjectDescription = (cwd: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${cwd}\\` on the server: the project folder the user picked.`,\n `It is a real project. Work inside it, keep its structure, and never delete or reorganize files unless you are asked to. ${lookAround}`,\n].join(\"\\n\");\n\nconst clientProjectDescription = (projectPath: string, label: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is the project folder \\`${projectPath}\\` on the workstation \"${label}\", not on the server.`,\n \"Every workspace tool runs there, and a relative path refers to that folder.\",\n `It is a real project. Keep its structure, and never delete or reorganize files unless you are asked to. ${lookAround}`,\n].join(\"\\n\");\n\nconst freshWorkstationDescription = (folderPath: string, label: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${folderPath}\\` on the workstation \"${label}\", not on the server: a folder of this run alone.`,\n \"Every workspace tool runs there, and a relative path refers to that folder.\",\n \"It starts empty unless the profile prepared content in it. Look around in it before you say anything about what is already there.\",\n].join(\"\\n\");\n\nconst freshDescription = (cwd: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${cwd}\\`, a private folder of this conversation on the server.`,\n \"No other conversation sees it, and it starts empty unless the profile prepared content in it.\",\n \"Look around in it before you say anything about what is already there.\",\n].join(\"\\n\");\n\nconst listed = (entries: readonly string[]): string =>\n entries.length === 1 ? entries[0]! : `${entries.slice(0, -1).join(\", \")} and ${entries.at(-1)!}`;\n\nconst rootList = (roots: readonly ServerRootDescription[]): string =>\n listed(roots.map((root) => `\\`${root.alias}\\` (${root.writable ? \"read and write\" : \"read only\"})`));\n\nconst variableList = (roots: readonly ServerRootDescription[]): string => listed(roots\n .flatMap((root) => root.environmentVariable === undefined ? [] : [`\\`$${root.environmentVariable}\\` for \\`${root.alias}\\``]));\n\nconst hasVariables = (roots: readonly ServerRootDescription[]): boolean => roots.some((root) => root.environmentVariable !== undefined);\n\n/** On the server, workspace and roots are on one machine; every bash sees both. */\nconst serverRootsDescription = (roots: readonly ServerRootDescription[]): string => [\n \"## Roots besides the working directory\",\n \"\",\n `This run also reaches ${rootList(roots)}. File tools and language servers take a path that starts with the alias, `\n + `such as \\`${roots[0]!.alias}/<path>\\`; \\`bash\\` runs in such a root with that path as \\`cwd\\`.`\n + (hasVariables(roots) ? ` \\`bash\\` also has ${variableList(roots)}.` : \"\"),\n].join(\"\\n\");\n\n/** The roots are on the server, the workspace on the workstation; a bash always sees only one of the two machines. */\nconst workstationRootsDescription = (roots: readonly ServerRootDescription[]): string => [\n \"## Roots on the server\",\n \"\",\n `This run also reaches roots on the server: ${rootList(roots)}. File tools and language servers reach them from the `\n + `workstation as well: pass a path that starts with the alias, such as \\`${roots[0]!.alias}/<path>\\`. \\`bash\\` runs on `\n + \"the workstation; with a `cwd` that starts with an alias it runs on the server instead and sees only the server\"\n + (hasVariables(roots) ? `, and only that bash has ${variableList(roots)}` : \"\")\n + \". One call reaches one machine: never combine a path with an alias and a path in the working directory in one call.\",\n].join(\"\\n\");\n\nexport class RunWorkspaceRuntime implements WorkspaceRuntime {\n readonly sandbox: WorkspaceSandboxHost;\n readonly toolNaming: WorkspaceToolNaming = sandboxToolNaming;\n readonly transfer: WorkspaceTransfer;\n readonly #options: RunWorkspaceRuntimeOptions;\n readonly #nugetCacheDirectory: string;\n /** The new folders on workstations that have already been created or are in progress during this server run. */\n readonly #preparations = new Map<string, Promise<void>>();\n\n constructor(options: RunWorkspaceRuntimeOptions) {\n this.#options = options;\n this.transfer = {\n boundDirectory: (runId) => boundServerDirectory(options.runState(runId)),\n assertDirectory: (directory) => void serverDirectoryFolder(directory),\n rebind: (runId, directory) => options.storeBinding(runId, { machine: \"server\", folder: serverDirectoryFolder(directory) }),\n };\n this.#nugetCacheDirectory = path.join(options.globalDirectory, \"nuget-cache\");\n this.sandbox = new WorkspaceSandboxHost({\n contributorName: \"ragents.workspace.sandbox\",\n contributions: options.contributions,\n workspaceFor: options.sessionWorkspaceFor,\n identFor: () => Promise.resolve(undefined),\n skillPaths: options.skillPaths,\n storageRootFor: options.storageRootFor,\n homeFor: (runId) => this.#homeFor(runId),\n executorFor: (runId) => Promise.resolve(this.#executorFor(runId)),\n serverDirectoryFor: (runId) => this.#serverDirectoryFor(runId),\n ...(options.processSandbox ? { processSandbox: options.processSandbox } : {}),\n ...(options.bash === undefined ? {} : { bash: options.bash }),\n ...(options.rg === undefined ? {} : { rg: options.rg }),\n ...(options.bashTimeoutSeconds === undefined ? {} : { bashTimeoutSeconds: options.bashTimeoutSeconds }),\n });\n }\n\n /** Work of a run that runs on the server while its workspace is on a workstation. */\n async #serverDirectoryFor(runId: string): Promise<string> {\n const directory = this.#options.sessionDirectory(runId, \"server\");\n await mkdir(directory, { recursive: true });\n return realpath(directory);\n }\n\n async #homeFor(runId: string): Promise<SandboxHomeEnvironment> {\n const home = this.#options.sessionDirectory(runId, \"home\");\n await mkdir(home, { recursive: true });\n await mkdir(this.#nugetCacheDirectory, { recursive: true });\n return { home, nugetPackages: this.#nugetCacheDirectory };\n }\n\n /** On a workstation, its executor runs on behalf of the run owner, otherwise the server's executor. */\n #executorFor(runId: string): WorkspaceExecutor | undefined {\n const state = this.#options.runState(runId);\n const binding = bindingOf(state);\n if (!isWorkstationBinding(binding)) return undefined;\n const { machine, folder } = binding;\n const executor = this.#options.clients.executorFor(workspaceOwnerOf(state), machine.client, machine.label, folder.path);\n return \"fresh\" in folder ? this.#preparing(state, binding, executor) : executor;\n }\n\n /** Before the first task of a run, the workstation creates its new folder; cleanup never creates one. */\n #preparing(state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): WorkspaceExecutor {\n return {\n ...executor,\n execute: async (runId, operation, input, options = {}) => {\n if (!options.whenReachable) await this.#prepared(runId, state, binding, executor);\n return executor.execute(runId, operation, input, options);\n },\n };\n }\n\n #prepared(runId: string, state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): Promise<void> {\n const known = this.#preparations.get(runId);\n if (known) return known;\n const preparation = this.#prepare(runId, state, binding, executor).catch((error: unknown) => {\n this.#preparations.delete(runId);\n throw error;\n });\n this.#preparations.set(runId, preparation);\n return preparation;\n }\n\n /** Only a freshly created folder gets the contribution's steps; if one fails, the folder disappears again and the next task starts over. */\n async #prepare(runId: string, state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): Promise<void> {\n const { created } = await executor.execute(runId, RUN_FOLDER_OPERATIONS.create, null) as RunFolderCreated;\n const steps = created ? this.#contribution()?.workstation?.prepare(this.#workstationContext(runId, state, binding)) ?? [] : [];\n try {\n await this.#runSteps(runId, executor, steps);\n } catch (error) {\n await executor.execute(runId, RUN_FOLDER_OPERATIONS.remove, null, { whenReachable: true });\n throw error;\n }\n }\n\n async #runSteps(runId: string, executor: WorkspaceExecutor, steps: readonly WorkspaceFolderStep[], options: WorkspaceExecuteOptions = {}): Promise<void> {\n for (const step of steps) await executor.execute(runId, step.operation, step.input, options);\n }\n\n #workstationContext(runId: string, state: RunState | null, binding: WorkstationBinding): WorkstationFolderContext {\n const contribution = this.#contribution();\n return {\n runId,\n path: binding.folder.path,\n label: binding.machine.label,\n choice: contribution && state ? this.#choiceFor(state, contribution) : null,\n };\n }\n\n async resolve(runId: string, emitSystem: (text: string) => void): Promise<SessionWorkspace> {\n const state = this.#options.runState(runId);\n if (!state) throw runNotStarted();\n const binding = bindingOf(state);\n const { folder } = binding;\n const onWorkstation = isWorkstationBinding(binding);\n const workspace = onWorkstation ? this.#workstation(runId, state, binding, emitSystem)\n : isFreshFolder(folder) ? await this.#fresh(runId, state, emitSystem) : this.#bound(folder, emitSystem);\n return this.#withRoots(workspace, onWorkstation);\n }\n\n /** What the prompt says about roots depends on the run's machine: only a bash on the server knows their variables. */\n async #withRoots(workspace: SessionWorkspace, onWorkstation: boolean): Promise<SessionWorkspace> {\n const roots = await this.sandbox.serverRoots();\n if (roots.length === 0) return workspace;\n const described = onWorkstation ? workstationRootsDescription(roots) : serverRootsDescription(roots);\n return { ...workspace, description: [workspace.description, described].filter(Boolean).join(\"\\n\\n\") };\n }\n\n placementOf(runId: string): WorkspacePlacement {\n const { machine, folder } = bindingOf(this.#options.runState(runId));\n const placement: WorkspacePlacement = {\n machine: machine === \"server\" ? \"server\" : \"client\",\n folder: isFreshFolder(folder) ? \"fresh\" : \"existing\",\n };\n const contribution = this.#contribution();\n const contributed = placement.folder === \"fresh\" && (placement.machine === \"server\" || contribution?.workstation !== undefined);\n const kind = contributed ? contribution?.kind?.id : undefined;\n return kind === undefined ? placement : { ...placement, kind };\n }\n\n async #fresh(runId: string, state: RunState, emitSystem: (text: string) => void): Promise<SessionWorkspace> {\n const resolver = this.#options.resolver();\n const directory = resolver?.kind\n ? this.#options.sessionDirectory(runId, \"workspace\")\n : await this.#sessionWorkspace(runId);\n if (!resolver) return this.#directory(directory, freshDescription(directory));\n const { cwd, description, currentRoot, runOperation, ...rest } = await resolver.resolve({\n runId,\n directory,\n choice: this.#choiceFor(state, resolver),\n emitSystem,\n });\n const resolved = path.resolve(cwd);\n return {\n ...this.#directory(resolved, description ?? freshDescription(resolved)),\n ...rest,\n ...(currentRoot ? { currentRoot } : {}),\n ...(runOperation ? { runOperation } : {}),\n };\n }\n\n #bound(folder: ExistingWorkspaceFolder, emitSystem: (text: string) => void): SessionWorkspace {\n const cwd = path.resolve(folder.path);\n const existing = async (): Promise<string> => {\n try {\n return await realpath(cwd);\n } catch {\n throw new DomainError(\"workspace-path-missing\", `The bound folder ${cwd} no longer exists on the server.`, 409);\n }\n };\n emitSystem(`Workspace: ${cwd} (project folder on the server)`);\n return {\n cwd,\n description: serverProjectDescription(cwd),\n currentRoot: existing,\n runOperation: (operation) => operation(),\n };\n }\n\n /** The workspace is on the workstation; the server knows only its path, and every local access to it fails loudly. */\n #workstation(runId: string, state: RunState, binding: WorkstationBinding, emitSystem: (text: string) => void): SessionWorkspace {\n const { machine: { label }, folder } = binding;\n const fresh = \"fresh\" in folder;\n const workstation = this.#contribution()?.workstation;\n emitSystem(fresh\n ? `Workspace: ${folder.path} (${workstation?.label ?? FRESH_WORKSPACE_LABEL} on the workstation ${label})`\n : `Workspace: ${folder.path} (project folder on the workstation ${label})`);\n const remote = (): Promise<string> => Promise.reject(new Error(\n `The workspace ${folder.path} is on the workstation ${label}, not on the server; `\n + \"it is reachable only through the run's executor (SandboxServices.execute).\",\n ));\n const description = !fresh\n ? clientProjectDescription(folder.path, label)\n : workstation?.description?.(this.#workstationContext(runId, state, binding)) ?? freshWorkstationDescription(folder.path, label);\n return {\n cwd: folder.path,\n description,\n currentRoot: remote,\n runOperation: (operation) => operation(),\n };\n }\n\n async #sessionWorkspace(runId: string): Promise<string> {\n const directory = this.#options.sessionDirectory(runId, \"workspace\");\n await mkdir(directory, { recursive: true });\n return directory;\n }\n\n #directory(cwd: string, description: string, extraEnv?: NodeJS.ProcessEnv): SessionWorkspace {\n return {\n cwd,\n description,\n ...(extraEnv ? { extraEnv } : {}),\n currentRoot: () => realpath(cwd),\n runOperation: (operation) => operation(),\n };\n }\n\n #choiceFor(state: RunState, resolver: WorkspaceResolver): JsonValue | null {\n if (resolver.optionId === undefined) return null;\n const choice = storedStartOption(state, resolver.optionId);\n if (choice === undefined) {\n throw new Error(`The start option ${resolver.optionId} of the workspace resolver is not stored in the run`);\n }\n return choice;\n }\n\n describe(): WorkspaceRuntimeDescription {\n return {\n mode: \"per-run\",\n directoryPattern: this.#contribution()?.kind?.directoryPattern\n ?? path.join(this.#options.sessionsDirectoryPattern, \"workspace\"),\n };\n }\n\n #contribution(): WorkspaceResolver | undefined {\n return this.#options.resolver();\n }\n\n /** On the server, a new folder including stop and deletion belongs to the contribution; on a workstation, the host cleans it up. */\n #serverContributionFor(runId: string): WorkspaceResolver | undefined {\n const { machine, folder } = bindingOf(this.#options.runState(runId));\n return machine === \"server\" && isFreshFolder(folder) ? this.#contribution() : undefined;\n }\n\n /** If the workstation is unreachable, the folder stays there with a notice; the run is deleted anyway. */\n async #removeWorkstationFolder(runId: string): Promise<void> {\n this.#preparations.delete(runId);\n const state = this.#options.runState(runId);\n const binding = bindingOf(state);\n if (!isWorkstationBinding(binding) || !(\"fresh\" in binding.folder)) return;\n const { machine, folder } = binding;\n const executor = this.#options.clients.executorFor(workspaceOwnerOf(state), machine.client, machine.label, folder.path);\n const steps = this.#contribution()?.workstation?.release?.(this.#workstationContext(runId, state, binding)) ?? [];\n await this.#runSteps(runId, executor, steps, { whenReachable: true });\n if (await executor.execute(runId, RUN_FOLDER_OPERATIONS.remove, null, { whenReachable: true }) !== null) return;\n console.warn(`The folder ${folder.path} of run ${runId} stays on the workstation ${machine.label} because it was unreachable.`);\n }\n\n async deleteSession(runId: string): Promise<void> {\n const contribution = this.#serverContributionFor(runId);\n await this.stopSession(runId);\n await this.#removeWorkstationFolder(runId);\n await contribution?.deleteSession?.(runId);\n }\n\n stopSession(runId: string): Promise<void> {\n const contribution = this.#serverContributionFor(runId);\n const sandbox = (): Promise<void> => this.sandbox.shutdown(runId);\n return contribution?.stopSession ? contribution.stopSession(runId, sandbox) : sandbox();\n }\n\n async shutdown(): Promise<void> {\n await this.sandbox.shutdownAll();\n this.#options.clients.shutdown();\n }\n}\n"],
5
- "mappings": ";;;;AAAA,OAAOA,WAAU;AACjB,SAAS,eAAAC,oBAAsE;AAC/E,SAAS,0BAA0B;AACnC,SAAS,wBAAwB,6BAAqD;AACtF,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AAEjC,SAAS,gBAAAC,eAAc,wBAAwB;;;AChB/C,SAAS,yBAA0C;AACnD,SAAS,oBAAoB;AAEtB,IAAM,uBAAuB,CAAC,UAA2B,UAC9D;AAAA;AAAA,EAAwB,kBAAkB,UAAU,KAAK,CAAC;AAGrD,IAAM,sBAAsB,CACjC,IACA,OACA,aACA,eACuB,aAAa;AAAA,EACpC;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,QAAQ,MAAM,qBAAqB,QAAQ,UAAU,WAAW;AAAA,EAChE,GAAI,aAAa,EAAE,cAAc,WAAW,IAAI,CAAC;AACnD,GAAG,MAAM;;;ACjBT,IAAM,qBAAqB;AAAA,EACzB,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,EAC3C,QAAQ,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,EAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE;AACvE;AAEO,IAAM,oBAAyC;AAAA,EACpD,gBAAgB,CAAC,WAAW,mBAAmB,MAAM;AACvD;AAEO,IAAM,0BAA6C;AAA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,eAAe,KAAK,QAAQ,aAAa;AAAA,MACzC,uBAAuB,KAAK,QAAQ,mBAAmB;AAAA,MACvD,SAAS,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,OAAO;AAAA,MACrD,cAAc;AAAA,MACd,YAAY,CAAC,OAAe,aAAqB,kBAAkB,UAAU,SAAS,KAAK,CAAC,GAAG,QAAQ;AAAA,IACzG;AACA,SAAK,QAAQ,GAAG,oBAAoB,aAAa,GAAG,GAAG,cAAc,OAAO,CAAC;AAC7E,SAAK,SAAS,oBAAoB,aAAa,CAAC;AAChD,SAAK,aAAa,uBAAuB,SAAS,YAAY,CAAC;AAC/D,SAAK,gBAAgB,EAAE,IAAI,uBAAuB,UAAU,CAAC,EAAE,MAAM,MAAM,kBAAkB,SAAS,KAAK,GAAG,aAAa,CAAC,EAAE,CAAC;AAC/H,SAAK,UAAU;AAAA,MACb,IAAI;AAAA,MACJ,YAAY,MAAM,iBAAiB,eAAe,MAAM,IAAI,mBAAmB;AAAA,MAC/E,aAAa,CAAC,EAAE,MAAM,MAAM,QAAQ,YAAY,KAAK;AAAA,MACrD,eAAe,CAAC,EAAE,MAAM,MAAM,QAAQ,cAAc,KAAK;AAAA,MACzD,UAAU,YAAY;AACpB,cAAM,QAAQ,SAAS;AACvB,cAAM,gBAAgB,KAAK;AAAA,MAC7B;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,SAAuB;AAAA,EAClC,QAAQ,CAAC,SAAS,uBAAuB,MAAM,KAAK,OAAO,OAAO,CAAC;AACrE;",
4
+ "sourcesContent": ["import path from \"node:path\";\nimport { DomainError, type JsonValue, type RAgentsPlugin, type RunState } from \"@ragents/engine\";\nimport { documentStoreToken } from \"@ragents/host/ragents/document-store.js\";\nimport { workspaceResolverToken, workspaceRuntimeToken, type WorkspaceResolver } from \"@ragents/host/ragents/workspace-runtime.js\";\nimport { sandboxServicesToken } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport {\n executorContributionsToken,\n hostAddressToken,\n runtimeProviderToken,\n runGuardToken,\n runWorkspaceProviderToken,\n workspaceGuardToken,\n} from \"@ragents/host/ragents/host-services.js\";\nimport { pluginAsset } from \"@ragents/host/plugin-support/plugin-folder.js\";\nimport { ServerProcessSandbox } from \"@ragents/host/plugin-support/process-sandbox.js\";\nimport { ripgrepAvailable } from \"@ragents/workspace-executor\";\nimport type { PluginModule } from \"@ragents/host/plugin-support/plugin-module.js\";\nimport { boundToTools, handlebarsPrompt } from \"@ragents/host/plugin-support/prompt.js\";\nimport { shellPlatformPrompt } from \"./shell-platform.js\";\nimport { agentWorkspaceToolNames } from \"./workspace-tool-naming.js\";\nimport { startOptionScope } from \"@ragents/host/ragents/start-option-state.js\";\nimport { WORKSPACE_BINDING_OPTION_ID, WORKSPACE_METADATA_ID } from \"../contract.js\";\nimport { bindingOf, executorShellChapter, sessionMetadataOf, workspaceBindingOption, workspaceLocation, workspaceOwnerOf } from \"./binding.js\";\nimport { createBrowseChannel, createBrowseMethods } from \"./browse-route.js\";\nimport { clientMethods, WorkspaceClientRegistry } from \"./clients.js\";\nimport { bashSetting, bashTimeoutSetting, PROCESS_SANDBOX_OFF, processSandboxSetting, rgSetting, workspaceConfigDescriptors } from \"./config.js\";\nimport { RunWorkspaceRuntime } from \"./runtime.js\";\n\nconst warnWithoutSandbox = (): void => {\n console.warn(`Process sandbox turned off (${PROCESS_SANDBOX_OFF}): run processes run on the server without a sandbox.`);\n};\n\nconst ragentsWorkspacePlugin = (skillPaths: () => Promise<readonly string[]>): RAgentsPlugin => ({\n manifest: { id: \"ragents.workspace\" },\n register: (host) => {\n const sessionWorkspaceFor = host.service(runWorkspaceProviderToken);\n const orchestration = host.service(runtimeProviderToken);\n const runState = (runId: string): RunState | null => {\n try {\n return orchestration().state(runId);\n } catch (error) {\n if (error instanceof DomainError && error.code === \"run-not-found\") return null;\n throw error;\n }\n };\n const documentsFor = (runId: string): Promise<string | undefined> =>\n host.optionalService(documentStoreToken)?.directoryFor(runId) ?? Promise.resolve(undefined);\n const documentsRoot = async (runId: string): Promise<string> => {\n const directory = await documentsFor(runId);\n if (!directory) throw new Error(\"This profile has no file store; the plugin ragents.documents is missing\");\n return directory;\n };\n const contributions = host.service(executorContributionsToken);\n const clients = new WorkspaceClientRegistry(contributions);\n const contribution = (): WorkspaceResolver | undefined => host.optionalService(workspaceResolverToken);\n host.config(...workspaceConfigDescriptors);\n const sandboxSetting = processSandboxSetting();\n const processSandbox = sandboxSetting.enabled\n ? new ServerProcessSandbox({\n network: sandboxSetting.network,\n serverAddress: host.service(hostAddressToken)(),\n dataDirectory: path.dirname(host.storage.sessionsRoot),\n disableSetting: PROCESS_SANDBOX_OFF,\n })\n : undefined;\n const bash = bashSetting();\n const rg = rgSetting();\n const bashTimeoutSeconds = bashTimeoutSetting();\n const serverTools = { ripgrep: ripgrepAvailable(rg, process.env) };\n const runtime = new RunWorkspaceRuntime({\n clients,\n contributions: contributions.map((contribution) => contribution.parts),\n ...(processSandbox ? { processSandbox } : {}),\n ...(bash === undefined ? {} : { bash }),\n ...(rg === undefined ? {} : { rg }),\n ...(bashTimeoutSeconds === undefined ? {} : { bashTimeoutSeconds }),\n globalDirectory: host.storage.root(),\n sessionDirectory: (runId, ...segments) => host.storage.session(runId, ...segments),\n storageRootFor: (runId) => path.join(host.storage.sessionsRoot, runId),\n sessionsDirectoryPattern: path.join(host.storage.sessionsRoot, \"{runId}\", \"plugins\", host.manifest.id),\n sessionWorkspaceFor,\n skillPaths,\n resolver: contribution,\n runState,\n storeBinding: (runId, binding) => {\n const state = orchestration().state(runId);\n orchestration().replacePluginState(\n { actorId: state.ownerId, commandId: `workspace-binding:${runId}:${state.revision}` },\n runId,\n { pluginId: WORKSPACE_BINDING_OPTION_ID, scope: startOptionScope, state: binding as unknown as JsonValue },\n );\n },\n });\n host.provide(workspaceRuntimeToken, runtime);\n host.provide(sandboxServicesToken, runtime.sandbox);\n host.functions(runtime.sandbox.workspaceTools());\n const rules = handlebarsPrompt(\"ragents.workspace.prompt\", 100, pluginAsset(\"ragents.workspace\", \"prompt.hbs\"));\n host.prompts(\n boundToTools({\n ...rules,\n delivery: \"initial\",\n // The rules apply to the host's workspaces; a contributed kind describes its own.\n render: (context) => contribution()?.kind ? \"\" : rules.render(context),\n }, ...agentWorkspaceToolNames),\n shellPlatformPrompt(\"ragents.workspace.shell.prompt\", 102, serverTools, (runId) => {\n const state = runState(runId);\n return executorShellChapter(clients, workspaceOwnerOf(state), bindingOf(state), serverTools);\n }),\n );\n const browseOptions = {\n ensureSession: host.service(runGuardToken),\n ensureWorkspaceAccess: host.service(workspaceGuardToken),\n execute: runtime.sandbox.execute.bind(runtime.sandbox),\n documentsFor: documentsRoot,\n locationOf: (runId: string, location: string) => workspaceLocation(bindingOf(runState(runId)), location),\n };\n host.methods(...createBrowseMethods(browseOptions), ...clientMethods(clients));\n host.channels(createBrowseChannel(browseOptions));\n host.startOptions(workspaceBindingOption(clients, contribution));\n host.sessionMetadata({ id: WORKSPACE_METADATA_ID, describe: ({ runId }) => sessionMetadataOf(runState(runId), contribution()) });\n host.lifecycle({\n id: \"ragents.workspace.lifecycle\",\n initialize: () => processSandbox ? processSandbox.start() : warnWithoutSandbox(),\n stopSession: ({ runId }) => runtime.stopSession(runId),\n deleteSession: ({ runId }) => runtime.deleteSession(runId),\n shutdown: async () => {\n await runtime.shutdown();\n await processSandbox?.stop();\n },\n });\n },\n});\n\nexport const plugin: PluginModule = {\n create: (host) => ragentsWorkspacePlugin(() => host.skills.global()),\n};\n", "import type { PromptContribution } from \"@ragents/engine\";\nimport { shellPlatformText, type ShellTools } from \"@ragents/workspace-executor\";\nimport { boundToTools } from \"@ragents/host/plugin-support/prompt.js\";\n\nexport const shellPlatformChapter = (platform: NodeJS.Platform, tools: ShellTools): string =>\n `## Shell platform\\n\\n${shellPlatformText(platform, tools)}`;\n\n/** Without a value, the platform and tools of the server apply; `chapterFor` names those of the executor that runs the run. */\nexport const shellPlatformPrompt = (\n id: string,\n order: number,\n serverTools: ShellTools,\n chapterFor?: (runId: string) => string,\n): PromptContribution => boundToTools({\n id,\n order,\n delivery: \"initial\",\n render: () => shellPlatformChapter(process.platform, serverTools),\n ...(chapterFor ? { renderForRun: chapterFor } : {}),\n}, \"bash\");\n", "import type { WorkspaceToolNaming } from \"@ragents/engine\";\n\nconst workspaceToolTable = {\n manual: { read: [], write: [], execute: [] },\n script: { read: [], write: [], execute: [] },\n agent: { read: [\"read\"], write: [\"edit\", \"write\"], execute: [\"bash\"] },\n} as const;\n\nexport const sandboxToolNaming: WorkspaceToolNaming = {\n agentToolNames: (driver) => workspaceToolTable[driver],\n};\n\nexport const agentWorkspaceToolNames: readonly string[] = [\n ...workspaceToolTable.agent.read,\n ...workspaceToolTable.agent.write,\n ...workspaceToolTable.agent.execute,\n];\n", "import { Type } from \"typebox\";\nimport { openJson } from \"@ragents/engine/src/http/contracts\";\nimport { defineChannel, defineOperation } from \"@ragents/engine/src/rpc/contract\";\n\nexport const WORKSPACE_PLUGIN_ID = \"ragents.workspace\";\n\nexport const BROWSE_ROOTS = [\"workspace\", \"files\"] as const;\nexport type BrowseRoot = typeof BROWSE_ROOTS[number];\n\nexport interface BrowseEntry {\n name: string;\n kind: \"directory\" | \"file\";\n size: number;\n modifiedAt: string;\n}\n\nexport interface BrowseListing {\n root: BrowseRoot;\n /** Where the root is; on a workstation with its label. */\n location: string;\n path: string;\n entries: BrowseEntry[];\n truncated: boolean;\n}\n\nexport type BrowsePreview =\n | { root: BrowseRoot; path: string; size: number; previewable: true; content: string }\n | { root: BrowseRoot; path: string; size: number; previewable: false; reason: string };\n\nexport const WORKSPACE_BINDING_OPTION_ID = \"ragents.workspace.binding\";\n\nexport const WORKSPACE_METADATA_ID = \"ragents.workspace\";\n\n/** On which machine the workspace of a run is: the server or a workstation whose label the binding records. */\nexport type WorkspaceMachine = \"server\" | { client: string; label: string };\n\n/** An existing folder that the run neither creates nor deletes. */\nexport type ExistingWorkspaceFolder = {\n path: string;\n};\n\n/** The new folder per run on a workstation; the binding records its path there from the moment it is chosen. */\nexport type FreshWorkstationFolder = {\n path: string;\n fresh: true;\n};\n\n/** Which folder: a new one per run or an existing one; for `fresh` on the server, the host creates one per run in its storage. */\nexport type WorkspaceFolder = \"fresh\" | ExistingWorkspaceFolder | FreshWorkstationFolder;\n\n/** Where and in which folder a run works; frozen into the journal as a start option at the start. */\nexport type WorkspaceBinding = {\n machine: WorkspaceMachine;\n folder: WorkspaceFolder;\n};\n\nexport const freshServerBinding = (): WorkspaceBinding => ({ machine: \"server\", folder: \"fresh\" });\n\nexport const WORKSPACE_CLIENT_ID_PATTERN = /^[A-Za-z0-9_-]{8,64}$/;\n\n/** What a workstation says about itself at sign-in. */\nexport interface WorkspaceClientDescription {\n label: string;\n hostname: string;\n platform: string;\n folders: string[];\n /** Where the workstation creates the new folders per run, one subfolder per run named with its ID. */\n runsDirectory: string;\n /** Whether the workstation's bash finds rg; the prompt adjusts the search accordingly. */\n ripgrep: boolean;\n}\n\nexport interface WorkspaceClientInfo extends WorkspaceClientDescription {\n id: string;\n}\n\n/** What the new folder per run is called on each machine: the empty folder or a plugin's contribution; null where there is none. */\nexport interface FreshWorkspaceLabels {\n server: string;\n client: string | null;\n}\n\nexport interface WorkspaceBindingPresentation {\n kind: \"workspace-binding\";\n clients: WorkspaceClientInfo[];\n fresh: FreshWorkspaceLabels;\n /** Whether an existing folder of the server machine may be bound. */\n serverFolders: boolean;\n}\n\nexport interface WorkspaceSessionMetadata {\n binding: WorkspaceBinding;\n summary: string;\n}\n\nconst clientId = Type.String({ pattern: \"^[A-Za-z0-9_-]{8,64}$\", description: \"Stable ID of the workstation\" });\n\nconst executorVersion = Type.String({ minLength: 1, maxLength: 64, description: \"Version of the executor that the workstation brings\" });\n\n/** The ID of a plugin; a workstation looks for its bundle under exactly this name, so it cannot contain a path. */\nexport const PLUGIN_ID_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;\n\nconst executorContributions = Type.Array(Type.Object({\n plugin: Type.String({ pattern: PLUGIN_ID_PATTERN.source, maxLength: 128, description: \"ID of the plugin\" }),\n revision: Type.String({ pattern: \"^[0-9a-f]{64}$\", description: \"SHA-256 of the contribution file\" }),\n}, { additionalProperties: false }), { maxItems: 64, description: \"The plugins' contributions to the executor, in the order of the server's plugin list\" });\n\nconst clientDescription = {\n label: Type.String({ minLength: 1, maxLength: 120 }),\n hostname: Type.String({ minLength: 1 }),\n platform: Type.String({ minLength: 1 }),\n folders: Type.Array(Type.String({ minLength: 1 }), { maxItems: 32 }),\n runsDirectory: Type.String({ minLength: 1, description: \"Absolute folder under which the workstation creates the new folders per run\" }),\n ripgrep: Type.Boolean({ description: \"Whether the workstation's bash finds rg\" }),\n};\n\nexport const clientInfoSchema = Type.Object({\n id: Type.String(),\n ...clientDescription,\n}, { additionalProperties: false });\n\n/** The sign-in as a workstation with the server's executor sends it. */\nexport const clientRegistrationSchema = Type.Object({\n id: clientId,\n ...clientDescription,\n executor: executorVersion,\n contributions: executorContributions,\n}, { additionalProperties: false });\n\n/** A workstation with a different executor does not know the shape of this version; the server rejects it by its version, not by its shape. */\nconst otherExecutorRegistration = Type.Object({ label: clientDescription.label, executor: executorVersion }, {\n description: \"Sign-in with a different executor version in any shape; the server rejects it with workspace-executor-version\",\n});\n\nconst absolutePath = Type.String({ minLength: 1, description: \"Absolute path in the bound folder\" });\n\n/** Not an operation of a module: releases what the workstation's executor holds for the run. */\nexport const WORKSPACE_CLIENT_STOP_OPERATION = \"stop\";\n\n/** The one operation the server calls on the workstation; progress is the JSON value of the operation, for bash { text }. */\nexport const workspaceClientContracts = {\n execute: defineOperation({\n id: \"ragents.workspace.client.execute\",\n description: \"Run an operation of the executor on the workstation, such as a tool, a file query, or the process display; the result is its value, progress its JSON value. stop releases what the workstation holds for the run.\",\n implementedBy: \"client\",\n input: Type.Object({\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"ID of the run\" }),\n operation: Type.String({ minLength: 1, maxLength: 64, description: \"Name of the operation, such as read, bash, roslyn_open, files.list, or stop\" }),\n toolCallId: Type.Optional(Type.String({ minLength: 1, maxLength: 200, description: \"Only for a tool call of the model\" })),\n cwd: absolutePath,\n env: Type.Record(Type.String(), Type.String(), { description: \"What the server contributes: run marker and git rules of the sandbox\" }),\n input: Type.Unknown({ description: \"The input of the operation\" }),\n }, { additionalProperties: false }),\n result: Type.Object({ value: Type.Unknown() }, { additionalProperties: false }),\n }),\n} as const;\n\nconst browseTarget = {\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"ID of the run\" }),\n root: Type.Union([Type.Literal(\"workspace\"), Type.Literal(\"files\")]),\n path: Type.String({ description: \"Path below the root; empty is the root itself\" }),\n};\n\n/** The sign-in of a workstation binds the calling connection; the server calls back through it. */\nexport const workspaceContracts = {\n browse: {\n list: defineOperation({\n id: \"ragents.workspace.browse.list\",\n description: \"List a directory in the workspace or in the file store of a run.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n input: Type.Object(browseTarget, { additionalProperties: false }),\n result: openJson<BrowseListing>(\"BrowseListing\"),\n }),\n preview: defineOperation({\n id: \"ragents.workspace.browse.preview\",\n description: \"Preview a file as text; files that are too large or binary state the reason instead.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n input: Type.Object(browseTarget, { additionalProperties: false }),\n result: openJson<BrowsePreview>(\"BrowsePreview\"),\n }),\n },\n channels: {\n browse: defineChannel({\n id: \"ragents.workspace.browse\",\n description: \"Reports every change below the observed root of a run.\",\n rights: [\"runs.read\", \"runs.inspect\"],\n params: Type.Object({ runId: browseTarget.runId, root: browseTarget.root }, { additionalProperties: false }),\n message: Type.Object({ changed: Type.Literal(true) }, { additionalProperties: false }),\n }),\n },\n clients: {\n list: defineOperation({\n id: \"ragents.workspace.clients.list\",\n description: \"The caller's signed-in workstations; other users' workstations do not appear even with runs.read.all.\",\n rights: [\"runs.read\"],\n input: Type.Object({}, { additionalProperties: false }),\n result: Type.Array(clientInfoSchema),\n }),\n contributions: defineOperation({\n id: \"ragents.workspace.clients.contributions\",\n description: \"The plugins' contributions to the executor that a workstation loads before sign-in and reports back with it. A workstation with a different executor version fails on its version; other fields do not matter.\",\n rights: [\"runs.write\"],\n input: Type.Object({ label: clientDescription.label, executor: executorVersion }),\n result: executorContributions,\n }),\n register: defineOperation({\n id: \"ragents.workspace.clients.register\",\n description: \"Sign in a workstation or renew its folders; the connection of this request becomes its return path and needs an event stream. A workstation with a different executor version fails on its version before the rest of the shape matters.\",\n rights: [\"runs.write\"],\n input: Type.Union([clientRegistrationSchema, otherExecutorRegistration]),\n result: clientInfoSchema,\n }),\n unregister: defineOperation({\n id: \"ragents.workspace.clients.unregister\",\n description: \"Sign out one of your own workstations; open tasks fail.\",\n rights: [\"runs.write\"],\n input: Type.Object({ id: clientId }, { additionalProperties: false }),\n result: Type.Null(),\n }),\n },\n} as const;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null;\n\nconst hasExactly = (value: Record<string, unknown>, keys: readonly string[]): boolean =>\n Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key));\n\nconst isMachine = (value: unknown): value is WorkspaceMachine =>\n value === \"server\" || (isRecord(value) && hasExactly(value, [\"client\", \"label\"])\n && typeof value.client === \"string\" && WORKSPACE_CLIENT_ID_PATTERN.test(value.client) && typeof value.label === \"string\");\n\nconst isFolder = (value: unknown): value is WorkspaceFolder => {\n if (value === \"fresh\") return true;\n if (!isRecord(value) || typeof value.path !== \"string\" || value.path.length === 0) return false;\n return hasExactly(value, [\"path\"]) || (hasExactly(value, [\"path\", \"fresh\"]) && value.fresh === true);\n};\n\n/** A new folder with a path exists only on a workstation; on the server the host creates it itself. */\nexport const isWorkspaceBinding = (value: unknown): value is WorkspaceBinding =>\n isRecord(value) && hasExactly(value, [\"machine\", \"folder\"]) && isMachine(value.machine) && isFolder(value.folder)\n && !(value.machine === \"server\" && typeof value.folder === \"object\" && \"fresh\" in value.folder);\n\nexport const isFreshFolder = (folder: WorkspaceFolder): folder is \"fresh\" | FreshWorkstationFolder =>\n folder === \"fresh\" || \"fresh\" in folder;\n\n/** The shape before machine and folder were separated, `{ kind: \"fresh\" | \"path\" | \"client\" }`, mapped unambiguously to the current one. */\nconst fromKind = (value: Record<string, unknown>): unknown => {\n switch (value.kind) {\n case \"fresh\": return hasExactly(value, [\"kind\"]) ? freshServerBinding() : undefined;\n case \"path\": return hasExactly(value, [\"kind\", \"path\"]) ? { machine: \"server\", folder: { path: value.path } } : undefined;\n case \"client\": return hasExactly(value, [\"kind\", \"client\", \"label\", \"path\"])\n ? { machine: { client: value.client, label: value.label }, folder: { path: value.path } }\n : undefined;\n default: return undefined;\n }\n};\n\n/** The stored binding; older, immutable journals carry the shape with `kind`, and only here is it mapped. */\nexport const storedWorkspaceBinding = (value: unknown): WorkspaceBinding | undefined => {\n if (isWorkspaceBinding(value)) return value;\n const mapped = isRecord(value) && Object.hasOwn(value, \"kind\") ? fromKind(value) : undefined;\n return isWorkspaceBinding(mapped) ? mapped : undefined;\n};\n\nexport const FRESH_WORKSPACE_LABEL = \"Empty folder per run\";\n\n/** What the new folder per run is called on the binding's machine; without a contribution there, the empty folder. */\nconst freshLabelOf = (binding: WorkspaceBinding, labels: FreshWorkspaceLabels): string =>\n (binding.machine === \"server\" ? labels.server : labels.client) ?? FRESH_WORKSPACE_LABEL;\n\nexport const workspaceBindingSummary = (binding: WorkspaceBinding, labels: FreshWorkspaceLabels): string => {\n const { machine, folder } = binding;\n const fresh = freshLabelOf(binding, labels);\n const where = folder === \"fresh\" ? fresh : \"fresh\" in folder ? `${folder.path} (${fresh})` : folder.path;\n return machine === \"server\" ? where : `${machine.label}: ${where}`;\n};\n", "import { statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { Type } from \"typebox\";\nimport { DomainError, type JsonValue, type RunState, type StartOptionContribution } from \"@ragents/engine\";\nimport type { ShellTools } from \"@ragents/workspace-executor\";\nimport { shellPlatformChapter } from \"./shell-platform.js\";\nimport { storedStartOption } from \"@ragents/host/ragents/start-option-state.js\";\nimport type { WorkspaceResolver } from \"@ragents/host/ragents/workspace-runtime.js\";\nimport {\n freshServerBinding,\n FRESH_WORKSPACE_LABEL,\n isFreshFolder,\n isWorkspaceBinding,\n storedWorkspaceBinding,\n WORKSPACE_BINDING_OPTION_ID,\n workspaceBindingSummary,\n type ExistingWorkspaceFolder,\n type FreshWorkspaceLabels,\n type FreshWorkstationFolder,\n type WorkspaceBinding,\n type WorkspaceBindingPresentation,\n type WorkspaceClientInfo,\n type WorkspaceSessionMetadata,\n} from \"../contract.js\";\nimport type { WorkspaceClientRegistry } from \"./clients.js\";\n\nconst machineSchema = Type.Union([\n Type.Literal(\"server\"),\n Type.Object({ client: Type.String({ minLength: 8, maxLength: 64 }), label: Type.String() }, { additionalProperties: false }),\n]);\n\nconst folderSchema = Type.Union([\n Type.Literal(\"fresh\"),\n Type.Object({ path: Type.String({ minLength: 1 }), fresh: Type.Optional(Type.Literal(true)) }, { additionalProperties: false }),\n]);\n\nconst bindingSchema = Type.Object({ machine: machineSchema, folder: folderSchema }, { additionalProperties: false });\n\n/** A run on a workstation with its ID, label, and the folder there; `fresh` then already carries its path. */\nexport type WorkstationBinding = {\n machine: { client: string; label: string };\n folder: ExistingWorkspaceFolder | FreshWorkstationFolder;\n};\n\nconst insideFolder = (folder: string, candidate: string): boolean => {\n const separator = folder.includes(\"\\\\\") ? \"\\\\\" : \"/\";\n const root = folder.endsWith(separator) ? folder.slice(0, -separator.length) : folder;\n return candidate === root || candidate.startsWith(root + separator);\n};\n\n/** The folder of a run below the folder in which a workstation creates the new folders per run; with its separator. */\nexport const workstationRunFolder = (runsDirectory: string, runId: string): string => {\n const separator = runsDirectory.includes(\"\\\\\") ? \"\\\\\" : \"/\";\n const root = runsDirectory.endsWith(separator) ? runsDirectory.slice(0, -separator.length) : runsDirectory;\n return `${root}${separator}${runId}`;\n};\n\n/** The binding of a run; without a stored choice the new folder on the server, an unreadable one blocks the run with a cause. */\nexport const bindingOf = (state: RunState | null): WorkspaceBinding => {\n const stored = storedStartOption(state, WORKSPACE_BINDING_OPTION_ID);\n if (stored === undefined) return freshServerBinding();\n const binding = storedWorkspaceBinding(stored);\n if (!binding || (binding.machine !== \"server\" && binding.folder === \"fresh\")) {\n throw new Error(`The stored workspace binding is invalid: ${JSON.stringify(stored)}`);\n }\n return binding;\n};\n\nexport const isWorkstationBinding = (binding: WorkspaceBinding): binding is WorkstationBinding =>\n binding.machine !== \"server\" && binding.folder !== \"fresh\";\n\n/** A run uses only workstations of its owner, a run without an owner only those signed in without a user. */\nexport const workspaceOwnerOf = (state: RunState | null): string | null => state?.ownerUserId ?? null;\n\n/** The existing folder on the server machine that the run is bound to; a new folder and a workstation are not there. */\nexport const boundServerDirectory = (state: RunState | null): string | null => {\n const { machine, folder } = bindingOf(state);\n return machine === \"server\" && folder !== \"fresh\" ? folder.path : null;\n};\n\n/** An existing folder of this server; the same check as when choosing the start option. */\nexport const serverDirectoryFolder = (directory: string): ExistingWorkspaceFolder => {\n if (!path.isAbsolute(directory)) throw new DomainError(\"workspace-path-relative\", \"The folder must be an absolute path.\", 400);\n const resolved = path.resolve(directory);\n if (!statSync(resolved, { throwIfNoEntry: false })?.isDirectory()) {\n throw new DomainError(\"workspace-path-missing\", `The folder ${resolved} does not exist on the server.`, 400);\n }\n return { path: resolved };\n};\n\n/** The bash of a run runs on the executor of its binding; the prompt therefore names its platform and tools, not those of the server. */\nexport const executorShellChapter = (\n registry: WorkspaceClientRegistry,\n owner: string | null,\n binding: WorkspaceBinding,\n serverTools: ShellTools,\n): string => {\n const { machine } = binding;\n if (machine === \"server\") return shellPlatformChapter(process.platform, serverTools);\n const client = registry.info(owner, machine.client);\n return client\n ? shellPlatformChapter(client.platform as NodeJS.Platform, { ripgrep: client.ripgrep })\n : `## Shell platform\\n\\nThe workstation ${machine.label} that holds this project is not registered right now, `\n + \"so the platform of its shell is unknown; the workspace tools fail until it connects again.\";\n};\n\n/** Where the root of a run is, in words: on a workstation with its label, otherwise the path itself. */\nexport const workspaceLocation = (binding: WorkspaceBinding, location: string): string =>\n binding.machine === \"server\" ? location : `Workstation ${binding.machine.label}: ${location}`;\n\n/** The contribution provides the new folder per run as soon as there is one; on a workstation only if it explicitly can there. */\nexport const freshLabels = (contribution: WorkspaceResolver | undefined): FreshWorkspaceLabels => ({\n server: contribution?.kind?.label ?? FRESH_WORKSPACE_LABEL,\n client: contribution ? contribution.workstation?.label ?? null : FRESH_WORKSPACE_LABEL,\n});\n\nexport const sessionMetadataOf = (state: RunState | null, contribution: WorkspaceResolver | undefined): WorkspaceSessionMetadata => {\n const binding = bindingOf(state);\n return { binding, summary: workspaceBindingSummary(binding, freshLabels(contribution)) };\n};\n\nconst unsupported = (message: string): DomainError => new DomainError(\"workspace-binding-unsupported\", message, 400);\n\n/** A workstation of the acting user that offers the folder; a new folder per run gets its path there below its folder for runs. */\nconst workstationBinding = (\n client: WorkspaceClientInfo,\n folder: WorkspaceBinding[\"folder\"],\n runId: string,\n labels: FreshWorkspaceLabels,\n): WorkstationBinding => {\n const machine = { client: client.id, label: client.label };\n if (isFreshFolder(folder)) {\n if (labels.client === null) {\n throw unsupported(`A new folder per run exists here only on the server (${labels.server}); choose one there or an existing folder of the workstation.`);\n }\n return { machine, folder: { path: workstationRunFolder(client.runsDirectory, runId), fresh: true } };\n }\n if (!client.folders.some((offered) => insideFolder(offered, folder.path))) {\n throw new DomainError(\"workspace-client-folder\", `The workstation ${client.label} does not offer the folder ${folder.path}.`, 400);\n }\n return { machine, folder: { path: folder.path } };\n};\n\nexport const workspaceBindingOption = (\n registry: WorkspaceClientRegistry,\n contribution: () => WorkspaceResolver | undefined,\n): StartOptionContribution => ({\n id: WORKSPACE_BINDING_OPTION_ID,\n schema: bindingSchema,\n selectable: () => true,\n defaultValue: () => freshServerBinding(),\n accept: (value, { runId, userId }) => {\n if (!isWorkspaceBinding(value)) throw new DomainError(\"workspace-binding-invalid\", \"The workspace binding has no valid format.\", 400);\n const labels = freshLabels(contribution());\n const { machine, folder } = value;\n if (machine === \"server\") {\n if (folder === \"fresh\") return freshServerBinding();\n if (\"fresh\" in folder) throw new DomainError(\"workspace-binding-invalid\", \"On the server, the host creates the new folder per run; it has no chosen path.\", 400);\n if (!(contribution()?.kind?.serverFolders ?? true)) {\n throw unsupported(`An existing folder on the server machine is not a binding here; choose ${labels.server} or a workstation.`);\n }\n return { machine, folder: serverDirectoryFolder(folder.path) };\n }\n const client = registry.info(userId, machine.client);\n if (!client) throw new DomainError(\"workspace-client-disconnected\", `The workstation ${machine.label || machine.client} is not connected.`, 409);\n return workstationBinding(client, folder, runId, labels);\n },\n describe: (_value, { userId }) => {\n const presentation: WorkspaceBindingPresentation = {\n kind: \"workspace-binding\",\n clients: registry.list(userId),\n fresh: freshLabels(contribution()),\n serverFolders: contribution()?.kind?.serverFolders ?? true,\n };\n return presentation as unknown as JsonValue;\n },\n ownerOnly: (value) => {\n const binding = storedWorkspaceBinding(value);\n return binding !== undefined && binding.machine !== \"server\";\n },\n});\n", "import {\n implement,\n implementChannel,\n type AccessContext,\n type ChannelContribution,\n type MethodContribution,\n} from \"@ragents/engine\";\nimport {\n FILE_OPERATIONS,\n listDirectory,\n readTextFile,\n watchDirectory,\n type FileListing,\n type FileText,\n type FileWatchProgress,\n} from \"@ragents/workspace-executor\";\nimport { withDomainCause, type SandboxServices } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport {\n workspaceContracts,\n type BrowseListing,\n type BrowsePreview,\n type BrowseRoot,\n} from \"../contract.js\";\n\nexport interface BrowseOptions {\n ensureSession: (runId: string) => void;\n /** The workspace of a run that only its owner operates is with the owner; the server's file store is not. */\n ensureWorkspaceAccess: (access: AccessContext, runId: string) => void;\n /** The workspace is reachable only through the run's executor, wherever it is. */\n execute: SandboxServices[\"execute\"];\n /** The file store is on the server and does not belong to the workspace. */\n documentsFor: (runId: string) => Promise<string>;\n /** What the root of a run is called, for example with the label of its workstation. */\n locationOf: (runId: string, location: string) => string;\n}\n\nconst onServer = async <T>(operation: () => Promise<T>): Promise<T> => {\n try {\n return await operation();\n } catch (error) {\n throw withDomainCause(error);\n }\n};\n\nconst listingOf = async (options: BrowseOptions, runId: string, root: BrowseRoot, target: string): Promise<BrowseListing> => {\n if (root === \"files\") {\n const listing = await onServer(async () => listDirectory(await options.documentsFor(runId), target));\n return { root, ...listing };\n }\n const listing = await options.execute(runId, FILE_OPERATIONS.list, { path: target }) as FileListing;\n return { root, ...listing, location: options.locationOf(runId, listing.location) };\n};\n\nconst previewOf = async (options: BrowseOptions, runId: string, root: BrowseRoot, target: string): Promise<BrowsePreview> => {\n const text = root === \"files\"\n ? await onServer(async () => readTextFile(await options.documentsFor(runId), target))\n : await options.execute(runId, FILE_OPERATIONS.read, { path: target }) as FileText;\n return { root, ...text };\n};\n\nconst ensureRoot = (options: BrowseOptions, access: AccessContext, runId: string, root: BrowseRoot): void => {\n if (root === \"workspace\") options.ensureWorkspaceAccess(access, runId);\n else options.ensureSession(runId);\n};\n\nexport const createBrowseMethods = (options: BrowseOptions): MethodContribution[] => [\n implement(workspaceContracts.browse.list, ({ runId, root, path: target }, { access }) => {\n ensureRoot(options, access, runId, root);\n return listingOf(options, runId, root, target);\n }),\n implement(workspaceContracts.browse.preview, ({ runId, root, path: target }, { access }) => {\n ensureRoot(options, access, runId, root);\n return previewOf(options, runId, root, target);\n }),\n];\n\n/** After a running watch ends, for example because the workstation was gone, the channel retries at this interval. */\nconst WATCH_RETRY_MS = 5_000;\n\n/** Watches the workspace at the run's executor until aborted; once the watch is established the channel is open, and when it ends, it starts a new one. */\nconst watchWorkspace = (options: BrowseOptions, runId: string, changed: () => void): Promise<() => void> =>\n new Promise((ready, failed) => {\n const controller = new AbortController();\n let opened = false;\n let retry: NodeJS.Timeout | undefined;\n const stop = (): void => {\n controller.abort();\n clearTimeout(retry);\n };\n const start = (): void => {\n let watching = false;\n const ended = (error?: unknown): void => {\n if (controller.signal.aborted) return;\n if (!opened) {\n failed(error ?? new Error(\"The workspace watch ended before it was established\"));\n return;\n }\n // When a running watch ends, the view reloads and shows the cause; once the next one is established, it reloads again.\n if (watching) changed();\n retry = setTimeout(start, WATCH_RETRY_MS);\n };\n options.execute(runId, FILE_OPERATIONS.watch, {}, {\n signal: controller.signal,\n untilAborted: true,\n onProgress: (value) => {\n if ((value as FileWatchProgress).kind === \"changed\") changed();\n else if (!watching) {\n watching = true;\n if (opened) changed();\n else {\n opened = true;\n ready(stop);\n }\n }\n },\n }).then(() => ended(), ended);\n };\n start();\n });\n\nexport const createBrowseChannel = (options: BrowseOptions): ChannelContribution =>\n implementChannel(workspaceContracts.channels.browse, async ({ runId, root }, emit, { access }) => {\n ensureRoot(options, access, runId, root);\n const changed = (): void => emit({ changed: true });\n if (root === \"workspace\") return watchWorkspace(options, runId, changed);\n return onServer(async () => watchDirectory(await options.documentsFor(runId), { onChange: changed, onError: changed }));\n });\n", "import { Value } from \"typebox/value\";\nimport {\n DomainError,\n RPC_ERROR_CODES,\n RpcError,\n implement,\n schemaComplaints,\n type AccessContext,\n type MethodConnection,\n type MethodContribution,\n} from \"@ragents/engine\";\nimport {\n WORKSPACE_EXECUTOR_VERSION,\n sandboxRunEnvironment,\n type ExecutorContributionRevision,\n type WorkspaceExecuteOptions,\n type WorkspaceExecutor,\n} from \"@ragents/workspace-executor\";\nimport {\n WORKSPACE_CLIENT_STOP_OPERATION,\n clientRegistrationSchema,\n workspaceClientContracts,\n workspaceContracts,\n type WorkspaceClientDescription,\n type WorkspaceClientInfo,\n} from \"../contract.js\";\n\ninterface ClientEntry {\n readonly info: WorkspaceClientInfo;\n readonly owner: string | null;\n readonly connection: MethodConnection;\n readonly release: () => void;\n /** The open calls through this sign-in; if a new connection replaces it, they fail immediately. */\n readonly calls: Set<AbortController>;\n /** The stops currently being delivered through this sign-in, per run. */\n readonly stops: Map<string, Promise<void>>;\n}\n\n/** The only limit against a hanging workstation; the executor has its own timeouts. */\nconst CLIENT_TIMEOUT_MS = 15 * 60 * 1000;\n\n/** This is how long cleanup (stop, `whenReachable`) waits for the workstation; it stays below the plugins' stop limit. */\nconst CLEANUP_TIMEOUT_MS = 10_000;\n\n/** After this long, the server retries a pending stop as long as the workstation is signed in. */\nconst STOP_RETRY_MS = 30_000;\n\nexport const ownerOf = (access: AccessContext): string | null => access.user?.id ?? null;\n\n/** A watch runs until aborted, cleanup briefly; everything else waits for the safety limit plus the duration the call itself requests. */\nconst timeoutFor = (options: WorkspaceExecuteOptions): { timeoutMs?: number } => {\n if (options.untilAborted) return {};\n if (options.whenReachable) return { timeoutMs: CLEANUP_TIMEOUT_MS };\n return { timeoutMs: CLIENT_TIMEOUT_MS + (options.durationMs ?? 0) };\n};\n\nconst disconnected = (label: string, detail: string): DomainError =>\n new DomainError(\"workspace-client-disconnected\", `The workstation ${label} lost the connection: ${detail}`, 409);\n\n/** If the connection breaks in the middle of a call, the cause must name the workstation, not the server; a domain error stays one. */\nconst withClientCause = (cause: unknown, label: string): unknown => {\n if (!(cause instanceof RpcError)) return cause;\n if (cause.code === RPC_ERROR_CODES.connectionClosed) return disconnected(label, cause.message);\n if (cause.code === RPC_ERROR_CODES.timeout) {\n return new DomainError(\"workspace-client-timeout\", `The workstation ${label} did not respond: ${cause.message}`, 504);\n }\n if (cause.code === RPC_ERROR_CODES.application && cause.domainCode !== undefined && cause.status !== undefined) {\n return new DomainError(cause.domainCode, cause.message, cause.status);\n }\n return cause;\n};\n\n/** The workstation was not there or did not respond in time; a domain error does not count. */\nconst unreached = (cause: unknown): boolean =>\n cause instanceof DomainError && (cause.code === \"workspace-client-disconnected\" || cause.code === \"workspace-client-timeout\");\n\nconst messageOf = (cause: unknown): string => cause instanceof Error ? cause.message : String(cause);\n\n/** A workstation is identified only by owner and ID; two users with the same ID share nothing. */\nconst keyOf = (owner: string | null, id: string): string => JSON.stringify([owner, id]);\n\n/** Server and workstation need the same executor; the message says which of the two is too old. */\nconst assertExecutor = (label: string, executor: string): void => {\n if (executor === WORKSPACE_EXECUTOR_VERSION) return;\n const action = Number(executor) > Number(WORKSPACE_EXECUTOR_VERSION)\n ? \"Update the server to the workstation's version.\"\n : \"Update the RAgents extension in VS Code or the package @schlenkr/ragents on the workstation.\";\n throw new DomainError(\n \"workspace-executor-version\",\n `The workstation ${label} brings executor ${executor}, the server requires ${WORKSPACE_EXECUTOR_VERSION}. ${action}`,\n 409,\n );\n};\n\nconst described = (contributions: readonly ExecutorContributionRevision[]): string =>\n contributions.map(({ plugin, revision }) => `${plugin} (${revision.slice(0, 12)})`).join(\", \") || \"none\";\n\n/** A workstation runs what the server's plugins contribute; with other contributions the same tools would behave differently there than on the server. */\nconst assertContributions = (label: string, expected: readonly ExecutorContributionRevision[], given: readonly ExecutorContributionRevision[]): void => {\n const key = (entry: ExecutorContributionRevision): string => `${entry.plugin}\\0${entry.revision}`;\n const same = expected.length === given.length && expected.every((entry) => given.some((other) => key(other) === key(entry)));\n if (same) return;\n throw new DomainError(\n \"workspace-executor-contributions\",\n `The workstation ${label} brings the executor contributions ${described(given)}, the server requires ${described(expected)}. `\n + \"The workstation queries them with ragents.workspace.clients.contributions and then signs in again.\",\n 409,\n );\n};\n\n/** Over the network, the server accepts workstations only from signed-in users; without users there would be only one owner for all access. */\nexport const assertMayRegister = (access: AccessContext, local: boolean): void => {\n if (local || (access.enabled && access.user !== null)) return;\n throw new DomainError(\n \"workspace-client-login-required\",\n \"This server has no user sign-in; it therefore accepts a workstation only over a loopback connection \"\n + \"(such as http://127.0.0.1 on its own machine). Over the network, a workstation needs a profile with users.\",\n 403,\n );\n};\n\n/** Knows the signed-in workstations per owner, holds per client the connection through which the server calls it back, and the stops that have not reached it. */\nexport class WorkspaceClientRegistry {\n /** What the server's plugins contribute to the executor; every workstation must carry exactly these contributions. */\n readonly contributions: readonly ExecutorContributionRevision[];\n readonly #clients = new Map<string, ClientEntry>();\n /** Stops that have not reached the workstation yet, per workstation and run with the folder of the binding. */\n readonly #pendingStops = new Map<string, Map<string, string>>();\n readonly #stopRetries = new Map<string, NodeJS.Timeout>();\n\n constructor(contributions: readonly ExecutorContributionRevision[]) {\n this.contributions = contributions.map(({ plugin, revision }) => ({ plugin, revision }));\n }\n\n async register(\n id: string,\n description: WorkspaceClientDescription,\n executor: string,\n contributions: readonly ExecutorContributionRevision[],\n connection: MethodConnection,\n ): Promise<WorkspaceClientInfo> {\n if (connection.streamless) {\n throw new DomainError(\"stream-required\", \"The sign-in of a workstation needs an event stream.\", 409);\n }\n assertExecutor(description.label, executor);\n assertContributions(description.label, this.contributions, contributions);\n const owner = connection.userId;\n const key = keyOf(owner, id);\n const previous = this.#clients.get(key);\n previous?.release();\n const info: WorkspaceClientInfo = { ...description, id };\n const renewed = previous?.connection === connection;\n const entry: ClientEntry = {\n info,\n owner,\n connection,\n release: connection.onClose(() => this.#disconnected(key, connection)),\n calls: renewed ? previous.calls : new Set(),\n stops: renewed ? previous.stops : new Map(),\n };\n this.#clients.set(key, entry);\n if (previous && !renewed) this.#abandon(previous);\n this.#deliverPendingStops(key);\n return info;\n }\n\n /** Only the connection that holds the entry signs it out; a sign-out without an entry is not an error after a disconnect. */\n unregister(owner: string | null, id: string, connection: MethodConnection): void {\n const key = keyOf(owner, id);\n const entry = this.#clients.get(key);\n if (entry?.connection !== connection) return;\n this.#remove(key, entry);\n }\n\n list(owner: string | null): WorkspaceClientInfo[] {\n return [...this.#clients.values()].filter((entry) => entry.owner === owner).map((entry) => entry.info);\n }\n\n info(owner: string | null, id: string): WorkspaceClientInfo | undefined {\n return this.#clients.get(keyOf(owner, id))?.info;\n }\n\n /** The runs whose stop has not reached this workstation yet. */\n pendingStops(owner: string | null, id: string): readonly string[] {\n return this.#pendingRuns(keyOf(owner, id));\n }\n\n /** The executor of a bound run: the same interface as in the server, only through the connection of its owner's workstation. */\n executorFor(owner: string | null, id: string, label: string, cwd: string): WorkspaceExecutor {\n const key = keyOf(owner, id);\n const call = async (runId: string, operation: string, input: unknown, options: WorkspaceExecuteOptions): Promise<unknown> => {\n if (options.untilAborted && !options.signal) throw new Error(`The operation ${operation} runs until aborted and needs an abort signal for that`);\n if (this.#pendingStops.get(key)?.has(runId)) {\n // Cleanup alongside a pending stop is done by that stop; everything else waits until it is delivered.\n if (options.whenReachable) return null;\n if (this.#clients.has(key)) await this.#deliverStop(key, runId);\n }\n const entry = this.#clients.get(key);\n if (!entry) {\n if (options.whenReachable) return null;\n throw new DomainError(\"workspace-client-disconnected\", `The workstation ${label} is not connected.`, 409);\n }\n try {\n return await this.#send(entry, runId, operation, input, cwd, options);\n } catch (cause) {\n if (options.whenReachable && unreached(cause)) return null;\n throw cause;\n }\n };\n return {\n version: WORKSPACE_EXECUTOR_VERSION,\n execute: (runId, operation, input, options = {}) => call(runId, operation, input, options),\n stopRun: async (runId) => {\n this.#pendingStopsOf(key).set(runId, cwd);\n await this.#deliverStop(key, runId);\n },\n shutdown: async () => undefined,\n };\n }\n\n shutdown(): void {\n for (const entry of this.#clients.values()) {\n entry.release();\n this.#abandon(entry);\n }\n this.#clients.clear();\n for (const timer of this.#stopRetries.values()) clearTimeout(timer);\n this.#stopRetries.clear();\n this.#pendingStops.clear();\n }\n\n /** A disconnected workstation leaves the registry; a later sign-in over a new connection stays. */\n #disconnected(key: string, connection: MethodConnection): void {\n const entry = this.#clients.get(key);\n if (entry?.connection !== connection) return;\n this.#remove(key, entry);\n }\n\n #remove(key: string, entry: ClientEntry): void {\n entry.release();\n this.#clients.delete(key);\n this.#abandon(entry);\n }\n\n /** A connection that nobody holds anymore gets no more answers delivered; its open calls fail immediately. */\n #abandon(entry: ClientEntry): void {\n for (const controller of entry.calls) controller.abort();\n entry.calls.clear();\n }\n\n async #send(\n entry: ClientEntry,\n runId: string,\n operation: string,\n input: unknown,\n cwd: string,\n options: WorkspaceExecuteOptions,\n ): Promise<unknown> {\n const label = entry.info.label;\n const abandoned = new AbortController();\n entry.calls.add(abandoned);\n const signal = options.signal ? AbortSignal.any([options.signal, abandoned.signal]) : abandoned.signal;\n try {\n const { value } = await Promise.race([\n entry.connection.call(\n workspaceClientContracts.execute,\n {\n runId,\n operation,\n ...(options.toolCallId ? { toolCallId: options.toolCallId } : {}),\n cwd,\n env: sandboxRunEnvironment(runId),\n input,\n },\n {\n signal,\n ...timeoutFor(options),\n ...(options.onProgress ? { onProgress: options.onProgress } : {}),\n },\n ),\n new Promise<never>((_settle, fail) => abandoned.signal.addEventListener(\"abort\", () =>\n fail(disconnected(label, \"a new connection replaced the sign-in\")), { once: true })),\n ]);\n return value;\n } catch (cause) {\n throw withClientCause(cause, label);\n } finally {\n entry.calls.delete(abandoned);\n }\n }\n\n #pendingStopsOf(key: string): Map<string, string> {\n const known = this.#pendingStops.get(key);\n if (known) return known;\n const created = new Map<string, string>();\n this.#pendingStops.set(key, created);\n return created;\n }\n\n /** Delivers a pending stop; if it does not reach the workstation, it stays pending and the next sign-in catches up on it. */\n #deliverStop(key: string, runId: string): Promise<void> {\n const entry = this.#clients.get(key);\n const cwd = this.#pendingStops.get(key)?.get(runId);\n if (cwd === undefined) return Promise.resolve();\n if (!entry) {\n console.warn(`The stop of run ${runId} reaches its workstation only at its next sign-in.`);\n return Promise.resolve();\n }\n const running = entry.stops.get(runId);\n if (running) return running;\n const delivery = this.#send(entry, runId, WORKSPACE_CLIENT_STOP_OPERATION, null, cwd, { whenReachable: true })\n .then(() => this.#stopDelivered(key, runId, cwd), (cause: unknown) => {\n if (!unreached(cause)) {\n this.#stopDelivered(key, runId, cwd);\n throw cause;\n }\n console.warn(`The stop of run ${runId} did not reach the workstation ${entry.info.label} and stays pending: ${messageOf(cause)}`);\n this.#retryStops(key);\n })\n .finally(() => entry.stops.delete(runId));\n entry.stops.set(runId, delivery);\n return delivery;\n }\n\n #stopDelivered(key: string, runId: string, cwd: string): void {\n const pending = this.#pendingStops.get(key);\n if (pending?.get(runId) === cwd) pending.delete(runId);\n if (pending?.size === 0) this.#pendingStops.delete(key);\n }\n\n #deliverPendingStops(key: string): void {\n for (const runId of this.#pendingRuns(key)) {\n void this.#deliverStop(key, runId).catch((cause: unknown) =>\n console.warn(`The delayed stop of run ${runId} failed: ${messageOf(cause)}`));\n }\n }\n\n #pendingRuns(key: string): readonly string[] {\n return [...this.#pendingStops.get(key)?.keys() ?? []];\n }\n\n /** A workstation that stays signed in but does not respond gets its pending stops again later. */\n #retryStops(key: string): void {\n if (this.#stopRetries.has(key)) return;\n const timer = setTimeout(() => {\n this.#stopRetries.delete(key);\n if (this.#clients.has(key)) this.#deliverPendingStops(key);\n }, STOP_RETRY_MS);\n timer.unref();\n this.#stopRetries.set(key, timer);\n }\n}\n\nexport const clientMethods = (registry: WorkspaceClientRegistry): MethodContribution[] => [\n implement(workspaceContracts.clients.list, (_input, { access }) => registry.list(ownerOf(access))),\n implement(workspaceContracts.clients.contributions, ({ label, executor }, { access, local }) => {\n assertMayRegister(access, local);\n assertExecutor(label, executor);\n return registry.contributions.map((entry) => ({ ...entry }));\n }),\n implement(workspaceContracts.clients.register, (input, { access, connection, local }) => {\n assertMayRegister(access, local);\n // Version first: a workstation with a different one does not know the shape of this version; with this one, the shape applies fully.\n assertExecutor(input.label, input.executor);\n if (!Value.Check(clientRegistrationSchema, input)) {\n throw new RpcError(RPC_ERROR_CODES.invalidParams,\n `Invalid input for ${workspaceContracts.clients.register.id}: ${schemaComplaints(clientRegistrationSchema, input, \"params\")}`);\n }\n const { id, executor, contributions, ...description } = input;\n return registry.register(id, description, executor, contributions, connection);\n }),\n implement(workspaceContracts.clients.unregister, ({ id }, { access, connection }) => {\n registry.unregister(ownerOf(access), id, connection);\n return null;\n }),\n];\n", "import { declaredEnvironment } from \"@ragents/host/plugin-support/plugin-config.js\";\nimport { PROCESS_SANDBOX_DEFAULT_NETWORK } from \"@ragents/host/plugin-support/process-sandbox.js\";\n\nexport const workspaceConfigDescriptors = [\n { key: \"PROCESS_SANDBOX\", source: \"environment\" },\n { key: \"PROCESS_SANDBOX_NETWORK\", source: \"environment\" },\n { key: \"RAGENTS_BASH\", source: \"environment\" },\n { key: \"RAGENTS_RG\", source: \"environment\" },\n { key: \"RAGENTS_BASH_TIMEOUT_SECONDS\", source: \"environment\" },\n] as const;\n\nconst env = declaredEnvironment(workspaceConfigDescriptors);\n\nexport interface ProcessSandboxSetting {\n readonly enabled: boolean;\n readonly network: readonly string[];\n}\n\n/** This is how the operator turns off the process sandbox in the profile file. */\nexport const PROCESS_SANDBOX_OFF = 'PROCESS_SANDBOX: \"off\" in the ragents.workspace section';\n\n/** Without a value the sandbox is on; it can only be turned off explicitly with \"off\". */\nexport const processSandboxSetting = (): ProcessSandboxSetting => {\n const mode = env.optional(\"PROCESS_SANDBOX\") ?? \"on\";\n if (mode !== \"on\" && mode !== \"off\") {\n throw new Error(`PROCESS_SANDBOX in the ragents.workspace section is \"on\" or \"off\", not \"${mode}\"`);\n }\n const network = env.optional(\"PROCESS_SANDBOX_NETWORK\") === undefined\n ? PROCESS_SANDBOX_DEFAULT_NETWORK\n : env.list(\"PROCESS_SANDBOX_NETWORK\");\n return { enabled: mode === \"on\", network };\n};\n\n/** The bash with which the executor of this server starts the bash tool; on Windows the VS Code extension sets it for its local host. */\nexport const bashSetting = (): string | undefined => env.optional(\"RAGENTS_BASH\") || undefined;\n\n/** The rg that the executor of this server puts at the front of the bash PATH; the VS Code extension sets it for its local host. */\nexport const rgSetting = (): string | undefined => env.optional(\"RAGENTS_RG\") || undefined;\n\n/** The bash timeout in seconds for calls without their own; the tool rejects more than the largest a call may name at startup. */\nexport const bashTimeoutSetting = (): number | undefined =>\n env.optional(\"RAGENTS_BASH_TIMEOUT_SECONDS\") ? env.positiveNumber(\"RAGENTS_BASH_TIMEOUT_SECONDS\", \"\") : undefined;\n", "import { mkdir, realpath } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { JsonValue, RunState, WorkspaceToolNaming } from \"@ragents/engine\";\nimport { DomainError } from \"@ragents/engine\";\nimport {\n RUN_FOLDER_OPERATIONS,\n type RunFolderCreated,\n type SandboxHomeEnvironment,\n type WorkspaceExecuteOptions,\n type WorkspaceExecutor,\n type WorkspaceExecutorParts,\n} from \"@ragents/workspace-executor\";\nimport type {\n SessionWorkspace,\n WorkspaceFolderStep,\n WorkspacePlacement,\n WorkspaceResolver,\n WorkspaceRuntime,\n WorkspaceRuntimeDescription,\n WorkspaceTransfer,\n WorkstationFolderContext,\n} from \"@ragents/host/ragents/workspace-runtime.js\";\nimport { storedStartOption } from \"@ragents/host/ragents/start-option-state.js\";\nimport { sandboxToolNaming } from \"./workspace-tool-naming.js\";\nimport { WorkspaceSandboxHost, type ServerRootDescription } from \"@ragents/host/plugin-support/workspace-sandbox-host.js\";\nimport type { RunProcessSandboxes } from \"@ragents/host/plugin-support/process-sandbox.js\";\nimport { FRESH_WORKSPACE_LABEL, isFreshFolder, type ExistingWorkspaceFolder, type WorkspaceBinding } from \"../contract.js\";\nimport {\n bindingOf,\n boundServerDirectory,\n isWorkstationBinding,\n serverDirectoryFolder,\n workspaceOwnerOf,\n type WorkstationBinding,\n} from \"./binding.js\";\nimport type { WorkspaceClientRegistry } from \"./clients.js\";\n\nexport interface RunWorkspaceRuntimeOptions {\n globalDirectory: string;\n sessionDirectory: (runId: string, ...segments: string[]) => string;\n /** The storage boundary of a run; within it, private work files belong to its account. */\n storageRootFor: (runId: string) => string;\n sessionsDirectoryPattern: string;\n sessionWorkspaceFor: (runId: string) => Promise<SessionWorkspace>;\n skillPaths: () => Promise<readonly string[]>;\n resolver: () => WorkspaceResolver | undefined;\n runState: (runId: string) => RunState | null;\n storeBinding: (runId: string, binding: WorkspaceBinding) => void;\n clients: WorkspaceClientRegistry;\n /** What the profile's plugins contribute to the server's executor; the workstations load the same contributions themselves. */\n contributions: readonly WorkspaceExecutorParts[];\n /** The server's process sandbox; without it, the server's processes run without one. */\n processSandbox?: RunProcessSandboxes;\n /** The server's bash from RAGENTS_BASH; required on Windows for the bash tool. */\n bash?: string;\n /** The server's rg from RAGENTS_RG; without a value, one in the PATH applies. */\n rg?: string;\n /** The bash timeout from RAGENTS_BASH_TIMEOUT_SECONDS; without a value, that of the tool. */\n bashTimeoutSeconds?: number;\n}\n\nconst runNotStarted = (): DomainError => new DomainError(\n \"run-not-started\",\n \"The run has not started yet; the working directory is created with the first message.\",\n 409,\n);\n\nconst lookAround = \"Look around in it before you say anything about the project.\";\n\nconst serverProjectDescription = (cwd: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${cwd}\\` on the server: the project folder the user picked.`,\n `It is a real project. Work inside it, keep its structure, and never delete or reorganize files unless you are asked to. ${lookAround}`,\n].join(\"\\n\");\n\nconst clientProjectDescription = (projectPath: string, label: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is the project folder \\`${projectPath}\\` on the workstation \"${label}\", not on the server.`,\n \"Every workspace tool runs there, and a relative path refers to that folder.\",\n `It is a real project. Keep its structure, and never delete or reorganize files unless you are asked to. ${lookAround}`,\n].join(\"\\n\");\n\nconst freshWorkstationDescription = (folderPath: string, label: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${folderPath}\\` on the workstation \"${label}\", not on the server: a folder of this run alone.`,\n \"Every workspace tool runs there, and a relative path refers to that folder.\",\n \"It starts empty unless the profile prepared content in it. Look around in it before you say anything about what is already there.\",\n].join(\"\\n\");\n\nconst freshDescription = (cwd: string): string => [\n \"# Working directory\",\n \"\",\n `Your working directory is \\`${cwd}\\`, a private folder of this conversation on the server.`,\n \"No other conversation sees it, and it starts empty unless the profile prepared content in it.\",\n \"Look around in it before you say anything about what is already there.\",\n].join(\"\\n\");\n\nconst listed = (entries: readonly string[]): string =>\n entries.length === 1 ? entries[0]! : `${entries.slice(0, -1).join(\", \")} and ${entries.at(-1)!}`;\n\nconst rootList = (roots: readonly ServerRootDescription[]): string =>\n listed(roots.map((root) => `\\`${root.alias}\\` (${root.writable ? \"read and write\" : \"read only\"})`));\n\nconst variableList = (roots: readonly ServerRootDescription[]): string => listed(roots\n .flatMap((root) => root.environmentVariable === undefined ? [] : [`\\`$${root.environmentVariable}\\` for \\`${root.alias}\\``]));\n\nconst hasVariables = (roots: readonly ServerRootDescription[]): boolean => roots.some((root) => root.environmentVariable !== undefined);\n\n/** On the server, workspace and roots are on one machine; every bash sees both. */\nconst serverRootsDescription = (roots: readonly ServerRootDescription[]): string => [\n \"## Roots besides the working directory\",\n \"\",\n `This run also reaches ${rootList(roots)}. File tools and language servers take a path that starts with the alias, `\n + `such as \\`${roots[0]!.alias}/<path>\\`; \\`bash\\` runs in such a root with that path as \\`cwd\\`.`\n + (hasVariables(roots) ? ` \\`bash\\` also has ${variableList(roots)}.` : \"\"),\n].join(\"\\n\");\n\n/** The roots are on the server, the workspace on the workstation; a bash always sees only one of the two machines. */\nconst workstationRootsDescription = (roots: readonly ServerRootDescription[]): string => [\n \"## Roots on the server\",\n \"\",\n `This run also reaches roots on the server: ${rootList(roots)}. File tools and language servers reach them from the `\n + `workstation as well: pass a path that starts with the alias, such as \\`${roots[0]!.alias}/<path>\\`. \\`bash\\` runs on `\n + \"the workstation; with a `cwd` that starts with an alias it runs on the server instead and sees only the server\"\n + (hasVariables(roots) ? `, and only that bash has ${variableList(roots)}` : \"\")\n + \". One call reaches one machine: never combine a path with an alias and a path in the working directory in one call.\",\n].join(\"\\n\");\n\nexport class RunWorkspaceRuntime implements WorkspaceRuntime {\n readonly sandbox: WorkspaceSandboxHost;\n readonly toolNaming: WorkspaceToolNaming = sandboxToolNaming;\n readonly transfer: WorkspaceTransfer;\n readonly #options: RunWorkspaceRuntimeOptions;\n readonly #nugetCacheDirectory: string;\n /** The new folders on workstations that have already been created or are in progress during this server run. */\n readonly #preparations = new Map<string, Promise<void>>();\n\n constructor(options: RunWorkspaceRuntimeOptions) {\n this.#options = options;\n this.transfer = {\n boundDirectory: (runId) => boundServerDirectory(options.runState(runId)),\n assertDirectory: (directory) => void serverDirectoryFolder(directory),\n rebind: (runId, directory) => options.storeBinding(runId, { machine: \"server\", folder: serverDirectoryFolder(directory) }),\n };\n this.#nugetCacheDirectory = path.join(options.globalDirectory, \"nuget-cache\");\n this.sandbox = new WorkspaceSandboxHost({\n contributorName: \"ragents.workspace.sandbox\",\n contributions: options.contributions,\n workspaceFor: options.sessionWorkspaceFor,\n identFor: () => Promise.resolve(undefined),\n skillPaths: options.skillPaths,\n storageRootFor: options.storageRootFor,\n homeFor: (runId) => this.#homeFor(runId),\n executorFor: (runId) => Promise.resolve(this.#executorFor(runId)),\n serverDirectoryFor: (runId) => this.#serverDirectoryFor(runId),\n ...(options.processSandbox ? { processSandbox: options.processSandbox } : {}),\n ...(options.bash === undefined ? {} : { bash: options.bash }),\n ...(options.rg === undefined ? {} : { rg: options.rg }),\n ...(options.bashTimeoutSeconds === undefined ? {} : { bashTimeoutSeconds: options.bashTimeoutSeconds }),\n });\n }\n\n /** Work of a run that runs on the server while its workspace is on a workstation. */\n async #serverDirectoryFor(runId: string): Promise<string> {\n const directory = this.#options.sessionDirectory(runId, \"server\");\n await mkdir(directory, { recursive: true });\n return realpath(directory);\n }\n\n async #homeFor(runId: string): Promise<SandboxHomeEnvironment> {\n const home = this.#options.sessionDirectory(runId, \"home\");\n await mkdir(home, { recursive: true });\n await mkdir(this.#nugetCacheDirectory, { recursive: true });\n return { home, nugetPackages: this.#nugetCacheDirectory };\n }\n\n /** On a workstation, its executor runs on behalf of the run owner, otherwise the server's executor. */\n #executorFor(runId: string): WorkspaceExecutor | undefined {\n const state = this.#options.runState(runId);\n const binding = bindingOf(state);\n if (!isWorkstationBinding(binding)) return undefined;\n const { machine, folder } = binding;\n const executor = this.#options.clients.executorFor(workspaceOwnerOf(state), machine.client, machine.label, folder.path);\n return \"fresh\" in folder ? this.#preparing(state, binding, executor) : executor;\n }\n\n /** Before the first task of a run, the workstation creates its new folder; cleanup never creates one. */\n #preparing(state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): WorkspaceExecutor {\n return {\n ...executor,\n execute: async (runId, operation, input, options = {}) => {\n if (!options.whenReachable) await this.#prepared(runId, state, binding, executor);\n return executor.execute(runId, operation, input, options);\n },\n };\n }\n\n #prepared(runId: string, state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): Promise<void> {\n const known = this.#preparations.get(runId);\n if (known) return known;\n const preparation = this.#prepare(runId, state, binding, executor).catch((error: unknown) => {\n this.#preparations.delete(runId);\n throw error;\n });\n this.#preparations.set(runId, preparation);\n return preparation;\n }\n\n /** Only a freshly created folder gets the contribution's steps; if one fails, the folder disappears again and the next task starts over. */\n async #prepare(runId: string, state: RunState | null, binding: WorkstationBinding, executor: WorkspaceExecutor): Promise<void> {\n const { created } = await executor.execute(runId, RUN_FOLDER_OPERATIONS.create, null) as RunFolderCreated;\n const steps = created ? this.#contribution()?.workstation?.prepare(this.#workstationContext(runId, state, binding)) ?? [] : [];\n try {\n await this.#runSteps(runId, executor, steps);\n } catch (error) {\n await executor.execute(runId, RUN_FOLDER_OPERATIONS.remove, null, { whenReachable: true });\n throw error;\n }\n }\n\n async #runSteps(runId: string, executor: WorkspaceExecutor, steps: readonly WorkspaceFolderStep[], options: WorkspaceExecuteOptions = {}): Promise<void> {\n for (const step of steps) await executor.execute(runId, step.operation, step.input, options);\n }\n\n #workstationContext(runId: string, state: RunState | null, binding: WorkstationBinding): WorkstationFolderContext {\n const contribution = this.#contribution();\n return {\n runId,\n path: binding.folder.path,\n label: binding.machine.label,\n choice: contribution && state ? this.#choiceFor(state, contribution) : null,\n };\n }\n\n async resolve(runId: string, emitSystem: (text: string) => void): Promise<SessionWorkspace> {\n const state = this.#options.runState(runId);\n if (!state) throw runNotStarted();\n const binding = bindingOf(state);\n const { folder } = binding;\n const onWorkstation = isWorkstationBinding(binding);\n const workspace = onWorkstation ? this.#workstation(runId, state, binding, emitSystem)\n : isFreshFolder(folder) ? await this.#fresh(runId, state, emitSystem) : this.#bound(folder, emitSystem);\n return this.#withRoots(workspace, onWorkstation);\n }\n\n /** What the prompt says about roots depends on the run's machine: only a bash on the server knows their variables. */\n async #withRoots(workspace: SessionWorkspace, onWorkstation: boolean): Promise<SessionWorkspace> {\n const roots = await this.sandbox.serverRoots();\n if (roots.length === 0) return workspace;\n const described = onWorkstation ? workstationRootsDescription(roots) : serverRootsDescription(roots);\n return { ...workspace, description: [workspace.description, described].filter(Boolean).join(\"\\n\\n\") };\n }\n\n placementOf(runId: string): WorkspacePlacement {\n const { machine, folder } = bindingOf(this.#options.runState(runId));\n const placement: WorkspacePlacement = {\n machine: machine === \"server\" ? \"server\" : \"client\",\n folder: isFreshFolder(folder) ? \"fresh\" : \"existing\",\n };\n const contribution = this.#contribution();\n const contributed = placement.folder === \"fresh\" && (placement.machine === \"server\" || contribution?.workstation !== undefined);\n const kind = contributed ? contribution?.kind?.id : undefined;\n return kind === undefined ? placement : { ...placement, kind };\n }\n\n async #fresh(runId: string, state: RunState, emitSystem: (text: string) => void): Promise<SessionWorkspace> {\n const resolver = this.#options.resolver();\n const directory = resolver?.kind\n ? this.#options.sessionDirectory(runId, \"workspace\")\n : await this.#sessionWorkspace(runId);\n if (!resolver) return this.#directory(directory, freshDescription(directory));\n const { cwd, description, currentRoot, runOperation, ...rest } = await resolver.resolve({\n runId,\n directory,\n choice: this.#choiceFor(state, resolver),\n emitSystem,\n });\n const resolved = path.resolve(cwd);\n return {\n ...this.#directory(resolved, description ?? freshDescription(resolved)),\n ...rest,\n ...(currentRoot ? { currentRoot } : {}),\n ...(runOperation ? { runOperation } : {}),\n };\n }\n\n #bound(folder: ExistingWorkspaceFolder, emitSystem: (text: string) => void): SessionWorkspace {\n const cwd = path.resolve(folder.path);\n const existing = async (): Promise<string> => {\n try {\n return await realpath(cwd);\n } catch {\n throw new DomainError(\"workspace-path-missing\", `The bound folder ${cwd} no longer exists on the server.`, 409);\n }\n };\n emitSystem(`Workspace: ${cwd} (project folder on the server)`);\n return {\n cwd,\n description: serverProjectDescription(cwd),\n currentRoot: existing,\n runOperation: (operation) => operation(),\n };\n }\n\n /** The workspace is on the workstation; the server knows only its path, and every local access to it fails loudly. */\n #workstation(runId: string, state: RunState, binding: WorkstationBinding, emitSystem: (text: string) => void): SessionWorkspace {\n const { machine: { label }, folder } = binding;\n const fresh = \"fresh\" in folder;\n const workstation = this.#contribution()?.workstation;\n emitSystem(fresh\n ? `Workspace: ${folder.path} (${workstation?.label ?? FRESH_WORKSPACE_LABEL} on the workstation ${label})`\n : `Workspace: ${folder.path} (project folder on the workstation ${label})`);\n const remote = (): Promise<string> => Promise.reject(new Error(\n `The workspace ${folder.path} is on the workstation ${label}, not on the server; `\n + \"it is reachable only through the run's executor (SandboxServices.execute).\",\n ));\n const description = !fresh\n ? clientProjectDescription(folder.path, label)\n : workstation?.description?.(this.#workstationContext(runId, state, binding)) ?? freshWorkstationDescription(folder.path, label);\n return {\n cwd: folder.path,\n description,\n currentRoot: remote,\n runOperation: (operation) => operation(),\n };\n }\n\n async #sessionWorkspace(runId: string): Promise<string> {\n const directory = this.#options.sessionDirectory(runId, \"workspace\");\n await mkdir(directory, { recursive: true });\n return directory;\n }\n\n #directory(cwd: string, description: string, extraEnv?: NodeJS.ProcessEnv): SessionWorkspace {\n return {\n cwd,\n description,\n ...(extraEnv ? { extraEnv } : {}),\n currentRoot: () => realpath(cwd),\n runOperation: (operation) => operation(),\n };\n }\n\n #choiceFor(state: RunState, resolver: WorkspaceResolver): JsonValue | null {\n if (resolver.optionId === undefined) return null;\n const choice = storedStartOption(state, resolver.optionId);\n if (choice === undefined) {\n throw new Error(`The start option ${resolver.optionId} of the workspace resolver is not stored in the run`);\n }\n return choice;\n }\n\n describe(): WorkspaceRuntimeDescription {\n return {\n mode: \"per-run\",\n directoryPattern: this.#contribution()?.kind?.directoryPattern\n ?? path.join(this.#options.sessionsDirectoryPattern, \"workspace\"),\n };\n }\n\n #contribution(): WorkspaceResolver | undefined {\n return this.#options.resolver();\n }\n\n /** On the server, a new folder including stop and deletion belongs to the contribution; on a workstation, the host cleans it up. */\n #serverContributionFor(runId: string): WorkspaceResolver | undefined {\n const { machine, folder } = bindingOf(this.#options.runState(runId));\n return machine === \"server\" && isFreshFolder(folder) ? this.#contribution() : undefined;\n }\n\n /** If the workstation is unreachable, the folder stays there with a notice; the run is deleted anyway. */\n async #removeWorkstationFolder(runId: string): Promise<void> {\n this.#preparations.delete(runId);\n const state = this.#options.runState(runId);\n const binding = bindingOf(state);\n if (!isWorkstationBinding(binding) || !(\"fresh\" in binding.folder)) return;\n const { machine, folder } = binding;\n const executor = this.#options.clients.executorFor(workspaceOwnerOf(state), machine.client, machine.label, folder.path);\n const steps = this.#contribution()?.workstation?.release?.(this.#workstationContext(runId, state, binding)) ?? [];\n await this.#runSteps(runId, executor, steps, { whenReachable: true });\n if (await executor.execute(runId, RUN_FOLDER_OPERATIONS.remove, null, { whenReachable: true }) !== null) return;\n console.warn(`The folder ${folder.path} of run ${runId} stays on the workstation ${machine.label} because it was unreachable.`);\n }\n\n async deleteSession(runId: string): Promise<void> {\n const contribution = this.#serverContributionFor(runId);\n await this.stopSession(runId);\n await this.#removeWorkstationFolder(runId);\n await contribution?.deleteSession?.(runId);\n }\n\n stopSession(runId: string): Promise<void> {\n const contribution = this.#serverContributionFor(runId);\n const sandbox = (): Promise<void> => this.sandbox.shutdown(runId);\n return contribution?.stopSession ? contribution.stopSession(runId, sandbox) : sandbox();\n }\n\n async shutdown(): Promise<void> {\n await this.sandbox.shutdownAll();\n this.#options.clients.shutdown();\n }\n}\n"],
5
+ "mappings": ";;;;AAAA,OAAOA,WAAU;AACjB,SAAS,eAAAC,oBAAsE;AAC/E,SAAS,0BAA0B;AACnC,SAAS,wBAAwB,6BAAqD;AACtF,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AAEjC,SAAS,gBAAAC,eAAc,wBAAwB;;;AChB/C,SAAS,yBAA0C;AACnD,SAAS,oBAAoB;AAEtB,IAAM,uBAAuB,CAAC,UAA2B,UAC9D;AAAA;AAAA,EAAwB,kBAAkB,UAAU,KAAK,CAAC;AAGrD,IAAM,sBAAsB,CACjC,IACA,OACA,aACA,eACuB,aAAa;AAAA,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rD,eAAe,CAAC,EAAE,MAAM,MAAM,QAAQ,cAAc,KAAK;AAAA,MACzD,UAAU,YAAY;AACpB,cAAM,QAAQ,SAAS;AACvB,cAAM,gBAAgB,KAAK;AAAA,MAC7B;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,SAAuB;AAAA,EAClC,QAAQ,CAAC,SAAS,uBAAuB,MAAM,KAAK,OAAO,OAAO,CAAC;AACrE;",
6
6
  "names": ["path", "DomainError", "boundToTools", "Type", "Type", "listing", "DomainError", "implement", "DomainError", "plugin", "implement", "path", "DomainError", "storedStartOption", "DomainError", "path", "described", "storedStartOption", "DomainError", "path", "contribution", "boundToTools"]
7
7
  }