@agentproto/agencies-mastra 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeremy André and agentproto contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # @agentproto/agencies-mastra
2
+
3
+ Mastra adapter for [agentagencies/v1](https://agentproto.sh/docs/agp-1).
4
+
5
+ ## Two surfaces
6
+
7
+ ### 1. Codegen (`./codegen`)
8
+
9
+ Turns a `PROCEDURE.md` (vendor-neutral playbook) into a Mastra `workflow.ts`.
10
+ Apps run this codegen once per procedure + commit the generated file.
11
+
12
+ ```ts
13
+ import { procedureToWorkflow } from "@agentproto/agencies-mastra/codegen"
14
+
15
+ const procedure = await loadProcedure("design-project-execute")
16
+ const tsSource = procedureToWorkflow(procedure.frontmatter, {
17
+ toolsModuleSpecifier: "@my-app/tools",
18
+ })
19
+
20
+ await writeFile(
21
+ "apps/my-app/src/mastra/workflows/design-project-execute.ts",
22
+ tsSource
23
+ )
24
+ ```
25
+
26
+ ### 2. Runtime (`./` main)
27
+
28
+ `createAgenciesBindings(config)` returns a bag of orchestration helpers:
29
+ engagement state machine, agreement issuer, invoice issuer. Phase 1 ships the
30
+ scaffold; Phase 2 wires actual Mastra suspend/resume.
31
+
32
+ ## Status
33
+
34
+ **Alpha — scaffolding.** The codegen emits a skeleton with TODOs; full state
35
+ machine wiring lands in Phase 2 once the host workflow patterns stabilize.
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,32 @@
1
+ import { ProcedureFrontmatter } from '@agentproto/agencies/doctypes';
2
+
3
+ /**
4
+ * PROCEDURE.md → Mastra `workflow.ts` codegen.
5
+ *
6
+ * Reads a procedure doctype + emits a TypeScript file that instantiates a
7
+ * Mastra workflow with one step per procedure step. Branching steps emit
8
+ * conditional resume logic; signature gates suspend via the governance Mastra adapter.
9
+ *
10
+ * Phase 1 scaffolding: outputs a skeleton workflow.ts with TODO markers where
11
+ * signature gates need to wire to @agentproto/governance-mastra primitives.
12
+ */
13
+
14
+ interface ProcedureToWorkflowOptions {
15
+ /** Workflow id used by Mastra (defaults to procedure slug). */
16
+ workflowId?: string;
17
+ /** Module specifier for tools used in the workflow (defaults to app's own tools file). */
18
+ toolsModuleSpecifier?: string;
19
+ /** Module specifier for the agencies bindings (defaults to "@agentproto/agencies-mastra"). */
20
+ bindingsModuleSpecifier?: string;
21
+ }
22
+ /**
23
+ * Generate a Mastra `workflow.ts` source string from a parsed PROCEDURE.md
24
+ * frontmatter.
25
+ *
26
+ * Phase 1 emits a skeleton with one step stub per procedure step + comments
27
+ * pointing at the canvakit/agency.* templates and the governance suspend hook.
28
+ * Apps customize the generated file then commit it.
29
+ */
30
+ declare function procedureToWorkflow(procedure: ProcedureFrontmatter, options?: ProcedureToWorkflowOptions): string;
31
+
32
+ export { type ProcedureToWorkflowOptions, procedureToWorkflow };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @agentproto/agencies-mastra v0.1.0-alpha
3
+ * Mastra adapter for agentagencies/v1.
4
+ */
5
+
6
+ // src/codegen.ts
7
+ function procedureToWorkflow(procedure, options = {}) {
8
+ const id = options.workflowId ?? procedure.slug;
9
+ const tools = options.toolsModuleSpecifier ?? "../tools/index.js";
10
+ const bindings = options.bindingsModuleSpecifier ?? "@agentproto/agencies-mastra";
11
+ const stepBlocks = procedure.steps.map((step, index) => {
12
+ const next = procedure.steps[index + 1]?.id ?? "<final>";
13
+ return `// Step: ${step.id}
14
+ // description: ${step.description ?? "(no description)"}
15
+ // requiredSkill: ${step.requiredSkill ?? "(none)"}
16
+ // expected output: ${step.output ?? "(none)"}
17
+ //
18
+ // TODO(phase-2): emit a Mastra step (tools[...], inputSchema, outputSchema, execute).
19
+ // If this step has \`branch\`, emit conditional resume to one of the branch.action targets.
20
+ // If this step requires signatures, suspend via @agentproto/governance-mastra
21
+ // shouldSuspendForSignatures + resume on signArtifact completion.
22
+ // Next step: ${next}
23
+ `;
24
+ }).join("\n");
25
+ return `/**
26
+ * AUTO-GENERATED from PROCEDURE.md slug=${procedure.slug} (agentagencies/v1).
27
+ * DO NOT EDIT BY HAND \u2014 re-run \`@agentproto/agencies-mastra\` codegen if the procedure changes.
28
+ *
29
+ * Procedure name: ${procedure.name}
30
+ * Procedure description: ${procedure.description ?? "(no description)"}
31
+ * Triggers: ${procedure.triggers.map((t) => t.kind).join(", ") || "(none)"}
32
+ * Required skills: ${procedure.requiredSkills.join(", ") || "(none)"}
33
+ * Autonomy policy: ${procedure.autonomyPolicy ?? "(none)"}
34
+ */
35
+
36
+ import { createWorkflow } from "@mastra/core/workflows" // peer dep
37
+ import { createGovernanceBindings } from "${bindings}"
38
+ import * as agencyTools from "${tools}" // app-provided tool registry
39
+
40
+ export const ${id.replace(/-/g, "_")}_workflow = createWorkflow({
41
+ id: ${JSON.stringify(id)},
42
+ steps: {
43
+ // \u2500\u2500\u2500 steps \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
44
+ ${stepBlocks}
45
+ },
46
+ })
47
+ `;
48
+ }
49
+
50
+ export { procedureToWorkflow };
51
+ //# sourceMappingURL=codegen.mjs.map
52
+ //# sourceMappingURL=codegen.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/codegen.ts"],"names":[],"mappings":";;;;;;AA8BO,SAAS,mBAAA,CACd,SAAA,EACA,OAAA,GAAsC,EAAC,EAC/B;AACR,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,UAAA,IAAc,SAAA,CAAU,IAAA;AAC3C,EAAA,MAAM,KAAA,GAAQ,QAAQ,oBAAA,IAAwB,mBAAA;AAC9C,EAAA,MAAM,QAAA,GAAW,QAAQ,uBAAA,IAA2B,6BAAA;AAEpD,EAAA,MAAM,aAAa,SAAA,CAAU,KAAA,CAC1B,GAAA,CAAI,CAAC,MAAM,KAAA,KAAU;AACpB,IAAA,MAAM,OAAO,SAAA,CAAU,KAAA,CAAM,KAAA,GAAQ,CAAC,GAAG,EAAA,IAAM,SAAA;AAC/C,IAAA,OAAO,CAAA,SAAA,EAAY,KAAK,EAAE;AAAA,gBAAA,EACd,IAAA,CAAK,eAAe,kBAAkB;AAAA,kBAAA,EACpC,IAAA,CAAK,iBAAiB,QAAQ;AAAA,oBAAA,EAC5B,IAAA,CAAK,UAAU,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAA,EAM7B,IAAI;AAAA,CAAA;AAAA,EAEhB,CAAC,CAAA,CACA,IAAA,CAAK,IAAI,CAAA;AAEZ,EAAA,OAAO,CAAA;AAAA,yCAAA,EACkC,UAAU,IAAI,CAAA;AAAA;AAAA;AAAA,mBAAA,EAGpC,UAAU,IAAI;AAAA,0BAAA,EACP,SAAA,CAAU,eAAe,kBAAkB;AAAA,aAAA,EACxD,SAAA,CAAU,QAAA,CAAS,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA,IAAK,QAAQ;AAAA,oBAAA,EACnD,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,IAAI,KAAK,QAAQ;AAAA,oBAAA,EAC/C,SAAA,CAAU,kBAAkB,QAAQ;AAAA;;AAAA;AAAA,0CAAA,EAId,QAAQ,CAAA;AAAA,8BAAA,EACpB,KAAK,CAAA;;AAAA,aAAA,EAEtB,EAAA,CAAG,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAC,CAAA;AAAA,MAAA,EAC5B,IAAA,CAAK,SAAA,CAAU,EAAE,CAAC,CAAA;AAAA;AAAA;AAAA,EAGxB,UAAU;AAAA;AAAA;AAAA,CAAA;AAIZ","file":"codegen.mjs","sourcesContent":["/**\n * PROCEDURE.md → Mastra `workflow.ts` codegen.\n *\n * Reads a procedure doctype + emits a TypeScript file that instantiates a\n * Mastra workflow with one step per procedure step. Branching steps emit\n * conditional resume logic; signature gates suspend via the governance Mastra adapter.\n *\n * Phase 1 scaffolding: outputs a skeleton workflow.ts with TODO markers where\n * signature gates need to wire to @agentproto/governance-mastra primitives.\n */\n\nimport type { ProcedureFrontmatter } from \"@agentproto/agencies/doctypes\"\n\nexport interface ProcedureToWorkflowOptions {\n /** Workflow id used by Mastra (defaults to procedure slug). */\n workflowId?: string\n /** Module specifier for tools used in the workflow (defaults to app's own tools file). */\n toolsModuleSpecifier?: string\n /** Module specifier for the agencies bindings (defaults to \"@agentproto/agencies-mastra\"). */\n bindingsModuleSpecifier?: string\n}\n\n/**\n * Generate a Mastra `workflow.ts` source string from a parsed PROCEDURE.md\n * frontmatter.\n *\n * Phase 1 emits a skeleton with one step stub per procedure step + comments\n * pointing at the canvakit/agency.* templates and the governance suspend hook.\n * Apps customize the generated file then commit it.\n */\nexport function procedureToWorkflow(\n procedure: ProcedureFrontmatter,\n options: ProcedureToWorkflowOptions = {}\n): string {\n const id = options.workflowId ?? procedure.slug\n const tools = options.toolsModuleSpecifier ?? \"../tools/index.js\"\n const bindings = options.bindingsModuleSpecifier ?? \"@agentproto/agencies-mastra\"\n\n const stepBlocks = procedure.steps\n .map((step, index) => {\n const next = procedure.steps[index + 1]?.id ?? \"<final>\"\n return `// Step: ${step.id}\n// description: ${step.description ?? \"(no description)\"}\n// requiredSkill: ${step.requiredSkill ?? \"(none)\"}\n// expected output: ${step.output ?? \"(none)\"}\n//\n// TODO(phase-2): emit a Mastra step (tools[...], inputSchema, outputSchema, execute).\n// If this step has \\`branch\\`, emit conditional resume to one of the branch.action targets.\n// If this step requires signatures, suspend via @agentproto/governance-mastra\n// shouldSuspendForSignatures + resume on signArtifact completion.\n// Next step: ${next}\n`\n })\n .join(\"\\n\")\n\n return `/**\n * AUTO-GENERATED from PROCEDURE.md slug=${procedure.slug} (agentagencies/v1).\n * DO NOT EDIT BY HAND — re-run \\`@agentproto/agencies-mastra\\` codegen if the procedure changes.\n *\n * Procedure name: ${procedure.name}\n * Procedure description: ${procedure.description ?? \"(no description)\"}\n * Triggers: ${procedure.triggers.map(t => t.kind).join(\", \") || \"(none)\"}\n * Required skills: ${procedure.requiredSkills.join(\", \") || \"(none)\"}\n * Autonomy policy: ${procedure.autonomyPolicy ?? \"(none)\"}\n */\n\nimport { createWorkflow } from \"@mastra/core/workflows\" // peer dep\nimport { createGovernanceBindings } from \"${bindings}\"\nimport * as agencyTools from \"${tools}\" // app-provided tool registry\n\nexport const ${id.replace(/-/g, \"_\")}_workflow = createWorkflow({\n id: ${JSON.stringify(id)},\n steps: {\n // ─── steps ──────────────────────────────────────────────────────────\n${stepBlocks}\n },\n})\n`\n}\n"]}
@@ -0,0 +1,29 @@
1
+ export { ProcedureToWorkflowOptions, procedureToWorkflow } from './codegen.js';
2
+ import '@agentproto/agencies/doctypes';
3
+
4
+ /**
5
+ * @agentproto/agencies-mastra — Mastra adapter for agentagencies/v1.
6
+ *
7
+ * Two roles:
8
+ * 1. **Codegen** (./codegen) — turns a `PROCEDURE.md` into a Mastra `workflow.ts`
9
+ * file at build time. Apps run this codegen once per template + commit the
10
+ * generated workflow.ts; runtime then registers it with Mastra normally.
11
+ *
12
+ * 2. **Runtime** (this entry) — `createAgenciesBindings(config)` returns a
13
+ * bag of high-level orchestration helpers (engagement state machine,
14
+ * agreement issuer, invoice issuer) that compose the FS-only spec runtime
15
+ * with Mastra workflow primitives.
16
+ *
17
+ * Phase 1 ships scaffolding + the procedure-to-workflow codegen surface.
18
+ * Phase 2 wires actual Mastra suspend/resume into the engagement state machine.
19
+ */
20
+
21
+ /**
22
+ * Bind agencies operations to a workspace + governance config.
23
+ *
24
+ * Phase 1 returns the input config + governance bindings; Phase 2 will add the
25
+ * full engagement orchestrator (state machine over ENGAGEMENT.md status).
26
+ */
27
+ declare function createAgenciesBindings(_config: unknown): unknown;
28
+
29
+ export { createAgenciesBindings };
package/dist/index.mjs ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @agentproto/agencies-mastra v0.1.0-alpha
3
+ * Mastra adapter for agentagencies/v1.
4
+ */
5
+
6
+ // src/codegen.ts
7
+ function procedureToWorkflow(procedure, options = {}) {
8
+ const id = options.workflowId ?? procedure.slug;
9
+ const tools = options.toolsModuleSpecifier ?? "../tools/index.js";
10
+ const bindings = options.bindingsModuleSpecifier ?? "@agentproto/agencies-mastra";
11
+ const stepBlocks = procedure.steps.map((step, index) => {
12
+ const next = procedure.steps[index + 1]?.id ?? "<final>";
13
+ return `// Step: ${step.id}
14
+ // description: ${step.description ?? "(no description)"}
15
+ // requiredSkill: ${step.requiredSkill ?? "(none)"}
16
+ // expected output: ${step.output ?? "(none)"}
17
+ //
18
+ // TODO(phase-2): emit a Mastra step (tools[...], inputSchema, outputSchema, execute).
19
+ // If this step has \`branch\`, emit conditional resume to one of the branch.action targets.
20
+ // If this step requires signatures, suspend via @agentproto/governance-mastra
21
+ // shouldSuspendForSignatures + resume on signArtifact completion.
22
+ // Next step: ${next}
23
+ `;
24
+ }).join("\n");
25
+ return `/**
26
+ * AUTO-GENERATED from PROCEDURE.md slug=${procedure.slug} (agentagencies/v1).
27
+ * DO NOT EDIT BY HAND \u2014 re-run \`@agentproto/agencies-mastra\` codegen if the procedure changes.
28
+ *
29
+ * Procedure name: ${procedure.name}
30
+ * Procedure description: ${procedure.description ?? "(no description)"}
31
+ * Triggers: ${procedure.triggers.map((t) => t.kind).join(", ") || "(none)"}
32
+ * Required skills: ${procedure.requiredSkills.join(", ") || "(none)"}
33
+ * Autonomy policy: ${procedure.autonomyPolicy ?? "(none)"}
34
+ */
35
+
36
+ import { createWorkflow } from "@mastra/core/workflows" // peer dep
37
+ import { createGovernanceBindings } from "${bindings}"
38
+ import * as agencyTools from "${tools}" // app-provided tool registry
39
+
40
+ export const ${id.replace(/-/g, "_")}_workflow = createWorkflow({
41
+ id: ${JSON.stringify(id)},
42
+ steps: {
43
+ // \u2500\u2500\u2500 steps \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
44
+ ${stepBlocks}
45
+ },
46
+ })
47
+ `;
48
+ }
49
+
50
+ // src/index.ts
51
+ function createAgenciesBindings(_config) {
52
+ return {};
53
+ }
54
+
55
+ export { createAgenciesBindings, procedureToWorkflow };
56
+ //# sourceMappingURL=index.mjs.map
57
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/codegen.ts","../src/index.ts"],"names":[],"mappings":";;;;;;AA8BO,SAAS,mBAAA,CACd,SAAA,EACA,OAAA,GAAsC,EAAC,EAC/B;AACR,EAAA,MAAM,EAAA,GAAK,OAAA,CAAQ,UAAA,IAAc,SAAA,CAAU,IAAA;AAC3C,EAAA,MAAM,KAAA,GAAQ,QAAQ,oBAAA,IAAwB,mBAAA;AAC9C,EAAA,MAAM,QAAA,GAAW,QAAQ,uBAAA,IAA2B,6BAAA;AAEpD,EAAA,MAAM,aAAa,SAAA,CAAU,KAAA,CAC1B,GAAA,CAAI,CAAC,MAAM,KAAA,KAAU;AACpB,IAAA,MAAM,OAAO,SAAA,CAAU,KAAA,CAAM,KAAA,GAAQ,CAAC,GAAG,EAAA,IAAM,SAAA;AAC/C,IAAA,OAAO,CAAA,SAAA,EAAY,KAAK,EAAE;AAAA,gBAAA,EACd,IAAA,CAAK,eAAe,kBAAkB;AAAA,kBAAA,EACpC,IAAA,CAAK,iBAAiB,QAAQ;AAAA,oBAAA,EAC5B,IAAA,CAAK,UAAU,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAA,EAM7B,IAAI;AAAA,CAAA;AAAA,EAEhB,CAAC,CAAA,CACA,IAAA,CAAK,IAAI,CAAA;AAEZ,EAAA,OAAO,CAAA;AAAA,yCAAA,EACkC,UAAU,IAAI,CAAA;AAAA;AAAA;AAAA,mBAAA,EAGpC,UAAU,IAAI;AAAA,0BAAA,EACP,SAAA,CAAU,eAAe,kBAAkB;AAAA,aAAA,EACxD,SAAA,CAAU,QAAA,CAAS,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,IAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA,IAAK,QAAQ;AAAA,oBAAA,EACnD,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,IAAI,KAAK,QAAQ;AAAA,oBAAA,EAC/C,SAAA,CAAU,kBAAkB,QAAQ;AAAA;;AAAA;AAAA,0CAAA,EAId,QAAQ,CAAA;AAAA,8BAAA,EACpB,KAAK,CAAA;;AAAA,aAAA,EAEtB,EAAA,CAAG,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAC,CAAA;AAAA,MAAA,EAC5B,IAAA,CAAK,SAAA,CAAU,EAAE,CAAC,CAAA;AAAA;AAAA;AAAA,EAGxB,UAAU;AAAA;AAAA;AAAA,CAAA;AAIZ;;;ACpDO,SAAS,uBAAuB,OAAA,EAA2B;AAEhE,EAAA,OAAO,EAAC;AACV","file":"index.mjs","sourcesContent":["/**\n * PROCEDURE.md → Mastra `workflow.ts` codegen.\n *\n * Reads a procedure doctype + emits a TypeScript file that instantiates a\n * Mastra workflow with one step per procedure step. Branching steps emit\n * conditional resume logic; signature gates suspend via the governance Mastra adapter.\n *\n * Phase 1 scaffolding: outputs a skeleton workflow.ts with TODO markers where\n * signature gates need to wire to @agentproto/governance-mastra primitives.\n */\n\nimport type { ProcedureFrontmatter } from \"@agentproto/agencies/doctypes\"\n\nexport interface ProcedureToWorkflowOptions {\n /** Workflow id used by Mastra (defaults to procedure slug). */\n workflowId?: string\n /** Module specifier for tools used in the workflow (defaults to app's own tools file). */\n toolsModuleSpecifier?: string\n /** Module specifier for the agencies bindings (defaults to \"@agentproto/agencies-mastra\"). */\n bindingsModuleSpecifier?: string\n}\n\n/**\n * Generate a Mastra `workflow.ts` source string from a parsed PROCEDURE.md\n * frontmatter.\n *\n * Phase 1 emits a skeleton with one step stub per procedure step + comments\n * pointing at the canvakit/agency.* templates and the governance suspend hook.\n * Apps customize the generated file then commit it.\n */\nexport function procedureToWorkflow(\n procedure: ProcedureFrontmatter,\n options: ProcedureToWorkflowOptions = {}\n): string {\n const id = options.workflowId ?? procedure.slug\n const tools = options.toolsModuleSpecifier ?? \"../tools/index.js\"\n const bindings = options.bindingsModuleSpecifier ?? \"@agentproto/agencies-mastra\"\n\n const stepBlocks = procedure.steps\n .map((step, index) => {\n const next = procedure.steps[index + 1]?.id ?? \"<final>\"\n return `// Step: ${step.id}\n// description: ${step.description ?? \"(no description)\"}\n// requiredSkill: ${step.requiredSkill ?? \"(none)\"}\n// expected output: ${step.output ?? \"(none)\"}\n//\n// TODO(phase-2): emit a Mastra step (tools[...], inputSchema, outputSchema, execute).\n// If this step has \\`branch\\`, emit conditional resume to one of the branch.action targets.\n// If this step requires signatures, suspend via @agentproto/governance-mastra\n// shouldSuspendForSignatures + resume on signArtifact completion.\n// Next step: ${next}\n`\n })\n .join(\"\\n\")\n\n return `/**\n * AUTO-GENERATED from PROCEDURE.md slug=${procedure.slug} (agentagencies/v1).\n * DO NOT EDIT BY HAND — re-run \\`@agentproto/agencies-mastra\\` codegen if the procedure changes.\n *\n * Procedure name: ${procedure.name}\n * Procedure description: ${procedure.description ?? \"(no description)\"}\n * Triggers: ${procedure.triggers.map(t => t.kind).join(\", \") || \"(none)\"}\n * Required skills: ${procedure.requiredSkills.join(\", \") || \"(none)\"}\n * Autonomy policy: ${procedure.autonomyPolicy ?? \"(none)\"}\n */\n\nimport { createWorkflow } from \"@mastra/core/workflows\" // peer dep\nimport { createGovernanceBindings } from \"${bindings}\"\nimport * as agencyTools from \"${tools}\" // app-provided tool registry\n\nexport const ${id.replace(/-/g, \"_\")}_workflow = createWorkflow({\n id: ${JSON.stringify(id)},\n steps: {\n // ─── steps ──────────────────────────────────────────────────────────\n${stepBlocks}\n },\n})\n`\n}\n","/**\n * @agentproto/agencies-mastra — Mastra adapter for agentagencies/v1.\n *\n * Two roles:\n * 1. **Codegen** (./codegen) — turns a `PROCEDURE.md` into a Mastra `workflow.ts`\n * file at build time. Apps run this codegen once per template + commit the\n * generated workflow.ts; runtime then registers it with Mastra normally.\n *\n * 2. **Runtime** (this entry) — `createAgenciesBindings(config)` returns a\n * bag of high-level orchestration helpers (engagement state machine,\n * agreement issuer, invoice issuer) that compose the FS-only spec runtime\n * with Mastra workflow primitives.\n *\n * Phase 1 ships scaffolding + the procedure-to-workflow codegen surface.\n * Phase 2 wires actual Mastra suspend/resume into the engagement state machine.\n */\n\nexport type { ProcedureToWorkflowOptions } from \"./codegen.js\"\nexport { procedureToWorkflow } from \"./codegen.js\"\n\n/**\n * Bind agencies operations to a workspace + governance config.\n *\n * Phase 1 returns the input config + governance bindings; Phase 2 will add the\n * full engagement orchestrator (state machine over ENGAGEMENT.md status).\n */\nexport function createAgenciesBindings(_config: unknown): unknown {\n // TODO(phase-2): full engagement orchestrator with Mastra workflow integration.\n return {}\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@agentproto/agencies-mastra",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Mastra adapter for agentagencies/v1 — PROCEDURE.md → Mastra workflow.ts codegen, engagement orchestrator, Mastra-flavored agencies tools.",
5
+ "keywords": [
6
+ "agentagencies",
7
+ "agencies",
8
+ "mastra",
9
+ "adapter",
10
+ "procedure",
11
+ "workflow",
12
+ "codegen"
13
+ ],
14
+ "homepage": "https://agentproto.sh/docs/agp-1",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/agentproto/ts",
18
+ "directory": "packages/agencies/mastra"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/agentproto/ts/issues"
22
+ },
23
+ "license": "MIT",
24
+ "type": "module",
25
+ "main": "dist/index.mjs",
26
+ "module": "dist/index.mjs",
27
+ "types": "dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.mjs",
32
+ "default": "./dist/index.mjs"
33
+ },
34
+ "./codegen": {
35
+ "types": "./dist/codegen.d.ts",
36
+ "import": "./dist/codegen.mjs",
37
+ "default": "./dist/codegen.mjs"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "dependencies": {
50
+ "zod": "^4.4.3",
51
+ "@agentproto/agencies": "0.1.0-alpha.0",
52
+ "@agentproto/governance": "0.1.0-alpha.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@mastra/core": "*"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@mastra/core": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^25.6.2",
64
+ "tsup": "^8.5.1",
65
+ "typescript": "^5.9.3",
66
+ "vitest": "^3.2.4",
67
+ "@agentproto/tooling": "0.1.0-alpha.0"
68
+ },
69
+ "scripts": {
70
+ "dev": "tsup --watch",
71
+ "build": "tsup",
72
+ "clean": "rm -rf dist",
73
+ "check-types": "tsc --noEmit",
74
+ "test": "vitest run --passWithNoTests"
75
+ }
76
+ }