@ai-sdk/harness-acp 1.0.60 → 1.0.62

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/harness-acp",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -26,8 +26,8 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@ai-sdk/harness": "1.0.122",
30
- "@ai-sdk/provider-utils": "5.0.46",
29
+ "@ai-sdk/harness": "1.0.124",
30
+ "@ai-sdk/provider-utils": "5.0.47",
31
31
  "ws": "^8.21.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -12,6 +12,7 @@ import {
12
12
  type HarnessV1Skill,
13
13
  type HarnessV1StreamPart,
14
14
  type HarnessV1ToolSpec,
15
+ harnessStateDirectoryPath,
15
16
  } from '@ai-sdk/harness';
16
17
  import { HarnessBridgeCapabilityUnsupportedError } from '@ai-sdk/harness/bridge';
17
18
  import {
@@ -25,7 +26,6 @@ import {
25
26
  forwardBridgeProcessStream,
26
27
  getRestrictedSandboxSession,
27
28
  markBridgeStarting,
28
- resolveSandboxDefaultWorkingDirectory,
29
29
  resolveSandboxHomeDir,
30
30
  SandboxChannel,
31
31
  shellQuote,
@@ -256,11 +256,6 @@ export function createACPV1<TBuiltinTools extends ToolSet = {}>({
256
256
  message: `The ${settings.harnessId} ACP harness cannot use \`mintBridgeToken\` with a sandbox session that does not expose an id.`,
257
257
  });
258
258
  }
259
- const defaultWorkingDirectory =
260
- await resolveSandboxDefaultWorkingDirectory({
261
- sandboxSession,
262
- abortSignal: startOptions.abortSignal,
263
- });
264
259
  const continueFrom =
265
260
  startOptions.continueFrom ?? startOptions.resumeFrom?.continueFrom;
266
261
  const lifecycleState = continueFrom ?? startOptions.resumeFrom;
@@ -376,19 +371,21 @@ export function createACPV1<TBuiltinTools extends ToolSet = {}>({
376
371
  ),
377
372
  );
378
373
  }
374
+ // Harness SDK state always lives under the sandbox's own HOME, never
375
+ // the working directory, so it stays out of a user-owned workspace.
376
+ const sandboxHomeDir = await resolveSandboxHomeDir({
377
+ sandbox: toolSafeSandboxSession,
378
+ abortSignal: startOptions.abortSignal,
379
+ });
380
+ const stateDirectory = harnessStateDirectoryPath({ sandboxHomeDir });
379
381
  const resolvedBridgeDir = posix.resolve(
380
- defaultWorkingDirectory,
382
+ stateDirectory,
381
383
  bootstrap.bootstrapDir,
382
384
  );
383
385
  const resolvedImplementationDir = `${resolvedBridgeDir}/implementation`;
384
386
  const workDir = startOptions.sessionWorkDir;
385
- const sandboxHomeDir = await resolveSandboxHomeDir({
386
- sandbox: toolSafeSandboxSession,
387
- abortSignal: startOptions.abortSignal,
388
- });
389
387
  const privateSessionDir = resolveACPPrivateSessionDirectory({
390
- sandboxHomeDir,
391
- harnessId: settings.harnessId,
388
+ stateDirectory,
392
389
  sessionId: startOptions.sessionId,
393
390
  });
394
391
  const implementationHomeDir =
@@ -2013,7 +2010,7 @@ function withNativeQuestionRequest({
2013
2010
  providerMetadata: {
2014
2011
  ...toolCall.providerMetadata,
2015
2012
  [harnessId]: {
2016
- ...(harnessMetadata ?? {}),
2013
+ ...harnessMetadata,
2017
2014
  nativeRequest,
2018
2015
  } as NonNullable<
2019
2016
  Extract<HarnessV1StreamPart, { type: 'tool-call' }>['providerMetadata']
@@ -2067,7 +2064,6 @@ function takeBufferedQuestionResult({
2067
2064
  return buffered;
2068
2065
  }
2069
2066
  }
2070
- return undefined;
2071
2067
  }
2072
2068
 
2073
2069
  function isPermissionModeMappingValue({
@@ -1,27 +1,20 @@
1
- import { createHash } from 'node:crypto';
2
1
  import path from 'node:path';
3
- import type { HarnessV1Skill } from '@ai-sdk/harness';
2
+ import {
3
+ harnessSessionDataDirectoryPath,
4
+ type HarnessV1Skill,
5
+ } from '@ai-sdk/harness';
4
6
 
5
7
  export const ACP_SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
8
  export const DEFAULT_ACP_SKILLS_DIRECTORY = '.agents/skills';
7
9
 
8
10
  export function resolveACPPrivateSessionDirectory({
9
- sandboxHomeDir,
10
- harnessId,
11
+ stateDirectory,
11
12
  sessionId,
12
13
  }: {
13
- sandboxHomeDir: string;
14
- harnessId: string;
14
+ stateDirectory: string;
15
15
  sessionId: string;
16
16
  }): string {
17
- const sessionKey = createHash('sha256').update(sessionId).digest('hex');
18
- return path.posix.join(
19
- sandboxHomeDir,
20
- '.ai-sdk',
21
- 'harness-acp',
22
- harnessId,
23
- sessionKey,
24
- );
17
+ return harnessSessionDataDirectoryPath({ stateDirectory, sessionId });
25
18
  }
26
19
 
27
20
  export function resolveACPSkillsDirectory({
@@ -66,8 +66,6 @@ function getErrorMessage({ error }: { error: unknown }): string | undefined {
66
66
  if (typeof error === 'string') {
67
67
  return error;
68
68
  }
69
-
70
- return undefined;
71
69
  }
72
70
 
73
71
  function stripMetadata({ value }: { value: unknown }): unknown {
@@ -515,7 +515,6 @@ function findTokenInvocation({
515
515
  return invocation;
516
516
  }
517
517
  }
518
- return undefined;
519
518
  }
520
519
 
521
520
  function removeInvocationForToolCall({
@@ -79,8 +79,8 @@ export function validateACPV1Implementation(
79
79
  validateForwardEnvironment({ forwardEnv: implementation.forwardEnv });
80
80
  validateForwardEnvironment({ forwardEnv: implementation.credentialEnv });
81
81
  validateEnvironment({ env: implementation.env });
82
- const forwardedKeys = new Set(implementation.forwardEnv ?? []);
83
- const credentialKeys = new Set(implementation.credentialEnv ?? []);
82
+ const forwardedKeys = new Set(implementation.forwardEnv);
83
+ const credentialKeys = new Set(implementation.credentialEnv);
84
84
  for (const key of credentialKeys) {
85
85
  if (forwardedKeys.has(key)) {
86
86
  throw new Error(
@@ -209,11 +209,9 @@ export function createImplementationIdentity({
209
209
  type: source.type,
210
210
  command: source.command,
211
211
  };
212
- const forwardedEnvironment = [
213
- ...new Set(implementation.forwardEnv ?? []),
214
- ].sort();
212
+ const forwardedEnvironment = [...new Set(implementation.forwardEnv)].sort();
215
213
  const credentialEnvironment = [
216
- ...new Set(implementation.credentialEnv ?? []),
214
+ ...new Set(implementation.credentialEnv),
217
215
  ].sort();
218
216
  const literalEnvironment = Object.fromEntries(
219
217
  Object.entries(implementation.env ?? {})