@ai-sdk/harness 1.0.122 → 1.0.123

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * One file to write into the sandbox as part of an adapter's bootstrap recipe.
3
3
  * Absolute paths are used as-is. Relative paths are resolved against the
4
- * sandbox's default working directory. Paths should live under
4
+ * harness state directory (`$HOME/.ai-sdk-harness`). Paths should live under
5
5
  * {@link HarnessV1Bootstrap.bootstrapDir}.
6
6
  */
7
7
  export interface HarnessV1BootstrapFile {
@@ -33,10 +33,10 @@ export interface HarnessV1Bootstrap {
33
33
 
34
34
  /**
35
35
  * Path inside the sandbox where this recipe writes its state. Absolute paths
36
- * are used as-is. Relative paths are resolved against the sandbox's default
37
- * working directory. The marker file lives directly under it. Files
38
- * declared in {@link files} should also use this prefix so an adapter upgrade
39
- * can sweep stale state by clearing the directory.
36
+ * are used as-is. Relative paths are resolved against the harness state
37
+ * directory (`$HOME/.ai-sdk-harness`). The marker file lives directly under
38
+ * it. Files declared in {@link files} should also use this prefix so an
39
+ * adapter upgrade can sweep stale state by clearing the directory.
40
40
  */
41
41
  readonly bootstrapDir: string;
42
42
 
@@ -1,3 +1,4 @@
1
+ import { posix } from 'node:path';
1
2
  import type { Experimental_SandboxSession as SandboxSession } from '@ai-sdk/provider-utils';
2
3
 
3
4
  /**
@@ -9,6 +10,29 @@ export type HarnessV1PortEndpoint = {
9
10
  readonly headers?: Readonly<Record<string, string>>;
10
11
  };
11
12
 
13
+ /**
14
+ * Fixed directory, relative to the sandbox's own HOME, that holds every
15
+ * piece of state the harness machinery generates.
16
+ */
17
+ const HARNESS_V1_STATE_DIRECTORY_NAME = '.ai-sdk-harness';
18
+
19
+ /**
20
+ * Fixed, non-configurable path for harness-generated state (bootstrap files,
21
+ * markers, and `.agent-runs`) under the sandbox's own HOME, never under
22
+ * {@link HarnessV1NetworkSandboxSession.defaultWorkingDirectory}. Resolve HOME
23
+ * with `resolveSandboxHomeDir` when it is not already known. This works from
24
+ * provider creation hooks that only have a plain sandbox session. The
25
+ * framework also calls this with a symbolic `$HOME` when hashing bootstrap
26
+ * recipes, so changes to the state path invalidate existing templates.
27
+ */
28
+ export function harnessStateDirectoryPath({
29
+ sandboxHomeDir,
30
+ }: {
31
+ sandboxHomeDir: string;
32
+ }): string {
33
+ return posix.join(sandboxHomeDir, HARNESS_V1_STATE_DIRECTORY_NAME);
34
+ }
35
+
12
36
  /**
13
37
  * Network sandbox session returned by `HarnessV1SandboxProvider.createSession()`. The
14
38
  * harness keeps this for the lifetime of a session. It is itself a
package/src/v1/index.ts CHANGED
@@ -63,6 +63,8 @@ export type {
63
63
  HarnessV1RequestTransformation,
64
64
  HarnessV1RequestTransformationSources,
65
65
  } from './harness-v1-network-sandbox-session';
66
+ export { harnessStateDirectoryPath } from './harness-v1-network-sandbox-session';
67
+ export { harnessSessionDataDirectoryPath } from './harness-session-data-directory-path';
66
68
  export type { HarnessV1Skill } from './harness-v1-skill';
67
69
  export type { HarnessV1StreamPart } from './harness-v1-stream-part';
68
70
  export {