@agentproto/app-kit 0.4.0 → 0.5.1
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 +46 -2
- package/dist/define-app.d.ts.map +1 -1
- package/dist/emit.d.ts +4 -1
- package/dist/emit.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +65 -4
- package/dist/index.mjs.map +1 -1
- package/dist/load-app.d.ts.map +1 -1
- package/dist/types.d.ts +47 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -87,6 +87,46 @@ by at least one agent. A dangling ref or an orphan workflow throws
|
|
|
87
87
|
`{ id }`), so a company, persona, or role rides along without app-kit depending
|
|
88
88
|
on each doctype package.
|
|
89
89
|
|
|
90
|
+
An app may also declare `requires: ["@acme/shared", ...]` — app ids that must be
|
|
91
|
+
applied to the same scope before this one can run. The runtime validates the
|
|
92
|
+
graph when mounting apps via `app_apply`.
|
|
93
|
+
|
|
94
|
+
## UI surfaces, artifacts, and dev-launch config
|
|
95
|
+
|
|
96
|
+
Beyond agents and workflows, an app can declare three optional surfaces that
|
|
97
|
+
round-trip through `emit` and `loadAppHandle` and are integrated into the
|
|
98
|
+
runtime app registry:
|
|
99
|
+
|
|
100
|
+
- **`ui`** — an HTML dashboard/panel. `html` is written to
|
|
101
|
+
`.agentproto/ui/index.html`; `APP.md` frontmatter carries the relative path
|
|
102
|
+
plus optional `title`, `description`, `tools`, and `csp`.
|
|
103
|
+
- **`artifacts`** — a list of artifact types the app's agents may produce,
|
|
104
|
+
declared for discovery.
|
|
105
|
+
- **`dev`** — one or more local launch recipes (`name`, `runtimeExecutable`,
|
|
106
|
+
`runtimeArgs`, `port`, `url`) for running the app in development.
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
export const dashboardApp = defineApp({
|
|
110
|
+
id: "@acme/dashboard",
|
|
111
|
+
name: "Operations Dashboard",
|
|
112
|
+
agents: [/* … */],
|
|
113
|
+
workflows: [/* … */],
|
|
114
|
+
ui: {
|
|
115
|
+
html: "<!doctype html><html>…</html>",
|
|
116
|
+
title: "Ops Dashboard",
|
|
117
|
+
tools: ["terminal_start", "agent_start"],
|
|
118
|
+
},
|
|
119
|
+
artifacts: [
|
|
120
|
+
{ type: "image/png", description: "Generated cover illustration" },
|
|
121
|
+
],
|
|
122
|
+
dev: {
|
|
123
|
+
launch: [
|
|
124
|
+
{ name: "web", runtimeExecutable: "npm", runtimeArgs: ["run", "dev"], port: 3000 },
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
90
130
|
## Consuming a bundle
|
|
91
131
|
|
|
92
132
|
### `handle.toMastraAgents(resolvers)` — run them
|
|
@@ -123,6 +163,7 @@ shared root `.agents/` convention:
|
|
|
123
163
|
<dir>/.agentproto/agents/reviewer/AGENT.md
|
|
124
164
|
<dir>/.agentproto/agents/fixer/AGENT.md
|
|
125
165
|
<dir>/.agentproto/workflows/review-and-fix/WORKFLOW.md (shared — a workflow may be run by several agents)
|
|
166
|
+
<dir>/.agentproto/ui/index.html (only when the app declares a `ui` surface)
|
|
126
167
|
```
|
|
127
168
|
|
|
128
169
|
The daemon's state root is migrating toward a `tenants/<t>/…` segment
|
|
@@ -140,8 +181,11 @@ description (APP.md). Because a `defineWorkflow` handle is pure data, the
|
|
|
140
181
|
`emit` always writes `<dir>/.agentproto/APP.md`: a `schema: "app/v1"` manifest
|
|
141
182
|
whose frontmatter lists every agent + workflow the app bundles as `{ id, path }`
|
|
142
183
|
refs (relative to `dir`), plus the app's own optional `id` / `name` / `version`
|
|
143
|
-
(defaults to `"0.1.0"` when `id` is set) / `description
|
|
144
|
-
|
|
184
|
+
(defaults to `"0.1.0"` when `id` is set) / `description`, an optional `requires`
|
|
185
|
+
array of app ids it depends on, and, when the app has a home workspace, that
|
|
186
|
+
workspace's `id`. When declared, `ui` metadata, `artifacts`, and `dev` launch
|
|
187
|
+
configs are also carried in the frontmatter (the `ui.html` document is written
|
|
188
|
+
next to `APP.md` and referenced by path). Nothing reads `AGENT.md`/`WORKFLOW.md`
|
|
145
189
|
files on their own today — `APP.md` is the thing a future daemon `app_install`
|
|
146
190
|
discovers and consumes.
|
|
147
191
|
|
package/dist/define-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-app.d.ts","sourceRoot":"","sources":["../src/define-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACT,aAAa,EAGd,MAAM,YAAY,CAAA;AAInB,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"define-app.d.ts","sourceRoot":"","sources":["../src/define-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACT,aAAa,EAGd,MAAM,YAAY,CAAA;AAInB,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS,CA4FvD;AA8GD,YAAY,EAAE,aAAa,EAAE,CAAA"}
|
package/dist/emit.d.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
*/
|
|
33
33
|
import type { WorkflowHandle } from "@agentproto/workflow";
|
|
34
34
|
import type { WorkspaceHandle } from "@agentproto/workspace";
|
|
35
|
-
import type { AgentEntry, EmittedApp } from "./types.js";
|
|
35
|
+
import type { AgentEntry, AppArtifactDecl, AppDevDefinition, AppUiDefinition, EmittedApp } from "./types.js";
|
|
36
36
|
interface EmitInput {
|
|
37
37
|
readonly agents: readonly AgentEntry[];
|
|
38
38
|
readonly workflows: readonly WorkflowHandle[];
|
|
@@ -42,6 +42,9 @@ interface EmitInput {
|
|
|
42
42
|
readonly version?: string;
|
|
43
43
|
readonly description?: string;
|
|
44
44
|
readonly requires?: readonly string[];
|
|
45
|
+
readonly ui?: AppUiDefinition;
|
|
46
|
+
readonly artifacts?: readonly AppArtifactDecl[];
|
|
47
|
+
readonly dev?: AppDevDefinition;
|
|
45
48
|
}
|
|
46
49
|
export declare function emitApp(app: EmitInput, dir: string): Promise<EmittedApp>;
|
|
47
50
|
export {};
|
package/dist/emit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG5G,UAAU,SAAS;IACjB,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAA;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,EAAE,CAAC,EAAE,eAAe,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,eAAe,EAAE,CAAA;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAA;CAChC;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAsF9E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,5 +40,5 @@ export { defineApp, AppDefinitionError } from "./define-app.js";
|
|
|
40
40
|
export { emitApp } from "./emit.js";
|
|
41
41
|
export { loadAppHandle, AppLoadError } from "./load-app.js";
|
|
42
42
|
export { refKey, stripOwner } from "./refs.js";
|
|
43
|
-
export type { AppDefinition, AppHandle, AgentEntry, DoctypeHandle, WorkspaceShorthand, WorkspaceInput, ToMastraAgentOptions, EmittedApp, } from "./types.js";
|
|
43
|
+
export type { AppDefinition, AppHandle, AgentEntry, DoctypeHandle, WorkspaceShorthand, WorkspaceInput, AppUiDefinition, AppArtifactDecl, AppDevLaunchConfig, AppDevDefinition, ToMastraAgentOptions, EmittedApp, } from "./types.js";
|
|
44
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC9C,YAAY,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC9C,YAAY,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -41,6 +41,21 @@ async function emitApp(app, dir) {
|
|
|
41
41
|
await writeFile(agentPath, toManifest(agent, body ?? ""), "utf8");
|
|
42
42
|
agentPaths[agent.id] = agentPath;
|
|
43
43
|
}
|
|
44
|
+
let uiPath;
|
|
45
|
+
let uiFrontmatter;
|
|
46
|
+
if (app.ui) {
|
|
47
|
+
const uiDir = join(dir, ".agentproto", "ui");
|
|
48
|
+
await mkdir(uiDir, { recursive: true });
|
|
49
|
+
uiPath = join(uiDir, "index.html");
|
|
50
|
+
await writeFile(uiPath, app.ui.html, "utf8");
|
|
51
|
+
uiFrontmatter = {
|
|
52
|
+
path: relative(dir, uiPath),
|
|
53
|
+
...app.ui.title !== void 0 ? { title: app.ui.title } : {},
|
|
54
|
+
...app.ui.description !== void 0 ? { description: app.ui.description } : {},
|
|
55
|
+
...app.ui.tools !== void 0 ? { tools: app.ui.tools } : {},
|
|
56
|
+
...app.ui.csp !== void 0 ? { csp: app.ui.csp } : {}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
44
59
|
const workflowPaths = [];
|
|
45
60
|
const workflowRefs2 = [];
|
|
46
61
|
for (const wf of app.workflows) {
|
|
@@ -66,10 +81,19 @@ async function emitApp(app, dir) {
|
|
|
66
81
|
agents: agentRefs,
|
|
67
82
|
workflows: workflowRefs2,
|
|
68
83
|
...app.workspace ? { workspace: app.workspace.id } : {},
|
|
69
|
-
...app.requires !== void 0 ? { requires: app.requires } : {}
|
|
84
|
+
...app.requires !== void 0 ? { requires: app.requires } : {},
|
|
85
|
+
...uiFrontmatter !== void 0 ? { ui: uiFrontmatter } : {},
|
|
86
|
+
...app.artifacts !== void 0 ? { artifacts: app.artifacts } : {},
|
|
87
|
+
...app.dev !== void 0 ? { dev: app.dev } : {}
|
|
70
88
|
};
|
|
71
89
|
await writeFile(appPath, toManifest(appFrontmatter, app.description ?? ""), "utf8");
|
|
72
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
agentPaths,
|
|
92
|
+
workflowPaths,
|
|
93
|
+
appPath,
|
|
94
|
+
...workspacePath ? { workspacePath } : {},
|
|
95
|
+
...uiPath ? { uiPath } : {}
|
|
96
|
+
};
|
|
73
97
|
}
|
|
74
98
|
function toManifest(handle, body) {
|
|
75
99
|
const data = JSON.parse(JSON.stringify(handle));
|
|
@@ -92,6 +116,12 @@ function defineApp(def) {
|
|
|
92
116
|
if (def.id !== void 0 && def.id.trim() === "") {
|
|
93
117
|
throw new AppDefinitionError("`id` must be non-empty when present.");
|
|
94
118
|
}
|
|
119
|
+
if (def.ui !== void 0 && (typeof def.ui.html !== "string" || def.ui.html.trim() === "")) {
|
|
120
|
+
throw new AppDefinitionError("`ui.html` must be a non-empty string when `ui` is present.");
|
|
121
|
+
}
|
|
122
|
+
if (def.dev !== void 0 && (!Array.isArray(def.dev.launch) || def.dev.launch.length === 0)) {
|
|
123
|
+
throw new AppDefinitionError("`dev.launch` must be a non-empty array when `dev` is present.");
|
|
124
|
+
}
|
|
95
125
|
const agents = def.agents.map(normalizeEntry);
|
|
96
126
|
const workflows = def.workflows ?? [];
|
|
97
127
|
const attachments = def.attach ?? [];
|
|
@@ -101,6 +131,9 @@ function defineApp(def) {
|
|
|
101
131
|
const version = def.version ?? (id ? "0.1.0" : void 0);
|
|
102
132
|
const description = def.description;
|
|
103
133
|
const requires = def.requires ? Object.freeze([...def.requires]) : void 0;
|
|
134
|
+
const ui = def.ui ? Object.freeze({ ...def.ui }) : void 0;
|
|
135
|
+
const artifacts = def.artifacts ? Object.freeze(def.artifacts.map((a) => Object.freeze({ ...a }))) : void 0;
|
|
136
|
+
const dev = def.dev ? Object.freeze({ launch: Object.freeze(def.dev.launch.map((l) => Object.freeze({ ...l }))) }) : void 0;
|
|
104
137
|
validateAttachment(agents, workflows);
|
|
105
138
|
const frozenAgents = Object.freeze(agents.map((e) => Object.freeze({ ...e })));
|
|
106
139
|
const frozenWorkflows = Object.freeze([...workflows]);
|
|
@@ -115,6 +148,9 @@ function defineApp(def) {
|
|
|
115
148
|
...version !== void 0 ? { version } : {},
|
|
116
149
|
...description !== void 0 ? { description } : {},
|
|
117
150
|
...requires !== void 0 ? { requires } : {},
|
|
151
|
+
...ui !== void 0 ? { ui } : {},
|
|
152
|
+
...artifacts !== void 0 ? { artifacts } : {},
|
|
153
|
+
...dev !== void 0 ? { dev } : {},
|
|
118
154
|
async toMastraAgents(opts, only) {
|
|
119
155
|
const targets = only ? selectAgents(frozenAgents, only) : frozenAgents;
|
|
120
156
|
const out = {};
|
|
@@ -144,7 +180,10 @@ function defineApp(def) {
|
|
|
144
180
|
...name !== void 0 ? { name } : {},
|
|
145
181
|
...version !== void 0 ? { version } : {},
|
|
146
182
|
...description !== void 0 ? { description } : {},
|
|
147
|
-
...requires !== void 0 ? { requires } : {}
|
|
183
|
+
...requires !== void 0 ? { requires } : {},
|
|
184
|
+
...ui !== void 0 ? { ui } : {},
|
|
185
|
+
...artifacts !== void 0 ? { artifacts } : {},
|
|
186
|
+
...dev !== void 0 ? { dev } : {}
|
|
148
187
|
},
|
|
149
188
|
dir
|
|
150
189
|
);
|
|
@@ -327,6 +366,25 @@ async function loadAppHandle(dir) {
|
|
|
327
366
|
);
|
|
328
367
|
}
|
|
329
368
|
}
|
|
369
|
+
let ui;
|
|
370
|
+
if (fm.ui) {
|
|
371
|
+
const uiPath = resolveRef(dir, fm.ui.path);
|
|
372
|
+
let html;
|
|
373
|
+
try {
|
|
374
|
+
html = await readFile(uiPath, "utf8");
|
|
375
|
+
} catch (err) {
|
|
376
|
+
throw new AppLoadError(
|
|
377
|
+
`ui: cannot read '${uiPath}': ${err instanceof Error ? err.message : String(err)}`
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
ui = {
|
|
381
|
+
html,
|
|
382
|
+
...fm.ui.title !== void 0 ? { title: fm.ui.title } : {},
|
|
383
|
+
...fm.ui.description !== void 0 ? { description: fm.ui.description } : {},
|
|
384
|
+
...fm.ui.tools !== void 0 ? { tools: fm.ui.tools } : {},
|
|
385
|
+
...fm.ui.csp !== void 0 ? { csp: fm.ui.csp } : {}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
330
388
|
return defineApp({
|
|
331
389
|
agents,
|
|
332
390
|
workflows,
|
|
@@ -335,7 +393,10 @@ async function loadAppHandle(dir) {
|
|
|
335
393
|
...fm.name !== void 0 ? { name: fm.name } : {},
|
|
336
394
|
...fm.version !== void 0 ? { version: fm.version } : {},
|
|
337
395
|
...fm.description !== void 0 ? { description: fm.description } : {},
|
|
338
|
-
...fm.requires !== void 0 ? { requires: fm.requires } : {}
|
|
396
|
+
...fm.requires !== void 0 ? { requires: fm.requires } : {},
|
|
397
|
+
...ui !== void 0 ? { ui } : {},
|
|
398
|
+
...fm.artifacts !== void 0 ? { artifacts: fm.artifacts } : {},
|
|
399
|
+
...fm.dev !== void 0 ? { dev: fm.dev } : {}
|
|
339
400
|
});
|
|
340
401
|
}
|
|
341
402
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/refs.ts","../src/emit.ts","../src/define-app.ts","../src/load-app.ts"],"names":["workflowRefs","join","matter"],"mappings":";;;;;;;;;;;;;;;;AASO,SAAS,OAAO,GAAA,EAAqB;AAC1C,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAA,EAAU,OAAO,GAAA;AACpC,EAAA,OAAO,GAAA,CAAI,OAAO,GAAA,CAAI,IAAA,IAAQ,KAAK,SAAA,CAAU,GAAA,CAAI,UAAU,GAAG,CAAA;AAChE;AAGO,SAAS,WAAW,EAAA,EAAoB;AAC7C,EAAA,MAAM,CAAA,GAAI,EAAA,CAAG,KAAA,CAAM,gBAAgB,CAAA;AACnC,EAAA,OAAO,CAAA,GAAI,CAAA,CAAE,CAAC,CAAA,GAAK,EAAA;AACrB;ACkCA,eAAsB,OAAA,CAAQ,KAAgB,GAAA,EAAkC;AAI9E,EAAA,IAAI,aAAA;AACJ,EAAA,IAAI,IAAI,SAAA,EAAW;AACjB,IAAA,MAAM,KAAA,CAAM,GAAA,EAAK,EAAE,SAAA,EAAW,MAAM,CAAA;AACpC,IAAA,aAAA,GAAgB,IAAA,CAAK,KAAK,cAAc,CAAA;AACxC,IAAA,MAAM,SAAA;AAAA,MACJ,aAAA;AAAA,MACA,UAAA,CAAW,IAAI,SAAA,EAAW,GAAA,CAAI,UAAU,WAAA,IAAe,GAAA,CAAI,UAAU,IAAI,CAAA;AAAA,MACzE;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,aAAqC,EAAC;AA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AQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OAClH;AAAA,IACF;AACA,IAAA,IAAI;AACF,MAAA,SAAA,GAAY,qBAAA,CAAsB,sBAAA,CAAuB,eAAe,CAAC,CAAA;AAAA,IAC3E,SAAS,GAAA,EAAK;AACZ,MAAA,MAAM,IAAI,YAAA;AAAA,QACR,CAAA,WAAA,EAAc,EAAA,CAAG,SAAS,CAAA,MAAA,EAAS,aAAa,CAAA,GAAA,EAAM,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OACxG;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,MAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAI,SAAA,GAAY,EAAE,SAAA,KAAc,EAAC;AAAA,IACjC,GAAI,GAAG,EAAA,KAAO,MAAA,GAAY,EAAE,EAAA,EAAI,EAAA,CAAG,EAAA,EAAG,GAAI,EAAC;AAAA,IAC3C,GAAI,GAAG,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,EAAA,CAAG,IAAA,EAAK,GAAI,EAAC;AAAA,IACjD,GAAI,GAAG,OAAA,KAAY,MAAA,GAAY,EAAE,OAAA,EAAS,EAAA,CAAG,OAAA,EAAQ,GAAI,EAAC;AAAA,IAC1D,GAAI,GAAG,WAAA,KAAgB,MAAA,GAAY,EAAE,WAAA,EAAa,EAAA,CAAG,WAAA,EAAY,GAAI,EAAC;AAAA,IACtE,GAAI,GAAG,QAAA,KAAa,MAAA,GAAY,EAAE,QAAA,EAAU,EAAA,CAAG,QAAA,EAAS,GAAI;AAAC,GAC9D,CAAA;AACH","file":"index.mjs","sourcesContent":["/**\n * Ref-key extraction, shared with the same convention `buildMastraAgent`\n * uses (`packages/mastra/src/build-agent.ts` `refKey`). An AIP-27 ref is\n * a string shorthand or `{ ref | file | inline }`; the key is the string,\n * else `.ref`, else `.file`, else a stable JSON of the inline payload.\n */\n\nimport type { AnyRef } from \"@agentproto/agent\"\n\nexport function refKey(ref: AnyRef): string {\n if (typeof ref === \"string\") return ref\n return ref.ref ?? ref.file ?? JSON.stringify(ref.inline ?? ref)\n}\n\n/** `@agentik/writer` → `writer`; bare ids untouched. */\nexport function stripOwner(id: string): string {\n const m = id.match(/^@[^/]+\\/(.+)$/)\n return m ? m[1]! : id\n}\n","/**\n * `emitApp(app, dir)` — write an app's agents + workflows to disk under an\n * agentproto-owned base, so the manifests don't squat the shared root\n * `.agents/` convention:\n *\n * <dir>/WORKSPACE.md (when the app has a\n * workspace — AIP-34 root\n * manifest; owner = tenant)\n * <dir>/.agentproto/agents/<id>/AGENT.md (one per agent)\n * <dir>/.agentproto/workflows/<wf.id>/WORKFLOW.md (shared — a workflow may\n * be run by several agents)\n * <dir>/.agentproto/APP.md (root index — always\n * written, so a future\n * `app_install` can\n * discover the bundle)\n *\n * The \"tenant\" isn't a `tenants/<t>/…` path segment — it's the `owner` of\n * the AIP-34 WORKSPACE.md (guild / user / org), and local storage is its\n * AIP-35 `storage` block. So there is no bespoke tenant folder to invent.\n *\n * All manifests are plain markdown: frontmatter = the validated handle (or,\n * for APP.md, the identity + a manifest of `{ id, path }` refs to every\n * agent/workflow it bundles), body = the agent's `body` (its system prompt),\n * the workflow description, or the app description. Because a\n * `defineWorkflow` handle is pure data, the WORKFLOW.md needs no `entry:`\n * module — the manifest *is* the workflow, so `loadWorkflowHandle` returns\n * it directly with nothing to reconcile against.\n *\n * `emitApp` stays dependency-light on purpose (no Mastra import) — that\n * split lets a host write/discover an app without paying for the Mastra\n * build path.\n */\n\nimport { mkdir, writeFile } from \"node:fs/promises\"\nimport { join, relative } from \"node:path\"\nimport matter from \"gray-matter\"\nimport type { WorkflowHandle } from \"@agentproto/workflow\"\nimport type { WorkspaceHandle } from \"@agentproto/workspace\"\nimport type { AgentEntry, EmittedApp } from \"./types.js\"\nimport { stripOwner } from \"./refs.js\"\n\ninterface EmitInput {\n readonly agents: readonly AgentEntry[]\n readonly workflows: readonly WorkflowHandle[]\n readonly workspace?: WorkspaceHandle\n readonly id?: string\n readonly name?: string\n readonly version?: string\n readonly description?: string\n readonly requires?: readonly string[]\n}\n\nexport async function emitApp(app: EmitInput, dir: string): Promise<EmittedApp> {\n // Root WORKSPACE.md (AIP-34): the workspace manifest whose `owner` names\n // the tenant and whose `storage` names the backing store. The agents +\n // workflows below live *inside* this workspace, under `.agentproto/`.\n let workspacePath: string | undefined\n if (app.workspace) {\n await mkdir(dir, { recursive: true })\n workspacePath = join(dir, \"WORKSPACE.md\")\n await writeFile(\n workspacePath,\n toManifest(app.workspace, app.workspace.description ?? app.workspace.name),\n \"utf8\",\n )\n }\n\n const agentPaths: Record<string, string> = {}\n for (const { agent, body } of app.agents) {\n const agentDir = join(dir, \".agentproto\", \"agents\", stripOwner(agent.id))\n await mkdir(agentDir, { recursive: true })\n const agentPath = join(agentDir, \"AGENT.md\")\n await writeFile(agentPath, toManifest(agent, body ?? \"\"), \"utf8\")\n agentPaths[agent.id] = agentPath\n }\n\n const workflowPaths: string[] = []\n const workflowRefs: { id: string; path: string }[] = []\n for (const wf of app.workflows) {\n const wfDir = join(dir, \".agentproto\", \"workflows\", wf.id)\n await mkdir(wfDir, { recursive: true })\n const wfPath = join(wfDir, \"WORKFLOW.md\")\n await writeFile(wfPath, toManifest(wf, wf.description ?? \"\"), \"utf8\")\n workflowPaths.push(wfPath)\n workflowRefs.push({ id: wf.id, path: relative(dir, wfPath) })\n }\n\n // Root APP.md (this WP): the index a future `app_install` reads to\n // discover the bundle — always written, unlike WORKSPACE.md which is\n // conditional on the app having a home workspace.\n await mkdir(join(dir, \".agentproto\"), { recursive: true })\n const appPath = join(dir, \".agentproto\", \"APP.md\")\n const agentRefs = app.agents.map(({ agent }) => ({\n id: agent.id,\n path: relative(dir, agentPaths[agent.id]!),\n }))\n const appFrontmatter: Record<string, unknown> = {\n schema: \"app/v1\",\n ...(app.id !== undefined ? { id: app.id } : {}),\n ...(app.name !== undefined ? { name: app.name } : {}),\n version: app.version ?? \"0.1.0\",\n ...(app.description !== undefined ? { description: app.description } : {}),\n agents: agentRefs,\n workflows: workflowRefs,\n ...(app.workspace ? { workspace: app.workspace.id } : {}),\n ...(app.requires !== undefined ? { requires: app.requires } : {}),\n }\n await writeFile(appPath, toManifest(appFrontmatter, app.description ?? \"\"), \"utf8\")\n\n return { agentPaths, workflowPaths, appPath, ...(workspacePath ? { workspacePath } : {}) }\n}\n\n/**\n * Serialize a handle to a `.md` manifest. gray-matter's YAML engine\n * rejects `undefined` values; a JSON clone drops them and yields a plain\n * data object (AIP handles are pure data, no functions/Dates) that\n * round-trips through the matching `parse*Manifest`. gray-matter appends\n * a trailing newline, so manifests end in exactly one newline.\n */\nfunction toManifest(handle: object, body: string): string {\n const data: Record<string, unknown> = JSON.parse(JSON.stringify(handle))\n return matter.stringify(`\\n${body}\\n`, data)\n}\n","/**\n * `defineApp({ agents, workflows, attach })` — bundle one or more AIP-42\n * agents, the AIP-15 workflows they run, and any other AIP artifacts into\n * one cross-linked, frozen handle.\n *\n * The only new invariant app-kit adds is *attachment*: the agents and the\n * bundled workflows must reference each other. Everything else (field\n * validation) already ran when the caller built the handles with\n * `defineAgent` / `defineWorkflow`, so `defineApp` validates the coupling,\n * not the fields.\n *\n * - agent ids are unique within the app.\n * - every `agent.workflows[]` ref MUST resolve to a bundled workflow id.\n * - every bundled workflow MUST be referenced by at least one agent.\n *\n * A dangling ref (an agent points at a workflow the app didn't bundle) or\n * an orphan (a bundled workflow no agent lists) throws — that is what \"an\n * agent attached to its workflows\" means, made checkable.\n */\n\nimport { buildMastraAgent } from \"@agentproto/mastra\"\nimport { defineWorkspace } from \"@agentproto/workspace\"\nimport type { AgentHandle, AnyRef } from \"@agentproto/agent\"\nimport type { WorkflowHandle } from \"@agentproto/workflow\"\nimport type { WorkspaceHandle } from \"@agentproto/workspace\"\nimport type {\n AgentEntry,\n AppDefinition,\n AppHandle,\n DoctypeHandle,\n ToMastraAgentOptions,\n WorkspaceInput,\n} from \"./types.js\"\nimport { refKey } from \"./refs.js\"\nimport { emitApp } from \"./emit.js\"\n\nexport class AppDefinitionError extends Error {\n constructor(message: string) {\n super(`defineApp (app-kit): ${message}`)\n this.name = \"AppDefinitionError\"\n }\n}\n\nexport function defineApp(def: AppDefinition): AppHandle {\n if (!Array.isArray(def.agents) || def.agents.length === 0) {\n throw new AppDefinitionError(\"`agents` must be a non-empty array.\")\n }\n if (def.id !== undefined && def.id.trim() === \"\") {\n throw new AppDefinitionError(\"`id` must be non-empty when present.\")\n }\n\n const agents = def.agents.map(normalizeEntry)\n const workflows = def.workflows ?? []\n const attachments = def.attach ?? []\n const workspace = def.workspace ? toWorkspaceHandle(def.workspace) : undefined\n const id = def.id\n const name = def.name\n const version = def.version ?? (id ? \"0.1.0\" : undefined)\n const description = def.description\n const requires = def.requires ? Object.freeze([...def.requires]) : undefined\n\n validateAttachment(agents, workflows)\n\n const frozenAgents = Object.freeze(agents.map((e) => Object.freeze({ ...e })))\n const frozenWorkflows = Object.freeze([...workflows])\n const frozenAttachments = Object.freeze([...attachments])\n\n const handle: AppHandle = {\n agents: frozenAgents,\n workflows: frozenWorkflows,\n attachments: frozenAttachments,\n ...(workspace ? { workspace } : {}),\n ...(id !== undefined ? { id } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(requires !== undefined ? { requires } : {}),\n\n async toMastraAgents(opts: ToMastraAgentOptions, only?: readonly string[]) {\n const targets = only ? selectAgents(frozenAgents, only) : frozenAgents\n const out: Record<string, Awaited<ReturnType<typeof buildMastraAgent>>> = {}\n for (const entry of targets) {\n out[entry.agent.id] = await buildOne(entry, opts)\n }\n return out\n },\n\n pick(ids: readonly string[]) {\n return selectAgents(frozenAgents, ids)\n },\n\n async toMastraAgent(opts: ToMastraAgentOptions) {\n if (frozenAgents.length !== 1) {\n throw new AppDefinitionError(\n `toMastraAgent requires exactly one agent (app has ${frozenAgents.length}); use toMastraAgents.`,\n )\n }\n return buildOne(frozenAgents[0]!, opts)\n },\n\n emit(dir: string) {\n return emitApp(\n {\n agents: frozenAgents,\n workflows: frozenWorkflows,\n ...(workspace ? { workspace } : {}),\n ...(id !== undefined ? { id } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(requires !== undefined ? { requires } : {}),\n },\n dir,\n )\n },\n }\n\n return Object.freeze(handle)\n}\n\n/**\n * Normalize the `workspace` input to an AIP-34 `WorkspaceHandle`. A built\n * handle (already run through `defineWorkspace`) carries `schema:\n * \"workspace/v1\"` and passes straight through; a `WorkspaceShorthand` is\n * completed with a local-fs storage default and a `0.1.0` version, then\n * validated by `defineWorkspace` — so a malformed shorthand fails with the\n * same AIP-34 diagnostic as a malformed WORKSPACE.md.\n */\nfunction toWorkspaceHandle(input: WorkspaceInput): WorkspaceHandle {\n if (\"schema\" in input) return input\n return defineWorkspace({\n schema: \"workspace/v1\",\n version: input.version ?? \"0.1.0\",\n id: input.id,\n name: input.name,\n owner: input.owner,\n storage: input.storage ?? { inline: { provider: \"local-fs\", config: {} } },\n ...(input.description ? { description: input.description } : {}),\n })\n}\n\n/**\n * Resolve `ids` to their app entries, preserving the caller's order. Throws\n * `AppDefinitionError` on any id the app doesn't bundle — a hand-picked list\n * that names a missing agent is a bug, not a silent no-op.\n */\nfunction selectAgents(\n agents: readonly AgentEntry[],\n ids: readonly string[],\n): readonly AgentEntry[] {\n const byId = new Map(agents.map((e) => [e.agent.id, e]))\n return ids.map((id) => {\n const entry = byId.get(id)\n if (!entry) {\n throw new AppDefinitionError(\n `agent '${id}' is not in this app. Bundled: [${[...byId.keys()].join(\", \")}].`,\n )\n }\n return entry\n })\n}\n\nfunction buildOne(entry: AgentEntry, opts: ToMastraAgentOptions) {\n // `entry.body` (the AGENT.md body) wins as instructions; an explicit\n // `opts.body` still overrides, matching buildMastraAgent's contract.\n return buildMastraAgent(entry.agent, { body: entry.body, ...opts })\n}\n\nfunction normalizeEntry(input: AgentEntry | AgentHandle): AgentEntry {\n // An AgentEntry has an `.agent`; a bare AgentHandle has `.id`/`.schema`.\n if (\"agent\" in input) return input\n return { agent: input }\n}\n\n/**\n * The attachment invariant across all agents: bundled workflow ids and\n * the union of every agent's `workflows[]` refs must be the same set.\n * External/registry workflow refs are out of scope for an app bundle —\n * if an agent lists it, the app must ship it.\n */\nfunction validateAttachment(\n agents: readonly AgentEntry[],\n workflows: readonly WorkflowHandle[],\n): void {\n const seenAgentIds = new Set<string>()\n for (const { agent } of agents) {\n if (seenAgentIds.has(agent.id)) {\n throw new AppDefinitionError(`duplicate agent id '${agent.id}' in the bundle.`)\n }\n seenAgentIds.add(agent.id)\n }\n\n const bundledIds = new Set<string>()\n for (const wf of workflows) {\n if (bundledIds.has(wf.id)) {\n throw new AppDefinitionError(`duplicate workflow id '${wf.id}' in the bundle.`)\n }\n bundledIds.add(wf.id)\n }\n\n const referenced = new Set<string>()\n for (const { agent } of agents) {\n for (const ref of workflowRefs(agent)) {\n const key = refKey(ref)\n referenced.add(key)\n if (!bundledIds.has(key)) {\n throw new AppDefinitionError(\n `agent '${agent.id}' references workflow '${key}' but the app does not bundle it. ` +\n `Bundled: [${[...bundledIds].join(\", \") || \"none\"}].`,\n )\n }\n }\n }\n\n for (const id of bundledIds) {\n if (!referenced.has(id)) {\n throw new AppDefinitionError(\n `workflow '${id}' is bundled but no agent lists it in workflows[]. ` +\n `Add { ref: \"${id}\" } to an agent, or drop the workflow.`,\n )\n }\n }\n}\n\nfunction workflowRefs(agent: AgentHandle): readonly AnyRef[] {\n return agent.workflows ?? []\n}\n\nexport type { DoctypeHandle }\n","/**\n * `loadAppHandle(dir)` — read a root `APP.md` off disk into an `AppHandle`.\n *\n * Mirror of `@agentproto/workflow-loader`'s `loadWorkflowHandle`: this is\n * the host-side seam that touches the filesystem so the pure packages\n * (`@agentproto/agent`, `@agentproto/workflow`, `@agentproto/workspace`)\n * don't have to.\n *\n * `<dir>/.agentproto/APP.md` lists every agent + workflow the app bundles\n * as `{ id, path }` refs (relative to `dir`, the shape `emitApp` writes).\n * Each is loaded with its own package's manifest reader — `AGENT.md` via\n * `@agentproto/agent/manifest`, `WORKFLOW.md` via\n * `@agentproto/workflow-loader` (which itself resolves an `entry:` module\n * when present) — then the whole bundle is re-run through `defineApp` so\n * the attachment invariant (every agent/workflow ref resolves both ways)\n * re-validates exactly as it did at authoring time. A stale or hand-edited\n * APP.md that drifted from its AGENT.md/WORKFLOW.md refs fails the same\n * way a bad `defineApp({...})` call would.\n *\n * The frontmatter shape intentionally has no generated zod schema (unlike\n * AGENT.md/WORKFLOW.md, there's no AIP number for \"app\" yet) and validation\n * here stays loose on purpose — a future key (e.g. WP-B3's `requires.tools`)\n * should round-trip without this loader rejecting it.\n */\n\nimport { readFile } from \"node:fs/promises\"\nimport { isAbsolute, join } from \"node:path\"\nimport matter from \"gray-matter\"\nimport { agentFromManifest, parseAgentManifest } from \"@agentproto/agent/manifest\"\nimport { loadWorkflowHandle } from \"@agentproto/workflow-loader\"\nimport { parseWorkspaceManifest, workspaceFromManifest } from \"@agentproto/workspace/manifest\"\nimport type { AgentEntry, AppHandle } from \"./types.js\"\nimport { defineApp } from \"./define-app.js\"\n\nexport class AppLoadError extends Error {\n constructor(message: string) {\n super(`loadAppHandle: ${message}`)\n this.name = \"AppLoadError\"\n }\n}\n\ninterface AppRef {\n readonly id: string\n readonly path: string\n}\n\ninterface AppFrontmatter {\n readonly schema: string\n readonly id?: string\n readonly name?: string\n readonly version?: string\n readonly description?: string\n readonly agents: readonly AppRef[]\n readonly workflows: readonly AppRef[]\n readonly workspace?: string\n readonly requires?: readonly string[]\n}\n\nfunction resolveRef(dir: string, path: string): string {\n return isAbsolute(path) ? path : join(dir, path)\n}\n\nfunction isRefArray(v: unknown): v is AppRef[] {\n return (\n Array.isArray(v) &&\n v.every(\n (e) =>\n typeof e === \"object\" &&\n e !== null &&\n typeof (e as { id?: unknown }).id === \"string\" &&\n typeof (e as { path?: unknown }).path === \"string\",\n )\n )\n}\n\n/** Minimal shape check — see the module doc for why this stays loose. */\nfunction parseAppFrontmatter(data: Record<string, unknown>, appPath: string): AppFrontmatter {\n if (data.schema !== \"app/v1\") {\n throw new AppLoadError(\n `'${appPath}': expected frontmatter 'schema: app/v1', got ${JSON.stringify(data.schema)}.`,\n )\n }\n if (!isRefArray(data.agents)) {\n throw new AppLoadError(`'${appPath}': frontmatter 'agents' must be an array of { id, path }.`)\n }\n if (!isRefArray(data.workflows)) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'workflows' must be an array of { id, path }.`,\n )\n }\n if (data.requires !== undefined) {\n if (!Array.isArray(data.requires) || !data.requires.every((e) => typeof e === \"string\")) {\n throw new AppLoadError(`'${appPath}': frontmatter 'requires' must be an array of strings.`)\n }\n }\n return data as unknown as AppFrontmatter\n}\n\nasync function loadAgentEntry(dir: string, ref: AppRef): Promise<AgentEntry> {\n const agentPath = resolveRef(dir, ref.path)\n let source: string\n try {\n source = await readFile(agentPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `agent '${ref.id}': cannot read '${agentPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n let body: string\n let manifest: ReturnType<typeof parseAgentManifest>\n try {\n manifest = parseAgentManifest(source)\n body = manifest.body.trim()\n } catch (err) {\n throw new AppLoadError(\n `agent '${ref.id}' at '${agentPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n return { agent: agentFromManifest(manifest), ...(body ? { body } : {}) }\n}\n\nasync function loadWorkflowRef(dir: string, ref: AppRef) {\n const wfPath = resolveRef(dir, ref.path)\n try {\n return await loadWorkflowHandle(wfPath)\n } catch (err) {\n throw new AppLoadError(\n `workflow '${ref.id}' at '${wfPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n}\n\n/**\n * Load `<dir>/.agentproto/APP.md` and every AGENT.md/WORKFLOW.md (and, if\n * declared, `<dir>/WORKSPACE.md`) it references, then re-run `defineApp` on\n * the result. Throws {@link AppLoadError} naming the offending path on a\n * missing APP.md, a missing referenced file, or a frontmatter/schema\n * mismatch; throws `AppDefinitionError` (from `defineApp`) if the loaded\n * bundle fails the attachment invariant.\n */\nexport async function loadAppHandle(dir: string): Promise<AppHandle> {\n const appPath = join(dir, \".agentproto\", \"APP.md\")\n let source: string\n try {\n source = await readFile(appPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `cannot read '${appPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n\n const parsed = matter(source)\n const fm = parseAppFrontmatter(parsed.data, appPath)\n\n const agents: AgentEntry[] = []\n for (const ref of fm.agents) {\n agents.push(await loadAgentEntry(dir, ref))\n }\n\n const workflows = []\n for (const ref of fm.workflows) {\n workflows.push(await loadWorkflowRef(dir, ref))\n }\n\n let workspace\n if (fm.workspace) {\n const workspacePath = join(dir, \"WORKSPACE.md\")\n let workspaceSource: string\n try {\n workspaceSource = await readFile(workspacePath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `workspace '${fm.workspace}': cannot read '${workspacePath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n try {\n workspace = workspaceFromManifest(parseWorkspaceManifest(workspaceSource))\n } catch (err) {\n throw new AppLoadError(\n `workspace '${fm.workspace}' at '${workspacePath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n }\n\n return defineApp({\n agents,\n workflows,\n ...(workspace ? { workspace } : {}),\n ...(fm.id !== undefined ? { id: fm.id } : {}),\n ...(fm.name !== undefined ? { name: fm.name } : {}),\n ...(fm.version !== undefined ? { version: fm.version } : {}),\n ...(fm.description !== undefined ? { description: fm.description } : {}),\n ...(fm.requires !== undefined ? { requires: fm.requires } : {}),\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/refs.ts","../src/emit.ts","../src/define-app.ts","../src/load-app.ts"],"names":["workflowRefs","join","matter"],"mappings":";;;;;;;;;;;;;;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/mastra/src/build-agent.ts` `refKey`). An AIP-27 ref is\n * a string shorthand or `{ ref | file | inline }`; the key is the string,\n * else `.ref`, else `.file`, else a stable JSON of the inline payload.\n */\n\nimport type { AnyRef } from \"@agentproto/agent\"\n\nexport function refKey(ref: AnyRef): string {\n if (typeof ref === \"string\") return ref\n return ref.ref ?? ref.file ?? JSON.stringify(ref.inline ?? ref)\n}\n\n/** `@agentik/writer` → `writer`; bare ids untouched. */\nexport function stripOwner(id: string): string {\n const m = id.match(/^@[^/]+\\/(.+)$/)\n return m ? m[1]! : id\n}\n","/**\n * `emitApp(app, dir)` — write an app's agents + workflows to disk under an\n * agentproto-owned base, so the manifests don't squat the shared root\n * `.agents/` convention:\n *\n * <dir>/WORKSPACE.md (when the app has a\n * workspace — AIP-34 root\n * manifest; owner = tenant)\n * <dir>/.agentproto/agents/<id>/AGENT.md (one per agent)\n * <dir>/.agentproto/workflows/<wf.id>/WORKFLOW.md (shared — a workflow may\n * be run by several agents)\n * <dir>/.agentproto/APP.md (root index — always\n * written, so a future\n * `app_install` can\n * discover the bundle)\n *\n * The \"tenant\" isn't a `tenants/<t>/…` path segment — it's the `owner` of\n * the AIP-34 WORKSPACE.md (guild / user / org), and local storage is its\n * AIP-35 `storage` block. So there is no bespoke tenant folder to invent.\n *\n * All manifests are plain markdown: frontmatter = the validated handle (or,\n * for APP.md, the identity + a manifest of `{ id, path }` refs to every\n * agent/workflow it bundles), body = the agent's `body` (its system prompt),\n * the workflow description, or the app description. Because a\n * `defineWorkflow` handle is pure data, the WORKFLOW.md needs no `entry:`\n * module — the manifest *is* the workflow, so `loadWorkflowHandle` returns\n * it directly with nothing to reconcile against.\n *\n * `emitApp` stays dependency-light on purpose (no Mastra import) — that\n * split lets a host write/discover an app without paying for the Mastra\n * build path.\n */\n\nimport { mkdir, writeFile } from \"node:fs/promises\"\nimport { join, relative } from \"node:path\"\nimport matter from \"gray-matter\"\nimport type { WorkflowHandle } from \"@agentproto/workflow\"\nimport type { WorkspaceHandle } from \"@agentproto/workspace\"\nimport type { AgentEntry, AppArtifactDecl, AppDevDefinition, AppUiDefinition, EmittedApp } from \"./types.js\"\nimport { stripOwner } from \"./refs.js\"\n\ninterface EmitInput {\n readonly agents: readonly AgentEntry[]\n readonly workflows: readonly WorkflowHandle[]\n readonly workspace?: WorkspaceHandle\n readonly id?: string\n readonly name?: string\n readonly version?: string\n readonly description?: string\n readonly requires?: readonly string[]\n readonly ui?: AppUiDefinition\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n}\n\nexport async function emitApp(app: EmitInput, dir: string): Promise<EmittedApp> {\n // Root WORKSPACE.md (AIP-34): the workspace manifest whose `owner` names\n // the tenant and whose `storage` names the backing store. The agents +\n // workflows below live *inside* this workspace, under `.agentproto/`.\n let workspacePath: string | undefined\n if (app.workspace) {\n await mkdir(dir, { recursive: true })\n workspacePath = join(dir, \"WORKSPACE.md\")\n await writeFile(\n workspacePath,\n toManifest(app.workspace, app.workspace.description ?? app.workspace.name),\n \"utf8\",\n )\n }\n\n const agentPaths: Record<string, string> = {}\n for (const { agent, body } of app.agents) {\n const agentDir = join(dir, \".agentproto\", \"agents\", stripOwner(agent.id))\n await mkdir(agentDir, { recursive: true })\n const agentPath = join(agentDir, \"AGENT.md\")\n await writeFile(agentPath, toManifest(agent, body ?? \"\"), \"utf8\")\n agentPaths[agent.id] = agentPath\n }\n\n // UI surface (`.agentproto/ui/index.html`): the `html` body is written to\n // disk, never inlined into APP.md frontmatter — the frontmatter carries\n // only the relative `path` plus the display metadata.\n let uiPath: string | undefined\n let uiFrontmatter: Record<string, unknown> | undefined\n if (app.ui) {\n const uiDir = join(dir, \".agentproto\", \"ui\")\n await mkdir(uiDir, { recursive: true })\n uiPath = join(uiDir, \"index.html\")\n await writeFile(uiPath, app.ui.html, \"utf8\")\n uiFrontmatter = {\n path: relative(dir, uiPath),\n ...(app.ui.title !== undefined ? { title: app.ui.title } : {}),\n ...(app.ui.description !== undefined ? { description: app.ui.description } : {}),\n ...(app.ui.tools !== undefined ? { tools: app.ui.tools } : {}),\n ...(app.ui.csp !== undefined ? { csp: app.ui.csp } : {}),\n }\n }\n\n const workflowPaths: string[] = []\n const workflowRefs: { id: string; path: string }[] = []\n for (const wf of app.workflows) {\n const wfDir = join(dir, \".agentproto\", \"workflows\", wf.id)\n await mkdir(wfDir, { recursive: true })\n const wfPath = join(wfDir, \"WORKFLOW.md\")\n await writeFile(wfPath, toManifest(wf, wf.description ?? \"\"), \"utf8\")\n workflowPaths.push(wfPath)\n workflowRefs.push({ id: wf.id, path: relative(dir, wfPath) })\n }\n\n // Root APP.md (this WP): the index a future `app_install` reads to\n // discover the bundle — always written, unlike WORKSPACE.md which is\n // conditional on the app having a home workspace.\n await mkdir(join(dir, \".agentproto\"), { recursive: true })\n const appPath = join(dir, \".agentproto\", \"APP.md\")\n const agentRefs = app.agents.map(({ agent }) => ({\n id: agent.id,\n path: relative(dir, agentPaths[agent.id]!),\n }))\n const appFrontmatter: Record<string, unknown> = {\n schema: \"app/v1\",\n ...(app.id !== undefined ? { id: app.id } : {}),\n ...(app.name !== undefined ? { name: app.name } : {}),\n version: app.version ?? \"0.1.0\",\n ...(app.description !== undefined ? { description: app.description } : {}),\n agents: agentRefs,\n workflows: workflowRefs,\n ...(app.workspace ? { workspace: app.workspace.id } : {}),\n ...(app.requires !== undefined ? { requires: app.requires } : {}),\n ...(uiFrontmatter !== undefined ? { ui: uiFrontmatter } : {}),\n ...(app.artifacts !== undefined ? { artifacts: app.artifacts } : {}),\n ...(app.dev !== undefined ? { dev: app.dev } : {}),\n }\n await writeFile(appPath, toManifest(appFrontmatter, app.description ?? \"\"), \"utf8\")\n\n return {\n agentPaths,\n workflowPaths,\n appPath,\n ...(workspacePath ? { workspacePath } : {}),\n ...(uiPath ? { uiPath } : {}),\n }\n}\n\n/**\n * Serialize a handle to a `.md` manifest. gray-matter's YAML engine\n * rejects `undefined` values; a JSON clone drops them and yields a plain\n * data object (AIP handles are pure data, no functions/Dates) that\n * round-trips through the matching `parse*Manifest`. gray-matter appends\n * a trailing newline, so manifests end in exactly one newline.\n */\nfunction toManifest(handle: object, body: string): string {\n const data: Record<string, unknown> = JSON.parse(JSON.stringify(handle))\n return matter.stringify(`\\n${body}\\n`, data)\n}\n","/**\n * `defineApp({ agents, workflows, attach })` — bundle one or more AIP-42\n * agents, the AIP-15 workflows they run, and any other AIP artifacts into\n * one cross-linked, frozen handle.\n *\n * The only new invariant app-kit adds is *attachment*: the agents and the\n * bundled workflows must reference each other. Everything else (field\n * validation) already ran when the caller built the handles with\n * `defineAgent` / `defineWorkflow`, so `defineApp` validates the coupling,\n * not the fields.\n *\n * - agent ids are unique within the app.\n * - every `agent.workflows[]` ref MUST resolve to a bundled workflow id.\n * - every bundled workflow MUST be referenced by at least one agent.\n *\n * A dangling ref (an agent points at a workflow the app didn't bundle) or\n * an orphan (a bundled workflow no agent lists) throws — that is what \"an\n * agent attached to its workflows\" means, made checkable.\n */\n\nimport { buildMastraAgent } from \"@agentproto/mastra\"\nimport { defineWorkspace } from \"@agentproto/workspace\"\nimport type { AgentHandle, AnyRef } from \"@agentproto/agent\"\nimport type { WorkflowHandle } from \"@agentproto/workflow\"\nimport type { WorkspaceHandle } from \"@agentproto/workspace\"\nimport type {\n AgentEntry,\n AppDefinition,\n AppHandle,\n DoctypeHandle,\n ToMastraAgentOptions,\n WorkspaceInput,\n} from \"./types.js\"\nimport { refKey } from \"./refs.js\"\nimport { emitApp } from \"./emit.js\"\n\nexport class AppDefinitionError extends Error {\n constructor(message: string) {\n super(`defineApp (app-kit): ${message}`)\n this.name = \"AppDefinitionError\"\n }\n}\n\nexport function defineApp(def: AppDefinition): AppHandle {\n if (!Array.isArray(def.agents) || def.agents.length === 0) {\n throw new AppDefinitionError(\"`agents` must be a non-empty array.\")\n }\n if (def.id !== undefined && def.id.trim() === \"\") {\n throw new AppDefinitionError(\"`id` must be non-empty when present.\")\n }\n if (def.ui !== undefined && (typeof def.ui.html !== \"string\" || def.ui.html.trim() === \"\")) {\n throw new AppDefinitionError(\"`ui.html` must be a non-empty string when `ui` is present.\")\n }\n if (def.dev !== undefined && (!Array.isArray(def.dev.launch) || def.dev.launch.length === 0)) {\n throw new AppDefinitionError(\"`dev.launch` must be a non-empty array when `dev` is present.\")\n }\n\n const agents = def.agents.map(normalizeEntry)\n const workflows = def.workflows ?? []\n const attachments = def.attach ?? []\n const workspace = def.workspace ? toWorkspaceHandle(def.workspace) : undefined\n const id = def.id\n const name = def.name\n const version = def.version ?? (id ? \"0.1.0\" : undefined)\n const description = def.description\n const requires = def.requires ? Object.freeze([...def.requires]) : undefined\n const ui = def.ui ? Object.freeze({ ...def.ui }) : undefined\n const artifacts = def.artifacts ? Object.freeze(def.artifacts.map(a => Object.freeze({ ...a }))) : undefined\n const dev = def.dev\n ? Object.freeze({ launch: Object.freeze(def.dev.launch.map(l => Object.freeze({ ...l }))) })\n : undefined\n\n validateAttachment(agents, workflows)\n\n const frozenAgents = Object.freeze(agents.map((e) => Object.freeze({ ...e })))\n const frozenWorkflows = Object.freeze([...workflows])\n const frozenAttachments = Object.freeze([...attachments])\n\n const handle: AppHandle = {\n agents: frozenAgents,\n workflows: frozenWorkflows,\n attachments: frozenAttachments,\n ...(workspace ? { workspace } : {}),\n ...(id !== undefined ? { id } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(requires !== undefined ? { requires } : {}),\n ...(ui !== undefined ? { ui } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n\n async toMastraAgents(opts: ToMastraAgentOptions, only?: readonly string[]) {\n const targets = only ? selectAgents(frozenAgents, only) : frozenAgents\n const out: Record<string, Awaited<ReturnType<typeof buildMastraAgent>>> = {}\n for (const entry of targets) {\n out[entry.agent.id] = await buildOne(entry, opts)\n }\n return out\n },\n\n pick(ids: readonly string[]) {\n return selectAgents(frozenAgents, ids)\n },\n\n async toMastraAgent(opts: ToMastraAgentOptions) {\n if (frozenAgents.length !== 1) {\n throw new AppDefinitionError(\n `toMastraAgent requires exactly one agent (app has ${frozenAgents.length}); use toMastraAgents.`,\n )\n }\n return buildOne(frozenAgents[0]!, opts)\n },\n\n emit(dir: string) {\n return emitApp(\n {\n agents: frozenAgents,\n workflows: frozenWorkflows,\n ...(workspace ? { workspace } : {}),\n ...(id !== undefined ? { id } : {}),\n ...(name !== undefined ? { name } : {}),\n ...(version !== undefined ? { version } : {}),\n ...(description !== undefined ? { description } : {}),\n ...(requires !== undefined ? { requires } : {}),\n ...(ui !== undefined ? { ui } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n },\n dir,\n )\n },\n }\n\n return Object.freeze(handle)\n}\n\n/**\n * Normalize the `workspace` input to an AIP-34 `WorkspaceHandle`. A built\n * handle (already run through `defineWorkspace`) carries `schema:\n * \"workspace/v1\"` and passes straight through; a `WorkspaceShorthand` is\n * completed with a local-fs storage default and a `0.1.0` version, then\n * validated by `defineWorkspace` — so a malformed shorthand fails with the\n * same AIP-34 diagnostic as a malformed WORKSPACE.md.\n */\nfunction toWorkspaceHandle(input: WorkspaceInput): WorkspaceHandle {\n if (\"schema\" in input) return input\n return defineWorkspace({\n schema: \"workspace/v1\",\n version: input.version ?? \"0.1.0\",\n id: input.id,\n name: input.name,\n owner: input.owner,\n storage: input.storage ?? { inline: { provider: \"local-fs\", config: {} } },\n ...(input.description ? { description: input.description } : {}),\n })\n}\n\n/**\n * Resolve `ids` to their app entries, preserving the caller's order. Throws\n * `AppDefinitionError` on any id the app doesn't bundle — a hand-picked list\n * that names a missing agent is a bug, not a silent no-op.\n */\nfunction selectAgents(\n agents: readonly AgentEntry[],\n ids: readonly string[],\n): readonly AgentEntry[] {\n const byId = new Map(agents.map((e) => [e.agent.id, e]))\n return ids.map((id) => {\n const entry = byId.get(id)\n if (!entry) {\n throw new AppDefinitionError(\n `agent '${id}' is not in this app. Bundled: [${[...byId.keys()].join(\", \")}].`,\n )\n }\n return entry\n })\n}\n\nfunction buildOne(entry: AgentEntry, opts: ToMastraAgentOptions) {\n // `entry.body` (the AGENT.md body) wins as instructions; an explicit\n // `opts.body` still overrides, matching buildMastraAgent's contract.\n return buildMastraAgent(entry.agent, { body: entry.body, ...opts })\n}\n\nfunction normalizeEntry(input: AgentEntry | AgentHandle): AgentEntry {\n // An AgentEntry has an `.agent`; a bare AgentHandle has `.id`/`.schema`.\n if (\"agent\" in input) return input\n return { agent: input }\n}\n\n/**\n * The attachment invariant across all agents: bundled workflow ids and\n * the union of every agent's `workflows[]` refs must be the same set.\n * External/registry workflow refs are out of scope for an app bundle —\n * if an agent lists it, the app must ship it.\n */\nfunction validateAttachment(\n agents: readonly AgentEntry[],\n workflows: readonly WorkflowHandle[],\n): void {\n const seenAgentIds = new Set<string>()\n for (const { agent } of agents) {\n if (seenAgentIds.has(agent.id)) {\n throw new AppDefinitionError(`duplicate agent id '${agent.id}' in the bundle.`)\n }\n seenAgentIds.add(agent.id)\n }\n\n const bundledIds = new Set<string>()\n for (const wf of workflows) {\n if (bundledIds.has(wf.id)) {\n throw new AppDefinitionError(`duplicate workflow id '${wf.id}' in the bundle.`)\n }\n bundledIds.add(wf.id)\n }\n\n const referenced = new Set<string>()\n for (const { agent } of agents) {\n for (const ref of workflowRefs(agent)) {\n const key = refKey(ref)\n referenced.add(key)\n if (!bundledIds.has(key)) {\n throw new AppDefinitionError(\n `agent '${agent.id}' references workflow '${key}' but the app does not bundle it. ` +\n `Bundled: [${[...bundledIds].join(\", \") || \"none\"}].`,\n )\n }\n }\n }\n\n for (const id of bundledIds) {\n if (!referenced.has(id)) {\n throw new AppDefinitionError(\n `workflow '${id}' is bundled but no agent lists it in workflows[]. ` +\n `Add { ref: \"${id}\" } to an agent, or drop the workflow.`,\n )\n }\n }\n}\n\nfunction workflowRefs(agent: AgentHandle): readonly AnyRef[] {\n return agent.workflows ?? []\n}\n\nexport type { DoctypeHandle }\n","/**\n * `loadAppHandle(dir)` — read a root `APP.md` off disk into an `AppHandle`.\n *\n * Mirror of `@agentproto/workflow-loader`'s `loadWorkflowHandle`: this is\n * the host-side seam that touches the filesystem so the pure packages\n * (`@agentproto/agent`, `@agentproto/workflow`, `@agentproto/workspace`)\n * don't have to.\n *\n * `<dir>/.agentproto/APP.md` lists every agent + workflow the app bundles\n * as `{ id, path }` refs (relative to `dir`, the shape `emitApp` writes).\n * Each is loaded with its own package's manifest reader — `AGENT.md` via\n * `@agentproto/agent/manifest`, `WORKFLOW.md` via\n * `@agentproto/workflow-loader` (which itself resolves an `entry:` module\n * when present) — then the whole bundle is re-run through `defineApp` so\n * the attachment invariant (every agent/workflow ref resolves both ways)\n * re-validates exactly as it did at authoring time. A stale or hand-edited\n * APP.md that drifted from its AGENT.md/WORKFLOW.md refs fails the same\n * way a bad `defineApp({...})` call would.\n *\n * The frontmatter shape intentionally has no generated zod schema (unlike\n * AGENT.md/WORKFLOW.md, there's no AIP number for \"app\" yet) and validation\n * here stays loose on purpose — a future key (e.g. WP-B3's `requires.tools`)\n * should round-trip without this loader rejecting it.\n */\n\nimport { readFile } from \"node:fs/promises\"\nimport { isAbsolute, join } from \"node:path\"\nimport matter from \"gray-matter\"\nimport { agentFromManifest, parseAgentManifest } from \"@agentproto/agent/manifest\"\nimport { loadWorkflowHandle } from \"@agentproto/workflow-loader\"\nimport { parseWorkspaceManifest, workspaceFromManifest } from \"@agentproto/workspace/manifest\"\nimport type { AgentEntry, AppArtifactDecl, AppDevDefinition, AppHandle } from \"./types.js\"\nimport { defineApp } from \"./define-app.js\"\n\nexport class AppLoadError extends Error {\n constructor(message: string) {\n super(`loadAppHandle: ${message}`)\n this.name = \"AppLoadError\"\n }\n}\n\ninterface AppRef {\n readonly id: string\n readonly path: string\n}\n\ninterface AppFrontmatterUi {\n readonly path: string\n readonly title?: string\n readonly description?: string\n readonly tools?: readonly string[]\n readonly csp?: {\n readonly connectDomains?: readonly string[]\n readonly resourceDomains?: readonly string[]\n }\n}\n\ninterface AppFrontmatter {\n readonly schema: string\n readonly id?: string\n readonly name?: string\n readonly version?: string\n readonly description?: string\n readonly agents: readonly AppRef[]\n readonly workflows: readonly AppRef[]\n readonly workspace?: string\n readonly requires?: readonly string[]\n readonly ui?: AppFrontmatterUi\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n}\n\nfunction resolveRef(dir: string, path: string): string {\n return isAbsolute(path) ? path : join(dir, path)\n}\n\nfunction isRefArray(v: unknown): v is AppRef[] {\n return (\n Array.isArray(v) &&\n v.every(\n (e) =>\n typeof e === \"object\" &&\n e !== null &&\n typeof (e as { id?: unknown }).id === \"string\" &&\n typeof (e as { path?: unknown }).path === \"string\",\n )\n )\n}\n\n/** Minimal shape check — see the module doc for why this stays loose. */\nfunction parseAppFrontmatter(data: Record<string, unknown>, appPath: string): AppFrontmatter {\n if (data.schema !== \"app/v1\") {\n throw new AppLoadError(\n `'${appPath}': expected frontmatter 'schema: app/v1', got ${JSON.stringify(data.schema)}.`,\n )\n }\n if (!isRefArray(data.agents)) {\n throw new AppLoadError(`'${appPath}': frontmatter 'agents' must be an array of { id, path }.`)\n }\n if (!isRefArray(data.workflows)) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'workflows' must be an array of { id, path }.`,\n )\n }\n if (data.requires !== undefined) {\n if (!Array.isArray(data.requires) || !data.requires.every((e) => typeof e === \"string\")) {\n throw new AppLoadError(`'${appPath}': frontmatter 'requires' must be an array of strings.`)\n }\n }\n return data as unknown as AppFrontmatter\n}\n\nasync function loadAgentEntry(dir: string, ref: AppRef): Promise<AgentEntry> {\n const agentPath = resolveRef(dir, ref.path)\n let source: string\n try {\n source = await readFile(agentPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `agent '${ref.id}': cannot read '${agentPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n let body: string\n let manifest: ReturnType<typeof parseAgentManifest>\n try {\n manifest = parseAgentManifest(source)\n body = manifest.body.trim()\n } catch (err) {\n throw new AppLoadError(\n `agent '${ref.id}' at '${agentPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n return { agent: agentFromManifest(manifest), ...(body ? { body } : {}) }\n}\n\nasync function loadWorkflowRef(dir: string, ref: AppRef) {\n const wfPath = resolveRef(dir, ref.path)\n try {\n return await loadWorkflowHandle(wfPath)\n } catch (err) {\n throw new AppLoadError(\n `workflow '${ref.id}' at '${wfPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n}\n\n/**\n * Load `<dir>/.agentproto/APP.md` and every AGENT.md/WORKFLOW.md (and, if\n * declared, `<dir>/WORKSPACE.md`) it references, then re-run `defineApp` on\n * the result. Throws {@link AppLoadError} naming the offending path on a\n * missing APP.md, a missing referenced file, or a frontmatter/schema\n * mismatch; throws `AppDefinitionError` (from `defineApp`) if the loaded\n * bundle fails the attachment invariant.\n */\nexport async function loadAppHandle(dir: string): Promise<AppHandle> {\n const appPath = join(dir, \".agentproto\", \"APP.md\")\n let source: string\n try {\n source = await readFile(appPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `cannot read '${appPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n\n const parsed = matter(source)\n const fm = parseAppFrontmatter(parsed.data, appPath)\n\n const agents: AgentEntry[] = []\n for (const ref of fm.agents) {\n agents.push(await loadAgentEntry(dir, ref))\n }\n\n const workflows = []\n for (const ref of fm.workflows) {\n workflows.push(await loadWorkflowRef(dir, ref))\n }\n\n let workspace\n if (fm.workspace) {\n const workspacePath = join(dir, \"WORKSPACE.md\")\n let workspaceSource: string\n try {\n workspaceSource = await readFile(workspacePath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `workspace '${fm.workspace}': cannot read '${workspacePath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n try {\n workspace = workspaceFromManifest(parseWorkspaceManifest(workspaceSource))\n } catch (err) {\n throw new AppLoadError(\n `workspace '${fm.workspace}' at '${workspacePath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n }\n\n let ui\n if (fm.ui) {\n const uiPath = resolveRef(dir, fm.ui.path)\n let html: string\n try {\n html = await readFile(uiPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(\n `ui: cannot read '${uiPath}': ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n ui = {\n html,\n ...(fm.ui.title !== undefined ? { title: fm.ui.title } : {}),\n ...(fm.ui.description !== undefined ? { description: fm.ui.description } : {}),\n ...(fm.ui.tools !== undefined ? { tools: fm.ui.tools } : {}),\n ...(fm.ui.csp !== undefined ? { csp: fm.ui.csp } : {}),\n }\n }\n\n return defineApp({\n agents,\n workflows,\n ...(workspace ? { workspace } : {}),\n ...(fm.id !== undefined ? { id: fm.id } : {}),\n ...(fm.name !== undefined ? { name: fm.name } : {}),\n ...(fm.version !== undefined ? { version: fm.version } : {}),\n ...(fm.description !== undefined ? { description: fm.description } : {}),\n ...(fm.requires !== undefined ? { requires: fm.requires } : {}),\n ...(ui !== undefined ? { ui } : {}),\n ...(fm.artifacts !== undefined ? { artifacts: fm.artifacts } : {}),\n ...(fm.dev !== undefined ? { dev: fm.dev } : {}),\n })\n}\n"]}
|
package/dist/load-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-app.d.ts","sourceRoot":"","sources":["../src/load-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"load-app.d.ts","sourceRoot":"","sources":["../src/load-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,KAAK,EAAiD,SAAS,EAAE,MAAM,YAAY,CAAA;AAG1F,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B;AA2GD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA6EnE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -64,6 +64,39 @@ export interface WorkspaceShorthand {
|
|
|
64
64
|
* structurally — a built handle carries `schema: "workspace/v1"`.
|
|
65
65
|
*/
|
|
66
66
|
export type WorkspaceInput = WorkspaceHandle | WorkspaceShorthand;
|
|
67
|
+
/**
|
|
68
|
+
* A single HTML surface an app ships alongside its agents — the artifact a
|
|
69
|
+
* host renders (e.g. an embedded panel). `html` is the full document; `emit`
|
|
70
|
+
* writes it to `.agentproto/ui/index.html` rather than inlining it into the
|
|
71
|
+
* APP.md frontmatter.
|
|
72
|
+
*/
|
|
73
|
+
export interface AppUiDefinition {
|
|
74
|
+
readonly html: string;
|
|
75
|
+
readonly title?: string;
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
readonly tools?: readonly string[];
|
|
78
|
+
readonly csp?: {
|
|
79
|
+
readonly connectDomains?: readonly string[];
|
|
80
|
+
readonly resourceDomains?: readonly string[];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** A kind of artifact the app's agents may produce, declared for discovery. */
|
|
84
|
+
export interface AppArtifactDecl {
|
|
85
|
+
readonly type: string;
|
|
86
|
+
readonly description?: string;
|
|
87
|
+
}
|
|
88
|
+
/** One way to launch the app for local development. */
|
|
89
|
+
export interface AppDevLaunchConfig {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly runtimeExecutable: string;
|
|
92
|
+
readonly runtimeArgs?: readonly string[];
|
|
93
|
+
readonly port?: number;
|
|
94
|
+
readonly url?: string;
|
|
95
|
+
}
|
|
96
|
+
/** Dev-launch configuration for the app, carried verbatim in APP.md frontmatter. */
|
|
97
|
+
export interface AppDevDefinition {
|
|
98
|
+
readonly launch: readonly AppDevLaunchConfig[];
|
|
99
|
+
}
|
|
67
100
|
/**
|
|
68
101
|
* Input to `defineApp`. Each `agents[]` entry is an already-validated
|
|
69
102
|
* `AgentHandle` (bare, no body) or an `AgentEntry` (handle + body).
|
|
@@ -94,6 +127,12 @@ export interface AppDefinition {
|
|
|
94
127
|
readonly description?: string;
|
|
95
128
|
/** APP ids this app depends on. */
|
|
96
129
|
readonly requires?: readonly string[];
|
|
130
|
+
/** An HTML surface the app ships alongside its agents. */
|
|
131
|
+
readonly ui?: AppUiDefinition;
|
|
132
|
+
/** Artifact types this app's agents may produce, declared for discovery. */
|
|
133
|
+
readonly artifacts?: readonly AppArtifactDecl[];
|
|
134
|
+
/** Dev-launch configuration for running the app locally. */
|
|
135
|
+
readonly dev?: AppDevDefinition;
|
|
97
136
|
}
|
|
98
137
|
/** Options for `toMastraAgent(s)`. Same resolvers as `buildMastraAgent`. */
|
|
99
138
|
export type ToMastraAgentOptions = BuildMastraAgentOptions;
|
|
@@ -107,6 +146,8 @@ export interface EmittedApp {
|
|
|
107
146
|
readonly workspacePath?: string;
|
|
108
147
|
/** Absolute path to the root `APP.md` index, always written. */
|
|
109
148
|
readonly appPath: string;
|
|
149
|
+
/** Absolute path to the written `.agentproto/ui/index.html`, when the app has a `ui`. */
|
|
150
|
+
readonly uiPath?: string;
|
|
110
151
|
}
|
|
111
152
|
/**
|
|
112
153
|
* The frozen result of `defineApp`. Carries the cross-linked agents +
|
|
@@ -128,6 +169,12 @@ export interface AppHandle {
|
|
|
128
169
|
readonly description?: string;
|
|
129
170
|
/** APP ids this app depends on. */
|
|
130
171
|
readonly requires?: readonly string[];
|
|
172
|
+
/** An HTML surface the app ships alongside its agents. */
|
|
173
|
+
readonly ui?: AppUiDefinition;
|
|
174
|
+
/** Artifact types this app's agents may produce, declared for discovery. */
|
|
175
|
+
readonly artifacts?: readonly AppArtifactDecl[];
|
|
176
|
+
/** Dev-launch configuration for running the app locally. */
|
|
177
|
+
readonly dev?: AppDevDefinition;
|
|
131
178
|
/**
|
|
132
179
|
* Build agents into runnable Mastra agents whose `instructions` field is
|
|
133
180
|
* the real system prompt (body → `composeInstructions`), keyed by agent id.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
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sBAAsB,CAAC,CAAC,CAAA;IAElD;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;IAEnD;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAE1E;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/app-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "@agentproto/app-kit — declare an agent (with its system prompt) and its workflows in one TypeScript module and import them anywhere. A thin umbrella over AIP-42 defineAgent + AIP-15 defineWorkflow: defineApp cross-links the two (every workflow agent-step must target the app's agent, every agent workflow ref must resolve), toMastraAgent turns the AGENT.md body into a real Mastra `instructions` field, and emit writes the .agents/<id>/AGENT.md + WORKFLOW.md(+entry) pair that runs through the agentproto-run lane unchanged.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"gray-matter": "^4.0.3",
|
|
46
46
|
"@agentproto/agent": "0.2.1",
|
|
47
|
-
"@agentproto/mastra": "0.2.
|
|
47
|
+
"@agentproto/mastra": "0.2.6",
|
|
48
48
|
"@agentproto/workflow": "0.2.0",
|
|
49
49
|
"@agentproto/workflow-loader": "0.1.3",
|
|
50
50
|
"@agentproto/workspace": "0.1.0"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mastra/core": ">=1.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@mastra/core": "1.
|
|
56
|
+
"@mastra/core": "1.57.0",
|
|
57
57
|
"@types/node": "^25.6.2",
|
|
58
58
|
"tsup": "^8.5.1",
|
|
59
59
|
"typescript": "^5.9.3",
|