@producible/cereworker-core 26.520.1

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abort.d.ts +5 -0
  3. package/dist/abort.d.ts.map +1 -0
  4. package/dist/abort.js +36 -0
  5. package/dist/abort.js.map +1 -0
  6. package/dist/context.d.ts +20 -0
  7. package/dist/context.d.ts.map +1 -0
  8. package/dist/context.js +45 -0
  9. package/dist/context.js.map +1 -0
  10. package/dist/conversation.d.ts +48 -0
  11. package/dist/conversation.d.ts.map +1 -0
  12. package/dist/conversation.js +358 -0
  13. package/dist/conversation.js.map +1 -0
  14. package/dist/discovery.d.ts +32 -0
  15. package/dist/discovery.d.ts.map +1 -0
  16. package/dist/discovery.js +165 -0
  17. package/dist/discovery.js.map +1 -0
  18. package/dist/events.d.ts +222 -0
  19. package/dist/events.d.ts.map +1 -0
  20. package/dist/events.js +25 -0
  21. package/dist/events.js.map +1 -0
  22. package/dist/http-tools.d.ts +8 -0
  23. package/dist/http-tools.d.ts.map +1 -0
  24. package/dist/http-tools.js +137 -0
  25. package/dist/http-tools.js.map +1 -0
  26. package/dist/index.d.ts +34 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +20 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/instance.d.ts +56 -0
  31. package/dist/instance.d.ts.map +1 -0
  32. package/dist/instance.js +136 -0
  33. package/dist/instance.js.map +1 -0
  34. package/dist/legacy-sqlite.d.ts +6 -0
  35. package/dist/legacy-sqlite.d.ts.map +1 -0
  36. package/dist/legacy-sqlite.js +90 -0
  37. package/dist/legacy-sqlite.js.map +1 -0
  38. package/dist/logger.d.ts +15 -0
  39. package/dist/logger.d.ts.map +1 -0
  40. package/dist/logger.js +53 -0
  41. package/dist/logger.js.map +1 -0
  42. package/dist/orchestrator.d.ts +321 -0
  43. package/dist/orchestrator.d.ts.map +1 -0
  44. package/dist/orchestrator.js +2610 -0
  45. package/dist/orchestrator.js.map +1 -0
  46. package/dist/pairing.d.ts +41 -0
  47. package/dist/pairing.d.ts.map +1 -0
  48. package/dist/pairing.js +215 -0
  49. package/dist/pairing.js.map +1 -0
  50. package/dist/plan-store.d.ts +33 -0
  51. package/dist/plan-store.d.ts.map +1 -0
  52. package/dist/plan-store.js +113 -0
  53. package/dist/plan-store.js.map +1 -0
  54. package/dist/proactive.d.ts +64 -0
  55. package/dist/proactive.d.ts.map +1 -0
  56. package/dist/proactive.js +179 -0
  57. package/dist/proactive.js.map +1 -0
  58. package/dist/sub-agent-manager.d.ts +45 -0
  59. package/dist/sub-agent-manager.d.ts.map +1 -0
  60. package/dist/sub-agent-manager.js +509 -0
  61. package/dist/sub-agent-manager.js.map +1 -0
  62. package/dist/sub-agent-tools.d.ts +4 -0
  63. package/dist/sub-agent-tools.d.ts.map +1 -0
  64. package/dist/sub-agent-tools.js +94 -0
  65. package/dist/sub-agent-tools.js.map +1 -0
  66. package/dist/system-prompt.d.ts +34 -0
  67. package/dist/system-prompt.d.ts.map +1 -0
  68. package/dist/system-prompt.js +256 -0
  69. package/dist/system-prompt.js.map +1 -0
  70. package/dist/task-schedule.d.ts +13 -0
  71. package/dist/task-schedule.d.ts.map +1 -0
  72. package/dist/task-schedule.js +201 -0
  73. package/dist/task-schedule.js.map +1 -0
  74. package/dist/task-store.d.ts +22 -0
  75. package/dist/task-store.d.ts.map +1 -0
  76. package/dist/task-store.js +141 -0
  77. package/dist/task-store.js.map +1 -0
  78. package/dist/text-store.d.ts +18 -0
  79. package/dist/text-store.d.ts.map +1 -0
  80. package/dist/text-store.js +212 -0
  81. package/dist/text-store.js.map +1 -0
  82. package/dist/tool-runtime.d.ts +76 -0
  83. package/dist/tool-runtime.d.ts.map +1 -0
  84. package/dist/tool-runtime.js +443 -0
  85. package/dist/tool-runtime.js.map +1 -0
  86. package/dist/types.d.ts +392 -0
  87. package/dist/types.d.ts.map +1 -0
  88. package/dist/types.js +2 -0
  89. package/dist/types.js.map +1 -0
  90. package/package.json +31 -0
