pulseed 0.4.7 → 0.4.9
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/README.md +12 -0
- package/dist/base/config/tool-metadata.js +1 -1
- package/dist/base/config/tool-metadata.js.map +1 -1
- package/dist/base/llm/provider-config.d.ts.map +1 -1
- package/dist/base/llm/provider-config.js +44 -11
- package/dist/base/llm/provider-config.js.map +1 -1
- package/dist/base/state/state-manager.d.ts +7 -0
- package/dist/base/state/state-manager.d.ts.map +1 -1
- package/dist/base/state/state-manager.js +127 -17
- package/dist/base/state/state-manager.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interface/chat/chat-history.d.ts +152 -46
- package/dist/interface/chat/chat-history.d.ts.map +1 -1
- package/dist/interface/chat/chat-history.js +55 -9
- package/dist/interface/chat/chat-history.js.map +1 -1
- package/dist/interface/chat/chat-runner.d.ts +9 -1
- package/dist/interface/chat/chat-runner.d.ts.map +1 -1
- package/dist/interface/chat/chat-runner.js +152 -9
- package/dist/interface/chat/chat-runner.js.map +1 -1
- package/dist/interface/chat/chat-session-store.d.ts +71 -0
- package/dist/interface/chat/chat-session-store.d.ts.map +1 -0
- package/dist/interface/chat/chat-session-store.js +378 -0
- package/dist/interface/chat/chat-session-store.js.map +1 -0
- package/dist/interface/cli/cli-command-registry.d.ts.map +1 -1
- package/dist/interface/cli/cli-command-registry.js +23 -7
- package/dist/interface/cli/cli-command-registry.js.map +1 -1
- package/dist/interface/cli/commands/approval.d.ts +3 -0
- package/dist/interface/cli/commands/approval.d.ts.map +1 -0
- package/dist/interface/cli/commands/approval.js +112 -0
- package/dist/interface/cli/commands/approval.js.map +1 -0
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +21 -7
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/apply.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/apply.js +86 -0
- package/dist/interface/cli/commands/setup/import/apply.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/constants.d.ts +1 -1
- package/dist/interface/cli/commands/setup/import/constants.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/constants.js +5 -0
- package/dist/interface/cli/commands/setup/import/constants.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/discovery.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/discovery.js +37 -6
- package/dist/interface/cli/commands/setup/import/discovery.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/flow.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/flow.js +22 -4
- package/dist/interface/cli/commands/setup/import/flow.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/fs-utils.d.ts +1 -0
- package/dist/interface/cli/commands/setup/import/fs-utils.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/fs-utils.js +27 -1
- package/dist/interface/cli/commands/setup/import/fs-utils.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/mcp.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/mcp.js +3 -1
- package/dist/interface/cli/commands/setup/import/mcp.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/provider.d.ts +3 -1
- package/dist/interface/cli/commands/setup/import/provider.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/import/provider.js +94 -5
- package/dist/interface/cli/commands/setup/import/provider.js.map +1 -1
- package/dist/interface/cli/commands/setup/import/telegram.d.ts +5 -0
- package/dist/interface/cli/commands/setup/import/telegram.d.ts.map +1 -0
- package/dist/interface/cli/commands/setup/import/telegram.js +109 -0
- package/dist/interface/cli/commands/setup/import/telegram.js.map +1 -0
- package/dist/interface/cli/commands/setup/import/types.d.ts +6 -1
- package/dist/interface/cli/commands/setup/import/types.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/steps-provider.d.ts +1 -1
- package/dist/interface/cli/commands/setup/steps-provider.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup/steps-provider.js +57 -38
- package/dist/interface/cli/commands/setup/steps-provider.js.map +1 -1
- package/dist/interface/cli/commands/setup-wizard.d.ts.map +1 -1
- package/dist/interface/cli/commands/setup-wizard.js +44 -6
- package/dist/interface/cli/commands/setup-wizard.js.map +1 -1
- package/dist/interface/cli/commands/telegram.d.ts.map +1 -1
- package/dist/interface/cli/commands/telegram.js +22 -20
- package/dist/interface/cli/commands/telegram.js.map +1 -1
- package/dist/interface/cli/ensure-api-key.d.ts +3 -1
- package/dist/interface/cli/ensure-api-key.d.ts.map +1 -1
- package/dist/interface/cli/ensure-api-key.js +20 -13
- package/dist/interface/cli/ensure-api-key.js.map +1 -1
- package/dist/interface/cli/utils.d.ts.map +1 -1
- package/dist/interface/cli/utils.js +1 -0
- package/dist/interface/cli/utils.js.map +1 -1
- package/dist/runtime/store/runtime-operation-schemas.d.ts +12 -12
- package/dist/runtime/store/runtime-schemas.d.ts +2 -2
- package/dist/runtime/types/envelope.d.ts +2 -2
- package/package.json +2 -2
- package/dist/adapters/agents/openclaw-acp.d.ts +0 -32
- package/dist/adapters/agents/openclaw-acp.d.ts.map +0 -1
- package/dist/adapters/agents/openclaw-acp.js +0 -212
- package/dist/adapters/agents/openclaw-acp.js.map +0 -1
- package/dist/adapters/datasources/openclaw-datasource.d.ts +0 -33
- package/dist/adapters/datasources/openclaw-datasource.d.ts.map +0 -1
- package/dist/adapters/datasources/openclaw-datasource.js +0 -176
- package/dist/adapters/datasources/openclaw-datasource.js.map +0 -1
- package/dist/interface/cli/commands/chat.d.ts +0 -3
- package/dist/interface/cli/commands/chat.d.ts.map +0 -1
- package/dist/interface/cli/commands/chat.js +0 -278
- package/dist/interface/cli/commands/chat.js.map +0 -1
- package/dist/orchestrator/knowledge/memory/memory-lifecycle.d.ts +0 -2
- package/dist/orchestrator/knowledge/memory/memory-lifecycle.d.ts.map +0 -1
- package/dist/orchestrator/knowledge/memory/memory-lifecycle.js +0 -2
- package/dist/orchestrator/knowledge/memory/memory-lifecycle.js.map +0 -1
|
@@ -10,13 +10,13 @@ export declare const RuntimeControlActorSchema: z.ZodObject<{
|
|
|
10
10
|
identity_key: z.ZodOptional<z.ZodString>;
|
|
11
11
|
user_id: z.ZodOptional<z.ZodString>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
surface: "cli" | "
|
|
13
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
14
14
|
platform?: string | undefined;
|
|
15
15
|
conversation_id?: string | undefined;
|
|
16
16
|
identity_key?: string | undefined;
|
|
17
17
|
user_id?: string | undefined;
|
|
18
18
|
}, {
|
|
19
|
-
surface: "cli" | "
|
|
19
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
20
20
|
platform?: string | undefined;
|
|
21
21
|
conversation_id?: string | undefined;
|
|
22
22
|
identity_key?: string | undefined;
|
|
@@ -32,7 +32,7 @@ export declare const RuntimeControlReplyTargetSchema: z.ZodObject<{
|
|
|
32
32
|
identity_key: z.ZodOptional<z.ZodString>;
|
|
33
33
|
user_id: z.ZodOptional<z.ZodString>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
surface?: "cli" | "
|
|
35
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
36
36
|
platform?: string | undefined;
|
|
37
37
|
conversation_id?: string | undefined;
|
|
38
38
|
identity_key?: string | undefined;
|
|
@@ -40,7 +40,7 @@ export declare const RuntimeControlReplyTargetSchema: z.ZodObject<{
|
|
|
40
40
|
response_channel?: string | undefined;
|
|
41
41
|
outbox_topic?: string | undefined;
|
|
42
42
|
}, {
|
|
43
|
-
surface?: "cli" | "
|
|
43
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
44
44
|
platform?: string | undefined;
|
|
45
45
|
conversation_id?: string | undefined;
|
|
46
46
|
identity_key?: string | undefined;
|
|
@@ -62,13 +62,13 @@ export declare const RuntimeControlOperationSchema: z.ZodObject<{
|
|
|
62
62
|
identity_key: z.ZodOptional<z.ZodString>;
|
|
63
63
|
user_id: z.ZodOptional<z.ZodString>;
|
|
64
64
|
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
surface: "cli" | "
|
|
65
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
66
66
|
platform?: string | undefined;
|
|
67
67
|
conversation_id?: string | undefined;
|
|
68
68
|
identity_key?: string | undefined;
|
|
69
69
|
user_id?: string | undefined;
|
|
70
70
|
}, {
|
|
71
|
-
surface: "cli" | "
|
|
71
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
72
72
|
platform?: string | undefined;
|
|
73
73
|
conversation_id?: string | undefined;
|
|
74
74
|
identity_key?: string | undefined;
|
|
@@ -83,7 +83,7 @@ export declare const RuntimeControlOperationSchema: z.ZodObject<{
|
|
|
83
83
|
identity_key: z.ZodOptional<z.ZodString>;
|
|
84
84
|
user_id: z.ZodOptional<z.ZodString>;
|
|
85
85
|
}, "strip", z.ZodTypeAny, {
|
|
86
|
-
surface?: "cli" | "
|
|
86
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
87
87
|
platform?: string | undefined;
|
|
88
88
|
conversation_id?: string | undefined;
|
|
89
89
|
identity_key?: string | undefined;
|
|
@@ -91,7 +91,7 @@ export declare const RuntimeControlOperationSchema: z.ZodObject<{
|
|
|
91
91
|
response_channel?: string | undefined;
|
|
92
92
|
outbox_topic?: string | undefined;
|
|
93
93
|
}, {
|
|
94
|
-
surface?: "cli" | "
|
|
94
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
95
95
|
platform?: string | undefined;
|
|
96
96
|
conversation_id?: string | undefined;
|
|
97
97
|
identity_key?: string | undefined;
|
|
@@ -139,14 +139,14 @@ export declare const RuntimeControlOperationSchema: z.ZodObject<{
|
|
|
139
139
|
operation_id: string;
|
|
140
140
|
requested_at: string;
|
|
141
141
|
requested_by: {
|
|
142
|
-
surface: "cli" | "
|
|
142
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
143
143
|
platform?: string | undefined;
|
|
144
144
|
conversation_id?: string | undefined;
|
|
145
145
|
identity_key?: string | undefined;
|
|
146
146
|
user_id?: string | undefined;
|
|
147
147
|
};
|
|
148
148
|
reply_target: {
|
|
149
|
-
surface?: "cli" | "
|
|
149
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
150
150
|
platform?: string | undefined;
|
|
151
151
|
conversation_id?: string | undefined;
|
|
152
152
|
identity_key?: string | undefined;
|
|
@@ -177,14 +177,14 @@ export declare const RuntimeControlOperationSchema: z.ZodObject<{
|
|
|
177
177
|
operation_id: string;
|
|
178
178
|
requested_at: string;
|
|
179
179
|
requested_by: {
|
|
180
|
-
surface: "cli" | "
|
|
180
|
+
surface: "cli" | "chat" | "gateway" | "tui";
|
|
181
181
|
platform?: string | undefined;
|
|
182
182
|
conversation_id?: string | undefined;
|
|
183
183
|
identity_key?: string | undefined;
|
|
184
184
|
user_id?: string | undefined;
|
|
185
185
|
};
|
|
186
186
|
reply_target: {
|
|
187
|
-
surface?: "cli" | "
|
|
187
|
+
surface?: "cli" | "chat" | "gateway" | "tui" | undefined;
|
|
188
188
|
platform?: string | undefined;
|
|
189
189
|
conversation_id?: string | undefined;
|
|
190
190
|
identity_key?: string | undefined;
|
|
@@ -150,15 +150,15 @@ export declare const OutboxRecordSchema: z.ZodObject<{
|
|
|
150
150
|
payload: z.ZodUnknown;
|
|
151
151
|
}, "strip", z.ZodTypeAny, {
|
|
152
152
|
created_at: number;
|
|
153
|
-
event_type: string;
|
|
154
153
|
seq: number;
|
|
154
|
+
event_type: string;
|
|
155
155
|
goal_id?: string | undefined;
|
|
156
156
|
payload?: unknown;
|
|
157
157
|
correlation_id?: string | undefined;
|
|
158
158
|
}, {
|
|
159
159
|
created_at: number;
|
|
160
|
-
event_type: string;
|
|
161
160
|
seq: number;
|
|
161
|
+
event_type: string;
|
|
162
162
|
goal_id?: string | undefined;
|
|
163
163
|
payload?: unknown;
|
|
164
164
|
correlation_id?: string | undefined;
|
|
@@ -52,8 +52,8 @@ export declare const EnvelopeSchema: z.ZodObject<{
|
|
|
52
52
|
payload?: unknown;
|
|
53
53
|
correlation_id?: string | undefined;
|
|
54
54
|
dedupe_key?: string | undefined;
|
|
55
|
-
reply_channel_id?: string | undefined;
|
|
56
55
|
ttl_ms?: number | undefined;
|
|
56
|
+
reply_channel_id?: string | undefined;
|
|
57
57
|
}, {
|
|
58
58
|
type: "command" | "event";
|
|
59
59
|
source: string;
|
|
@@ -69,8 +69,8 @@ export declare const EnvelopeSchema: z.ZodObject<{
|
|
|
69
69
|
payload?: unknown;
|
|
70
70
|
correlation_id?: string | undefined;
|
|
71
71
|
dedupe_key?: string | undefined;
|
|
72
|
-
reply_channel_id?: string | undefined;
|
|
73
72
|
ttl_ms?: number | undefined;
|
|
73
|
+
reply_channel_id?: string | undefined;
|
|
74
74
|
}>;
|
|
75
75
|
export type Envelope = z.infer<typeof EnvelopeSchema>;
|
|
76
76
|
/** Helper to create an Envelope with defaults */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pulseed",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "AI agent orchestrator that gives existing agents the drive to persist — set a goal, and PulSeed observes, delegates, verifies, and loops until done.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"ai-agent",
|
|
34
34
|
"multi-agent",
|
|
35
35
|
"typescript",
|
|
36
|
-
"openclaw",
|
|
37
36
|
"gateway"
|
|
38
37
|
],
|
|
39
38
|
"repository": {
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
"scripts": {
|
|
49
48
|
"build": "tsc -p tsconfig.build.json",
|
|
50
49
|
"check:docs": "node scripts/check-docs.mjs",
|
|
50
|
+
"release": "node scripts/release.mjs",
|
|
51
51
|
"test": "vitest run --exclude tests/e2e",
|
|
52
52
|
"test:all": "vitest run",
|
|
53
53
|
"test:e2e": "vitest run tests/e2e",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IAdapter, AgentTask, AgentResult } from "../../orchestrator/execution/adapter-layer.js";
|
|
2
|
-
export interface OpenClawACPConfig {
|
|
3
|
-
/** Path to the openclaw executable. Default: "openclaw" */
|
|
4
|
-
cliPath?: string;
|
|
5
|
-
/** OpenClaw profile to use. Default: "default" */
|
|
6
|
-
profile?: string;
|
|
7
|
-
/** Model override passed to OpenClaw (optional). */
|
|
8
|
-
model?: string;
|
|
9
|
-
/** Working directory for the child process (optional). */
|
|
10
|
-
workDir?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class OpenClawACPAdapter implements IAdapter {
|
|
13
|
-
readonly adapterType = "openclaw_acp";
|
|
14
|
-
readonly capabilities: readonly ["execute_code", "read_files", "write_files", "run_commands", "browse_web", "search"];
|
|
15
|
-
private readonly cliPath;
|
|
16
|
-
private readonly profile;
|
|
17
|
-
private readonly model;
|
|
18
|
-
private readonly workDir;
|
|
19
|
-
private child;
|
|
20
|
-
private sessionKey;
|
|
21
|
-
private requestId;
|
|
22
|
-
constructor(config?: OpenClawACPConfig);
|
|
23
|
-
execute(task: AgentTask): Promise<AgentResult>;
|
|
24
|
-
private spawnProcess;
|
|
25
|
-
/**
|
|
26
|
-
* Write a JSON-RPC request to stdin and wait for the matching response from stdout.
|
|
27
|
-
* Responses are newline-delimited JSON. Skips lines that do not parse or belong to
|
|
28
|
-
* a different request ID.
|
|
29
|
-
*/
|
|
30
|
-
private sendRequest;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=openclaw-acp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-acp.d.ts","sourceRoot":"","sources":["../../../src/adapters/agents/openclaw-acp.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AA8BtG,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAID,qBAAa,kBAAmB,YAAW,QAAQ;IACjD,QAAQ,CAAC,WAAW,kBAAkB;IACtC,QAAQ,CAAC,YAAY,iGAOV;IAEX,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,SAAS,CAAK;gBAEV,MAAM,GAAE,iBAAsB;IASpC,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAyGpD,OAAO,CAAC,YAAY;IAmBpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;CA2EpB"}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
// ─── OpenClawACPAdapter ───
|
|
2
|
-
//
|
|
3
|
-
// IAdapter implementation that drives OpenClaw via the ACP (Agent Communication Protocol).
|
|
4
|
-
// OpenClaw is started as a stdio child process (`openclaw acp`). Messages are exchanged
|
|
5
|
-
// as newline-delimited JSON-RPC 2.0 over stdin/stdout.
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
-
// ─── Adapter ───
|
|
8
|
-
export class OpenClawACPAdapter {
|
|
9
|
-
adapterType = "openclaw_acp";
|
|
10
|
-
capabilities = [
|
|
11
|
-
"execute_code",
|
|
12
|
-
"read_files",
|
|
13
|
-
"write_files",
|
|
14
|
-
"run_commands",
|
|
15
|
-
"browse_web",
|
|
16
|
-
"search",
|
|
17
|
-
];
|
|
18
|
-
cliPath;
|
|
19
|
-
profile;
|
|
20
|
-
model;
|
|
21
|
-
workDir;
|
|
22
|
-
child = null;
|
|
23
|
-
sessionKey;
|
|
24
|
-
requestId = 0;
|
|
25
|
-
constructor(config = {}) {
|
|
26
|
-
this.cliPath = config.cliPath ?? "openclaw";
|
|
27
|
-
this.profile = config.profile ?? "default";
|
|
28
|
-
this.model = config.model;
|
|
29
|
-
this.workDir = config.workDir;
|
|
30
|
-
}
|
|
31
|
-
// ─── IAdapter.execute ───
|
|
32
|
-
async execute(task) {
|
|
33
|
-
const startedAt = Date.now();
|
|
34
|
-
// Ensure the child process is running
|
|
35
|
-
if (!this.child || this.child.exitCode !== null) {
|
|
36
|
-
try {
|
|
37
|
-
this.child = this.spawnProcess();
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
const elapsed = Date.now() - startedAt;
|
|
41
|
-
const errMessage = err instanceof Error ? err.message : String(err);
|
|
42
|
-
return {
|
|
43
|
-
success: false,
|
|
44
|
-
output: "",
|
|
45
|
-
error: errMessage,
|
|
46
|
-
exit_code: null,
|
|
47
|
-
elapsed_ms: elapsed,
|
|
48
|
-
stopped_reason: "error",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const requestId = ++this.requestId;
|
|
53
|
-
const request = {
|
|
54
|
-
jsonrpc: "2.0",
|
|
55
|
-
id: requestId,
|
|
56
|
-
method: "message/send",
|
|
57
|
-
params: {
|
|
58
|
-
message: task.prompt,
|
|
59
|
-
...(this.sessionKey ? { sessionKey: this.sessionKey } : {}),
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
// Setup timeout via AbortController
|
|
63
|
-
const controller = new AbortController();
|
|
64
|
-
const timeoutHandle = setTimeout(() => controller.abort(), task.timeout_ms);
|
|
65
|
-
try {
|
|
66
|
-
const response = await this.sendRequest(request, controller.signal);
|
|
67
|
-
clearTimeout(timeoutHandle);
|
|
68
|
-
if (response.error) {
|
|
69
|
-
const elapsed = Date.now() - startedAt;
|
|
70
|
-
return {
|
|
71
|
-
success: false,
|
|
72
|
-
output: "",
|
|
73
|
-
error: `ACP error ${response.error.code}: ${response.error.message}`,
|
|
74
|
-
exit_code: null,
|
|
75
|
-
elapsed_ms: elapsed,
|
|
76
|
-
stopped_reason: "error",
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
if (!response.result) {
|
|
80
|
-
const elapsed = Date.now() - startedAt;
|
|
81
|
-
return {
|
|
82
|
-
success: false,
|
|
83
|
-
output: "",
|
|
84
|
-
error: "ACP response missing result",
|
|
85
|
-
exit_code: null,
|
|
86
|
-
elapsed_ms: elapsed,
|
|
87
|
-
stopped_reason: "error",
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// Persist the session key for subsequent requests
|
|
91
|
-
this.sessionKey = response.result.sessionKey;
|
|
92
|
-
const elapsed = Date.now() - startedAt;
|
|
93
|
-
return {
|
|
94
|
-
success: true,
|
|
95
|
-
output: response.result.content,
|
|
96
|
-
error: null,
|
|
97
|
-
exit_code: null,
|
|
98
|
-
elapsed_ms: elapsed,
|
|
99
|
-
stopped_reason: "completed",
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
catch (err) {
|
|
103
|
-
clearTimeout(timeoutHandle);
|
|
104
|
-
const elapsed = Date.now() - startedAt;
|
|
105
|
-
const errMessage = err instanceof Error ? err.message : String(err);
|
|
106
|
-
if (controller.signal.aborted) {
|
|
107
|
-
return {
|
|
108
|
-
success: false,
|
|
109
|
-
output: "",
|
|
110
|
-
error: `Timed out after ${task.timeout_ms}ms`,
|
|
111
|
-
exit_code: null,
|
|
112
|
-
elapsed_ms: elapsed,
|
|
113
|
-
stopped_reason: "timeout",
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
success: false,
|
|
118
|
-
output: "",
|
|
119
|
-
error: errMessage,
|
|
120
|
-
exit_code: null,
|
|
121
|
-
elapsed_ms: elapsed,
|
|
122
|
-
stopped_reason: "error",
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// ─── Private helpers ───
|
|
127
|
-
spawnProcess() {
|
|
128
|
-
const args = ["acp", "--profile", this.profile];
|
|
129
|
-
if (this.model) {
|
|
130
|
-
args.push("--model", this.model);
|
|
131
|
-
}
|
|
132
|
-
const child = spawn(this.cliPath, args, {
|
|
133
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
134
|
-
...(this.workDir !== undefined ? { cwd: this.workDir } : {}),
|
|
135
|
-
});
|
|
136
|
-
// Suppress EPIPE: the spawned process may close stdin before we write
|
|
137
|
-
child.stdin?.on("error", (err) => {
|
|
138
|
-
if (err.code !== "EPIPE")
|
|
139
|
-
throw err;
|
|
140
|
-
});
|
|
141
|
-
return child;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Write a JSON-RPC request to stdin and wait for the matching response from stdout.
|
|
145
|
-
* Responses are newline-delimited JSON. Skips lines that do not parse or belong to
|
|
146
|
-
* a different request ID.
|
|
147
|
-
*/
|
|
148
|
-
sendRequest(request, signal) {
|
|
149
|
-
return new Promise((resolve, reject) => {
|
|
150
|
-
if (!this.child) {
|
|
151
|
-
reject(new Error("Child process not available"));
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const child = this.child;
|
|
155
|
-
let buffer = "";
|
|
156
|
-
let settled = false;
|
|
157
|
-
const cleanup = () => {
|
|
158
|
-
child.stdout?.removeListener("data", onData);
|
|
159
|
-
child.removeListener("error", onError);
|
|
160
|
-
child.removeListener("close", onClose);
|
|
161
|
-
};
|
|
162
|
-
const settle = (fn) => {
|
|
163
|
-
if (settled)
|
|
164
|
-
return;
|
|
165
|
-
settled = true;
|
|
166
|
-
cleanup();
|
|
167
|
-
fn();
|
|
168
|
-
};
|
|
169
|
-
const onData = (chunk) => {
|
|
170
|
-
buffer += chunk.toString("utf8");
|
|
171
|
-
const lines = buffer.split("\n");
|
|
172
|
-
// Keep incomplete last line in buffer
|
|
173
|
-
buffer = lines.pop() ?? "";
|
|
174
|
-
for (const line of lines) {
|
|
175
|
-
const trimmed = line.trim();
|
|
176
|
-
if (!trimmed)
|
|
177
|
-
continue;
|
|
178
|
-
let parsed;
|
|
179
|
-
try {
|
|
180
|
-
parsed = JSON.parse(trimmed);
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
// Skip non-JSON lines (e.g., startup messages)
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
const resp = parsed;
|
|
187
|
-
if (resp.id === request.id) {
|
|
188
|
-
settle(() => resolve(resp));
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
const onError = (err) => {
|
|
194
|
-
settle(() => reject(err));
|
|
195
|
-
};
|
|
196
|
-
const onClose = () => {
|
|
197
|
-
settle(() => reject(new Error("OpenClaw process closed unexpectedly")));
|
|
198
|
-
};
|
|
199
|
-
// Abort handling
|
|
200
|
-
signal.addEventListener("abort", () => {
|
|
201
|
-
settle(() => reject(new Error("Aborted")));
|
|
202
|
-
});
|
|
203
|
-
child.stdout?.on("data", onData);
|
|
204
|
-
child.on("error", onError);
|
|
205
|
-
child.on("close", onClose);
|
|
206
|
-
// Send the request
|
|
207
|
-
const line = JSON.stringify(request) + "\n";
|
|
208
|
-
child.stdin?.write(line, "utf8");
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
//# sourceMappingURL=openclaw-acp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-acp.js","sourceRoot":"","sources":["../../../src/adapters/agents/openclaw-acp.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,2FAA2F;AAC3F,wFAAwF;AACxF,uDAAu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CAAC;gBACH,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,OAAO,GAAG,CAAC,GAAU,EAAQ,EAAE;gBACnC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5B,CAAC,CAAC;YAEF,MAAM,OAAO,GAAG,GAAS,EAAE;gBACzB,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC;YAEF,iBAAiB;YACjB,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;gBACpC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7C,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACjC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAE3B,mBAAmB;YACnB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YAC5C,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { IDataSourceAdapter } from "../../platform/observation/data-source-adapter.js";
|
|
2
|
-
import type { DataSourceType, DataSourceConfig, DataSourceQuery, DataSourceResult } from "../../base/types/data-source.js";
|
|
3
|
-
export interface OpenClawDataSourceConfig {
|
|
4
|
-
sessionDir?: string;
|
|
5
|
-
dimensionMapping?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
export declare class OpenClawDataSourceAdapter implements IDataSourceAdapter {
|
|
8
|
-
readonly sourceType: DataSourceType;
|
|
9
|
-
readonly config: DataSourceConfig;
|
|
10
|
-
private readonly sessionDir;
|
|
11
|
-
constructor(config: DataSourceConfig, opts?: OpenClawDataSourceConfig);
|
|
12
|
-
get sourceId(): string;
|
|
13
|
-
connect(): Promise<void>;
|
|
14
|
-
disconnect(): Promise<void>;
|
|
15
|
-
healthCheck(): Promise<boolean>;
|
|
16
|
-
getSupportedDimensions(): string[];
|
|
17
|
-
query(params: DataSourceQuery): Promise<DataSourceResult>;
|
|
18
|
-
/**
|
|
19
|
-
* List all JSONL files in the session directory.
|
|
20
|
-
* Returns empty array if directory does not exist.
|
|
21
|
-
*/
|
|
22
|
-
private listSessionFiles;
|
|
23
|
-
/**
|
|
24
|
-
* Parse events from a JSONL file, skipping malformed lines.
|
|
25
|
-
*/
|
|
26
|
-
private parseFile;
|
|
27
|
-
/**
|
|
28
|
-
* Aggregate stats across all session files.
|
|
29
|
-
* Only parses files needed for the requested dimension.
|
|
30
|
-
*/
|
|
31
|
-
private aggregate;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=openclaw-datasource.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-datasource.d.ts","sourceRoot":"","sources":["../../../src/adapters/datasources/openclaw-datasource.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AAWzC,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAaD,qBAAa,yBAA0B,YAAW,kBAAkB;IAClE,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAY;IAC/C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,EAAE,gBAAgB,EAAE,IAAI,GAAE,wBAA6B;IAOzE,IAAI,QAAQ,IAAI,MAAM,CAErB;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAUrC,sBAAsB,IAAI,MAAM,EAAE;IAI5B,KAAK,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsC/D;;;OAGG;YACW,gBAAgB;IAc9B;;OAEG;YACW,SAAS;IAwBvB;;;OAGG;YACW,SAAS;CAgDxB"}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
// ─── OpenClawDataSourceAdapter ───
|
|
2
|
-
//
|
|
3
|
-
// IDataSourceAdapter implementation that reads OpenClaw session logs to observe
|
|
4
|
-
// goal progress dimensions.
|
|
5
|
-
//
|
|
6
|
-
// Session logs are JSONL files under ~/.openclaw/sessions/ (configurable).
|
|
7
|
-
// Each line is a JSON event with a "type" field.
|
|
8
|
-
//
|
|
9
|
-
// Supported dimension_name values:
|
|
10
|
-
// "session_count" — number of JSONL session files found
|
|
11
|
-
// "last_session_status" — status string from the last event of the most recent file
|
|
12
|
-
// "total_messages" — total message events across all sessions
|
|
13
|
-
// "tool_call_count" — total tool_call events across all sessions
|
|
14
|
-
// "error_count" — total error events across all sessions
|
|
15
|
-
//
|
|
16
|
-
// dimension_mapping is supported: keys map query dimension names to internal ones.
|
|
17
|
-
import * as fsp from "node:fs/promises";
|
|
18
|
-
import * as path from "node:path";
|
|
19
|
-
import * as os from "node:os";
|
|
20
|
-
// Known dimensions this adapter supports
|
|
21
|
-
const KNOWN_DIMENSIONS = new Set([
|
|
22
|
-
"session_count",
|
|
23
|
-
"last_session_status",
|
|
24
|
-
"total_messages",
|
|
25
|
-
"tool_call_count",
|
|
26
|
-
"error_count",
|
|
27
|
-
]);
|
|
28
|
-
// ─── Adapter ───
|
|
29
|
-
export class OpenClawDataSourceAdapter {
|
|
30
|
-
sourceType = "custom";
|
|
31
|
-
config;
|
|
32
|
-
sessionDir;
|
|
33
|
-
constructor(config, opts = {}) {
|
|
34
|
-
this.config = config;
|
|
35
|
-
this.sessionDir =
|
|
36
|
-
opts.sessionDir ??
|
|
37
|
-
(config.connection.path || path.join(os.homedir(), ".openclaw", "sessions"));
|
|
38
|
-
}
|
|
39
|
-
get sourceId() {
|
|
40
|
-
return this.config.id;
|
|
41
|
-
}
|
|
42
|
-
async connect() {
|
|
43
|
-
// no persistent connection — directory checked at query time
|
|
44
|
-
}
|
|
45
|
-
async disconnect() {
|
|
46
|
-
// no-op
|
|
47
|
-
}
|
|
48
|
-
async healthCheck() {
|
|
49
|
-
try {
|
|
50
|
-
await fsp.access(this.sessionDir);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// Directory missing is not fatal — we return zero values instead
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
getSupportedDimensions() {
|
|
59
|
-
return Array.from(KNOWN_DIMENSIONS);
|
|
60
|
-
}
|
|
61
|
-
async query(params) {
|
|
62
|
-
// Resolve dimension via mapping
|
|
63
|
-
const dimMapping = this.config.dimension_mapping ?? {};
|
|
64
|
-
const rawDim = params.expression ?? params.dimension_name;
|
|
65
|
-
const dimension = dimMapping[rawDim] ?? rawDim;
|
|
66
|
-
if (!KNOWN_DIMENSIONS.has(dimension)) {
|
|
67
|
-
return {
|
|
68
|
-
value: null,
|
|
69
|
-
raw: null,
|
|
70
|
-
timestamp: new Date().toISOString(),
|
|
71
|
-
source_id: this.sourceId,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
// Read session files
|
|
75
|
-
const files = await this.listSessionFiles();
|
|
76
|
-
// Aggregate
|
|
77
|
-
const stats = await this.aggregate(files, dimension);
|
|
78
|
-
const value = dimension === "last_session_status"
|
|
79
|
-
? (stats.lastSessionStatus ?? null)
|
|
80
|
-
: stats[dimension];
|
|
81
|
-
return {
|
|
82
|
-
value,
|
|
83
|
-
raw: { session_files: files.length, dimension, stats },
|
|
84
|
-
timestamp: new Date().toISOString(),
|
|
85
|
-
source_id: this.sourceId,
|
|
86
|
-
metadata: stats,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
// ─── Private helpers ───
|
|
90
|
-
/**
|
|
91
|
-
* List all JSONL files in the session directory.
|
|
92
|
-
* Returns empty array if directory does not exist.
|
|
93
|
-
*/
|
|
94
|
-
async listSessionFiles() {
|
|
95
|
-
let entries;
|
|
96
|
-
try {
|
|
97
|
-
entries = await fsp.readdir(this.sessionDir);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return [];
|
|
101
|
-
}
|
|
102
|
-
return entries
|
|
103
|
-
.filter((f) => f.endsWith(".jsonl") || f.endsWith(".json"))
|
|
104
|
-
.map((f) => path.join(this.sessionDir, f))
|
|
105
|
-
.sort(); // stable order; last file = most recent
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Parse events from a JSONL file, skipping malformed lines.
|
|
109
|
-
*/
|
|
110
|
-
async parseFile(filePath) {
|
|
111
|
-
let content;
|
|
112
|
-
try {
|
|
113
|
-
content = await fsp.readFile(filePath, "utf-8");
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return [];
|
|
117
|
-
}
|
|
118
|
-
const events = [];
|
|
119
|
-
for (const line of content.split("\n")) {
|
|
120
|
-
const trimmed = line.trim();
|
|
121
|
-
if (!trimmed)
|
|
122
|
-
continue;
|
|
123
|
-
try {
|
|
124
|
-
const parsed = JSON.parse(trimmed);
|
|
125
|
-
if (typeof parsed === "object" && parsed !== null && "type" in parsed) {
|
|
126
|
-
events.push(parsed);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
// Skip malformed lines
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return events;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Aggregate stats across all session files.
|
|
137
|
-
* Only parses files needed for the requested dimension.
|
|
138
|
-
*/
|
|
139
|
-
async aggregate(files, dimension) {
|
|
140
|
-
const stats = {
|
|
141
|
-
session_count: files.length,
|
|
142
|
-
total_messages: 0,
|
|
143
|
-
tool_call_count: 0,
|
|
144
|
-
error_count: 0,
|
|
145
|
-
lastSessionStatus: null,
|
|
146
|
-
};
|
|
147
|
-
// If only session_count is needed, no file parsing required
|
|
148
|
-
if (dimension === "session_count")
|
|
149
|
-
return stats;
|
|
150
|
-
for (let i = 0; i < files.length; i++) {
|
|
151
|
-
const events = await this.parseFile(files[i]);
|
|
152
|
-
if (dimension === "total_messages" ||
|
|
153
|
-
dimension === "tool_call_count" ||
|
|
154
|
-
dimension === "error_count") {
|
|
155
|
-
for (const ev of events) {
|
|
156
|
-
if (ev.type === "message")
|
|
157
|
-
stats.total_messages++;
|
|
158
|
-
if (ev.type === "tool_call")
|
|
159
|
-
stats.tool_call_count++;
|
|
160
|
-
if (ev.type === "error")
|
|
161
|
-
stats.error_count++;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
// last_session_status: last event of the last file
|
|
165
|
-
if (dimension === "last_session_status" && i === files.length - 1) {
|
|
166
|
-
const lastEvent = events[events.length - 1];
|
|
167
|
-
if (lastEvent) {
|
|
168
|
-
stats.lastSessionStatus =
|
|
169
|
-
lastEvent.status ?? lastEvent.type ?? null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return stats;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=openclaw-datasource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openclaw-datasource.js","sourceRoot":"","sources":["../../../src/adapters/datasources/openclaw-datasource.ts"],"names":[],"mappings":"A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