@mastra/code-sdk 1.2.0-alpha.1 → 1.2.0-alpha.13

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/dist/agents/credential-resolver.d.ts +6 -0
  3. package/dist/agents/credential-resolver.d.ts.map +1 -1
  4. package/dist/agents/credential-resolver.js +14 -4
  5. package/dist/agents/credential-resolver.js.map +1 -1
  6. package/dist/agents/mastracode-gateway.d.ts.map +1 -1
  7. package/dist/agents/mastracode-gateway.js +27 -13
  8. package/dist/agents/mastracode-gateway.js.map +1 -1
  9. package/dist/agents/model.d.ts +16 -1
  10. package/dist/agents/model.d.ts.map +1 -1
  11. package/dist/agents/model.js +27 -6
  12. package/dist/agents/model.js.map +1 -1
  13. package/dist/agents/tools.js +1 -1
  14. package/dist/headless/cli.d.ts.map +1 -1
  15. package/dist/headless/cli.js +3 -0
  16. package/dist/headless/cli.js.map +1 -1
  17. package/dist/headless/flags.js +1 -1
  18. package/dist/headless/flags.js.map +1 -1
  19. package/dist/headless/types.d.ts +2 -2
  20. package/dist/headless/types.d.ts.map +1 -1
  21. package/dist/headless/types.js +2 -1
  22. package/dist/headless/types.js.map +1 -1
  23. package/dist/hooks/executor.d.ts.map +1 -1
  24. package/dist/hooks/executor.js +1 -0
  25. package/dist/hooks/executor.js.map +1 -1
  26. package/dist/hooks/manager.d.ts +9 -2
  27. package/dist/hooks/manager.d.ts.map +1 -1
  28. package/dist/hooks/manager.js +19 -3
  29. package/dist/hooks/manager.js.map +1 -1
  30. package/dist/hooks/types.d.ts +20 -0
  31. package/dist/hooks/types.d.ts.map +1 -1
  32. package/dist/hooks/types.js.map +1 -1
  33. package/dist/index.d.ts +68 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +179 -64
  36. package/dist/index.js.map +1 -1
  37. package/dist/onboarding/settings.d.ts +75 -6
  38. package/dist/onboarding/settings.d.ts.map +1 -1
  39. package/dist/onboarding/settings.js +128 -13
  40. package/dist/onboarding/settings.js.map +1 -1
  41. package/dist/plugin.d.ts +64 -1
  42. package/dist/plugin.d.ts.map +1 -1
  43. package/dist/plugin.js +3 -1
  44. package/dist/plugin.js.map +1 -1
  45. package/dist/plugins/loader.d.ts +7 -3
  46. package/dist/plugins/loader.d.ts.map +1 -1
  47. package/dist/plugins/loader.js +53 -1
  48. package/dist/plugins/loader.js.map +1 -1
  49. package/dist/plugins/manager.d.ts +36 -2
  50. package/dist/plugins/manager.d.ts.map +1 -1
  51. package/dist/plugins/manager.js +74 -2
  52. package/dist/plugins/manager.js.map +1 -1
  53. package/dist/plugins/signal-lane.d.ts +58 -0
  54. package/dist/plugins/signal-lane.d.ts.map +1 -0
  55. package/dist/plugins/signal-lane.js +166 -0
  56. package/dist/plugins/signal-lane.js.map +1 -0
  57. package/dist/plugins/types.d.ts +36 -0
  58. package/dist/plugins/types.d.ts.map +1 -1
  59. package/dist/providers/claude-max.d.ts +13 -0
  60. package/dist/providers/claude-max.d.ts.map +1 -1
  61. package/dist/providers/claude-max.js +83 -3
  62. package/dist/providers/claude-max.js.map +1 -1
  63. package/dist/providers/openai-codex.d.ts +3 -1
  64. package/dist/providers/openai-codex.d.ts.map +1 -1
  65. package/dist/providers/openai-codex.js +13 -2
  66. package/dist/providers/openai-codex.js.map +1 -1
  67. package/dist/schema.d.ts +11 -5
  68. package/dist/schema.d.ts.map +1 -1
  69. package/dist/schema.js +5 -4
  70. package/dist/schema.js.map +1 -1
  71. package/package.json +13 -13
@@ -66,8 +66,28 @@ export interface HookStdinStop extends HookStdinBase {
66
66
  assistant_message?: string;
67
67
  stop_reason: 'complete' | 'aborted' | 'error';
68
68
  }
69
+ /**
70
+ * Describes the git worktree a session is running in. Absent for sessions
71
+ * started in an ordinary checkout.
72
+ */
73
+ export interface SessionWorktreeInfo {
74
+ /** Absolute path to the worktree root. */
75
+ path: string;
76
+ /** Branch checked out in the worktree, when it can be resolved. */
77
+ branch?: string;
78
+ /** Absolute path to the main repository the worktree is linked to. */
79
+ mainRepoPath?: string;
80
+ }
69
81
  export interface HookStdinSession extends HookStdinBase {
70
82
  hook_event_name: 'SessionStart' | 'SessionEnd';
83
+ /**
84
+ * Set only when the session's project directory is a git worktree, so a hook
85
+ * can provision or tear down per-worktree resources (a database, a bucket, a
86
+ * dev server) and distinguish that from a session in the main checkout.
87
+ */
88
+ worktree_path?: string;
89
+ branch?: string;
90
+ main_repo_path?: string;
71
91
  }