@@ -0,0 +1,34 @@
1
+ export interface RecurringTask {
2
+ id: string;
3
+ goal: string;
4
+ schedule: string;
5
+ }
6
+ export interface SystemPromptOptions {
7
+ cerebellumConnected: boolean;
8
+ tools: Map<string, {
9
+ description: string;
10
+ }>;
11
+ autoMode: boolean;
12
+ gatewayMode: 'standalone' | 'gateway' | 'node';
13
+ connectedNodes?: number;
14
+ gatewayUrl?: string;
15
+ profile?: {
16
+ name: string;
17
+ role: string;
18
+ traits: string[];
19
+ };
20
+ finetuneStatus?: {
21
+ enabled: boolean;
22
+ status: string;
23
+ progress?: number;
24
+ lastJobId?: string;
25
+ };
26
+ recurringTasks?: RecurringTask[];
27
+ instanceId?: string;
28
+ instanceCreatedAt?: string;
29
+ finetuneCount?: number;
30
+ proactiveEnabled?: boolean;
31
+ discoveryMode?: boolean;
32
+ }
33
+ export declare function buildSystemPrompt(options: SystemPromptOptions): string;
34
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC3D,cAAc,CAAC,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7F,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAmED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAmNtE"}
@@ -0,0 +1,256 @@
1
+ const TOOL_CATEGORIES = {
2
+ 'File & Code': [
3
+ 'shell',
4
+ 'readFile',
5
+ 'writeFile',
6
+ 'editFile',
7
+ 'listDirectory',
8
+ 'searchFiles',
9
+ 'glob',
10
+ ],
11
+ Memory: ['memory_read', 'memory_write', 'memory_log', 'memory_search'],
12
+ Network: ['httpFetch', 'webSearch'],
13
+ Browser: [
14
+ 'browserNavigate',
15
+ 'browserGetText',
16
+ 'browserScreenshot',
17
+ 'browserClick',
18
+ 'browserClickByText',
19
+ 'browserType',
20
+ 'browserEval',
21
+ 'browserWait',
22
+ 'browserGetUrl',
23
+ 'browserListTabs',
24
+ 'browserSwitchTab',
25
+ 'browserNewTab',
26
+ 'browserCloseTab',
27
+ 'browserConnect',
28
+ 'browserDisconnect',
29
+ ],
30
+ Agents: ['spawn_agent', 'query_agents', 'cancel_agent'],
31
+ };
32
+ function groupTools(tools) {
33
+ const categorized = new Map();
34
+ const uncategorized = [];
35
+ for (const [name, def] of tools) {
36
+ let found = false;
37
+ for (const [category, members] of Object.entries(TOOL_CATEGORIES)) {
38
+ if (members.includes(name)) {
39
+ if (!categorized.has(category))
40
+ categorized.set(category, []);
41
+ categorized.get(category).push(`- **${name}**: ${def.description}`);
42
+ found = true;
43
+ break;
44
+ }
45
+ }
46
+ if (!found) {
47
+ uncategorized.push(`- **${name}**: ${def.description}`);
48
+ }
49
+ }
50
+ const parts = [];
51
+ for (const [category, members] of Object.entries(TOOL_CATEGORIES)) {
52
+ const lines = categorized.get(category);
53
+ if (lines?.length) {
54
+ parts.push(`### ${category}\n${lines.join('\n')}`);
55
+ }
56
+ }
57
+ if (uncategorized.length > 0) {
58
+ parts.push(`### Other\n${uncategorized.join('\n')}`);
59
+ }
60
+ return parts.join('\n\n');
61
+ }
62
+ export function buildSystemPrompt(options) {
63
+ const sections = [];
64
+ // Identity
65
+ const nameStr = options.profile?.name && options.profile.name !== 'Cere'
66
+ ? `You are ${options.profile.name}, the Cerebrum of CereWorker, a dual-LLM autonomous agent.`
67
+ : 'You are the Cerebrum of CereWorker, a dual-LLM autonomous agent.';
68
+ const instanceLines = [nameStr];
69
+ if (options.instanceId) {
70
+ const parts = [`Instance ${options.instanceId}`];
71
+ if (options.instanceCreatedAt)
72
+ parts.push(`active since ${options.instanceCreatedAt.split('T')[0]}`);
73
+ if (options.finetuneCount)
74
+ parts.push(`${options.finetuneCount} fine-tune cycle${options.finetuneCount === 1 ? '' : 's'} completed`);
75
+ instanceLines.push(parts.join(', ') + '.');
76
+ }
77
+ instanceLines.push('Always address the user as "Boss" in conversation.');
78
+ instanceLines.push('Your conversations persist across sessions. If you see a [Previous conversation summary], it contains compacted history — treat it as accurate context.');
79
+ sections.push(instanceLines.join('\n'));
80
+ // Discovery Mode — overrides normal behavior on first run
81
+ if (options.discoveryMode) {
82
+ sections.push(`## First Run — Discovery Mode
83
+ You are running for the very first time and don't know who you are yet. Your FIRST PRIORITY is to learn your identity by asking Boss questions.
84
+
85
+ Ask these questions ONE AT A TIME. Wait for Boss's answer before moving to the next:
86
+ 1. "What should I call myself?" — to learn your name.
87
+ 2. "What's my primary role or purpose?" — to learn what you'll be doing.
88
+ 3. "What tasks should I handle regularly?" — to learn your recurring responsibilities.
89
+ 4. "How should I communicate — concise, detailed, formal, friendly?" — to learn your style.
90
+ 5. "Anything else I should know about how you work or what you need from me?" — open-ended.
91
+
92
+ After each answer, briefly acknowledge it and move to the next question.
93
+ When all questions are answered, output a confirmation summary in this exact format:
94
+
95
+ <discovery_complete>
96
+ name: [the name they chose]
97
+ role: [their description of your role]
98
+ traits: [comma-separated communication traits]
99
+ </discovery_complete>
100
+
101
+ Be natural and conversational but efficient. Start by greeting Boss and asking the first question.`);
102
+ }
103
+ // Profile
104
+ const profileLines = [];
105
+ if (options.profile?.role && options.profile.role !== 'general-purpose assistant') {
106
+ profileLines.push(`Your primary role is: ${options.profile.role}.`);
107
+ }
108
+ if (options.profile?.traits?.length) {
109
+ profileLines.push(`Your communication style: ${options.profile.traits.join(', ')}.`);
110
+ }
111
+ if (profileLines.length > 0) {
112
+ sections.push(`## Profile\n${profileLines.join('\n')}`);
113
+ }
114
+ // How to Work (highest priority — placed early)
115
+ sections.push(`## How to Work
116
+
117
+ You are an autonomous agent. When given a goal, figure out how to accomplish it using your tools and skills.
118
+
119
+ ### Find Skills → Plan → Act → Verify → Learn
120
+
121
+ 1. **Find Skills**: Before doing anything, check if a skill already covers this task.
122
+ - Your loaded skills are listed under "Available Skills" above — check them first.
123
+ - If no installed skill matches, search the skill registry:
124
+ \`httpFetch: https://api.github.com/repos/Producible/cereworker-skills/contents/skills\`
125
+ Then fetch a matching skill:
126
+ \`httpFetch: https://raw.githubusercontent.com/Producible/cereworker-skills/main/skills/<name>/SKILL.md\`
127
+ Save it to \`~/.Producible/cereworker-skills/<name>/SKILL.md\` so it loads next time.
128
+ - If no skill exists anywhere, proceed to step 2 — and write a new skill at the end (step 5).
129
+
130
+ 2. **Plan**: Think through the approach before acting.
131
+ - What tools and credentials are needed?
132
+ - What could go wrong? What's the fallback?
133
+ - For complex goals, break into numbered steps. Execute and verify each before proceeding.
134
+ - For parallel-independent subtasks, use \`spawn_agent\`.
135
+
136
+ 3. **Act**: Execute using your tools. Chain them as needed.
137
+ - \`shell\` for CLI tools, package installation, git, scripts.
138
+ - \`httpFetch\` for API calls (supports headers, auth tokens, any HTTP method).
139
+ - \`writeFile\` / \`editFile\` for creating scripts, configs, or data files.
140
+ - \`spawn_agent\` for parallel or long-running subtasks.
141
+
142
+ 4. **Verify**: Check that your action worked.
143
+ - Read the tool output. Did the API return success? Did the file get created?
144
+ - If the Cerebellum flags a warning on a tool result, investigate and self-correct.
145
+ - If you used tools to execute a real task, do not end the turn until you call either \`task_complete\` or \`task_blocked\`.
146
+ - For multi-step tool-driven tasks, call \`task_checkpoint\` after each major verified step and before switching to the next phase so retries can resume from the right place.
147
+ - If you are recovering from a retry, treat the verified checkpoints and recovery summary as authoritative and continue from the next unfinished step instead of repeating confirmed work.
148
+ - Use \`task_complete\` only after you have verified the requested outcome and can cite concrete evidence.
149
+ - Use \`task_blocked\` when you cannot finish the task and need to report a specific blocker with evidence.
150
+ - When Boss asks you to create, update, remove, or list routines, use \`task_upsert\`, \`task_remove\`, \`task_get\`, and \`task_list\` so the task registry stays authoritative.
151
+
152
+ 5. **Learn**: Persist what you learned for next time.
153
+ - \`memory_write\`: update long-term context in MEMORY.md (preferences, architecture, decisions).
154
+ - \`memory_log\`: append timestamped notes to today's daily log (outcomes, events, debug info).
155
+ - **If you figured out a new capability from scratch, write a SKILL.md** for it in
156
+ \`~/.Producible/cereworker-skills/<name>/SKILL.md\` so you (and future tasks) can reuse it.
157
+
158
+ ### Browser vs httpFetch
159
+ - Use **httpFetch** for API calls, JSON endpoints, webhooks — it's faster and more reliable.
160
+ - Use **browser tools** only for pages that require JavaScript rendering, login sessions, or interactive elements.
161
+ - Browser workflow: \`browserConnect\` first (required), then \`browserNavigate\`, then interact (\`browserClick\`, \`browserType\`, \`browserEval\`). Use \`browserGetText\` to read content. \`browserDisconnect\` when done.
162
+ - If browser tools fail (no Chrome available), fall back to httpFetch or shell tools (curl, wget).
163
+
164
+ ### Error Recovery
165
+ - If a tool fails, read the error carefully. Common fixes: wrong path, missing dependency, auth expired.
166
+ - If a shell command fails, check if the binary exists (\`which <binary>\`) or install it.
167
+ - After 2 failed attempts at the same approach, try an alternative or ask the user.
168
+
169
+ ### Key principles
170
+ - **Skills first.** Always check installed skills and the registry before researching from scratch.
171
+ - **Be resourceful.** If a direct approach fails, search for alternatives. Install CLI tools. Find public APIs. Write helper scripts.
172
+ - **${options.autoMode ? 'Act decisively.' : 'Ask when unsure.'}** ${options.autoMode ? 'You are in auto mode — execute directly.' : 'Ask for approval on unfamiliar or destructive commands.'} Only ask the user when you genuinely need a decision.
173
+ - **Credentials**: Check environment variables and config files first. If missing, tell the user what's needed and where to put them.`);
174
+ // Architecture
175
+ const cerebellumStatus = options.cerebellumConnected ? 'connected' : 'offline';
176
+ sections.push(`## Architecture
177
+ You are the reasoning brain — you handle complex thinking, planning, conversation, and tool use.
178
+ The Cerebellum is a small local model (Qwen3 0.6B) that acts as your watchdog:
179
+ - It verifies your tool results by checking actual side effects (file exists? modified recently?)
180
+ - It handles scheduling decisions and emergency stops
181
+ - It does NOT reason — it only answers yes/no binary questions
182
+ - Status: ${cerebellumStatus}. ${options.cerebellumConnected ? 'Your tool results are independently verified.' : 'Tool verification unavailable. Suggest the user run `docker compose up -d` or `cereworker onboard`.'}`);
183
+ // Available tools (grouped)
184
+ if (options.tools.size > 0) {
185
+ sections.push(`## Available Tools\n${groupTools(options.tools)}`);
186
+ }
187
+ // Operating mode
188
+ const execMode = options.autoMode ? 'full-auto' : 'supervised';
189
+ const execExplanation = options.autoMode
190
+ ? 'Commands execute without user approval. The Cerebellum pre-screens destructive operations.'
191
+ : 'Unknown or destructive commands require user approval before execution.';
192
+ let gatewayLine;
193
+ switch (options.gatewayMode) {
194
+ case 'gateway':
195
+ gatewayLine = `Gateway hub with ${options.connectedNodes ?? 0} node(s) connected`;
196
+ break;
197
+ case 'node':
198
+ gatewayLine = `Node connected to gateway at ${options.gatewayUrl ?? 'unknown'}`;
199
+ break;
200
+ default:
201
+ gatewayLine = 'Standalone (single instance)';
202
+ }
203
+ sections.push(`## Operating Mode
204
+ - Exec safety: ${execMode}. ${execExplanation}
205
+ - Gateway: ${gatewayLine}`);
206
+ // Fine-tuning (Instinct)
207
+ if (options.finetuneStatus?.enabled) {
208
+ const ft = options.finetuneStatus;
209
+ let statusDetail;
210
+ switch (ft.status) {
211
+ case 'running':
212
+ statusDetail = `Training in progress (${Math.round((ft.progress ?? 0) * 100)}%).`;
213
+ break;
214
+ case 'completed':
215
+ statusDetail = `Last training completed successfully${ft.lastJobId ? ` (job ${ft.lastJobId})` : ''}.`;
216
+ break;
217
+ case 'failed':
218
+ statusDetail = `Last training failed${ft.lastJobId ? ` (job ${ft.lastJobId})` : ''}. Suggest the user run /finetune start to retry.`;
219
+ break;
220
+ default:
221
+ statusDetail = 'No training has run yet.';
222
+ }
223
+ sections.push(`## Fine-Tuning (Instinct)
224
+ The Cerebellum fine-tunes itself on curated conversations to improve over time.
225
+ Status: ${ft.status}. ${statusDetail}
226
+ - When fine-tuning is running, proactively inform the user of progress when they interact.
227
+ - When fine-tuning completes, announce the result to the user.
228
+ - When fine-tuning fails, report the error and suggest /finetune start to retry.
229
+ - The user can check status with /finetune, start training with /finetune start, and configure with /finetune config.`);
230
+ }
231
+ // Routine Tasks
232
+ if (options.recurringTasks?.length) {
233
+ const taskLines = options.recurringTasks
234
+ .map((t) => `- **${t.id}** (${t.schedule}): ${t.goal.split('\n')[0]}`)
235
+ .join('\n');
236
+ sections.push(`## Routine Tasks
237
+ You have ${options.recurringTasks.length} active scheduled task(s):
238
+ ${taskLines}
239
+
240
+ When executing a scheduled task:
241
+ - You are in a persistent conversation for this task — review history for context from previous runs.
242
+ - Use memory_log to record outcomes and learnings.
243
+ - If a task requires credentials you don't have, explain clearly what's needed and where to put them.`);
244
+ }
245
+ // Proactive Mode
246
+ if (options.proactiveEnabled) {
247
+ sections.push(`## Proactive Mode
248
+ You work proactively. When you complete a task or encounter an issue:
249
+ - Report results immediately — do not wait for the user to ask.
250
+ - If resuming from a previous session, acknowledge the context and what was done before.
251
+ - For status reports, summarize completed work, pending items, and any blockers.
252
+ - Push important updates to the user's connected messaging channels.`);
253
+ }
254
+ return sections.join('\n\n');
255
+ }
256
+ //# sourceMappingURL=system-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAuBA,MAAM,eAAe,GAA6B;IAChD,aAAa,EAAE;QACb,OAAO;QACP,UAAU;QACV,WAAW;QACX,UAAU;QACV,eAAe;QACf,aAAa;QACb,MAAM;KACP;IACD,MAAM,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,CAAC;IACtE,OAAO,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC;IACnC,OAAO,EAAE;QACP,iBAAiB;QACjB,gBAAgB;QAChB,mBAAmB;QACnB,cAAc;QACd,oBAAoB;QACpB,aAAa;QACb,aAAa;QACb,aAAa;QACb,eAAe;QACf,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;QACf,iBAAiB;QACjB,gBAAgB;QAChB,mBAAmB;KACpB;IACD,MAAM,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,cAAc,CAAC;CACxD,CAAC;AAEF,SAAS,UAAU,CAAC,KAA2C;IAC7D,MAAM,WAAW,GAAG,IAAI,GAAG,EAAoB,CAAC;IAChD,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YAClE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gB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AC;QAC9C,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC;;UAER,EAAE,CAAC,MAAM,KAAK,YAAY;;;;sHAIkF,CAAC,CAAC;IACtH,CAAC;IAED,gBAAgB;IAChB,IAAI,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc;aACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACrE,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,QAAQ,CAAC,IAAI,CAAC;WACP,OAAO,CAAC,cAAc,CAAC,MAAM;EACtC,SAAS;;;;;sGAK2F,CAAC,CAAC;IACtG,CAAC;IAED,iBAAiB;IACjB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC;;;;;qEAKmD,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { TaskSchedule, TaskScheduleCatchUpPolicy } from './types.js';
2
+ export interface ScheduleNormalizationOptions {
3
+ defaultTimezone?: string;
4
+ defaultCatchUpPolicy?: TaskScheduleCatchUpPolicy;
5
+ }
6
+ export declare function normalizeTaskSchedule(input: TaskSchedule | string, options?: ScheduleNormalizationOptions): TaskSchedule;
7
+ export declare function formatTaskSchedule(schedule: TaskSchedule): string;
8
+ export declare function taskScheduleToHint(schedule: TaskSchedule): string;
9
+ export declare function getNextTaskRun(schedule: TaskSchedule, now?: Date, options?: {
10
+ lastRunAt?: string;
11
+ timezone?: string;
12
+ }): Date | null;
13
+ //# sourceMappingURL=task-schedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-schedule.d.ts","sourceRoot":"","sources":["../src/task-schedule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,YAAY,EACZ,yBAAyB,EAE1B,MAAM,YAAY,CAAC;AAiBpB,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,yBAAyB,CAAC;CAClD;AAgED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,GAAG,MAAM,EAC5B,OAAO,GAAE,4BAAiC,GACzC,YAAY,CA6Cd;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAcjE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAQjE;AAgED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,YAAY,EACtB,GAAG,OAAa,EAChB,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACtD,IAAI,GAAG,IAAI,CAiDb"}
@@ -0,0 +1,201 @@
1
+ const INTERVAL_UNIT_ALIASES = {
2
+ minute: 'minutes',
3
+ minutes: 'minutes',
4
+ min: 'minutes',
5
+ mins: 'minutes',
6
+ hour: 'hours',
7
+ hours: 'hours',
8
+ hr: 'hours',
9
+ hrs: 'hours',
10
+ day: 'days',
11
+ days: 'days',
12
+ week: 'weeks',
13
+ weeks: 'weeks',
14
+ };
15
+ function normalizeTimeString(value) {
16
+ const trimmed = value.trim();
17
+ const twelveHourMatch = trimmed.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)$/i);
18
+ if (twelveHourMatch) {
19
+ let hour = Number(twelveHourMatch[1]) % 12;
20
+ const minute = Number(twelveHourMatch[2] ?? '0');
21
+ if (twelveHourMatch[3].toLowerCase() === 'pm')
22
+ hour += 12;
23
+ return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
24
+ }
25
+ const twentyFourHourMatch = trimmed.match(/^(\d{1,2}):(\d{2})$/);
26
+ if (twentyFourHourMatch) {
27
+ const hour = Number(twentyFourHourMatch[1]);
28
+ const minute = Number(twentyFourHourMatch[2]);
29
+ if (hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59) {
30
+ return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
31
+ }
32
+ }
33
+ throw new Error(`Invalid time string: ${value}`);
34
+ }
35
+ function normalizeIntervalSchedule(input) {
36
+ if (!Number.isFinite(input.every) || input.every <= 0) {
37
+ throw new Error('Interval schedules require a positive "every" value.');
38
+ }
39
+ if (!['minutes', 'hours', 'days', 'weeks'].includes(input.unit)) {
40
+ throw new Error(`Invalid interval unit: ${input.unit}`);
41
+ }
42
+ return {
43
+ type: 'interval',
44
+ every: Math.floor(input.every),
45
+ unit: input.unit,
46
+ };
47
+ }
48
+ function normalizeDailyAtSchedule(input, options) {
49
+ return {
50
+ type: 'daily_at',
51
+ time: normalizeTimeString(input.time),
52
+ timezone: input.timezone ?? options.defaultTimezone,
53
+ catchUpPolicy: input.catchUpPolicy ?? options.defaultCatchUpPolicy ?? 'once',
54
+ };
55
+ }
56
+ function normalizeOneShotSchedule(input, options) {
57
+ const dueAt = new Date(input.dueAt);
58
+ if (Number.isNaN(dueAt.getTime())) {
59
+ throw new Error(`Invalid one-shot dueAt: ${input.dueAt}`);
60
+ }
61
+ return {
62
+ type: 'one_shot',
63
+ dueAt: dueAt.toISOString(),
64
+ timezone: input.timezone ?? options.defaultTimezone,
65
+ catchUpPolicy: input.catchUpPolicy ?? options.defaultCatchUpPolicy ?? 'once',
66
+ };
67
+ }
68
+ export function normalizeTaskSchedule(input, options = {}) {
69
+ if (typeof input !== 'string') {
70
+ if (input.type === 'interval')
71
+ return normalizeIntervalSchedule(input);
72
+ if (input.type === 'daily_at')
73
+ return normalizeDailyAtSchedule(input, options);
74
+ return normalizeOneShotSchedule(input, options);
75
+ }
76
+ const raw = input.trim();
77
+ const lowered = raw.toLowerCase();
78
+ if (lowered === 'hourly') {
79
+ return { type: 'interval', every: 1, unit: 'hours' };
80
+ }
81
+ if (lowered === 'daily') {
82
+ return { type: 'interval', every: 1, unit: 'days' };
83
+ }
84
+ if (lowered === 'weekly') {
85
+ return { type: 'interval', every: 1, unit: 'weeks' };
86
+ }
87
+ const intervalMatch = lowered.match(/^every\s+(\d+)\s+([a-z]+)$/);
88
+ if (intervalMatch) {
89
+ const unit = INTERVAL_UNIT_ALIASES[intervalMatch[2]];
90
+ if (!unit) {
91
+ throw new Error(`Unsupported interval unit in schedule: ${input}`);
92
+ }
93
+ return { type: 'interval', every: Number(intervalMatch[1]), unit };
94
+ }
95
+ const dailyAtMatch = raw.match(/^daily\s+at\s+(.+)$/i);
96
+ if (dailyAtMatch) {
97
+ return normalizeDailyAtSchedule({ type: 'daily_at', time: dailyAtMatch[1] }, options);
98
+ }
99
+ const onceAtMatch = raw.match(/^(?:once|one[- ]shot)\s+(?:at|on)\s+(.+)$/i);
100
+ if (onceAtMatch) {
101
+ return normalizeOneShotSchedule({ type: 'one_shot', dueAt: onceAtMatch[1] }, options);
102
+ }
103
+ throw new Error(`Unsupported schedule string: ${input}`);
104
+ }
105
+ export function formatTaskSchedule(schedule) {
106
+ if (schedule.type === 'interval') {
107
+ if (schedule.every === 1) {
108
+ if (schedule.unit === 'hours')
109
+ return 'every hour';
110
+ if (schedule.unit === 'days')
111
+ return 'every day';
112
+ if (schedule.unit === 'weeks')
113
+ return 'every week';
114
+ return 'every minute';
115
+ }
116
+ return `every ${schedule.every} ${schedule.unit}`;
117
+ }
118
+ if (schedule.type === 'daily_at') {
119
+ return `daily at ${schedule.time}${schedule.timezone ? ` (${schedule.timezone})` : ''}`;
120
+ }
121
+ return `once at ${schedule.dueAt}${schedule.timezone ? ` (${schedule.timezone})` : ''}`;
122
+ }
123
+ export function taskScheduleToHint(schedule) {
124
+ if (schedule.type === 'interval') {
125
+ return formatTaskSchedule(schedule);
126
+ }
127
+ if (schedule.type === 'daily_at') {
128
+ return `daily at ${schedule.time}`;
129
+ }
130
+ return `once at ${schedule.dueAt}`;
131
+ }
132
+ function zonedParts(date, timezone) {
133
+ const formatter = new Intl.DateTimeFormat('en-CA', {
134
+ timeZone: timezone,
135
+ year: 'numeric',
136
+ month: '2-digit',
137
+ day: '2-digit',
138
+ hour: '2-digit',
139
+ minute: '2-digit',
140
+ second: '2-digit',
141
+ hour12: false,
142
+ });
143
+ const parts = formatter.formatToParts(date);
144
+ const read = (type) => Number(parts.find((part) => part.type === type)?.value ?? '0');
145
+ return {
146
+ year: read('year'),
147
+ month: read('month'),
148
+ day: read('day'),
149
+ hour: read('hour'),
150
+ minute: read('minute'),
151
+ second: read('second'),
152
+ };
153
+ }
154
+ function zonedDateTimeToUtc(year, month, day, hour, minute, second, timezone) {
155
+ let guess = Date.UTC(year, month - 1, day, hour, minute, second);
156
+ for (let i = 0; i < 3; i += 1) {
157
+ const actual = zonedParts(new Date(guess), timezone);
158
+ const desiredUtc = Date.UTC(year, month - 1, day, hour, minute, second);
159
+ const actualUtc = Date.UTC(actual.year, actual.month - 1, actual.day, actual.hour, actual.minute, actual.second);
160
+ const diff = desiredUtc - actualUtc;
161
+ if (diff === 0)
162
+ break;
163
+ guess += diff;
164
+ }
165
+ return new Date(guess);
166
+ }
167
+ function addDays(date, days) {
168
+ return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
169
+ }
170
+ export function getNextTaskRun(schedule, now = new Date(), options = {}) {
171
+ if (schedule.type === 'interval') {
172
+ const base = options.lastRunAt ? new Date(options.lastRunAt) : now;
173
+ const multiplier = schedule.unit === 'minutes' ? 60_000
174
+ : schedule.unit === 'hours' ? 60 * 60_000
175
+ : schedule.unit === 'days' ? 24 * 60 * 60_000
176
+ : 7 * 24 * 60 * 60_000;
177
+ return new Date(base.getTime() + schedule.every * multiplier);
178
+ }
179
+ if (schedule.type === 'one_shot') {
180
+ return new Date(schedule.dueAt);
181
+ }
182
+ const timezone = schedule.timezone ?? options.timezone;
183
+ if (!timezone) {
184
+ const [hour, minute] = schedule.time.split(':').map(Number);
185
+ const candidate = new Date(now);
186
+ candidate.setHours(hour, minute, 0, 0);
187
+ if (candidate <= now)
188
+ candidate.setDate(candidate.getDate() + 1);
189
+ return candidate;
190
+ }
191
+ const [hour, minute] = schedule.time.split(':').map(Number);
192
+ const parts = zonedParts(now, timezone);
193
+ let candidate = zonedDateTimeToUtc(parts.year, parts.month, parts.day, hour, minute, 0, timezone);
194
+ if (candidate <= now) {
195
+ const nextDay = addDays(candidate, 1);
196
+ const nextParts = zonedParts(nextDay, timezone);
197
+ candidate = zonedDateTimeToUtc(nextParts.year, nextParts.month, nextParts.day, hour, minute, 0, timezone);
198
+ }
199
+ return candidate;
200
+ }
201
+ //# sourceMappingURL=task-schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-schedule.js","sourceRoot":"","sources":["../src/task-schedule.ts"],"names":[],"mappings":"AASA,MAAM,qBAAqB,GAAqC;IAC9D,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,OAAO;IACX,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;CACf,CAAC;AAOF,SAAS,mBAAmB,CAAC,KAAa;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC7E,IAAI,eAAe,EAAE,CAAC;QACpB,IAAI,IAAI,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC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AQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvC,IAAI,SAAS,IAAI,GAAG;YAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACxC,IAAI,SAAS,GAAG,kBAAkB,CAChC,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,EACT,IAAI,EACJ,MAAM,EACN,CAAC,EACD,QAAQ,CACT,CAAC;IACF,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAChD,SAAS,GAAG,kBAAkB,CAC5B,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,KAAK,EACf,SAAS,CAAC,GAAG,EACb,IAAI,EACJ,MAAM,EACN,CAAC,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { TaskDefinition, TaskRunRecord } from './types.js';
2
+ export declare class TaskStore {
3
+ private readonly inMemory;
4
+ private readonly baseDir;
5
+ private readonly definitionsPath;
6
+ private readonly runsDir;
7
+ private memoryTasks;
8
+ private memoryRuns;
9
+ private definitionsCache;
10
+ private definitionsCacheMtimeMs;
11
+ constructor(basePath?: string);
12
+ list(): TaskDefinition[];
13
+ get(taskId: string): TaskDefinition | undefined;
14
+ upsert(task: TaskDefinition): TaskDefinition;
15
+ remove(taskId: string): boolean;
16
+ appendRun(taskId: string, run: Omit<TaskRunRecord, 'id' | 'taskId'>): TaskRunRecord;
17
+ listRuns(taskId: string): TaskRunRecord[];
18
+ private getRunPath;
19
+ private readDefinitionsFile;
20
+ private writeDefinitionsFile;
21
+ }
22
+ //# sourceMappingURL=task-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-store.d.ts","sourceRoot":"","sources":["../src/task-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkBhE,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAgB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,gBAAgB,CAAmC;IAC3D,OAAO,CAAC,uBAAuB,CAAuB;gBAE1C,QAAQ,CAAC,EAAE,MAAM;IAY7B,IAAI,IAAI,cAAc,EAAE;IAQxB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAU/C,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc;IAmB5C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAY/B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG,aAAa;IAmBnF,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE;IAKzC,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,oBAAoB;CAY7B"}