experimental-ash 0.55.2 → 0.56.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/CHANGELOG.md +27 -0
- package/LICENSE +202 -0
- package/dist/docs/public/meta.json +1 -0
- package/dist/docs/public/onboarding.md +7 -5
- package/dist/docs/public/tools.mdx +10 -2
- package/dist/skills/agent/SKILL.md +169 -0
- package/dist/skills/agent/references/deployment.md +35 -0
- package/dist/skills/agent/references/getting-started.md +58 -0
- package/dist/skills/agent/references/project-layout.md +35 -0
- package/dist/skills/agent/references/runtime-model.md +24 -0
- package/dist/skills/agent/references/skills.md +26 -0
- package/dist/skills/agent/scripts/add-to-existing-project.sh +12 -0
- package/dist/skills/agent/scripts/bootstrap-from-npm.sh +9 -0
- package/dist/skills/agent/scripts/verify-local-agent.sh +16 -0
- package/dist/skills/ash-add-agent/SKILL.md +166 -0
- package/dist/skills/ash-add-next/SKILL.md +137 -0
- package/dist/skills/framework/SKILL.md +93 -0
- package/dist/skills/framework/references/architecture.md +14 -0
- package/dist/skills/framework/references/discovery-and-compilation.md +15 -0
- package/dist/skills/framework/references/quality-gates.md +13 -0
- package/dist/skills/framework/references/runtime-model.md +12 -0
- package/dist/skills/framework/references/workspace-and-sandbox.md +25 -0
- package/dist/skills/framework/scripts/framework-review-checklist.sh +13 -0
- package/dist/skills/framework/scripts/run-framework-gates.sh +8 -0
- package/dist/src/client/output-schema.js +1 -1
- package/dist/src/compiler/compile-from-memory.d.ts +2 -0
- package/dist/src/compiler/compile-from-memory.js +1 -1
- package/dist/src/compiler/manifest.d.ts +4 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/compiler/normalize-subagent.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/keys.d.ts +1 -0
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/session.js +1 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/harness/code-mode-lifecycle.js +1 -1
- package/dist/src/harness/code-mode.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/harness/provider-tools.d.ts +7 -1
- package/dist/src/harness/provider-tools.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/harness/tools.d.ts +2 -0
- package/dist/src/harness/tools.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/packages/ash-scaffold/src/channels.js +2 -2
- package/dist/src/packages/ash-scaffold/src/steps/run-add-to-agent.js +1 -1
- package/dist/src/packages/ash-scaffold/src/web-template.js +2 -2
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/definitions/tool.d.ts +21 -1
- package/dist/src/public/tools/define-bash-tool.js +1 -1
- package/dist/src/public/tools/define-glob-tool.js +1 -1
- package/dist/src/public/tools/define-grep-tool.js +1 -1
- package/dist/src/public/tools/define-read-file-tool.js +1 -1
- package/dist/src/public/tools/define-write-file-tool.js +1 -1
- package/dist/src/public/tools/internal.js +1 -1
- package/dist/src/runtime/agent/mock-model-adapter.js +1 -1
- package/dist/src/runtime/connections/authorization-tokens.d.ts +8 -0
- package/dist/src/runtime/connections/authorization-tokens.js +1 -1
- package/dist/src/runtime/connections/mcp-client.d.ts +14 -0
- package/dist/src/runtime/connections/mcp-client.js +1 -1
- package/dist/src/runtime/connections/types.d.ts +1 -0
- package/dist/src/runtime/framework-tools/ask-question.d.ts +4 -0
- package/dist/src/runtime/framework-tools/ask-question.js +1 -1
- package/dist/src/runtime/framework-tools/bash.d.ts +5 -0
- package/dist/src/runtime/framework-tools/bash.js +1 -1
- package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +1 -0
- package/dist/src/runtime/framework-tools/connection-search-dynamic.js +1 -1
- package/dist/src/runtime/framework-tools/final-output.js +1 -1
- package/dist/src/runtime/framework-tools/glob.d.ts +5 -0
- package/dist/src/runtime/framework-tools/glob.js +2 -2
- package/dist/src/runtime/framework-tools/grep.d.ts +5 -0
- package/dist/src/runtime/framework-tools/grep.js +2 -2
- package/dist/src/runtime/framework-tools/read-file.d.ts +5 -0
- package/dist/src/runtime/framework-tools/read-file.js +2 -2
- package/dist/src/runtime/framework-tools/skill.d.ts +2 -0
- package/dist/src/runtime/framework-tools/skill.js +1 -1
- package/dist/src/runtime/framework-tools/todo.d.ts +2 -0
- package/dist/src/runtime/framework-tools/todo.js +2 -2
- package/dist/src/runtime/framework-tools/web-fetch.d.ts +3 -0
- package/dist/src/runtime/framework-tools/web-fetch.js +2 -2
- package/dist/src/runtime/framework-tools/web-search.d.ts +17 -0
- package/dist/src/runtime/framework-tools/web-search.js +1 -1
- package/dist/src/runtime/framework-tools/write-file.d.ts +5 -0
- package/dist/src/runtime/framework-tools/write-file.js +2 -2
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/subagents/registry.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/runtime/types.d.ts +5 -0
- package/dist/src/shared/dynamic-tool-definition.d.ts +2 -1
- package/dist/src/shared/json-schema.d.ts +3 -1
- package/dist/src/shared/json-schema.js +1 -1
- package/dist/src/shared/tool-definition.d.ts +10 -2
- package/package.json +20 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
cat <<'EOF'
|
|
5
|
+
Common local Ash verification commands:
|
|
6
|
+
|
|
7
|
+
ash info
|
|
8
|
+
ash build
|
|
9
|
+
pnpm dev
|
|
10
|
+
|
|
11
|
+
Optional durable run smoke test:
|
|
12
|
+
|
|
13
|
+
curl -X POST http://127.0.0.1:3000/.well-known/ash/v1/message \
|
|
14
|
+
-H 'content-type: application/json' \
|
|
15
|
+
-d '{"message":"Hello"}'
|
|
16
|
+
EOF
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ash-add-agent
|
|
3
|
+
description: Add an Ash agent to an existing Next.js app. Use when turning a Next app into a combined Next.js + Ash app.
|
|
4
|
+
doc:
|
|
5
|
+
title: Add Agent to Next.js
|
|
6
|
+
description: Add Ash to an existing Next.js app while keeping Next.js as the primary web app.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Add Ash to an existing Next.js app while keeping Next as the primary web app. Preserve existing Next config, scripts, aliases, and app files unless they conflict with Ash.
|
|
10
|
+
|
|
11
|
+
## Target
|
|
12
|
+
|
|
13
|
+
```txt
|
|
14
|
+
agent/
|
|
15
|
+
agent.ts
|
|
16
|
+
channels/
|
|
17
|
+
ash.ts
|
|
18
|
+
instructions.md
|
|
19
|
+
app/
|
|
20
|
+
next.config.ts
|
|
21
|
+
package.json
|
|
22
|
+
tsconfig.json
|
|
23
|
+
vercel.json # generated/updated by withAsh()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
1. Install Ash:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm add experimental-ash ai zod
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Add the agent root:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// agent/agent.ts
|
|
38
|
+
import { defineAgent } from "experimental-ash";
|
|
39
|
+
|
|
40
|
+
export default defineAgent({
|
|
41
|
+
model: "openai/gpt-5.4-mini",
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```md
|
|
46
|
+
<!-- agent/instructions.md -->
|
|
47
|
+
|
|
48
|
+
You are a helpful assistant running inside an Ash agent.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use the model requested by the user or the project standard.
|
|
52
|
+
|
|
53
|
+
3. Add the Ash HTTP channel:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// agent/channels/ash.ts
|
|
57
|
+
import { ashChannel } from "experimental-ash/channels/ash";
|
|
58
|
+
import { type AuthFn, localDev, vercelOidc } from "experimental-ash/channels/auth";
|
|
59
|
+
|
|
60
|
+
function exampleProductionAuth(): AuthFn<Request> {
|
|
61
|
+
return () => {
|
|
62
|
+
if (process.env.VERCEL_ENV === "production") {
|
|
63
|
+
throw new Error(
|
|
64
|
+
"Configure production auth in agent/channels/ash.ts (e.g. Auth.js or Clerk).",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default ashChannel({
|
|
72
|
+
auth: [localDev(), vercelOidc(), exampleProductionAuth()],
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
An authored `agent/channels/ash.ts` replaces Ash's framework default `ash` channel. Keep `localDev()` for localhost and the REPL, keep `vercelOidc()` so Vercel services can reach the deployed agent, and replace `exampleProductionAuth()` with the app's real user auth before production. If the app already uses Auth.js, Clerk, or another session provider, wire it here instead of leaving the placeholder.
|
|
77
|
+
|
|
78
|
+
4. Merge package imports only when agent files use `#...` aliases:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"imports": {
|
|
83
|
+
"#*": "./agent/*",
|
|
84
|
+
"#evals/*": "./evals/*"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
5. Wrap `next.config.ts` with `withAsh()`:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import type { NextConfig } from "next";
|
|
93
|
+
import { withAsh } from "experimental-ash/next";
|
|
94
|
+
|
|
95
|
+
const nextConfig: NextConfig = {
|
|
96
|
+
// existing config
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default withAsh(nextConfig);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
If config is already wrapped by other plugins, make `withAsh()` outermost:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
export default withAsh(withSomePlugin(nextConfig));
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If config is an async function, wrap the function export with `withAsh()` rather than rewriting its internals.
|
|
109
|
+
|
|
110
|
+
6. Keep Next as the main command and add Ash-specific scripts:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"scripts": {
|
|
115
|
+
"dev": "next dev",
|
|
116
|
+
"build": "next build",
|
|
117
|
+
"start": "next start",
|
|
118
|
+
"dev:ash": "ash dev",
|
|
119
|
+
"build:ash": "ash build",
|
|
120
|
+
"info:ash": "ash info",
|
|
121
|
+
"typecheck": "tsc --noEmit"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Keep an existing `typecheck` unless it excludes `agent/**/*.ts`.
|
|
127
|
+
|
|
128
|
+
7. Update `tsconfig.json` without clobbering existing aliases:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"include": [
|
|
133
|
+
"next-env.d.ts",
|
|
134
|
+
"**/*.ts",
|
|
135
|
+
"**/*.tsx",
|
|
136
|
+
".ash/**/*.d.ts",
|
|
137
|
+
".next/types/**/*.ts",
|
|
138
|
+
".next/dev/types/**/*.ts"
|
|
139
|
+
],
|
|
140
|
+
"compilerOptions": {
|
|
141
|
+
"paths": {
|
|
142
|
+
"@/*": ["./*"],
|
|
143
|
+
"#*": ["./agent/*"],
|
|
144
|
+
"#evals/*": ["./evals/*"]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Add `paths` only if the project uses those aliases.
|
|
151
|
+
|
|
152
|
+
8. Let `withAsh()` generate or update `vercel.json`.
|
|
153
|
+
|
|
154
|
+
After adding `withAsh()`, run `pnpm dev` or the relevant build command. Do not hand-author the Vercel services config unless generation fails or the user explicitly wants manual control. If `vercel.json` is created or changed, review and commit it.
|
|
155
|
+
|
|
156
|
+
## Verify
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pnpm install
|
|
160
|
+
pnpm dev
|
|
161
|
+
curl http://localhost:3000/ash/v1/health
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Use `pnpm info:ash` or `pnpm dev:ash` to inspect Ash directly.
|
|
165
|
+
|
|
166
|
+
If `agent/channels/ash.ts` throws in production, that is intentional until production auth is wired.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ash-add-next
|
|
3
|
+
description: Add Next.js to an existing Ash agent project. Use when turning an Ash-only app into a combined Ash + Next.js app.
|
|
4
|
+
doc:
|
|
5
|
+
title: Add Next.js frontend to Ash
|
|
6
|
+
description: Add a Next.js frontend to an existing Ash agent project.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Convert an Ash-only project into a combined Next.js app plus Ash agent. Preserve existing `agent/` files unless the user asks to change them.
|
|
10
|
+
|
|
11
|
+
## Target
|
|
12
|
+
|
|
13
|
+
```txt
|
|
14
|
+
agent/
|
|
15
|
+
agent.ts
|
|
16
|
+
instructions.md
|
|
17
|
+
app/
|
|
18
|
+
globals.css
|
|
19
|
+
layout.tsx
|
|
20
|
+
page.tsx
|
|
21
|
+
next.config.ts
|
|
22
|
+
next-env.d.ts
|
|
23
|
+
package.json
|
|
24
|
+
tsconfig.json
|
|
25
|
+
vercel.json # generated/updated by withAsh()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Steps
|
|
29
|
+
|
|
30
|
+
1. Install Next dependencies:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add next react react-dom
|
|
34
|
+
pnpm add -D typescript @types/react @types/react-dom
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Align versions with the installed `experimental-ash` if peer warnings appear.
|
|
38
|
+
|
|
39
|
+
2. Add minimal App Router files:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
// app/layout.tsx
|
|
43
|
+
import type { Metadata } from "next";
|
|
44
|
+
import "./globals.css";
|
|
45
|
+
|
|
46
|
+
export const metadata: Metadata = {
|
|
47
|
+
title: "Ash + Next.js",
|
|
48
|
+
description: "Next.js app with an Ash agent",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
52
|
+
return (
|
|
53
|
+
<html lang="en">
|
|
54
|
+
<body>{children}</body>
|
|
55
|
+
</html>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// app/page.tsx
|
|
62
|
+
export default function Page() {
|
|
63
|
+
return <main style={{ padding: 24 }}>Ash + Next.js</main>;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Create `app/globals.css` if imported. Add `next-env.d.ts` with the standard Next references.
|
|
68
|
+
|
|
69
|
+
3. Add `withAsh()`:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
// next.config.ts
|
|
73
|
+
import type { NextConfig } from "next";
|
|
74
|
+
import { withAsh } from "experimental-ash/next";
|
|
75
|
+
|
|
76
|
+
const nextConfig: NextConfig = {};
|
|
77
|
+
|
|
78
|
+
export default withAsh(nextConfig);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
4. Make Next own the main scripts:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"scripts": {
|
|
86
|
+
"dev": "next dev",
|
|
87
|
+
"dev:ash": "ash dev",
|
|
88
|
+
"build": "next build",
|
|
89
|
+
"build:ash": "ash build",
|
|
90
|
+
"info:ash": "ash info",
|
|
91
|
+
"typecheck": "tsc --noEmit"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
5. Use a Next-compatible `tsconfig.json`, keep `.ash/**/*.d.ts` in `include`, and preserve Ash aliases:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"compilerOptions": {
|
|
101
|
+
"module": "esnext",
|
|
102
|
+
"moduleResolution": "bundler",
|
|
103
|
+
"jsx": "react-jsx",
|
|
104
|
+
"plugins": [{ "name": "next" }],
|
|
105
|
+
"paths": {
|
|
106
|
+
"@/*": ["./*"],
|
|
107
|
+
"#*": ["./agent/*"],
|
|
108
|
+
"#evals/*": ["./evals/*"]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"include": [
|
|
112
|
+
"next-env.d.ts",
|
|
113
|
+
"**/*.ts",
|
|
114
|
+
"**/*.tsx",
|
|
115
|
+
".ash/**/*.d.ts",
|
|
116
|
+
".next/types/**/*.ts",
|
|
117
|
+
".next/dev/types/**/*.ts"
|
|
118
|
+
],
|
|
119
|
+
"exclude": ["node_modules"]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Merge matching `package.json` `imports` when Ash files use `#...`.
|
|
124
|
+
|
|
125
|
+
6. Let `withAsh()` generate or update `vercel.json`.
|
|
126
|
+
|
|
127
|
+
After adding `withAsh()`, run `pnpm dev` or the relevant build command. Do not hand-author the Vercel services config unless generation fails or the user explicitly wants manual control. If `vercel.json` is created or changed, review and commit it.
|
|
128
|
+
|
|
129
|
+
7. Ignore generated artifacts if needed: `.next`, `.ash`, `.output`, `*.tsbuildinfo`. Do not ignore `vercel.json` when it is generated for the app.
|
|
130
|
+
|
|
131
|
+
## Verify
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm install
|
|
135
|
+
pnpm dev
|
|
136
|
+
curl http://localhost:3000/ash/v1/health
|
|
137
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ash-framework
|
|
3
|
+
description: Internal Ash framework guide for contributors working on discovery, compilation, runtime behavior, `.ash` artifacts, sandbox/workflow plumbing, or other implementation details behind the public authored surface.
|
|
4
|
+
metadata:
|
|
5
|
+
author: Ash repo
|
|
6
|
+
version: "0.0.1"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Use this skill for implementation-facing Ash work.
|
|
10
|
+
|
|
11
|
+
## When to use this skill
|
|
12
|
+
|
|
13
|
+
Use this skill when the task changes or depends on Ash internals, including:
|
|
14
|
+
|
|
15
|
+
- discovery or validation behavior
|
|
16
|
+
- compiler outputs and `.ash` artifacts
|
|
17
|
+
- Nitro host or runtime integration
|
|
18
|
+
- runtime loading and turn preparation
|
|
19
|
+
- message execution and durable session behavior
|
|
20
|
+
- workspace or sandbox plumbing
|
|
21
|
+
- build and deploy behavior tied to framework internals
|
|
22
|
+
|
|
23
|
+
If the task is primarily about how an app author uses Ash, use the `ash-agent` skill instead.
|
|
24
|
+
|
|
25
|
+
## How to use this skill
|
|
26
|
+
|
|
27
|
+
1. Read the bundled internal references before making claims.
|
|
28
|
+
2. Preserve the architecture boundaries listed here.
|
|
29
|
+
3. Use the packaged scripts when validating the repo.
|
|
30
|
+
4. Update public docs too when user-facing behavior changes. When writing or
|
|
31
|
+
adding files under `/docs/public`, follow the format spelled out in the
|
|
32
|
+
`ash-agent` skill's "Writing or updating public docs" section — each new
|
|
33
|
+
file needs frontmatter (`title` + `description`), a slot in
|
|
34
|
+
`/docs/public/meta.json#pages`, and an optional `url:` override if its
|
|
35
|
+
filename does not match the intended site URL. Run `pnpm docs:check` to
|
|
36
|
+
validate.
|
|
37
|
+
|
|
38
|
+
## Core boundaries to preserve
|
|
39
|
+
|
|
40
|
+
- discovery is filesystem-only and must not execute authored modules
|
|
41
|
+
- compiler output is framework-owned and inspectable
|
|
42
|
+
- runtime consumes compiled artifacts instead of rediscovering authored files per request
|
|
43
|
+
- authored dynamic code runs inside framework-owned execution boundaries
|
|
44
|
+
- workspace and sandbox are different runtime surfaces
|
|
45
|
+
- the sandbox currently uses local and Vercel backends
|
|
46
|
+
- message execution is durable and asynchronous
|
|
47
|
+
|
|
48
|
+
## Common mistakes to avoid
|
|
49
|
+
|
|
50
|
+
- reintroducing authored-module execution during discovery
|
|
51
|
+
- making request paths depend on rediscovery or recompilation
|
|
52
|
+
- explaining Ash purely from internal architecture when the task is user-facing
|
|
53
|
+
- treating `lib/` as workspace-mounted content
|
|
54
|
+
- adding unnecessary step boundaries for pure data reshaping work
|
|
55
|
+
- confusing route auth with per-run ownership controls
|
|
56
|
+
- forgetting that artifacts are still useful for debugging compile failures
|
|
57
|
+
|
|
58
|
+
## Preferred references
|
|
59
|
+
|
|
60
|
+
Read these bundled references in roughly this order:
|
|
61
|
+
|
|
62
|
+
1. `references/architecture.md`
|
|
63
|
+
2. `references/discovery-and-compilation.md`
|
|
64
|
+
3. `references/runtime-model.md`
|
|
65
|
+
4. `references/workspace-and-sandbox.md`
|
|
66
|
+
5. `references/quality-gates.md`
|
|
67
|
+
|
|
68
|
+
## Runtime notes
|
|
69
|
+
|
|
70
|
+
- hosted Vercel builds are detected via `VERCEL` and write host output to `.vercel/output`
|
|
71
|
+
- local builds write host output to `.output`
|
|
72
|
+
- Vercel sandbox prewarm can happen at build time when the relevant deployment environment is present
|
|
73
|
+
- if hosted Vercel prewarm is attempted and fails, the build should fail instead of masking it
|
|
74
|
+
- workspace template-preparation is independent from sandbox backend selection
|
|
75
|
+
|
|
76
|
+
## Bundled scripts
|
|
77
|
+
|
|
78
|
+
Use these packaged scripts when helpful:
|
|
79
|
+
|
|
80
|
+
- `scripts/run-framework-gates.sh` - run the expected repo quality gates
|
|
81
|
+
- `scripts/framework-review-checklist.sh` - print the internal review checklist
|
|
82
|
+
|
|
83
|
+
## Supporting skills
|
|
84
|
+
|
|
85
|
+
When internal work touches adjacent systems, also load the relevant specialist skills.
|
|
86
|
+
Use `ai-sdk` for model and tool-calling work, and `workflow` for durable orchestration behavior.
|
|
87
|
+
|
|
88
|
+
## Completion checklist
|
|
89
|
+
|
|
90
|
+
- validate the architecture boundaries above are preserved
|
|
91
|
+
- update public docs when public behavior changes
|
|
92
|
+
- run the expected quality gates before considering the work done
|
|
93
|
+
- ensure public API changes are documented and covered by tests
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Architecture Reference
|
|
2
|
+
|
|
3
|
+
Ash separates authoring from execution.
|
|
4
|
+
|
|
5
|
+
High-level phases:
|
|
6
|
+
|
|
7
|
+
1. discovery
|
|
8
|
+
2. compilation
|
|
9
|
+
3. runtime loading
|
|
10
|
+
4. turn preparation
|
|
11
|
+
5. tool or action execution
|
|
12
|
+
6. durable workflow orchestration
|
|
13
|
+
|
|
14
|
+
This separation keeps the public authoring model simple while preserving runtime correctness.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Discovery And Compilation Reference
|
|
2
|
+
|
|
3
|
+
## Discovery
|
|
4
|
+
|
|
5
|
+
- reads authored files from disk
|
|
6
|
+
- validates structure and authored shapes
|
|
7
|
+
- must not execute authored modules
|
|
8
|
+
|
|
9
|
+
## Compilation
|
|
10
|
+
|
|
11
|
+
- writes framework-owned artifacts
|
|
12
|
+
- keeps artifacts inspectable for debugging
|
|
13
|
+
- must not persist secrets in compiled metadata
|
|
14
|
+
|
|
15
|
+
Do not make request handling depend on rediscovery or recompilation.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Runtime Model Reference
|
|
2
|
+
|
|
3
|
+
Runtime rules to preserve:
|
|
4
|
+
|
|
5
|
+
- the runtime consumes compiled artifacts
|
|
6
|
+
- message handling is durable and asynchronous
|
|
7
|
+
- tool execution pauses and resumes turns through framework-owned boundaries
|
|
8
|
+
- subagent work runs in child executions
|
|
9
|
+
- session state is carried through the durable runtime
|
|
10
|
+
- runtime state flows through one unified `AlsContext` container
|
|
11
|
+
- channels seed durable authored context in `onDeliver()`
|
|
12
|
+
- providers rebuild live step-local values from that durable context before each step
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Workspace And Sandbox Reference
|
|
2
|
+
|
|
3
|
+
Each Ash agent has exactly one sandbox. It is the live bash-style environment where the framework
|
|
4
|
+
`bash`, `read_file`, and `write_file` tools run, and where `getSandbox()` binds.
|
|
5
|
+
|
|
6
|
+
- workspace: the `/workspace` filesystem inside that sandbox
|
|
7
|
+
- sandbox: the isolated runtime that owns the workspace and lifecycle hooks
|
|
8
|
+
|
|
9
|
+
Authored override paths:
|
|
10
|
+
|
|
11
|
+
- `agent/sandbox/sandbox.ts` — optional definition override. When absent, the framework default is
|
|
12
|
+
used.
|
|
13
|
+
- `agent/sandbox/workspace/**` — optional seed files mirrored into the sandbox at session
|
|
14
|
+
bootstrap. Reserved: `agent/sandbox/workspace/skills/` — skills belong under `agent/skills/`.
|
|
15
|
+
|
|
16
|
+
Important constraints:
|
|
17
|
+
|
|
18
|
+
- `lib/` is import-only code, not workspace content.
|
|
19
|
+
- The sandbox is a provisioned runtime surface, not an ordinary directory.
|
|
20
|
+
- Do not collapse sandbox and workspace concepts together in docs or implementation.
|
|
21
|
+
- Sandbox backends are currently `local` and `vercel` only.
|
|
22
|
+
- Subagents each have their own independent sandbox. A subagent does not inherit the parent's
|
|
23
|
+
sandbox; different agents carry different skills and should not share a filesystem.
|
|
24
|
+
- There is no multi-sandbox configuration anymore. `defineBashTool`, `defineReadFileTool`, and
|
|
25
|
+
`defineWriteFileTool` do not take a `sandbox` option, and `getSandbox()` takes no arguments.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
cat <<'EOF'
|
|
5
|
+
Framework review checklist:
|
|
6
|
+
|
|
7
|
+
- discovery stays filesystem-only
|
|
8
|
+
- compiled artifacts remain the runtime contract
|
|
9
|
+
- no secrets land in compiled metadata
|
|
10
|
+
- workspace and sandbox stay separate concepts
|
|
11
|
+
- public docs are updated if user-facing behavior changed
|
|
12
|
+
- full quality gates run before completion
|
|
13
|
+
EOF
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";function normalizeOutputSchemaForRequest(t){return t===void 0?void 0:normalizeJsonSchemaDefinition(t)}function extractCompletedResult(e){let t;for(let n of e)isResultCompletedEvent(n)&&(t=n.data.result);return t}function isResultCompletedEvent(e){return e.type===`result.completed`}export{extractCompletedResult,normalizeOutputSchemaForRequest};
|
|
1
|
+
import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";function normalizeOutputSchemaForRequest(t){return t===void 0?void 0:normalizeJsonSchemaDefinition(t,`output`)}function extractCompletedResult(e){let t;for(let n of e)isResultCompletedEvent(n)&&(t=n.data.result);return t}function isResultCompletedEvent(e){return e.type===`result.completed`}export{extractCompletedResult,normalizeOutputSchemaForRequest};
|
|
@@ -46,6 +46,8 @@ export interface CompileFromMemoryToolInput {
|
|
|
46
46
|
* (lowered to `null` when omitted).
|
|
47
47
|
*/
|
|
48
48
|
readonly inputSchema?: JsonObject | null;
|
|
49
|
+
/** JSON-schema-like object describing the tool output. */
|
|
50
|
+
readonly outputSchema?: JsonObject;
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* Per-skill descriptor entry consumed by {@link compileFromMemory}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest}from"#compiler/manifest.js";function compileFromMemory(t){let n=t.appRoot??`/virtual/ash-memory-app`,r=t.agentRoot??`${n}/agent`,i=t.name??`memory-agent`,a={model:{id:t.model},name:i};t.outputSchema!==void 0&&(a.outputSchema=t.outputSchema);let o=(t.tools??[]).map(e=>({description:e.description??`${e.name} test tool.`,inputSchema:e.inputSchema??null,logicalPath:`tools/${e.name}.ts`,name:e.name,sourceId:createMemorySourceId(`tools/${e.name}.ts`),sourceKind:`module`}));return{manifest:createCompiledAgentManifest({agentRoot:r,appRoot:n,config:a,skills:(t.skills??[]).map(e=>({description:e.description,logicalPath:`skills/${e.name}.md`,markdown:e.markdown??`# ${e.name}\n`,name:e.name,sourceId:createMemorySourceId(`skills/${e.name}.md`),sourceKind:`markdown`})),tools:o}),moduleMap:{nodes:{[ROOT_COMPILED_AGENT_NODE_ID]:{modules:Object.fromEntries(o.map(e=>[e.sourceId,Object.freeze({})]))}}}}}function createMemorySourceId(e){return`memory::${e}`}export{compileFromMemory};
|
|
1
|
+
import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest}from"#compiler/manifest.js";function compileFromMemory(t){let n=t.appRoot??`/virtual/ash-memory-app`,r=t.agentRoot??`${n}/agent`,i=t.name??`memory-agent`,a={model:{id:t.model},name:i};t.outputSchema!==void 0&&(a.outputSchema=t.outputSchema);let o=(t.tools??[]).map(e=>({description:e.description??`${e.name} test tool.`,inputSchema:e.inputSchema??null,logicalPath:`tools/${e.name}.ts`,name:e.name,outputSchema:e.outputSchema,sourceId:createMemorySourceId(`tools/${e.name}.ts`),sourceKind:`module`}));return{manifest:createCompiledAgentManifest({agentRoot:r,appRoot:n,config:a,skills:(t.skills??[]).map(e=>({description:e.description,logicalPath:`skills/${e.name}.md`,markdown:e.markdown??`# ${e.name}\n`,name:e.name,sourceId:createMemorySourceId(`skills/${e.name}.md`),sourceKind:`markdown`})),tools:o}),moduleMap:{nodes:{[ROOT_COMPILED_AGENT_NODE_ID]:{modules:Object.fromEntries(o.map(e=>[e.sourceId,Object.freeze({})]))}}}}}function createMemorySourceId(e){return`memory::${e}`}export{compileFromMemory};
|
|
@@ -18,7 +18,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
|
|
|
18
18
|
/**
|
|
19
19
|
* Current compiled manifest schema version.
|
|
20
20
|
*/
|
|
21
|
-
export declare const COMPILED_AGENT_MANIFEST_VERSION =
|
|
21
|
+
export declare const COMPILED_AGENT_MANIFEST_VERSION = 26;
|
|
22
22
|
/**
|
|
23
23
|
* Compiled channel entry preserved in the compiled manifest.
|
|
24
24
|
*/
|
|
@@ -297,6 +297,7 @@ declare const compiledAgentNodeManifestSchema: z.ZodObject<{
|
|
|
297
297
|
inputSchema: z.ZodNullable<z.ZodType<import("../shared/json.js").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.js").JsonObject, unknown>>>;
|
|
298
298
|
logicalPath: z.ZodString;
|
|
299
299
|
name: z.ZodString;
|
|
300
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../shared/json.js").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.js").JsonObject, unknown>>>;
|
|
300
301
|
sourceId: z.ZodString;
|
|
301
302
|
sourceKind: z.ZodLiteral<"module">;
|
|
302
303
|
}, z.core.$strict>>;
|
|
@@ -403,10 +404,11 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
|
|
|
403
404
|
inputSchema: z.ZodNullable<z.ZodType<import("../shared/json.js").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.js").JsonObject, unknown>>>;
|
|
404
405
|
logicalPath: z.ZodString;
|
|
405
406
|
name: z.ZodString;
|
|
407
|
+
outputSchema: z.ZodOptional<z.ZodType<import("../shared/json.js").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.js").JsonObject, unknown>>>;
|
|
406
408
|
sourceId: z.ZodString;
|
|
407
409
|
sourceKind: z.ZodLiteral<"module">;
|
|
408
410
|
}, z.core.$strict>>;
|
|
409
|
-
version: z.ZodLiteral<
|
|
411
|
+
version: z.ZodLiteral<26>;
|
|
410
412
|
workspaceResourceRoot: z.ZodObject<{
|
|
411
413
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
412
414
|
logicalPath: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`ash-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=25,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`)]),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional()}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),experimental:z.object({codeMode:z.boolean().optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),source:moduleSourceRefSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(25),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,experimental:e.config.experimental===void 0?void 0:{codeMode:e.config.experimental.codeMode},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;(e.skills??[]).length>0&&t.add(`skills/`);for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:25}}function cloneCompiledRuntimeModelReference(e){return e.contextWindowTokens===void 0&&e.source===void 0&&e.providerOptions===void 0?{id:e.id}:e.source===void 0?e.providerOptions===void 0?{contextWindowTokens:e.contextWindowTokens,id:e.id}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:{...e.providerOptions}}:e.contextWindowTokens===void 0&&e.providerOptions===void 0?{id:e.id,source:{...e.source}}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:e.providerOptions===void 0?void 0:{...e.providerOptions},source:{...e.source}}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|
|
1
|
+
import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`ash-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=26,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`)]),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional()}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),experimental:z.object({codeMode:z.boolean().optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),source:moduleSourceRefSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(26),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,experimental:e.config.experimental===void 0?void 0:{codeMode:e.config.experimental.codeMode},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;(e.skills??[]).length>0&&t.add(`skills/`);for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:26}}function cloneCompiledRuntimeModelReference(e){return e.contextWindowTokens===void 0&&e.source===void 0&&e.providerOptions===void 0?{id:e.id}:e.source===void 0?e.providerOptions===void 0?{contextWindowTokens:e.contextWindowTokens,id:e.id}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:{...e.providerOptions}}:e.contextWindowTokens===void 0&&e.providerOptions===void 0?{id:e.id,source:{...e.source}}:{contextWindowTokens:e.contextWindowTokens,id:e.id,providerOptions:e.providerOptions===void 0?void 0:{...e.providerOptions},source:{...e.source}}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";var MissingAgentConfigModuleError=class extends Error{agentId;constructor(e){super(`Agent "${e}" does not have an agent.ts config module. The "model" field is required.`),this.name=`MissingAgentConfigModuleError`,this.agentId=e}};async function compileAgentConfig(e,r){if(e.configModule===void 0)throw new MissingAgentConfigModuleError(e.agentId);let i=normalizeAgentDefinition(await loadModuleBackedDefinition({agentRoot:e.agentRoot,kind:`agent config`,source:e.configModule}),`Expected the agent config export "${e.configModule.exportName??`default`}" from "${e.configModule.logicalPath}" to match the public Ash shape.`),o=await normalizeAuthoredModelReference({modelCatalog:r.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:i.modelContextWindowTokens,providerOptions:i.modelOptions?.providerOptions,source:e.configModule,value:i.model}),s={},c={compaction:s,model:o,name:e.agentId};return i.description!==void 0&&(c.description=i.description),i.experimental?.codeMode!==void 0&&(c.experimental={codeMode:i.experimental.codeMode}),i.build!==void 0&&(c.build={externalDependencies:i.build.externalDependencies===void 0?void 0:[...i.build.externalDependencies]}),i.outputSchema!==void 0&&(c.outputSchema=normalizeJsonSchemaDefinition(i.outputSchema)),c.source={exportName:e.configModule.exportName,sourceKind:`module`,logicalPath:e.configModule.logicalPath,sourceId:e.configModule.sourceId},i.compaction?.model!==void 0&&(s.model=await normalizeAuthoredModelReference({modelCatalog:r.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:i.compaction.modelContextWindowTokens,providerOptions:i.modelOptions?.providerOptions,source:e.configModule,value:i.compaction.model})),i.compaction?.thresholdPercent!==void 0&&(s.thresholdPercent=i.compaction.thresholdPercent),c}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,i=n.specificationVersion;if(i!==`v2`&&i!==`v3`&&i!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${t.logicalPath}" to provide a valid AI SDK language model.`);let a={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...a,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(a,e)}async function withCompiledRuntimeModelLimits(t,n){if(n.contextWindowTokens!==void 0)return{...t,contextWindowTokens:n.contextWindowTokens};let r;try{r=await n.modelCatalog.getModelLimits(t.id)}catch(r){throw Error(`Failed to load AI Gateway model metadata for ${n.purpose} "${t.id}". ${toErrorMessage(r)}`)}if(r===null)throw Error(`Cannot compile agent compaction because ${n.purpose} "${t.id}" does not have known AI Gateway context window metadata.`);return{...t,contextWindowTokens:r.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{MissingAgentConfigModuleError,compileAgentConfig};
|
|
1
|
+
import{toErrorMessage}from"#shared/errors.js";import{normalizeJsonSchemaDefinition}from"#shared/json-schema.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";var MissingAgentConfigModuleError=class extends Error{agentId;constructor(e){super(`Agent "${e}" does not have an agent.ts config module. The "model" field is required.`),this.name=`MissingAgentConfigModuleError`,this.agentId=e}};async function compileAgentConfig(e,r){if(e.configModule===void 0)throw new MissingAgentConfigModuleError(e.agentId);let i=normalizeAgentDefinition(await loadModuleBackedDefinition({agentRoot:e.agentRoot,kind:`agent config`,source:e.configModule}),`Expected the agent config export "${e.configModule.exportName??`default`}" from "${e.configModule.logicalPath}" to match the public Ash shape.`),o=await normalizeAuthoredModelReference({modelCatalog:r.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:i.modelContextWindowTokens,providerOptions:i.modelOptions?.providerOptions,source:e.configModule,value:i.model}),s={},c={compaction:s,model:o,name:e.agentId};return i.description!==void 0&&(c.description=i.description),i.experimental?.codeMode!==void 0&&(c.experimental={codeMode:i.experimental.codeMode}),i.build!==void 0&&(c.build={externalDependencies:i.build.externalDependencies===void 0?void 0:[...i.build.externalDependencies]}),i.outputSchema!==void 0&&(c.outputSchema=normalizeJsonSchemaDefinition(i.outputSchema,`output`)),c.source={exportName:e.configModule.exportName,sourceKind:`module`,logicalPath:e.configModule.logicalPath,sourceId:e.configModule.sourceId},i.compaction?.model!==void 0&&(s.model=await normalizeAuthoredModelReference({modelCatalog:r.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:i.compaction.modelContextWindowTokens,providerOptions:i.modelOptions?.providerOptions,source:e.configModule,value:i.compaction.model})),i.compaction?.thresholdPercent!==void 0&&(s.thresholdPercent=i.compaction.thresholdPercent),c}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,i=n.specificationVersion;if(i!==`v2`&&i!==`v3`&&i!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${t.logicalPath}" to provide a valid AI SDK language model.`);let a={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...a,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(a,e)}async function withCompiledRuntimeModelLimits(t,n){if(n.contextWindowTokens!==void 0)return{...t,contextWindowTokens:n.contextWindowTokens};let r;try{r=await n.modelCatalog.getModelLimits(t.id)}catch(r){throw Error(`Failed to load AI Gateway model metadata for ${n.purpose} "${t.id}". ${toErrorMessage(r)}`)}if(r===null)throw Error(`Cannot compile agent compaction because ${n.purpose} "${t.id}" does not have known AI Gateway context window metadata.`);return{...t,contextWindowTokens:r.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{MissingAgentConfigModuleError,compileAgentConfig};
|