72
92
  export interface HookStdinNotification extends HookStdinBase {
73
93
  hook_event_name: 'Notification';
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hooks/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,aAAa,GACb,MAAM,GACN,kBAAkB,GAClB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,UAAU,GACV,mBAAmB,GACnB,kBAAkB,GAClB,WAAW,GACX,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAE3E,yFAAyF;AACzF,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,UAAU,GACV,mBAAmB,GACnB,kBAAkB,GAClB,WAAW,GACX,eAAe,GACf,aAAa,CAAC;AAElB,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,KAAK,IAAI,iBAAiB,CAEhF;AAMD,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,IAAI,EAAE,SAAS,CAAC;IAChB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM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Aa,GACb,gBAAgB,GAChB,qBAAqB,GACrB,mBAAmB,GACnB,iBAAiB,GACjB,0BAA0B,GAC1B,yBAAyB,GACzB,kBAAkB,GAClB,sBAAsB,GACtB,oBAAoB,CAAC;AAMzB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAMD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/hooks/types.ts"],"sourcesContent":["/**\n * Type definitions for the hooks system.\n * Hooks are user-configured shell commands that run at lifecycle events.\n */\n\n// =============================================================================\n// Hook Event Names\n// =============================================================================\nexport type HookEventName =\n | 'PreToolUse'\n | 'PostToolUse'\n | 'Stop'\n | 'UserPromptSubmit'\n | 'SessionStart'\n | 'SessionEnd'\n | 'Notification'\n | 'AgentStart'\n | 'AgentEnd'\n | 'PermissionRequest'\n | 'PermissionResult'\n | 'Interrupt'\n | 'SubagentStart'\n | 'SubagentEnd';\n\nexport type BlockingHookEvent = 'PreToolUse' | 'Stop' | 'UserPromptSubmit';\n\n/** Lifecycle hook events are non-blocking: they observe behavior without changing it. */\nexport type LifecycleHookEvent =\n | 'AgentStart'\n | 'AgentEnd'\n | 'PermissionRequest'\n | 'PermissionResult'\n | 'Interrupt'\n | 'SubagentStart'\n | 'SubagentEnd';\n\nexport function isBlockingEvent(event: HookEventName): event is BlockingHookEvent {\n return event === 'PreToolUse' || event === 'Stop' || event === 'UserPromptSubmit';\n}\n\n// =============================================================================\n// Hook Configuration\n// =============================================================================\n\nexport interface HookMatcher {\n /** Regex pattern matched against tool_name (PreToolUse/PostToolUse only). */\n tool_name?: string;\n}\n\nexport interface HookDefinition {\n /** Hook type. Only \"command\" supported in phase 1. */\n type: 'command';\n /** Shell command to execute via /bin/sh -c. */\n command: string;\n /** Optional matcher to filter when this hook runs. */\n matcher?: HookMatcher;\n /** Timeout in ms. Default 10000. Process killed after timeout. */\n timeout?: number;\n /** Human-readable description for /hooks display. */\n description?: string;\n}\nexport interface HooksConfig {\n PreToolUse?: HookDefinition[];\n PostToolUse?: HookDefinition[];\n Stop?: HookDefinition[];\n UserPromptSubmit?: HookDefinition[];\n SessionStart?: HookDefinition[];\n SessionEnd?: HookDefinition[];\n Notification?: HookDefinition[];\n AgentStart?: HookDefinition[];\n AgentEnd?: HookDefinition[];\n PermissionRequest?: HookDefinition[];\n PermissionResult?: HookDefinition[];\n Interrupt?: HookDefinition[];\n SubagentStart?: HookDefinition[];\n SubagentEnd?: HookDefinition[];\n}\n\n// =============================================================================\n// Stdin Protocol (JSON sent to hook process)\n// =============================================================================\n\nexport interface HookStdinBase {\n session_id: string;\n cwd: string;\n hook_event_name: HookEventName;\n /**\n * Stable MastraCode-generated id for the active agent run. Present on events\n * emitted while a run is active (AgentStart..AgentEnd, tool hooks, Stop).\n * Absent outside a run (SessionStart, SessionEnd, Notification fired idle).\n */\n run_id?: string;\n}\n\nexport interface HookStdinToolEvent extends HookStdinBase {\n hook_event_name: 'PreToolUse' | 'PostToolUse';\n tool_name: string;\n tool_input: unknown;\n tool_output?: unknown;\n tool_error?: boolean;\n}\n\nexport interface HookStdinUserPrompt extends HookStdinBase {\n hook_event_name: 'UserPromptSubmit';\n user_message: string;\n}\n\nexport interface HookStdinStop extends HookStdinBase {\n hook_event_name: 'Stop';\n assistant_message?: string;\n stop_reason: 'complete' | 'aborted' | 'error';\n}\nexport interface HookStdinSession extends HookStdinBase {\n hook_event_name: 'SessionStart' | 'SessionEnd';\n}\n\nexport interface HookStdinNotification extends HookStdinBase {\n hook_event_name: 'Notification';\n /** Why the notification fired: agent_done, ask_question, tool_approval, plan_approval, sandbox_access */\n reason: string;\n /** Optional human-readable message for the notification. */\n message?: string;\n}\n\nexport interface HookStdinAgentStart extends HookStdinBase {\n hook_event_name: 'AgentStart';\n run_id: string;\n}\n\nexport interface HookStdinAgentEnd extends HookStdinBase {\n hook_event_name: 'AgentEnd';\n run_id: string;\n stop_reason: 'complete' | 'aborted' | 'error' | 'suspended';\n}\n\nexport type PermissionKind = 'tool_approval' | 'sandbox_access' | 'plan_approval';\n\nexport interface HookStdinPermissionRequest extends HookStdinBase {\n hook_event_name: 'PermissionRequest';\n run_id: string;\n permission_kind: PermissionKind;\n tool_call_id: string;\n tool_name: string;\n tool_input?: unknown;\n}\n\nexport type PermissionDecision = 'approved' | 'declined' | 'dismissed' | 'auto_approved' | 'auto_declined';\n\nexport interface HookStdinPermissionResult extends HookStdinBase {\n hook_event_name: 'PermissionResult';\n run_id: string;\n permission_kind: PermissionKind;\n tool_call_id: string;\n tool_name: string;\n tool_input?: unknown;\n decision: PermissionDecision;\n}\n\nexport type InterruptReason = 'user_interrupt' | 'goal_judge_interrupt' | 'process_sigint';\n\nexport interface HookStdinInterrupt extends HookStdinBase {\n hook_event_name: 'Interrupt';\n run_id: string;\n reason: InterruptReason;\n}\n\nexport interface HookStdinSubagentStart extends HookStdinBase {\n hook_event_name: 'SubagentStart';\n run_id: string;\n tool_call_id: string;\n agent_type: string;\n task: string;\n model_id?: string;\n forked?: boolean;\n}\n\nexport interface HookStdinSubagentEnd extends HookStdinBase {\n hook_event_name: 'SubagentEnd';\n run_id: string;\n tool_call_id: string;\n agent_type: string;\n result: unknown;\n is_error: boolean;\n duration_ms: number;\n}\n\nexport type HookStdin =\n | HookStdinToolEvent\n | HookStdinUserPrompt\n | HookStdinStop\n | HookStdinSession\n | HookStdinNotification\n | HookStdinAgentStart\n | HookStdinAgentEnd\n | HookStdinPermissionRequest\n | HookStdinPermissionResult\n | HookStdinInterrupt\n | HookStdinSubagentStart\n | HookStdinSubagentEnd;\n\n// =============================================================================\n// Stdout Protocol (JSON read from hook process)\n// =============================================================================\n\nexport interface HookStdout {\n decision?: 'allow' | 'block';\n reason?: string;\n additionalContext?: string;\n}\n\n// =============================================================================\n// Execution Results\n// =============================================================================\n\nexport interface HookResult {\n hook: HookDefinition;\n exitCode: number;\n stdout?: HookStdout;\n stderr?: string;\n timedOut: boolean;\n durationMs: number;\n}\n\nexport interface HookEventResult {\n allowed: boolean;\n blockReason?: string;\n additionalContext?: string;\n results: HookResult[];\n warnings: string[];\n}\n"],"mappings":";AAoCA,SAAgB,gBAAgB,OAAkD;CAChF,OAAO,UAAU,gBAAgB,UAAU,UAAU,UAAU;AACjE"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/hooks/types.ts"],"sourcesContent":["/**\n * Type definitions for the hooks system.\n * Hooks are user-configured shell commands that run at lifecycle events.\n */\n\n// =============================================================================\n// Hook Event Names\n// =============================================================================\nexport type HookEventName =\n | 'PreToolUse'\n | 'PostToolUse'\n | 'Stop'\n | 'UserPromptSubmit'\n | 'SessionStart'\n | 'SessionEnd'\n | 'Notification'\n | 'AgentStart'\n | 'AgentEnd'\n | 'PermissionRequest'\n | 'PermissionResult'\n | 'Interrupt'\n | 'SubagentStart'\n | 'SubagentEnd';\n\nexport type BlockingHookEvent = 'PreToolUse' | 'Stop' | 'UserPromptSubmit';\n\n/** Lifecycle hook events are non-blocking: they observe behavior without changing it. */\nexport type LifecycleHookEvent =\n | 'AgentStart'\n | 'AgentEnd'\n | 'PermissionRequest'\n | 'PermissionResult'\n | 'Interrupt'\n | 'SubagentStart'\n | 'SubagentEnd';\n\nexport function isBlockingEvent(event: HookEventName): event is BlockingHookEvent {\n return event === 'PreToolUse' || event === 'Stop' || event === 'UserPromptSubmit';\n}\n\n// =============================================================================\n// Hook Configuration\n// =============================================================================\n\nexport interface HookMatcher {\n /** Regex pattern matched against tool_name (PreToolUse/PostToolUse only). */\n tool_name?: string;\n}\n\nexport interface HookDefinition {\n /** Hook type. Only \"command\" supported in phase 1. */\n type: 'command';\n /** Shell command to execute via /bin/sh -c. */\n command: string;\n /** Optional matcher to filter when this hook runs. */\n matcher?: HookMatcher;\n /** Timeout in ms. Default 10000. Process killed after timeout. */\n timeout?: number;\n /** Human-readable description for /hooks display. */\n description?: string;\n}\nexport interface HooksConfig {\n PreToolUse?: HookDefinition[];\n PostToolUse?: HookDefinition[];\n Stop?: HookDefinition[];\n UserPromptSubmit?: HookDefinition[];\n SessionStart?: HookDefinition[];\n SessionEnd?: HookDefinition[];\n Notification?: HookDefinition[];\n AgentStart?: HookDefinition[];\n AgentEnd?: HookDefinition[];\n PermissionRequest?: HookDefinition[];\n PermissionResult?: HookDefinition[];\n Interrupt?: HookDefinition[];\n SubagentStart?: HookDefinition[];\n SubagentEnd?: HookDefinition[];\n}\n\n// =============================================================================\n// Stdin Protocol (JSON sent to hook process)\n// =============================================================================\n\nexport interface HookStdinBase {\n session_id: string;\n cwd: string;\n hook_event_name: HookEventName;\n /**\n * Stable MastraCode-generated id for the active agent run. Present on events\n * emitted while a run is active (AgentStart..AgentEnd, tool hooks, Stop).\n * Absent outside a run (SessionStart, SessionEnd, Notification fired idle).\n */\n run_id?: string;\n}\n\nexport interface HookStdinToolEvent extends HookStdinBase {\n hook_event_name: 'PreToolUse' | 'PostToolUse';\n tool_name: string;\n tool_input: unknown;\n tool_output?: unknown;\n tool_error?: boolean;\n}\n\nexport interface HookStdinUserPrompt extends HookStdinBase {\n hook_event_name: 'UserPromptSubmit';\n user_message: string;\n}\n\nexport interface HookStdinStop extends HookStdinBase {\n hook_event_name: 'Stop';\n assistant_message?: string;\n stop_reason: 'complete' | 'aborted' | 'error';\n}\n/**\n * Describes the git worktree a session is running in. Absent for sessions\n * started in an ordinary checkout.\n */\nexport interface SessionWorktreeInfo {\n /** Absolute path to the worktree root. */\n path: string;\n /** Branch checked out in the worktree, when it can be resolved. */\n branch?: string;\n /** Absolute path to the main repository the worktree is linked to. */\n mainRepoPath?: string;\n}\n\nexport interface HookStdinSession extends HookStdinBase {\n hook_event_name: 'SessionStart' | 'SessionEnd';\n /**\n * Set only when the session's project directory is a git worktree, so a hook\n * can provision or tear down per-worktree resources (a database, a bucket, a\n * dev server) and distinguish that from a session in the main checkout.\n */\n worktree_path?: string;\n branch?: string;\n main_repo_path?: string;\n}\n\nexport interface HookStdinNotification extends HookStdinBase {\n hook_event_name: 'Notification';\n /** Why the notification fired: agent_done, ask_question, tool_approval, plan_approval, sandbox_access */\n reason: string;\n /** Optional human-readable message for the notification. */\n message?: string;\n}\n\nexport interface HookStdinAgentStart extends HookStdinBase {\n hook_event_name: 'AgentStart';\n run_id: string;\n}\n\nexport interface HookStdinAgentEnd extends HookStdinBase {\n hook_event_name: 'AgentEnd';\n run_id: string;\n stop_reason: 'complete' | 'aborted' | 'error' | 'suspended';\n}\n\nexport type PermissionKind = 'tool_approval' | 'sandbox_access' | 'plan_approval';\n\nexport interface HookStdinPermissionRequest extends HookStdinBase {\n hook_event_name: 'PermissionRequest';\n run_id: string;\n permission_kind: PermissionKind;\n tool_call_id: string;\n tool_name: string;\n tool_input?: unknown;\n}\n\nexport type PermissionDecision = 'approved' | 'declined' | 'dismissed' | 'auto_approved' | 'auto_declined';\n\nexport interface HookStdinPermissionResult extends HookStdinBase {\n hook_event_name: 'PermissionResult';\n run_id: string;\n permission_kind: PermissionKind;\n tool_call_id: string;\n tool_name: string;\n tool_input?: unknown;\n decision: PermissionDecision;\n}\n\nexport type InterruptReason = 'user_interrupt' | 'goal_judge_interrupt' | 'process_sigint';\n\nexport interface HookStdinInterrupt extends HookStdinBase {\n hook_event_name: 'Interrupt';\n run_id: string;\n reason: InterruptReason;\n}\n\nexport interface HookStdinSubagentStart extends HookStdinBase {\n hook_event_name: 'SubagentStart';\n run_id: string;\n tool_call_id: string;\n agent_type: string;\n task: string;\n model_id?: string;\n forked?: boolean;\n}\n\nexport interface HookStdinSubagentEnd extends HookStdinBase {\n hook_event_name: 'SubagentEnd';\n run_id: string;\n tool_call_id: string;\n agent_type: string;\n result: unknown;\n is_error: boolean;\n duration_ms: number;\n}\n\nexport type HookStdin =\n | HookStdinToolEvent\n | HookStdinUserPrompt\n | HookStdinStop\n | HookStdinSession\n | HookStdinNotification\n | HookStdinAgentStart\n | HookStdinAgentEnd\n | HookStdinPermissionRequest\n | HookStdinPermissionResult\n | HookStdinInterrupt\n | HookStdinSubagentStart\n | HookStdinSubagentEnd;\n\n// =============================================================================\n// Stdout Protocol (JSON read from hook process)\n// =============================================================================\n\nexport interface HookStdout {\n decision?: 'allow' | 'block';\n reason?: string;\n additionalContext?: string;\n}\n\n// =============================================================================\n// Execution Results\n// =============================================================================\n\nexport interface HookResult {\n hook: HookDefinition;\n exitCode: number;\n stdout?: HookStdout;\n stderr?: string;\n timedOut: boolean;\n durationMs: number;\n}\n\nexport interface HookEventResult {\n allowed: boolean;\n blockReason?: string;\n additionalContext?: string;\n results: HookResult[];\n warnings: string[];\n}\n"],"mappings":";AAoCA,SAAgB,gBAAgB,OAAkD;CAChF,OAAO,UAAU,gBAAgB,UAAU,UAAU,UAAU;AACjE"}
package/dist/index.d.ts CHANGED
@@ -128,6 +128,40 @@ export declare function createMastraCodeAgentController(config?: MastraCodeConfi
128
128
  sessionId: string;
129
129
  ownerId: string;
130
130
  setActiveSession: (session: Session<MastraCodeState>) => void;
131
+ /**
132
+ * Starts the signal providers contributed by plugins. Called by the
133
+ * composition layer once the controller is inited, because that is when a
134
+ * Mastra instance exists — a provider without one has no storage, and
135
+ * nothing else will hand it one: the Agent propagates Mastra only to the
136
+ * providers in its own `signals` array, which these deliberately are not in.
137
+ */
138
+ startPluginSignalProviders: () => void;
139
+ /**
140
+ * Stops every plugin-contributed signal provider and stops listening for
141
+ * plugin reloads. The inverse of `startPluginSignalProviders`, for an
142
+ * embedder that is done with this controller: a `pluginManager` shared
143
+ * across controllers (`MastraCodeConfig.pluginManager`) outlives any one of
144
+ * them, so without this its providers keep polling and its reload listener
145
+ * keeps firing for a controller that is gone.
146
+ */
147
+ stopPluginSignalProviders: () => void;
148
+ /**
149
+ * Hands Mastra to the statically configured input processors.
150
+ *
151
+ * The Agent does this itself, but only for processors configured as a
152
+ * plain array (`Array.isArray` in `__registerMastra`). This lane is a
153
+ * function so plugins can contribute to it, which takes those processors
154
+ * out of that branch — including any an embedder passed as
155
+ * `config.inputProcessors`, some of which need Mastra to work at all
156
+ * (`CostGuardProcessor` reads observability storage there). Doing it here
157
+ * keeps that unchanged.
158
+ *
159
+ * Plugin processors are deliberately not included: they come and go with
160
+ * their plugin, and the registry keeps the first instance registered under
161
+ * an id forever, which would leave a retired instance behind. Plugins
162
+ * reach Mastra through `getController()` on the plugin context instead.
163
+ */
164
+ registerConfiguredProcessorsWithMastra: () => void;
131
165
  }>;
132
166
  /**
133
167
  * Result of {@link createMastraCodeAgentController}: every shared resource plus the
@@ -175,6 +209,40 @@ export declare function bootLocalAgentController(config?: MastraCodeConfig): Pro
175
209
  sessionId: string;
176
210
  ownerId: string;
177
211
  setActiveSession: (session: Session<MastraCodeState>) => void;
212
+ /**
213
+ * Starts the signal providers contributed by plugins. Called by the
214
+ * composition layer once the controller is inited, because that is when a
215
+ * Mastra instance exists — a provider without one has no storage, and
216
+ * nothing else will hand it one: the Agent propagates Mastra only to the
217
+ * providers in its own `signals` array, which these deliberately are not in.
218
+ */
219
+ startPluginSignalProviders: () => void;
220
+ /**
221
+ * Stops every plugin-contributed signal provider and stops listening for
222
+ * plugin reloads. The inverse of `startPluginSignalProviders`, for an
223
+ * embedder that is done with this controller: a `pluginManager` shared
224
+ * across controllers (`MastraCodeConfig.pluginManager`) outlives any one of
225
+ * them, so without this its providers keep polling and its reload listener
226
+ * keeps firing for a controller that is gone.
227
+ */
228
+ stopPluginSignalProviders: () => void;
229
+ /**
230
+ * Hands Mastra to the statically configured input processors.
231
+ *
232
+ * The Agent does this itself, but only for processors configured as a
233
+ * plain array (`Array.isArray` in `__registerMastra`). This lane is a
234
+ * function so plugins can contribute to it, which takes those processors
235
+ * out of that branch — including any an embedder passed as
236
+ * `config.inputProcessors`, some of which need Mastra to work at all
237
+ * (`CostGuardProcessor` reads observability storage there). Doing it here
238
+ * keeps that unchanged.
239
+ *
240
+ * Plugin processors are deliberately not included: they come and go with
241
+ * their plugin, and the registry keeps the first instance registered under
242
+ * an id forever, which would leave a retired instance behind. Plugins
243
+ * reach Mastra through `getController()` on the plugin context instead.
244
+ */
245
+ registerConfiguredProcessorsWithMastra: () => void;
178
246
  }>;
