@4onstudios/iris-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +690 -0
- package/dist/api/acp/acpServer.d.ts +23 -0
- package/dist/api/acp/acpServer.js +814 -0
- package/dist/api/acp/index.d.ts +2 -0
- package/dist/api/acp/index.js +2 -0
- package/dist/api/acp/irisClient.d.ts +58 -0
- package/dist/api/acp/irisClient.js +214 -0
- package/dist/api/agent.d.ts +14 -0
- package/dist/api/agent.js +4171 -0
- package/dist/api/backendService.d.ts +4 -0
- package/dist/api/backendService.js +14 -0
- package/dist/api/core/agent/host/AgentContract.d.ts +82 -0
- package/dist/api/core/agent/host/AgentContract.js +1 -0
- package/dist/api/core/agent/host/AgentRegistry.d.ts +24 -0
- package/dist/api/core/agent/host/AgentRegistry.js +125 -0
- package/dist/api/core/agent/host/defaultRegistry.d.ts +15 -0
- package/dist/api/core/agent/host/defaultRegistry.js +46 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.d.ts +65 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.js +117 -0
- package/dist/api/core/agent/host/hostSessionManager.d.ts +111 -0
- package/dist/api/core/agent/host/hostSessionManager.js +352 -0
- package/dist/api/core/agent/host/index.d.ts +5 -0
- package/dist/api/core/agent/host/index.js +5 -0
- package/dist/api/core/agent/index.d.ts +87 -0
- package/dist/api/core/agent/index.js +1024 -0
- package/dist/api/core/agent/publicContracts.d.ts +35 -0
- package/dist/api/core/agent/publicContracts.js +103 -0
- package/dist/api/core/agent/tools/applyDiff.d.ts +51 -0
- package/dist/api/core/agent/tools/applyDiff.js +131 -0
- package/dist/api/core/agent/tools/backgroundTasks.d.ts +240 -0
- package/dist/api/core/agent/tools/backgroundTasks.js +313 -0
- package/dist/api/core/agent/tools/createDirectory.d.ts +43 -0
- package/dist/api/core/agent/tools/createDirectory.js +77 -0
- package/dist/api/core/agent/tools/deleteFile.d.ts +37 -0
- package/dist/api/core/agent/tools/deleteFile.js +66 -0
- package/dist/api/core/agent/tools/editFile.d.ts +73 -0
- package/dist/api/core/agent/tools/editFile.js +173 -0
- package/dist/api/core/agent/tools/executeCommand.d.ts +59 -0
- package/dist/api/core/agent/tools/executeCommand.js +250 -0
- package/dist/api/core/agent/tools/fileContent.d.ts +54 -0
- package/dist/api/core/agent/tools/fileContent.js +227 -0
- package/dist/api/core/agent/tools/findDefinition.d.ts +72 -0
- package/dist/api/core/agent/tools/findDefinition.js +109 -0
- package/dist/api/core/agent/tools/findReferences.d.ts +86 -0
- package/dist/api/core/agent/tools/findReferences.js +135 -0
- package/dist/api/core/agent/tools/formatDocument.d.ts +67 -0
- package/dist/api/core/agent/tools/formatDocument.js +90 -0
- package/dist/api/core/agent/tools/getCodeActions.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeActions.js +97 -0
- package/dist/api/core/agent/tools/getCodeCompletion.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeCompletion.js +174 -0
- package/dist/api/core/agent/tools/getCodeContext.d.ts +14 -0
- package/dist/api/core/agent/tools/getCodeContext.js +282 -0
- package/dist/api/core/agent/tools/getSignatureHelp.d.ts +61 -0
- package/dist/api/core/agent/tools/getSignatureHelp.js +85 -0
- package/dist/api/core/agent/tools/getSymbols.d.ts +50 -0
- package/dist/api/core/agent/tools/getSymbols.js +164 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.d.ts +58 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.js +147 -0
- package/dist/api/core/agent/tools/getTypeInfo.d.ts +70 -0
- package/dist/api/core/agent/tools/getTypeInfo.js +84 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.d.ts +80 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.js +281 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.d.ts +53 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.js +97 -0
- package/dist/api/core/agent/tools/grepSearch.d.ts +100 -0
- package/dist/api/core/agent/tools/grepSearch.js +211 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.d.ts +13 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.js +22 -0
- package/dist/api/core/agent/tools/listDirectory.d.ts +66 -0
- package/dist/api/core/agent/tools/listDirectory.js +161 -0
- package/dist/api/core/agent/tools/mcpTools.d.ts +48 -0
- package/dist/api/core/agent/tools/mcpTools.js +442 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.d.ts +120 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.js +306 -0
- package/dist/api/core/agent/tools/readFile.d.ts +92 -0
- package/dist/api/core/agent/tools/readFile.js +337 -0
- package/dist/api/core/agent/tools/renameFile.d.ts +49 -0
- package/dist/api/core/agent/tools/renameFile.js +86 -0
- package/dist/api/core/agent/tools/renameSymbol.d.ts +70 -0
- package/dist/api/core/agent/tools/renameSymbol.js +106 -0
- package/dist/api/core/agent/tools/runTerminalCommand.d.ts +72 -0
- package/dist/api/core/agent/tools/runTerminalCommand.js +69 -0
- package/dist/api/core/agent/tools/searchFiles.d.ts +82 -0
- package/dist/api/core/agent/tools/searchFiles.js +280 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.d.ts +3 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.js +676 -0
- package/dist/api/core/agent/tools/treeTraversal.d.ts +60 -0
- package/dist/api/core/agent/tools/treeTraversal.js +217 -0
- package/dist/api/core/agent/tools/webSearch.d.ts +37 -0
- package/dist/api/core/agent/tools/webSearch.js +80 -0
- package/dist/api/core/agent/tools/writeFile.d.ts +59 -0
- package/dist/api/core/agent/tools/writeFile.js +97 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.d.ts +12 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.js +67 -0
- package/dist/api/core/agent/utils/diffUtils.d.ts +14 -0
- package/dist/api/core/agent/utils/diffUtils.js +39 -0
- package/dist/api/core/agent/utils/environmentSnapshot.d.ts +42 -0
- package/dist/api/core/agent/utils/environmentSnapshot.js +213 -0
- package/dist/api/core/agent/utils/errorRecovery.d.ts +49 -0
- package/dist/api/core/agent/utils/errorRecovery.js +229 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.d.ts +8 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.js +238 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.d.ts +12 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.js +34 -0
- package/dist/api/core/agent/utils/pathRecovery.d.ts +1 -0
- package/dist/api/core/agent/utils/pathRecovery.js +29 -0
- package/dist/api/core/agent/utils/repoMapIndex.d.ts +3 -0
- package/dist/api/core/agent/utils/repoMapIndex.js +197 -0
- package/dist/api/core/agent/utils/skillsDiscovery.d.ts +10 -0
- package/dist/api/core/agent/utils/skillsDiscovery.js +50 -0
- package/dist/api/core/agent/utils/toolCallBudget.d.ts +9 -0
- package/dist/api/core/agent/utils/toolCallBudget.js +55 -0
- package/dist/api/core/agent/utils/toolLifecycle.d.ts +30 -0
- package/dist/api/core/agent/utils/toolLifecycle.js +361 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.d.ts +12 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.js +57 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.d.ts +13 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.js +149 -0
- package/dist/api/core/agent/utils/workspacePathGuard.d.ts +7 -0
- package/dist/api/core/agent/utils/workspacePathGuard.js +79 -0
- package/dist/api/core/containers/chat/toolResultSerialization.d.ts +8 -0
- package/dist/api/core/containers/chat/toolResultSerialization.js +71 -0
- package/dist/api/core/library/BrowserManager.d.ts +11 -0
- package/dist/api/core/library/BrowserManager.js +66 -0
- package/dist/api/core/library/desktopWorkspace.d.ts +1 -0
- package/dist/api/core/library/desktopWorkspace.js +3 -0
- package/dist/api/core/library/extensionManager.d.ts +10 -0
- package/dist/api/core/library/extensionManager.js +27 -0
- package/dist/api/core/library/knowledgeGraph.d.ts +268 -0
- package/dist/api/core/library/knowledgeGraph.js +989 -0
- package/dist/api/core/library/languageModelTools.d.ts +141 -0
- package/dist/api/core/library/languageModelTools.js +207 -0
- package/dist/api/core/library/localRuntime.d.ts +23 -0
- package/dist/api/core/library/localRuntime.js +144 -0
- package/dist/api/core/library/lsp/coreLsp.d.ts +367 -0
- package/dist/api/core/library/lsp/coreLsp.js +2076 -0
- package/dist/api/core/library/lsp/protocol.d.ts +25 -0
- package/dist/api/core/library/lsp/protocol.js +1 -0
- package/dist/api/core/library/lsp/serverManager.d.ts +37 -0
- package/dist/api/core/library/lsp/serverManager.js +427 -0
- package/dist/api/core/library/mcpServerProvider.d.ts +69 -0
- package/dist/api/core/library/mcpServerProvider.js +152 -0
- package/dist/api/core/library/mcpSettings.d.ts +20 -0
- package/dist/api/core/library/mcpSettings.js +131 -0
- package/dist/api/core/library/patternMatcher.d.ts +66 -0
- package/dist/api/core/library/patternMatcher.js +284 -0
- package/dist/api/core/library/regexEscape.d.ts +4 -0
- package/dist/api/core/library/regexEscape.js +4 -0
- package/dist/api/core/library/runtimeEventBus.d.ts +27 -0
- package/dist/api/core/library/runtimeEventBus.js +78 -0
- package/dist/api/core/library/safetyMiddleware.d.ts +98 -0
- package/dist/api/core/library/safetyMiddleware.js +215 -0
- package/dist/api/core/library/tauri.d.ts +71 -0
- package/dist/api/core/library/tauri.js +222 -0
- package/dist/api/core/library/tauriImport.d.ts +5 -0
- package/dist/api/core/library/tauriImport.js +7 -0
- package/dist/api/core/library/terminalAutoApproveSettings.d.ts +32 -0
- package/dist/api/core/library/terminalAutoApproveSettings.js +529 -0
- package/dist/api/core/library/workspaceIdentity.d.ts +10 -0
- package/dist/api/core/library/workspaceIdentity.js +49 -0
- package/dist/api/core/library/workspaceSummary.d.ts +19 -0
- package/dist/api/core/library/workspaceSummary.js +35 -0
- package/dist/api/core/skills/agent-customization/SKILL.md +27 -0
- package/dist/api/core/skills/bug-fix/SKILL.md +21 -0
- package/dist/api/core/skills/create-pr/SKILL.md +32 -0
- package/dist/api/core/skills/dev-server/SKILL.md +20 -0
- package/dist/api/core/skills/fix-suggestions/SKILL.md +21 -0
- package/dist/api/core/skills/github-search/SKILL.md +21 -0
- package/dist/api/core/skills/github-summary/SKILL.md +25 -0
- package/dist/api/core/skills/integration-tests/SKILL.md +29 -0
- package/dist/api/core/skills/pr-comments/SKILL.md +23 -0
- package/dist/api/core/skills/project-setup/SKILL.md +20 -0
- package/dist/api/core/skills/search-integration/SKILL.md +19 -0
- package/dist/api/core/skills/search-results/SKILL.md +19 -0
- package/dist/api/core/skills/typescript-upgrade/SKILL.md +21 -0
- package/dist/api/data/runStore.d.ts +46 -0
- package/dist/api/data/runStore.js +244 -0
- package/dist/api/helpers/agentUtils.d.ts +11 -0
- package/dist/api/helpers/agentUtils.js +23 -0
- package/dist/api/helpers/modelTokenLimits.d.ts +2 -0
- package/dist/api/helpers/modelTokenLimits.js +158 -0
- package/dist/api/helpers/observationalMemory.d.ts +10 -0
- package/dist/api/helpers/observationalMemory.js +36 -0
- package/dist/api/helpers/promptBudget.d.ts +30 -0
- package/dist/api/helpers/promptBudget.js +216 -0
- package/dist/api/helpers/resolveImageMessageParts.d.ts +9 -0
- package/dist/api/helpers/resolveImageMessageParts.js +140 -0
- package/dist/api/helpers/slashCommands.d.ts +31 -0
- package/dist/api/helpers/slashCommands.js +129 -0
- package/dist/api/helpers/tokenUsage.d.ts +19 -0
- package/dist/api/helpers/tokenUsage.js +81 -0
- package/dist/api/routes/fileRoutes.d.ts +2 -0
- package/dist/api/routes/fileRoutes.js +108 -0
- package/dist/api/routes/lspDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspDocumentRoutes.js +84 -0
- package/dist/api/routes/lspHierarchyRoutes.d.ts +4 -0
- package/dist/api/routes/lspHierarchyRoutes.js +122 -0
- package/dist/api/routes/lspPositionRoutes.d.ts +4 -0
- package/dist/api/routes/lspPositionRoutes.js +263 -0
- package/dist/api/routes/lspQueryRoutes.d.ts +4 -0
- package/dist/api/routes/lspQueryRoutes.js +679 -0
- package/dist/api/routes/lspResolveRoutes.d.ts +4 -0
- package/dist/api/routes/lspResolveRoutes.js +143 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.js +98 -0
- package/dist/api/routes/semanticRoutes.d.ts +2 -0
- package/dist/api/routes/semanticRoutes.js +126 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +160 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +38 -0
- package/package.json +100 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-customization
|
|
3
|
+
description: Create, fix, or debug agent customization files — SKILL.md, .instructions.md, .prompt.md, .agent.md, copilot-instructions.md — including frontmatter and trigger issues. Triggers - "create a custom agent/skill", "add agent instructions", "why isn't this skill triggering".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Customization
|
|
7
|
+
|
|
8
|
+
## File types
|
|
9
|
+
|
|
10
|
+
- `SKILL.md` — one skill per directory (`skills/<name>/SKILL.md`); YAML frontmatter requires `name` and `description`.
|
|
11
|
+
- `.instructions.md` — global/always-on instructions.
|
|
12
|
+
- `.prompt.md` — system prompt customizations.
|
|
13
|
+
- `.agent.md` — agent definitions and modes.
|
|
14
|
+
- `copilot-instructions.md` — VS Code Copilot repo config.
|
|
15
|
+
|
|
16
|
+
## Writing effective skills
|
|
17
|
+
|
|
18
|
+
- Only the frontmatter `description` is loaded into the agent prompt; the body is read on demand. Spend effort on the description.
|
|
19
|
+
- Description formula: what it does + trigger phrases + "NOT for X (use Y)" disambiguation from overlapping skills. Keep it to 1-3 sentences on ONE line (multi-line YAML breaks discovery).
|
|
20
|
+
- Body: imperative workflow steps and hard rules only — no capability marketing, no generic best practices.
|
|
21
|
+
|
|
22
|
+
## Debugging "skill not triggering"
|
|
23
|
+
|
|
24
|
+
1. Check frontmatter parses: `name:` and `description:` each on a single line at the top of the file.
|
|
25
|
+
2. Check the directory layout (`skills/<dir>/SKILL.md`) and that the skill isn't disabled in user preferences.
|
|
26
|
+
3. Check the description actually contains the phrases users say — vague descriptions don't match intent.
|
|
27
|
+
4. Check for a duplicate `name` in another skills directory — higher-precedence dirs override.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-fix
|
|
3
|
+
description: Diagnose and FIX a bug end-to-end — reproduce, find root cause, apply the smallest safe code change, verify with tests. Triggers - "fix this bug", "this is broken", "resolve this error", failing test/build. NOT for advisory-only recommendations without editing code (use fix-suggestions).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Bug Fix
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Gather evidence: exact error text, logs, stack trace, failing test.
|
|
11
|
+
2. Reproduce the failure (or isolate a deterministic trigger) BEFORE editing code.
|
|
12
|
+
3. Trace to root cause. Never patch symptoms.
|
|
13
|
+
4. Apply the minimal fix, preserving existing conventions. No refactors, no unrelated changes.
|
|
14
|
+
5. Validate: run the failing test plus directly related tests/lint/build.
|
|
15
|
+
6. Add a regression test when practical.
|
|
16
|
+
7. Report: root cause, change made, verification evidence — briefly.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- If not reproducible, state assumptions and the next diagnostic steps explicitly; do not guess-fix.
|
|
21
|
+
- One bug per fix. If you discover other issues, mention them; don't fix them unasked.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-pr
|
|
3
|
+
description: Create a GitHub pull request from current changes — branch, commit, push, title/description, linked issues, draft or ready. Triggers - "create/open a PR", "submit as pull request", "draft PR". NOT for responding to review feedback on an existing PR (use pr-comments).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Create PR
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Verify state: `git status`, current branch, diff vs default branch. Never open a PR from the default branch — create a feature branch if needed.
|
|
11
|
+
2. Commit and push outstanding changes (confirm with the user before pushing).
|
|
12
|
+
3. Use the repository's PR template if one exists (`.github/PULL_REQUEST_TEMPLATE*`); otherwise use the fallback below.
|
|
13
|
+
4. Title: imperative, ≤72 chars, describes the change not the activity.
|
|
14
|
+
5. Link issues with closing keywords (`Fixes #123`) when applicable.
|
|
15
|
+
6. Create as draft if the user wants early feedback; otherwise ready for review.
|
|
16
|
+
|
|
17
|
+
## Fallback description format
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
## Summary
|
|
21
|
+
What changed and why (2-4 sentences).
|
|
22
|
+
|
|
23
|
+
## Testing
|
|
24
|
+
How the change was verified.
|
|
25
|
+
|
|
26
|
+
Fixes #<issue> (if applicable)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Rules
|
|
30
|
+
|
|
31
|
+
- Keep the PR focused; flag unrelated changes instead of bundling them.
|
|
32
|
+
- Mention screenshots for UI changes.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-server
|
|
3
|
+
description: Start, stop, or troubleshoot local development servers — pick the right script, run as a background process, handle port conflicts, report the URL. Triggers - "start the dev server", "run the app locally", "start frontend and backend", "port already in use".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dev Server
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Find the dev command: check `package.json` scripts (or Makefile / framework config) — never guess.
|
|
11
|
+
2. Check the target port is free; if occupied, identify the process and ask before killing it, or use an alternate port.
|
|
12
|
+
3. Start the server as a long-running background process (never block on it).
|
|
13
|
+
4. Wait for the ready signal in output; report the URL and port.
|
|
14
|
+
5. On startup failure, read the error output and fix the cause — don't blindly restart.
|
|
15
|
+
|
|
16
|
+
## Rules
|
|
17
|
+
|
|
18
|
+
- Multiple services (frontend + backend): start each separately and confirm each is ready.
|
|
19
|
+
- Reuse an already-running healthy server instead of starting a duplicate.
|
|
20
|
+
- Stop servers you started when the user is done with them.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fix-suggestions
|
|
3
|
+
description: RECOMMEND fixes for a code issue without applying them — explain root cause, propose 1-3 options with trade-offs, recommend one. Triggers - "how do I fix", "give me options", "what's the best way to resolve", "why is this failing". NOT for actually implementing the fix (use bug-fix).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fix Suggestions
|
|
7
|
+
|
|
8
|
+
Advisory only: do not edit files unless the user asks you to apply a suggestion.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
1. Read the error/issue and the relevant code for context.
|
|
13
|
+
2. Identify the root cause; state it in one or two sentences.
|
|
14
|
+
3. Propose 1-3 solutions, each with a minimal code example.
|
|
15
|
+
4. Note trade-offs only where options genuinely differ.
|
|
16
|
+
5. Recommend one option with a one-line rationale and how to verify it.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- Prefer one strong solution over padding to three.
|
|
21
|
+
- Ground every suggestion in the actual code — no generic advice.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-search
|
|
3
|
+
description: Build and run GitHub search queries for issues, PRs, code, and repos using qualifier syntax (state, label, author, repo, language, dates). Triggers - "search GitHub for", "find issues/PRs about X", "find code using this pattern". NOT for formatting existing results (use search-results) or summarizing one item (use github-summary).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Search
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Translate the request into qualifier syntax; combine filters for precision.
|
|
11
|
+
2. Execute the search.
|
|
12
|
+
3. Return results with direct GitHub URLs and one-line context each; hand off to search-results for table formatting.
|
|
13
|
+
4. If results are too broad/narrow, refine qualifiers once before asking the user.
|
|
14
|
+
|
|
15
|
+
## Qualifier reference
|
|
16
|
+
|
|
17
|
+
- `type:issue|pr` · `state:open|closed` · `is:merged|draft`
|
|
18
|
+
- `repo:owner/name` · `org:name` · `author:user` · `assignee:user`
|
|
19
|
+
- `label:"bug"` · `in:title,body` · `language:typescript`
|
|
20
|
+
- `created:>2026-01-01` · `updated:<2026-06-01` · `comments:>10`
|
|
21
|
+
- `sort:updated-desc` · negate with `-` (e.g. `-label:wontfix`)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-summary
|
|
3
|
+
description: Summarize a single GitHub issue, PR, or notification — key points, decisions, open questions, action items. Triggers - "summarize this issue/PR", "what's this discussion about", "what are the action items". NOT for searching (use github-search).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Summary
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Fetch the full item: title, description, all comments, and for PRs the changed-files overview.
|
|
11
|
+
2. Extract decisions and requirements from the discussion — weight recent comments and maintainer responses higher.
|
|
12
|
+
3. Output in this format, omitting empty sections:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
**Overview**: 1-2 sentences.
|
|
16
|
+
**Key points**: bullets (max 5).
|
|
17
|
+
**Decisions**: what was agreed.
|
|
18
|
+
**Open questions**: unresolved items.
|
|
19
|
+
**Action items**: who/what, if identifiable.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Rules
|
|
23
|
+
|
|
24
|
+
- Report only what is in the thread; never infer decisions that weren't made.
|
|
25
|
+
- Keep the whole summary under ~150 words unless the user asks for detail.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: integration-tests
|
|
3
|
+
description: Generate integration tests in four layers — L1 TestContainers (DB/queue/cache in Docker), L2 smoke tests, L3 cloud/Azure integration, L4 end-to-end behavioral flows. Triggers - "add integration tests", "create TestContainers/smoke/e2e tests". NOT for unit tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Integration Tests
|
|
7
|
+
|
|
8
|
+
## Layer selection
|
|
9
|
+
|
|
10
|
+
Ask which layer(s) if the user didn't specify. Default to L1 + L2.
|
|
11
|
+
|
|
12
|
+
- **L1 TestContainers**: real DB/queue/cache in Docker containers; test the data/messaging boundary.
|
|
13
|
+
- **L2 Smoke**: app starts, critical endpoints/happy paths respond, basic error handling.
|
|
14
|
+
- **L3 Cloud (Azure)**: real service connectivity, auth flows, managed identity — requires provisioned resources; confirm they exist first.
|
|
15
|
+
- **L4 Behavioral**: full user workflows across components, data consistency end-to-end.
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
1. Identify integration points from the code (DB clients, HTTP clients, queues, external SDKs).
|
|
20
|
+
2. Use the project's existing test framework and conventions — inspect current tests first.
|
|
21
|
+
3. Write fixtures with realistic data; every test must clean up its resources (containers, rows, files).
|
|
22
|
+
4. Name tests after the scenario they verify, not the method they call.
|
|
23
|
+
5. Run the new tests and iterate until green; then run the existing suite to confirm no interference.
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- Tests must be independent and order-agnostic; enable parallel execution where the framework supports it.
|
|
28
|
+
- Never hardcode credentials — use env vars or the framework's secret mechanism.
|
|
29
|
+
- If Docker isn't available, say so and offer L2 alternatives instead of writing untestable code.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-comments
|
|
3
|
+
description: Address review comments (including Copilot review comments) on an existing pull request — implement requested changes, reply to reviewers, resolve threads. Triggers - "address review comments", "address PR comments", "apply reviewer suggestions", "respond to PR feedback", "implement requested changes", "resolve these threads". NOT for creating a new PR (use create-pr).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Comments
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Fetch the PR. If its last-updated timestamp is under 3 minutes old the PR is still changing — re-fetch with a refresh so you don't act on stale threads.
|
|
11
|
+
2. Collect unresolved feedback: inline threads not yet resolved, plus general review comments requesting changes.
|
|
12
|
+
3. Classify each: actionable code change, question, or opinion.
|
|
13
|
+
4. Implement actionable changes grouped by file; keep each change scoped to what the reviewer asked.
|
|
14
|
+
5. Commit with messages referencing the feedback; push after user confirmation.
|
|
15
|
+
6. Reply per thread: "Done in <commit>" for implemented items; a brief technical rationale when respectfully declining; ask for clarification when the request is ambiguous.
|
|
16
|
+
7. Resolve threads only after the change is pushed or the discussion is settled, and only where the thread is actually resolvable by you.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- Never resolve a thread you haven't addressed.
|
|
21
|
+
- Skip threads already resolved, or that you lack permission to resolve.
|
|
22
|
+
- If a suggestion would introduce a bug or conflict with another comment, say so in the reply instead of silently skipping it.
|
|
23
|
+
- Report anything intentionally skipped, with the reasoning.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-setup
|
|
3
|
+
description: Scaffold a complete NEW project from scratch — framework init, config files, dependencies, folder structure, verified build. Triggers - "create a new React/Next.js/Vite/Node project", "set up a workspace", "scaffold an app". NOT for adding files or features to an existing project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Project Setup
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Confirm framework, language, and package manager from the request; ask only if genuinely ambiguous.
|
|
11
|
+
2. Prefer the official scaffolding CLI (`npm create vite@latest`, `npx create-next-app`, etc.) over hand-writing config.
|
|
12
|
+
3. Install dependencies with the chosen package manager.
|
|
13
|
+
4. Add essentials the scaffold omits: `.gitignore`, TypeScript strictness, lint/format config if requested.
|
|
14
|
+
5. Verify: run the build (and dev server briefly) to prove the setup works before handing off.
|
|
15
|
+
6. Summarize the structure and the commands to run.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- Use current stable versions; never pin to outdated majors.
|
|
20
|
+
- Don't add tooling the user didn't ask for beyond the essentials above.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: search-integration
|
|
3
|
+
description: Search the local workspace codebase — exact text, regex, and file-type-filtered searches with contextual results. Triggers - "find all usages of", "where is X defined/imported", "locate TODO comments", "find files matching". NOT for GitHub-wide search (use github-search).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Search Integration
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Pick the cheapest query that answers the question: exact string for identifiers; regex with alternation (`foo|bar`) to cover variants in ONE pass; glob file filters to cut noise.
|
|
11
|
+
2. Run the search; if zero hits, broaden once (case variants, partial word) before concluding it's absent.
|
|
12
|
+
3. Report file paths with line numbers and a snippet of surrounding context per match.
|
|
13
|
+
4. Group matches by file; note total count.
|
|
14
|
+
|
|
15
|
+
## Rules
|
|
16
|
+
|
|
17
|
+
- Escape regex metacharacters when the user gives a literal string.
|
|
18
|
+
- Distinguish definitions from usages when the user asks "where is X" — show the definition first.
|
|
19
|
+
- Too many hits (>50): narrow by directory or file type instead of dumping everything.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: search-results
|
|
3
|
+
description: Format GitHub search results for display — sortable tables, filtered views, counts, side-by-side comparisons with links. Triggers - "show results in a table", "sort by comments", "only open issues", "compare these". NOT for running the search itself (use github-search).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Search Results
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Take the result set (from github-search or provided by the user); apply any requested filter/sort first.
|
|
11
|
+
2. Render as a markdown table. Default columns: Title (linked) | State | Author | Created | Comments. Adjust columns to what's relevant.
|
|
12
|
+
3. End with a one-line stat: total shown / total found, breakdown by state if mixed.
|
|
13
|
+
|
|
14
|
+
## Rules
|
|
15
|
+
|
|
16
|
+
- Every title must be a direct GitHub link.
|
|
17
|
+
- Truncate titles at ~60 chars with `…`.
|
|
18
|
+
- Default sort: relevance; state the sort order used when it differs.
|
|
19
|
+
- >20 results: show top 20 and say how many were omitted.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript-upgrade
|
|
3
|
+
description: Upgrade npm dependencies in a TypeScript project and resolve breaking changes — staged upgrades, type-check verification, migration of changed APIs. Triggers - "upgrade dependencies", "update TypeScript/React to latest", "resolve dependency conflict", "migrate to <major version>".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TypeScript Upgrade
|
|
7
|
+
|
|
8
|
+
## Workflow
|
|
9
|
+
|
|
10
|
+
1. Baseline first: confirm build, type-check, and tests pass BEFORE upgrading. Fix or note pre-existing failures.
|
|
11
|
+
2. Inventory: `npm outdated`; identify majors vs minors/patches.
|
|
12
|
+
3. Upgrade in stages — minors/patches in one batch; each major separately.
|
|
13
|
+
4. For each major: check the changelog/migration guide, upgrade, fix compile errors and changed APIs, run type-check + tests before moving to the next.
|
|
14
|
+
5. Keep related packages in lockstep (e.g. `react`/`react-dom`/`@types/react`; a library and its plugins).
|
|
15
|
+
6. Final gate: full build + test suite green; then commit with a summary of versions changed.
|
|
16
|
+
|
|
17
|
+
## Rules
|
|
18
|
+
|
|
19
|
+
- Never combine multiple major upgrades in one step — isolate failures.
|
|
20
|
+
- If a major upgrade breaks and can't be fixed quickly, revert that package and report the blocker rather than leaving the repo broken.
|
|
21
|
+
- Verify peer-dependency warnings; don't silence them with `--force`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type RunLifecycleState = "queued" | "running" | "waiting_tool" | "waiting_confirmation" | "waiting_user_input" | "paused" | "succeeded" | "failed" | "cancelled";
|
|
2
|
+
export type RunStopReason = "none" | "completed" | "awaiting_approval" | "awaiting_user_input" | "max_steps_reached" | "no_progress" | "max_attempts" | "error" | "cancelled";
|
|
3
|
+
export type AgentRunRow = {
|
|
4
|
+
run_id: string;
|
|
5
|
+
status: string;
|
|
6
|
+
stop_reason: string;
|
|
7
|
+
objective: string | null;
|
|
8
|
+
workspace_path: string | null;
|
|
9
|
+
model_id: string | null;
|
|
10
|
+
cancel_requested?: number | null;
|
|
11
|
+
cancel_requested_at?: string | null;
|
|
12
|
+
created_at: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
};
|
|
15
|
+
export type AgentRunCheckpointRow = {
|
|
16
|
+
run_id: string;
|
|
17
|
+
sequence: number;
|
|
18
|
+
lifecycle_state: string;
|
|
19
|
+
stop_reason: string;
|
|
20
|
+
event_type: string;
|
|
21
|
+
payload_json: string | null;
|
|
22
|
+
created_at: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const isSafeRunId: (runId: string) => boolean;
|
|
25
|
+
declare const persistRunLifecycleEvent: (params: {
|
|
26
|
+
runId: string;
|
|
27
|
+
lifecycleState: RunLifecycleState;
|
|
28
|
+
stopReason: RunStopReason;
|
|
29
|
+
eventType: string;
|
|
30
|
+
payload?: Record<string, unknown>;
|
|
31
|
+
objective?: string;
|
|
32
|
+
workspacePath?: string;
|
|
33
|
+
modelId?: string;
|
|
34
|
+
}) => Promise<void>;
|
|
35
|
+
export declare const safePersistRunLifecycleEvent: (params: Parameters<typeof persistRunLifecycleEvent>[0]) => Promise<void>;
|
|
36
|
+
export declare const requestRunCancellation: (runId: string) => Promise<boolean>;
|
|
37
|
+
export declare const isRunCancellationRequested: (runId: string) => Promise<boolean>;
|
|
38
|
+
export declare const clearRunCancellationRequest: (runId: string) => Promise<void>;
|
|
39
|
+
export declare const deleteRunDataBatch: (runIds: string[]) => Promise<void>;
|
|
40
|
+
export declare const getRunSnapshot: (runId: string) => Promise<{
|
|
41
|
+
run: AgentRunRow;
|
|
42
|
+
latestCheckpoint: AgentRunCheckpointRow | null;
|
|
43
|
+
} | null>;
|
|
44
|
+
export declare const listRunEvents: (runId: string, afterSequence: number, limit: number) => Promise<AgentRunCheckpointRow[]>;
|
|
45
|
+
export declare const asRunLifecycleState: (value: string | undefined) => RunLifecycleState;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
import sqlite3 from "sqlite3";
|
|
5
|
+
import { open } from "sqlite";
|
|
6
|
+
export const isSafeRunId = (runId) => /^[A-Za-z0-9._:-]{1,160}$/.test(runId);
|
|
7
|
+
const RUN_STORE_DIR = path.join(os.homedir(), ".iris");
|
|
8
|
+
const RUN_STORE_DB_PATH = process.env.IRIS_AGENT_RUNS_DB_PATH || path.join(RUN_STORE_DIR, "agent-runs.sqlite");
|
|
9
|
+
let runStorePromise = null;
|
|
10
|
+
// Serialize all write operations so concurrent calls never overlap on one SQLite connection.
|
|
11
|
+
let writeQueue = Promise.resolve();
|
|
12
|
+
const enqueueWrite = (fn) => {
|
|
13
|
+
const next = writeQueue.then(fn, fn);
|
|
14
|
+
writeQueue = next.then(() => undefined, () => undefined);
|
|
15
|
+
return next;
|
|
16
|
+
};
|
|
17
|
+
const initializeRunStore = async () => {
|
|
18
|
+
await fs.mkdir(path.dirname(RUN_STORE_DB_PATH), { recursive: true });
|
|
19
|
+
const db = await open({
|
|
20
|
+
filename: RUN_STORE_DB_PATH,
|
|
21
|
+
driver: sqlite3.Database,
|
|
22
|
+
});
|
|
23
|
+
// Set the busy timeout before WAL because switching journal modes also needs
|
|
24
|
+
// a database lock during fresh concurrent sidecar startup.
|
|
25
|
+
await db.exec("PRAGMA busy_timeout = 5000;");
|
|
26
|
+
// Use WAL mode so readers don't block writers (and vice versa).
|
|
27
|
+
await db.exec("PRAGMA journal_mode = WAL;");
|
|
28
|
+
await db.exec(`
|
|
29
|
+
CREATE TABLE IF NOT EXISTS agent_runs (
|
|
30
|
+
run_id TEXT PRIMARY KEY,
|
|
31
|
+
status TEXT NOT NULL,
|
|
32
|
+
stop_reason TEXT NOT NULL,
|
|
33
|
+
objective TEXT,
|
|
34
|
+
workspace_path TEXT,
|
|
35
|
+
model_id TEXT,
|
|
36
|
+
cancel_requested INTEGER NOT NULL DEFAULT 0,
|
|
37
|
+
cancel_requested_at TEXT,
|
|
38
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
39
|
+
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
40
|
+
);
|
|
41
|
+
`);
|
|
42
|
+
const runColumns = (await db.all("PRAGMA table_info(agent_runs)"));
|
|
43
|
+
const hasCancelRequested = runColumns.some((column) => column.name === "cancel_requested");
|
|
44
|
+
const hasCancelRequestedAt = runColumns.some((column) => column.name === "cancel_requested_at");
|
|
45
|
+
if (!hasCancelRequested) {
|
|
46
|
+
await db.exec("ALTER TABLE agent_runs ADD COLUMN cancel_requested INTEGER NOT NULL DEFAULT 0;");
|
|
47
|
+
}
|
|
48
|
+
if (!hasCancelRequestedAt) {
|
|
49
|
+
await db.exec("ALTER TABLE agent_runs ADD COLUMN cancel_requested_at TEXT;");
|
|
50
|
+
}
|
|
51
|
+
await db.exec(`
|
|
52
|
+
CREATE TABLE IF NOT EXISTS agent_run_checkpoints (
|
|
53
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
54
|
+
run_id TEXT NOT NULL,
|
|
55
|
+
sequence INTEGER NOT NULL,
|
|
56
|
+
lifecycle_state TEXT NOT NULL,
|
|
57
|
+
stop_reason TEXT NOT NULL,
|
|
58
|
+
event_type TEXT NOT NULL,
|
|
59
|
+
payload_json TEXT,
|
|
60
|
+
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
61
|
+
UNIQUE(run_id, sequence)
|
|
62
|
+
);
|
|
63
|
+
`);
|
|
64
|
+
await db.exec("CREATE INDEX IF NOT EXISTS idx_agent_run_checkpoints_run_id ON agent_run_checkpoints(run_id, sequence);");
|
|
65
|
+
return db;
|
|
66
|
+
};
|
|
67
|
+
const getRunStore = async () => {
|
|
68
|
+
if (!runStorePromise) {
|
|
69
|
+
runStorePromise = initializeRunStore().catch((error) => {
|
|
70
|
+
runStorePromise = null;
|
|
71
|
+
throw error;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return runStorePromise;
|
|
75
|
+
};
|
|
76
|
+
const persistRunLifecycleEvent = async (params) => {
|
|
77
|
+
return enqueueWrite(async () => {
|
|
78
|
+
const db = await getRunStore();
|
|
79
|
+
await db.exec("BEGIN IMMEDIATE TRANSACTION;");
|
|
80
|
+
try {
|
|
81
|
+
await db.run(`
|
|
82
|
+
INSERT INTO agent_runs(run_id, status, stop_reason, objective, workspace_path, model_id, created_at, updated_at)
|
|
83
|
+
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
|
84
|
+
ON CONFLICT(run_id) DO UPDATE SET
|
|
85
|
+
status=excluded.status,
|
|
86
|
+
stop_reason=excluded.stop_reason,
|
|
87
|
+
objective=COALESCE(excluded.objective, agent_runs.objective),
|
|
88
|
+
workspace_path=COALESCE(excluded.workspace_path, agent_runs.workspace_path),
|
|
89
|
+
model_id=COALESCE(excluded.model_id, agent_runs.model_id),
|
|
90
|
+
updated_at=CURRENT_TIMESTAMP
|
|
91
|
+
`, params.runId, params.lifecycleState, params.stopReason, params.objective || null, params.workspacePath || null, params.modelId || null);
|
|
92
|
+
const sequenceRow = (await db.get("SELECT COALESCE(MAX(sequence), 0) AS maxSequence FROM agent_run_checkpoints WHERE run_id = ?", params.runId));
|
|
93
|
+
const nextSequence = (sequenceRow?.maxSequence || 0) + 1;
|
|
94
|
+
await db.run(`
|
|
95
|
+
INSERT INTO agent_run_checkpoints(
|
|
96
|
+
run_id,
|
|
97
|
+
sequence,
|
|
98
|
+
lifecycle_state,
|
|
99
|
+
stop_reason,
|
|
100
|
+
event_type,
|
|
101
|
+
payload_json,
|
|
102
|
+
created_at
|
|
103
|
+
) VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
|
|
104
|
+
`, params.runId, nextSequence, params.lifecycleState, params.stopReason, params.eventType, params.payload ? JSON.stringify(params.payload) : null);
|
|
105
|
+
await db.exec("COMMIT;");
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
await db.exec("ROLLBACK;");
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
export const safePersistRunLifecycleEvent = async (params) => {
|
|
114
|
+
try {
|
|
115
|
+
await persistRunLifecycleEvent(params);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const err = error;
|
|
119
|
+
console.warn("[agent] Failed to persist run lifecycle event:", err.message);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export const requestRunCancellation = async (runId) => {
|
|
123
|
+
return enqueueWrite(async () => {
|
|
124
|
+
const db = await getRunStore();
|
|
125
|
+
const result = await db.run(`
|
|
126
|
+
UPDATE agent_runs
|
|
127
|
+
SET cancel_requested = 1,
|
|
128
|
+
cancel_requested_at = CURRENT_TIMESTAMP,
|
|
129
|
+
updated_at = CURRENT_TIMESTAMP
|
|
130
|
+
WHERE run_id = ?
|
|
131
|
+
`, runId);
|
|
132
|
+
return typeof result?.changes === "number" && result.changes > 0;
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
export const isRunCancellationRequested = async (runId) => {
|
|
136
|
+
const db = await getRunStore();
|
|
137
|
+
const row = (await db.get("SELECT cancel_requested FROM agent_runs WHERE run_id = ?", runId));
|
|
138
|
+
return Number(row?.cancel_requested || 0) === 1;
|
|
139
|
+
};
|
|
140
|
+
export const clearRunCancellationRequest = async (runId) => {
|
|
141
|
+
return enqueueWrite(async () => {
|
|
142
|
+
const db = await getRunStore();
|
|
143
|
+
await db.run(`
|
|
144
|
+
UPDATE agent_runs
|
|
145
|
+
SET cancel_requested = 0,
|
|
146
|
+
cancel_requested_at = NULL,
|
|
147
|
+
updated_at = CURRENT_TIMESTAMP
|
|
148
|
+
WHERE run_id = ?
|
|
149
|
+
`, runId);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const deleteRunData = async (runId) => {
|
|
153
|
+
return enqueueWrite(async () => {
|
|
154
|
+
const db = await getRunStore();
|
|
155
|
+
await db.exec("BEGIN IMMEDIATE TRANSACTION;");
|
|
156
|
+
try {
|
|
157
|
+
await db.run("DELETE FROM agent_run_checkpoints WHERE run_id = ?", runId);
|
|
158
|
+
await db.run("DELETE FROM agent_runs WHERE run_id = ?", runId);
|
|
159
|
+
await db.exec("COMMIT;");
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
await db.exec("ROLLBACK;");
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
export const deleteRunDataBatch = async (runIds) => {
|
|
168
|
+
const uniqueSafeRunIds = Array.from(new Set(runIds.map((value) => value.trim()).filter((value) => isSafeRunId(value))));
|
|
169
|
+
for (const runId of uniqueSafeRunIds) {
|
|
170
|
+
await deleteRunData(runId);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
export const getRunSnapshot = async (runId) => {
|
|
174
|
+
const db = await getRunStore();
|
|
175
|
+
const run = (await db.get(`
|
|
176
|
+
SELECT
|
|
177
|
+
run_id,
|
|
178
|
+
status,
|
|
179
|
+
stop_reason,
|
|
180
|
+
objective,
|
|
181
|
+
workspace_path,
|
|
182
|
+
model_id,
|
|
183
|
+
cancel_requested,
|
|
184
|
+
cancel_requested_at,
|
|
185
|
+
created_at,
|
|
186
|
+
updated_at
|
|
187
|
+
FROM agent_runs
|
|
188
|
+
WHERE run_id = ?
|
|
189
|
+
`, runId));
|
|
190
|
+
if (!run)
|
|
191
|
+
return null;
|
|
192
|
+
const latestCheckpoint = (await db.get(`
|
|
193
|
+
SELECT
|
|
194
|
+
run_id,
|
|
195
|
+
sequence,
|
|
196
|
+
lifecycle_state,
|
|
197
|
+
stop_reason,
|
|
198
|
+
event_type,
|
|
199
|
+
payload_json,
|
|
200
|
+
created_at
|
|
201
|
+
FROM agent_run_checkpoints
|
|
202
|
+
WHERE run_id = ?
|
|
203
|
+
ORDER BY sequence DESC
|
|
204
|
+
LIMIT 1
|
|
205
|
+
`, runId));
|
|
206
|
+
return {
|
|
207
|
+
run,
|
|
208
|
+
latestCheckpoint: latestCheckpoint || null,
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
export const listRunEvents = async (runId, afterSequence, limit) => {
|
|
212
|
+
const db = await getRunStore();
|
|
213
|
+
return (await db.all(`
|
|
214
|
+
SELECT
|
|
215
|
+
run_id,
|
|
216
|
+
sequence,
|
|
217
|
+
lifecycle_state,
|
|
218
|
+
stop_reason,
|
|
219
|
+
event_type,
|
|
220
|
+
payload_json,
|
|
221
|
+
created_at
|
|
222
|
+
FROM agent_run_checkpoints
|
|
223
|
+
WHERE run_id = ? AND sequence > ?
|
|
224
|
+
ORDER BY sequence ASC
|
|
225
|
+
LIMIT ?
|
|
226
|
+
`, runId, Math.max(0, afterSequence), Math.max(1, Math.min(500, limit))));
|
|
227
|
+
};
|
|
228
|
+
export const asRunLifecycleState = (value) => {
|
|
229
|
+
const valid = [
|
|
230
|
+
"queued",
|
|
231
|
+
"running",
|
|
232
|
+
"waiting_tool",
|
|
233
|
+
"waiting_confirmation",
|
|
234
|
+
"waiting_user_input",
|
|
235
|
+
"paused",
|
|
236
|
+
"succeeded",
|
|
237
|
+
"failed",
|
|
238
|
+
"cancelled",
|
|
239
|
+
];
|
|
240
|
+
if (value && valid.includes(value)) {
|
|
241
|
+
return value;
|
|
242
|
+
}
|
|
243
|
+
return "running";
|
|
244
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-local agent utilities.
|
|
3
|
+
*
|
|
4
|
+
* Keep this file under `api/` so the backend can be bundled standalone
|
|
5
|
+
* without importing UI-layer source modules.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Truncate environment response to prevent context window overflow.
|
|
9
|
+
* Keeps beginning and end of output for context.
|
|
10
|
+
*/
|
|
11
|
+
export declare const truncateEnvironmentResponse: (response: string, maxChars?: number) => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-local agent utilities.
|
|
3
|
+
*
|
|
4
|
+
* Keep this file under `api/` so the backend can be bundled standalone
|
|
5
|
+
* without importing UI-layer source modules.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Truncate environment response to prevent context window overflow.
|
|
9
|
+
* Keeps beginning and end of output for context.
|
|
10
|
+
*/
|
|
11
|
+
export const truncateEnvironmentResponse = (response, maxChars = 12000) => {
|
|
12
|
+
if (!response || typeof response !== "string") {
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
if (response.length <= maxChars) {
|
|
16
|
+
return response;
|
|
17
|
+
}
|
|
18
|
+
// Keep 80% from beginning, 20% from end.
|
|
19
|
+
const keepChars = Math.floor(maxChars * 0.8);
|
|
20
|
+
const tailChars = maxChars - keepChars;
|
|
21
|
+
const truncatedCount = response.length - maxChars;
|
|
22
|
+
return `${response.slice(0, keepChars)}\n\n... [TRUNCATED ${truncatedCount} characters to prevent context overflow] ...\n\n${response.slice(-tailChars)}`;
|
|
23
|
+
};
|