@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/package.json +5 -5
- package/src/agent.js +166 -0
- package/src/builtin-tools.js +349 -0
- package/src/channels/base.js +509 -0
- package/src/channels/discord.js +374 -0
- package/src/channels/index.js +186 -0
- package/src/channels/telegram.js +395 -0
- package/src/daemon.js +593 -0
- package/src/daemon.ts +188 -1
- package/src/hooks.js +145 -0
- package/src/hooks.ts +3 -0
- package/src/index.js +123 -0
- package/src/memory.js +323 -0
- package/src/state.js +168 -0
- package/src/tools.js +192 -0
- package/src/types.js +21 -0
- package/src/types.ts +62 -0
- package/src/worktree.js +195 -0
package/src/daemon.ts
CHANGED
|
@@ -111,6 +111,13 @@ export class GLMDaemon {
|
|
|
111
111
|
branchCreated: false,
|
|
112
112
|
currentCommit: "",
|
|
113
113
|
},
|
|
114
|
+
reflection: {
|
|
115
|
+
toolCount: 0,
|
|
116
|
+
totalToolCount: 0,
|
|
117
|
+
checkpointCount: 0,
|
|
118
|
+
lastReflection: null,
|
|
119
|
+
summaries: [],
|
|
120
|
+
},
|
|
114
121
|
};
|
|
115
122
|
}
|
|
116
123
|
|
|
@@ -181,7 +188,7 @@ Iteration: ${this.state.iteration}
|
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
/**
|
|
184
|
-
* Main daemon loop (SLAM pattern)
|
|
191
|
+
* Main daemon loop (SLAM pattern with reflection checkpoints)
|
|
185
192
|
*/
|
|
186
193
|
private async runLoop(): Promise<void> {
|
|
187
194
|
while (this.running) {
|
|
@@ -201,6 +208,12 @@ Iteration: ${this.state.iteration}
|
|
|
201
208
|
break;
|
|
202
209
|
}
|
|
203
210
|
|
|
211
|
+
// Check for reflection checkpoint (tool limit hit)
|
|
212
|
+
if (this.state.slam.phase === "reflecting") {
|
|
213
|
+
await this.executePhase();
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
|
|
204
217
|
// Run iteration start hook
|
|
205
218
|
await this.hooks.execute("onIterationStart", this.state.iteration);
|
|
206
219
|
|
|
@@ -232,6 +245,9 @@ Iteration: ${this.state.iteration}
|
|
|
232
245
|
case "executing":
|
|
233
246
|
await this.phaseExecuting();
|
|
234
247
|
break;
|
|
248
|
+
case "reflecting":
|
|
249
|
+
await this.phaseReflecting();
|
|
250
|
+
break;
|
|
235
251
|
case "paranoid":
|
|
236
252
|
await this.phaseParanoid();
|
|
237
253
|
break;
|
|
@@ -320,6 +336,130 @@ Focus on code changes, testing, and verification.
|
|
|
320
336
|
}
|
|
321
337
|
}
|
|
322
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Reflecting phase - TL;DR checkpoint after N tools
|
|
341
|
+
* Pauses, summarizes progress, saves state, continues
|
|
342
|
+
*/
|
|
343
|
+
private async phaseReflecting(): Promise<void> {
|
|
344
|
+
const reflectionConfig = this.config.reflection || {
|
|
345
|
+
enabled: true,
|
|
346
|
+
toolLimit: 50,
|
|
347
|
+
autoContinue: true,
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
console.log(`[GLMDaemon] Phase: Reflecting (checkpoint #${this.state.reflection.checkpointCount + 1})`);
|
|
351
|
+
console.log(`[GLMDaemon] Tools used this chunk: ${this.state.reflection.toolCount}`);
|
|
352
|
+
|
|
353
|
+
const previousPhase = this.state.slam.previousPhase || "executing";
|
|
354
|
+
|
|
355
|
+
const prompt = `REFLECTION CHECKPOINT #${this.state.reflection.checkpointCount + 1}
|
|
356
|
+
|
|
357
|
+
You have used ${this.state.reflection.toolCount} tools. Pause and reflect.
|
|
358
|
+
|
|
359
|
+
Task: ${this.state.prompt}
|
|
360
|
+
Current Phase (before reflection): ${previousPhase}
|
|
361
|
+
Iteration: ${this.state.iteration}
|
|
362
|
+
Subtasks: ${this.state.slam.completedSubtasks.length}/${this.state.slam.subtasks.length} complete
|
|
363
|
+
|
|
364
|
+
Files changed: ${this.state.filesChanged.length > 0 ? this.state.filesChanged.join(", ") : "none"}
|
|
365
|
+
|
|
366
|
+
Generate a TL;DR summary in this JSON format:
|
|
367
|
+
{
|
|
368
|
+
"summary": "1-2 sentence summary of progress",
|
|
369
|
+
"accomplishments": ["what was done"],
|
|
370
|
+
"nextSteps": ["what needs to be done next"],
|
|
371
|
+
"issues": ["any blockers or problems"]
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
Be concise. Focus on what matters for continuing the task.
|
|
375
|
+
`;
|
|
376
|
+
|
|
377
|
+
const response = await this.agent.execute(prompt);
|
|
378
|
+
const summary = this.parseReflectionSummary(response, previousPhase);
|
|
379
|
+
|
|
380
|
+
// Update reflection state
|
|
381
|
+
this.state.reflection.checkpointCount++;
|
|
382
|
+
this.state.reflection.lastReflection = new Date().toISOString();
|
|
383
|
+
this.state.reflection.toolCount = 0; // Reset for next chunk
|
|
384
|
+
this.state.reflection.summaries.push(summary);
|
|
385
|
+
|
|
386
|
+
// Log the reflection
|
|
387
|
+
console.log(`[GLMDaemon] TL;DR: ${summary.summary}`);
|
|
388
|
+
console.log(`[GLMDaemon] Accomplishments: ${summary.accomplishments.join(", ")}`);
|
|
389
|
+
console.log(`[GLMDaemon] Next: ${summary.nextSteps.join(", ")}`);
|
|
390
|
+
|
|
391
|
+
// Run reflection hook
|
|
392
|
+
await this.hooks.execute("onReflection", this.state, summary);
|
|
393
|
+
|
|
394
|
+
// Save state
|
|
395
|
+
await this.stateManager.save(this.state);
|
|
396
|
+
|
|
397
|
+
// Return to previous phase (or continue executing)
|
|
398
|
+
if (reflectionConfig.autoContinue) {
|
|
399
|
+
this.state.slam.phase = previousPhase;
|
|
400
|
+
console.log(`[GLMDaemon] Continuing in phase: ${previousPhase}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Parse reflection summary from agent response
|
|
406
|
+
*/
|
|
407
|
+
private parseReflectionSummary(response: string, phase: string): import("./types.js").GLMReflectionSummary {
|
|
408
|
+
try {
|
|
409
|
+
const jsonMatch = response.match(/\{[\s\S]*\}/);
|
|
410
|
+
if (jsonMatch) {
|
|
411
|
+
const parsed = JSON.parse(jsonMatch[0]);
|
|
412
|
+
return {
|
|
413
|
+
checkpoint: this.state.reflection.checkpointCount + 1,
|
|
414
|
+
timestamp: new Date().toISOString(),
|
|
415
|
+
toolsUsed: this.state.reflection.toolCount,
|
|
416
|
+
phase: phase as import("./types.js").GLMPhase,
|
|
417
|
+
summary: parsed.summary || "Progress made",
|
|
418
|
+
accomplishments: parsed.accomplishments || [],
|
|
419
|
+
nextSteps: parsed.nextSteps || [],
|
|
420
|
+
issues: parsed.issues || [],
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
} catch {
|
|
424
|
+
// Fallback
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
checkpoint: this.state.reflection.checkpointCount + 1,
|
|
429
|
+
timestamp: new Date().toISOString(),
|
|
430
|
+
toolsUsed: this.state.reflection.toolCount,
|
|
431
|
+
phase: phase as import("./types.js").GLMPhase,
|
|
432
|
+
summary: response.substring(0, 200),
|
|
433
|
+
accomplishments: [],
|
|
434
|
+
nextSteps: [],
|
|
435
|
+
issues: [],
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Increment tool count and check for reflection trigger
|
|
441
|
+
*/
|
|
442
|
+
incrementToolCount(): boolean {
|
|
443
|
+
const reflectionConfig = this.config.reflection || {
|
|
444
|
+
enabled: true,
|
|
445
|
+
toolLimit: 50,
|
|
446
|
+
autoContinue: true,
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
this.state.reflection.toolCount++;
|
|
450
|
+
this.state.reflection.totalToolCount++;
|
|
451
|
+
|
|
452
|
+
// Check if we hit the limit
|
|
453
|
+
if (reflectionConfig.enabled && this.state.reflection.toolCount >= reflectionConfig.toolLimit) {
|
|
454
|
+
// Store current phase to return after reflection
|
|
455
|
+
this.state.slam.previousPhase = this.state.slam.phase;
|
|
456
|
+
this.state.slam.phase = "reflecting";
|
|
457
|
+
return true; // Reflection triggered
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
|
|
323
463
|
/**
|
|
324
464
|
* Paranoid phase - quality check after every edit
|
|
325
465
|
*/
|
|
@@ -468,6 +608,53 @@ Test your fixes thoroughly.
|
|
|
468
608
|
};
|
|
469
609
|
}
|
|
470
610
|
|
|
611
|
+
/**
|
|
612
|
+
* Get reflection status and summaries
|
|
613
|
+
*/
|
|
614
|
+
getReflectionStatus(): {
|
|
615
|
+
enabled: boolean;
|
|
616
|
+
toolLimit: number;
|
|
617
|
+
toolCount: number;
|
|
618
|
+
totalToolCount: number;
|
|
619
|
+
checkpointCount: number;
|
|
620
|
+
lastReflection: string | null;
|
|
621
|
+
summaries: import("./types.js").GLMReflectionSummary[];
|
|
622
|
+
} {
|
|
623
|
+
const config = this.config.reflection || {
|
|
624
|
+
enabled: true,
|
|
625
|
+
toolLimit: 50,
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
return {
|
|
629
|
+
enabled: config.enabled,
|
|
630
|
+
toolLimit: config.toolLimit,
|
|
631
|
+
toolCount: this.state.reflection.toolCount,
|
|
632
|
+
totalToolCount: this.state.reflection.totalToolCount,
|
|
633
|
+
checkpointCount: this.state.reflection.checkpointCount,
|
|
634
|
+
lastReflection: this.state.reflection.lastReflection,
|
|
635
|
+
summaries: this.state.reflection.summaries,
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Force a reflection checkpoint now
|
|
641
|
+
*/
|
|
642
|
+
async forceReflection(): Promise<import("./types.js").GLMReflectionSummary | null> {
|
|
643
|
+
if (!this.running) {
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Store current phase
|
|
648
|
+
this.state.slam.previousPhase = this.state.slam.phase;
|
|
649
|
+
this.state.slam.phase = "reflecting";
|
|
650
|
+
|
|
651
|
+
// Execute reflection
|
|
652
|
+
await this.phaseReflecting();
|
|
653
|
+
|
|
654
|
+
// Return the latest summary
|
|
655
|
+
return this.state.reflection.summaries[this.state.reflection.summaries.length - 1] || null;
|
|
656
|
+
}
|
|
657
|
+
|
|
471
658
|
/**
|
|
472
659
|
* Parse subtasks from agent response
|
|
473
660
|
*/
|
package/src/hooks.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GLM Daemon - Hook System
|
|
4
|
+
*
|
|
5
|
+
* Implements hook lifecycle for daemon events.
|
|
6
|
+
* Based on Claude Code's hook system.
|
|
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.HookSystem = void 0;
|
|
46
|
+
var HookSystem = /** @class */ (function () {
|
|
47
|
+
function HookSystem(config) {
|
|
48
|
+
this.hooks = new Map();
|
|
49
|
+
// Register hooks from config
|
|
50
|
+
if (config.onSessionStart) {
|
|
51
|
+
this.register("onSessionStart", config.onSessionStart);
|
|
52
|
+
}
|
|
53
|
+
if (config.onSessionEnd) {
|
|
54
|
+
this.register("onSessionEnd", config.onSessionEnd);
|
|
55
|
+
}
|
|
56
|
+
if (config.onPreToolUse) {
|
|
57
|
+
this.register("onPreToolUse", config.onPreToolUse);
|
|
58
|
+
}
|
|
59
|
+
if (config.onPostToolUse) {
|
|
60
|
+
this.register("onPostToolUse", config.onPostToolUse);
|
|
61
|
+
}
|
|
62
|
+
if (config.onSubagentStart) {
|
|
63
|
+
this.register("onSubagentStart", config.onSubagentStart);
|
|
64
|
+
}
|
|
65
|
+
if (config.onSubagentStop) {
|
|
66
|
+
this.register("onSubagentStop", config.onSubagentStop);
|
|
67
|
+
}
|
|
68
|
+
if (config.onIterationStart) {
|
|
69
|
+
this.register("onIterationStart", config.onIterationStart);
|
|
70
|
+
}
|
|
71
|
+
if (config.onIterationEnd) {
|
|
72
|
+
this.register("onIterationEnd", config.onIterationEnd);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Register a hook handler
|
|
77
|
+
*/
|
|
78
|
+
HookSystem.prototype.register = function (event, handler) {
|
|
79
|
+
if (!this.hooks.has(event)) {
|
|
80
|
+
this.hooks.set(event, []);
|
|
81
|
+
}
|
|
82
|
+
this.hooks.get(event).push(handler);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Execute all handlers for an event
|
|
86
|
+
*/
|
|
87
|
+
HookSystem.prototype.execute = function (event) {
|
|
88
|
+
var args = [];
|
|
89
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
90
|
+
args[_i - 1] = arguments[_i];
|
|
91
|
+
}
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var handlers, _a, handlers_1, handler, error_1;
|
|
94
|
+
return __generator(this, function (_b) {
|
|
95
|
+
switch (_b.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
handlers = this.hooks.get(event);
|
|
98
|
+
if (!handlers) {
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
_a = 0, handlers_1 = handlers;
|
|
102
|
+
_b.label = 1;
|
|
103
|
+
case 1:
|
|
104
|
+
if (!(_a < handlers_1.length)) return [3 /*break*/, 6];
|
|
105
|
+
handler = handlers_1[_a];
|
|
106
|
+
_b.label = 2;
|
|
107
|
+
case 2:
|
|
108
|
+
_b.trys.push([2, 4, , 5]);
|
|
109
|
+
return [4 /*yield*/, handler.apply(void 0, args)];
|
|
110
|
+
case 3:
|
|
111
|
+
_b.sent();
|
|
112
|
+
return [3 /*break*/, 5];
|
|
113
|
+
case 4:
|
|
114
|
+
error_1 = _b.sent();
|
|
115
|
+
console.error("[HookSystem] Error in ".concat(event, ":"), error_1);
|
|
116
|
+
return [3 /*break*/, 5];
|
|
117
|
+
case 5:
|
|
118
|
+
_a++;
|
|
119
|
+
return [3 /*break*/, 1];
|
|
120
|
+
case 6: return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Remove all handlers for an event
|
|
127
|
+
*/
|
|
128
|
+
HookSystem.prototype.clear = function (event) {
|
|
129
|
+
this.hooks.delete(event);
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Remove all hooks
|
|
133
|
+
*/
|
|
134
|
+
HookSystem.prototype.clearAll = function () {
|
|
135
|
+
this.hooks.clear();
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Get registered events
|
|
139
|
+
*/
|
|
140
|
+
HookSystem.prototype.getEvents = function () {
|
|
141
|
+
return Array.from(this.hooks.keys());
|
|
142
|
+
};
|
|
143
|
+
return HookSystem;
|
|
144
|
+
}());
|
|
145
|
+
exports.HookSystem = HookSystem;
|
package/src/hooks.ts
CHANGED
|
@@ -40,6 +40,9 @@ export class HookSystem {
|
|
|
40
40
|
if (config.onIterationEnd) {
|
|
41
41
|
this.register("onIterationEnd", config.onIterationEnd as GLMHookHandler);
|
|
42
42
|
}
|
|
43
|
+
if (config.onReflection) {
|
|
44
|
+
this.register("onReflection", config.onReflection as GLMHookHandler);
|
|
45
|
+
}
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
package/src/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GLM Daemon - Autonomous GLM 4.7 Agent Daemon
|
|
4
|
+
*
|
|
5
|
+
* A daemon for autonomous AI agents powered by GLM 4.7.
|
|
6
|
+
* Implements SLAM pattern (State → Loop → Action → Memory).
|
|
7
|
+
* Supports hooks, tools via MCP, multi-agent coordination, and communication channels.
|
|
8
|
+
*
|
|
9
|
+
* @module @ebowwa/glm-daemon
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
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);
|
|
36
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.ChannelRegistry = exports.DiscordChannel = exports.TelegramChannel = exports.BaseChannel = exports.StringConversationMemory = exports.NumericConversationMemory = exports.ConversationMemory = exports.executeBuiltinTool = exports.toGLMFormat = exports.getBuiltinToolNames = exports.getBuiltinTool = exports.BUILTIN_TOOLS = exports.WorktreeManager = exports.StateManager = exports.ToolBridge = exports.HookSystem = exports.GLMAgent = exports.GLMDaemon = void 0;
|
|
63
|
+
exports.createGLMDaemon = createGLMDaemon;
|
|
64
|
+
exports.startGLMDaemon = startGLMDaemon;
|
|
65
|
+
// Main daemon class
|
|
66
|
+
var daemon_js_1 = require("./daemon.js");
|
|
67
|
+
Object.defineProperty(exports, "GLMDaemon", { enumerable: true, get: function () { return daemon_js_1.GLMDaemon; } });
|
|
68
|
+
// Agent class
|
|
69
|
+
var agent_js_1 = require("./agent.js");
|
|
70
|
+
Object.defineProperty(exports, "GLMAgent", { enumerable: true, get: function () { return agent_js_1.GLMAgent; } });
|
|
71
|
+
// Supporting systems
|
|
72
|
+
var hooks_js_1 = require("./hooks.js");
|
|
73
|
+
Object.defineProperty(exports, "HookSystem", { enumerable: true, get: function () { return hooks_js_1.HookSystem; } });
|
|
74
|
+
var tools_js_1 = require("./tools.js");
|
|
75
|
+
Object.defineProperty(exports, "ToolBridge", { enumerable: true, get: function () { return tools_js_1.ToolBridge; } });
|
|
76
|
+
var state_js_1 = require("./state.js");
|
|
77
|
+
Object.defineProperty(exports, "StateManager", { enumerable: true, get: function () { return state_js_1.StateManager; } });
|
|
78
|
+
var worktree_js_1 = require("./worktree.js");
|
|
79
|
+
Object.defineProperty(exports, "WorktreeManager", { enumerable: true, get: function () { return worktree_js_1.WorktreeManager; } });
|
|
80
|
+
// Built-in tools
|
|
81
|
+
var builtin_tools_js_1 = require("./builtin-tools.js");
|
|
82
|
+
Object.defineProperty(exports, "BUILTIN_TOOLS", { enumerable: true, get: function () { return builtin_tools_js_1.BUILTIN_TOOLS; } });
|
|
83
|
+
Object.defineProperty(exports, "getBuiltinTool", { enumerable: true, get: function () { return builtin_tools_js_1.getBuiltinTool; } });
|
|
84
|
+
Object.defineProperty(exports, "getBuiltinToolNames", { enumerable: true, get: function () { return builtin_tools_js_1.getBuiltinToolNames; } });
|
|
85
|
+
Object.defineProperty(exports, "toGLMFormat", { enumerable: true, get: function () { return builtin_tools_js_1.toGLMFormat; } });
|
|
86
|
+
Object.defineProperty(exports, "executeBuiltinTool", { enumerable: true, get: function () { return builtin_tools_js_1.executeBuiltinTool; } });
|
|
87
|
+
// Memory systems
|
|
88
|
+
var memory_js_1 = require("./memory.js");
|
|
89
|
+
Object.defineProperty(exports, "ConversationMemory", { enumerable: true, get: function () { return memory_js_1.ConversationMemory; } });
|
|
90
|
+
Object.defineProperty(exports, "NumericConversationMemory", { enumerable: true, get: function () { return memory_js_1.NumericConversationMemory; } });
|
|
91
|
+
Object.defineProperty(exports, "StringConversationMemory", { enumerable: true, get: function () { return memory_js_1.StringConversationMemory; } });
|
|
92
|
+
// Communication channels
|
|
93
|
+
var index_js_1 = require("./channels/index.js");
|
|
94
|
+
Object.defineProperty(exports, "BaseChannel", { enumerable: true, get: function () { return index_js_1.BaseChannel; } });
|
|
95
|
+
Object.defineProperty(exports, "TelegramChannel", { enumerable: true, get: function () { return index_js_1.TelegramChannel; } });
|
|
96
|
+
Object.defineProperty(exports, "DiscordChannel", { enumerable: true, get: function () { return index_js_1.DiscordChannel; } });
|
|
97
|
+
Object.defineProperty(exports, "ChannelRegistry", { enumerable: true, get: function () { return index_js_1.ChannelRegistry; } });
|
|
98
|
+
// Types
|
|
99
|
+
__exportStar(require("./types.js"), exports);
|
|
100
|
+
// Convenience function to create and start a daemon
|
|
101
|
+
var daemon_js_2 = require("./daemon.js");
|
|
102
|
+
function createGLMDaemon(config) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var daemon;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
daemon = new daemon_js_2.GLMDaemon(config);
|
|
107
|
+
return [2 /*return*/, daemon];
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function startGLMDaemon(config, prompt) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var daemon;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
daemon = new daemon_js_2.GLMDaemon(config);
|
|
118
|
+
return [4 /*yield*/, daemon.start(prompt)];
|
|
119
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|