experimental-ash 0.6.1 → 0.7.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.
- package/README.md +3 -4
- package/dist/docs/internals/discovery.md +2 -2
- package/dist/docs/internals/mechanical-invariants.md +1 -1
- package/dist/docs/internals/testing.md +1 -1
- package/dist/docs/public/README.md +1 -1
- package/dist/docs/public/agent-ts.md +2 -2
- package/dist/docs/public/channels/README.md +1 -1
- package/dist/docs/public/context-control.md +20 -20
- package/dist/docs/public/getting-started.md +1 -1
- package/dist/docs/public/project-layout.md +21 -21
- package/dist/docs/public/schedules.md +1 -1
- package/dist/docs/public/skills.md +3 -3
- package/dist/docs/public/subagents.md +3 -3
- package/dist/docs/public/typescript-api.md +2 -2
- package/dist/src/chunks/{dev-authored-source-watcher-Bk-ZWzF_.js → dev-authored-source-watcher-HzOplr1S.js} +1 -1
- package/dist/src/chunks/{host-CEiB9Ps8.js → host-Ca8xvEQ1.js} +2 -2
- package/dist/src/chunks/paths-BiY7uVwD.js +88 -0
- package/dist/src/chunks/{prewarm-BK_ZT4-w.js → prewarm-DiZ_sYLy.js} +1 -1
- package/dist/src/cli/commands/info.js +1 -1
- package/dist/src/cli/run.js +1 -1
- package/dist/src/cli/templates/init-app/package.json +1 -1
- package/dist/src/compiled/.vendor-stamp.json +2 -2
- package/dist/src/compiled/@ai-sdk/otel/index.js +3 -3
- package/dist/src/compiled/@ai-sdk/otel/package.json +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +1 -0
- package/dist/src/compiler/compile-agent.js +10 -0
- package/dist/src/compiler/manifest.d.ts +8 -7
- package/dist/src/compiler/manifest.js +5 -5
- package/dist/src/compiler/normalize-instructions.d.ts +12 -0
- package/dist/src/compiler/normalize-instructions.js +28 -0
- package/dist/src/compiler/normalize-manifest.js +3 -3
- package/dist/src/discover/discover-agent.d.ts +2 -2
- package/dist/src/discover/discover-agent.js +5 -5
- package/dist/src/discover/discover-subagent.js +4 -4
- package/dist/src/discover/filesystem.d.ts +4 -4
- package/dist/src/discover/filesystem.js +30 -0
- package/dist/src/discover/grammar.d.ts +21 -7
- package/dist/src/discover/grammar.js +79 -21
- package/dist/src/discover/manifest.d.ts +11 -8
- package/dist/src/discover/manifest.js +2 -2
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/sandbox/bindings/local.js +32 -3
- package/dist/src/execution/sandbox/bindings/vercel.js +3 -2
- package/dist/src/execution/sandbox/session.d.ts +2 -2
- package/dist/src/execution/sandbox/session.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/core.d.ts +7 -6
- package/dist/src/internal/authored-definition/core.js +6 -5
- package/dist/src/internal/authored-definition/sandbox.d.ts +3 -10
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.d.ts +5 -5
- package/dist/src/internal/nitro/routes/home-page/build-home-page-response.js +16 -15
- package/dist/src/internal/nitro/routes/home-page/load-home-page-data.d.ts +2 -2
- package/dist/src/internal/nitro/routes/web-ui/assets/{index-z8flAc4k.js → index-BQa8fbHJ.js} +1 -1
- package/dist/src/internal/nitro/routes/web-ui/index.html +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +7 -0
- package/dist/src/public/channels/slack/slackChannel.js +5 -0
- package/dist/src/public/definitions/instructions.d.ts +29 -0
- package/dist/src/public/definitions/instructions.js +12 -0
- package/dist/src/public/definitions/sandbox-backend.d.ts +1 -123
- package/dist/src/public/definitions/sandbox.d.ts +6 -165
- package/dist/src/public/helpers/markdown.d.ts +5 -5
- package/dist/src/public/helpers/markdown.js +7 -7
- package/dist/src/public/instructions/index.d.ts +8 -0
- package/dist/src/public/instructions/index.js +6 -0
- package/dist/src/public/sandbox/index.d.ts +1 -1
- package/dist/src/runtime/agent/bootstrap.js +3 -3
- package/dist/src/runtime/prompt/compose.d.ts +5 -4
- package/dist/src/runtime/prompt/compose.js +6 -6
- package/dist/src/runtime/resolve-agent.js +10 -10
- package/dist/src/runtime/types.d.ts +15 -15
- package/dist/src/shared/sandbox-backend.d.ts +124 -0
- package/dist/src/shared/sandbox-backend.js +1 -0
- package/dist/src/shared/sandbox-definition.d.ts +72 -0
- package/dist/src/shared/sandbox-definition.js +1 -0
- package/dist/src/shared/sandbox-session.d.ts +95 -0
- package/dist/src/shared/sandbox-session.js +1 -0
- package/package.json +12 -7
- package/dist/src/chunks/paths-Dxh19LKr.js +0 -88
- package/dist/src/compiler/normalize-system.d.ts +0 -11
- package/dist/src/compiler/normalize-system.js +0 -27
- package/dist/src/public/definitions/system.d.ts +0 -16
- package/dist/src/public/definitions/system.js +0 -7
- package/dist/src/public/system/index.d.ts +0 -4
- package/dist/src/public/system/index.js +0 -4
- /package/dist/src/cli/templates/init-app/agent/{system.md → instructions.md} +0 -0
|
@@ -38,6 +38,13 @@ export interface SlackInteractionAction {
|
|
|
38
38
|
readonly actionId: string;
|
|
39
39
|
readonly value?: string;
|
|
40
40
|
readonly blockId?: string;
|
|
41
|
+
/**
|
|
42
|
+
* `ts` of the Slack message that hosts the clicked component. Required by
|
|
43
|
+
* handlers that want to update the clicked message in place via
|
|
44
|
+
* `chat.update` — `ctx.slack.threadTs` resolves to the thread root for
|
|
45
|
+
* components clicked inside thread replies, not to the clicked message.
|
|
46
|
+
*/
|
|
47
|
+
readonly messageTs?: string;
|
|
41
48
|
}
|
|
42
49
|
export type SlackRunResult = {
|
|
43
50
|
auth: import("#channel/types.js").SessionAuthContext | null;
|
|
@@ -67,11 +67,16 @@ function parseBlockActionsPayload(body) {
|
|
|
67
67
|
const team = body.team;
|
|
68
68
|
const user = body.user;
|
|
69
69
|
const teamId = team?.id ?? user?.team_id;
|
|
70
|
+
// `message.ts` is the ts of the message that hosts the clicked component.
|
|
71
|
+
// It differs from `threadTs` whenever the bot's message is a thread reply,
|
|
72
|
+
// and is required for `chat.update` on the clicked message.
|
|
73
|
+
const messageTs = typeof message?.ts === "string" ? message.ts : undefined;
|
|
70
74
|
return {
|
|
71
75
|
actions: actions.map((a) => ({
|
|
72
76
|
actionId: String(a.action_id ?? ""),
|
|
73
77
|
value: a.value != null ? String(a.value) : undefined,
|
|
74
78
|
blockId: a.block_id != null ? String(a.block_id) : undefined,
|
|
79
|
+
messageTs,
|
|
75
80
|
})),
|
|
76
81
|
channelId: channel,
|
|
77
82
|
threadTs,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public definition for an instructions prompt authored in markdown or
|
|
3
|
+
* TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* Authored at the agent root as either `instructions.md` or
|
|
6
|
+
* `instructions.{ts,cts,mts,js,cjs,mjs}`. Module-backed instructions
|
|
7
|
+
* sources execute once at build time — the resulting markdown is captured
|
|
8
|
+
* into the compiled manifest. Authored definitions do not carry a `name`
|
|
9
|
+
* field.
|
|
10
|
+
*/
|
|
11
|
+
export interface InstructionsDefinition {
|
|
12
|
+
markdown: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Defines an instructions prompt in TypeScript using the same shape
|
|
16
|
+
* discovery produces from markdown.
|
|
17
|
+
*/
|
|
18
|
+
export declare function defineInstructions<TInstructions extends InstructionsDefinition>(definition: TInstructions): TInstructions;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use {@link InstructionsDefinition} instead. The authored
|
|
21
|
+
* file slot was renamed from `system.{md,ts,...}` to
|
|
22
|
+
* `instructions.{md,ts,...}`.
|
|
23
|
+
*/
|
|
24
|
+
export type SystemDefinition = InstructionsDefinition;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use {@link defineInstructions} instead. The authored file
|
|
27
|
+
* slot was renamed from `system.{md,ts,...}` to `instructions.{md,ts,...}`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const defineSystem: typeof defineInstructions;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an instructions prompt in TypeScript using the same shape
|
|
3
|
+
* discovery produces from markdown.
|
|
4
|
+
*/
|
|
5
|
+
export function defineInstructions(definition) {
|
|
6
|
+
return definition;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use {@link defineInstructions} instead. The authored file
|
|
10
|
+
* slot was renamed from `system.{md,ts,...}` to `instructions.{md,ts,...}`.
|
|
11
|
+
*/
|
|
12
|
+
export const defineSystem = defineInstructions;
|
|
@@ -1,126 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Live sandbox handle returned by a {@link SandboxBackend}.
|
|
4
|
-
*
|
|
5
|
-
* Wraps the public {@link SandboxSession} with lifecycle methods so the
|
|
6
|
-
* runtime orchestrator can persist reconnect metadata and release
|
|
7
|
-
* resources.
|
|
8
|
-
*/
|
|
9
|
-
export interface SandboxBackendHandle<S extends SandboxSession = SandboxSession> {
|
|
10
|
-
readonly session: SandboxSession;
|
|
11
|
-
readonly useSessionFn: SandboxSessionUseFn<S>;
|
|
12
|
-
captureState(): Promise<SandboxBackendSessionState>;
|
|
13
|
-
dispose(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Serializable per-sandbox reconnect record stored on the harness session.
|
|
17
|
-
*
|
|
18
|
-
* `backendName` matches the {@link SandboxBackend.name} of the backend
|
|
19
|
-
* that produced this state, and is used by the runtime to decide whether
|
|
20
|
-
* a previously persisted handle is still compatible with the current
|
|
21
|
-
* backend.
|
|
22
|
-
*/
|
|
23
|
-
export interface SandboxBackendSessionState {
|
|
24
|
-
readonly backendName: string;
|
|
25
|
-
readonly metadata: Record<string, unknown>;
|
|
26
|
-
readonly sessionKey: string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* One file written into a sandbox template before snapshot capture.
|
|
30
|
-
*/
|
|
31
|
-
export interface SandboxSeedFile {
|
|
32
|
-
readonly path: string;
|
|
33
|
-
readonly content: string | Buffer;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Diagnostic tags attached to provider-owned sandbox resources.
|
|
37
|
-
*
|
|
38
|
-
* Built-in backends may forward these into their hosting platform's
|
|
39
|
-
* native tagging system. Ash supplies stable tags such as the active
|
|
40
|
-
* agent, channel, and session id so sandboxes can be found and
|
|
41
|
-
* attributed in provider dashboards.
|
|
42
|
-
*/
|
|
43
|
-
export type SandboxBackendTags = Readonly<Record<string, string>>;
|
|
44
|
-
/**
|
|
45
|
-
* Framework-owned runtime context handed to a backend on every
|
|
46
|
-
* {@link SandboxBackend.create} call.
|
|
47
|
-
*
|
|
48
|
-
* Backends use this to derive any per-call state that depends on the
|
|
49
|
-
* surrounding application — for example, the local backend computes its
|
|
50
|
-
* cache directory from `appRoot`. Backends that don't need anything
|
|
51
|
-
* here may ignore the field entirely.
|
|
52
|
-
*/
|
|
53
|
-
export interface SandboxBackendRuntimeContext {
|
|
54
|
-
readonly appRoot: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Input passed to {@link SandboxBackend.create} when the runtime needs a
|
|
58
|
-
* live sandbox session.
|
|
59
|
-
*/
|
|
60
|
-
export interface SandboxBackendCreateInput {
|
|
61
|
-
readonly templateKey: string;
|
|
62
|
-
readonly sessionKey: string;
|
|
63
|
-
readonly existingMetadata?: Record<string, unknown>;
|
|
64
|
-
/**
|
|
65
|
-
* Runtime tags the backend should attach to sandbox resources when
|
|
66
|
-
* the underlying provider supports tags.
|
|
67
|
-
*/
|
|
68
|
-
readonly tags?: SandboxBackendTags;
|
|
69
|
-
readonly runtimeContext: SandboxBackendRuntimeContext;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Input passed to {@link SandboxBackend.prewarm} when the build pipeline
|
|
73
|
-
* is preparing reusable templates.
|
|
74
|
-
*
|
|
75
|
-
* Every authored sandbox in the compiled graph receives exactly one
|
|
76
|
-
* `prewarm(...)` call before runtime opens its first session. The
|
|
77
|
-
* backend captures a reusable template snapshot from the supplied
|
|
78
|
-
* `bootstrap` hook and `seedFiles`, then `backend.create(...)` opens
|
|
79
|
-
* durable sessions from that snapshot.
|
|
80
|
-
*/
|
|
81
|
-
export interface SandboxBackendPrewarmInput {
|
|
82
|
-
readonly templateKey: string;
|
|
83
|
-
readonly bootstrap?: (input: SandboxBootstrapContext) => void | Promise<void>;
|
|
84
|
-
readonly runtimeContext: SandboxBackendRuntimeContext;
|
|
85
|
-
readonly seedFiles: ReadonlyArray<SandboxSeedFile>;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Pluggable sandbox backend.
|
|
89
|
-
*
|
|
90
|
-
* A `SandboxBackend` is a value an author attaches to a
|
|
91
|
-
* {@link SandboxDefinition} to choose which underlying runtime hosts the
|
|
92
|
-
* sandbox. Ash ships two built-in backends — `vercelBackend()` and
|
|
93
|
-
* `localBackend()` — but the interface is public so authors can write
|
|
94
|
-
* their own.
|
|
95
|
-
*
|
|
96
|
-
* Each backend owns the full template-then-session lifecycle internally;
|
|
97
|
-
* callers only need a single `create` call.
|
|
98
|
-
*/
|
|
99
|
-
export interface SandboxBackend<S extends SandboxSession = SandboxSession> {
|
|
100
|
-
/**
|
|
101
|
-
* Stable identifier for this backend implementation.
|
|
102
|
-
*
|
|
103
|
-
* Participates in cache-key derivation and the persisted reconnect
|
|
104
|
-
* state, so two backends that should not share template snapshots
|
|
105
|
-
* must use distinct names. Built-in backends use `"vercel"` and
|
|
106
|
-
* `"local"`. Custom backends pick a unique string.
|
|
107
|
-
*/
|
|
108
|
-
readonly name: string;
|
|
109
|
-
/**
|
|
110
|
-
* Creates or reattaches one live sandbox session from a template
|
|
111
|
-
* previously captured by {@link SandboxBackend.prewarm}. Throws
|
|
112
|
-
* {@link SandboxTemplateNotProvisionedError} when the requested
|
|
113
|
-
* template is missing.
|
|
114
|
-
*/
|
|
115
|
-
create(input: SandboxBackendCreateInput): Promise<SandboxBackendHandle<S>>;
|
|
116
|
-
/**
|
|
117
|
-
* Build-time prewarm hook. Ash invokes this for every authored
|
|
118
|
-
* sandbox in the compiled graph before serving traffic so the backend
|
|
119
|
-
* can capture a reusable template snapshot. Idempotent against an
|
|
120
|
-
* existing snapshot keyed by `templateKey`.
|
|
121
|
-
*/
|
|
122
|
-
prewarm(input: SandboxBackendPrewarmInput): Promise<void>;
|
|
123
|
-
}
|
|
1
|
+
export type { SandboxBackendHandle, SandboxBackendSessionState, SandboxSeedFile, SandboxBackendTags, SandboxBackendRuntimeContext, SandboxBackendCreateInput, SandboxBackendPrewarmInput, SandboxBackend, } from "#shared/sandbox-backend.js";
|
|
124
2
|
export declare class SandboxTemplateNotProvisionedError extends Error {
|
|
125
3
|
readonly backendName: string;
|
|
126
4
|
readonly templateKey: string;
|
|
@@ -1,168 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
readonly stderr: string;
|
|
8
|
-
readonly stdout: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Options for reading a text file from a sandbox with optional line ranges.
|
|
12
|
-
*/
|
|
13
|
-
export interface SandboxReadFileOptions {
|
|
14
|
-
/**
|
|
15
|
-
* 1-based inclusive end line. When past the file's line count, the read
|
|
16
|
-
* returns through EOF without error.
|
|
17
|
-
*/
|
|
18
|
-
readonly endLine?: number;
|
|
19
|
-
/**
|
|
20
|
-
* 1-based inclusive start line. Defaults to 1.
|
|
21
|
-
*/
|
|
22
|
-
readonly startLine?: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Minimal Ash-owned sandbox session exposed to authored lifecycle hooks.
|
|
26
|
-
*/
|
|
27
|
-
export interface SandboxSession {
|
|
28
|
-
/**
|
|
29
|
-
* Stable identifier for the backend session this handle wraps.
|
|
30
|
-
*
|
|
31
|
-
* Persists across reconnects to the same logical session: two calls
|
|
32
|
-
* that resume the same underlying backend sandbox observe the same
|
|
33
|
-
* `id`. Template sessions constructed during bootstrap expose the
|
|
34
|
-
* template key; live sessions expose the session key assigned by the
|
|
35
|
-
* runtime. Useful as a cache key for per-session state that must
|
|
36
|
-
* outlive individual step executions.
|
|
37
|
-
*/
|
|
38
|
-
readonly id: string;
|
|
39
|
-
/**
|
|
40
|
-
* Reads one text file from the sandbox as UTF-8.
|
|
41
|
-
*
|
|
42
|
-
* Returns `null` when the file does not exist. Throws when the file
|
|
43
|
-
* contains invalid UTF-8.
|
|
44
|
-
*
|
|
45
|
-
* Relative paths resolve from `/workspace`, the live working directory
|
|
46
|
-
* for every backend. Absolute paths pass through unchanged.
|
|
47
|
-
*
|
|
48
|
-
* Line ranges are 1-based and inclusive. When `endLine` is past EOF the
|
|
49
|
-
* read returns through EOF without error.
|
|
50
|
-
*/
|
|
51
|
-
readFile(path: string, options?: SandboxReadFileOptions): Promise<string | null>;
|
|
52
|
-
/**
|
|
53
|
-
* Reads one file from the sandbox as raw bytes.
|
|
54
|
-
*
|
|
55
|
-
* Returns `null` when the file does not exist. Unlike
|
|
56
|
-
* {@link SandboxSession.readFile}, this variant performs no UTF-8
|
|
57
|
-
* decoding and is safe for binary payloads (images, PDFs, archives,
|
|
58
|
-
* attachment bytes written by the framework at
|
|
59
|
-
* `/workspace/attachments/...`).
|
|
60
|
-
*
|
|
61
|
-
* Relative paths resolve from `/workspace`, the live working
|
|
62
|
-
* directory for every backend. Absolute paths pass through unchanged.
|
|
63
|
-
*/
|
|
64
|
-
readFileBytes(path: string): Promise<Buffer | null>;
|
|
65
|
-
/**
|
|
66
|
-
* Anchors a sandbox-relative path to `/workspace` and returns the
|
|
67
|
-
* resulting absolute path.
|
|
68
|
-
*
|
|
69
|
-
* Relative paths resolve from `/workspace`; absolute paths pass through.
|
|
70
|
-
* `readFile(...)` and `writeFile(...)` already apply this internally.
|
|
71
|
-
*/
|
|
72
|
-
resolvePath(path: string): string;
|
|
73
|
-
/**
|
|
74
|
-
* Runs one shell command inside the current sandbox session and returns the
|
|
75
|
-
* captured stdout, stderr, and exit code.
|
|
76
|
-
*
|
|
77
|
-
* Commands execute with `/workspace` as the working directory on every
|
|
78
|
-
* backend.
|
|
79
|
-
*/
|
|
80
|
-
runCommand(command: string): Promise<SandboxCommandResult>;
|
|
81
|
-
/**
|
|
82
|
-
* Writes one file to the sandbox, creating parent directories
|
|
83
|
-
* recursively and overwriting any existing file.
|
|
84
|
-
*
|
|
85
|
-
* `content` accepts a UTF-8 `string` for text files or a `Buffer` for
|
|
86
|
-
* arbitrary bytes. The framework uses the `Buffer` overload to mount
|
|
87
|
-
* binary workspace assets (images under skill `assets/` directories,
|
|
88
|
-
* fixture payloads, and so on) through the same public surface authors
|
|
89
|
-
* use.
|
|
90
|
-
*
|
|
91
|
-
* Relative paths resolve from `/workspace`. Absolute paths pass through
|
|
92
|
-
* unchanged.
|
|
93
|
-
*/
|
|
94
|
-
writeFile(path: string, content: string | Buffer): Promise<void>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* A transform applied to network requests matching a domain rule.
|
|
98
|
-
*/
|
|
99
|
-
export interface SandboxNetworkTransformer {
|
|
100
|
-
readonly headers?: Record<string, string>;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* A rule applied to requests matching a domain in the network policy.
|
|
104
|
-
*/
|
|
105
|
-
export interface SandboxNetworkPolicyRule {
|
|
106
|
-
readonly transform?: SandboxNetworkTransformer[];
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Network policy to define network restrictions for the sandbox.
|
|
110
|
-
*
|
|
111
|
-
* - `"allow-all"`: Full internet access (default). All traffic is allowed.
|
|
112
|
-
* - `"deny-all"`: No internet access. All traffic is denied.
|
|
113
|
-
* - Object: Custom access with explicit allow/deny lists.
|
|
114
|
-
*/
|
|
115
|
-
export type SandboxNetworkPolicy = "allow-all" | "deny-all" | {
|
|
116
|
-
readonly allow?: string[] | Readonly<Record<string, SandboxNetworkPolicyRule[]>>;
|
|
117
|
-
};
|
|
118
|
-
export interface SandboxBootstrapUseOptions {
|
|
119
|
-
readonly runtime?: string;
|
|
120
|
-
readonly ports?: number[];
|
|
121
|
-
readonly env?: Record<string, string>;
|
|
122
|
-
}
|
|
123
|
-
export interface SandboxSessionUseOptions {
|
|
124
|
-
readonly networkPolicy?: SandboxNetworkPolicy;
|
|
125
|
-
readonly resources?: {
|
|
126
|
-
vcpus?: number;
|
|
127
|
-
};
|
|
128
|
-
readonly timeout?: number;
|
|
129
|
-
readonly tags?: Record<string, string>;
|
|
130
|
-
}
|
|
131
|
-
export type SandboxBootstrapUseFn = (options?: SandboxBootstrapUseOptions) => Promise<SandboxSession>;
|
|
132
|
-
export type SandboxSessionUseFn<S extends SandboxSession = SandboxSession> = (options?: SandboxSessionUseOptions) => Promise<S>;
|
|
133
|
-
export interface SandboxBootstrapContext {
|
|
134
|
-
readonly use: SandboxBootstrapUseFn;
|
|
135
|
-
}
|
|
136
|
-
export interface SandboxSessionContext<S extends SandboxSession = SandboxSession> {
|
|
137
|
-
readonly use: SandboxSessionUseFn<S>;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Public sandbox definition authored in `agent/sandbox.ts` (shorthand)
|
|
141
|
-
* or `agent/sandbox/sandbox.ts` (folder layout, when paired with an
|
|
142
|
-
* authored `sandbox/workspace/` subtree).
|
|
143
|
-
*
|
|
144
|
-
* Each agent (and each subagent) owns exactly one sandbox. When the
|
|
145
|
-
* module file is absent the framework auto-provides a default sandbox
|
|
146
|
-
* via `defaultBackend()`. Authors override lifecycle and backend by
|
|
147
|
-
* creating `agent/sandbox.ts` (or `agent/sandbox/sandbox.ts` when they
|
|
148
|
-
* also want a workspace folder); subagents override independently via
|
|
149
|
-
* `subagents/<name>/sandbox.ts` (or the folder form) and do not inherit
|
|
150
|
-
* their parent's sandbox (skill seeds differ per agent).
|
|
151
|
-
*/
|
|
152
|
-
export interface SandboxDefinition<S extends SandboxSession = SandboxSession> {
|
|
153
|
-
/**
|
|
154
|
-
* Backend that runs this sandbox.
|
|
155
|
-
*
|
|
156
|
-
* When this field is omitted, Ash substitutes `defaultBackend()` at
|
|
157
|
-
* runtime, which delegates to `vercelBackend()` on hosted Vercel
|
|
158
|
-
* (where `process.env.VERCEL` is set) and to `localBackend()`
|
|
159
|
-
* everywhere else. Set `backend` explicitly to pin the sandbox to a
|
|
160
|
-
* specific backend regardless of environment.
|
|
161
|
-
*/
|
|
162
|
-
readonly backend?: SandboxBackend<S>;
|
|
163
|
-
bootstrap?(input: SandboxBootstrapContext): Promise<void> | void;
|
|
164
|
-
onSession?(input: SandboxSessionContext<S>): Promise<void> | void;
|
|
165
|
-
}
|
|
1
|
+
import type { Optional } from "#shared/optional.js";
|
|
2
|
+
import type { SandboxSession } from "#shared/sandbox-session.js";
|
|
3
|
+
import type { SandboxDefinition as SharedSandboxDefinition } from "#shared/sandbox-definition.js";
|
|
4
|
+
export type { SandboxCommandOptions, SandboxCommandResult, SandboxReadFileOptions, SandboxSession, } from "#shared/sandbox-session.js";
|
|
5
|
+
export type { SandboxNetworkPolicy, SandboxBootstrapUseOptions, SandboxSessionUseOptions, SandboxBootstrapUseFn, SandboxSessionUseFn, SandboxBootstrapContext, SandboxSessionContext, } from "#shared/sandbox-definition.js";
|
|
6
|
+
export type SandboxDefinition<S extends SandboxSession = SandboxSession> = Optional<SharedSandboxDefinition<S>, "backend">;
|
|
166
7
|
/**
|
|
167
8
|
* Defines a sandbox configuration.
|
|
168
9
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ScheduleDefinition } from "#public/definitions/schedule.js";
|
|
2
2
|
import { type SkillDefinition } from "#public/definitions/skill.js";
|
|
3
|
-
import { type
|
|
3
|
+
import { type InstructionsDefinition } from "#public/definitions/instructions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Parsed markdown document with optional YAML frontmatter.
|
|
6
6
|
*/
|
|
@@ -24,11 +24,11 @@ export interface ParsedMarkdownDocument {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function parseMarkdownDocument(source: string): ParsedMarkdownDocument;
|
|
26
26
|
/**
|
|
27
|
-
* Lowers authored
|
|
28
|
-
* shape.
|
|
29
|
-
* carries a `name`.
|
|
27
|
+
* Lowers authored instructions prompt markdown into the shared public
|
|
28
|
+
* definition shape. Instructions identity is path-derived, so the lowered
|
|
29
|
+
* definition never carries a `name`.
|
|
30
30
|
*/
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function lowerInstructionsMarkdown(markdown: string): InstructionsDefinition;
|
|
32
32
|
/**
|
|
33
33
|
* Optional input for {@link lowerSkillMarkdown}.
|
|
34
34
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import grayMatter from "gray-matter";
|
|
2
|
-
import { normalizeScheduleDefinition, normalizeSkillDefinition,
|
|
2
|
+
import { normalizeScheduleDefinition, normalizeSkillDefinition, normalizeInstructionsDefinition, } from "#internal/authored-definition/core.js";
|
|
3
3
|
import { isObject } from "#shared/guards.js";
|
|
4
4
|
import { defineSchedule } from "#public/definitions/schedule.js";
|
|
5
5
|
import { defineSkill } from "#public/definitions/skill.js";
|
|
6
|
-
import {
|
|
6
|
+
import { defineInstructions, } from "#public/definitions/instructions.js";
|
|
7
7
|
const CLOSED_FRONTMATTER_PATTERN = /^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/;
|
|
8
8
|
/**
|
|
9
9
|
* Parses markdown with optional YAML frontmatter.
|
|
@@ -36,12 +36,12 @@ export function parseMarkdownDocument(source) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Lowers authored
|
|
40
|
-
* shape.
|
|
41
|
-
* carries a `name`.
|
|
39
|
+
* Lowers authored instructions prompt markdown into the shared public
|
|
40
|
+
* definition shape. Instructions identity is path-derived, so the lowered
|
|
41
|
+
* definition never carries a `name`.
|
|
42
42
|
*/
|
|
43
|
-
export function
|
|
44
|
-
return
|
|
43
|
+
export function lowerInstructionsMarkdown(markdown) {
|
|
44
|
+
return defineInstructions(normalizeInstructionsDefinition({ markdown }, "Expected authored instructions markdown to match the public Ash shape."));
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Lowers authored skill markdown into the shared public definition shape.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instructions prompt authoring helpers for `agent/instructions.ts` files.
|
|
3
|
+
*/
|
|
4
|
+
export { defineInstructions, type InstructionsDefinition,
|
|
5
|
+
/** @deprecated Use {@link defineInstructions} instead. */
|
|
6
|
+
defineSystem,
|
|
7
|
+
/** @deprecated Use {@link InstructionsDefinition} instead. */
|
|
8
|
+
type SystemDefinition, } from "#public/definitions/instructions.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `agent/sandbox/sandbox.ts` when paired with a `workspace/` folder).
|
|
4
4
|
*/
|
|
5
5
|
export { getSandbox } from "#context/accessors.js";
|
|
6
|
-
export { defineSandbox, type SandboxBootstrapContext, type SandboxBootstrapUseFn, type SandboxBootstrapUseOptions, type SandboxCommandResult, type SandboxDefinition, type SandboxNetworkPolicy, type SandboxReadFileOptions, type SandboxSession, type SandboxSessionContext, type SandboxSessionUseFn, type SandboxSessionUseOptions, } from "#public/definitions/sandbox.js";
|
|
6
|
+
export { defineSandbox, type SandboxBootstrapContext, type SandboxBootstrapUseFn, type SandboxBootstrapUseOptions, type SandboxCommandOptions, type SandboxCommandResult, type SandboxDefinition, type SandboxNetworkPolicy, type SandboxReadFileOptions, type SandboxSession, type SandboxSessionContext, type SandboxSessionUseFn, type SandboxSessionUseOptions, } from "#public/definitions/sandbox.js";
|
|
7
7
|
export type { SandboxBackend, SandboxBackendCreateInput, SandboxBackendHandle, SandboxBackendPrewarmInput, SandboxBackendRuntimeContext, SandboxBackendSessionState, SandboxSeedFile, } from "#public/definitions/sandbox-backend.js";
|
|
8
8
|
export { SandboxTemplateNotProvisionedError } from "#public/definitions/sandbox-backend.js";
|
|
9
9
|
export { defaultBackend } from "#public/sandbox/backends/default.js";
|
|
@@ -19,7 +19,7 @@ export function createResolvedRuntimeTurnAgent(input) {
|
|
|
19
19
|
id: agent.config.name,
|
|
20
20
|
instructions: composeRuntimeBasePrompt({
|
|
21
21
|
connections: agent.connections,
|
|
22
|
-
|
|
22
|
+
instructions: agent.instructions,
|
|
23
23
|
skills: agent.skills,
|
|
24
24
|
toolsAvailable: input.tools.length > 0,
|
|
25
25
|
workspaceSpec: agent.workspaceSpec,
|
|
@@ -39,8 +39,8 @@ function createResolvedTurnMetadata(agent) {
|
|
|
39
39
|
...agent.config.metadata,
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
if (agent.
|
|
43
|
-
metadata.
|
|
42
|
+
if (agent.instructions !== undefined) {
|
|
43
|
+
metadata.instructionsName = agent.instructions.name;
|
|
44
44
|
}
|
|
45
45
|
if (agent.skills.length > 0) {
|
|
46
46
|
metadata.skillNames = agent.skills.map((skill) => skill.name);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type { ResolvedConnectionDefinition,
|
|
1
|
+
import type { ResolvedConnectionDefinition, ResolvedInstructions, ResolvedSkillDefinition } from "#runtime/types.js";
|
|
2
2
|
import type { WorkspaceRuntimeSpec } from "#runtime/workspace/types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Input for composing the base authored
|
|
4
|
+
* Input for composing the base authored instructions prompt for one
|
|
5
|
+
* resolved agent.
|
|
5
6
|
*/
|
|
6
7
|
export interface ComposeRuntimeBasePromptInput {
|
|
7
8
|
connections?: readonly ResolvedConnectionDefinition[];
|
|
8
|
-
|
|
9
|
+
instructions?: ResolvedInstructions;
|
|
9
10
|
skills?: readonly ResolvedSkillDefinition[];
|
|
10
11
|
toolsAvailable?: boolean;
|
|
11
12
|
workspaceSpec?: WorkspaceRuntimeSpec;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* Composes the authored base prompt from the resolved
|
|
15
|
+
* Composes the authored base prompt from the resolved instructions source
|
|
15
16
|
* without flattening skills into always-on instructions.
|
|
16
17
|
*/
|
|
17
18
|
export declare function composeRuntimeBasePrompt(input: ComposeRuntimeBasePromptInput): readonly string[];
|
|
@@ -3,27 +3,27 @@ import { createWorkspacePromptSection } from "#runtime/workspace/spec.js";
|
|
|
3
3
|
import { formatConnectionsSection } from "#runtime/prompt/connections.js";
|
|
4
4
|
const PARALLEL_ACTION_INSTRUCTION = "Tool execution\nA single tool or subagent call runs as one serial action. If you call multiple independent tools or subagents in one response, Ash treats that batch as parallel work. Only batch work that is independent and does not rely on another call in the same response.";
|
|
5
5
|
/**
|
|
6
|
-
* Composes the authored base prompt from the resolved
|
|
6
|
+
* Composes the authored base prompt from the resolved instructions source
|
|
7
7
|
* without flattening skills into always-on instructions.
|
|
8
8
|
*/
|
|
9
9
|
export function composeRuntimeBasePrompt(input) {
|
|
10
10
|
return [
|
|
11
|
-
...
|
|
11
|
+
...createInstructionsPromptBlocks(input.instructions),
|
|
12
12
|
...createWorkspacePromptBlocks(input.workspaceSpec),
|
|
13
13
|
...(input.toolsAvailable ? [PARALLEL_ACTION_INSTRUCTION] : []),
|
|
14
14
|
...createConnectionsPromptBlocks(input.connections),
|
|
15
15
|
...createSkillsPromptBlocks(input.skills),
|
|
16
16
|
];
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
18
|
+
function createInstructionsPromptBlocks(instructions) {
|
|
19
|
+
if (instructions === undefined) {
|
|
20
20
|
return [];
|
|
21
21
|
}
|
|
22
|
-
const markdown =
|
|
22
|
+
const markdown = instructions.markdown.trim();
|
|
23
23
|
if (markdown.length === 0) {
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
|
-
return [`
|
|
26
|
+
return [`Instructions (${instructions.name})\n${markdown}`];
|
|
27
27
|
}
|
|
28
28
|
function createWorkspacePromptBlocks(workspaceSpec) {
|
|
29
29
|
if (workspaceSpec === undefined) {
|
|
@@ -41,7 +41,7 @@ export async function resolveAgent(input) {
|
|
|
41
41
|
const authoredSandbox = input.manifest.sandbox === null
|
|
42
42
|
? null
|
|
43
43
|
: await resolveSandboxDefinition(input.manifest.sandbox, input.moduleMap, input.nodeId);
|
|
44
|
-
const
|
|
44
|
+
const instructions = createResolvedInstructions(input.manifest.instructions);
|
|
45
45
|
const workspaceResourceRoot = input.manifest.workspaceResourceRoot;
|
|
46
46
|
const resolvedAgent = {
|
|
47
47
|
channels: resolvedChannels,
|
|
@@ -61,21 +61,21 @@ export async function resolveAgent(input) {
|
|
|
61
61
|
tools: resolvedTools,
|
|
62
62
|
workspaceSpec: { rootEntries: [...workspaceResourceRoot.rootEntries] },
|
|
63
63
|
};
|
|
64
|
-
if (
|
|
65
|
-
return { ...resolvedAgent,
|
|
64
|
+
if (instructions !== undefined) {
|
|
65
|
+
return { ...resolvedAgent, instructions };
|
|
66
66
|
}
|
|
67
67
|
return resolvedAgent;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
if (
|
|
69
|
+
function createResolvedInstructions(instructions) {
|
|
70
|
+
if (instructions === undefined) {
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
73
|
return {
|
|
74
|
-
name:
|
|
75
|
-
logicalPath:
|
|
76
|
-
markdown:
|
|
77
|
-
sourceId:
|
|
78
|
-
sourceKind:
|
|
74
|
+
name: instructions.name,
|
|
75
|
+
logicalPath: instructions.logicalPath,
|
|
76
|
+
markdown: instructions.markdown,
|
|
77
|
+
sourceId: instructions.sourceId,
|
|
78
|
+
sourceKind: instructions.sourceKind,
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function createResolvedAgentConfig(manifest) {
|
|
@@ -3,8 +3,6 @@ import type { ChannelAdapter } from "#channel/adapter.js";
|
|
|
3
3
|
import type { DiscoverDiagnosticsSummary } from "#discover/diagnostics.js";
|
|
4
4
|
import type { ChannelMethod, Route, RouteContext } from "#public/definitions/channel.js";
|
|
5
5
|
import type { RouteHandler } from "#channel/routes.js";
|
|
6
|
-
import type { SandboxBootstrapContext, SandboxSessionContext } from "#public/definitions/sandbox.js";
|
|
7
|
-
import type { SandboxBackend } from "#public/definitions/sandbox-backend.js";
|
|
8
6
|
import type { LifecycleHooks, StreamEventHook } from "#public/definitions/hook.js";
|
|
9
7
|
import type { CompactionHookInput, CompactionHookResult, NeedsApprovalContext, ToolRetentionPolicy } from "#public/definitions/tool.js";
|
|
10
8
|
import type { AuthorizationDefinition, HeadersDefinition, ToolFilterDefinition } from "#runtime/connections/types.js";
|
|
@@ -16,17 +14,21 @@ import type { SourceRef, ModuleSourceRef, SkillPackageSourceRef, MarkdownSourceR
|
|
|
16
14
|
import type { InternalSkillDefinition } from "#shared/skill-definition.js";
|
|
17
15
|
import type { InternalAgentDefinition } from "#shared/agent-definition.js";
|
|
18
16
|
import type { InternalToolDefinitionWithExecuteFn } from "#shared/tool-definition.js";
|
|
17
|
+
import type { SandboxDefinition } from "#shared/sandbox-definition.js";
|
|
18
|
+
import type { SandboxSession } from "#shared/sandbox-session.js";
|
|
19
19
|
/**
|
|
20
20
|
* Runtime-owned source ref describing one additive config module import.
|
|
21
21
|
*/
|
|
22
22
|
export type ResolvedModuleSourceRef = Readonly<ModuleSourceRef>;
|
|
23
23
|
/**
|
|
24
|
-
* Authored
|
|
24
|
+
* Authored instructions prompt resolved from `instructions.md` or
|
|
25
|
+
* `instructions.{ts,...}`.
|
|
25
26
|
*
|
|
26
|
-
* Module-backed
|
|
27
|
-
* markdown is captured here. Runtime never re-evaluates
|
|
27
|
+
* Module-backed instructions sources are executed once at build time —
|
|
28
|
+
* the resulting markdown is captured here. Runtime never re-evaluates
|
|
29
|
+
* the module.
|
|
28
30
|
*/
|
|
29
|
-
export type
|
|
31
|
+
export type ResolvedInstructions = Readonly<SourceRef & {
|
|
30
32
|
name: string;
|
|
31
33
|
markdown: string;
|
|
32
34
|
} & (Omit<MarkdownSourceRef<undefined>, "definition"> | ModuleSourceRef)>;
|
|
@@ -77,18 +79,15 @@ export interface ResolvedConnectionDefinition extends ResolvedModuleSourceRef {
|
|
|
77
79
|
* map.
|
|
78
80
|
*
|
|
79
81
|
* The resolved `backend` is non-optional: every sandbox in the runtime
|
|
80
|
-
* graph carries a concrete
|
|
82
|
+
* graph carries a concrete SandboxBackend value, even when the
|
|
81
83
|
* authored definition omits `backend`. The unauthored case is filled
|
|
82
84
|
* in by `defaultBackend()` (which itself selects between
|
|
83
85
|
* `vercelBackend()` and `localBackend()` based on the current
|
|
84
86
|
* environment).
|
|
85
87
|
*/
|
|
86
|
-
export
|
|
87
|
-
readonly backend: SandboxBackend;
|
|
88
|
-
readonly bootstrap?: (input: SandboxBootstrapContext) => Promise<void> | void;
|
|
88
|
+
export type ResolvedSandboxDefinition = Readonly<SandboxDefinition<SandboxSession>> & ResolvedModuleSourceRef & {
|
|
89
89
|
readonly description?: string;
|
|
90
|
-
|
|
91
|
-
}
|
|
90
|
+
};
|
|
92
91
|
/**
|
|
93
92
|
* Runtime-owned authored tool definition resolved from a compiled module map.
|
|
94
93
|
* A tool without `execute` is surfaced to the client and never executed by Ash.
|
|
@@ -235,10 +234,11 @@ export interface ResolvedAgent {
|
|
|
235
234
|
readonly disabledFrameworkTools: readonly string[];
|
|
236
235
|
readonly metadata: ResolvedAgentMetadata;
|
|
237
236
|
/**
|
|
238
|
-
* Authored
|
|
239
|
-
* or `undefined` when the agent does not
|
|
237
|
+
* Authored instructions prompt resolved from `instructions.md` or
|
|
238
|
+
* `instructions.{ts,...}`, or `undefined` when the agent does not
|
|
239
|
+
* declare one.
|
|
240
240
|
*/
|
|
241
|
-
readonly
|
|
241
|
+
readonly instructions?: ResolvedInstructions;
|
|
242
242
|
/**
|
|
243
243
|
* Authored sandbox override for this agent, when one exists. `null`
|
|
244
244
|
* means the agent uses the framework default sandbox unchanged.
|