@agentproto/adapter-mastra-agent 0.5.0 → 0.5.2

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 CHANGED
@@ -20,10 +20,10 @@ agentproto-mastra acp --model anthropic/claude-opus-4-8
20
20
  AGENT.md ──parseAgentManifest──▶ AgentHandle
21
21
  │ buildMastraAgent (@agentproto/mastra)
22
22
 
23
- Mastra Agent.stream()
24
- text deltas
23
+ Mastra AgentController
24
+ AgentControllerEvent subscription
25
25
 
26
- MastraAcpAgent (src/acp-host.ts) ──agent_message_chunk──▶ ACP client
26
+ MastraAcpAgent (src/acp-host.ts) ──agent_message_chunk / tool_call ──▶ ACP client
27
27
 
28
28
  @agentclientprotocol/sdk AgentSideConnection (stdio)
29
29
  ```
@@ -33,6 +33,16 @@ AGENT.md ──parseAgentManifest──▶ AgentHandle
33
33
  spawn environment. Default: `openrouter/z-ai/glm-5.2`.
34
34
  - **Agent** — pass `--agent ./path/AGENT.md` (or `AGENTPROTO_MASTRA_AGENT_FILE`)
35
35
  to run a custom agent; omit for a built-in coding default.
36
+ - **Modes** — the default agent runs a `plan` → `build` → `review` cycle via
37
+ Mastra's `AgentController`. A custom `AGENT.md` can override the modes with a
38
+ `## Modes` section; `submit_plan` gates the transition from plan to build.
39
+ - **Daemon integration** — when spawned by the agentproto daemon, the adapter
40
+ discovers it via `DaemonClient` and a `SignalProvider` pushes session lifecycle
41
+ events (turn-end, errors, permissions, child-session exits) plus workspace git
42
+ state into the agent thread.
43
+ - **Tool approvals / suspension** — workspace tools can surface a
44
+ `session/request_permission` round-trip through the ACP host, and suspended
45
+ tools resume once the host responds.
36
46
 
37
47
  ## Workspace tools
38
48
 
@@ -73,6 +83,7 @@ across spawns), overridable with `AGENTPROTO_MASTRA_MEMORY_DB`. A custom
73
83
  Streaming conversation + workspace tools (edit/run) + SQLite memory, with tool
74
84
  activity surfaced live: each tool the agent runs is relayed to the host as an
75
85
  ACP `tool_call` (status `in_progress`) and then a `tool_call_update` (status
76
- `completed`/`failed` with the raw output) — read off Mastra's `fullStream` and
77
- mapped in `src/tool-call-map.ts`. So a host (codex/claude-code/an IDE) shows the
78
- "🔧 run_command: …" feed, not just the final prose.
86
+ `completed`/`failed` with the raw output) — read from the `AgentController`
87
+ event subscription and mapped in `src/tool-call-map.ts`. The adapter also
88
+ supports plan/build/review modes, tool-approval round-trips, and session resume
89
+ via the ACP `session/load` flow.
@@ -1404,6 +1404,22 @@ var REVIEWER_SUBAGENT = {
1404
1404
  allowedControllerTools: [...REVIEWER_ALLOWED_TOOL_IDS],
1405
1405
  forked: true
1406
1406
  };
1407
+ var stripTrailingReasoningRule = {
1408
+ name: "strip-trailing-reasoning-from-assistant",
1409
+ applyToPrompt({ prompt }) {
1410
+ let mutated = false;
1411
+ const next = prompt.flatMap((message) => {
1412
+ if (message.role !== "assistant" || !Array.isArray(message.content)) return [message];
1413
+ const content = message.content;
1414
+ const last = content[content.length - 1];
1415
+ if (!last || last.type !== "reasoning") return [message];
1416
+ const filtered = content.filter((p) => p.type !== "reasoning");
1417
+ mutated = true;
1418
+ return filtered.length > 0 ? [{ ...message, content: filtered }] : [];
1419
+ });
1420
+ return mutated ? next : void 0;
1421
+ }
1422
+ };
1407
1423
  function makeAgentFactory(opts = {}) {
1408
1424
  return async () => {
1409
1425
  const source = await resolveAgentSource(opts);
@@ -1418,22 +1434,7 @@ function makeAgentFactory(opts = {}) {
1418
1434
  const store = buildSqliteStore();
1419
1435
  let memory;
1420
1436
  const historyCompat = new ProviderHistoryCompat({
1421
- additionalRules: [{
1422
- name: "strip-trailing-reasoning-from-assistant",
1423
- applyToPrompt({ prompt }) {
1424
- let mutated = false;
1425
- const next = prompt.map((message) => {
1426
- if (message.role !== "assistant" || !Array.isArray(message.content)) return message;
1427
- const content = message.content;
1428
- const last = content[content.length - 1];
1429
- if (!last || last.type !== "reasoning") return message;
1430
- const filtered = content.filter((p) => p.type !== "reasoning");
1431
- mutated = true;
1432
- return { ...message, content: filtered.length > 0 ? filtered : [{ type: "text", text: "" }] };
1433
- });
1434
- return mutated ? next : void 0;
1435
- }
1436
- }]
1437
+ additionalRules: [stripTrailingReasoningRule]
1437
1438
  });
1438
1439
  const { agent } = await buildMastraAgent(handle, {
1439
1440
  inputProcessors: [historyCompat],
@@ -2090,5 +2091,5 @@ function runAcpOverStdio(buildController) {
2090
2091
  }
2091
2092
 
2092
2093
  export { DEFAULT_MODEL, DEFAULT_MODEL_CATALOG, DEFAULT_TOOL_IDS, DISABLED_BUILTIN_TOOL_IDS, DaemonClient, DaemonHttpError, DaemonNotFoundError, MastraAcpAgent, buildSqliteMemory, buildSqliteStore, createEventMapper, defaultAgentManifest, discoverDaemonEndpoint, makeAgentFactory, makeDaemonTools, makeWorkspaceTools, messageText, modelRefToString, promptContent, promptText, providerOf, resolveInCwd, resolveMastraModel, resolveMemoryDbPath, runAcpOverStdio, toolCallTitle, toolKindFor };
2093
- //# sourceMappingURL=chunk-5C2H4JSD.mjs.map
2094
- //# sourceMappingURL=chunk-5C2H4JSD.mjs.map
2094
+ //# sourceMappingURL=chunk-6ILIPWNM.mjs.map
2095
+ //# sourceMappingURL=chunk-6ILIPWNM.mjs.map