@ebowwa/glm-daemon 0.3.2 → 0.4.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/src/daemon.js ADDED
@@ -0,0 +1,593 @@
1
+ "use strict";
2
+ /**
3
+ * GLM Daemon - Core Daemon
4
+ *
5
+ * Main orchestrator for autonomous GLM 4.7 agents.
6
+ * Implements SLAM pattern: State → Loop → Action → Memory
7
+ */
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var __generator = (this && this.__generator) || function (thisArg, body) {
18
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
19
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
20
+ function verb(n) { return function (v) { return step([n, v]); }; }
21
+ function step(op) {
22
+ if (f) throw new TypeError("Generator is already executing.");
23
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
24
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
25
+ if (y = 0, t) op = [op[0] & 2, t.value];
26
+ switch (op[0]) {
27
+ case 0: case 1: t = op; break;
28
+ case 4: _.label++; return { value: op[1], done: false };
29
+ case 5: _.label++; y = op[1]; op = [0]; continue;
30
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
31
+ default:
32
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
33
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
35
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
36
+ if (t[2]) _.ops.pop();
37
+ _.trys.pop(); continue;
38
+ }
39
+ op = body.call(thisArg, _);
40
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
41
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
42
+ }
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.GLMDaemon = void 0;
46
+ var path_1 = require("path");
47
+ var agent_js_1 = require("./agent.js");
48
+ var hooks_js_1 = require("./hooks.js");
49
+ var tools_js_1 = require("./tools.js");
50
+ var state_js_1 = require("./state.js");
51
+ var worktree_js_1 = require("./worktree.js");
52
+ var teammates_1 = require("@ebowwa/teammates");
53
+ var client_1 = require("@ebowwa/ai/client");
54
+ var STATE_FILE = ".glm-daemon.json";
55
+ var SETTINGS_FILE = ".claude/settings.local.json";
56
+ var GLMDaemon = /** @class */ (function () {
57
+ function GLMDaemon(config) {
58
+ this.team = null;
59
+ this.subagents = new Map();
60
+ this.running = false;
61
+ this.config = config;
62
+ this.statePath = (0, path_1.join)(config.cwd, STATE_FILE);
63
+ this.client = new client_1.GLMClient();
64
+ // Initialize state
65
+ this.state = this.initializeState();
66
+ // Initialize components
67
+ this.hooks = new hooks_js_1.HookSystem(config.hooks || {});
68
+ this.tools = new tools_js_1.ToolBridge(config.tools || {});
69
+ this.stateManager = new state_js_1.StateManager(this.statePath);
70
+ this.worktreeManager = new worktree_js_1.WorktreeManager(config);
71
+ // Initialize main agent
72
+ this.agent = new agent_js_1.GLMAgent({
73
+ agentId: "glm-daemon",
74
+ name: "GLM Daemon",
75
+ prompt: this.buildSystemPrompt(),
76
+ model: config.model,
77
+ tools: this.tools.getAvailableTools(),
78
+ });
79
+ }
80
+ /**
81
+ * Initialize daemon state
82
+ */
83
+ GLMDaemon.prototype.initializeState = function () {
84
+ var now = new Date().toISOString();
85
+ return {
86
+ prompt: "", // Will be set when starting
87
+ promise: this.config.completionPromise || "TASK_COMPLETE",
88
+ iteration: 0,
89
+ maxIterations: this.config.maxIterations || 0,
90
+ startTime: now,
91
+ lastUpdate: now,
92
+ tokens: {
93
+ totalInput: 0,
94
+ totalOutput: 0,
95
+ byIteration: [],
96
+ },
97
+ filesChanged: [],
98
+ workMemory: {
99
+ completedFiles: [],
100
+ fileChecksums: {},
101
+ },
102
+ slam: {
103
+ enabled: true,
104
+ phase: "planning",
105
+ state: {
106
+ currentTask: "",
107
+ beliefs: {},
108
+ goals: [this.config.completionPromise || "TASK_COMPLETE"],
109
+ },
110
+ subtasks: [],
111
+ currentSubtask: null,
112
+ completedSubtasks: [],
113
+ memory: {
114
+ actionsTaken: [],
115
+ outcomes: {},
116
+ patterns: {},
117
+ },
118
+ },
119
+ git: {
120
+ enabled: this.config.autoCommit || this.config.autoPR || false,
121
+ autoCommit: this.config.autoCommit || false,
122
+ autoPR: this.config.autoPR || false,
123
+ baseBranch: this.config.baseBranch || "main",
124
+ useWorktree: this.config.enableWorktree || false,
125
+ branchName: "",
126
+ branchCreated: false,
127
+ currentCommit: "",
128
+ },
129
+ };
130
+ };
131
+ /**
132
+ * Build system prompt from config and state
133
+ * // TODO MOVE PROMPT TO STRUCTURED PROMPTS seed
134
+ *
135
+ */
136
+ GLMDaemon.prototype.buildSystemPrompt = function () {
137
+ return "You are an autonomous AI agent powered by GLM 4.7.\n\nYour task: ".concat(this.state.prompt, "\n\nYou work in SLAM phases:\n- Planning: Break down the task into subtasks\n- Executing: Work on the current subtask\n- Paranoid: Review your work for bugs and issues\n- Reviewing: Check quality of completed work\n- Fixing: Address any issues found\n- Committing: Commit your changes\n- Complete: Task is finished\n\nUse tools when available. Be thorough but efficient.\n\nCurrent phase: ").concat(this.state.slam.phase, "\nIteration: ").concat(this.state.iteration, "\n");
138
+ };
139
+ /**
140
+ * Start the daemon with a prompt
141
+ */
142
+ GLMDaemon.prototype.start = function (prompt) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var worktreePath, _a, _b;
145
+ var _this = this;
146
+ return __generator(this, function (_c) {
147
+ switch (_c.label) {
148
+ case 0:
149
+ if (this.running) {
150
+ throw new Error("Daemon already running");
151
+ }
152
+ this.state.prompt = prompt;
153
+ this.state.slam.state.currentTask = prompt;
154
+ this.running = true;
155
+ if (!this.config.enableWorktree) return [3 /*break*/, 3];
156
+ return [4 /*yield*/, this.worktreeManager.createWorktree()];
157
+ case 1:
158
+ worktreePath = _c.sent();
159
+ _a = this.state.git;
160
+ return [4 /*yield*/, this.worktreeManager.createBranch()];
161
+ case 2:
162
+ _a.branchName = _c.sent();
163
+ this.state.git.branchCreated = true;
164
+ _c.label = 3;
165
+ case 3:
166
+ // Initialize team for multi-agent coordination
167
+ _b = this;
168
+ return [4 /*yield*/, teammates_1.Team.create({
169
+ name: this.config.teamName,
170
+ description: "GLM daemon for: ".concat(prompt.substring(0, 50), "..."),
171
+ })];
172
+ case 4:
173
+ // Initialize team for multi-agent coordination
174
+ _b.team = _c.sent();
175
+ // Run session start hook
176
+ return [4 /*yield*/, this.hooks.execute("onSessionStart", this.state)];
177
+ case 5:
178
+ // Run session start hook
179
+ _c.sent();
180
+ // Save initial state
181
+ return [4 /*yield*/, this.stateManager.save(this.state)];
182
+ case 6:
183
+ // Save initial state
184
+ _c.sent();
185
+ // Start main loop
186
+ this.runLoop().catch(function (error) {
187
+ console.error("[GLMDaemon] Loop error:", error);
188
+ _this.running = false;
189
+ });
190
+ return [2 /*return*/, this.config.teamName];
191
+ }
192
+ });
193
+ });
194
+ };
195
+ /**
196
+ * Main daemon loop (SLAM pattern)
197
+ */
198
+ GLMDaemon.prototype.runLoop = function () {
199
+ return __awaiter(this, void 0, void 0, function () {
200
+ return __generator(this, function (_a) {
201
+ switch (_a.label) {
202
+ case 0:
203
+ if (!this.running) return [3 /*break*/, 9];
204
+ if (!this.checkCompletion()) return [3 /*break*/, 2];
205
+ return [4 /*yield*/, this.complete()];
206
+ case 1:
207
+ _a.sent();
208
+ return [3 /*break*/, 9];
209
+ case 2:
210
+ if (!(this.state.maxIterations > 0 &&
211
+ this.state.iteration >= this.state.maxIterations)) return [3 /*break*/, 4];
212
+ console.log("[GLMDaemon] Max iterations reached: ".concat(this.state.maxIterations));
213
+ return [4 /*yield*/, this.stop()];
214
+ case 3:
215
+ _a.sent();
216
+ return [3 /*break*/, 9];
217
+ case 4:
218
+ // Run iteration start hook
219
+ return [4 /*yield*/, this.hooks.execute("onIterationStart", this.state.iteration)];
220
+ case 5:
221
+ // Run iteration start hook
222
+ _a.sent();
223
+ // Execute current SLAM phase
224
+ return [4 /*yield*/, this.executePhase()];
225
+ case 6:
226
+ // Execute current SLAM phase
227
+ _a.sent();
228
+ // Update state
229
+ this.state.iteration++;
230
+ this.state.lastUpdate = new Date().toISOString();
231
+ // Save state
232
+ return [4 /*yield*/, this.stateManager.save(this.state)];
233
+ case 7:
234
+ // Save state
235
+ _a.sent();
236
+ // Run iteration end hook
237
+ return [4 /*yield*/, this.hooks.execute("onIterationEnd", this.state.iteration, null)];
238
+ case 8:
239
+ // Run iteration end hook
240
+ _a.sent();
241
+ return [3 /*break*/, 0];
242
+ case 9: return [2 /*return*/];
243
+ }
244
+ });
245
+ });
246
+ };
247
+ /**
248
+ * Execute current SLAM phase
249
+ */
250
+ GLMDaemon.prototype.executePhase = function () {
251
+ return __awaiter(this, void 0, void 0, function () {
252
+ var phase, _a;
253
+ return __generator(this, function (_b) {
254
+ switch (_b.label) {
255
+ case 0:
256
+ phase = this.state.slam.phase;
257
+ _a = phase;
258
+ switch (_a) {
259
+ case "planning": return [3 /*break*/, 1];
260
+ case "executing": return [3 /*break*/, 3];
261
+ case "paranoid": return [3 /*break*/, 5];
262
+ case "reviewing": return [3 /*break*/, 7];
263
+ case "fixing": return [3 /*break*/, 9];
264
+ case "committing": return [3 /*break*/, 11];
265
+ case "complete": return [3 /*break*/, 13];
266
+ }
267
+ return [3 /*break*/, 15];
268
+ case 1: return [4 /*yield*/, this.phasePlanning()];
269
+ case 2:
270
+ _b.sent();
271
+ return [3 /*break*/, 15];
272
+ case 3: return [4 /*yield*/, this.phaseExecuting()];
273
+ case 4:
274
+ _b.sent();
275
+ return [3 /*break*/, 15];
276
+ case 5: return [4 /*yield*/, this.phaseParanoid()];
277
+ case 6:
278
+ _b.sent();
279
+ return [3 /*break*/, 15];
280
+ case 7: return [4 /*yield*/, this.phaseReviewing()];
281
+ case 8:
282
+ _b.sent();
283
+ return [3 /*break*/, 15];
284
+ case 9: return [4 /*yield*/, this.phaseFixing()];
285
+ case 10:
286
+ _b.sent();
287
+ return [3 /*break*/, 15];
288
+ case 11: return [4 /*yield*/, this.phaseCommitting()];
289
+ case 12:
290
+ _b.sent();
291
+ return [3 /*break*/, 15];
292
+ case 13: return [4 /*yield*/, this.complete()];
293
+ case 14:
294
+ _b.sent();
295
+ return [3 /*break*/, 15];
296
+ case 15: return [2 /*return*/];
297
+ }
298
+ });
299
+ });
300
+ };
301
+ /**
302
+ * Planning phase - break down task into subtasks
303
+ */
304
+ GLMDaemon.prototype.phasePlanning = function () {
305
+ return __awaiter(this, void 0, void 0, function () {
306
+ var prompt, response, subtasks;
307
+ var _a;
308
+ return __generator(this, function (_b) {
309
+ switch (_b.label) {
310
+ case 0:
311
+ console.log("[GLMDaemon] Phase: Planning");
312
+ prompt = "".concat(this.state.prompt, "\n\nBreak this task down into 3-7 concrete subtasks.\nFor each subtask, specify:\n- Title (short description)\n- Description (what needs to be done)\n- Dependencies (which subtasks must come first)\n\nRespond with a JSON array of subtasks.\n");
313
+ return [4 /*yield*/, this.agent.execute(prompt)];
314
+ case 1:
315
+ response = _b.sent();
316
+ subtasks = this.parseSubtasks(response);
317
+ this.state.slam.subtasks = subtasks;
318
+ this.state.slam.phase = "executing";
319
+ this.state.slam.currentSubtask = ((_a = subtasks[0]) === null || _a === void 0 ? void 0 : _a.id) || null;
320
+ return [2 /*return*/];
321
+ }
322
+ });
323
+ });
324
+ };
325
+ /**
326
+ * Executing phase - work on current subtask
327
+ */
328
+ GLMDaemon.prototype.phaseExecuting = function () {
329
+ return __awaiter(this, void 0, void 0, function () {
330
+ var currentSubtaskId, subtask, prompt, response, nextSubtask;
331
+ var _this = this;
332
+ return __generator(this, function (_a) {
333
+ switch (_a.label) {
334
+ case 0:
335
+ currentSubtaskId = this.state.slam.currentSubtask;
336
+ if (!currentSubtaskId) {
337
+ this.state.slam.phase = "reviewing";
338
+ return [2 /*return*/];
339
+ }
340
+ subtask = this.state.slam.subtasks.find(function (st) { return st.id === currentSubtaskId; });
341
+ if (!subtask) {
342
+ this.state.slam.phase = "reviewing";
343
+ return [2 /*return*/];
344
+ }
345
+ console.log("[GLMDaemon] Executing subtask: ".concat(subtask.title));
346
+ prompt = "Work on this subtask: ".concat(subtask.title, "\n\n").concat(subtask.description, "\n\nUse available tools to complete the work.\nFocus on code changes, testing, and verification.\n");
347
+ return [4 /*yield*/, this.agent.execute(prompt)];
348
+ case 1:
349
+ response = _a.sent();
350
+ // Update subtask status
351
+ subtask.status = "completed";
352
+ subtask.result = response;
353
+ this.state.slam.completedSubtasks.push(currentSubtaskId);
354
+ nextSubtask = this.state.slam.subtasks.find(function (st) { return !_this.state.slam.completedSubtasks.includes(st.id); });
355
+ if (nextSubtask) {
356
+ this.state.slam.currentSubtask = nextSubtask.id;
357
+ }
358
+ else {
359
+ this.state.slam.phase = "paranoid";
360
+ }
361
+ return [2 /*return*/];
362
+ }
363
+ });
364
+ });
365
+ };
366
+ /**
367
+ * Paranoid phase - quality check after every edit
368
+ */
369
+ GLMDaemon.prototype.phaseParanoid = function () {
370
+ return __awaiter(this, void 0, void 0, function () {
371
+ var prompt, response, hasIssues;
372
+ return __generator(this, function (_a) {
373
+ switch (_a.label) {
374
+ case 0:
375
+ console.log("[GLMDaemon] Phase: Paranoid (quality check)");
376
+ prompt = "Review the changes made in this session for:\n- Bugs or errors\n- Edge cases not handled\n- Security vulnerabilities\n- Performance issues\n- Breaking changes\n\nTask: ".concat(this.state.prompt, "\n\nChanges made:\n").concat(this.state.filesChanged.map(function (f) { return "- ".concat(f); }).join("\n"), "\n\nBe thorough. If issues found, we'll fix them. If clean, we proceed to review.\n");
377
+ return [4 /*yield*/, this.agent.execute(prompt)];
378
+ case 1:
379
+ response = _a.sent();
380
+ hasIssues = this.detectIssues(response);
381
+ if (hasIssues) {
382
+ this.state.slam.phase = "fixing";
383
+ }
384
+ else {
385
+ this.state.slam.phase = "reviewing";
386
+ }
387
+ return [2 /*return*/];
388
+ }
389
+ });
390
+ });
391
+ };
392
+ /**
393
+ * Reviewing phase - final quality review
394
+ */
395
+ GLMDaemon.prototype.phaseReviewing = function () {
396
+ return __awaiter(this, void 0, void 0, function () {
397
+ var prompt, response;
398
+ return __generator(this, function (_a) {
399
+ switch (_a.label) {
400
+ case 0:
401
+ console.log("[GLMDaemon] Phase: Reviewing");
402
+ prompt = "Final review of the completed work.\n\nTask: ".concat(this.state.prompt, "\nCompletion promise: ").concat(this.state.promise, "\n\nDoes the implementation fully satisfy the completion promise?\nAre there any remaining issues or TODOs?\n\nIf complete and clean, respond with \"APPROVED\".\nOtherwise, list remaining issues.\n");
403
+ return [4 /*yield*/, this.agent.execute(prompt)];
404
+ case 1:
405
+ response = _a.sent();
406
+ if (response.includes("APPROVED")) {
407
+ this.state.slam.phase = "committing";
408
+ }
409
+ else {
410
+ this.state.slam.phase = "fixing";
411
+ }
412
+ return [2 /*return*/];
413
+ }
414
+ });
415
+ });
416
+ };
417
+ /**
418
+ * Fixing phase - fix issues found
419
+ */
420
+ GLMDaemon.prototype.phaseFixing = function () {
421
+ return __awaiter(this, void 0, void 0, function () {
422
+ var prompt;
423
+ return __generator(this, function (_a) {
424
+ switch (_a.label) {
425
+ case 0:
426
+ console.log("[GLMDaemon] Phase: Fixing");
427
+ prompt = "Fix the issues identified in the review.\n\nUse tools to make necessary changes.\nTest your fixes thoroughly.\n";
428
+ return [4 /*yield*/, this.agent.execute(prompt)];
429
+ case 1:
430
+ _a.sent();
431
+ this.state.slam.phase = "paranoid"; // Re-check after fixes
432
+ return [2 /*return*/];
433
+ }
434
+ });
435
+ });
436
+ };
437
+ /**
438
+ * Committing phase - commit changes
439
+ */
440
+ GLMDaemon.prototype.phaseCommitting = function () {
441
+ return __awaiter(this, void 0, void 0, function () {
442
+ return __generator(this, function (_a) {
443
+ switch (_a.label) {
444
+ case 0:
445
+ console.log("[GLMDaemon] Phase: Committing");
446
+ if (!this.state.git.autoCommit) return [3 /*break*/, 2];
447
+ // Commit changes via worktree manager
448
+ return [4 /*yield*/, this.worktreeManager.commitChanges({
449
+ message: "feat: ".concat(this.state.prompt.substring(0, 50)),
450
+ files: this.state.filesChanged,
451
+ })];
452
+ case 1:
453
+ // Commit changes via worktree manager
454
+ _a.sent();
455
+ _a.label = 2;
456
+ case 2:
457
+ this.state.slam.phase = "complete";
458
+ return [2 /*return*/];
459
+ }
460
+ });
461
+ });
462
+ };
463
+ /**
464
+ * Complete the daemon run
465
+ */
466
+ GLMDaemon.prototype.complete = function () {
467
+ return __awaiter(this, void 0, void 0, function () {
468
+ return __generator(this, function (_a) {
469
+ switch (_a.label) {
470
+ case 0:
471
+ console.log("[GLMDaemon] Task complete!");
472
+ this.state.slam.phase = "complete";
473
+ this.running = false;
474
+ // Run session end hook
475
+ return [4 /*yield*/, this.hooks.execute("onSessionEnd", this.state)];
476
+ case 1:
477
+ // Run session end hook
478
+ _a.sent();
479
+ // Save final state
480
+ return [4 /*yield*/, this.stateManager.save(this.state)];
481
+ case 2:
482
+ // Save final state
483
+ _a.sent();
484
+ if (!this.state.git.autoPR) return [3 /*break*/, 4];
485
+ return [4 /*yield*/, this.worktreeManager.createPullRequest({
486
+ title: this.state.prompt.substring(0, 50),
487
+ body: "Completes: ".concat(this.state.promise),
488
+ })];
489
+ case 3:
490
+ _a.sent();
491
+ _a.label = 4;
492
+ case 4: return [2 /*return*/];
493
+ }
494
+ });
495
+ });
496
+ };
497
+ /**
498
+ * Stop the daemon
499
+ */
500
+ GLMDaemon.prototype.stop = function () {
501
+ return __awaiter(this, void 0, void 0, function () {
502
+ return __generator(this, function (_a) {
503
+ switch (_a.label) {
504
+ case 0:
505
+ console.log("[GLMDaemon] Stopping...");
506
+ this.running = false;
507
+ if (!this.team) return [3 /*break*/, 2];
508
+ return [4 /*yield*/, this.team.broadcast("team-lead", "Daemon stopping")];
509
+ case 1:
510
+ _a.sent();
511
+ _a.label = 2;
512
+ case 2:
513
+ // Save final state
514
+ return [4 /*yield*/, this.stateManager.save(this.state)];
515
+ case 3:
516
+ // Save final state
517
+ _a.sent();
518
+ return [2 /*return*/];
519
+ }
520
+ });
521
+ });
522
+ };
523
+ /**
524
+ * Get daemon status
525
+ */
526
+ GLMDaemon.prototype.getStatus = function () {
527
+ return {
528
+ id: this.config.teamName,
529
+ status: this.running ? "running" : "stopped",
530
+ phase: this.state.slam.phase,
531
+ iteration: this.state.iteration,
532
+ prompt: this.state.prompt,
533
+ currentTask: this.state.slam.state.currentTask,
534
+ totalSubtasks: this.state.slam.subtasks.length,
535
+ completedSubtasks: this.state.slam.completedSubtasks.length,
536
+ startedAt: this.state.startTime,
537
+ lastUpdate: this.state.lastUpdate,
538
+ };
539
+ };
540
+ /**
541
+ * Parse subtasks from agent response
542
+ */
543
+ GLMDaemon.prototype.parseSubtasks = function (response) {
544
+ try {
545
+ var jsonMatch = response.match(/\[[\s\S]*\]/);
546
+ if (jsonMatch) {
547
+ var parsed = JSON.parse(jsonMatch[0]);
548
+ return parsed.map(function (st, idx) { return ({
549
+ id: st.id || "subtask-".concat(idx),
550
+ title: st.title || st.task || "Subtask ".concat(idx + 1),
551
+ description: st.description || "",
552
+ status: "pending",
553
+ dependencies: st.dependencies || [],
554
+ }); });
555
+ }
556
+ }
557
+ catch (_a) {
558
+ // Fallback: create single subtask from prompt
559
+ return [{
560
+ id: "subtask-0",
561
+ title: this.state.prompt.substring(0, 50),
562
+ description: this.state.prompt,
563
+ status: "pending",
564
+ }];
565
+ }
566
+ return [];
567
+ };
568
+ /**
569
+ * Detect issues in paranoid check response
570
+ */
571
+ GLMDaemon.prototype.detectIssues = function (response) {
572
+ var issueKeywords = [
573
+ "bug", "error", "issue", "problem", "vulnerability",
574
+ "fix", "improve", "missing", "incomplete", "broken"
575
+ ];
576
+ var lower = response.toLowerCase();
577
+ return issueKeywords.some(function (kw) { return lower.includes(kw); });
578
+ };
579
+ /**
580
+ * Check if completion promise is met
581
+ */
582
+ GLMDaemon.prototype.checkCompletion = function () {
583
+ var _this = this;
584
+ // Simple check: all subtasks complete
585
+ var allComplete = this.state.slam.subtasks.length > 0 &&
586
+ this.state.slam.subtasks.every(function (st) {
587
+ return _this.state.slam.completedSubtasks.includes(st.id);
588
+ });
589
+ return allComplete || this.state.slam.phase === "complete";
590
+ };
591
+ return GLMDaemon;
592
+ }());
593
+ exports.GLMDaemon = GLMDaemon;