@hachej/boring-agent 0.1.85 → 0.1.86

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.
@@ -1811,6 +1811,14 @@ async function prepareVercelDeploymentSnapshot(opts) {
1811
1811
  });
1812
1812
  }
1813
1813
 
1814
+ // src/server/config/workspaceRoot.ts
1815
+ var WORKSPACE_ROOT_ENV = "BORING_AGENT_WORKSPACE_ROOT";
1816
+ function resolveWorkspaceRoot(defaultRoot = process.cwd()) {
1817
+ const configured = process.env[WORKSPACE_ROOT_ENV]?.trim();
1818
+ if (!configured) return defaultRoot;
1819
+ return configured;
1820
+ }
1821
+
1814
1822
  // src/server/runtime/createServerFileSearch.ts
1815
1823
  var DEFAULT_LIMIT = 500;
1816
1824
  var MAX_LIMIT = 5e3;
@@ -12827,7 +12835,7 @@ function requirePath(value, reply) {
12827
12835
  return value;
12828
12836
  }
12829
12837
  function gitRoutes(app, opts, done) {
12830
- async function resolveWorkspaceRoot(request) {
12838
+ async function resolveWorkspaceRoot2(request) {
12831
12839
  const workspace = opts.getWorkspace ? await opts.getWorkspace(request) : opts.workspace;
12832
12840
  return workspace === void 0 ? void 0 : getNodeWorkspaceHostRoot(workspace);
12833
12841
  }
@@ -12835,7 +12843,7 @@ function gitRoutes(app, opts, done) {
12835
12843
  const query = request.query;
12836
12844
  const path4 = requirePath(query.path, reply);
12837
12845
  if (path4 === null) return;
12838
- const workspaceRoot = await resolveWorkspaceRoot(request);
12846
+ const workspaceRoot = await resolveWorkspaceRoot2(request);
12839
12847
  if (!workspaceRoot) {
12840
12848
  return {
12841
12849
  enabled: false,
@@ -13967,7 +13975,8 @@ var registerAgentRoutes = async (app, opts) => {
13967
13975
  }
13968
13976
  });
13969
13977
  const modelsWorkspaceScoped = Boolean(opts.filterModels);
13970
- const requestScopedRuntime = typeof opts.getWorkspaceId === "function" || typeof opts.getWorkspaceRoot === "function" || typeof opts.getTemplatePath === "function" || typeof opts.getPi === "function" || typeof opts.getExtraTools === "function" || typeof opts.getSessionNamespace === "function" || typeof opts.getSystemPromptDynamic === "function" || typeof opts.getTrustedWorkspaceRoot === "function";
13978
+ const requestScopedRuntime = typeof opts.getWorkspaceId === "function" || typeof opts.getWorkspaceRoot === "function" || typeof opts.getTemplatePath === "function" || typeof opts.getPi === "function" || typeof opts.getExtraTools === "function" || typeof opts.getSessionNamespace === "function" || typeof opts.getSystemPromptDynamic === "function" || typeof opts.getRuntimeScopeContribution === "function" || typeof opts.getTrustedWorkspaceRoot === "function";
13979
+ const runtimeScopeByRequest = /* @__PURE__ */ new WeakMap();
13971
13980
  const sessionChangesTracker = new InMemorySessionChangesTracker();
13972
13981
  const externalPluginsEnabled = opts.externalPlugins !== false;
13973
13982
  async function resolveScopePi(workspaceId, root, request) {
@@ -13990,11 +13999,13 @@ var registerAgentRoutes = async (app, opts) => {
13990
13999
  const pi = await resolveScopePi(workspaceId, root, request);
13991
14000
  const sessionNamespace = normalizeSessionNamespace(opts.getSessionNamespace ? await opts.getSessionNamespace({ workspaceId, workspaceRoot: root, request, userId: trustedCtx?.userId }) : opts.sessionNamespace);
13992
14001
  const extraToolsAuthSubject = opts.getExtraTools ? trustedCtx?.userId ?? getRequestAuthSubject2(request) : void 0;
14002
+ const contribution = await opts.getRuntimeScopeContribution?.({ workspaceId, workspaceRoot: root, request });
13993
14003
  return {
13994
14004
  root,
13995
14005
  templatePath: scopedTemplatePath,
13996
14006
  pi,
13997
14007
  sessionNamespace,
14008
+ loadSystemPromptAppend: contribution?.loadSystemPromptAppend,
13998
14009
  key: JSON.stringify([
13999
14010
  resolvedMode,
14000
14011
  workspaceId,
@@ -14002,10 +14013,26 @@ var registerAgentRoutes = async (app, opts) => {
14002
14013
  scopedTemplatePath ?? null,
14003
14014
  pi,
14004
14015
  sessionNamespace ?? null,
14005
- extraToolsAuthSubject ?? null
14016
+ extraToolsAuthSubject ?? null,
14017
+ contribution?.identity ?? null
14006
14018
  ])
14007
14019
  };
14008
14020
  }
14021
+ function getRuntimeScope(workspaceId, request, trustedCtx) {
14022
+ if (!request) return resolveRuntimeScope(workspaceId, void 0, trustedCtx);
14023
+ let scopes = runtimeScopeByRequest.get(request);
14024
+ if (!scopes) {
14025
+ scopes = /* @__PURE__ */ new Map();
14026
+ runtimeScopeByRequest.set(request, scopes);
14027
+ }
14028
+ const identity = JSON.stringify([workspaceId, trustedCtx?.userId ?? null]);
14029
+ let promise = scopes.get(identity);
14030
+ if (!promise) {
14031
+ promise = resolveRuntimeScope(workspaceId, request, trustedCtx);
14032
+ scopes.set(identity, promise);
14033
+ }
14034
+ return promise;
14035
+ }
14009
14036
  async function resolveSkillScope(workspaceId, request) {
14010
14037
  const root = request && opts.getWorkspaceRoot ? await opts.getWorkspaceRoot(workspaceId, request) : workspaceRoot;
14011
14038
  const pi = await resolveScopePi(workspaceId, root, request);
@@ -14052,6 +14079,7 @@ var registerAgentRoutes = async (app, opts) => {
14052
14079
  }
14053
14080
  async function createRuntimeBinding(workspaceId, scope, request, trustedCtx) {
14054
14081
  const root = scope.root;
14082
+ const scopedSystemPromptAppend = await scope.loadSystemPromptAppend?.();
14055
14083
  const modeCtx = {
14056
14084
  workspaceRoot: root,
14057
14085
  sessionId: workspaceId,
@@ -14265,7 +14293,7 @@ var registerAgentRoutes = async (app, opts) => {
14265
14293
  checkReadiness
14266
14294
  }),
14267
14295
  harnessFactory,
14268
- systemPromptAppend: opts.systemPromptAppend,
14296
+ systemPromptAppend: [opts.systemPromptAppend, scopedSystemPromptAppend].filter(Boolean).join("\n\n") || void 0,
14269
14297
  systemPromptDynamic,
14270
14298
  telemetry: opts.telemetry,
14271
14299
  metering: opts.metering,
@@ -14324,7 +14352,7 @@ var registerAgentRoutes = async (app, opts) => {
14324
14352
  }
14325
14353
  async function resolveRuntimeBinding(workspaceId, request, options = {}) {
14326
14354
  bindingLifecycle.assertAdmission(workspaceId, request);
14327
- const scope = await resolveRuntimeScope(workspaceId, request, options.trustedCtx);
14355
+ const scope = await getRuntimeScope(workspaceId, request, options.trustedCtx);
14328
14356
  bindingLifecycle.assertAdmission(workspaceId, request);
14329
14357
  const existing = bindingLifecycle.getEntry(scope.key);
14330
14358
  if (existing) {
@@ -14746,6 +14774,8 @@ export {
14746
14774
  getBoringAgentPathEntries,
14747
14775
  getBoringAgentRuntimeEnv,
14748
14776
  createDirectSandbox,
14777
+ validatePath,
14778
+ assertRealPathWithinWorkspace,
14749
14779
  createNodeWorkspace,
14750
14780
  createBwrapSandbox,
14751
14781
  FileHandleStore,
@@ -14758,6 +14788,7 @@ export {
14758
14788
  prepareDeploymentSnapshot,
14759
14789
  createVercelDeploymentSnapshotProvider,
14760
14790
  prepareVercelDeploymentSnapshot,
14791
+ resolveWorkspaceRoot,
14761
14792
  REMOTE_WORKER_RUNTIME_CWD,
14762
14793
  REMOTE_WORKER_PROVIDER,
14763
14794
  WORKER_INTERNAL_TOKEN_HEADER,
@@ -191,6 +191,17 @@ interface CreateNodeWorkspaceOptions {
191
191
  }
192
192
  declare function createNodeWorkspace(root: string, opts?: CreateNodeWorkspaceOptions): Workspace;
193
193
 
194
+ /**
195
+ * Validate and resolve a user-provided relative path under workspaceRoot.
196
+ */
197
+ declare function validatePath(workspaceRoot: string, relPath: string): string;
198
+ /**
199
+ * Resolve symlinks and ensure candidate path remains under workspaceRoot.
200
+ */
201
+ declare function assertRealPathWithinWorkspace(workspaceRoot: string, absPath: string): Promise<void>;
202
+
203
+ declare function resolveWorkspaceRoot(defaultRoot?: string): string;
204
+
194
205
  interface BoringAgentRuntimePaths {
195
206
  /** Runtime-visible workspace root. This is BORING_AGENT_WORKSPACE_ROOT. */
196
207
  workspaceRoot: string;
@@ -1300,6 +1311,18 @@ interface RegisterAgentRoutesOptions {
1300
1311
  workspaceId: string;
1301
1312
  workspaceRoot: string;
1302
1313
  }) => string | undefined | Promise<string | undefined>;
1314
+ /** Immutable host contribution captured once in the runtime binding scope. */
1315
+ getRuntimeScopeContribution?: (ctx: {
1316
+ workspaceId: string;
1317
+ workspaceRoot: string;
1318
+ request?: FastifyRequest;
1319
+ }) => Readonly<{
1320
+ identity: string;
1321
+ loadSystemPromptAppend?: () => Promise<string | undefined>;
1322
+ }> | Promise<Readonly<{
1323
+ identity: string;
1324
+ loadSystemPromptAppend?: () => Promise<string | undefined>;
1325
+ }>>;
1303
1326
  /** Override the default pi-backed harness with a custom agent runtime. */
1304
1327
  harnessFactory?: AgentHarnessFactory;
1305
1328
  /** Optional pi adapter/runtime knobs used by the default harness. */
@@ -1425,4 +1448,4 @@ interface Logger {
1425
1448
  }
1426
1449
  declare function createLogger(prefix: string): Logger;
1427
1450
 
1428
- export { AgentConfig, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentHarnessFactory, type AgentMeteringSink, type BoringAgentRuntimePaths, type BuiltinRuntimeModeId, type CreateAgentAppOptions, type CreateVercelProvisioningAdapterOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, FileHandleStore, type LogFields, type Logger, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifact, type ManagedAgentArtifactCandidate, type ManagedAgentArtifactRef, type ManagedAgentBoundRunnerWorkspace, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateRunInput, type ManagedAgentDelegateRunner, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type ManagedAgentWorkspaceResolutionInput, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolvedAgent, type ResolvedAgentDigestInput, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type ShareEntryMcpResourceOptions, type SnapshotBakeOptions, type SnapshotBakeResult, UV_SETUP_COMMANDS, VERCEL_PROVISIONING_CACHE_ROOT, VERCEL_SANDBOX_WORKSPACE_ROOT, UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS, type VercelBakeClient, type VercelBakeSandbox, type VercelDeploymentSnapshotOptions, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, autoDetectMode, bakeSnapshotIfNeeded, buildDeploymentSnapshotRecipe, buildPackageHash, buildSnapshotRecipeHash, compactPiPackages, compileAgentDirectory, constantTimeTokenEqual, createAgent, createAgentApp, createDirectSandbox, createLogger, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createNodeWorkspace, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResourceSettingsManager, createVercelDeploymentSnapshotProvider, createVercelProvisioningAdapter, createVercelSandboxWorkspace, decodeBytesFromWorker, encodeBytesForWorker, fileRoutes, getBoringAgentPathEntries, getBoringAgentRuntimeEnv, getBoringAgentRuntimePaths, hasBwrap, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, prepareVercelDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveMode, resolveSandboxHandle, shareResourceUri };
1451
+ export { AgentConfig, AgentDirectoryCompilerError, type AgentDirectoryCompilerErrorCode, type AgentDirectoryCompilerPublicErrorCode, AgentHarnessFactory, type AgentMeteringSink, type BoringAgentRuntimePaths, type BuiltinRuntimeModeId, type CreateAgentAppOptions, type CreateVercelProvisioningAdapterOptions, type DeploymentSnapshotProvider, type DeploymentSnapshotRecipe, type DeploymentSnapshotResult, type DeploymentSnapshotStatus, FileHandleStore, type LogFields, type Logger, MANAGED_AGENT_MCP_DELIVERY_RULE, MANAGED_AGENT_MCP_ORIGIN_SURFACE, type ManagedAgentArtifact, type ManagedAgentArtifactCandidate, type ManagedAgentArtifactRef, type ManagedAgentBoundRunnerWorkspace, type ManagedAgentCollectArtifactsInput, type ManagedAgentDelegateInput, type ManagedAgentDelegateProgress, type ManagedAgentDelegateRequestContext, type ManagedAgentDelegateResult, type ManagedAgentDelegateRunInput, type ManagedAgentDelegateRunner, type ManagedAgentDelegateStatus, type ManagedAgentDelegateStatusResult, ManagedAgentMcpDelegateController, type ManagedAgentMcpDelegateOptions, ManagedAgentMcpError, type ManagedAgentMcpHttpHandlerOptions, type ManagedAgentMcpServerOptions, type ManagedAgentSafeError, type ManagedAgentWorkspaceResolutionInput, type MeteringErrorLogger, type MeteringReleaseInput, type MeteringReleaseReason, type MeteringReservationResult, type MeteringReserveInput, type MeteringRunKind, type MeteringRunScope, type MeteringRunStatus, type MeteringSettleInput, type MeteringUsage, type MeteringUsageInput, type ModeContext, PI_PACKAGE_RESOURCE_FILTERS, type PiExtensionFactory, type PiHarnessOptions, type PiPackageSource, type PluginSkillSource, type ProvisionRuntimeWorkspaceOptions, type ProvisionWorkspaceRuntimeOptions, type ProvisioningArtifactRequest, type RegisterAgentRoutesOptions, RemoteWorkerClient, RemoteWorkerClientError, type RemoteWorkerClientOptions, RemoteWorkerExecRequest, type RemoteWorkerModeAdapterOptions, RemoteWorkerWorkspaceOp, RemoteWorkerWorkspaceResult, type ResolvedAgent, type ResolvedAgentDigestInput, type RuntimeBundle, type RuntimeEnvContribution, type RuntimeEnvContributionContext, type RuntimeFilesystemBinding, type RuntimeFilesystemBindingOperations, type RuntimeModeAdapter, type RuntimeModeId, type RuntimeNodePackageSpec$1 as RuntimeNodePackageSpec, type RuntimeProvisioningContribution$1 as RuntimeProvisioningContribution, type RuntimePythonSpec$1 as RuntimePythonSpec, type RuntimeTemplateContribution$1 as RuntimeTemplateContribution, type RuntimeWorkspaceProvisioningResult, type ShareEntryMcpResourceOptions, type SnapshotBakeOptions, type SnapshotBakeResult, UV_SETUP_COMMANDS, VERCEL_PROVISIONING_CACHE_ROOT, VERCEL_SANDBOX_WORKSPACE_ROOT, UV_SETUP_COMMANDS as VERCEL_UV_SETUP_COMMANDS, type VercelBakeClient, type VercelBakeSandbox, type VercelDeploymentSnapshotOptions, type WorkspaceAgentDispatcherBinding, type WorkspaceAgentDispatcherResolveOptions, type WorkspaceAgentDispatcherResolver, type WorkspaceProvisioningAdapter, type WorkspaceProvisioningExecResult, type WorkspaceProvisioningResult, applyCspHeaders, assertRealPathWithinWorkspace, autoDetectMode, bakeSnapshotIfNeeded, buildDeploymentSnapshotRecipe, buildPackageHash, buildSnapshotRecipeHash, compactPiPackages, compileAgentDirectory, constantTimeTokenEqual, createAgent, createAgentApp, createDirectSandbox, createLogger, createManagedAgentMcpDelegateController, createManagedAgentMcpHttpHandler, createManagedAgentMcpServer, createNodeWorkspace, createRemoteWorkerModeAdapter, createRemoteWorkerSandbox, createRemoteWorkerWorkspace, createResolvedAgentDigest, createResourceSettingsManager, createVercelDeploymentSnapshotProvider, createVercelProvisioningAdapter, createVercelSandboxWorkspace, decodeBytesFromWorker, encodeBytesForWorker, fileRoutes, getBoringAgentPathEntries, getBoringAgentRuntimeEnv, getBoringAgentRuntimePaths, hasBwrap, mergePiPackageSources, normalizeMeteringUsage, piPackageSourceKey, prepareDeploymentSnapshot, prepareVercelDeploymentSnapshot, provisionRuntimeWorkspace, provisionWorkspaceRuntime, registerAgentRoutes, registerShareEntryResources, resolveAgentDeployment, resolveMode, resolveSandboxHandle, resolveWorkspaceRoot, shareResourceUri, validatePath };
@@ -16,6 +16,7 @@ import {
16
16
  WORKER_REQUEST_ID_HEADER,
17
17
  WORKER_WORKSPACE_ID_HEADER,
18
18
  applyCspHeaders,
19
+ assertRealPathWithinWorkspace,
19
20
  autoDetectMode,
20
21
  bakeSnapshotIfNeeded,
21
22
  buildDeploymentSnapshotRecipe,
@@ -55,8 +56,10 @@ import {
55
56
  resolveAgentDeployment,
56
57
  resolveMode,
57
58
  resolveSandboxHandle,
58
- shareResourceUri
59
- } from "../chunk-HY7EERLW.js";
59
+ resolveWorkspaceRoot,
60
+ shareResourceUri,
61
+ validatePath
62
+ } from "../chunk-RRVL5JRE.js";
60
63
  import "../chunk-YONTHCD7.js";
61
64
  import "../chunk-LYBTHR7J.js";
62
65
  import "../chunk-WSQ5QNIY.js";
@@ -91,6 +94,7 @@ export {
91
94
  WORKER_REQUEST_ID_HEADER,
92
95
  WORKER_WORKSPACE_ID_HEADER,
93
96
  applyCspHeaders,
97
+ assertRealPathWithinWorkspace,
94
98
  autoDetectMode,
95
99
  bakeSnapshotIfNeeded,
96
100
  buildDeploymentSnapshotRecipe,
@@ -135,5 +139,7 @@ export {
135
139
  resolveAgentDeployment,
136
140
  resolveMode,
137
141
  resolveSandboxHandle,
138
- shareResourceUri
142
+ resolveWorkspaceRoot,
143
+ shareResourceUri,
144
+ validatePath
139
145
  };
@@ -4,7 +4,7 @@ import {
4
4
  constantTimeTokenEqual,
5
5
  createBwrapSandbox,
6
6
  createNodeWorkspace
7
- } from "../../chunk-HY7EERLW.js";
7
+ } from "../../chunk-RRVL5JRE.js";
8
8
  import "../../chunk-YONTHCD7.js";
9
9
  import "../../chunk-LYBTHR7J.js";
10
10
  import "../../chunk-WSQ5QNIY.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hachej/boring-agent",
3
- "version": "0.1.85",
3
+ "version": "0.1.86",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Pane-embeddable coding agent. Ships direct/local/vercel-sandbox execution modes behind one interface.",
@@ -84,7 +84,7 @@
84
84
  "use-stick-to-bottom": "^1.1.6",
85
85
  "yaml": "^2.9.0",
86
86
  "zod": "^3.25.76",
87
- "@hachej/boring-ui-kit": "0.1.85"
87
+ "@hachej/boring-ui-kit": "0.1.86"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@antithesishq/bombadil": "0.6.1",