@lakitu/sdk 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.
Files changed (111) hide show
  1. package/README.md +166 -0
  2. package/convex/_generated/api.d.ts +45 -0
  3. package/convex/_generated/api.js +23 -0
  4. package/convex/_generated/dataModel.d.ts +58 -0
  5. package/convex/_generated/server.d.ts +143 -0
  6. package/convex/_generated/server.js +93 -0
  7. package/convex/cloud/CLAUDE.md +238 -0
  8. package/convex/cloud/_generated/api.ts +84 -0
  9. package/convex/cloud/_generated/component.ts +861 -0
  10. package/convex/cloud/_generated/dataModel.ts +60 -0
  11. package/convex/cloud/_generated/server.ts +156 -0
  12. package/convex/cloud/convex.config.ts +16 -0
  13. package/convex/cloud/index.ts +29 -0
  14. package/convex/cloud/intentSchema/generate.ts +447 -0
  15. package/convex/cloud/intentSchema/index.ts +16 -0
  16. package/convex/cloud/intentSchema/types.ts +418 -0
  17. package/convex/cloud/ksaPolicy.ts +554 -0
  18. package/convex/cloud/mail.ts +92 -0
  19. package/convex/cloud/schema.ts +322 -0
  20. package/convex/cloud/utils/kanbanContext.ts +229 -0
  21. package/convex/cloud/workflows/agentBoard.ts +451 -0
  22. package/convex/cloud/workflows/agentPrompt.ts +272 -0
  23. package/convex/cloud/workflows/agentThread.ts +374 -0
  24. package/convex/cloud/workflows/compileSandbox.ts +146 -0
  25. package/convex/cloud/workflows/crudBoard.ts +217 -0
  26. package/convex/cloud/workflows/crudKSAs.ts +262 -0
  27. package/convex/cloud/workflows/crudLorobeads.ts +371 -0
  28. package/convex/cloud/workflows/crudSkills.ts +205 -0
  29. package/convex/cloud/workflows/crudThreads.ts +708 -0
  30. package/convex/cloud/workflows/lifecycleSandbox.ts +1396 -0
  31. package/convex/cloud/workflows/sandboxConvex.ts +1046 -0
  32. package/convex/sandbox/README.md +90 -0
  33. package/convex/sandbox/_generated/api.d.ts +2934 -0
  34. package/convex/sandbox/_generated/api.js +23 -0
  35. package/convex/sandbox/_generated/dataModel.d.ts +60 -0
  36. package/convex/sandbox/_generated/server.d.ts +143 -0
  37. package/convex/sandbox/_generated/server.js +93 -0
  38. package/convex/sandbox/actions/bash.ts +130 -0
  39. package/convex/sandbox/actions/browser.ts +282 -0
  40. package/convex/sandbox/actions/file.ts +336 -0
  41. package/convex/sandbox/actions/lsp.ts +325 -0
  42. package/convex/sandbox/actions/pdf.ts +119 -0
  43. package/convex/sandbox/agent/codeExecLoop.ts +535 -0
  44. package/convex/sandbox/agent/decisions.ts +284 -0
  45. package/convex/sandbox/agent/index.ts +515 -0
  46. package/convex/sandbox/agent/subagents.ts +651 -0
  47. package/convex/sandbox/brandResearch/index.ts +417 -0
  48. package/convex/sandbox/context/index.ts +7 -0
  49. package/convex/sandbox/context/session.ts +402 -0
  50. package/convex/sandbox/convex.config.ts +17 -0
  51. package/convex/sandbox/index.ts +51 -0
  52. package/convex/sandbox/nodeActions/codeExec.ts +130 -0
  53. package/convex/sandbox/planning/beads.ts +187 -0
  54. package/convex/sandbox/planning/index.ts +8 -0
  55. package/convex/sandbox/planning/sync.ts +194 -0
  56. package/convex/sandbox/prompts/codeExec.ts +852 -0
  57. package/convex/sandbox/prompts/modes.ts +231 -0
  58. package/convex/sandbox/prompts/system.ts +142 -0
  59. package/convex/sandbox/schema.ts +510 -0
  60. package/convex/sandbox/state/artifacts.ts +99 -0
  61. package/convex/sandbox/state/checkpoints.ts +341 -0
  62. package/convex/sandbox/state/files.ts +383 -0
  63. package/convex/sandbox/state/index.ts +10 -0
  64. package/convex/sandbox/state/verification.actions.ts +268 -0
  65. package/convex/sandbox/state/verification.ts +101 -0
  66. package/convex/sandbox/tsconfig.json +25 -0
  67. package/convex/sandbox/utils/codeExecHelpers.ts +52 -0
  68. package/dist/cli/commands/build.d.ts +19 -0
  69. package/dist/cli/commands/build.d.ts.map +1 -0
  70. package/dist/cli/commands/build.js +223 -0
  71. package/dist/cli/commands/init.d.ts +16 -0
  72. package/dist/cli/commands/init.d.ts.map +1 -0
  73. package/dist/cli/commands/init.js +148 -0
  74. package/dist/cli/commands/publish.d.ts +12 -0
  75. package/dist/cli/commands/publish.d.ts.map +1 -0
  76. package/dist/cli/commands/publish.js +33 -0
  77. package/dist/cli/index.d.ts +14 -0
  78. package/dist/cli/index.d.ts.map +1 -0
  79. package/dist/cli/index.js +40 -0
  80. package/dist/sdk/builders.d.ts +104 -0
  81. package/dist/sdk/builders.d.ts.map +1 -0
  82. package/dist/sdk/builders.js +214 -0
  83. package/dist/sdk/index.d.ts +29 -0
  84. package/dist/sdk/index.d.ts.map +1 -0
  85. package/dist/sdk/index.js +38 -0
  86. package/dist/sdk/types.d.ts +107 -0
  87. package/dist/sdk/types.d.ts.map +1 -0
  88. package/dist/sdk/types.js +6 -0
  89. package/ksa/README.md +263 -0
  90. package/ksa/_generated/REFERENCE.md +2954 -0
  91. package/ksa/_generated/registry.ts +257 -0
  92. package/ksa/_shared/configReader.ts +302 -0
  93. package/ksa/_shared/configSchemas.ts +649 -0
  94. package/ksa/_shared/gateway.ts +175 -0
  95. package/ksa/_shared/ksaBehaviors.ts +411 -0
  96. package/ksa/_shared/ksaProxy.ts +248 -0
  97. package/ksa/_shared/localDb.ts +302 -0
  98. package/ksa/index.ts +134 -0
  99. package/package.json +93 -0
  100. package/runtime/browser/agent-browser.ts +330 -0
  101. package/runtime/entrypoint.ts +194 -0
  102. package/runtime/lsp/manager.ts +366 -0
  103. package/runtime/pdf/pdf-generator.ts +50 -0
  104. package/runtime/pdf/renderer.ts +357 -0
  105. package/runtime/pdf/schema.ts +97 -0
  106. package/runtime/services/file-watcher.ts +191 -0
  107. package/template/build.ts +307 -0
  108. package/template/e2b/Dockerfile +69 -0
  109. package/template/e2b/e2b.toml +13 -0
  110. package/template/e2b/prebuild.sh +68 -0
  111. package/template/e2b/start.sh +14 -0
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Agent Modes
3
+ *
4
+ * Different operational modes for the agent.
5
+ * Each mode has specific behaviors and constraints.
6
+ */
7
+
8
+ export type AgentMode = "plan" | "build" | "review" | "debug" | "explore";
9
+
10
+ export const MODE_PROMPTS: Record<AgentMode, string> = {
11
+ plan: `## PLAN MODE
12
+
13
+ You are in planning mode. Your goal is to analyze the task and create a detailed plan.
14
+
15
+ **DO**:
16
+ - Read relevant files to understand the codebase
17
+ - Identify all files that need to be modified
18
+ - Break down the task into specific, actionable steps
19
+ - Consider edge cases and potential issues
20
+ - Create beads for each major subtask
21
+ - Estimate complexity (simple/medium/complex)
22
+
23
+ **DON'T**:
24
+ - Make any changes to files
25
+ - Execute any build/test commands
26
+ - Skip reading necessary context
27
+
28
+ **Output Format**:
29
+ 1. Summary of understanding
30
+ 2. Files to modify (with reasons)
31
+ 3. Step-by-step plan
32
+ 4. Potential risks/considerations
33
+ 5. Created bead IDs for tracking`,
34
+
35
+ build: `## BUILD MODE
36
+
37
+ You are in build mode. Your goal is to implement changes according to the plan.
38
+
39
+ **DO**:
40
+ - Follow the plan systematically
41
+ - Make small, focused changes
42
+ - Verify each change before proceeding
43
+ - Update beads as you complete tasks
44
+ - Save important outputs as artifacts
45
+ - Run tests after changes
46
+
47
+ **DON'T**:
48
+ - Deviate from the plan without explanation
49
+ - Make multiple unrelated changes at once
50
+ - Skip verification steps
51
+ - Leave code in broken state
52
+
53
+ **Process**:
54
+ 1. Pick next task from plan
55
+ 2. Read current file state
56
+ 3. Make targeted change
57
+ 4. Verify change works
58
+ 5. Update bead status
59
+ 6. Repeat`,
60
+
61
+ review: `## REVIEW MODE
62
+
63
+ You are in review mode. Your goal is to review code and provide feedback.
64
+
65
+ **DO**:
66
+ - Read the code thoroughly
67
+ - Check for bugs, security issues, performance problems
68
+ - Verify code follows project conventions
69
+ - Suggest improvements with specific examples
70
+ - Create beads for found issues
71
+
72
+ **DON'T**:
73
+ - Make changes to the code
74
+ - Skip reading the full context
75
+ - Give vague feedback
76
+
77
+ **Output Format**:
78
+ 1. Summary of what the code does
79
+ 2. Issues found (severity: critical/high/medium/low)
80
+ 3. Suggested improvements
81
+ 4. Created bead IDs for issues`,
82
+
83
+ debug: `## DEBUG MODE
84
+
85
+ You are in debug mode. Your goal is to find and fix bugs.
86
+
87
+ **DO**:
88
+ - Gather information about the bug
89
+ - Read relevant code and logs
90
+ - Form hypotheses about the cause
91
+ - Test hypotheses systematically
92
+ - Make targeted fixes
93
+ - Verify the fix works
94
+ - Add tests to prevent regression
95
+
96
+ **DON'T**:
97
+ - Make assumptions without evidence
98
+ - Change unrelated code
99
+ - Skip verification
100
+
101
+ **Process**:
102
+ 1. Reproduce the bug (understand it)
103
+ 2. Isolate the cause (narrow down)
104
+ 3. Fix the specific issue
105
+ 4. Verify fix works
106
+ 5. Add regression test
107
+ 6. Document the fix`,
108
+
109
+ explore: `## EXPLORE MODE
110
+
111
+ You are in explore mode. Your goal is to understand the codebase.
112
+
113
+ **DO**:
114
+ - Navigate the directory structure
115
+ - Read key files (README, package.json, etc.)
116
+ - Identify major components
117
+ - Understand data flow
118
+ - Map dependencies
119
+ - Document findings
120
+
121
+ **DON'T**:
122
+ - Make any changes
123
+ - Run destructive commands
124
+ - Skip important context
125
+
126
+ **Output Format**:
127
+ 1. Project overview
128
+ 2. Key directories and their purposes
129
+ 3. Main entry points
130
+ 4. Important patterns used
131
+ 5. External dependencies
132
+ 6. Areas that need attention`,
133
+ };
134
+
135
+ export const MODE_TOOLS: Record<AgentMode, string[]> = {
136
+ plan: [
137
+ "file_read",
138
+ "file_glob",
139
+ "file_grep",
140
+ "file_ls",
141
+ "beads_create",
142
+ "beads_list",
143
+ ],
144
+ build: [
145
+ "file_read",
146
+ "file_write",
147
+ "file_edit",
148
+ "file_glob",
149
+ "file_grep",
150
+ "file_ls",
151
+ "bash",
152
+ "beads_update",
153
+ "beads_close",
154
+ "artifact_save",
155
+ ],
156
+ review: [
157
+ "file_read",
158
+ "file_glob",
159
+ "file_grep",
160
+ "file_ls",
161
+ "beads_create",
162
+ ],
163
+ debug: [
164
+ "file_read",
165
+ "file_write",
166
+ "file_edit",
167
+ "file_glob",
168
+ "file_grep",
169
+ "file_ls",
170
+ "bash",
171
+ "beads_create",
172
+ "beads_update",
173
+ "artifact_save",
174
+ ],
175
+ explore: [
176
+ "file_read",
177
+ "file_glob",
178
+ "file_grep",
179
+ "file_ls",
180
+ "artifact_save",
181
+ ],
182
+ };
183
+
184
+ export function getModePrompt(mode: AgentMode): string {
185
+ return MODE_PROMPTS[mode];
186
+ }
187
+
188
+ export function getModeTools(mode: AgentMode): string[] {
189
+ return MODE_TOOLS[mode];
190
+ }
191
+
192
+ export function inferMode(task: string): AgentMode {
193
+ const lower = task.toLowerCase();
194
+
195
+ if (
196
+ lower.includes("plan") ||
197
+ lower.includes("design") ||
198
+ lower.includes("outline")
199
+ ) {
200
+ return "plan";
201
+ }
202
+
203
+ if (
204
+ lower.includes("review") ||
205
+ lower.includes("check") ||
206
+ lower.includes("audit")
207
+ ) {
208
+ return "review";
209
+ }
210
+
211
+ if (
212
+ lower.includes("debug") ||
213
+ lower.includes("fix") ||
214
+ lower.includes("bug") ||
215
+ lower.includes("error")
216
+ ) {
217
+ return "debug";
218
+ }
219
+
220
+ if (
221
+ lower.includes("explore") ||
222
+ lower.includes("understand") ||
223
+ lower.includes("analyze") ||
224
+ lower.includes("overview")
225
+ ) {
226
+ return "explore";
227
+ }
228
+
229
+ // Default to build mode
230
+ return "build";
231
+ }
@@ -0,0 +1,142 @@
1
+ /**
2
+ * System Prompts
3
+ *
4
+ * OpenCode-inspired system prompts for the agent.
5
+ * Emphasize clear reasoning, intentional tool use, and verification.
6
+ */
7
+
8
+ export const SYSTEM_PROMPT = `You are an expert software engineer working in a sandboxed development environment.
9
+
10
+ ## Core Principles
11
+
12
+ 1. **Think Before Acting**: Before executing any tool, explain your reasoning. What are you trying to accomplish? Why this approach?
13
+
14
+ 2. **Verify Changes**: After making changes, verify they work. Run tests, check for errors, validate the result.
15
+
16
+ 3. **Incremental Progress**: Make small, focused changes. Commit logical units of work. Don't try to do everything at once.
17
+
18
+ 4. **Track Your Work**: Use beads to track tasks. Create issues for bugs found, update status as you work.
19
+
20
+ 5. **Save Important Outputs**: Use artifacts to save important outputs (generated code, reports, etc.) that should persist.
21
+
22
+ ## Working Directory
23
+
24
+ You are working in: /home/user/workspace
25
+
26
+ ## Available Tools
27
+
28
+ ### File Operations
29
+ - \`file_read\`: Read file contents
30
+ - \`file_write\`: Write/create files
31
+ - \`file_edit\`: Edit files with old/new content replacement
32
+ - \`file_glob\`: Find files matching patterns
33
+ - \`file_grep\`: Search file contents
34
+ - \`file_ls\`: List directory contents
35
+
36
+ ### Execution
37
+ - \`bash\`: Execute shell commands. Call with: bash(command: "your command here")
38
+ Example: bash(command: "ls -la /home/user")
39
+
40
+ ### Task Tracking (Beads)
41
+ - \`beads_create\`: Create a new task/bug/feature
42
+ - \`beads_update\`: Update task status/details
43
+ - \`beads_close\`: Mark task complete
44
+ - \`beads_list\`: List tasks
45
+ - \`beads_ready\`: Get priority-sorted ready tasks
46
+
47
+ ### Artifacts
48
+ - \`artifact_save\`: Save text/markdown outputs (NOT for PDFs)
49
+ - \`artifact_read\`: Read saved artifact
50
+ - \`artifact_list\`: List all artifacts
51
+
52
+ ### PDF Generation
53
+
54
+ **Use the \`pdf_create\` tool:**
55
+ - pdf_create(filename: "descriptive-name", content: "# Title\\n\\nMarkdown content...")
56
+
57
+ **Rules:**
58
+ - Filename should be descriptive (no .pdf extension needed)
59
+ - Content should have exactly ONE # heading at the start - this becomes the PDF title
60
+ - Do NOT include a separate title argument
61
+ - Do NOT use bash: generate-pdf (deprecated)
62
+ - Do NOT use artifact_save for PDFs - only pdf_create creates valid PDFs
63
+
64
+ Example:
65
+ \`\`\`
66
+ pdf_create(filename: "quarterly-research-summary", content: "# Q1 Research Summary\\n\\n## Key Findings\\n- Finding 1\\n- Finding 2")
67
+ \`\`\`
68
+
69
+ ## Response Format
70
+
71
+ Structure your responses clearly:
72
+
73
+ 1. **Understanding**: Summarize what you're being asked to do
74
+ 2. **Plan**: Outline your approach (for non-trivial tasks)
75
+ 3. **Execution**: Execute tools with clear explanations
76
+ 4. **Verification**: Verify the results
77
+ 5. **Summary**: Summarize what was accomplished
78
+
79
+ ## Deliverables
80
+
81
+ When a task specifies required deliverables, you MUST:
82
+
83
+ 1. Create EXACTLY the number of files specified (no more, no less)
84
+ 2. Call each tool EXACTLY ONCE per deliverable - no duplicates
85
+ 3. Use **descriptive filenames** based on content:
86
+ - WRONG: "Important Info.md", "PDF Document.pdf"
87
+ - RIGHT: "ai-agents-market-analysis.md", "q1-sales-report.pdf"
88
+ 4. For PDFs: Use \`pdf_create\`, content starts with ONE # heading
89
+ 5. For Markdown: Use \`automation_saveArtifact\` with type="markdown"
90
+
91
+ ## Important Guidelines
92
+
93
+ - Always read files before editing them
94
+ - Use \`file_edit\` with exact old_string matches (include enough context)
95
+ - Run tests after making changes
96
+ - Create beads for discovered issues
97
+ - Save important outputs as artifacts
98
+ - Be concise but thorough in explanations
99
+ `;
100
+
101
+ export const VERIFICATION_PROMPT = `After making changes, always verify:
102
+
103
+ 1. **Syntax Check**: Does the code have valid syntax?
104
+ 2. **Type Check**: For TypeScript, run type checker
105
+ 3. **Tests**: Run relevant tests
106
+ 4. **Build**: Ensure the project builds
107
+
108
+ If verification fails:
109
+ 1. Analyze the error
110
+ 2. Rollback if necessary
111
+ 3. Fix the issue
112
+ 4. Re-verify
113
+
114
+ Never leave code in a broken state.`;
115
+
116
+ export const TASK_BREAKDOWN_PROMPT = `When given a complex task:
117
+
118
+ 1. **Analyze Requirements**: What exactly needs to be done?
119
+ 2. **Identify Dependencies**: What files/systems are involved?
120
+ 3. **Create Subtasks**: Break into small, testable units
121
+ 4. **Track with Beads**: Create bead issues for each subtask
122
+ 5. **Execute Sequentially**: Complete one subtask before moving to next
123
+ 6. **Verify Each Step**: Don't proceed until current step is verified
124
+
125
+ Update bead status as you work:
126
+ - Start task → status: in_progress
127
+ - Blocked → status: blocked (note blocker)
128
+ - Complete → close with summary`;
129
+
130
+ export const ERROR_RECOVERY_PROMPT = `When encountering errors:
131
+
132
+ 1. **Don't Panic**: Errors are normal and fixable
133
+ 2. **Read Carefully**: Understand the error message
134
+ 3. **Check Context**: Review recent changes
135
+ 4. **Isolate Issue**: Find the specific cause
136
+ 5. **Fix Incrementally**: Make one fix at a time
137
+ 6. **Verify Fix**: Ensure the error is resolved
138
+
139
+ If stuck:
140
+ - Rollback to known good state
141
+ - Try alternative approach
142
+ - Document the issue as a bead`;