179
247
  /** Result of {@link mountAgentControllerOnMastra}: shared handles plus the owning Mastra. */
180
248
  export type MountedMastraCode = MastraCodeAgentController & {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EACV,eAAe,EACf,qBAAqB,EAErB,mBAAmB,EACnB,uBAAuB,EAEvB,OAAO,EACR,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAQ7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAmB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,KAAK,EAAE,YAAY,EA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;;;;GAIG;AACH,OAAO,EACL,KAAK,EACL,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ import { hasExplicitOMConfiguration } from "./onboarding/om-settings.js";
29
29
  import { getAvailableModePacks, getAvailableOmPacks, selectPreferredOMPack } from "./onboarding/packs.js";
30
30
  import { getToolCategory } from "./permissions.js";
31
31
  import { PluginManager } from "./plugins/manager.js";
32
+ import { PluginSignalLane } from "./plugins/signal-lane.js";
32
33
  import { PlanRejectionAbortProcessor } from "./processors/plan-rejection-abort.js";
33
34
  import { stateSchema } from "./schema.js";
34
35
  import { mastraBrand } from "./theme-palette.js";
@@ -50,6 +51,7 @@ import { AgentController } from "@mastra/core/agent-controller";
50
51
  import { createCodingAgent } from "@mastra/core/coding-agent";
51
52
  import { PROVIDER_REGISTRY } from "@mastra/core/llm";
52
53
  import { Mastra } from "@mastra/core/mastra";
54
+ import { defaultNotificationDeliveryDecision } from "@mastra/core/notifications";
53
55
  import { AgentsMDInjector, PrefillErrorHandler, ProviderHistoryCompat, StreamErrorRetryProcessor, isBadRequestError } from "@mastra/core/processors";
54
56
  import { RequestContext } from "@mastra/core/request-context";
55
57
  import { InMemoryHarness, MastraCompositeStore } from "@mastra/core/storage";
@@ -201,6 +203,7 @@ async function createMastraCodeAgentController(config) {
201
203
  const homeDir = config?.homeDir ?? config?.initialState?.homeDir;
202
204
  const configDir = config?.configDir ?? ".mastracode";
203
205
  let activeSession;
206
+ let pluginRuntimeController;
204
207
  if (configDir !== ".mastracode") validateConfigDirName(configDir);
205
208
  try {
206
209
  process.loadEnvFile(path.join(cwd, ".env"));
@@ -314,66 +317,136 @@ async function createMastraCodeAgentController(config) {
314
317
  });
315
318
  const memory = config?.memory === false ? void 0 : config?.memory ?? getDynamicMemory(storage, vector);
316
319
  const mcpManager = config?.disableMcp ? void 0 : createMcpManager(project.rootPath, configDir, config?.mcpServers);
317
- const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir, homeDir);
320
+ const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir, homeDir, project.isWorktree ? {
321
+ path: project.rootPath,
322
+ branch: project.gitBranch,
323
+ mainRepoPath: project.mainRepoPath
324
+ } : void 0);
318
325
  const pluginManager = config?.disablePlugins ? void 0 : config?.pluginManager ?? new PluginManager({
319
326
  projectRoot: project.rootPath,
320
327
  configDir,
321
328
  homeDir
322
329
  });
