experimental-ash 0.18.3 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/docs/internals/context.md +7 -0
  3. package/dist/docs/public/channels/README.md +5 -0
  4. package/dist/docs/public/channels/slack.md +58 -4
  5. package/dist/docs/public/hooks.md +4 -2
  6. package/dist/docs/public/sandbox.md +71 -49
  7. package/dist/docs/public/typescript-api.md +6 -1
  8. package/dist/src/channel/adapter.js +12 -2
  9. package/dist/src/channel/routes.d.ts +9 -1
  10. package/dist/src/channel/send.js +3 -3
  11. package/dist/src/channel/types.d.ts +3 -1
  12. package/dist/src/chunks/{dev-authored-source-watcher-j7YWh2Gx.js → dev-authored-source-watcher-L3_pagDa.js} +1 -1
  13. package/dist/src/chunks/{host-C19hLVqS.js → host-e2GUqnTr.js} +2 -2
  14. package/dist/src/chunks/{paths-Dwv0Eash.js → paths-BBleOGpa.js} +25 -25
  15. package/dist/src/chunks/{prewarm-CQYfka30.js → prewarm-DEymC5M-.js} +1 -1
  16. package/dist/src/cli/commands/info.js +1 -1
  17. package/dist/src/cli/run.js +1 -1
  18. package/dist/src/compiled/.vendor-stamp.json +1 -1
  19. package/dist/src/compiled/@vercel/sandbox/index.d.ts +6 -1
  20. package/dist/src/context/hook-lifecycle.js +5 -1
  21. package/dist/src/evals/cli/eval.js +1 -1
  22. package/dist/src/execution/sandbox/bindings/local.d.ts +14 -1
  23. package/dist/src/execution/sandbox/bindings/local.js +5 -1
  24. package/dist/src/execution/sandbox/bindings/vercel.d.ts +6 -0
  25. package/dist/src/execution/sandbox/bindings/vercel.js +12 -1
  26. package/dist/src/execution/sandbox/lazy-backend.d.ts +15 -0
  27. package/dist/src/execution/sandbox/lazy-backend.js +33 -0
  28. package/dist/src/execution/workflow-entry.d.ts +2 -4
  29. package/dist/src/execution/workflow-entry.js +1 -1
  30. package/dist/src/harness/messages.js +15 -0
  31. package/dist/src/harness/types.d.ts +6 -7
  32. package/dist/src/internal/application/package.js +1 -1
  33. package/dist/src/internal/authored-definition/sandbox.d.ts +8 -2
  34. package/dist/src/internal/authored-definition/sandbox.js +10 -2
  35. package/dist/src/public/channels/slack/index.d.ts +3 -0
  36. package/dist/src/public/channels/slack/index.js +2 -0
  37. package/dist/src/public/channels/slack/slackChannel.d.ts +12 -4
  38. package/dist/src/public/channels/slack/slackChannel.js +4 -1
  39. package/dist/src/public/channels/slack/thread.d.ts +26 -0
  40. package/dist/src/public/channels/slack/thread.js +45 -0
  41. package/dist/src/public/sandbox/backends/default.d.ts +16 -1
  42. package/dist/src/public/sandbox/backends/default.js +7 -19
  43. package/dist/src/public/sandbox/backends/local.d.ts +7 -4
  44. package/dist/src/public/sandbox/backends/local.js +7 -5
  45. package/dist/src/public/sandbox/backends/vercel.d.ts +9 -3
  46. package/dist/src/public/sandbox/backends/vercel.js +9 -3
  47. package/dist/src/public/sandbox/index.d.ts +2 -1
  48. package/dist/src/public/sandbox/local-sandbox.d.ts +7 -0
  49. package/dist/src/public/sandbox/local-sandbox.js +1 -0
  50. package/dist/src/public/sandbox/vercel-sandbox.d.ts +13 -1
  51. package/dist/src/runtime/resolve-sandbox.js +5 -1
  52. package/dist/src/runtime/types.d.ts +10 -1
  53. package/dist/src/shared/sandbox-definition.d.ts +16 -1
  54. package/package.json +1 -1
@@ -7,10 +7,12 @@ import { createLocalSandboxBackend } from "#execution/sandbox/bindings/local.js"
7
7
  * under the application root. It is the default backend on developer
8
8
  * machines (`pnpm ash dev`).
9
9
  *
10
- * Takes no arguments today `just-bash` does not currently expose any
11
- * configuration that's worth surfacing through ash. New options would
12
- * be added here as the underlying runtime grows.
10
+ * Accepts an `opts` parameter for parity with other backends, but
11
+ * `LocalSandboxCreateOptions` is empty today `just-bash` does not
12
+ * currently expose any configuration worth surfacing. New options would
13
+ * be added by widening `LocalSandboxCreateOptions` and routing them
14
+ * into the binding without changing this signature.
13
15
  */
