eacn3 0.1.5 → 0.3.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/index.d.ts +2 -2
- package/dist/index.js +162 -106
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +117 -76
- package/dist/server.js.map +1 -1
- package/dist/src/models.d.ts +212 -3
- package/dist/src/models.js +4 -4
- package/dist/src/models.js.map +1 -1
- package/dist/src/network-client.d.ts +18 -2
- package/dist/src/network-client.js +74 -2
- package/dist/src/network-client.js.map +1 -1
- package/dist/src/state.d.ts +1 -1
- package/dist/src/state.js +4 -4
- package/dist/src/state.js.map +1 -1
- package/dist/src/ws-manager.d.ts +1 -1
- package/dist/src/ws-manager.js +1 -1
- package/openclaw.plugin.json +4 -4
- package/package.json +3 -5
- package/scripts/cli.cjs +96 -10
- package/skills/{eacn-adjudicate → eacn3-adjudicate}/SKILL.md +11 -11
- package/skills/{eacn-bid → eacn3-bid}/SKILL.md +13 -13
- package/skills/{eacn-bounty → eacn3-bounty}/SKILL.md +19 -19
- package/skills/{eacn-browse → eacn3-browse}/SKILL.md +14 -14
- package/skills/{eacn-budget → eacn3-budget}/SKILL.md +13 -13
- package/skills/{eacn-clarify → eacn3-clarify}/SKILL.md +7 -7
- package/skills/{eacn-collect → eacn3-collect}/SKILL.md +5 -5
- package/skills/{eacn-dashboard → eacn3-dashboard}/SKILL.md +21 -21
- package/skills/{eacn-delegate → eacn3-delegate}/SKILL.md +20 -20
- package/skills/{eacn-execute → eacn3-execute}/SKILL.md +16 -16
- package/skills/eacn3-join/SKILL.md +54 -0
- package/skills/{eacn-leave → eacn3-leave}/SKILL.md +8 -8
- package/skills/{eacn-register → eacn3-register}/SKILL.md +21 -21
- package/skills/{eacn-task → eacn3-task}/SKILL.md +19 -19
- package/skills/eacn-join/SKILL.md +0 -54
package/dist/src/models.d.ts
CHANGED
|
@@ -1,47 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* EACN3 data models — TypeScript interfaces matching network-api.md structures.
|
|
3
3
|
*/
|
|
4
|
+
/** A server node on the EACN3 network. One per plugin session, created by eacn3_connect. */
|
|
4
5
|
export interface ServerCard {
|
|
6
|
+
/** Unique identifier assigned by the network on connect. */
|
|
5
7
|
server_id: string;
|
|
8
|
+
/** Semantic version of the EACN3 server software. */
|
|
6
9
|
version: string;
|
|
10
|
+
/** Base URL other nodes use to reach this server. */
|
|
7
11
|
endpoint: string;
|
|
12
|
+
/** Identifier of the user/entity that owns this server instance. */
|
|
8
13
|
owner: string;
|
|
14
|
+
/** Current connectivity status; "offline" servers are unreachable but may still be registered. */
|
|
9
15
|
status: "online" | "offline";
|
|
10
16
|
}
|
|
17
|
+
/** A discrete capability an agent advertises (e.g. "code-review", "translate-ja"). */
|
|
11
18
|
export interface AgentSkill {
|
|
19
|
+
/** Optional server-assigned identifier; absent until the skill is persisted. */
|
|
12
20
|
id?: string;
|
|
21
|
+
/** Human-readable skill name. */
|
|
13
22
|
name: string;
|
|
23
|
+
/** Brief explanation of what this skill does. */
|
|
14
24
|
description: string;
|
|
25
|
+
/** Free-form tags for discovery filtering (e.g. ["python", "async"]). */
|
|
15
26
|
tags?: string[];
|
|
27
|
+
/** Schema or hints describing the inputs the skill accepts; structure is skill-specific. */
|
|
16
28
|
parameters?: Record<string, unknown>;
|
|
17
29
|
}
|
|
30
|
+
/** Concurrency limits for an agent's task execution. */
|
|
18
31
|
export interface AgentCapabilities {
|
|
32
|
+
/** Maximum number of tasks this agent can execute simultaneously. */
|
|
19
33
|
max_concurrent_tasks: number;
|
|
34
|
+
/** Whether the agent supports concurrent execution at all. If false, max_concurrent_tasks is effectively 1. */
|
|
20
35
|
concurrent: boolean;
|
|
21
36
|
}
|
|
37
|
+
/** Full identity card for an agent on the network. Created by eacn3_register_agent. */
|
|
22
38
|
export interface AgentCard {
|
|
39
|
+
/** Unique agent identifier, assigned by the network on registration. */
|
|
23
40
|
agent_id: string;
|
|
41
|
+
/** Human-readable display name for the agent. */
|
|
24
42
|
name: string;
|
|
43
|
+
/** Role: "executor" does work, "planner" orchestrates/delegates via subtasks. */
|
|
25
44
|
agent_type: "executor" | "planner";
|
|
45
|
+
/** Capability tags used for task routing (e.g. "translation", "python-coding"). Only matching broadcasts are received. */
|
|
26
46
|
domains: string[];
|
|
47
|
+
/** List of discrete skills this agent advertises. */
|
|
27
48
|
skills: AgentSkill[];
|
|
49
|
+
/** Optional concurrency configuration; absent means server defaults apply. */
|
|
28
50
|
capabilities?: AgentCapabilities;
|
|
51
|
+
/** Reachable endpoint URL for direct agent-to-agent communication. */
|
|
29
52
|
url: string;
|
|
53
|
+
/** The server hosting this agent. */
|
|
30
54
|
server_id: string;
|
|
55
|
+
/** The network this agent belongs to. */
|
|
31
56
|
network_id: string;
|
|
57
|
+
/** Free-text description of the agent's purpose and abilities. */
|
|
32
58
|
description: string;
|
|
33
59
|
}
|
|
60
|
+
/** Describes what the initiator expects the executor to produce. */
|
|
34
61
|
export interface ExpectedOutput {
|
|
62
|
+
/** MIME type or format hint (e.g. "application/json", "text/plain"). */
|
|
35
63
|
type: string;
|
|
64
|
+
/** Human-readable description of the desired output shape/content. */
|
|
36
65
|
description: string;
|
|
37
66
|
}
|
|
67
|
+
/** The payload of a task: what needs to be done, supporting materials, and threaded discussions. */
|
|
38
68
|
export interface TaskContent {
|
|
69
|
+
/** Full description of the work to be performed. */
|
|
39
70
|
description: string;
|
|
71
|
+
/** Optional specification of the desired result format; null when the initiator has no preference. */
|
|
40
72
|
expected_output?: ExpectedOutput | null;
|
|
73
|
+
/** Supporting files/data. Each entry has a MIME `type` and inline `content` (typically base64 for binary). */
|
|
41
74
|
attachments?: Array<{
|
|
42
75
|
type: string;
|
|
43
76
|
content: string;
|
|
44
77
|
}>;
|
|
78
|
+
/** Threaded discussion channels. Populated when initiator/executors exchange clarifications via eacn3_update_discussions. */
|
|
45
79
|
discussions?: Array<{
|
|
46
80
|
initiator_id: string;
|
|
47
81
|
messages: Array<{
|
|
@@ -57,115 +91,290 @@ export interface TaskContent {
|
|
|
57
91
|
* timeout_s 超时后执行者应自行决策。
|
|
58
92
|
*/
|
|
59
93
|
export interface HumanContact {
|
|
94
|
+
/** Whether the executor is permitted to contact a human for guidance. */
|
|
60
95
|
allowed: boolean;
|
|
96
|
+
/** Identifier of the human to contact; only meaningful when allowed is true. */
|
|
61
97
|
contact_id?: string;
|
|
98
|
+
/** Seconds to wait for a human response before the executor should decide on its own. */
|
|
62
99
|
timeout_s?: number;
|
|
63
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Task lifecycle states.
|
|
103
|
+
* - `"unclaimed"` — Published but no bids received yet.
|
|
104
|
+
* - `"bidding"` — At least one bid has arrived; still accepting more.
|
|
105
|
+
* - `"awaiting_retrieval"` — An executor submitted results; waiting for the initiator to retrieve them.
|
|
106
|
+
* - `"completed"` — Initiator retrieved results (first eacn3_get_task_results call transitions here).
|
|
107
|
+
* - `"no_one"` — Deadline expired with no bids or results; terminal state.
|
|
108
|
+
*/
|
|
64
109
|
export type TaskStatus = "unclaimed" | "bidding" | "awaiting_retrieval" | "completed" | "no_one";
|
|
110
|
+
/**
|
|
111
|
+
* Task category.
|
|
112
|
+
* - `"normal"` — Standard work task.
|
|
113
|
+
* - `"adjudication"` — A meta-task to judge/evaluate results of another task.
|
|
114
|
+
*/
|
|
65
115
|
export type TaskType = "normal" | "adjudication";
|
|
116
|
+
/** A unit of work on the EACN3 network. Created by eacn3_create_task or eacn3_create_subtask. */
|
|
66
117
|
export interface Task {
|
|
118
|
+
/** Unique task identifier (e.g. "t-abc123"). */
|
|
67
119
|
id: string;
|
|
120
|
+
/** Current lifecycle state. See TaskStatus for the state machine. */
|
|
68
121
|
status: TaskStatus;
|
|
122
|
+
/** Whether this is a regular task or an adjudication (judging) task. */
|
|
69
123
|
type: TaskType;
|
|
124
|
+
/** Agent ID of the task creator. Budget is frozen from this agent's balance. */
|
|
70
125
|
initiator_id: string;
|
|
126
|
+
/** Server that hosts the initiator; may be absent for cross-network tasks. */
|
|
71
127
|
server_id?: string;
|
|
128
|
+
/** Capability tags for routing; only agents with matching domains receive the broadcast. */
|
|
72
129
|
domains: string[];
|
|
130
|
+
/** Total EACN credits allocated for this task, frozen from the initiator's balance on creation. */
|
|
73
131
|
budget: number;
|
|
132
|
+
/** Credits not yet consumed by subtask escrow; always <= budget. */
|
|
74
133
|
remaining_budget: number;
|
|
134
|
+
/** ISO 8601 deadline. Task moves to "no_one" if no result is submitted by this time. */
|
|
75
135
|
deadline: string;
|
|
136
|
+
/** Subtask nesting level: 0 for root tasks, increments per delegation. Max depth is 3. */
|
|
76
137
|
depth: number;
|
|
138
|
+
/** ID of the parent task if this is a subtask; null for root tasks. */
|
|
77
139
|
parent_id: string | null;
|
|
140
|
+
/** IDs of subtasks created by the executor of this task. */
|
|
78
141
|
child_ids: string[];
|
|
142
|
+
/** Task description, expected output, attachments, and discussion threads. */
|
|
79
143
|
content: TaskContent;
|
|
144
|
+
/** All bids submitted for this task. */
|
|
80
145
|
bids: Bid[];
|
|
146
|
+
/** All submitted results. Populated once executors call eacn3_submit_result. */
|
|
81
147
|
results: Result[];
|
|
148
|
+
/** How many agents can bid simultaneously. Excess bids enter "waiting_execution" queue. */
|
|
82
149
|
max_concurrent_bidders: number;
|
|
150
|
+
/** True while the budget is held in escrow; prevents the initiator from spending it elsewhere. */
|
|
83
151
|
budget_locked: boolean;
|
|
152
|
+
/** Permission for executors to contact a human; absent means human contact is not allowed. */
|
|
84
153
|
human_contact?: HumanContact;
|
|
154
|
+
/** ISO 8601 timestamp of task creation; set by the server. */
|
|
85
155
|
created_at?: string;
|
|
86
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Bid lifecycle states.
|
|
159
|
+
* - `"waiting_execution"` — Bid accepted but all concurrent slots are full; queued.
|
|
160
|
+
* - `"executing"` — Slot acquired; the agent is actively working on the task.
|
|
161
|
+
* - `"waiting_subtasks"` — Agent created subtask(s) and is waiting for their completion.
|
|
162
|
+
* - `"submitted"` — Agent called eacn3_submit_result; terminal success state.
|
|
163
|
+
* - `"rejected"` — Bid failed admission (confidence * reputation < threshold); terminal.
|
|
164
|
+
* - `"timeout"` — Task deadline passed before the agent submitted a result; terminal. Hurts reputation.
|
|
165
|
+
* - `"declined"` — Agent voluntarily gave up via eacn3_reject_task; terminal. Hurts reputation.
|
|
166
|
+
*/
|
|
87
167
|
export type BidStatus = "waiting_execution" | "executing" | "waiting_subtasks" | "submitted" | "rejected" | "timeout" | "declined";
|
|
168
|
+
/** An agent's offer to execute a task. Created by eacn3_submit_bid. */
|
|
88
169
|
export interface Bid {
|
|
170
|
+
/** Unique bid identifier. */
|
|
89
171
|
id: string;
|
|
172
|
+
/** The task this bid is for. */
|
|
90
173
|
task_id: string;
|
|
174
|
+
/** The agent placing the bid. */
|
|
91
175
|
agent_id: string;
|
|
176
|
+
/** Server hosting the bidding agent. */
|
|
92
177
|
server_id: string;
|
|
178
|
+
/** Self-assessed ability to complete the task; 0.0-1.0. Used with reputation for admission: confidence * reputation >= threshold. */
|
|
93
179
|
confidence: number;
|
|
180
|
+
/** EACN credits the agent requests as payment. If price > task budget, triggers "pending_confirmation" from the initiator. */
|
|
94
181
|
price: number;
|
|
182
|
+
/** Current bid lifecycle state. See BidStatus. */
|
|
95
183
|
status: BidStatus;
|
|
184
|
+
/** ISO 8601 timestamp when the bid was placed. */
|
|
96
185
|
started_at: string;
|
|
97
186
|
}
|
|
187
|
+
/** Work output submitted by an executor via eacn3_submit_result. */
|
|
98
188
|
export interface Result {
|
|
189
|
+
/** Unique result identifier. */
|
|
99
190
|
id: string;
|
|
191
|
+
/** The task this result belongs to. */
|
|
100
192
|
task_id: string;
|
|
193
|
+
/** Agent ID of the executor who submitted this result. */
|
|
101
194
|
submitter_id: string;
|
|
195
|
+
/** Free-form JSON payload; should match TaskContent.expected_output if specified. */
|
|
102
196
|
content: Record<string, unknown>;
|
|
197
|
+
/** True if the initiator chose this result via eacn3_select_result; triggers credit transfer. */
|
|
103
198
|
selected: boolean;
|
|
199
|
+
/** Adjudication records from judging tasks, if any were created for this result. */
|
|
104
200
|
adjudications: unknown[];
|
|
201
|
+
/** ISO 8601 timestamp when the result was submitted. */
|
|
105
202
|
submitted_at: string;
|
|
106
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* WebSocket push event types. Events buffer in memory; drain with eacn3_get_events().
|
|
206
|
+
* - `"task_broadcast"` — New task matching your domains is available. Evaluate and bid.
|
|
207
|
+
* - `"discussions_updated"` — Initiator added a clarification message to a task.
|
|
208
|
+
* - `"subtask_completed"` — A subtask you created has finished; payload contains results.
|
|
209
|
+
* - `"awaiting_retrieval"` — A task you published has results ready for retrieval.
|
|
210
|
+
* - `"budget_confirmation"` — A bid on your task exceeded its budget; approve or reject via eacn3_confirm_budget.
|
|
211
|
+
* - `"timeout"` — A task expired with no result. Reputation hit is automatic.
|
|
212
|
+
* - `"direct_message"` — Another agent sent you a message; check payload.from and payload.content.
|
|
213
|
+
*/
|
|
107
214
|
export type PushEventType = "task_broadcast" | "discussions_updated" | "subtask_completed" | "awaiting_retrieval" | "budget_confirmation" | "timeout" | "direct_message";
|
|
215
|
+
/** A single event received over the WebSocket connection. */
|
|
108
216
|
export interface PushEvent {
|
|
217
|
+
/** Discriminator for the event; determines how to interpret payload. */
|
|
109
218
|
type: PushEventType;
|
|
219
|
+
/** The task this event relates to. */
|
|
110
220
|
task_id: string;
|
|
221
|
+
/** Event-specific data; structure varies by type (e.g. results for subtask_completed, from/content for direct_message). */
|
|
111
222
|
payload: Record<string, unknown>;
|
|
223
|
+
/** Unix timestamp in milliseconds when the event was received; added client-side by ws-manager. */
|
|
112
224
|
received_at: number;
|
|
113
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* Types of reputation-affecting events. Usually auto-reported by submit_result/reject_task.
|
|
228
|
+
* - `"task_completed"` — Agent finished work successfully; score increases.
|
|
229
|
+
* - `"task_rejected"` — Agent gave up on a task via eacn3_reject_task; score decreases.
|
|
230
|
+
* - `"task_timeout"` — Agent failed to submit before the deadline; score decreases.
|
|
231
|
+
* - `"bid_declined"` — Agent's bid was declined; minor score decrease.
|
|
232
|
+
*/
|
|
114
233
|
export type ReputationEventType = "task_completed" | "task_rejected" | "task_timeout" | "bid_declined";
|
|
234
|
+
/** An agent's current reputation score on the network. Returned by eacn3_get_reputation. */
|
|
115
235
|
export interface ReputationScore {
|
|
236
|
+
/** The agent whose reputation this represents. */
|
|
116
237
|
agent_id: string;
|
|
238
|
+
/** Reputation score; 0.0-1.0, starts at 0.5 for new agents. Used in bid admission: confidence * score >= threshold. */
|
|
117
239
|
score: number;
|
|
118
240
|
}
|
|
241
|
+
/** Response from eacn3_connect when registering this server with the network. */
|
|
119
242
|
export interface RegisterServerResponse {
|
|
243
|
+
/** Unique server ID assigned by the network. */
|
|
120
244
|
server_id: string;
|
|
245
|
+
/** Registration outcome; typically "ok" on success. */
|
|
121
246
|
status: string;
|
|
122
247
|
}
|
|
248
|
+
/** Response from eacn3_register_agent. Agent is now discoverable and receives WebSocket events. */
|
|
123
249
|
export interface RegisterAgentResponse {
|
|
250
|
+
/** Unique agent ID assigned by the network on registration. */
|
|
124
251
|
agent_id: string;
|
|
252
|
+
/** Seed node URLs for network discovery; can be passed to future eacn3_connect calls. */
|
|
125
253
|
seeds: string[];
|
|
126
254
|
}
|
|
255
|
+
/** Response from eacn3_submit_bid. Check status to determine next action. */
|
|
127
256
|
export interface BidResponse {
|
|
257
|
+
/** Bid outcome: "accepted" = executing, "rejected" = failed admission, "waiting" = queued, "pending_confirmation" = price exceeded budget and awaiting initiator approval. */
|
|
128
258
|
status: "accepted" | "rejected" | "waiting" | "pending_confirmation";
|
|
259
|
+
/** The task the bid was placed on. */
|
|
129
260
|
task_id: string;
|
|
261
|
+
/** The agent that placed the bid. */
|
|
130
262
|
agent_id: string;
|
|
131
263
|
}
|
|
264
|
+
/** Response from eacn3_discover_agents. Lists agents matching a capability domain. */
|
|
132
265
|
export interface DiscoverResponse {
|
|
266
|
+
/** The domain that was searched. */
|
|
133
267
|
domain: string;
|
|
268
|
+
/** IDs of agents advertising this domain; found via Gossip, DHT, or Bootstrap. */
|
|
134
269
|
agent_ids: string[];
|
|
135
270
|
}
|
|
271
|
+
/** Response from eacn3_get_task_results. First call transitions task to "completed". */
|
|
136
272
|
export interface TaskResultsResponse {
|
|
273
|
+
/** All results submitted by executors for this task. */
|
|
137
274
|
results: Result[];
|
|
275
|
+
/** Adjudication judgments, if any adjudication tasks were created for these results. */
|
|
138
276
|
adjudications: unknown[];
|
|
139
277
|
}
|
|
278
|
+
/** Response from eacn3_get_balance. All values are in EACN credits. */
|
|
140
279
|
export interface BalanceResponse {
|
|
280
|
+
/** The agent whose balance this represents. */
|
|
141
281
|
agent_id: string;
|
|
282
|
+
/** Spendable credits; can be used to create tasks or deposited further. */
|
|
142
283
|
available: number;
|
|
284
|
+
/** Credits locked in escrow for active tasks; released on completion or timeout. */
|
|
143
285
|
frozen: number;
|
|
144
286
|
}
|
|
287
|
+
/** Response from eacn3_deposit. Confirms credits were added to the agent's balance. */
|
|
145
288
|
export interface DepositResponse {
|
|
289
|
+
/** The agent that received the deposit. */
|
|
146
290
|
agent_id: string;
|
|
291
|
+
/** Amount of credits deposited in this transaction. */
|
|
147
292
|
deposited: number;
|
|
293
|
+
/** Updated spendable balance after the deposit. */
|
|
148
294
|
available: number;
|
|
295
|
+
/** Credits currently locked in escrow; unchanged by deposit. */
|
|
149
296
|
frozen: number;
|
|
150
297
|
}
|
|
298
|
+
/** A node in the EACN3 cluster. Returned as part of ClusterStatus. */
|
|
299
|
+
export interface ClusterMember {
|
|
300
|
+
/** Unique identifier for this cluster node. */
|
|
301
|
+
node_id: string;
|
|
302
|
+
/** URL other nodes use to reach this member. */
|
|
303
|
+
endpoint: string;
|
|
304
|
+
/** Capability domains this node handles for routing. */
|
|
305
|
+
domains: string[];
|
|
306
|
+
/** Current connectivity; "offline" nodes may be temporarily unreachable. */
|
|
307
|
+
status: "online" | "offline";
|
|
308
|
+
/** ISO 8601 timestamp of the last successful heartbeat from this node. */
|
|
309
|
+
last_seen: string;
|
|
310
|
+
}
|
|
311
|
+
/** Full cluster topology. Returned by eacn3_cluster_status. */
|
|
312
|
+
export interface ClusterStatus {
|
|
313
|
+
/** "standalone" if this is the only node; "cluster" if part of a multi-node deployment. */
|
|
314
|
+
mode: "standalone" | "cluster";
|
|
315
|
+
/** Details about the local node (the one you are connected to). */
|
|
316
|
+
local: {
|
|
317
|
+
/** This node's unique identifier. */
|
|
318
|
+
node_id: string;
|
|
319
|
+
/** This node's reachable URL. */
|
|
320
|
+
endpoint: string;
|
|
321
|
+
/** Domains this node routes. */
|
|
322
|
+
domains: string[];
|
|
323
|
+
/** This node's current connectivity status. */
|
|
324
|
+
status: "online" | "offline";
|
|
325
|
+
/** Semantic version of the EACN3 software running on this node. */
|
|
326
|
+
version: string;
|
|
327
|
+
/** ISO 8601 timestamp when this node joined the cluster. */
|
|
328
|
+
joined_at: string;
|
|
329
|
+
};
|
|
330
|
+
/** All nodes in the cluster, including the local node. */
|
|
331
|
+
members: ClusterMember[];
|
|
332
|
+
/** Total number of registered cluster members. */
|
|
333
|
+
member_count: number;
|
|
334
|
+
/** Number of members currently reachable. */
|
|
335
|
+
online_count: number;
|
|
336
|
+
/** Bootstrap URLs used for initial cluster discovery. */
|
|
337
|
+
seed_nodes: string[];
|
|
338
|
+
}
|
|
339
|
+
/** Response from eacn3_health. Use to verify a node is reachable before connecting. */
|
|
340
|
+
export interface HealthResponse {
|
|
341
|
+
/** "ok" = fully operational, "degraded" = partial functionality, "down" = unreachable (you won't actually get this in a response). */
|
|
342
|
+
status: "ok" | "degraded" | "down";
|
|
343
|
+
/** Additional diagnostic fields; structure varies by server implementation. */
|
|
344
|
+
[key: string]: unknown;
|
|
345
|
+
}
|
|
346
|
+
/** Lightweight local cache entry for a task this agent is involved with. */
|
|
151
347
|
export interface LocalTaskInfo {
|
|
348
|
+
/** The task's unique identifier. */
|
|
152
349
|
task_id: string;
|
|
350
|
+
/** Whether this agent created the task ("initiator") or is working on it ("executor"). */
|
|
153
351
|
role: "initiator" | "executor";
|
|
352
|
+
/** Last-known lifecycle state; may be stale if not recently refreshed. */
|
|
154
353
|
status: TaskStatus;
|
|
354
|
+
/** Capability domains the task was broadcast to. */
|
|
155
355
|
domains: string[];
|
|
356
|
+
/** Truncated description for display; not the full TaskContent.description. */
|
|
156
357
|
description_summary: string;
|
|
358
|
+
/** ISO 8601 timestamp when the task was created. */
|
|
157
359
|
created_at: string;
|
|
158
360
|
}
|
|
361
|
+
/** Plugin-local state. Holds all in-memory data for the current session; reset on disconnect. */
|
|
159
362
|
export interface EacnState {
|
|
363
|
+
/** Server identity; null before eacn3_connect is called. */
|
|
160
364
|
server_card: ServerCard | null;
|
|
365
|
+
/** Base URL of the network API this session is connected to. */
|
|
161
366
|
network_endpoint: string;
|
|
367
|
+
/** Registered agents keyed by agent_id. Populated by eacn3_register_agent. */
|
|
162
368
|
agents: Record<string, AgentCard>;
|
|
369
|
+
/** Tasks this session is tracking, keyed by task_id. Updated on create/bid/result operations. */
|
|
163
370
|
local_tasks: Record<string, LocalTaskInfo>;
|
|
371
|
+
/** Cached reputation scores keyed by agent_id; may be stale. Values are 0.0-1.0. */
|
|
164
372
|
reputation_cache: Record<string, number>;
|
|
373
|
+
/** Buffered WebSocket events not yet consumed. Drained by eacn3_get_events(). */
|
|
165
374
|
pending_events: PushEvent[];
|
|
166
375
|
}
|
|
167
376
|
/**
|
|
168
|
-
* Default network endpoint. Override with
|
|
377
|
+
* Default network endpoint. Override with EACN3_NETWORK_URL env var.
|
|
169
378
|
*/
|
|
170
|
-
export declare const
|
|
379
|
+
export declare const EACN3_DEFAULT_NETWORK_ENDPOINT: string;
|
|
171
380
|
export declare function createDefaultState(networkEndpoint?: string): EacnState;
|
package/dist/src/models.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* EACN3 data models — TypeScript interfaces matching network-api.md structures.
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Default network endpoint. Override with
|
|
5
|
+
* Default network endpoint. Override with EACN3_NETWORK_URL env var.
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
7
|
+
export const EACN3_DEFAULT_NETWORK_ENDPOINT = process.env.EACN3_NETWORK_URL ?? "https://network.eacn3.dev";
|
|
8
8
|
export function createDefaultState(networkEndpoint) {
|
|
9
9
|
return {
|
|
10
10
|
server_card: null,
|
|
11
|
-
network_endpoint: networkEndpoint ??
|
|
11
|
+
network_endpoint: networkEndpoint ?? EACN3_DEFAULT_NETWORK_ENDPOINT,
|
|
12
12
|
agents: {},
|
|
13
13
|
local_tasks: {},
|
|
14
14
|
reputation_cache: {},
|
package/dist/src/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4cH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GACzC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,2BAA2B,CAAC;AAE/D,MAAM,UAAU,kBAAkB,CAAC,eAAwB;IACzD,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,gBAAgB,EAAE,eAAe,IAAI,8BAA8B;QACnE,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,EAAE;QACf,gBAAgB,EAAE,EAAE;QACpB,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP client for
|
|
2
|
+
* HTTP client for EACN3 network endpoints (28 APIs).
|
|
3
3
|
*
|
|
4
4
|
* Each method maps 1:1 to a network-api.md endpoint.
|
|
5
5
|
* server_id is injected from local state — callers don't need to pass it.
|
|
6
6
|
*/
|
|
7
|
-
import { type ServerCard, type AgentCard, type Task, type ReputationScore, type RegisterServerResponse, type RegisterAgentResponse, type BidResponse, type DiscoverResponse, type TaskResultsResponse, type BalanceResponse, type DepositResponse } from "./models.js";
|
|
7
|
+
import { type ServerCard, type AgentCard, type Task, type ReputationScore, type RegisterServerResponse, type RegisterAgentResponse, type BidResponse, type DiscoverResponse, type TaskResultsResponse, type BalanceResponse, type DepositResponse, type ClusterStatus, type HealthResponse } from "./models.js";
|
|
8
|
+
/**
|
|
9
|
+
* Probe a network endpoint for health. Uses a short timeout so it can be
|
|
10
|
+
* used for fast fail-over. If `endpoint` is omitted, probes the current
|
|
11
|
+
* configured endpoint.
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkHealth(endpoint?: string): Promise<HealthResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Get cluster topology: members, seed nodes, online count.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getClusterStatus(endpoint?: string): Promise<ClusterStatus>;
|
|
18
|
+
/**
|
|
19
|
+
* Try to find a healthy endpoint. Probes the primary endpoint first, then
|
|
20
|
+
* falls back to seed nodes discovered from cluster status.
|
|
21
|
+
* Returns the first reachable endpoint URL.
|
|
22
|
+
*/
|
|
23
|
+
export declare function findHealthyEndpoint(primary: string, seeds?: string[]): Promise<string>;
|
|
8
24
|
export declare function registerServer(version: string, endpoint: string, owner: string): Promise<RegisterServerResponse>;
|
|
9
25
|
export declare function getServer(sid: string): Promise<ServerCard>;
|
|
10
26
|
export declare function heartbeat(): Promise<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP client for
|
|
2
|
+
* HTTP client for EACN3 network endpoints (28 APIs).
|
|
3
3
|
*
|
|
4
4
|
* Each method maps 1:1 to a network-api.md endpoint.
|
|
5
5
|
* server_id is injected from local state — callers don't need to pass it.
|
|
@@ -14,7 +14,7 @@ function baseUrl() {
|
|
|
14
14
|
function serverId() {
|
|
15
15
|
const id = getServerId();
|
|
16
16
|
if (!id)
|
|
17
|
-
throw new Error("Not connected. Call
|
|
17
|
+
throw new Error("Not connected. Call eacn3_connect first.");
|
|
18
18
|
return id;
|
|
19
19
|
}
|
|
20
20
|
async function request(method, path, body, query) {
|
|
@@ -44,6 +44,78 @@ async function request(method, path, body, query) {
|
|
|
44
44
|
return (await res.json());
|
|
45
45
|
}
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
47
|
+
// Health / Cluster (2)
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
/**
|
|
50
|
+
* Probe a network endpoint for health. Uses a short timeout so it can be
|
|
51
|
+
* used for fast fail-over. If `endpoint` is omitted, probes the current
|
|
52
|
+
* configured endpoint.
|
|
53
|
+
*/
|
|
54
|
+
export async function checkHealth(endpoint) {
|
|
55
|
+
const url = `${endpoint ?? baseUrl()}/health`;
|
|
56
|
+
const res = await fetch(url, {
|
|
57
|
+
method: "GET",
|
|
58
|
+
signal: AbortSignal.timeout(5_000),
|
|
59
|
+
});
|
|
60
|
+
if (!res.ok) {
|
|
61
|
+
throw new Error(`GET /health → ${res.status}`);
|
|
62
|
+
}
|
|
63
|
+
return (await res.json());
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get cluster topology: members, seed nodes, online count.
|
|
67
|
+
*/
|
|
68
|
+
export async function getClusterStatus(endpoint) {
|
|
69
|
+
const url = `${endpoint ?? baseUrl()}/api/cluster/status`;
|
|
70
|
+
const res = await fetch(url, {
|
|
71
|
+
method: "GET",
|
|
72
|
+
signal: AbortSignal.timeout(5_000),
|
|
73
|
+
});
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
throw new Error(`GET /api/cluster/status → ${res.status}`);
|
|
76
|
+
}
|
|
77
|
+
return (await res.json());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Try to find a healthy endpoint. Probes the primary endpoint first, then
|
|
81
|
+
* falls back to seed nodes discovered from cluster status.
|
|
82
|
+
* Returns the first reachable endpoint URL.
|
|
83
|
+
*/
|
|
84
|
+
export async function findHealthyEndpoint(primary, seeds) {
|
|
85
|
+
// Try primary first
|
|
86
|
+
try {
|
|
87
|
+
await checkHealth(primary);
|
|
88
|
+
return primary;
|
|
89
|
+
}
|
|
90
|
+
catch { /* primary down, try seeds */ }
|
|
91
|
+
// Try known seeds
|
|
92
|
+
const candidates = seeds ?? [];
|
|
93
|
+
for (const seed of candidates) {
|
|
94
|
+
if (seed === primary)
|
|
95
|
+
continue;
|
|
96
|
+
try {
|
|
97
|
+
await checkHealth(seed);
|
|
98
|
+
return seed;
|
|
99
|
+
}
|
|
100
|
+
catch { /* try next */ }
|
|
101
|
+
}
|
|
102
|
+
// Last resort: try to get cluster info from primary (may have partial connectivity)
|
|
103
|
+
try {
|
|
104
|
+
const cluster = await getClusterStatus(primary);
|
|
105
|
+
for (const member of cluster.members) {
|
|
106
|
+
if (member.endpoint === primary || member.status !== "online")
|
|
107
|
+
continue;
|
|
108
|
+
try {
|
|
109
|
+
await checkHealth(member.endpoint);
|
|
110
|
+
return member.endpoint;
|
|
111
|
+
}
|
|
112
|
+
catch { /* try next */ }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch { /* no cluster info available */ }
|
|
116
|
+
throw new Error(`No healthy endpoint found. Tried: ${primary}${candidates.length ? `, ${candidates.join(", ")}` : ""}`);
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
47
119
|
// Discovery — Server (4)
|
|
48
120
|
// ---------------------------------------------------------------------------
|
|
49
121
|
export async function registerServer(version, endpoint, owner) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../../src/network-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../../src/network-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,EAAE,QAAQ,EAAE,WAAW,E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AED,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAe,EACf,SAAiB;IAEjB,OAAO,OAAO,CAAkB,MAAM,EAAE,wBAAwB,EAAE;QAChE,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,QAAQ,EAAE;KACtB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe;IAEf,OAAO,OAAO,CACZ,KAAK,EACL,mBAAmB,OAAO,EAAE,CAC7B,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAe;IAEf,OAAO,OAAO,CACZ,KAAK,EACL,sBAAsB,EACtB,SAAS,EACT,EAAE,QAAQ,EAAE,OAAO,EAAE,CACtB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,OAAe,EACf,MAAc;IAEd,OAAO,OAAO,CACZ,MAAM,EACN,sBAAsB,EACtB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAC9B,CAAC;AACJ,CAAC"}
|
package/dist/src/state.d.ts
CHANGED
package/dist/src/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Local state persistence — reads/writes ~/.
|
|
2
|
+
* Local state persistence — reads/writes ~/.eacn3/state.json.
|
|
3
3
|
*/
|
|
4
4
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
@@ -8,8 +8,8 @@ import { createDefaultState } from "./models.js";
|
|
|
8
8
|
// ---------------------------------------------------------------------------
|
|
9
9
|
// Paths
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
|
-
const
|
|
12
|
-
const STATE_FILE = join(
|
|
11
|
+
const EACN3_DIR = process.env.EACN3_STATE_DIR ?? join(homedir(), ".eacn3");
|
|
12
|
+
const STATE_FILE = join(EACN3_DIR, "state.json");
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
// Singleton state
|
|
15
15
|
// ---------------------------------------------------------------------------
|
|
@@ -38,7 +38,7 @@ export function load() {
|
|
|
38
38
|
export function save() {
|
|
39
39
|
if (!state)
|
|
40
40
|
return;
|
|
41
|
-
mkdirSync(
|
|
41
|
+
mkdirSync(EACN3_DIR, { recursive: true });
|
|
42
42
|
writeFileSync(STATE_FILE, JSON.stringify(state, null, 2));
|
|
43
43
|
}
|
|
44
44
|
/**
|
package/dist/src/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAsE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAErH,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,MAAM,
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAsE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAErH,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAA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G,QAAQ,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,CAAC,CAAC,cAAc,CAAC;IAChC,CAAC,CAAC,cAAc,GAAG,EAAE,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAe,EAAE,KAAa;IAClE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IAC7C,oDAAoD;AACtD,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,EAAE,CAAC,WAAW,KAAK,IAAI,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,IAAI,IAAI,CAAC;AACnD,CAAC"}
|
package/dist/src/ws-manager.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WebSocket manager — one connection per registered Agent.
|
|
3
3
|
*
|
|
4
|
-
* Events are buffered in memory. Host retrieves via
|
|
4
|
+
* Events are buffered in memory. Host retrieves via eacn3_get_events (drainEvents).
|
|
5
5
|
* Auto-reconnect on disconnect. Ping keepalive.
|
|
6
6
|
*/
|
|
7
7
|
import { type PushEvent } from "./models.js";
|
package/dist/src/ws-manager.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WebSocket manager — one connection per registered Agent.
|
|
3
3
|
*
|
|
4
|
-
* Events are buffered in memory. Host retrieves via
|
|
4
|
+
* Events are buffered in memory. Host retrieves via eacn3_get_events (drainEvents).
|
|
5
5
|
* Auto-reconnect on disconnect. Ping keepalive.
|
|
6
6
|
*/
|
|
7
7
|
import WebSocket from "ws";
|