330
+ pluginManager?.setRuntime({
331
+ getController: () => pluginRuntimeController,
332
+ getActiveSession: () => activeSession
333
+ });
323
334
  const loadedPlugins = pluginManager ? await pluginManager.reload() : [];
324
335
  const pluginTools = pluginManager?.getPluginTools() ?? {};
325
336
  const outcomeScorer = createOutcomeScorer();
326
337
  const efficiencyScorer = createEfficiencyScorer();
338
+ const getNotificationStreamOptions = async ({ resourceId, threadId }) => {
339
+ const session = await controller.getSessionByResource(resourceId) ?? activeSession;
340
+ if (!session) return void 0;
341
+ const modeId = session.mode.get();
342
+ const defaultModeModelId = controller.listModes().find((mode) => mode.id === modeId)?.defaultModelId;
343
+ const modelId = session.model.get() || activeSession?.model.get() || defaultModeModelId || "";
344
+ const requestContext = new RequestContext();
345
+ const agentControllerContext = {
346
+ controllerId: controller.id,
347
+ state: session.state.get(),
348
+ getState: () => session.state.get(),
349
+ setState: (updates) => session.state.set(updates),
350
+ threadId,
351
+ resourceId,
352
+ session: {
353
+ id: session.identity.getId(),
354
+ ownerId: session.identity.getOwnerId(),
355
+ modeId,
356
+ modelId,
357
+ state: {
358
+ get: () => session.state.get(),
359
+ set: (updates) => session.state.set(updates),
360
+ update: (updater) => session.state.update(updater)
361
+ }
362
+ },
363
+ workspace: session.getWorkspace(),
364
+ getSubagentModelId: (params) => session.subagents.model.get(params ?? {})
365
+ };
366
+ requestContext.set("controller", agentControllerContext);
367
+ return {
368
+ memory: {
369
+ thread: threadId,
370
+ resource: resourceId
371
+ },
372
+ requestContext,
373
+ maxSteps: 1e3,
374
+ savePerStep: false,
375
+ requireToolApproval: session.state.get().yolo !== true,
376
+ modelSettings: { temperature: 1 }
377
+ };
378
+ };
327
379
  const githubSignals = globalSettings.signals?.experimentalGithubSignals && !config?.disableGithubSignals ? new GithubSignals({
328
380
  cwd: project.rootPath,
329
381
  gitcrawlCommand: process.env.MASTRACODE_GITCRAWL_BIN ?? process.env.GITCRAWL_BIN ?? process.env.MASTRACODE_GITCRAWL_COMMAND ?? process.env.GITCRAWL_COMMAND,
330
- getNotificationStreamOptions: async ({ resourceId, threadId }) => {
331
- const session = await controller.getSessionByResource(resourceId) ?? activeSession;
332
- const modeId = session.mode.get();
333
- const defaultModeModelId = controller.listModes().find((mode) => mode.id === modeId)?.defaultModelId;
334
- const modelId = session.model.get() || activeSession?.model.get() || defaultModeModelId || "";
335
- const requestContext = new RequestContext();
336
- const agentControllerContext = {
337
- controllerId: controller.id,
338
- state: session.state.get(),
339
- getState: () => session.state.get(),
340
- setState: (updates) => session.state.set(updates),
341
- threadId,
342
- resourceId,
343
- session: {
344
- id: session.identity.getId(),
345
- ownerId: session.identity.getOwnerId(),
346
- modeId,
347
- modelId,
348
- state: {
349
- get: () => session.state.get(),
350
- set: (updates) => session.state.set(updates),
351
- update: (updater) => session.state.update(updater)
352
- }
353
- },
354
- workspace: controller.getWorkspace(),
355
- getSubagentModelId: (params) => session.subagents.model.get(params ?? {})
356
- };
357
- requestContext.set("controller", agentControllerContext);
358
- return {
359
- memory: {
360
- thread: threadId,
361
- resource: resourceId
362
- },
363
- requestContext,
364
- maxSteps: 1e3,
365
- savePerStep: false,
366
- requireToolApproval: session.state.get().yolo !== true,
367
- modelSettings: { temperature: 1 }
368
- };
369
- }
382
+ getNotificationStreamOptions
370
383
  }) : void 0;