14
- export function localBackend() {
15
- return createLocalSandboxBackend();
16
+ export function localBackend(opts) {
17
+ return createLocalSandboxBackend({ createOptions: opts });
16
18
  }
@@ -1,11 +1,17 @@
1
1
  import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
2
- import type { VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions } from "#public/sandbox/vercel-sandbox.js";
2
+ import type { VercelSandboxBootstrapUseOptions, VercelSandboxCreateOptions, VercelSandboxSessionUseOptions } from "#public/sandbox/vercel-sandbox.js";
3
3
  /**
4
4
  * Constructs the built-in Vercel sandbox backend.
5
5
  *
6
+ * The optional `opts` parameter is forwarded to the Vercel SDK's
7
+ * `Sandbox.create(...)` for every fresh sandbox the framework creates
8
+ * (template at prewarm, session at first-time create). On resume
9
+ * (`Sandbox.get`), no create happens, so opts are not re-applied.
10
+ *
6
11
  * `bootstrap({ use })` applies its options to the template via
7
12
  * `sandbox.update(...)`; those settings persist into the snapshot.
8
13
  * `onSession({ use })` applies its options to the live session via the
9
- * SDK's `update` under the hood.
14
+ * SDK's `update` under the hood — overriding any overlapping field
15
+ * from `opts`.
10
16
  */
11
- export declare function vercelBackend(): SandboxBackend<VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions>;
17
+ export declare function vercelBackend(opts?: VercelSandboxCreateOptions): SandboxBackend<VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions>;
@@ -2,11 +2,17 @@ import { createVercelSandboxBackend } from "#execution/sandbox/bindings/vercel.j
2
2
  /**
3
3
  * Constructs the built-in Vercel sandbox backend.
4
4
  *
5
+ * The optional `opts` parameter is forwarded to the Vercel SDK's
6
+ * `Sandbox.create(...)` for every fresh sandbox the framework creates
7
+ * (template at prewarm, session at first-time create). On resume
8
+ * (`Sandbox.get`), no create happens, so opts are not re-applied.
9
+ *
5
10
  * `bootstrap({ use })` applies its options to the template via
6
11
  * `sandbox.update(...)`; those settings persist into the snapshot.
7
12
  * `onSession({ use })` applies its options to the live session via the
8
- * SDK's `update` under the hood.
13
+ * SDK's `update` under the hood — overriding any overlapping field
14
+ * from `opts`.
9
15
  */
10
- export function vercelBackend() {
11
- return createVercelSandboxBackend();
16
+ export function vercelBackend(opts) {
17
+ return createVercelSandboxBackend({ createOptions: opts });
12
18
  }
@@ -9,4 +9,5 @@ export { SandboxTemplateNotProvisionedError } from "#public/definitions/sandbox-
9
9
  export { defaultBackend } from "#public/sandbox/backends/default.js";
10
10
  export { localBackend } from "#public/sandbox/backends/local.js";
11
11
  export { vercelBackend } from "#public/sandbox/backends/vercel.js";
12
- export type { VercelSandboxBootstrapUseOptions, VercelSandboxSessionUseOptions, } from "#public/sandbox/vercel-sandbox.js";
12
+ export type { LocalSandboxCreateOptions } from "#public/sandbox/local-sandbox.js";
13
+ export type { VercelSandboxBootstrapUseOptions, VercelSandboxCreateOptions, VercelSandboxSessionUseOptions, } from "#public/sandbox/vercel-sandbox.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Options accepted by `localBackend(opts)`. Reserved for future
3
+ * widening: today the local backend exposes no consumer-controllable
4
+ * create options, so this is an empty object. The parameter exists on
5
+ * the factory so adding real fields here later is purely additive.
6
+ */
7
+ export type LocalSandboxCreateOptions = Record<string, never>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,16 @@
1
- import type { SandboxUpdateParams } from "#compiled/@vercel/sandbox/index.js";
1
+ import type { Sandbox as SdkSandbox, SandboxUpdateParams } from "#compiled/@vercel/sandbox/index.js";
2
+ /**
3
+ * Options accepted by `vercelBackend(opts)`. Forwarded directly to the
4
+ * Vercel SDK's `Sandbox.create(...)` for every fresh sandbox the
5
+ * framework creates (template at prewarm time, session at first-time
6
+ * session-create). Skipped on resume (`Sandbox.get`) since no create
7
+ * happens there.
8
+ *
9
+ * Framework-injected fields (`name`, `persistent`, `source`, `signal`)
10
+ * are excluded — the framework owns those and overrides any author-
11
+ * supplied values.
12
+ */
13
+ export type VercelSandboxCreateOptions = Omit<NonNullable<Parameters<typeof SdkSandbox.create>[0]>, "name" | "persistent" | "source" | "signal">;
2
14
  /**
3
15
  * Options accepted by the Vercel backend's `bootstrap({ use })` hook.
4
16
  * Aliases the Vercel SDK's `SandboxUpdateParams` because bootstrap
@@ -1,3 +1,4 @@
1
+ import { lazyBackend } from "#execution/sandbox/lazy-backend.js";
1
2
  import { expectObjectRecord } from "#internal/authored-module.js";
2
3
  import { defaultBackend } from "#public/sandbox/backends/default.js";
3
4
  import { toErrorMessage } from "#shared/errors.js";
@@ -47,8 +48,11 @@ function resolveBackend(value, logicalPath) {
47
48
  if (value === undefined) {
48
49
  return defaultBackend();
49
50
  }
51
+ if (typeof value === "function") {
52
+ return lazyBackend(value);
53
+ }
50
54
  if (typeof value !== "object" || value === null) {
51
- throw new ResolveAgentError(`Sandbox "${logicalPath}" exposed a non-object "backend" field. Use vercelBackend(), localBackend(), or another factory that returns a SandboxBackend value.`, { logicalPath });
55
+ throw new ResolveAgentError(`Sandbox "${logicalPath}" exposed a non-object "backend" field. Use vercelBackend(), localBackend(), another factory that returns a SandboxBackend value, or a zero-arg callback returning one.`, { logicalPath });
52
56
  }
53
57
  const record = value;
54
58
  if (typeof record.name !== "string" || record.name.length === 0) {
@@ -15,6 +15,7 @@ import type { SourceRef, ModuleSourceRef, SkillPackageSourceRef, MarkdownSourceR
15
15
  import type { InternalSkillDefinition } from "#shared/skill-definition.js";
16
16
  import type { InternalAgentDefinition } from "#shared/agent-definition.js";
17
17
  import type { InternalToolDefinitionWithExecuteFn } from "#shared/tool-definition.js";
18
+ import type { SandboxBackend } from "#shared/sandbox-backend.js";
18
19
  import type { SandboxDefinition } from "#shared/sandbox-definition.js";
19
20
  /**
20
21
  * Runtime-owned source ref describing one additive config module import.
@@ -82,7 +83,15 @@ export interface ResolvedConnectionDefinition extends ResolvedModuleSourceRef {
82
83
  * `vercelBackend()` and `localBackend()` based on the current
83
84
  * environment).
84
85
  */
85
- export type ResolvedSandboxDefinition = Readonly<SandboxDefinition> & ResolvedModuleSourceRef & {
86
+ export type ResolvedSandboxDefinition = Readonly<Omit<SandboxDefinition, "backend">> & ResolvedModuleSourceRef & {
87
+ /**
88
+ * Resolved backend value. The authored `SandboxDefinition.backend`
89
+ * accepts either a `SandboxBackend` or a `() => SandboxBackend`; by
90
+ * the time it reaches the runtime the function form has been
91
+ * unwrapped via `lazyBackend(...)` so consumers always see a plain
92
+ * value.
93
+ */
94
+ readonly backend: SandboxBackend;
86
95
  readonly description?: string;
87
96
  };
88
97
  /**
@@ -25,13 +25,28 @@ export interface SandboxDefinition<BO = Record<string, never>, SO = Record<strin
25
25
  /**
26
26
  * Backend that runs this sandbox.
27
27
  *
28
+ * Accepts either a {@link SandboxBackend} value or a zero-arg factory
29
+ * function that returns one. The factory form is invoked lazily on
30
+ * first framework access and the result is memoized for the lifetime
31
+ * of the process, so backend-internal state (such as the Vercel
32
+ * backend's prewarmed-template cache) is preserved across every call.
33
+ * Use the factory form to defer evaluation — for example, when create
34
+ * options depend on environment variables that aren't set at module
35
+ * load time:
36
+ *
37
+ * ```ts
38
+ * defineSandbox({
39
+ * backend: () => vercelBackend({ env: { TOKEN: process.env.TOKEN ?? "" } }),
40
+ * });
41
+ * ```
42
+ *
28
43
  * When this field is omitted, Ash substitutes `defaultBackend()` at
29
44
  * runtime, which delegates to `vercelBackend()` on hosted Vercel
30
45
  * (where `process.env.VERCEL` is set) and to `localBackend()`
31
46
  * everywhere else. Set `backend` explicitly to pin the sandbox to a
32
47
  * specific backend regardless of environment.
33
48
  */
34
- backend: SandboxBackend<BO, SO>;
49
+ backend: SandboxBackend<BO, SO> | (() => SandboxBackend<BO, SO>);
35
50
  bootstrap?(input: SandboxBootstrapContext<BO>): Promise<void> | void;
36
51
  onSession?(input: SandboxSessionContext<SO>): Promise<void> | void;
37
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "experimental-ash",
3
- "version": "0.18.3",
3
+ "version": "0.19.0",
4
4
  "bin": {
5
5
  "ash": "./bin/ash.js",
6
6
  "experimental-ash": "./bin/ash.js"