@ebowwa/daemons 0.5.1 → 0.7.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/dist/core.d.ts +89 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +346 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +16 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -125305
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +28 -273
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +14 -65
- package/src/core.ts +476 -0
- package/src/index.ts +23 -101
- package/src/types.ts +24 -301
- package/dist/agent.d.ts +0 -37
- package/dist/agent.d.ts.map +0 -1
- package/dist/bin/discord-cli.js +0 -124083
- package/dist/bin/manager.js +0 -143
- package/dist/bin/telegram-cli.js +0 -124079
- package/dist/channels/base.d.ts +0 -163
- package/dist/channels/base.d.ts.map +0 -1
- package/dist/channels/discord.d.ts +0 -61
- package/dist/channels/discord.d.ts.map +0 -1
- package/dist/channels/index.d.ts +0 -55
- package/dist/channels/index.d.ts.map +0 -1
- package/dist/channels/telegram.d.ts +0 -113
- package/dist/channels/telegram.d.ts.map +0 -1
- package/dist/daemon.d.ts +0 -119
- package/dist/daemon.d.ts.map +0 -1
- package/dist/hooks.d.ts +0 -34
- package/dist/hooks.d.ts.map +0 -1
- package/dist/memory.d.ts +0 -151
- package/dist/memory.d.ts.map +0 -1
- package/dist/skills/coding/commit.d.ts +0 -31
- package/dist/skills/coding/commit.d.ts.map +0 -1
- package/dist/skills/coding/execute-subtask.d.ts +0 -30
- package/dist/skills/coding/execute-subtask.d.ts.map +0 -1
- package/dist/skills/coding/fix-issues.d.ts +0 -29
- package/dist/skills/coding/fix-issues.d.ts.map +0 -1
- package/dist/skills/coding/index.d.ts +0 -21
- package/dist/skills/coding/index.d.ts.map +0 -1
- package/dist/skills/coding/plan-task.d.ts +0 -38
- package/dist/skills/coding/plan-task.d.ts.map +0 -1
- package/dist/skills/coding/quality-check.d.ts +0 -35
- package/dist/skills/coding/quality-check.d.ts.map +0 -1
- package/dist/skills/index.d.ts +0 -38
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/registry.d.ts +0 -95
- package/dist/skills/registry.d.ts.map +0 -1
- package/dist/skills/shared/index.d.ts +0 -16
- package/dist/skills/shared/index.d.ts.map +0 -1
- package/dist/skills/shared/reflect.d.ts +0 -42
- package/dist/skills/shared/reflect.d.ts.map +0 -1
- package/dist/skills/shared/review.d.ts +0 -42
- package/dist/skills/shared/review.d.ts.map +0 -1
- package/dist/skills/shared/trajectory.d.ts +0 -80
- package/dist/skills/shared/trajectory.d.ts.map +0 -1
- package/dist/skills/trading/analyze-market.d.ts +0 -43
- package/dist/skills/trading/analyze-market.d.ts.map +0 -1
- package/dist/skills/trading/check-risk.d.ts +0 -33
- package/dist/skills/trading/check-risk.d.ts.map +0 -1
- package/dist/skills/trading/execute-trade.d.ts +0 -38
- package/dist/skills/trading/execute-trade.d.ts.map +0 -1
- package/dist/skills/trading/generate-signal.d.ts +0 -57
- package/dist/skills/trading/generate-signal.d.ts.map +0 -1
- package/dist/skills/trading/index.d.ts +0 -21
- package/dist/skills/trading/index.d.ts.map +0 -1
- package/dist/skills/trading/monitor-position.d.ts +0 -37
- package/dist/skills/trading/monitor-position.d.ts.map +0 -1
- package/dist/skills/types.d.ts +0 -173
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/skills/workflows.d.ts +0 -36
- package/dist/skills/workflows.d.ts.map +0 -1
- package/dist/state.d.ts +0 -31
- package/dist/state.d.ts.map +0 -1
- package/dist/tools.d.ts +0 -42
- package/dist/tools.d.ts.map +0 -1
- package/dist/workflow.d.ts +0 -182
- package/dist/workflow.d.ts.map +0 -1
- package/dist/workflows/coding.d.ts +0 -79
- package/dist/workflows/coding.d.ts.map +0 -1
- package/dist/workflows/index.d.ts +0 -24
- package/dist/workflows/index.d.ts.map +0 -1
- package/dist/workflows/trading.d.ts +0 -72
- package/dist/workflows/trading.d.ts.map +0 -1
- package/src/agent.ts +0 -111
- package/src/channels/base.ts +0 -574
- package/src/channels/discord.ts +0 -306
- package/src/channels/index.ts +0 -169
- package/src/channels/telegram.ts +0 -316
- package/src/daemon.ts +0 -534
- package/src/hooks.ts +0 -97
- package/src/memory.ts +0 -369
- package/src/skills/coding/commit.ts +0 -202
- package/src/skills/coding/execute-subtask.ts +0 -136
- package/src/skills/coding/fix-issues.ts +0 -126
- package/src/skills/coding/index.ts +0 -26
- package/src/skills/coding/plan-task.ts +0 -158
- package/src/skills/coding/quality-check.ts +0 -155
- package/src/skills/index.ts +0 -65
- package/src/skills/registry.ts +0 -380
- package/src/skills/shared/index.ts +0 -21
- package/src/skills/shared/reflect.ts +0 -156
- package/src/skills/shared/review.ts +0 -201
- package/src/skills/shared/trajectory.ts +0 -326
- package/src/skills/trading/analyze-market.ts +0 -144
- package/src/skills/trading/check-risk.ts +0 -176
- package/src/skills/trading/execute-trade.ts +0 -185
- package/src/skills/trading/generate-signal.ts +0 -160
- package/src/skills/trading/index.ts +0 -26
- package/src/skills/trading/monitor-position.ts +0 -179
- package/src/skills/types.ts +0 -235
- package/src/skills/workflows.ts +0 -340
- package/src/state.ts +0 -77
- package/src/tools.ts +0 -134
- package/src/workflow.ts +0 -341
- package/src/workflows/coding.ts +0 -580
- package/src/workflows/index.ts +0 -61
- package/src/workflows/trading.ts +0 -608
package/dist/workflow.d.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM Daemon - Workflow System
|
|
3
|
-
*
|
|
4
|
-
* Pluggable workflow architecture for domain-agnostic daemon operations.
|
|
5
|
-
* Supports multiple workflows: coding, trading, research, etc.
|
|
6
|
-
*/
|
|
7
|
-
import type { GLMAgent } from "./agent.js";
|
|
8
|
-
import type { GLMDaemonState, GLMReflectionSummary } from "./types.js";
|
|
9
|
-
/**
|
|
10
|
-
* Workflow phase definition
|
|
11
|
-
*/
|
|
12
|
-
export interface GLMWorkflowPhase<P extends string = string> {
|
|
13
|
-
/** Phase identifier */
|
|
14
|
-
name: P;
|
|
15
|
-
/** Human-readable phase name */
|
|
16
|
-
label: string;
|
|
17
|
-
/** Phase description for system prompts */
|
|
18
|
-
description: string;
|
|
19
|
-
/** Optional timeout for this phase (ms) */
|
|
20
|
-
timeout?: number;
|
|
21
|
-
/** Whether this phase can be skipped */
|
|
22
|
-
skippable?: boolean;
|
|
23
|
-
/** Hooks to run before phase execution */
|
|
24
|
-
beforeHooks?: string[];
|
|
25
|
-
/** Hooks to run after phase execution */
|
|
26
|
-
afterHooks?: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Workflow execution context
|
|
30
|
-
*/
|
|
31
|
-
export interface GLMWorkflowContext {
|
|
32
|
-
/** Current daemon state */
|
|
33
|
-
state: GLMDaemonState;
|
|
34
|
-
/** Agent instance for executing prompts */
|
|
35
|
-
agent: GLMAgent;
|
|
36
|
-
/** Reflection summary if in reflecting phase */
|
|
37
|
-
reflectionSummary?: GLMReflectionSummary;
|
|
38
|
-
/** Custom data for workflow-specific use */
|
|
39
|
-
custom: Record<string, unknown>;
|
|
40
|
-
/** Tool count increment callback */
|
|
41
|
-
incrementToolCount: () => boolean;
|
|
42
|
-
/** Hook execution callback */
|
|
43
|
-
executeHook: (event: string, ...args: unknown[]) => Promise<void>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Phase execution result
|
|
47
|
-
*/
|
|
48
|
-
export interface GLMWorkflowPhaseResult {
|
|
49
|
-
/** Next phase to transition to */
|
|
50
|
-
nextPhase: string;
|
|
51
|
-
/** Whether to continue the loop */
|
|
52
|
-
continue: boolean;
|
|
53
|
-
/** Optional result data */
|
|
54
|
-
data?: unknown;
|
|
55
|
-
/** Optional error */
|
|
56
|
-
error?: Error;
|
|
57
|
-
/** State updates to apply */
|
|
58
|
-
stateUpdates?: Partial<GLMDaemonState>;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Workflow transition rule
|
|
62
|
-
*/
|
|
63
|
-
export interface GLMWorkflowTransition<P extends string = string> {
|
|
64
|
-
/** From phase */
|
|
65
|
-
from: P | "*";
|
|
66
|
-
/** Condition for transition */
|
|
67
|
-
condition?: (context: GLMWorkflowContext) => boolean | Promise<boolean>;
|
|
68
|
-
/** Target phase */
|
|
69
|
-
to: P;
|
|
70
|
-
/** Priority (higher = checked first) */
|
|
71
|
-
priority?: number;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Workflow configuration
|
|
75
|
-
*/
|
|
76
|
-
export interface GLMWorkflowConfig<P extends string = string> {
|
|
77
|
-
/** Workflow identifier */
|
|
78
|
-
id: string;
|
|
79
|
-
/** Human-readable name */
|
|
80
|
-
name: string;
|
|
81
|
-
/** Workflow description */
|
|
82
|
-
description: string;
|
|
83
|
-
/** All phases in this workflow */
|
|
84
|
-
phases: GLMWorkflowPhase<P>[];
|
|
85
|
-
/** Initial phase */
|
|
86
|
-
initialPhase: P;
|
|
87
|
-
/** Terminal phases (end states) */
|
|
88
|
-
terminalPhases: P[];
|
|
89
|
-
/** Transition rules */
|
|
90
|
-
transitions: GLMWorkflowTransition<P>[];
|
|
91
|
-
/** Default phase execution order if no transitions match */
|
|
92
|
-
defaultOrder?: P[];
|
|
93
|
-
/** Workflow-specific system prompt additions */
|
|
94
|
-
systemPromptExtensions?: string;
|
|
95
|
-
/** Reflection phase name (if supported) */
|
|
96
|
-
reflectionPhase?: P;
|
|
97
|
-
/** Custom completion check */
|
|
98
|
-
isComplete?: (context: GLMWorkflowContext) => boolean | Promise<boolean>;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Workflow executor interface
|
|
102
|
-
*/
|
|
103
|
-
export interface GLMWorkflowExecutor {
|
|
104
|
-
/** Get workflow configuration */
|
|
105
|
-
getConfig(): GLMWorkflowConfig;
|
|
106
|
-
/** Execute a specific phase */
|
|
107
|
-
executePhase(phase: string, context: GLMWorkflowContext): Promise<GLMWorkflowPhaseResult>;
|
|
108
|
-
/** Determine next phase based on current state */
|
|
109
|
-
getNextPhase(context: GLMWorkflowContext): Promise<string>;
|
|
110
|
-
/** Check if workflow is complete */
|
|
111
|
-
isComplete(context: GLMWorkflowContext): Promise<boolean>;
|
|
112
|
-
/** Get phase definition */
|
|
113
|
-
getPhase(phase: string): GLMWorkflowPhase | undefined;
|
|
114
|
-
/** Get all phases */
|
|
115
|
-
getPhases(): GLMWorkflowPhase[];
|
|
116
|
-
/** Build system prompt for current state */
|
|
117
|
-
buildSystemPrompt(context: GLMWorkflowContext): string;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Base workflow class with common functionality
|
|
121
|
-
*/
|
|
122
|
-
export declare abstract class BaseWorkflow<P extends string = string> implements GLMWorkflowExecutor {
|
|
123
|
-
protected config: GLMWorkflowConfig<P>;
|
|
124
|
-
protected phaseMap: Map<string, GLMWorkflowPhase<P>>;
|
|
125
|
-
constructor(config: GLMWorkflowConfig<P>);
|
|
126
|
-
getConfig(): GLMWorkflowConfig;
|
|
127
|
-
getPhase(phase: string): GLMWorkflowPhase | undefined;
|
|
128
|
-
getPhases(): GLMWorkflowPhase[];
|
|
129
|
-
/**
|
|
130
|
-
* Execute a phase - must be implemented by subclasses
|
|
131
|
-
*/
|
|
132
|
-
abstract executePhase(phase: string, context: GLMWorkflowContext): Promise<GLMWorkflowPhaseResult>;
|
|
133
|
-
/**
|
|
134
|
-
* Determine next phase based on transitions
|
|
135
|
-
*/
|
|
136
|
-
getNextPhase(context: GLMWorkflowContext): Promise<string>;
|
|
137
|
-
/**
|
|
138
|
-
* Check if workflow is complete
|
|
139
|
-
*/
|
|
140
|
-
isComplete(context: GLMWorkflowContext): Promise<boolean>;
|
|
141
|
-
/**
|
|
142
|
-
* Build system prompt with workflow context
|
|
143
|
-
*/
|
|
144
|
-
buildSystemPrompt(context: GLMWorkflowContext): string;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Workflow registry for managing multiple workflows
|
|
148
|
-
*/
|
|
149
|
-
export declare class WorkflowRegistry {
|
|
150
|
-
private workflows;
|
|
151
|
-
private defaultWorkflow;
|
|
152
|
-
/**
|
|
153
|
-
* Register a workflow
|
|
154
|
-
*/
|
|
155
|
-
register(workflow: GLMWorkflowExecutor, setDefault?: boolean): void;
|
|
156
|
-
/**
|
|
157
|
-
* Get a workflow by ID
|
|
158
|
-
*/
|
|
159
|
-
get(id: string): GLMWorkflowExecutor | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* Get the default workflow
|
|
162
|
-
*/
|
|
163
|
-
getDefault(): GLMWorkflowExecutor | undefined;
|
|
164
|
-
/**
|
|
165
|
-
* Set the default workflow
|
|
166
|
-
*/
|
|
167
|
-
setDefault(id: string): void;
|
|
168
|
-
/**
|
|
169
|
-
* List all registered workflows
|
|
170
|
-
*/
|
|
171
|
-
list(): Array<{
|
|
172
|
-
id: string;
|
|
173
|
-
name: string;
|
|
174
|
-
description: string;
|
|
175
|
-
}>;
|
|
176
|
-
/**
|
|
177
|
-
* Check if a workflow exists
|
|
178
|
-
*/
|
|
179
|
-
has(id: string): boolean;
|
|
180
|
-
}
|
|
181
|
-
export declare const workflowRegistry: WorkflowRegistry;
|
|
182
|
-
//# sourceMappingURL=workflow.d.ts.map
|
package/dist/workflow.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACzD,uBAAuB;IACvB,IAAI,EAAE,CAAC,CAAC;IAER,gCAAgC;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,UAAQ,GAAG,IAAI;IASjE;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAIhD;;OAEG;IACH,UAAU,IAAI,mBAAmB,GAAG,SAAS;IAO7C;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAO5B;;OAEG;IACH,IAAI,IAAI,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAWhE;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;CAGzB;AAGD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM Daemon - Coding Workflow
|
|
3
|
-
*
|
|
4
|
-
* Default coding workflow extracted from hardcoded daemon phases.
|
|
5
|
-
* Phases: planning → executing → reflecting → paranoid → reviewing → fixing → committing → complete
|
|
6
|
-
*/
|
|
7
|
-
import { BaseWorkflow, type GLMWorkflowConfig, type GLMWorkflowContext, type GLMWorkflowPhaseResult, type GLMWorkflowPhase, type GLMWorkflowTransition } from "../workflow.js";
|
|
8
|
-
/**
|
|
9
|
-
* Coding workflow phases
|
|
10
|
-
*/
|
|
11
|
-
export type CodingPhase = "planning" | "executing" | "reflecting" | "paranoid" | "reviewing" | "fixing" | "committing" | "complete";
|
|
12
|
-
/**
|
|
13
|
-
* Coding workflow phases definition
|
|
14
|
-
*/
|
|
15
|
-
export declare const CODING_PHASES: GLMWorkflowPhase<CodingPhase>[];
|
|
16
|
-
/**
|
|
17
|
-
* Coding workflow transition rules
|
|
18
|
-
*/
|
|
19
|
-
export declare const CODING_TRANSITIONS: GLMWorkflowTransition<CodingPhase>[];
|
|
20
|
-
/**
|
|
21
|
-
* Coding workflow configuration
|
|
22
|
-
*/
|
|
23
|
-
export declare const CODING_WORKFLOW_CONFIG: GLMWorkflowConfig<CodingPhase>;
|
|
24
|
-
/**
|
|
25
|
-
* Coding Workflow implementation
|
|
26
|
-
*/
|
|
27
|
-
export declare class CodingWorkflow extends BaseWorkflow<CodingPhase> {
|
|
28
|
-
constructor();
|
|
29
|
-
/**
|
|
30
|
-
* Execute a coding phase
|
|
31
|
-
*/
|
|
32
|
-
executePhase(phase: string, context: GLMWorkflowContext): Promise<GLMWorkflowPhaseResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Planning phase - break down task into subtasks
|
|
35
|
-
*/
|
|
36
|
-
private phasePlanning;
|
|
37
|
-
/**
|
|
38
|
-
* Executing phase - work on current subtask
|
|
39
|
-
*/
|
|
40
|
-
private phaseExecuting;
|
|
41
|
-
/**
|
|
42
|
-
* Reflecting phase - TL;DR checkpoint after N tools
|
|
43
|
-
*/
|
|
44
|
-
private phaseReflecting;
|
|
45
|
-
/**
|
|
46
|
-
* Paranoid phase - quality check after every edit
|
|
47
|
-
*/
|
|
48
|
-
private phaseParanoid;
|
|
49
|
-
/**
|
|
50
|
-
* Reviewing phase - final quality review
|
|
51
|
-
*/
|
|
52
|
-
private phaseReviewing;
|
|
53
|
-
/**
|
|
54
|
-
* Fixing phase - fix issues found
|
|
55
|
-
*/
|
|
56
|
-
private phaseFixing;
|
|
57
|
-
/**
|
|
58
|
-
* Committing phase - commit changes
|
|
59
|
-
*/
|
|
60
|
-
private phaseCommitting;
|
|
61
|
-
/**
|
|
62
|
-
* Complete phase - task is finished
|
|
63
|
-
*/
|
|
64
|
-
private phaseComplete;
|
|
65
|
-
/**
|
|
66
|
-
* Parse subtasks from agent response
|
|
67
|
-
*/
|
|
68
|
-
private parseSubtasks;
|
|
69
|
-
/**
|
|
70
|
-
* Parse reflection summary from agent response
|
|
71
|
-
*/
|
|
72
|
-
private parseReflectionSummary;
|
|
73
|
-
/**
|
|
74
|
-
* Detect issues in paranoid check response
|
|
75
|
-
*/
|
|
76
|
-
private detectIssues;
|
|
77
|
-
}
|
|
78
|
-
export declare const codingWorkflow: CodingWorkflow;
|
|
79
|
-
//# sourceMappingURL=coding.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coding.d.ts","sourceRoot":"","sources":["../../src/workflows/coding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,WAAW,GACX,YAAY,GACZ,UAAU,GACV,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,UAAU,CAAC;AAEf;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAkDxD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,qBAAqB,CAAC,WAAW,CAAC,EAiFlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,WAAW,CAYjE,CAAC;AAEF;;GAEG;AACH,qBAAa,cAAe,SAAQ,YAAY,CAAC,WAAW,CAAC;;IAK3D;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuB/F;;OAEG;YACW,aAAa;IA+B3B;;OAEG;YACW,cAAc;IA6D5B;;OAEG;YACW,eAAe;IA8C7B;;OAEG;YACW,aAAa;IA8B3B;;OAEG;YACW,cAAc;IA2B5B;;OAEG;YACW,WAAW;IAqBzB;;OAEG;YACW,eAAe;IAc7B;;OAEG;YACW,aAAa;IAW3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAoC9B;;OAEG;IACH,OAAO,CAAC,YAAY;CASrB;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM Daemon - Workflows Index
|
|
3
|
-
*
|
|
4
|
-
* Export all available workflows and register them with the registry.
|
|
5
|
-
*/
|
|
6
|
-
export type { GLMWorkflowPhase, GLMWorkflowContext, GLMWorkflowPhaseResult, GLMWorkflowTransition, GLMWorkflowConfig, GLMWorkflowExecutor, } from "../workflow.js";
|
|
7
|
-
export { BaseWorkflow, WorkflowRegistry, workflowRegistry } from "../workflow.js";
|
|
8
|
-
export { CodingWorkflow, CODING_PHASES, CODING_TRANSITIONS, CODING_WORKFLOW_CONFIG, codingWorkflow } from "./coding.js";
|
|
9
|
-
export { TradingWorkflow, TRADING_PHASES, TRADING_TRANSITIONS, TRADING_WORKFLOW_CONFIG, tradingWorkflow } from "./trading.js";
|
|
10
|
-
export type { CodingPhase } from "./coding.js";
|
|
11
|
-
export type { TradingPhase } from "./trading.js";
|
|
12
|
-
/**
|
|
13
|
-
* Initialize all built-in workflows
|
|
14
|
-
*/
|
|
15
|
-
export declare function initializeWorkflows(): void;
|
|
16
|
-
/**
|
|
17
|
-
* Get a workflow by ID
|
|
18
|
-
*/
|
|
19
|
-
export declare function getWorkflow(id: string): import("./index.js").GLMWorkflowExecutor | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Get the default workflow
|
|
22
|
-
*/
|
|
23
|
-
export declare function getDefaultWorkflow(): import("./index.js").GLMWorkflowExecutor | undefined;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGxH,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG9H,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,wDAErC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,yDAEjC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM Daemon - Trading Workflow
|
|
3
|
-
*
|
|
4
|
-
* Trading workflow for automated market analysis and execution.
|
|
5
|
-
* Phases: analyzing → signaling → risk_checking → executing → monitoring → complete
|
|
6
|
-
*
|
|
7
|
-
* Key differences from coding workflow:
|
|
8
|
-
* - No git state (trading doesn't need commits/PRs)
|
|
9
|
-
* - Focus on market signals and risk management
|
|
10
|
-
* - Real-time monitoring loops
|
|
11
|
-
*/
|
|
12
|
-
import { BaseWorkflow, type GLMWorkflowConfig, type GLMWorkflowContext, type GLMWorkflowPhaseResult, type GLMWorkflowPhase, type GLMWorkflowTransition } from "../workflow.js";
|
|
13
|
-
/**
|
|
14
|
-
* Trading workflow phases
|
|
15
|
-
*/
|
|
16
|
-
export type TradingPhase = "analyzing" | "signaling" | "risk_checking" | "executing" | "monitoring" | "reflecting" | "complete";
|
|
17
|
-
/**
|
|
18
|
-
* Trading workflow phases definition
|
|
19
|
-
*/
|
|
20
|
-
export declare const TRADING_PHASES: GLMWorkflowPhase<TradingPhase>[];
|
|
21
|
-
/**
|
|
22
|
-
* Trading workflow transition rules
|
|
23
|
-
*/
|
|
24
|
-
export declare const TRADING_TRANSITIONS: GLMWorkflowTransition<TradingPhase>[];
|
|
25
|
-
/**
|
|
26
|
-
* Trading workflow configuration
|
|
27
|
-
*/
|
|
28
|
-
export declare const TRADING_WORKFLOW_CONFIG: GLMWorkflowConfig<TradingPhase>;
|
|
29
|
-
/**
|
|
30
|
-
* Trading Workflow implementation
|
|
31
|
-
*/
|
|
32
|
-
export declare class TradingWorkflow extends BaseWorkflow<TradingPhase> {
|
|
33
|
-
constructor();
|
|
34
|
-
/**
|
|
35
|
-
* Build system prompt for trading context
|
|
36
|
-
*/
|
|
37
|
-
buildSystemPrompt(context: GLMWorkflowContext): string;
|
|
38
|
-
/**
|
|
39
|
-
* Execute a trading phase
|
|
40
|
-
*/
|
|
41
|
-
executePhase(phase: string, context: GLMWorkflowContext): Promise<GLMWorkflowPhaseResult>;
|
|
42
|
-
/**
|
|
43
|
-
* Analyzing phase - analyze market conditions
|
|
44
|
-
*/
|
|
45
|
-
private phaseAnalyzing;
|
|
46
|
-
/**
|
|
47
|
-
* Signaling phase - generate trading signals
|
|
48
|
-
*/
|
|
49
|
-
private phaseSignaling;
|
|
50
|
-
/**
|
|
51
|
-
* Risk Checking phase - evaluate risk before execution
|
|
52
|
-
*/
|
|
53
|
-
private phaseRiskChecking;
|
|
54
|
-
/**
|
|
55
|
-
* Executing phase - execute trades
|
|
56
|
-
*/
|
|
57
|
-
private phaseExecuting;
|
|
58
|
-
/**
|
|
59
|
-
* Monitoring phase - monitor positions
|
|
60
|
-
*/
|
|
61
|
-
private phaseMonitoring;
|
|
62
|
-
/**
|
|
63
|
-
* Reflecting phase - review performance
|
|
64
|
-
*/
|
|
65
|
-
private phaseReflecting;
|
|
66
|
-
/**
|
|
67
|
-
* Complete phase - trading session finished
|
|
68
|
-
*/
|
|
69
|
-
private phaseComplete;
|
|
70
|
-
}
|
|
71
|
-
export declare const tradingWorkflow: TradingWorkflow;
|
|
72
|
-
//# sourceMappingURL=trading.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trading.d.ts","sourceRoot":"","sources":["../../src/workflows/trading.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,WAAW,GACX,eAAe,GACf,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,UAAU,CAAC;AAEf;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,YAAY,CAAC,EA+C1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,qBAAqB,CAAC,YAAY,CAAC,EA6EpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,YAAY,CAenE,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY,CAAC,YAAY,CAAC;;IAK7D;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM;IActD;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAqB/F;;OAEG;YACW,cAAc;IAsD5B;;OAEG;YACW,cAAc;IAqD5B;;OAEG;YACW,iBAAiB;IA6D/B;;OAEG;YACW,cAAc;IA8B5B;;OAEG;YACW,eAAe;IAyE7B;;OAEG;YACW,eAAe;IA4C7B;;OAEG;YACW,aAAa;CAgC5B;AAGD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|
package/src/agent.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GLM Agent - Individual GLM-powered agent
|
|
3
|
-
*
|
|
4
|
-
* Wraps GLM 4.7 API with tool access and hook integration.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { GLMAgentConfig, GLMToolResult } from "./types.js";
|
|
8
|
-
import { GLMClient } from "@ebowwa/ai";
|
|
9
|
-
import type { ChatMessage } from "@ebowwa/codespaces-types/runtime/ai";
|
|
10
|
-
|
|
11
|
-
export class GLMAgent {
|
|
12
|
-
private config: GLMAgentConfig;
|
|
13
|
-
private client: GLMClient;
|
|
14
|
-
private tools: Map<string, (args: unknown) => Promise<unknown>> = new Map();
|
|
15
|
-
|
|
16
|
-
constructor(config: GLMAgentConfig) {
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.client = new GLMClient();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Execute a prompt and get response
|
|
23
|
-
*/
|
|
24
|
-
async execute(prompt: string, tools?: Record<string, unknown>): Promise<string> {
|
|
25
|
-
const messages: ChatMessage[] = [
|
|
26
|
-
{
|
|
27
|
-
role: "system",
|
|
28
|
-
content: this.config.prompt,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
role: "user",
|
|
32
|
-
content: prompt,
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
// Add tool context if provided
|
|
37
|
-
if (tools) {
|
|
38
|
-
messages.push({
|
|
39
|
-
role: "user",
|
|
40
|
-
content: `\nAvailable tools: ${Object.keys(tools).join(", ")}`,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const response = await this.client.chatCompletion(messages, {
|
|
45
|
-
model: this.config.model || "glm-4.7",
|
|
46
|
-
temperature: this.config.temperature || 0.7,
|
|
47
|
-
maxTokens: this.config.maxTokens || 4096,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return response.choices[0]?.message?.content || "";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Execute a tool call
|
|
55
|
-
*/
|
|
56
|
-
async executeTool(toolName: string, args: unknown): Promise<GLMToolResult> {
|
|
57
|
-
const start = Date.now();
|
|
58
|
-
const tool = this.tools.get(toolName);
|
|
59
|
-
|
|
60
|
-
if (!tool) {
|
|
61
|
-
return {
|
|
62
|
-
success: false,
|
|
63
|
-
error: `Tool not found: ${toolName}`,
|
|
64
|
-
duration: Date.now() - start,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const result = await tool(args);
|
|
70
|
-
return {
|
|
71
|
-
success: true,
|
|
72
|
-
result,
|
|
73
|
-
duration: Date.now() - start,
|
|
74
|
-
};
|
|
75
|
-
} catch (error) {
|
|
76
|
-
return {
|
|
77
|
-
success: false,
|
|
78
|
-
error: error instanceof Error ? error.message : String(error),
|
|
79
|
-
duration: Date.now() - start,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Register a tool
|
|
86
|
-
*/
|
|
87
|
-
registerTool(name: string, handler: (args: unknown) => Promise<unknown>): void {
|
|
88
|
-
this.tools.set(name, handler);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get available tools
|
|
93
|
-
*/
|
|
94
|
-
getAvailableTools(): string[] {
|
|
95
|
-
return Array.from(this.tools.keys());
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get agent ID
|
|
100
|
-
*/
|
|
101
|
-
get agentId(): string {
|
|
102
|
-
return this.config.agentId;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get agent name
|
|
107
|
-
*/
|
|
108
|
-
get name(): string {
|
|
109
|
-
return this.config.name;
|
|
110
|
-
}
|
|
111
|
-
}
|