mastracode 0.21.2 → 0.22.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/CHANGELOG.md +38 -0
- package/dist/HarnessCompat.d.ts +21 -2
- package/dist/HarnessCompat.d.ts.map +1 -1
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -1
- package/dist/agents/tools.d.ts +2 -1
- package/dist/agents/tools.d.ts.map +1 -1
- package/dist/{chunk-HFGEUXMI.js → chunk-7ZTY5SBK.js} +1154 -13
- package/dist/chunk-7ZTY5SBK.js.map +1 -0
- package/dist/{chunk-MNOWL5GQ.cjs → chunk-B4IKAUT7.cjs} +3533 -2776
- package/dist/chunk-B4IKAUT7.cjs.map +1 -0
- package/dist/{chunk-YRX4OMQN.js → chunk-BFO3NTQO.js} +2671 -1914
- package/dist/chunk-BFO3NTQO.js.map +1 -0
- package/dist/{chunk-A4TDK7QP.cjs → chunk-DFC5V3P7.cjs} +267 -103
- package/dist/chunk-DFC5V3P7.cjs.map +1 -0
- package/dist/{chunk-DJBUYADN.cjs → chunk-EAUXUMEB.cjs} +1157 -12
- package/dist/chunk-EAUXUMEB.cjs.map +1 -0
- package/dist/{chunk-AWYGW5ZV.cjs → chunk-JHYTJMKT.cjs} +7 -3
- package/dist/chunk-JHYTJMKT.cjs.map +1 -0
- package/dist/{chunk-TTAAM2XR.js → chunk-UOFNLVKF.js} +7 -3
- package/dist/chunk-UOFNLVKF.js.map +1 -0
- package/dist/{chunk-J4DYNVTI.js → chunk-Y5AUV6T3.js} +202 -38
- package/dist/chunk-Y5AUV6T3.js.map +1 -0
- package/dist/cli.cjs +27 -19
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +1 -1
- package/dist/github-signals/index.d.ts +217 -0
- package/dist/github-signals/index.d.ts.map +1 -0
- package/dist/headless.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/onboarding/settings.d.ts +2 -0
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/permissions-RL7PPO42.cjs +40 -0
- package/dist/{permissions-GWY37IEK.cjs.map → permissions-RL7PPO42.cjs.map} +1 -1
- package/dist/permissions-TJGRCT4O.js +3 -0
- package/dist/{permissions-EDE3D2DA.js.map → permissions-TJGRCT4O.js.map} +1 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/schema.d.ts +7 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/tool-names.d.ts +1 -0
- package/dist/tool-names.d.ts.map +1 -1
- package/dist/tui/command-dispatch.d.ts.map +1 -1
- package/dist/tui/commands/github.d.ts +3 -0
- package/dist/tui/commands/github.d.ts.map +1 -0
- package/dist/tui/commands/index.d.ts +1 -0
- package/dist/tui/commands/index.d.ts.map +1 -1
- package/dist/tui/commands/settings.d.ts.map +1 -1
- package/dist/tui/components/help-overlay.d.ts.map +1 -1
- package/dist/tui/components/notification-summary.d.ts +12 -0
- package/dist/tui/components/notification-summary.d.ts.map +1 -0
- package/dist/tui/components/notification.d.ts +14 -0
- package/dist/tui/components/notification.d.ts.map +1 -0
- package/dist/tui/components/reactive-signal.d.ts +11 -0
- package/dist/tui/components/reactive-signal.d.ts.map +1 -0
- package/dist/tui/components/settings.d.ts +2 -0
- package/dist/tui/components/settings.d.ts.map +1 -1
- package/dist/tui/components/state-signal.d.ts +13 -0
- package/dist/tui/components/state-signal.d.ts.map +1 -0
- package/dist/tui/event-dispatch.d.ts.map +1 -1
- package/dist/tui/handlers/message.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/render-messages.d.ts.map +1 -1
- package/dist/tui/setup.d.ts.map +1 -1
- package/dist/tui/state.d.ts +14 -0
- package/dist/tui/state.d.ts.map +1 -1
- package/dist/tui/status-line.d.ts.map +1 -1
- package/dist/tui.cjs +19 -19
- package/dist/tui.js +2 -2
- package/package.json +10 -10
- package/dist/chunk-A4TDK7QP.cjs.map +0 -1
- package/dist/chunk-AWYGW5ZV.cjs.map +0 -1
- package/dist/chunk-DJBUYADN.cjs.map +0 -1
- package/dist/chunk-HFGEUXMI.js.map +0 -1
- package/dist/chunk-J4DYNVTI.js.map +0 -1
- package/dist/chunk-MNOWL5GQ.cjs.map +0 -1
- package/dist/chunk-TTAAM2XR.js.map +0 -1
- package/dist/chunk-YRX4OMQN.js.map +0 -1
- package/dist/permissions-EDE3D2DA.js +0 -3
- package/dist/permissions-GWY37IEK.cjs +0 -40
|
@@ -21,7 +21,9 @@ var MC_TOOLS = {
|
|
|
21
21
|
GET_PROCESS_OUTPUT: "get_process_output",
|
|
22
22
|
KILL_PROCESS: "kill_process",
|
|
23
23
|
// Code intelligence
|
|
24
|
-
LSP_INSPECT: "lsp_inspect"
|
|
24
|
+
LSP_INSPECT: "lsp_inspect",
|
|
25
|
+
// Notifications
|
|
26
|
+
NOTIFICATION_INBOX: "notification_inbox"
|
|
25
27
|
};
|
|
26
28
|
var TOOL_NAME_OVERRIDES = {
|
|
27
29
|
[workspace.WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]: { name: MC_TOOLS.VIEW },
|
|
@@ -68,6 +70,8 @@ var TOOL_CATEGORY_MAP = {
|
|
|
68
70
|
"web-search": "read",
|
|
69
71
|
web_extract: "read",
|
|
70
72
|
"web-extract": "read",
|
|
73
|
+
// Edit tools — mutate local project or session state
|
|
74
|
+
[MC_TOOLS.NOTIFICATION_INBOX]: "edit",
|
|
71
75
|
// Edit tools — modify files
|
|
72
76
|
[MC_TOOLS.STRING_REPLACE_LSP]: "edit",
|
|
73
77
|
[MC_TOOLS.AST_SMART_EDIT]: "edit",
|
|
@@ -156,5 +160,5 @@ exports.createDefaultRules = createDefaultRules;
|
|
|
156
160
|
exports.getToolCategory = getToolCategory;
|
|
157
161
|
exports.getToolsForCategory = getToolsForCategory;
|
|
158
162
|
exports.resolveApproval = resolveApproval;
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
160
|
-
//# sourceMappingURL=chunk-
|
|
163
|
+
//# sourceMappingURL=chunk-JHYTJMKT.cjs.map
|
|
164
|
+
//# sourceMappingURL=chunk-JHYTJMKT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tool-names.ts","../src/permissions.ts"],"names":["WORKSPACE_TOOLS"],"mappings":";;;;;AAaO,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,IAAA,EAAM,MAAA;AAAA,EACN,UAAA,EAAY,YAAA;AAAA,EACZ,kBAAA,EAAoB,oBAAA;AAAA,EACpB,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,eAAA,EAAiB,iBAAA;AAAA,EACjB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,YAAA,EAAc,cAAA;AAAA;AAAA,EAGd,WAAA,EAAa,aAAA;AAAA;AAAA,EAGb,kBAAA,EAAoB;AACtB;AAOO,IAAM,mBAAA,GAAsB;AAAA,EACjC,CAACA,0BAAgB,UAAA,CAAW,SAAS,GAAG,EAAE,IAAA,EAAM,SAAS,IAAA,EAAK;AAAA,EAC9D,CAACA,0BAAgB,UAAA,CAAW,UAAU,GAAG,EAAE,IAAA,EAAM,SAAS,UAAA,EAAW;AAAA,EACrE,CAACA,0BAAgB,UAAA,CAAW,SAAS,GAAG,EAAE,IAAA,EAAM,SAAS,kBAAA,EAAmB;AAAA,EAC5E,CAACA,0BAAgB,UAAA,CAAW,UAAU,GAAG,EAAE,IAAA,EAAM,SAAS,UAAA,EAAW;AAAA,EACrE,CAACA,0BAAgB,UAAA,CAAW,MAAM,GAAG,EAAE,IAAA,EAAM,SAAS,WAAA,EAAY;AAAA,EAClE,CAAC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AAA,CAAM,QAAQ,CAAA;AACvC,EAAA,IAAI,YAAY,OAAO,UAAA;AAGvB,EAAA,IAAI,aAAA,CAAc,SAAA,CAAU,QAAA,EAAU,QAAQ,GAAG,OAAO,OAAA;AAGxD,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,UAAA,CAAW,QAAQ,CAAA;AAChD,EAAA,IAAI,gBAAgB,OAAO,cAAA;AAG3B,EAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,KAAA;AACvC","file":"chunk-JHYTJMKT.cjs","sourcesContent":["/**\n * Mastracode tool name constants.\n *\n * These are the names exposed to the LLM via workspace tool name remapping.\n * Used throughout mastracode for permissions, TUI rendering, tool guidance,\n * subagent allowedTools, etc.\n *\n * The workspace tools get remapped from their core names (e.g. `mastra_workspace_read_file`)\n * to these names (e.g. `view`) via the `name` property in workspace tool config.\n */\n\nimport { WORKSPACE_TOOLS } from '@mastra/core/workspace';\n\nexport const MC_TOOLS = {\n // Filesystem\n VIEW: 'view',\n WRITE_FILE: 'write_file',\n STRING_REPLACE_LSP: 'string_replace_lsp',\n FIND_FILES: 'find_files',\n DELETE_FILE: 'delete_file',\n FILE_STAT: 'file_stat',\n MKDIR: 'mkdir',\n\n // Search\n SEARCH_CONTENT: 'search_content',\n\n // Code intelligence\n AST_SMART_EDIT: 'ast_smart_edit',\n\n // Sandbox\n EXECUTE_COMMAND: 'execute_command',\n GET_PROCESS_OUTPUT: 'get_process_output',\n KILL_PROCESS: 'kill_process',\n\n // Code intelligence\n LSP_INSPECT: 'lsp_inspect',\n\n // Notifications\n NOTIFICATION_INBOX: 'notification_inbox',\n} as const;\n\n/**\n * Workspace tool name remapping config.\n * Maps core workspace tool constants to mastracode's tool names.\n * Pass this (or spread it) into `Workspace({ tools: ... })`.\n */\nexport const TOOL_NAME_OVERRIDES = {\n [WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]: { name: MC_TOOLS.VIEW },\n [WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE]: { name: MC_TOOLS.WRITE_FILE },\n [WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE]: { name: MC_TOOLS.STRING_REPLACE_LSP },\n [WORKSPACE_TOOLS.FILESYSTEM.LIST_FILES]: { name: MC_TOOLS.FIND_FILES },\n [WORKSPACE_TOOLS.FILESYSTEM.DELETE]: { name: MC_TOOLS.DELETE_FILE },\n [WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT]: { name: MC_TOOLS.FILE_STAT },\n [WORKSPACE_TOOLS.FILESYSTEM.MKDIR]: { name: MC_TOOLS.MKDIR },\n [WORKSPACE_TOOLS.FILESYSTEM.GREP]: { name: MC_TOOLS.SEARCH_CONTENT },\n [WORKSPACE_TOOLS.FILESYSTEM.AST_EDIT]: { name: MC_TOOLS.AST_SMART_EDIT },\n [WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND]: { name: MC_TOOLS.EXECUTE_COMMAND },\n [WORKSPACE_TOOLS.SANDBOX.GET_PROCESS_OUTPUT]: { name: MC_TOOLS.GET_PROCESS_OUTPUT },\n [WORKSPACE_TOOLS.SANDBOX.KILL_PROCESS]: { name: MC_TOOLS.KILL_PROCESS },\n [WORKSPACE_TOOLS.LSP.LSP_INSPECT]: { name: MC_TOOLS.LSP_INSPECT },\n} as const;\n","/**\n * Granular tool permission system.\n *\n * Tools are classified into categories by risk level.\n * Each category has a configurable policy: \"allow\", \"ask\", or \"deny\".\n * Session-scoped grants let the user approve a category once per session.\n */\n\nimport { MC_TOOLS } from './tool-names.js';\n\n// ---------------------------------------------------------------------------\n// Categories\n// ---------------------------------------------------------------------------\n\nexport type ToolCategory = 'read' | 'edit' | 'execute' | 'mcp';\n\nexport const TOOL_CATEGORIES: Record<ToolCategory, { label: string; description: string }> = {\n read: {\n label: 'Read',\n description: 'Read files, search, list directories',\n },\n edit: {\n label: 'Edit',\n description: 'Create, modify, or delete files',\n },\n execute: {\n label: 'Execute',\n description: 'Run shell commands',\n },\n mcp: {\n label: 'MCP',\n description: 'External MCP server tools',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Tool → Category mapping\n// ---------------------------------------------------------------------------\n\nconst TOOL_CATEGORY_MAP: Record<string, ToolCategory> = {\n // Read-only tools — always safe\n [MC_TOOLS.VIEW]: 'read',\n [MC_TOOLS.SEARCH_CONTENT]: 'read',\n [MC_TOOLS.FIND_FILES]: 'read',\n [MC_TOOLS.LSP_INSPECT]: 'read',\n web_search: 'read',\n 'web-search': 'read',\n web_extract: 'read',\n 'web-extract': 'read',\n // Edit tools — mutate local project or session state\n [MC_TOOLS.NOTIFICATION_INBOX]: 'edit',\n // Edit tools — modify files\n [MC_TOOLS.STRING_REPLACE_LSP]: 'edit',\n [MC_TOOLS.AST_SMART_EDIT]: 'edit',\n [MC_TOOLS.WRITE_FILE]: 'edit',\n subagent: 'edit',\n\n // Execute tools — run arbitrary commands\n [MC_TOOLS.EXECUTE_COMMAND]: 'execute',\n\n // Interactive / planning tools — always allowed (no category needed)\n // ask_user, task_write, task_update, task_complete, task_check, submit_plan, request_access\n};\n\n// Tools that never need approval regardless of policy\nconst ALWAYS_ALLOW_TOOLS = new Set([\n 'ask_user',\n 'task_write',\n 'task_update',\n 'task_complete',\n 'task_check',\n 'submit_plan',\n 'request_access',\n]);\n\n/**\n * Get the category for a tool, or null if the tool is always-allowed.\n */\nexport function getToolCategory(toolName: string): ToolCategory | null {\n if (ALWAYS_ALLOW_TOOLS.has(toolName)) return null;\n return TOOL_CATEGORY_MAP[toolName] ?? 'mcp';\n}\n\n/**\n * Get the list of known tools for a given category.\n */\nexport function getToolsForCategory(category: ToolCategory): string[] {\n return Object.entries(TOOL_CATEGORY_MAP)\n .filter(([, cat]) => cat === category)\n .map(([tool]) => tool);\n}\n\n// ---------------------------------------------------------------------------\n// Policies\n// ---------------------------------------------------------------------------\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport interface PermissionRules {\n /** Policy per category. Missing categories default to their DEFAULT_POLICIES value. */\n categories: Partial<Record<ToolCategory, PermissionPolicy>>;\n /** Per-tool overrides. Tool name → policy. Takes precedence over category. */\n tools: Record<string, PermissionPolicy>;\n}\n\n/** Default policies when no rules are configured (YOLO=false equivalent). */\nexport const DEFAULT_POLICIES: Record<ToolCategory, PermissionPolicy> = {\n read: 'allow',\n edit: 'ask',\n execute: 'ask',\n mcp: 'ask',\n};\n\n/** YOLO-mode policies — everything auto-allowed. */\nexport const YOLO_POLICIES: Record<ToolCategory, PermissionPolicy> = {\n read: 'allow',\n edit: 'allow',\n execute: 'allow',\n mcp: 'allow',\n};\n\nexport function createDefaultRules(): PermissionRules {\n return {\n categories: { ...DEFAULT_POLICIES },\n tools: {},\n };\n}\n\n// ---------------------------------------------------------------------------\n// Session grants — temporary \"always allow\" for this session\n// ---------------------------------------------------------------------------\n\nexport class SessionGrants {\n private grantedCategories = new Set<ToolCategory>();\n private grantedTools = new Set<string>();\n\n allowCategory(category: ToolCategory): void {\n this.grantedCategories.add(category);\n }\n\n allowTool(toolName: string): void {\n this.grantedTools.add(toolName);\n }\n\n isGranted(toolName: string, category: ToolCategory): boolean {\n return this.grantedTools.has(toolName) || this.grantedCategories.has(category);\n }\n\n reset(): void {\n this.grantedCategories.clear();\n this.grantedTools.clear();\n }\n\n getGrantedCategories(): ToolCategory[] {\n return [...this.grantedCategories];\n }\n\n getGrantedTools(): string[] {\n return [...this.grantedTools];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Decision engine\n// ---------------------------------------------------------------------------\n\nexport type ApprovalDecision = 'allow' | 'ask' | 'deny';\n\n/**\n * Determine whether a tool call should be allowed, prompted, or denied.\n *\n * Priority order:\n * 1. Always-allowed tools (ask_user, task_write, etc.) → allow\n * 2. Per-tool policy override → use that policy\n * 3. Session grants (user said \"always allow\" during this session) → allow\n * 4. Category policy → use that policy\n * 5. Fallback → \"ask\"\n */\nexport function resolveApproval(\n toolName: string,\n rules: PermissionRules,\n sessionGrants: SessionGrants,\n): ApprovalDecision {\n // 1. Always-allowed tools\n const category = getToolCategory(toolName);\n if (category === null) return 'allow';\n\n // 2. Per-tool override\n const toolPolicy = rules.tools[toolName];\n if (toolPolicy) return toolPolicy;\n\n // 3. Session grants\n if (sessionGrants.isGranted(toolName, category)) return 'allow';\n\n // 4. Category policy\n const categoryPolicy = rules.categories[category];\n if (categoryPolicy) return categoryPolicy;\n\n // 5. Default policy for category\n return DEFAULT_POLICIES[category] ?? 'ask';\n}\n"]}
|
|
@@ -19,7 +19,9 @@ var MC_TOOLS = {
|
|
|
19
19
|
GET_PROCESS_OUTPUT: "get_process_output",
|
|
20
20
|
KILL_PROCESS: "kill_process",
|
|
21
21
|
// Code intelligence
|
|
22
|
-
LSP_INSPECT: "lsp_inspect"
|
|
22
|
+
LSP_INSPECT: "lsp_inspect",
|
|
23
|
+
// Notifications
|
|
24
|
+
NOTIFICATION_INBOX: "notification_inbox"
|
|
23
25
|
};
|
|
24
26
|
var TOOL_NAME_OVERRIDES = {
|
|
25
27
|
[WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]: { name: MC_TOOLS.VIEW },
|
|
@@ -66,6 +68,8 @@ var TOOL_CATEGORY_MAP = {
|
|
|
66
68
|
"web-search": "read",
|
|
67
69
|
web_extract: "read",
|
|
68
70
|
"web-extract": "read",
|
|
71
|
+
// Edit tools — mutate local project or session state
|
|
72
|
+
[MC_TOOLS.NOTIFICATION_INBOX]: "edit",
|
|
69
73
|
// Edit tools — modify files
|
|
70
74
|
[MC_TOOLS.STRING_REPLACE_LSP]: "edit",
|
|
71
75
|
[MC_TOOLS.AST_SMART_EDIT]: "edit",
|
|
@@ -145,5 +149,5 @@ function resolveApproval(toolName, rules, sessionGrants) {
|
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
export { DEFAULT_POLICIES, MC_TOOLS, SessionGrants, TOOL_CATEGORIES, TOOL_NAME_OVERRIDES, YOLO_POLICIES, createDefaultRules, getToolCategory, getToolsForCategory, resolveApproval };
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
149
|
-
//# sourceMappingURL=chunk-
|
|
152
|
+
//# sourceMappingURL=chunk-UOFNLVKF.js.map
|
|
153
|
+
//# sourceMappingURL=chunk-UOFNLVKF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tool-names.ts","../src/permissions.ts"],"names":[],"mappings":";;;AAaO,IAAM,QAAA,GAAW;AAAA;AAAA,EAEtB,IAAA,EAAM,MAAA;AAAA,EACN,UAAA,EAAY,YAAA;AAAA,EACZ,kBAAA,EAAoB,oBAAA;AAAA,EACpB,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,SAAA,EAAW,WAAA;AAAA,EACX,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAGhB,eAAA,EAAiB,iBAAA;AAAA,EACjB,kBAAA,EAAoB,oBAAA;AAAA,EACpB,YAAA,EAAc,cAAA;AAAA;AAAA,EAGd,WAAA,EAAa,aAAA;AAAA;AAAA,EAGb,kBAAA,EAAoB;AACtB;AAOO,IAAM,mBAAA,GAAsB;AAAA,EACjC,CAAC,gBAAgB,UAAA,CAAW,SAAS,GAAG,EAAE,IAAA,EAAM,SAAS,IAAA,EAAK;AAAA,EAC9D,CAAC,gBAAgB,UAAA,CAAW,UAAU,GAAG,EAAE,IAAA,EAAM,SAAS,UAAA,EAAW;AAAA,EACrE,CAAC,gBAAgB,UAAA,CAAW,SAAS,GAAG,EAAE,IAAA,EAAM,SAAS,kBAAA,EAAmB;AAAA,EAC5E,CAAC,gBAAgB,UAAA,CAAW,UAAU,GAAG,EAAE,IAAA,EAAM,SAAS,UAAA,EAAW;AAAA,EACrE,CAAC,gBAAgB,UAAA,CAAW,MAAM,GAAG,EAAE,IAAA,EAAM,SAAS,WAAA,EAAY;AAAA,EAClE,CAAC,gBAAgB,UAAA,CAAW,SAAS,GAAG,EAAE,IAAA,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,OAAO,UAAA;AAGvB,EAAA,IAAI,aAAA,CAAc,SAAA,CAAU,QAAA,EAAU,QAAQ,GAAG,OAAO,OAAA;AAGxD,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,UAAA,CAAW,QAAQ,CAAA;AAChD,EAAA,IAAI,gBAAgB,OAAO,cAAA;AAG3B,EAAA,OAAO,gBAAA,CAAiB,QAAQ,CAAA,IAAK,KAAA;AACvC","file":"chunk-UOFNLVKF.js","sourcesContent":["/**\n * Mastracode tool name constants.\n *\n * These are the names exposed to the LLM via workspace tool name remapping.\n * Used throughout mastracode for permissions, TUI rendering, tool guidance,\n * subagent allowedTools, etc.\n *\n * The workspace tools get remapped from their core names (e.g. `mastra_workspace_read_file`)\n * to these names (e.g. `view`) via the `name` property in workspace tool config.\n */\n\nimport { WORKSPACE_TOOLS } from '@mastra/core/workspace';\n\nexport const MC_TOOLS = {\n // Filesystem\n VIEW: 'view',\n WRITE_FILE: 'write_file',\n STRING_REPLACE_LSP: 'string_replace_lsp',\n FIND_FILES: 'find_files',\n DELETE_FILE: 'delete_file',\n FILE_STAT: 'file_stat',\n MKDIR: 'mkdir',\n\n // Search\n SEARCH_CONTENT: 'search_content',\n\n // Code intelligence\n AST_SMART_EDIT: 'ast_smart_edit',\n\n // Sandbox\n EXECUTE_COMMAND: 'execute_command',\n GET_PROCESS_OUTPUT: 'get_process_output',\n KILL_PROCESS: 'kill_process',\n\n // Code intelligence\n LSP_INSPECT: 'lsp_inspect',\n\n // Notifications\n NOTIFICATION_INBOX: 'notification_inbox',\n} as const;\n\n/**\n * Workspace tool name remapping config.\n * Maps core workspace tool constants to mastracode's tool names.\n * Pass this (or spread it) into `Workspace({ tools: ... })`.\n */\nexport const TOOL_NAME_OVERRIDES = {\n [WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]: { name: MC_TOOLS.VIEW },\n [WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE]: { name: MC_TOOLS.WRITE_FILE },\n [WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE]: { name: MC_TOOLS.STRING_REPLACE_LSP },\n [WORKSPACE_TOOLS.FILESYSTEM.LIST_FILES]: { name: MC_TOOLS.FIND_FILES },\n [WORKSPACE_TOOLS.FILESYSTEM.DELETE]: { name: MC_TOOLS.DELETE_FILE },\n [WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT]: { name: MC_TOOLS.FILE_STAT },\n [WORKSPACE_TOOLS.FILESYSTEM.MKDIR]: { name: MC_TOOLS.MKDIR },\n [WORKSPACE_TOOLS.FILESYSTEM.GREP]: { name: MC_TOOLS.SEARCH_CONTENT },\n [WORKSPACE_TOOLS.FILESYSTEM.AST_EDIT]: { name: MC_TOOLS.AST_SMART_EDIT },\n [WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND]: { name: MC_TOOLS.EXECUTE_COMMAND },\n [WORKSPACE_TOOLS.SANDBOX.GET_PROCESS_OUTPUT]: { name: MC_TOOLS.GET_PROCESS_OUTPUT },\n [WORKSPACE_TOOLS.SANDBOX.KILL_PROCESS]: { name: MC_TOOLS.KILL_PROCESS },\n [WORKSPACE_TOOLS.LSP.LSP_INSPECT]: { name: MC_TOOLS.LSP_INSPECT },\n} as const;\n","/**\n * Granular tool permission system.\n *\n * Tools are classified into categories by risk level.\n * Each category has a configurable policy: \"allow\", \"ask\", or \"deny\".\n * Session-scoped grants let the user approve a category once per session.\n */\n\nimport { MC_TOOLS } from './tool-names.js';\n\n// ---------------------------------------------------------------------------\n// Categories\n// ---------------------------------------------------------------------------\n\nexport type ToolCategory = 'read' | 'edit' | 'execute' | 'mcp';\n\nexport const TOOL_CATEGORIES: Record<ToolCategory, { label: string; description: string }> = {\n read: {\n label: 'Read',\n description: 'Read files, search, list directories',\n },\n edit: {\n label: 'Edit',\n description: 'Create, modify, or delete files',\n },\n execute: {\n label: 'Execute',\n description: 'Run shell commands',\n },\n mcp: {\n label: 'MCP',\n description: 'External MCP server tools',\n },\n};\n\n// ---------------------------------------------------------------------------\n// Tool → Category mapping\n// ---------------------------------------------------------------------------\n\nconst TOOL_CATEGORY_MAP: Record<string, ToolCategory> = {\n // Read-only tools — always safe\n [MC_TOOLS.VIEW]: 'read',\n [MC_TOOLS.SEARCH_CONTENT]: 'read',\n [MC_TOOLS.FIND_FILES]: 'read',\n [MC_TOOLS.LSP_INSPECT]: 'read',\n web_search: 'read',\n 'web-search': 'read',\n web_extract: 'read',\n 'web-extract': 'read',\n // Edit tools — mutate local project or session state\n [MC_TOOLS.NOTIFICATION_INBOX]: 'edit',\n // Edit tools — modify files\n [MC_TOOLS.STRING_REPLACE_LSP]: 'edit',\n [MC_TOOLS.AST_SMART_EDIT]: 'edit',\n [MC_TOOLS.WRITE_FILE]: 'edit',\n subagent: 'edit',\n\n // Execute tools — run arbitrary commands\n [MC_TOOLS.EXECUTE_COMMAND]: 'execute',\n\n // Interactive / planning tools — always allowed (no category needed)\n // ask_user, task_write, task_update, task_complete, task_check, submit_plan, request_access\n};\n\n// Tools that never need approval regardless of policy\nconst ALWAYS_ALLOW_TOOLS = new Set([\n 'ask_user',\n 'task_write',\n 'task_update',\n 'task_complete',\n 'task_check',\n 'submit_plan',\n 'request_access',\n]);\n\n/**\n * Get the category for a tool, or null if the tool is always-allowed.\n */\nexport function getToolCategory(toolName: string): ToolCategory | null {\n if (ALWAYS_ALLOW_TOOLS.has(toolName)) return null;\n return TOOL_CATEGORY_MAP[toolName] ?? 'mcp';\n}\n\n/**\n * Get the list of known tools for a given category.\n */\nexport function getToolsForCategory(category: ToolCategory): string[] {\n return Object.entries(TOOL_CATEGORY_MAP)\n .filter(([, cat]) => cat === category)\n .map(([tool]) => tool);\n}\n\n// ---------------------------------------------------------------------------\n// Policies\n// ---------------------------------------------------------------------------\n\nexport type PermissionPolicy = 'allow' | 'ask' | 'deny';\n\nexport interface PermissionRules {\n /** Policy per category. Missing categories default to their DEFAULT_POLICIES value. */\n categories: Partial<Record<ToolCategory, PermissionPolicy>>;\n /** Per-tool overrides. Tool name → policy. Takes precedence over category. */\n tools: Record<string, PermissionPolicy>;\n}\n\n/** Default policies when no rules are configured (YOLO=false equivalent). */\nexport const DEFAULT_POLICIES: Record<ToolCategory, PermissionPolicy> = {\n read: 'allow',\n edit: 'ask',\n execute: 'ask',\n mcp: 'ask',\n};\n\n/** YOLO-mode policies — everything auto-allowed. */\nexport const YOLO_POLICIES: Record<ToolCategory, PermissionPolicy> = {\n read: 'allow',\n edit: 'allow',\n execute: 'allow',\n mcp: 'allow',\n};\n\nexport function createDefaultRules(): PermissionRules {\n return {\n categories: { ...DEFAULT_POLICIES },\n tools: {},\n };\n}\n\n// ---------------------------------------------------------------------------\n// Session grants — temporary \"always allow\" for this session\n// ---------------------------------------------------------------------------\n\nexport class SessionGrants {\n private grantedCategories = new Set<ToolCategory>();\n private grantedTools = new Set<string>();\n\n allowCategory(category: ToolCategory): void {\n this.grantedCategories.add(category);\n }\n\n allowTool(toolName: string): void {\n this.grantedTools.add(toolName);\n }\n\n isGranted(toolName: string, category: ToolCategory): boolean {\n return this.grantedTools.has(toolName) || this.grantedCategories.has(category);\n }\n\n reset(): void {\n this.grantedCategories.clear();\n this.grantedTools.clear();\n }\n\n getGrantedCategories(): ToolCategory[] {\n return [...this.grantedCategories];\n }\n\n getGrantedTools(): string[] {\n return [...this.grantedTools];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Decision engine\n// ---------------------------------------------------------------------------\n\nexport type ApprovalDecision = 'allow' | 'ask' | 'deny';\n\n/**\n * Determine whether a tool call should be allowed, prompted, or denied.\n *\n * Priority order:\n * 1. Always-allowed tools (ask_user, task_write, etc.) → allow\n * 2. Per-tool policy override → use that policy\n * 3. Session grants (user said \"always allow\" during this session) → allow\n * 4. Category policy → use that policy\n * 5. Fallback → \"ask\"\n */\nexport function resolveApproval(\n toolName: string,\n rules: PermissionRules,\n sessionGrants: SessionGrants,\n): ApprovalDecision {\n // 1. Always-allowed tools\n const category = getToolCategory(toolName);\n if (category === null) return 'allow';\n\n // 2. Per-tool override\n const toolPolicy = rules.tools[toolName];\n if (toolPolicy) return toolPolicy;\n\n // 3. Session grants\n if (sessionGrants.isGranted(toolName, category)) return 'allow';\n\n // 4. Category policy\n const categoryPolicy = rules.categories[category];\n if (categoryPolicy) return categoryPolicy;\n\n // 5. Default policy for category\n return DEFAULT_POLICIES[category] ?? 'ask';\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { setAuthStorage, setAuthStorage3, setAuthStorage2, loadSettings, MEMORY_GATEWAY_PROVIDER, getDynamicModel, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, releaseThreadLock, acquireThreadLock, getCustomProviderId, toCustomProviderModelId, getCopilotModelCatalog, saveSettings,
|
|
1
|
+
import { setAuthStorage, setAuthStorage3, setAuthStorage2, loadSettings, MEMORY_GATEWAY_PROVIDER, GithubSignals, getDynamicModel, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, resolveModel, releaseThreadLock, acquireThreadLock, getCustomProviderId, toCustomProviderModelId, getCopilotModelCatalog, saveSettings, mastra, OBSERVABILITY_AUTH_PREFIX } from './chunk-7ZTY5SBK.js';
|
|
2
2
|
import { DEFAULT_OM_MODEL_ID, DEFAULT_CONFIG_DIR, AuthStorage, validateConfigDirName, detectProject, getResourceIdOverride, getStorageConfig, getObservabilityDatabasePath, getVectorDatabasePath, getCurrentGitBranchAsync, getOmScope, DEFAULT_REF_THRESHOLD, DEFAULT_OBS_THRESHOLD, getDatabasePath, getAppDataDir } from './chunk-5FT2NNFO.js';
|
|
3
|
-
import { MC_TOOLS, getToolCategory, TOOL_NAME_OVERRIDES } from './chunk-
|
|
3
|
+
import { MC_TOOLS, getToolCategory, TOOL_NAME_OVERRIDES } from './chunk-UOFNLVKF.js';
|
|
4
4
|
import { createHash } from 'crypto';
|
|
5
5
|
import * as os from 'os';
|
|
6
6
|
import os__default, { hostname, homedir } from 'os';
|
|
@@ -10,6 +10,7 @@ import { Agent } from '@mastra/core/agent';
|
|
|
10
10
|
import { Harness } from '@mastra/core/harness/v1';
|
|
11
11
|
import { GatewayRegistry, PROVIDER_REGISTRY } from '@mastra/core/llm';
|
|
12
12
|
import { StreamErrorRetryProcessor, PrefillErrorHandler, ProviderHistoryCompat, AgentsMDInjector } from '@mastra/core/processors';
|
|
13
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
13
14
|
import { InMemoryHarness, MastraCompositeStore } from '@mastra/core/storage';
|
|
14
15
|
import { DuckDBStore } from '@mastra/duckdb';
|
|
15
16
|
import { Observability, SensitiveDataFilter, MastraStorageExporter, MastraPlatformExporter } from '@mastra/observability';
|
|
@@ -26,6 +27,7 @@ import { fastembed } from '@mastra/fastembed';
|
|
|
26
27
|
import { Memory } from '@mastra/memory';
|
|
27
28
|
import { createAnthropic } from '@ai-sdk/anthropic';
|
|
28
29
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
30
|
+
import { createNotificationInboxTool, NotificationsStorage } from '@mastra/core/notifications';
|
|
29
31
|
import { createScorer, filterRun } from '@mastra/core/evals';
|
|
30
32
|
import { Harness as Harness$1 } from '@mastra/core/harness';
|
|
31
33
|
import { MCPClient, MCPOAuthClientProvider } from '@mastra/mcp';
|
|
@@ -849,6 +851,14 @@ You have access to the following tools. Use the RIGHT tool for the job:`);
|
|
|
849
851
|
- Example: \`{ path: "/abs/path/src/foo.ts", line: 10, match: "const foo = <<<bar()" }\` \u2014 inspect the symbol at the \`<<<\` position.
|
|
850
852
|
- Use \`${MC_TOOLS.VIEW}\` when you need to read the implementation or surrounding code.
|
|
851
853
|
- Use \`${MC_TOOLS.SEARCH_CONTENT}\` or \`${MC_TOOLS.FIND_FILES}\` first if you do not yet know where the symbol is.`);
|
|
854
|
+
}
|
|
855
|
+
if (!denied.has(MC_TOOLS.NOTIFICATION_INBOX)) {
|
|
856
|
+
readTools.push(`
|
|
857
|
+
**${MC_TOOLS.NOTIFICATION_INBOX}** \u2014 Inspect and manage notification inbox records
|
|
858
|
+
- Use this when a \`<notification-summary>\` says pending notifications exist.
|
|
859
|
+
- Use \`{ "action": "list", "status": "pending" }\` or \`{ "action": "search", "query": "..." }\` to find notification records for the current thread.
|
|
860
|
+
- Use \`read\` to deliver unread notification signals into the chat and mark them seen; the tool result summarizes the count instead of exposing notification contents.
|
|
861
|
+
- Use \`dismiss\` or \`archive\` only when the user asks or the notification is no longer relevant.`);
|
|
852
862
|
}
|
|
853
863
|
if (readTools.length > 0) {
|
|
854
864
|
sections.push(readTools.join("\n"));
|
|
@@ -1020,7 +1030,7 @@ ${lines.join("\n")}
|
|
|
1020
1030
|
// src/agents/instructions.ts
|
|
1021
1031
|
async function getDynamicInstructions({ requestContext }) {
|
|
1022
1032
|
const harnessContext = requestContext.get("harness");
|
|
1023
|
-
const state = harnessContext?.
|
|
1033
|
+
const state = harnessContext?.getState?.();
|
|
1024
1034
|
const modeId = harnessContext?.modeId ?? "build";
|
|
1025
1035
|
const projectPath = state?.projectPath ?? process.cwd();
|
|
1026
1036
|
const promptCtx = {
|
|
@@ -1305,6 +1315,38 @@ async function restoreOMThreadStateForCurrentThread(harness) {
|
|
|
1305
1315
|
if (!threadId) return;
|
|
1306
1316
|
await restoreSettingsForThread(harness, threadId);
|
|
1307
1317
|
}
|
|
1318
|
+
var LazyNotificationsStorage = class extends NotificationsStorage {
|
|
1319
|
+
constructor(storage) {
|
|
1320
|
+
super();
|
|
1321
|
+
this.storage = storage;
|
|
1322
|
+
}
|
|
1323
|
+
storage;
|
|
1324
|
+
async getNotificationsStorage() {
|
|
1325
|
+
const notifications = await this.storage.getStore("notifications");
|
|
1326
|
+
if (!notifications) {
|
|
1327
|
+
throw new Error("notification_inbox requires a notifications storage domain");
|
|
1328
|
+
}
|
|
1329
|
+
return notifications;
|
|
1330
|
+
}
|
|
1331
|
+
async createNotification(input) {
|
|
1332
|
+
return (await this.getNotificationsStorage()).createNotification(input);
|
|
1333
|
+
}
|
|
1334
|
+
async listNotifications(input) {
|
|
1335
|
+
return (await this.getNotificationsStorage()).listNotifications(input);
|
|
1336
|
+
}
|
|
1337
|
+
async listDueNotifications(input) {
|
|
1338
|
+
return (await this.getNotificationsStorage()).listDueNotifications(input);
|
|
1339
|
+
}
|
|
1340
|
+
async getNotification(input) {
|
|
1341
|
+
return (await this.getNotificationsStorage()).getNotification(input);
|
|
1342
|
+
}
|
|
1343
|
+
async updateNotification(input) {
|
|
1344
|
+
return (await this.getNotificationsStorage()).updateNotification(input);
|
|
1345
|
+
}
|
|
1346
|
+
async dangerouslyClearAll() {
|
|
1347
|
+
return (await this.getNotificationsStorage()).dangerouslyClearAll();
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1308
1350
|
function wrapToolWithHooks(toolName, tool, hookManager) {
|
|
1309
1351
|
if (!hookManager || typeof tool?.execute !== "function") {
|
|
1310
1352
|
return tool;
|
|
@@ -1335,16 +1377,21 @@ function wrapToolWithHooks(toolName, tool, hookManager) {
|
|
|
1335
1377
|
}
|
|
1336
1378
|
};
|
|
1337
1379
|
}
|
|
1338
|
-
function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools) {
|
|
1380
|
+
function createDynamicTools(mcpManager, extraTools, hookManager, disabledTools, storage) {
|
|
1339
1381
|
return function getDynamicTools({ requestContext }) {
|
|
1340
1382
|
const ctx = requestContext.get("harness");
|
|
1341
|
-
const state = ctx?.getState();
|
|
1383
|
+
const state = ctx?.getState?.();
|
|
1342
1384
|
const modelId = state?.currentModelId;
|
|
1343
1385
|
const isAnthropicModel = modelId?.startsWith("anthropic/");
|
|
1344
1386
|
const isOpenAIModel = modelId?.startsWith("openai/");
|
|
1345
1387
|
const tools = {
|
|
1346
1388
|
request_access: requestSandboxAccessTool
|
|
1347
1389
|
};
|
|
1390
|
+
if (storage) {
|
|
1391
|
+
tools[MC_TOOLS.NOTIFICATION_INBOX] = createNotificationInboxTool({
|
|
1392
|
+
storage: new LazyNotificationsStorage(storage)
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1348
1395
|
if (hasTavilyKey()) {
|
|
1349
1396
|
tools.web_search = createWebSearchTool();
|
|
1350
1397
|
tools.web_extract = createWebExtractTool();
|
|
@@ -1914,15 +1961,62 @@ var HarnessCompat = class extends Harness$1 {
|
|
|
1914
1961
|
super(args);
|
|
1915
1962
|
this.#harnessV1 = harnessV1;
|
|
1916
1963
|
}
|
|
1964
|
+
getState() {
|
|
1965
|
+
const state = super.getState();
|
|
1966
|
+
let session;
|
|
1967
|
+
try {
|
|
1968
|
+
session = this.#session;
|
|
1969
|
+
} catch {
|
|
1970
|
+
session = void 0;
|
|
1971
|
+
}
|
|
1972
|
+
if (!session) {
|
|
1973
|
+
return state;
|
|
1974
|
+
}
|
|
1975
|
+
return {
|
|
1976
|
+
...state,
|
|
1977
|
+
...session.getState(),
|
|
1978
|
+
currentModelId: session.getModelId(),
|
|
1979
|
+
modeId: session.getMode().id
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
async setState(updates) {
|
|
1983
|
+
const { currentModelId, modeId, ...harnessUpdates } = updates;
|
|
1984
|
+
let session;
|
|
1985
|
+
try {
|
|
1986
|
+
session = this.#session;
|
|
1987
|
+
} catch {
|
|
1988
|
+
session = void 0;
|
|
1989
|
+
}
|
|
1990
|
+
if (session) {
|
|
1991
|
+
if (typeof currentModelId === "string") {
|
|
1992
|
+
session.setModelId(currentModelId);
|
|
1993
|
+
}
|
|
1994
|
+
if (typeof modeId === "string" && modeId !== session.getMode().id) {
|
|
1995
|
+
await this.switchMode({ modeId });
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
if (Object.keys(harnessUpdates).length > 0) {
|
|
1999
|
+
if (session) {
|
|
2000
|
+
await session.setState(harnessUpdates);
|
|
2001
|
+
}
|
|
2002
|
+
await super.setState(harnessUpdates);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
getSubagentModelId({ agentType } = {}) {
|
|
2006
|
+
return super.getSubagentModelId({ agentType });
|
|
2007
|
+
}
|
|
2008
|
+
async setSubagentModelId({ modelId, agentType }) {
|
|
2009
|
+
await super.setSubagentModelId({ modelId, agentType });
|
|
2010
|
+
}
|
|
1917
2011
|
async switchThread({ threadId }) {
|
|
1918
|
-
const
|
|
1919
|
-
|
|
2012
|
+
const currentModelId = this.getState().currentModelId;
|
|
2013
|
+
const session = await this.#harnessV1.session({
|
|
1920
2014
|
threadId,
|
|
1921
2015
|
resourceId: this.getResourceId()
|
|
1922
2016
|
});
|
|
1923
|
-
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
2017
|
+
this.#session = session;
|
|
2018
|
+
if (typeof currentModelId === "string" && currentModelId.length > 0) {
|
|
2019
|
+
session.setModelId(currentModelId);
|
|
1926
2020
|
}
|
|
1927
2021
|
await super.switchThread({ threadId });
|
|
1928
2022
|
}
|
|
@@ -2017,12 +2111,24 @@ var HarnessCompat = class extends Harness$1 {
|
|
|
2017
2111
|
if (!mode) {
|
|
2018
2112
|
throw new Error(`Mode not found: ${modeId}`);
|
|
2019
2113
|
}
|
|
2020
|
-
if (
|
|
2021
|
-
|
|
2114
|
+
if (this.#session) {
|
|
2115
|
+
this.#session.setMode(mode);
|
|
2022
2116
|
}
|
|
2023
|
-
this.#session.setMode(mode);
|
|
2024
2117
|
await super.switchMode({ modeId });
|
|
2025
2118
|
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Activate a skill on the current v1 session.
|
|
2121
|
+
*
|
|
2122
|
+
* Pass-through to `Session.useSkill` — returns the resolved instructions
|
|
2123
|
+
* string, or throws `HarnessSkillNotFoundError` if the skill is missing.
|
|
2124
|
+
* Throws if there is no active session.
|
|
2125
|
+
*/
|
|
2126
|
+
async useSkill(name, opts) {
|
|
2127
|
+
if (!this.#session) {
|
|
2128
|
+
throw new Error("No active session to use skill");
|
|
2129
|
+
}
|
|
2130
|
+
return this.#session.useSkill(name, opts);
|
|
2131
|
+
}
|
|
2026
2132
|
};
|
|
2027
2133
|
var VALID_EVENTS = [
|
|
2028
2134
|
"PreToolUse",
|
|
@@ -2867,15 +2973,12 @@ function createMcpManager(projectDir, configDirName = DEFAULT_CONFIG_DIR, extraS
|
|
|
2867
2973
|
};
|
|
2868
2974
|
}
|
|
2869
2975
|
var stateSchema = z.object({
|
|
2976
|
+
subagentModelId: z.string().optional(),
|
|
2870
2977
|
projectPath: z.string().optional(),
|
|
2871
2978
|
projectName: z.string().optional(),
|
|
2872
2979
|
configDir: z.string().default(DEFAULT_CONFIG_DIR),
|
|
2873
2980
|
gitBranch: z.string().optional(),
|
|
2874
2981
|
lastCommand: z.string().optional(),
|
|
2875
|
-
currentModelId: z.string().default(""),
|
|
2876
|
-
// Subagent model settings (per-thread/per-mode)
|
|
2877
|
-
subagentModelId: z.string().optional(),
|
|
2878
|
-
// Thread-level default for subagents
|
|
2879
2982
|
// Observational Memory model settings
|
|
2880
2983
|
observerModelId: z.string().default(DEFAULT_OM_MODEL_ID),
|
|
2881
2984
|
reflectorModelId: z.string().default(DEFAULT_OM_MODEL_ID),
|
|
@@ -3287,7 +3390,7 @@ async function createMastraCode(config) {
|
|
|
3287
3390
|
// Environment & project:
|
|
3288
3391
|
// state.projectName, state.gitBranch
|
|
3289
3392
|
// Model configuration:
|
|
3290
|
-
// state.currentModelId
|
|
3393
|
+
// state.currentModelId
|
|
3291
3394
|
// Agent settings:
|
|
3292
3395
|
// state.yolo, state.thinkingLevel, state.smartEditing
|
|
3293
3396
|
// Observational memory settings:
|
|
@@ -3304,7 +3407,6 @@ async function createMastraCode(config) {
|
|
|
3304
3407
|
"harness.state.gitBranch",
|
|
3305
3408
|
// Model configuration
|
|
3306
3409
|
"harness.state.currentModelId",
|
|
3307
|
-
"harness.state.subagentModelId",
|
|
3308
3410
|
// Agent settings
|
|
3309
3411
|
"harness.state.yolo",
|
|
3310
3412
|
"harness.state.thinkingLevel",
|
|
@@ -3330,12 +3432,13 @@ async function createMastraCode(config) {
|
|
|
3330
3432
|
const hookManager = config?.disableHooks ? void 0 : new HookManager(project.rootPath, "session-init", configDir);
|
|
3331
3433
|
const outcomeScorer = createOutcomeScorer();
|
|
3332
3434
|
const efficiencyScorer = createEfficiencyScorer();
|
|
3435
|
+
const githubSignalsProcessor = globalSettings.signals?.experimentalGithubSignals ? new GithubSignals({ cwd: project.rootPath }) : void 0;
|
|
3333
3436
|
const codeAgent = new Agent({
|
|
3334
3437
|
id: CODE_AGENT_ID,
|
|
3335
3438
|
name: "Code Agent",
|
|
3336
3439
|
instructions: getDynamicInstructions,
|
|
3337
3440
|
model: getDynamicModel,
|
|
3338
|
-
tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools),
|
|
3441
|
+
tools: createDynamicTools(mcpManager, config?.extraTools, hookManager, config?.disabledTools, storage),
|
|
3339
3442
|
scorers: {
|
|
3340
3443
|
outcome: {
|
|
3341
3444
|
scorer: outcomeScorer,
|
|
@@ -3354,10 +3457,38 @@ async function createMastraCode(config) {
|
|
|
3354
3457
|
return getStaticallyLoadedInstructionPaths(projectPath);
|
|
3355
3458
|
}
|
|
3356
3459
|
}),
|
|
3460
|
+
...githubSignalsProcessor ? [githubSignalsProcessor] : [],
|
|
3357
3461
|
new ProviderHistoryCompat()
|
|
3358
3462
|
],
|
|
3359
3463
|
errorProcessors: [new StreamErrorRetryProcessor(), new PrefillErrorHandler(), new ProviderHistoryCompat()]
|
|
3360
3464
|
});
|
|
3465
|
+
githubSignalsProcessor?.addAgent(codeAgent, {
|
|
3466
|
+
getNotificationStreamOptions: ({ resourceId, threadId }) => {
|
|
3467
|
+
const requestContext = new RequestContext();
|
|
3468
|
+
const harnessContext = {
|
|
3469
|
+
harnessId: harness.id,
|
|
3470
|
+
state: harness.getState(),
|
|
3471
|
+
getState: () => harness.getState(),
|
|
3472
|
+
setState: (updates) => harness.setState(updates),
|
|
3473
|
+
threadId,
|
|
3474
|
+
resourceId,
|
|
3475
|
+
modeId: harness.getCurrentModeId(),
|
|
3476
|
+
workspace: harness.getWorkspace(),
|
|
3477
|
+
registerQuestion: (params) => harness.registerQuestion(params),
|
|
3478
|
+
registerPlanApproval: (params) => harness.registerPlanApproval(params),
|
|
3479
|
+
getSubagentModelId: (params) => harness.getSubagentModelId(params)
|
|
3480
|
+
};
|
|
3481
|
+
requestContext.set("harness", harnessContext);
|
|
3482
|
+
return {
|
|
3483
|
+
memory: { thread: threadId, resource: resourceId },
|
|
3484
|
+
requestContext,
|
|
3485
|
+
maxSteps: 1e3,
|
|
3486
|
+
savePerStep: false,
|
|
3487
|
+
requireToolApproval: harness.getState().yolo !== true,
|
|
3488
|
+
modelSettings: { temperature: 1 }
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3361
3492
|
const defaultSubagents = [exploreSubagent, planSubagent, executeSubagent];
|
|
3362
3493
|
const defaultModesV1 = [
|
|
3363
3494
|
{
|
|
@@ -3397,6 +3528,7 @@ async function createMastraCode(config) {
|
|
|
3397
3528
|
handler: () => syncGateways()
|
|
3398
3529
|
}
|
|
3399
3530
|
];
|
|
3531
|
+
const heartbeatHandlers = config?.heartbeatHandlers ?? defaultHeartbeatHandlers;
|
|
3400
3532
|
const anthropicCred = authStorage.get("anthropic");
|
|
3401
3533
|
const openaiCred = authStorage.get("openai-codex");
|
|
3402
3534
|
const githubCopilotCred = authStorage.get("github-copilot");
|
|
@@ -3524,15 +3656,32 @@ async function createMastraCode(config) {
|
|
|
3524
3656
|
});
|
|
3525
3657
|
})
|
|
3526
3658
|
);
|
|
3659
|
+
const typedStateSchema = stateSchema;
|
|
3660
|
+
const initialState = {
|
|
3661
|
+
projectPath: project.rootPath,
|
|
3662
|
+
projectName: project.name,
|
|
3663
|
+
gitBranch: project.gitBranch,
|
|
3664
|
+
yolo: true,
|
|
3665
|
+
...globalInitialState,
|
|
3666
|
+
...config?.initialState,
|
|
3667
|
+
// configDir must always win over initialState spreads to stay in sync
|
|
3668
|
+
// with MCP/hooks/storage which were already initialized with this value.
|
|
3669
|
+
configDir
|
|
3670
|
+
};
|
|
3671
|
+
const workspace = config?.workspace ?? getDynamicWorkspace;
|
|
3527
3672
|
const harnessV1 = new Harness({
|
|
3528
3673
|
ownerId,
|
|
3529
3674
|
agents: { [CODE_AGENT_ID]: codeAgent },
|
|
3530
3675
|
memory,
|
|
3531
3676
|
modes: modesV1,
|
|
3532
3677
|
defaultModeId,
|
|
3533
|
-
storage: harnessStorage
|
|
3678
|
+
storage: harnessStorage,
|
|
3679
|
+
stateSchema: typedStateSchema,
|
|
3680
|
+
initialState,
|
|
3681
|
+
workspace,
|
|
3682
|
+
resolveModel: (modelId) => resolveModel(modelId),
|
|
3683
|
+
toolCategoryResolver: (name) => getToolCategory(name) ?? null
|
|
3534
3684
|
});
|
|
3535
|
-
const typedStateSchema = stateSchema;
|
|
3536
3685
|
const harness = new HarnessCompat(
|
|
3537
3686
|
{
|
|
3538
3687
|
id: "mastra-code",
|
|
@@ -3545,21 +3694,11 @@ async function createMastraCode(config) {
|
|
|
3545
3694
|
subagents,
|
|
3546
3695
|
resolveModel: (modelId) => resolveModel(modelId),
|
|
3547
3696
|
toolCategoryResolver: getToolCategory,
|
|
3548
|
-
initialState
|
|
3549
|
-
|
|
3550
|
-
projectName: project.name,
|
|
3551
|
-
gitBranch: project.gitBranch,
|
|
3552
|
-
yolo: true,
|
|
3553
|
-
...globalInitialState,
|
|
3554
|
-
...config?.initialState,
|
|
3555
|
-
// configDir must always win over initialState spreads to stay in sync
|
|
3556
|
-
// with MCP/hooks/storage which were already initialized with this value.
|
|
3557
|
-
configDir
|
|
3558
|
-
},
|
|
3559
|
-
workspace: config?.workspace ?? getDynamicWorkspace,
|
|
3697
|
+
initialState,
|
|
3698
|
+
workspace,
|
|
3560
3699
|
browser: config?.browser,
|
|
3561
3700
|
modes,
|
|
3562
|
-
heartbeatHandlers
|
|
3701
|
+
heartbeatHandlers,
|
|
3563
3702
|
modelAuthChecker: (provider) => {
|
|
3564
3703
|
const gatewayKey = authStorage.getStoredApiKey(MEMORY_GATEWAY_PROVIDER) ?? process.env["MASTRA_GATEWAY_API_KEY"];
|
|
3565
3704
|
if (gatewayKey) {
|
|
@@ -3650,6 +3789,30 @@ async function createMastraCode(config) {
|
|
|
3650
3789
|
}
|
|
3651
3790
|
});
|
|
3652
3791
|
}
|
|
3792
|
+
if (githubSignalsProcessor) {
|
|
3793
|
+
const startGithubPollingForCurrentThread = async (threadId) => {
|
|
3794
|
+
if (!threadId) return;
|
|
3795
|
+
githubSignalsProcessor.stopAllPolling();
|
|
3796
|
+
try {
|
|
3797
|
+
const threads2 = await harness.listThreads({ allResources: true });
|
|
3798
|
+
const thread = threads2.find((item) => item.id === threadId);
|
|
3799
|
+
await githubSignalsProcessor.startPollingForThread(
|
|
3800
|
+
{
|
|
3801
|
+
threadId,
|
|
3802
|
+
resourceId: thread?.resourceId ?? harness.getResourceId()
|
|
3803
|
+
},
|
|
3804
|
+
{ pollImmediately: true }
|
|
3805
|
+
);
|
|
3806
|
+
} catch (error) {
|
|
3807
|
+
console.warn("Failed to start GitHub PR polling:", error);
|
|
3808
|
+
}
|
|
3809
|
+
};
|
|
3810
|
+
harness.subscribe((event) => {
|
|
3811
|
+
if (event.type === "thread_changed") void startGithubPollingForCurrentThread(event.threadId);
|
|
3812
|
+
else if (event.type === "thread_created") void startGithubPollingForCurrentThread(event.thread.id);
|
|
3813
|
+
});
|
|
3814
|
+
void startGithubPollingForCurrentThread(harness.getCurrentThreadId());
|
|
3815
|
+
}
|
|
3653
3816
|
const omThreadStateHarness = harness;
|
|
3654
3817
|
attachOMThreadStatePersistence(omThreadStateHarness);
|
|
3655
3818
|
await restoreOMThreadStateForCurrentThread(omThreadStateHarness).catch(() => {
|
|
@@ -3665,10 +3828,11 @@ async function createMastraCode(config) {
|
|
|
3665
3828
|
observabilityWarning,
|
|
3666
3829
|
builtinPacks,
|
|
3667
3830
|
builtinOmPacks,
|
|
3668
|
-
effectiveDefaults
|
|
3831
|
+
effectiveDefaults,
|
|
3832
|
+
githubSignals: githubSignalsProcessor
|
|
3669
3833
|
};
|
|
3670
3834
|
}
|
|
3671
3835
|
|
|
3672
3836
|
export { createAuthStorage, createMastraCode };
|
|
3673
|
-
//# sourceMappingURL=chunk-
|
|
3674
|
-
//# sourceMappingURL=chunk-
|
|
3837
|
+
//# sourceMappingURL=chunk-Y5AUV6T3.js.map
|
|
3838
|
+
//# sourceMappingURL=chunk-Y5AUV6T3.js.map
|