384
+ const mastraCodeInputProcessors = [
385
+ ...config?.inputProcessors ?? [],
386
+ new PlanRejectionAbortProcessor(),
387
+ new AgentsMDInjector({
388
+ isEnabled: ({ requestContext }) => {
389
+ const state = getInjectorSessionState(requestContext);
390
+ return state?.untrustedCheckout !== true || typeof state?.baseRef === "string";
391
+ },
392
+ getReader: ({ requestContext }) => {
393
+ const state = getInjectorSessionState(requestContext);
394
+ if (state?.untrustedCheckout !== true || typeof state?.baseRef !== "string") return void 0;
395
+ return createGitRefReminderReader(state?.projectPath ?? project.rootPath, state.baseRef);
396
+ },
397
+ getIgnoredInstructionPaths: ({ requestContext }) => {
398
+ const state = getInjectorSessionState(requestContext);
399
+ const projectPath = state?.projectPath ?? project.rootPath;
400
+ return getStaticallyLoadedInstructionPaths(projectPath, void 0, state?.untrustedCheckout === true && typeof state?.baseRef === "string" ? createGitRefInstructionReader(projectPath, state.baseRef) : void 0);
401
+ }
402
+ }),
403
+ new ProviderHistoryCompat()
404
+ ];
405
+ const taskSignalProvider = new TaskSignalProvider();
406
+ const NO_PLUGIN_PROCESSORS = {
407
+ input: [],
408
+ output: []
409
+ };
410
+ let pluginProcessorReadWarned = false;
411
+ const pluginSignalLane = pluginManager ? new PluginSignalLane({ reservedProviderIds: [taskSignalProvider.id, ...githubSignals ? [githubSignals.id] : []] }) : void 0;
412
+ let unsubscribePluginReload;
413
+ /**
414
+ * Plugin processors are read through a function so that enabling, disabling or
415
+ * updating a plugin takes effect on the next request rather than requiring a
416
+ * new agent. This runs before every LLM call, and also outside the request
417
+ * path when the Agent catalogues its configured processors — where a throw is
418
+ * swallowed into a debug log. So it only reads already-resolved state: no
419
+ * filesystem, no network, no construction, and it never throws.
420
+ */
421
+ const readPluginProcessors = () => {
422
+ try {
423
+ return pluginManager?.getPluginProcessors() ?? NO_PLUGIN_PROCESSORS;
424
+ } catch (error) {
425
+ if (!pluginProcessorReadWarned) {
426
+ pluginProcessorReadWarned = true;
427
+ console.warn("Failed to read plugin processors:", error);
428
+ }
429
+ return NO_PLUGIN_PROCESSORS;
430
+ }
431
+ };
371
432
  const codeAgent = createCodingAgent({
372
433
  id: CODE_AGENT_ID,
373
434
  name: "Code Agent",
374
435
  workspace: void 0,
375
436
  instructions: getDynamicInstructions,
376
- model: getDynamicModel,
437
+ model: (ctx) => getDynamicModel(ctx, config?.settingsPath),
438
+ notifications: { deliveryPolicy: { decide: async (input) => {
439
+ const decision = defaultNotificationDeliveryDecision(input);
440
+ if (!input.record.resourceId) return decision;
441
+ const streamOptions = await getNotificationStreamOptions({
442
+ resourceId: input.record.resourceId,
443
+ threadId: input.record.threadId
444
+ });
445
+ return streamOptions ? {
446
+ ...decision,
447
+ streamOptions
448
+ } : decision;
449
+ } } },
377
450
  tools: createDynamicTools(mcpManager, config?.extraTools, config?.disabledTools, storage, pluginTools),
378
451
  hooks: createToolHooks(hookManager, config?.postToolObserver),
379
452
  scorers: {
@@ -389,7 +462,7 @@ async function createMastraCodeAgentController(config) {
389
462
  }
390
463
  }
391
464
  },
392
- signals: [new TaskSignalProvider(), ...githubSignals ? [githubSignals] : []],
465
+ signals: [taskSignalProvider, ...githubSignals ? [githubSignals] : []],
393
466
  goal: {
394
467
  judge: (ctx) => getGoalJudgeModel(ctx, config?.settingsPath),
395
468
  maxRuns: globalSettings.models.goalMaxTurns ?? 50,
@@ -397,27 +470,12 @@ async function createMastraCodeAgentController(config) {
397
470
  prompt: DEFAULT_GOAL_JUDGE_PROMPT,
398
471
  tools: getGoalJudgeTools
399
472
  },
400
- inputProcessors: [
401
- ...config?.inputProcessors ?? [],
402
- new PlanRejectionAbortProcessor(),
403
- new AgentsMDInjector({
404
- isEnabled: ({ requestContext }) => {
405
- const state = getInjectorSessionState(requestContext);
406
- return state?.untrustedCheckout !== true || typeof state?.baseRef === "string";
407
- },
408
- getReader: ({ requestContext }) => {
409
- const state = getInjectorSessionState(requestContext);
410
- if (state?.untrustedCheckout !== true || typeof state?.baseRef !== "string") return void 0;
411
- return createGitRefReminderReader(state?.projectPath ?? project.rootPath, state.baseRef);
412
- },
413
- getIgnoredInstructionPaths: ({ requestContext }) => {
414
- const state = getInjectorSessionState(requestContext);
415
- const projectPath = state?.projectPath ?? project.rootPath;
416
- return getStaticallyLoadedInstructionPaths(projectPath, void 0, state?.untrustedCheckout === true && typeof state?.baseRef === "string" ? createGitRefInstructionReader(projectPath, state.baseRef) : void 0);
417
- }
418
- }),
419
- new ProviderHistoryCompat()
473
+ inputProcessors: () => [
474
+ ...mastraCodeInputProcessors,
475
+ ...readPluginProcessors().input.map((entry) => entry.value),
476
+ ...pluginSignalLane?.getInputProcessors() ?? []
420
477
  ],
478
+ outputProcessors: () => [...readPluginProcessors().output.map((entry) => entry.value), ...pluginSignalLane?.getOutputProcessors() ?? []],
421
479
  errorProcessors: [
422
480
  new ProviderHistoryCompat(),
423
481
  new StreamErrorRetryProcessor({ matchers: [
@@ -518,7 +576,6 @@ async function createMastraCodeAgentController(config) {
518
576
  if (effectiveObserveAttachments !== void 0) globalInitialState.observeAttachments = effectiveObserveAttachments;
519
577
  }
520
578
  if (globalSettings.preferences.yolo !== null) globalInitialState.yolo = globalSettings.preferences.yolo;
521
- globalInitialState.thinkingLevel = globalSettings.preferences.thinkingLevel;
522
579
  if (config?.omScope) globalInitialState.omScope = config.omScope;
523
580
  for (const [key, modelId] of Object.entries(globalSettings.models.subagentModels)) if (key === "default" || key === "_default") globalInitialState.subagentModelId = modelId;
524
581
  else globalInitialState[`subagentModelId_${key}`] = modelId;
@@ -567,6 +624,11 @@ async function createMastraCodeAgentController(config) {
567
624
  release: releaseThreadLock
568
625
  }
569
626
  });
627
+ pluginRuntimeController = controller;
628
+ if (pluginSignalLane && pluginManager) {
629
+ pluginSignalLane.sync(pluginManager.getPluginSignalProviders());
630
+ unsubscribePluginReload = pluginManager.onReload(() => pluginSignalLane.sync(pluginManager.getPluginSignalProviders()));
631
+ }
570
632
  return {
571
633
  controller,
572
634
  storage,
@@ -591,6 +653,55 @@ async function createMastraCodeAgentController(config) {
591
653
  ownerId,
592
654
  setActiveSession: (session) => {
593
655
  activeSession = session;
656
+ },
657
+ /**
658
+ * Starts the signal providers contributed by plugins. Called by the
659
+ * composition layer once the controller is inited, because that is when a
660
+ * Mastra instance exists — a provider without one has no storage, and
661
+ * nothing else will hand it one: the Agent propagates Mastra only to the
662
+ * providers in its own `signals` array, which these deliberately are not in.
663
+ */
664
+ startPluginSignalProviders: () => {
665
+ const mastra = controller.getMastra();
666
+ if (!pluginSignalLane || !mastra) return;
667
+ pluginSignalLane.setMastra(mastra, codeAgent);
668
+ },
669
+ /**
670
+ * Stops every plugin-contributed signal provider and stops listening for
671
+ * plugin reloads. The inverse of `startPluginSignalProviders`, for an
672
+ * embedder that is done with this controller: a `pluginManager` shared
673
+ * across controllers (`MastraCodeConfig.pluginManager`) outlives any one of
674
+ * them, so without this its providers keep polling and its reload listener
675
+ * keeps firing for a controller that is gone.
676
+ */
677
+ stopPluginSignalProviders: () => {
678
+ unsubscribePluginReload?.();
679
+ unsubscribePluginReload = void 0;
680
+ pluginSignalLane?.stopAll();
681
+ },
682
+ /**
683
+ * Hands Mastra to the statically configured input processors.
684
+ *
685
+ * The Agent does this itself, but only for processors configured as a
686
+ * plain array (`Array.isArray` in `__registerMastra`). This lane is a
687
+ * function so plugins can contribute to it, which takes those processors
688
+ * out of that branch — including any an embedder passed as
689
+ * `config.inputProcessors`, some of which need Mastra to work at all
690
+ * (`CostGuardProcessor` reads observability storage there). Doing it here
691
+ * keeps that unchanged.
692
+ *
693
+ * Plugin processors are deliberately not included: they come and go with
694
+ * their plugin, and the registry keeps the first instance registered under
695
+ * an id forever, which would leave a retired instance behind. Plugins
696
+ * reach Mastra through `getController()` on the plugin context instead.
697
+ */
698
+ registerConfiguredProcessorsWithMastra: () => {
699
+ const mastra = controller.getMastra();
700
+ if (!mastra) return;
701
+ for (const processor of mastraCodeInputProcessors) {
702
+ mastra.addProcessor(processor);
703
+ mastra.addProcessorConfiguration(processor, CODE_AGENT_ID, "input");
704
+ }
594
705
  }
595
706
  };
596
707
  }
@@ -643,6 +754,8 @@ async function bootLocalAgentController(config) {
643
754
  const { controller, sessionId, ownerId } = base;
644
755
  await controller.init();
645
756
  await controller.getMastra()?.startWorkers();
757
+ base.registerConfiguredProcessorsWithMastra();
758
+ base.startPluginSignalProviders();
646
759
  const session = await controller.createSession({
647
760
  id: sessionId,
648
761
  ownerId
@@ -720,6 +833,8 @@ async function prepareAgentControllerMount(config) {
720
833
  const finalize = async () => {
721
834
  await controller.init();
722
835
  await controller.getMastra()?.startWorkers();
836
+ base.registerConfiguredProcessorsWithMastra();
837
+ base.startPluginSignalProviders();
723
838
  };
724
839
  return {
725
840
  base,