@agentproto/app-kit 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/define-app.d.ts.map +1 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +170 -3
- package/dist/index.mjs.map +1 -1
- package/dist/load-app-tools.d.ts +45 -0
- package/dist/load-app-tools.d.ts.map +1 -0
- package/dist/load-app.d.ts +7 -3
- package/dist/load-app.d.ts.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -169,10 +169,38 @@ serve`) and receives a `window.McpApp` bridge:
|
|
|
169
169
|
- `openLink(url)` — ask the host to open a URL.
|
|
170
170
|
- `onTeardown(cb)` — register a cleanup callback fired when the host tears down
|
|
171
171
|
the panel.
|
|
172
|
+
- `getHostContext()` / `onHostContext(cb)` — the host context (display mode,
|
|
173
|
+
theme, safe-area insets, …), merged on every `host-context-changed`.
|
|
174
|
+
- `displayMode` — the fullscreen toggle, also on `window.McpApp.displayMode`.
|
|
172
175
|
|
|
173
176
|
In a standalone browser tab, `callTool` proxies to the daemon's `/mcp` endpoint,
|
|
174
177
|
while `sendMessage` and `updateModelContext` reject (there is no chat host).
|
|
175
178
|
|
|
179
|
+
#### Display mode (⤢ Agrandir)
|
|
180
|
+
|
|
181
|
+
Every `ui` panel gets a floating fullscreen toggle for free, placed clear of
|
|
182
|
+
the host's own chrome (`hostContext.safeAreaInsets`) and themed from
|
|
183
|
+
`hostContext.theme`. It appears **only** for modes the host advertises in
|
|
184
|
+
`hostContext.availableDisplayModes` — a host with its own native control
|
|
185
|
+
(Claude Desktop) advertises none and gets no second button.
|
|
186
|
+
|
|
187
|
+
To place it yourself, opt the floating one out and mount it where you want:
|
|
188
|
+
|
|
189
|
+
```html
|
|
190
|
+
<meta name="agentproto-display-toggle" content="none">
|
|
191
|
+
<script>
|
|
192
|
+
const app = await window.McpApp.connect()
|
|
193
|
+
app.displayMode.mountToggle(document.querySelector("header"))
|
|
194
|
+
app.displayMode.onChange(mode => console.log("now", mode))
|
|
195
|
+
</script>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`content="optimistic"` instead shows the button against a host that
|
|
199
|
+
advertises nothing but may still honour `ui/request-display-mode`; the first
|
|
200
|
+
refusal hides it permanently. `connect({ displayToggle: … })` is the
|
|
201
|
+
programmatic equivalent and wins over the meta tag. Full API and the
|
|
202
|
+
`--agentproto-dm-*` CSS variables: `@agentproto/app-client/display-mode`.
|
|
203
|
+
|
|
176
204
|
### Skill surface flow
|
|
177
205
|
|
|
178
206
|
1. The app declares `skill: { path: "/abs/path/to/skill-dir", title?, description? }`
|
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;AAQH,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;AAQH,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,CA8IvD;AAiID,YAAY,EAAE,aAAa,EAAE,CAAA"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Thrown by `loadAppHandle` and its helpers (`loadAppBundledTools`, …) on
|
|
2
|
+
* any disk/parse/validation failure while reading an app bundle off disk. */
|
|
3
|
+
export declare class AppLoadError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;8EAC8E;AAC9E,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
export { defineApp, AppDefinitionError } from "./define-app.js";
|
|
40
40
|
export { emitApp } from "./emit.js";
|
|
41
41
|
export { loadAppHandle, AppLoadError, resolveAppUIRoot } from "./load-app.js";
|
|
42
|
+
export { loadAppBundledTools } from "./load-app-tools.js";
|
|
42
43
|
export { refKey, stripOwner } from "./refs.js";
|
|
43
44
|
export type { AppDefinition, AppHandle, AgentEntry, DoctypeHandle, WorkspaceShorthand, WorkspaceInput, AppUiDefinition, AppArtifactSurface, AppSkillSurface, AppArtifactDecl, AppDevLaunchConfig, AppDataDefinition, AppDevDefinition, ToMastraAgentOptions, EmittedApp, } from "./types.js";
|
|
44
45
|
//# 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,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC7E,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,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,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,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,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,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { join, relative, isAbsolute, dirname } from 'path';
|
|
1
|
+
import { join, relative, isAbsolute, dirname, resolve } from 'path';
|
|
2
2
|
import { defineWorkspace } from '@agentproto/workspace';
|
|
3
|
-
import { mkdir, writeFile, copyFile, cp, readFile } from 'fs/promises';
|
|
3
|
+
import { mkdir, writeFile, copyFile, cp, readFile, readdir } from 'fs/promises';
|
|
4
4
|
import matter2 from 'gray-matter';
|
|
5
5
|
import { parseAgentManifest, agentFromManifest } from '@agentproto/agent/manifest';
|
|
6
6
|
import { loadWorkflowHandle } from '@agentproto/workflow-loader';
|
|
7
7
|
import { workspaceFromManifest, parseWorkspaceManifest } from '@agentproto/workspace/manifest';
|
|
8
|
+
import { toolFromManifestOnly, parseToolManifest } from '@agentproto/tool';
|
|
9
|
+
import { parseDriverManifest, driverDefinitionFromManifest, driverFromManifest } from '@agentproto/driver/manifest';
|
|
10
|
+
import { normalizeToolId } from '@agentproto/driver';
|
|
11
|
+
import { defineCliDriver } from '@agentproto/driver-cli';
|
|
12
|
+
import { defineHttpDriver } from '@agentproto/driver-http';
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* @agentproto/app-kit v0.1.0
|
|
@@ -180,6 +185,8 @@ function defineApp(def) {
|
|
|
180
185
|
}
|
|
181
186
|
const agents = (def.agents ?? []).map(normalizeEntry);
|
|
182
187
|
const workflows = def.workflows ?? [];
|
|
188
|
+
const tools = def.tools ?? [];
|
|
189
|
+
const drivers = def.drivers ?? [];
|
|
183
190
|
const attachments = def.attach ?? [];
|
|
184
191
|
const workspace = def.workspace ? toWorkspaceHandle(def.workspace) : void 0;
|
|
185
192
|
const id = def.id;
|
|
@@ -196,12 +203,18 @@ function defineApp(def) {
|
|
|
196
203
|
const data = def.data ? Object.freeze({ ...def.data }) : void 0;
|
|
197
204
|
const category = def.category;
|
|
198
205
|
validateAttachment(agents, workflows);
|
|
206
|
+
validateUniqueIds(tools, "tool");
|
|
207
|
+
validateUniqueIds(drivers, "driver");
|
|
199
208
|
const frozenAgents = Object.freeze(agents.map((e) => Object.freeze({ ...e })));
|
|
200
209
|
const frozenWorkflows = Object.freeze([...workflows]);
|
|
210
|
+
const frozenTools = Object.freeze([...tools]);
|
|
211
|
+
const frozenDrivers = Object.freeze([...drivers]);
|
|
201
212
|
const frozenAttachments = Object.freeze([...attachments]);
|
|
202
213
|
const handle = {
|
|
203
214
|
agents: frozenAgents,
|
|
204
215
|
workflows: frozenWorkflows,
|
|
216
|
+
tools: frozenTools,
|
|
217
|
+
drivers: frozenDrivers,
|
|
205
218
|
attachments: frozenAttachments,
|
|
206
219
|
...workspace ? { workspace } : {},
|
|
207
220
|
...id !== void 0 ? { id } : {},
|
|
@@ -332,12 +345,163 @@ function validateAttachment(agents, workflows) {
|
|
|
332
345
|
function workflowRefs(agent) {
|
|
333
346
|
return agent.workflows ?? [];
|
|
334
347
|
}
|
|
348
|
+
function validateUniqueIds(items, kind) {
|
|
349
|
+
const seen = /* @__PURE__ */ new Set();
|
|
350
|
+
for (const item of items) {
|
|
351
|
+
if (seen.has(item.id)) {
|
|
352
|
+
throw new AppDefinitionError(`duplicate ${kind} id '${item.id}' in the bundle.`);
|
|
353
|
+
}
|
|
354
|
+
seen.add(item.id);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/errors.ts
|
|
335
359
|
var AppLoadError = class extends Error {
|
|
336
360
|
constructor(message) {
|
|
337
361
|
super(`loadAppHandle: ${message}`);
|
|
338
362
|
this.name = "AppLoadError";
|
|
339
363
|
}
|
|
340
364
|
};
|
|
365
|
+
async function listBundleIds(base) {
|
|
366
|
+
let entries;
|
|
367
|
+
try {
|
|
368
|
+
entries = await readdir(base, { withFileTypes: true });
|
|
369
|
+
} catch {
|
|
370
|
+
return [];
|
|
371
|
+
}
|
|
372
|
+
return entries.filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
373
|
+
}
|
|
374
|
+
function errMsg(err) {
|
|
375
|
+
return err instanceof Error ? err.message : String(err);
|
|
376
|
+
}
|
|
377
|
+
async function loadToolEntry(id, toolPath) {
|
|
378
|
+
let source;
|
|
379
|
+
try {
|
|
380
|
+
source = await readFile(toolPath, "utf8");
|
|
381
|
+
} catch (err) {
|
|
382
|
+
throw new AppLoadError(`tool '${id}': cannot read '${toolPath}': ${errMsg(err)}`);
|
|
383
|
+
}
|
|
384
|
+
try {
|
|
385
|
+
return toolFromManifestOnly(parseToolManifest(source));
|
|
386
|
+
} catch (err) {
|
|
387
|
+
throw new AppLoadError(`tool '${id}' at '${toolPath}': ${errMsg(err)}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function requiredSecretNames(fm) {
|
|
391
|
+
const auth = fm.auth;
|
|
392
|
+
const env = auth?.state?.env;
|
|
393
|
+
return Array.isArray(env) ? env.filter((e) => typeof e === "string") : [];
|
|
394
|
+
}
|
|
395
|
+
function wrapExecuteWithSecretCheck(driverId, execute, secretNames) {
|
|
396
|
+
if (secretNames.length === 0) return execute;
|
|
397
|
+
const wrapped = {};
|
|
398
|
+
for (const [toolId, fn] of Object.entries(execute)) {
|
|
399
|
+
wrapped[toolId] = async (args) => {
|
|
400
|
+
const resolved = {};
|
|
401
|
+
for (const name of secretNames) {
|
|
402
|
+
const value = process.env[name];
|
|
403
|
+
if (!value) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
`driver '${driverId}': missing required secret '${name}' (declared in DRIVER.md 'auth.state.env').`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
resolved[name] = value;
|
|
409
|
+
}
|
|
410
|
+
const priorSecrets = args.driverCtx.secrets ?? {};
|
|
411
|
+
return fn({ ...args, driverCtx: { ...args.driverCtx, secrets: { ...resolved, ...priorSecrets } } });
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
return wrapped;
|
|
415
|
+
}
|
|
416
|
+
function resolveCliCwd(appRoot, driverId, cwd) {
|
|
417
|
+
const absoluteAppRoot = resolve(appRoot);
|
|
418
|
+
if (cwd === void 0) return absoluteAppRoot;
|
|
419
|
+
if (typeof cwd !== "string" || cwd.trim() === "") {
|
|
420
|
+
throw new Error(`driver '${driverId}': 'metadata.cli.cwd' must be a non-empty string.`);
|
|
421
|
+
}
|
|
422
|
+
const resolved = isAbsolute(cwd) ? resolve(cwd) : resolve(absoluteAppRoot, cwd);
|
|
423
|
+
const rel = relative(absoluteAppRoot, resolved);
|
|
424
|
+
if (rel !== "" && (rel.startsWith("..") || isAbsolute(rel))) {
|
|
425
|
+
throw new Error(
|
|
426
|
+
`driver '${driverId}': 'metadata.cli.cwd' (${cwd}) resolves to '${resolved}', outside the app root '${absoluteAppRoot}'.`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
return resolved;
|
|
430
|
+
}
|
|
431
|
+
function driverHandleFromManifest(manifest, appRoot) {
|
|
432
|
+
const fm = manifest.frontmatter;
|
|
433
|
+
const secretNames = requiredSecretNames(fm);
|
|
434
|
+
if (fm.kind === "cli") {
|
|
435
|
+
const cliMeta = fm.metadata?.cli ?? {};
|
|
436
|
+
if (typeof cliMeta.bin !== "string" || cliMeta.bin.trim() === "") {
|
|
437
|
+
throw new Error(
|
|
438
|
+
"kind:cli DRIVER.md requires a non-empty 'metadata.cli.bin' frontmatter field naming the binary."
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
const handle = defineCliDriver({
|
|
442
|
+
...driverDefinitionFromManifest(manifest),
|
|
443
|
+
bin: cliMeta.bin,
|
|
444
|
+
binArgs: cliMeta.binArgs,
|
|
445
|
+
output: cliMeta.output,
|
|
446
|
+
tty: cliMeta.tty,
|
|
447
|
+
sandbox: cliMeta.sandbox,
|
|
448
|
+
cwd: resolveCliCwd(appRoot, fm.id, cliMeta.cwd)
|
|
449
|
+
});
|
|
450
|
+
return { ...handle, execute: wrapExecuteWithSecretCheck(fm.id, handle.execute, secretNames) };
|
|
451
|
+
}
|
|
452
|
+
if (fm.kind === "http") {
|
|
453
|
+
const httpMeta = fm.metadata?.http ?? {};
|
|
454
|
+
if (typeof httpMeta.baseUrl !== "string" || httpMeta.baseUrl.trim() === "") {
|
|
455
|
+
throw new Error("kind:http DRIVER.md requires a non-empty 'metadata.http.baseUrl' frontmatter field.");
|
|
456
|
+
}
|
|
457
|
+
const handle = defineHttpDriver({
|
|
458
|
+
...driverDefinitionFromManifest(manifest),
|
|
459
|
+
baseUrl: httpMeta.baseUrl,
|
|
460
|
+
defaultHeaders: httpMeta.defaultHeaders,
|
|
461
|
+
defaultMethod: httpMeta.defaultMethod,
|
|
462
|
+
streaming: httpMeta.streaming
|
|
463
|
+
});
|
|
464
|
+
return { ...handle, execute: wrapExecuteWithSecretCheck(fm.id, handle.execute, secretNames) };
|
|
465
|
+
}
|
|
466
|
+
const execute = {};
|
|
467
|
+
for (const entry of fm.implements) {
|
|
468
|
+
const toolId = normalizeToolId(entry.tool);
|
|
469
|
+
execute[toolId] = async () => {
|
|
470
|
+
throw new Error(
|
|
471
|
+
`driver '${fm.id}': kind '${fm.kind}' is not supported by this host \u2014 only 'cli' and 'http' drivers dispatch.`
|
|
472
|
+
);
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
return driverFromManifest({ manifest, execute });
|
|
476
|
+
}
|
|
477
|
+
async function loadDriverEntry(id, driverPath, appRoot) {
|
|
478
|
+
let source;
|
|
479
|
+
try {
|
|
480
|
+
source = await readFile(driverPath, "utf8");
|
|
481
|
+
} catch (err) {
|
|
482
|
+
throw new AppLoadError(`driver '${id}': cannot read '${driverPath}': ${errMsg(err)}`);
|
|
483
|
+
}
|
|
484
|
+
try {
|
|
485
|
+
return driverHandleFromManifest(parseDriverManifest(source), appRoot);
|
|
486
|
+
} catch (err) {
|
|
487
|
+
throw new AppLoadError(`driver '${id}' at '${driverPath}': ${errMsg(err)}`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
async function loadAppBundledTools(dir) {
|
|
491
|
+
const toolsDir = join(dir, ".agentproto", "tools");
|
|
492
|
+
const driversDir = join(dir, ".agentproto", "drivers");
|
|
493
|
+
const tools = [];
|
|
494
|
+
for (const id of await listBundleIds(toolsDir)) {
|
|
495
|
+
tools.push(await loadToolEntry(id, join(toolsDir, id, "TOOL.md")));
|
|
496
|
+
}
|
|
497
|
+
const drivers = [];
|
|
498
|
+
for (const id of await listBundleIds(driversDir)) {
|
|
499
|
+
drivers.push(await loadDriverEntry(id, join(driversDir, id, "DRIVER.md"), dir));
|
|
500
|
+
}
|
|
501
|
+
return { tools, drivers };
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// src/load-app.ts
|
|
341
505
|
function resolveRef(dir, path) {
|
|
342
506
|
return isAbsolute(path) ? path : join(dir, path);
|
|
343
507
|
}
|
|
@@ -459,6 +623,7 @@ async function loadAppHandle(dir) {
|
|
|
459
623
|
for (const ref of fm.workflows) {
|
|
460
624
|
workflows.push(await loadWorkflowRef(dir, ref));
|
|
461
625
|
}
|
|
626
|
+
const { tools, drivers } = await loadAppBundledTools(dir);
|
|
462
627
|
let workspace;
|
|
463
628
|
if (fm.workspace) {
|
|
464
629
|
const workspacePath = join(dir, "WORKSPACE.md");
|
|
@@ -501,6 +666,8 @@ async function loadAppHandle(dir) {
|
|
|
501
666
|
return defineApp({
|
|
502
667
|
agents,
|
|
503
668
|
workflows,
|
|
669
|
+
tools,
|
|
670
|
+
drivers,
|
|
504
671
|
...workspace ? { workspace } : {},
|
|
505
672
|
...fm.id !== void 0 ? { id: fm.id } : {},
|
|
506
673
|
...fm.name !== void 0 ? { name: fm.name } : {},
|
|
@@ -518,6 +685,6 @@ async function loadAppHandle(dir) {
|
|
|
518
685
|
});
|
|
519
686
|
}
|
|
520
687
|
|
|
521
|
-
export { AppDefinitionError, AppLoadError, defineApp, emitApp, loadAppHandle, refKey, resolveAppUIRoot, stripOwner };
|
|
688
|
+
export { AppDefinitionError, AppLoadError, defineApp, emitApp, loadAppBundledTools, loadAppHandle, refKey, resolveAppUIRoot, stripOwner };
|
|
522
689
|
//# sourceMappingURL=index.mjs.map
|
|
523
690
|
//# sourceMappingURL=index.mjs.map
|
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","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AC,EAAG,KAC1M,EAAC;AAAA,IACL,GAAI,GAAG,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,EAAW,EAAA,CAAG,SAAA,EAAU,GAAI,EAAC;AAAA,IAChE,GAAI,GAAG,GAAA,KAAQ,MAAA,GAAY,EAAE,GAAA,EAAK,EAAA,CAAG,GAAA,EAAI,GAAI,EAAC;AAAA,IAC9C,GAAI,GAAG,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,EAAA,CAAG,IAAA,EAAK,GAAI,EAAC;AAAA,IACjD,GAAI,GAAG,iBAAA,KAAsB,MAAA,GAAY,EAAE,iBAAA,EAAmB,EAAA,CAAG,iBAAA,EAAkB,GAAI,EAAC;AAAA,IACxF,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 { copyFile, cp, 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, AppArtifactSurface, AppDataDefinition, AppDevDefinition, AppSkillSurface, 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 artifact?: AppArtifactSurface\n readonly skill?: AppSkillSurface\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n readonly data?: AppDataDefinition\n readonly externalReadRoots?: readonly string[]\n readonly category?: string\n}\n\nexport async function emitApp(app: EmitInput, dir: string): Promise<EmittedApp> {\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 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.port !== undefined ? { port: app.ui.port } : {}),\n ...(app.ui.csp !== undefined ? { csp: app.ui.csp } : {}),\n }\n }\n\n let artifactPath: string | undefined\n let artifactFrontmatter: Record<string, unknown> | undefined\n if (app.artifact) {\n const artifactDir = join(dir, \".agentproto\", \"artifact\")\n await mkdir(artifactDir, { recursive: true })\n artifactPath = join(artifactDir, \"index.html\")\n await copyFile(app.artifact.path, artifactPath)\n artifactFrontmatter = {\n path: relative(dir, artifactPath),\n ...(app.artifact.title !== undefined ? { title: app.artifact.title } : {}),\n ...(app.artifact.description !== undefined ? { description: app.artifact.description } : {}),\n }\n }\n\n let skillPath: string | undefined\n let skillFrontmatter: Record<string, unknown> | undefined\n if (app.skill) {\n skillPath = join(dir, \".agentproto\", \"skill\")\n await mkdir(skillPath, { recursive: true })\n await cp(app.skill.path, skillPath, { recursive: true })\n skillFrontmatter = {\n path: relative(dir, skillPath),\n ...(app.skill.title !== undefined ? { title: app.skill.title } : {}),\n ...(app.skill.description !== undefined ? { description: app.skill.description } : {}),\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 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 ...(artifactFrontmatter !== undefined ? { artifact: artifactFrontmatter } : {}),\n ...(skillFrontmatter !== undefined ? { skill: skillFrontmatter } : {}),\n ...(app.artifacts !== undefined ? { artifacts: app.artifacts } : {}),\n ...(app.dev !== undefined ? { dev: app.dev } : {}),\n ...(app.data !== undefined ? { data: app.data } : {}),\n ...(app.externalReadRoots !== undefined ? { externalReadRoots: app.externalReadRoots } : {}),\n ...(app.category !== undefined ? { category: app.category } : {}),\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 ...(artifactPath ? { artifactPath } : {}),\n ...(skillPath ? { skillPath } : {}),\n }\n}\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 { isAbsolute } from \"node:path\"\nimport { defineWorkspace } from \"@agentproto/workspace\"\nimport type { AgentHandle, AnyRef } from \"@agentproto/agent\"\nimport type { BuildMastraAgentResult } from \"@agentproto/mastra\"\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 (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.agents === undefined || def.agents.length === 0) && def.ui === undefined) {\n throw new AppDefinitionError(\n \"an app needs at least one agent, or a `ui` block for a UI-only app — got neither.\",\n )\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 if (def.data !== undefined && def.data.dir !== undefined && (typeof def.data.dir !== \"string\" || def.data.dir.trim() === \"\")) {\n throw new AppDefinitionError(\"`data.dir` must be a non-empty string when present.\")\n }\nif (def.artifact !== undefined && (typeof def.artifact.path !== \"string\" || def.artifact.path.trim() === \"\")) {\n throw new AppDefinitionError(\"`artifact.path` must be a non-empty string when `artifact` is present.\")\n }\n // AIP-53 rule 7: `artifact.path` / `skill.path` MUST be absolute —\n // `emit` copies from them at write time and a relative path has no\n // defined base to resolve against.\n if (def.artifact !== undefined && !isAbsolute(def.artifact.path)) {\n throw new AppDefinitionError(\n `\\`artifact.path\\` must be an absolute filesystem path, got '${def.artifact.path}' — a relative path has no defined base to resolve against (AIP-53 rule 7).`,\n )\n }\n if (def.skill !== undefined && (typeof def.skill.path !== \"string\" || def.skill.path.trim() === \"\")) {\n throw new AppDefinitionError(\"`skill.path` must be a non-empty string when `skill` is present.\")\n }\n if (def.skill !== undefined && !isAbsolute(def.skill.path)) {\n throw new AppDefinitionError(\n `\\`skill.path\\` must be an absolute filesystem path, got '${def.skill.path}' — a relative path has no defined base to resolve against (AIP-53 rule 7).`,\n )\n }\n if (def.category !== undefined && def.category.trim() === \"\") {\n throw new AppDefinitionError(\"`category` must be a non-empty string 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 const ui = def.ui ? Object.freeze({ ...def.ui }) : undefined\n const artifact = def.artifact ? Object.freeze({ ...def.artifact }) : undefined\n const skill = def.skill ? Object.freeze({ ...def.skill }) : 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 const externalReadRoots = def.externalReadRoots ? Object.freeze([...def.externalReadRoots]) : undefined\n const data = def.data ? Object.freeze({ ...def.data }) : undefined\n const category = def.category\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 ...(artifact !== undefined ? { artifact } : {}),\n ...(skill !== undefined ? { skill } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(externalReadRoots !== undefined ? { externalReadRoots } : {}),\n ...(category !== undefined ? { category } : {}),\n\n async toMastraAgents(opts: ToMastraAgentOptions, only?: readonly string[]) {\n const targets = only ? selectAgents(frozenAgents, only) : frozenAgents\n const out: Record<string, BuildMastraAgentResult> = {}\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 ...(artifact !== undefined ? { artifact } : {}),\n ...(skill !== undefined ? { skill } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(externalReadRoots !== undefined ? { externalReadRoots } : {}),\n ...(category !== undefined ? { category } : {}),\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\nasync function buildOne(entry: AgentEntry, opts: ToMastraAgentOptions): Promise<BuildMastraAgentResult> {\n // Dynamic import, not a static top-level one: `@agentproto/mastra` pulls in\n // `@mastra/core` (a documented peer dependency — see index.ts), which a\n // bundler would otherwise inline into ANY host that merely calls\n // `defineApp()` without ever calling `toMastraAgent(s)` (e.g. a UI-only app\n // consumer). Loading it lazily, only from the one place it's actually used,\n // keeps `defineApp()`/the rest of this module free of that cost.\n const { buildMastraAgent } = await import(\"@agentproto/mastra\")\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 * Frontmatter validation here is deliberately minimal, and that is now an\n * AIP-53 conformance decision, not an accident of app having \"no AIP yet\":\n * AIP-53 (Draft) freezes the loader contract at the checks below — schema\n * MUST be exactly `app/v1`, `agents`/`workflows` MUST be `{ id, path }`\n * ref arrays, every ref MUST resolve, and the bundle MUST re-run through\n * `defineApp` — and it does NOT require rejecting unknown frontmatter\n * keys. Staying permissive past the frozen checks lets a future frontmatter\n * key (e.g. a later WP's addition) round-trip through this loader without\n * hosts that haven't upgraded rejecting the whole app; tightening beyond\n * the spec would break that forward compatibility for no conformance gain.\n */\n\nimport { readFile } from \"node:fs/promises\"\nimport { dirname, 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, AppDataDefinition, 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 port?: number\n readonly csp?: {\n readonly connectDomains?: readonly string[]\n readonly resourceDomains?: readonly string[]\n readonly frameDomains?: readonly string[]\n }\n}\n\ninterface AppFrontmatterArtifact {\n readonly path: string\n readonly title?: string\n readonly description?: string\n}\n\ninterface AppFrontmatterSkill {\n readonly path: string\n readonly title?: string\n readonly description?: 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 readonly ui?: AppFrontmatterUi\n readonly artifact?: AppFrontmatterArtifact\n readonly skill?: AppFrontmatterSkill\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n readonly data?: AppDataDefinition\n readonly externalReadRoots?: readonly string[]\n readonly category?: string\n}\n\nfunction resolveRef(dir: string, path: string): string {\n return isAbsolute(path) ? path : join(dir, path)\n}\n\n/**\n * Resolve the UI ROOT directory an app's UI should be served from — the\n * same resolution `app_install`/`loadAppHandle` uses for `ui.path`, so\n * `app serve` and install agree on where the UI lives.\n *\n * Reads `<appDir>/.agentproto/APP.md` frontmatter: when a `ui.path` is\n * declared, the UI root is the directory CONTAINING that entry file (e.g.\n * `ui.path: ui/index.html` → `<appDir>/ui`); when `ui` is absent, returns\n * `undefined` and callers fall back to the legacy `<appDir>/.agentproto/ui/`.\n * Throws {@link AppLoadError} on a `ui` that isn't an object or whose `path`\n * isn't a non-empty string — the same shape `loadAppHandle` would reject.\n * Returns `undefined` (not a throw) when APP.md itself is unreadable, since\n * callers check APP.md existence separately.\n */\nexport async function resolveAppUIRoot(appDir: string): Promise<string | undefined> {\n const appMdPath = join(appDir, \".agentproto\", \"APP.md\")\n let source: string\n try {\n source = await readFile(appMdPath, \"utf8\")\n } catch {\n return undefined\n }\n const data = matter(source).data as Record<string, unknown>\n const ui = data.ui\n if (ui === undefined) return undefined\n if (typeof ui !== \"object\" || ui === null || Array.isArray(ui)) {\n throw new AppLoadError(`'${appMdPath}': frontmatter 'ui' must be an object.`)\n }\n const path = (ui as Record<string, unknown>).path\n if (typeof path !== \"string\" || path.trim() === \"\") {\n throw new AppLoadError(\n `'${appMdPath}': frontmatter 'ui.path' must be a non-empty string.`,\n )\n }\n return dirname(resolveRef(appDir, 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 if (data.data !== undefined) {\n const d = data.data as { dir?: unknown } | null\n if (\n typeof d !== \"object\" ||\n d === null ||\n (d.dir !== undefined && (typeof d.dir !== \"string\" || d.dir.trim() === \"\"))\n ) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'data' must be an object whose optional 'dir' is a non-empty string.`,\n )\n }\n }\n if (data.externalReadRoots !== undefined) {\n if (\n !Array.isArray(data.externalReadRoots) ||\n !data.externalReadRoots.every((e) => typeof e === \"string\" && e.trim() !== \"\")\n ) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'externalReadRoots' must be an array of non-empty strings.`,\n )\n }\n }\n if (data.category !== undefined && (typeof data.category !== \"string\" || data.category.trim() === \"\")) {\n throw new AppLoadError(`'${appPath}': frontmatter 'category' must be a non-empty string.`)\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.port !== undefined ? { port: fm.ui.port } : {}),\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.artifact !== undefined\n ? { artifact: { path: resolveRef(dir, fm.artifact.path), ...(fm.artifact.title !== undefined ? { title: fm.artifact.title } : {}), ...(fm.artifact.description !== undefined ? { description: fm.artifact.description } : {}) } }\n : {}),\n ...(fm.skill !== undefined\n ? { skill: { path: resolveRef(dir, fm.skill.path), ...(fm.skill.title !== undefined ? { title: fm.skill.title } : {}), ...(fm.skill.description !== undefined ? { description: fm.skill.description } : {}) } }\n : {}),\n ...(fm.artifacts !== undefined ? { artifacts: fm.artifacts } : {}),\n ...(fm.dev !== undefined ? { dev: fm.dev } : {}),\n ...(fm.data !== undefined ? { data: fm.data } : {}),\n ...(fm.externalReadRoots !== undefined ? { externalReadRoots: fm.externalReadRoots } : {}),\n ...(fm.category !== undefined ? { category: fm.category } : {}),\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/refs.ts","../src/emit.ts","../src/define-app.ts","../src/errors.ts","../src/load-app-tools.ts","../src/load-app.ts"],"names":["workflowRefs","matter","isAbsolute","relative","join","readFile"],"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,EAA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,GAAY,EAAE,SAAA,EAAW,EAAA,CAAG,SAAA,EAAU,GAAI,EAAC;AAAA,IAChE,GAAI,GAAG,GAAA,KAAQ,MAAA,GAAY,EAAE,GAAA,EAAK,EAAA,CAAG,GAAA,EAAI,GAAI,EAAC;AAAA,IAC9C,GAAI,GAAG,IAAA,KAAS,MAAA,GAAY,EAAE,IAAA,EAAM,EAAA,CAAG,IAAA,EAAK,GAAI,EAAC;AAAA,IACjD,GAAI,GAAG,iBAAA,KAAsB,MAAA,GAAY,EAAE,iBAAA,EAAmB,EAAA,CAAG,iBAAA,EAAkB,GAAI,EAAC;AAAA,IACxF,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 { copyFile, cp, 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, AppArtifactSurface, AppDataDefinition, AppDevDefinition, AppSkillSurface, 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 artifact?: AppArtifactSurface\n readonly skill?: AppSkillSurface\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n readonly data?: AppDataDefinition\n readonly externalReadRoots?: readonly string[]\n readonly category?: string\n}\n\nexport async function emitApp(app: EmitInput, dir: string): Promise<EmittedApp> {\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 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.port !== undefined ? { port: app.ui.port } : {}),\n ...(app.ui.csp !== undefined ? { csp: app.ui.csp } : {}),\n }\n }\n\n let artifactPath: string | undefined\n let artifactFrontmatter: Record<string, unknown> | undefined\n if (app.artifact) {\n const artifactDir = join(dir, \".agentproto\", \"artifact\")\n await mkdir(artifactDir, { recursive: true })\n artifactPath = join(artifactDir, \"index.html\")\n await copyFile(app.artifact.path, artifactPath)\n artifactFrontmatter = {\n path: relative(dir, artifactPath),\n ...(app.artifact.title !== undefined ? { title: app.artifact.title } : {}),\n ...(app.artifact.description !== undefined ? { description: app.artifact.description } : {}),\n }\n }\n\n let skillPath: string | undefined\n let skillFrontmatter: Record<string, unknown> | undefined\n if (app.skill) {\n skillPath = join(dir, \".agentproto\", \"skill\")\n await mkdir(skillPath, { recursive: true })\n await cp(app.skill.path, skillPath, { recursive: true })\n skillFrontmatter = {\n path: relative(dir, skillPath),\n ...(app.skill.title !== undefined ? { title: app.skill.title } : {}),\n ...(app.skill.description !== undefined ? { description: app.skill.description } : {}),\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 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 ...(artifactFrontmatter !== undefined ? { artifact: artifactFrontmatter } : {}),\n ...(skillFrontmatter !== undefined ? { skill: skillFrontmatter } : {}),\n ...(app.artifacts !== undefined ? { artifacts: app.artifacts } : {}),\n ...(app.dev !== undefined ? { dev: app.dev } : {}),\n ...(app.data !== undefined ? { data: app.data } : {}),\n ...(app.externalReadRoots !== undefined ? { externalReadRoots: app.externalReadRoots } : {}),\n ...(app.category !== undefined ? { category: app.category } : {}),\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 ...(artifactPath ? { artifactPath } : {}),\n ...(skillPath ? { skillPath } : {}),\n }\n}\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 { isAbsolute } from \"node:path\"\nimport { defineWorkspace } from \"@agentproto/workspace\"\nimport type { AgentHandle, AnyRef } from \"@agentproto/agent\"\nimport type { BuildMastraAgentResult } from \"@agentproto/mastra\"\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 (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.agents === undefined || def.agents.length === 0) && def.ui === undefined) {\n throw new AppDefinitionError(\n \"an app needs at least one agent, or a `ui` block for a UI-only app — got neither.\",\n )\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 if (def.data !== undefined && def.data.dir !== undefined && (typeof def.data.dir !== \"string\" || def.data.dir.trim() === \"\")) {\n throw new AppDefinitionError(\"`data.dir` must be a non-empty string when present.\")\n }\nif (def.artifact !== undefined && (typeof def.artifact.path !== \"string\" || def.artifact.path.trim() === \"\")) {\n throw new AppDefinitionError(\"`artifact.path` must be a non-empty string when `artifact` is present.\")\n }\n // AIP-53 rule 7: `artifact.path` / `skill.path` MUST be absolute —\n // `emit` copies from them at write time and a relative path has no\n // defined base to resolve against.\n if (def.artifact !== undefined && !isAbsolute(def.artifact.path)) {\n throw new AppDefinitionError(\n `\\`artifact.path\\` must be an absolute filesystem path, got '${def.artifact.path}' — a relative path has no defined base to resolve against (AIP-53 rule 7).`,\n )\n }\n if (def.skill !== undefined && (typeof def.skill.path !== \"string\" || def.skill.path.trim() === \"\")) {\n throw new AppDefinitionError(\"`skill.path` must be a non-empty string when `skill` is present.\")\n }\n if (def.skill !== undefined && !isAbsolute(def.skill.path)) {\n throw new AppDefinitionError(\n `\\`skill.path\\` must be an absolute filesystem path, got '${def.skill.path}' — a relative path has no defined base to resolve against (AIP-53 rule 7).`,\n )\n }\n if (def.category !== undefined && def.category.trim() === \"\") {\n throw new AppDefinitionError(\"`category` must be a non-empty string when present.\")\n }\n\n const agents = (def.agents ?? []).map(normalizeEntry)\n const workflows = def.workflows ?? []\n const tools = def.tools ?? []\n const drivers = def.drivers ?? []\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 artifact = def.artifact ? Object.freeze({ ...def.artifact }) : undefined\n const skill = def.skill ? Object.freeze({ ...def.skill }) : 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 const externalReadRoots = def.externalReadRoots ? Object.freeze([...def.externalReadRoots]) : undefined\n const data = def.data ? Object.freeze({ ...def.data }) : undefined\n const category = def.category\n\n validateAttachment(agents, workflows)\n validateUniqueIds(tools, \"tool\")\n validateUniqueIds(drivers, \"driver\")\n\n const frozenAgents = Object.freeze(agents.map((e) => Object.freeze({ ...e })))\n const frozenWorkflows = Object.freeze([...workflows])\n const frozenTools = Object.freeze([...tools])\n const frozenDrivers = Object.freeze([...drivers])\n const frozenAttachments = Object.freeze([...attachments])\n\n const handle: AppHandle = {\n agents: frozenAgents,\n workflows: frozenWorkflows,\n tools: frozenTools,\n drivers: frozenDrivers,\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 ...(artifact !== undefined ? { artifact } : {}),\n ...(skill !== undefined ? { skill } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(externalReadRoots !== undefined ? { externalReadRoots } : {}),\n ...(category !== undefined ? { category } : {}),\n\n async toMastraAgents(opts: ToMastraAgentOptions, only?: readonly string[]) {\n const targets = only ? selectAgents(frozenAgents, only) : frozenAgents\n const out: Record<string, BuildMastraAgentResult> = {}\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 ...(artifact !== undefined ? { artifact } : {}),\n ...(skill !== undefined ? { skill } : {}),\n ...(artifacts !== undefined ? { artifacts } : {}),\n ...(dev !== undefined ? { dev } : {}),\n ...(data !== undefined ? { data } : {}),\n ...(externalReadRoots !== undefined ? { externalReadRoots } : {}),\n ...(category !== undefined ? { category } : {}),\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\nasync function buildOne(entry: AgentEntry, opts: ToMastraAgentOptions): Promise<BuildMastraAgentResult> {\n // Dynamic import, not a static top-level one: `@agentproto/mastra` pulls in\n // `@mastra/core` (a documented peer dependency — see index.ts), which a\n // bundler would otherwise inline into ANY host that merely calls\n // `defineApp()` without ever calling `toMastraAgent(s)` (e.g. a UI-only app\n // consumer). Loading it lazily, only from the one place it's actually used,\n // keeps `defineApp()`/the rest of this module free of that cost.\n const { buildMastraAgent } = await import(\"@agentproto/mastra\")\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\n/** Duplicate-id guard for `tools`/`drivers` — mirrors the agent/workflow id\n * uniqueness `validateAttachment` already enforces. */\nfunction validateUniqueIds(items: readonly { id: string }[], kind: string): void {\n const seen = new Set<string>()\n for (const item of items) {\n if (seen.has(item.id)) {\n throw new AppDefinitionError(`duplicate ${kind} id '${item.id}' in the bundle.`)\n }\n seen.add(item.id)\n }\n}\n\nexport type { DoctypeHandle }\n","/** Thrown by `loadAppHandle` and its helpers (`loadAppBundledTools`, …) on\n * any disk/parse/validation failure while reading an app bundle off disk. */\nexport class AppLoadError extends Error {\n constructor(message: string) {\n super(`loadAppHandle: ${message}`)\n this.name = \"AppLoadError\"\n }\n}\n","/**\n * Loader for an app's bundled AIP-14 TOOL.md contracts and AIP-30 DRIVER.md\n * implementations — the deterministic-step half of WORKFLOW.md `tool` steps\n * (yt-dlp, an STT HTTP call, a PDF render, …), as opposed to `agent` steps.\n *\n * Neither AIP-53 (app, still Draft with no scaffolded spec) nor AIP-14/30\n * declare a bundle location for these, so this is a convention this loader\n * defines: `<dir>/.agentproto/tools/<id>/TOOL.md` and\n * `<dir>/.agentproto/drivers/<id>/DRIVER.md`, one manifest per `<id>`\n * subdirectory, discovered by listing — not declared as APP.md frontmatter\n * refs like `agents`/`workflows` are. An absent `tools`/`drivers` directory\n * is not an error (most apps have neither); a subdirectory that exists but\n * fails to parse, or is missing its TOOL.md/DRIVER.md, fails the whole load\n * — `loadAppHandle` never silently drops a broken tool/driver bundle.\n *\n * Only `kind: cli` and `kind: http` drivers dispatch (the two\n * `@agentproto/driver-cli` / `@agentproto/driver-http` sugars this package\n * already depends on). Any other `kind` (`mcp`, `sdk`, `builtin`) still\n * loads — a malformed manifest still fails the app load — but its execute\n * body refuses clearly instead of silently no-oping or crashing on a\n * dispatch mechanism this host doesn't implement yet.\n *\n * A `kind: cli` driver's subprocess `cwd` defaults to the app root (`dir`,\n * the directory containing `.agentproto/`) rather than the host process's\n * own cwd — relative paths in an app-bundled cli driver (DRIVER.md argv,\n * `--out-dir`-style flags, …) resolve against the app root. A DRIVER.md can\n * override this with `metadata.cli.cwd`; a relative value there is itself\n * resolved against the app root, and a value that escapes the app root\n * (`../..`) is a load error, not a silent escape.\n */\n\nimport { readdir, readFile } from \"node:fs/promises\"\nimport type { Dirent } from \"node:fs\"\nimport { isAbsolute, join, relative, resolve } from \"node:path\"\nimport {\n parseToolManifest,\n toolFromManifestOnly,\n type ToolHandle,\n} from \"@agentproto/tool\"\nimport {\n driverFromManifest,\n driverDefinitionFromManifest,\n parseDriverManifest,\n type DriverManifest,\n} from \"@agentproto/driver/manifest\"\nimport { normalizeToolId, type DriverHandle, type ExecuteFn } from \"@agentproto/driver\"\nimport { defineCliDriver, type CliDriverDefinition } from \"@agentproto/driver-cli\"\nimport { defineHttpDriver, type HttpDriverDefinition } from \"@agentproto/driver-http\"\nimport { AppLoadError } from \"./errors.js\"\n\n/** List `<id>` subdirectory names under `base`, sorted. Missing `base` (the\n * common case — most apps ship neither tools nor drivers) is not an error. */\nasync function listBundleIds(base: string): Promise<string[]> {\n let entries: Dirent[]\n try {\n entries = await readdir(base, { withFileTypes: true })\n } catch {\n return []\n }\n return entries\n .filter((e) => e.isDirectory())\n .map((e) => e.name)\n .sort()\n}\n\nfunction errMsg(err: unknown): string {\n return err instanceof Error ? err.message : String(err)\n}\n\nasync function loadToolEntry(id: string, toolPath: string): Promise<ToolHandle> {\n let source: string\n try {\n source = await readFile(toolPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(`tool '${id}': cannot read '${toolPath}': ${errMsg(err)}`)\n }\n try {\n return toolFromManifestOnly(parseToolManifest(source))\n } catch (err) {\n throw new AppLoadError(`tool '${id}' at '${toolPath}': ${errMsg(err)}`)\n }\n}\n\n/** Env var names DRIVER.md declares as required secrets — `auth.state.env`,\n * the existing AIP-30 field for \"env var names this provider's auth needs\".\n * Loosely typed at the manifest layer (`auth: z.unknown()`), so this reads\n * defensively rather than trusting a shape. */\nfunction requiredSecretNames(fm: DriverManifest[\"frontmatter\"]): readonly string[] {\n const auth = fm.auth as { state?: { env?: unknown } } | undefined\n const env = auth?.state?.env\n return Array.isArray(env) ? env.filter((e): e is string => typeof e === \"string\") : []\n}\n\n/**\n * Wrap every execute body so a declared-but-unresolved secret fails the\n * STEP with a clear `driver-error` naming the secret — never at app\n * install (secrets are resolved lazily, only when the tool actually\n * dispatches). Resolved values are merged into `driverCtx.secrets` ahead of\n * whatever the caller already put there (a workflow tool step's compiled\n * `secrets` is empty today — see BRIEF-D — so this is the only source for\n * an app-bundled driver), letting `${secrets.X}` templating in\n * `defineCliDriver`/`defineHttpDriver` resolve as authors expect.\n */\nfunction wrapExecuteWithSecretCheck(\n driverId: string,\n execute: Record<string, ExecuteFn>,\n secretNames: readonly string[],\n): Record<string, ExecuteFn> {\n if (secretNames.length === 0) return execute\n const wrapped: Record<string, ExecuteFn> = {}\n for (const [toolId, fn] of Object.entries(execute)) {\n wrapped[toolId] = async (args) => {\n const resolved: Record<string, string> = {}\n for (const name of secretNames) {\n const value = process.env[name]\n if (!value) {\n throw new Error(\n `driver '${driverId}': missing required secret '${name}' (declared in DRIVER.md 'auth.state.env').`,\n )\n }\n resolved[name] = value\n }\n const priorSecrets = (args.driverCtx as { secrets?: Record<string, string> }).secrets ?? {}\n return fn({ ...args, driverCtx: { ...args.driverCtx, secrets: { ...resolved, ...priorSecrets } } })\n }\n }\n return wrapped\n}\n\n/**\n * Resolve a kind:cli DRIVER.md's working directory. Relative paths in an\n * app-bundled cli driver resolve against the app root (the dir containing\n * `.agentproto/`) — not the daemon's own cwd, which is what `runSubprocess`\n * fell back to before this existed and is almost never what a DRIVER.md\n * author means (see `@agentproto/driver-cli`'s README). Defaults to the app\n * root itself when `metadata.cli.cwd` is unset; an explicit value — relative\n * or absolute — that resolves outside the app root is a load error rather\n * than silently escaping the bundle.\n */\nfunction resolveCliCwd(appRoot: string, driverId: string, cwd: unknown): string {\n const absoluteAppRoot = resolve(appRoot)\n if (cwd === undefined) return absoluteAppRoot\n if (typeof cwd !== \"string\" || cwd.trim() === \"\") {\n throw new Error(`driver '${driverId}': 'metadata.cli.cwd' must be a non-empty string.`)\n }\n const resolved = isAbsolute(cwd) ? resolve(cwd) : resolve(absoluteAppRoot, cwd)\n const rel = relative(absoluteAppRoot, resolved)\n if (rel !== \"\" && (rel.startsWith(\"..\") || isAbsolute(rel))) {\n throw new Error(\n `driver '${driverId}': 'metadata.cli.cwd' (${cwd}) resolves to '${resolved}', outside the app root '${absoluteAppRoot}'.`,\n )\n }\n return resolved\n}\n\n/** Build a working {@link DriverHandle} from a parsed DRIVER.md, dispatching\n * on `kind`. Throws a plain `Error` (wrapped in `AppLoadError` by the\n * caller, which has the file path) on a `cli`/`http` manifest missing its\n * dispatch config. */\nfunction driverHandleFromManifest(manifest: DriverManifest, appRoot: string): DriverHandle {\n const fm = manifest.frontmatter\n const secretNames = requiredSecretNames(fm)\n\n if (fm.kind === \"cli\") {\n const cliMeta = (fm.metadata?.cli ?? {}) as Partial<CliDriverDefinition> & { cwd?: unknown }\n if (typeof cliMeta.bin !== \"string\" || cliMeta.bin.trim() === \"\") {\n throw new Error(\n \"kind:cli DRIVER.md requires a non-empty 'metadata.cli.bin' frontmatter field naming the binary.\",\n )\n }\n const handle = defineCliDriver({\n ...driverDefinitionFromManifest(manifest),\n bin: cliMeta.bin,\n binArgs: cliMeta.binArgs,\n output: cliMeta.output,\n tty: cliMeta.tty,\n sandbox: cliMeta.sandbox,\n cwd: resolveCliCwd(appRoot, fm.id, cliMeta.cwd),\n })\n return { ...handle, execute: wrapExecuteWithSecretCheck(fm.id, handle.execute, secretNames) }\n }\n\n if (fm.kind === \"http\") {\n const httpMeta = (fm.metadata?.http ?? {}) as Partial<HttpDriverDefinition>\n if (typeof httpMeta.baseUrl !== \"string\" || httpMeta.baseUrl.trim() === \"\") {\n throw new Error(\"kind:http DRIVER.md requires a non-empty 'metadata.http.baseUrl' frontmatter field.\")\n }\n const handle = defineHttpDriver({\n ...driverDefinitionFromManifest(manifest),\n baseUrl: httpMeta.baseUrl,\n defaultHeaders: httpMeta.defaultHeaders,\n defaultMethod: httpMeta.defaultMethod,\n streaming: httpMeta.streaming,\n })\n return { ...handle, execute: wrapExecuteWithSecretCheck(fm.id, handle.execute, secretNames) }\n }\n\n // mcp / sdk / builtin: load (so a malformed manifest still fails the app\n // load), but refuse at resolve/dispatch — every implements[] entry gets\n // an execute body that fails with a clear message instead of silently\n // no-oping or throwing an opaque \"no dispatch mechanism\" error.\n const execute: Record<string, ExecuteFn> = {}\n for (const entry of fm.implements) {\n const toolId = normalizeToolId(entry.tool)\n execute[toolId] = async () => {\n throw new Error(\n `driver '${fm.id}': kind '${fm.kind}' is not supported by this host — only 'cli' and 'http' drivers dispatch.`,\n )\n }\n }\n return driverFromManifest({ manifest, execute })\n}\n\nasync function loadDriverEntry(id: string, driverPath: string, appRoot: string): Promise<DriverHandle> {\n let source: string\n try {\n source = await readFile(driverPath, \"utf8\")\n } catch (err) {\n throw new AppLoadError(`driver '${id}': cannot read '${driverPath}': ${errMsg(err)}`)\n }\n try {\n return driverHandleFromManifest(parseDriverManifest(source), appRoot)\n } catch (err) {\n throw new AppLoadError(`driver '${id}' at '${driverPath}': ${errMsg(err)}`)\n }\n}\n\n/**\n * Scan `<dir>/.agentproto/tools/*` and `<dir>/.agentproto/drivers/*` for\n * TOOL.md / DRIVER.md bundles and load them into live handles. Used by\n * `loadAppHandle` (install-time validation, via `defineApp`) and reusable\n * directly by a host that needs an already-installed app's tools/drivers\n * without re-walking its agents/workflows (see `@agentproto/runtime`'s\n * workflow `compileWorkflow` seam).\n */\nexport async function loadAppBundledTools(\n dir: string,\n): Promise<{ tools: ToolHandle[]; drivers: DriverHandle[] }> {\n const toolsDir = join(dir, \".agentproto\", \"tools\")\n const driversDir = join(dir, \".agentproto\", \"drivers\")\n\n const tools: ToolHandle[] = []\n for (const id of await listBundleIds(toolsDir)) {\n tools.push(await loadToolEntry(id, join(toolsDir, id, \"TOOL.md\")))\n }\n\n const drivers: DriverHandle[] = []\n for (const id of await listBundleIds(driversDir)) {\n drivers.push(await loadDriverEntry(id, join(driversDir, id, \"DRIVER.md\"), dir))\n }\n\n return { tools, drivers }\n}\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 app may also ship AIP-14 TOOL.md / AIP-30 DRIVER.md bundles under\n * `.agentproto/tools/<id>/TOOL.md` and `.agentproto/drivers/<id>/DRIVER.md`\n * — discovered by directory convention (see `loadAppBundledTools`), not\n * declared as APP.md frontmatter refs like agents/workflows are.\n *\n * Frontmatter validation here is deliberately minimal, and that is now an\n * AIP-53 conformance decision, not an accident of app having \"no AIP yet\":\n * AIP-53 (Draft) freezes the loader contract at the checks below — schema\n * MUST be exactly `app/v1`, `agents`/`workflows` MUST be `{ id, path }`\n * ref arrays, every ref MUST resolve, and the bundle MUST re-run through\n * `defineApp` — and it does NOT require rejecting unknown frontmatter\n * keys. Staying permissive past the frozen checks lets a future frontmatter\n * key (e.g. a later WP's addition) round-trip through this loader without\n * hosts that haven't upgraded rejecting the whole app; tightening beyond\n * the spec would break that forward compatibility for no conformance gain.\n */\n\nimport { readFile } from \"node:fs/promises\"\nimport { dirname, 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, AppDataDefinition, AppDevDefinition, AppHandle } from \"./types.js\"\nimport { defineApp } from \"./define-app.js\"\nimport { AppLoadError } from \"./errors.js\"\nimport { loadAppBundledTools } from \"./load-app-tools.js\"\n\nexport { AppLoadError }\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 port?: number\n readonly csp?: {\n readonly connectDomains?: readonly string[]\n readonly resourceDomains?: readonly string[]\n readonly frameDomains?: readonly string[]\n }\n}\n\ninterface AppFrontmatterArtifact {\n readonly path: string\n readonly title?: string\n readonly description?: string\n}\n\ninterface AppFrontmatterSkill {\n readonly path: string\n readonly title?: string\n readonly description?: 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 readonly ui?: AppFrontmatterUi\n readonly artifact?: AppFrontmatterArtifact\n readonly skill?: AppFrontmatterSkill\n readonly artifacts?: readonly AppArtifactDecl[]\n readonly dev?: AppDevDefinition\n readonly data?: AppDataDefinition\n readonly externalReadRoots?: readonly string[]\n readonly category?: string\n}\n\nfunction resolveRef(dir: string, path: string): string {\n return isAbsolute(path) ? path : join(dir, path)\n}\n\n/**\n * Resolve the UI ROOT directory an app's UI should be served from — the\n * same resolution `app_install`/`loadAppHandle` uses for `ui.path`, so\n * `app serve` and install agree on where the UI lives.\n *\n * Reads `<appDir>/.agentproto/APP.md` frontmatter: when a `ui.path` is\n * declared, the UI root is the directory CONTAINING that entry file (e.g.\n * `ui.path: ui/index.html` → `<appDir>/ui`); when `ui` is absent, returns\n * `undefined` and callers fall back to the legacy `<appDir>/.agentproto/ui/`.\n * Throws {@link AppLoadError} on a `ui` that isn't an object or whose `path`\n * isn't a non-empty string — the same shape `loadAppHandle` would reject.\n * Returns `undefined` (not a throw) when APP.md itself is unreadable, since\n * callers check APP.md existence separately.\n */\nexport async function resolveAppUIRoot(appDir: string): Promise<string | undefined> {\n const appMdPath = join(appDir, \".agentproto\", \"APP.md\")\n let source: string\n try {\n source = await readFile(appMdPath, \"utf8\")\n } catch {\n return undefined\n }\n const data = matter(source).data as Record<string, unknown>\n const ui = data.ui\n if (ui === undefined) return undefined\n if (typeof ui !== \"object\" || ui === null || Array.isArray(ui)) {\n throw new AppLoadError(`'${appMdPath}': frontmatter 'ui' must be an object.`)\n }\n const path = (ui as Record<string, unknown>).path\n if (typeof path !== \"string\" || path.trim() === \"\") {\n throw new AppLoadError(\n `'${appMdPath}': frontmatter 'ui.path' must be a non-empty string.`,\n )\n }\n return dirname(resolveRef(appDir, 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 if (data.data !== undefined) {\n const d = data.data as { dir?: unknown } | null\n if (\n typeof d !== \"object\" ||\n d === null ||\n (d.dir !== undefined && (typeof d.dir !== \"string\" || d.dir.trim() === \"\"))\n ) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'data' must be an object whose optional 'dir' is a non-empty string.`,\n )\n }\n }\n if (data.externalReadRoots !== undefined) {\n if (\n !Array.isArray(data.externalReadRoots) ||\n !data.externalReadRoots.every((e) => typeof e === \"string\" && e.trim() !== \"\")\n ) {\n throw new AppLoadError(\n `'${appPath}': frontmatter 'externalReadRoots' must be an array of non-empty strings.`,\n )\n }\n }\n if (data.category !== undefined && (typeof data.category !== \"string\" || data.category.trim() === \"\")) {\n throw new AppLoadError(`'${appPath}': frontmatter 'category' must be a non-empty string.`)\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 // AIP-14/AIP-30 tool + driver bundles — not enumerated in APP.md\n // frontmatter like agents/workflows are; discovered by convention under\n // `.agentproto/tools/<id>/TOOL.md` and `.agentproto/drivers/<id>/DRIVER.md`.\n // No declared bundle location exists yet in AIP-53/14/30 (spec gap) — see\n // `loadAppBundledTools` for the loader and its error-handling contract\n // (a parse/read failure fails the whole app load, naming the file path;\n // an absent `tools`/`drivers` directory is not an error).\n const { tools, drivers } = await loadAppBundledTools(dir)\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.port !== undefined ? { port: fm.ui.port } : {}),\n ...(fm.ui.csp !== undefined ? { csp: fm.ui.csp } : {}),\n }\n }\n\n return defineApp({\n agents,\n workflows,\n tools,\n drivers,\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.artifact !== undefined\n ? { artifact: { path: resolveRef(dir, fm.artifact.path), ...(fm.artifact.title !== undefined ? { title: fm.artifact.title } : {}), ...(fm.artifact.description !== undefined ? { description: fm.artifact.description } : {}) } }\n : {}),\n ...(fm.skill !== undefined\n ? { skill: { path: resolveRef(dir, fm.skill.path), ...(fm.skill.title !== undefined ? { title: fm.skill.title } : {}), ...(fm.skill.description !== undefined ? { description: fm.skill.description } : {}) } }\n : {}),\n ...(fm.artifacts !== undefined ? { artifacts: fm.artifacts } : {}),\n ...(fm.dev !== undefined ? { dev: fm.dev } : {}),\n ...(fm.data !== undefined ? { data: fm.data } : {}),\n ...(fm.externalReadRoots !== undefined ? { externalReadRoots: fm.externalReadRoots } : {}),\n ...(fm.category !== undefined ? { category: fm.category } : {}),\n })\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loader for an app's bundled AIP-14 TOOL.md contracts and AIP-30 DRIVER.md
|
|
3
|
+
* implementations — the deterministic-step half of WORKFLOW.md `tool` steps
|
|
4
|
+
* (yt-dlp, an STT HTTP call, a PDF render, …), as opposed to `agent` steps.
|
|
5
|
+
*
|
|
6
|
+
* Neither AIP-53 (app, still Draft with no scaffolded spec) nor AIP-14/30
|
|
7
|
+
* declare a bundle location for these, so this is a convention this loader
|
|
8
|
+
* defines: `<dir>/.agentproto/tools/<id>/TOOL.md` and
|
|
9
|
+
* `<dir>/.agentproto/drivers/<id>/DRIVER.md`, one manifest per `<id>`
|
|
10
|
+
* subdirectory, discovered by listing — not declared as APP.md frontmatter
|
|
11
|
+
* refs like `agents`/`workflows` are. An absent `tools`/`drivers` directory
|
|
12
|
+
* is not an error (most apps have neither); a subdirectory that exists but
|
|
13
|
+
* fails to parse, or is missing its TOOL.md/DRIVER.md, fails the whole load
|
|
14
|
+
* — `loadAppHandle` never silently drops a broken tool/driver bundle.
|
|
15
|
+
*
|
|
16
|
+
* Only `kind: cli` and `kind: http` drivers dispatch (the two
|
|
17
|
+
* `@agentproto/driver-cli` / `@agentproto/driver-http` sugars this package
|
|
18
|
+
* already depends on). Any other `kind` (`mcp`, `sdk`, `builtin`) still
|
|
19
|
+
* loads — a malformed manifest still fails the app load — but its execute
|
|
20
|
+
* body refuses clearly instead of silently no-oping or crashing on a
|
|
21
|
+
* dispatch mechanism this host doesn't implement yet.
|
|
22
|
+
*
|
|
23
|
+
* A `kind: cli` driver's subprocess `cwd` defaults to the app root (`dir`,
|
|
24
|
+
* the directory containing `.agentproto/`) rather than the host process's
|
|
25
|
+
* own cwd — relative paths in an app-bundled cli driver (DRIVER.md argv,
|
|
26
|
+
* `--out-dir`-style flags, …) resolve against the app root. A DRIVER.md can
|
|
27
|
+
* override this with `metadata.cli.cwd`; a relative value there is itself
|
|
28
|
+
* resolved against the app root, and a value that escapes the app root
|
|
29
|
+
* (`../..`) is a load error, not a silent escape.
|
|
30
|
+
*/
|
|
31
|
+
import { type ToolHandle } from "@agentproto/tool";
|
|
32
|
+
import { type DriverHandle } from "@agentproto/driver";
|
|
33
|
+
/**
|
|
34
|
+
* Scan `<dir>/.agentproto/tools/*` and `<dir>/.agentproto/drivers/*` for
|
|
35
|
+
* TOOL.md / DRIVER.md bundles and load them into live handles. Used by
|
|
36
|
+
* `loadAppHandle` (install-time validation, via `defineApp`) and reusable
|
|
37
|
+
* directly by a host that needs an already-installed app's tools/drivers
|
|
38
|
+
* without re-walking its agents/workflows (see `@agentproto/runtime`'s
|
|
39
|
+
* workflow `compileWorkflow` seam).
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadAppBundledTools(dir: string): Promise<{
|
|
42
|
+
tools: ToolHandle[];
|
|
43
|
+
drivers: DriverHandle[];
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=load-app-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-app-tools.d.ts","sourceRoot":"","sources":["../src/load-app-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAA;AAOzB,OAAO,EAAmB,KAAK,YAAY,EAAkB,MAAM,oBAAoB,CAAA;AAsLvF;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAe3D"}
|
package/dist/load-app.d.ts
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
* APP.md that drifted from its AGENT.md/WORKFLOW.md refs fails the same
|
|
18
18
|
* way a bad `defineApp({...})` call would.
|
|
19
19
|
*
|
|
20
|
+
* The app may also ship AIP-14 TOOL.md / AIP-30 DRIVER.md bundles under
|
|
21
|
+
* `.agentproto/tools/<id>/TOOL.md` and `.agentproto/drivers/<id>/DRIVER.md`
|
|
22
|
+
* — discovered by directory convention (see `loadAppBundledTools`), not
|
|
23
|
+
* declared as APP.md frontmatter refs like agents/workflows are.
|
|
24
|
+
*
|
|
20
25
|
* Frontmatter validation here is deliberately minimal, and that is now an
|
|
21
26
|
* AIP-53 conformance decision, not an accident of app having "no AIP yet":
|
|
22
27
|
* AIP-53 (Draft) freezes the loader contract at the checks below — schema
|
|
@@ -29,9 +34,8 @@
|
|
|
29
34
|
* the spec would break that forward compatibility for no conformance gain.
|
|
30
35
|
*/
|
|
31
36
|
import type { AppHandle } from "./types.js";
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
37
|
+
import { AppLoadError } from "./errors.js";
|
|
38
|
+
export { AppLoadError };
|
|
35
39
|
/**
|
|
36
40
|
* Resolve the UI ROOT directory an app's UI should be served from — the
|
|
37
41
|
* same resolution `app_install`/`loadAppHandle` uses for `ui.path`, so
|
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
|
|
1
|
+
{"version":3,"file":"load-app.d.ts","sourceRoot":"","sources":["../src/load-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAQH,OAAO,KAAK,EAAoE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE7G,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,YAAY,EAAE,CAAA;AAwDvB;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqBlF;AAiGD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAkGnE"}
|
package/dist/types.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ import type { AgentHandle } from "@agentproto/agent";
|
|
|
19
19
|
import type { WorkflowHandle } from "@agentproto/workflow";
|
|
20
20
|
import type { WorkspaceHandle, WorkspaceDefinition } from "@agentproto/workspace";
|
|
21
21
|
import type { BuildMastraAgentResult, BuildMastraAgentOptions } from "@agentproto/mastra";
|
|
22
|
+
import type { ToolHandle } from "@agentproto/tool";
|
|
23
|
+
import type { DriverHandle } from "@agentproto/driver";
|
|
22
24
|
/**
|
|
23
25
|
* An agent paired with the prose that becomes its system prompt. `body`
|
|
24
26
|
* is the AGENT.md body (AIP-42) — the only place free-text instructions
|
|
@@ -152,6 +154,17 @@ export interface AppDataDefinition {
|
|
|
152
154
|
export interface AppDefinition {
|
|
153
155
|
readonly agents?: readonly (AgentEntry | AgentHandle)[];
|
|
154
156
|
readonly workflows?: readonly WorkflowHandle[];
|
|
157
|
+
/**
|
|
158
|
+
* AIP-14 TOOL.md contracts the app bundles. Normally populated by
|
|
159
|
+
* `loadAppHandle` from `.agentproto/tools/<id>/TOOL.md` (see
|
|
160
|
+
* `loadAppBundledTools`) rather than set directly by a TS author.
|
|
161
|
+
*/
|
|
162
|
+
readonly tools?: readonly ToolHandle[];
|
|
163
|
+
/**
|
|
164
|
+
* AIP-30 DRIVER.md implementations the app bundles. Normally populated by
|
|
165
|
+
* `loadAppHandle` from `.agentproto/drivers/<id>/DRIVER.md`.
|
|
166
|
+
*/
|
|
167
|
+
readonly drivers?: readonly DriverHandle[];
|
|
155
168
|
/** Any other AIP handles to carry with the app (AIP-6/25/47/…). */
|
|
156
169
|
readonly attach?: readonly DoctypeHandle[];
|
|
157
170
|
/**
|
|
@@ -237,6 +250,10 @@ export interface EmittedApp {
|
|
|
237
250
|
export interface AppHandle {
|
|
238
251
|
readonly agents: readonly AgentEntry[];
|
|
239
252
|
readonly workflows: readonly WorkflowHandle[];
|
|
253
|
+
/** AIP-14 TOOL.md contracts the app bundles (see {@link AppDefinition.tools}). */
|
|
254
|
+
readonly tools: readonly ToolHandle[];
|
|
255
|
+
/** AIP-30 DRIVER.md implementations the app bundles (see {@link AppDefinition.drivers}). */
|
|
256
|
+
readonly drivers: readonly DriverHandle[];
|
|
240
257
|
readonly attachments: readonly DoctypeHandle[];
|
|
241
258
|
/** The app's home workspace (AIP-34), normalized to a handle. Absent if none. */
|
|
242
259
|
readonly workspace?: WorkspaceHandle;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,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AAG,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": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -43,17 +43,21 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"gray-matter": "^4.0.3",
|
|
46
|
-
"@agentproto/agent": "0.2.
|
|
47
|
-
"@agentproto/
|
|
48
|
-
"@agentproto/
|
|
49
|
-
"@agentproto/
|
|
50
|
-
"@agentproto/
|
|
46
|
+
"@agentproto/agent": "0.2.4",
|
|
47
|
+
"@agentproto/driver": "0.2.4",
|
|
48
|
+
"@agentproto/driver-cli": "0.2.0",
|
|
49
|
+
"@agentproto/driver-http": "0.1.8",
|
|
50
|
+
"@agentproto/mastra": "0.2.15",
|
|
51
|
+
"@agentproto/tool": "0.3.1",
|
|
52
|
+
"@agentproto/workflow": "0.7.0",
|
|
53
|
+
"@agentproto/workflow-loader": "0.2.4",
|
|
54
|
+
"@agentproto/workspace": "0.1.3"
|
|
51
55
|
},
|
|
52
56
|
"peerDependencies": {
|
|
53
57
|
"@mastra/core": ">=1.0.0"
|
|
54
58
|
},
|
|
55
59
|
"devDependencies": {
|
|
56
|
-
"@mastra/core": "1.
|
|
60
|
+
"@mastra/core": "1.66.0",
|
|
57
61
|
"@types/node": "^25.9.5",
|
|
58
62
|
"tsup": "^8.5.1",
|
|
59
63
|
"typescript": "^5.9.3",
|