@cleocode/contracts 2026.3.74 → 2026.3.76
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/agent-registry.d.ts +78 -0
- package/dist/agent-registry.d.ts.map +1 -0
- package/dist/agent-registry.js +12 -0
- package/dist/agent-registry.js.map +1 -0
- package/dist/conduit.d.ts +14 -7
- package/dist/conduit.d.ts.map +1 -1
- package/dist/conduit.js +4 -1
- package/dist/conduit.js.map +1 -1
- package/dist/data-accessor.d.ts +47 -0
- package/dist/data-accessor.d.ts.map +1 -1
- package/dist/data-accessor.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lafs.d.ts +1 -1
- package/dist/lafs.js +1 -1
- package/dist/task.d.ts +2 -0
- package/dist/task.d.ts.map +1 -1
- package/dist/transport.d.ts +49 -5
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +10 -3
- package/dist/transport.js.map +1 -1
- package/dist/wasm/index.d.ts +114 -0
- package/dist/wasm/index.d.ts.map +1 -0
- package/dist/wasm/index.js +184 -0
- package/dist/wasm/index.js.map +1 -0
- package/package.json +1 -1
- package/src/agent-registry.ts +100 -0
- package/src/conduit.ts +14 -7
- package/src/data-accessor.ts +56 -0
- package/src/index.ts +17 -1
- package/src/lafs.ts +2 -2
- package/src/task.ts +3 -0
- package/src/transport.ts +69 -5
- package/src/wasm/index.ts +193 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central WASM SDK for CLEO Core Contracts
|
|
3
|
+
*
|
|
4
|
+
* Provides unified access to all Rust crate WASM modules:
|
|
5
|
+
* - lafs-core: LAFS envelope types and validation
|
|
6
|
+
* - conduit-core: Conduit wire types and CANT metadata
|
|
7
|
+
* - cant-core: CANT grammar parser (via @cleocode/cant)
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { initWasm, lafs, conduit } from '@cleocode/contracts/wasm';
|
|
12
|
+
*
|
|
13
|
+
* await initWasm();
|
|
14
|
+
*
|
|
15
|
+
* // LAFS
|
|
16
|
+
* const meta = new lafs.WasmLafsMeta('tasks.list', 'http');
|
|
17
|
+
* const envelope = lafs.WasmLafsEnvelope.createSuccess('{"tasks":[]}', meta);
|
|
18
|
+
*
|
|
19
|
+
* // Conduit
|
|
20
|
+
* const msg = new conduit.WasmConduitMessage('msg-1', 'agent-a', 'Hello', '2026-03-25T00:00:00Z');
|
|
21
|
+
* const cant = new conduit.WasmCantMetadata('actionable', '["@agent"]', '["T123"]', '["#tag"]');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// WASM module instances
|
|
25
|
+
let lafsModule = null;
|
|
26
|
+
let conduitModule = null;
|
|
27
|
+
let isInitialized = false;
|
|
28
|
+
let isInitializing = false;
|
|
29
|
+
let initPromise = null;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize all WASM modules
|
|
32
|
+
* Must be called before using any WASM classes/functions
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import { initWasm, lafs, conduit } from '@cleocode/contracts/wasm';
|
|
37
|
+
*
|
|
38
|
+
* await initWasm();
|
|
39
|
+
*
|
|
40
|
+
* // Now you can use WASM classes
|
|
41
|
+
* const meta = new lafs.WasmLafsMeta('tasks.list', 'http');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export async function initWasm() {
|
|
45
|
+
if (isInitialized)
|
|
46
|
+
return;
|
|
47
|
+
if (isInitializing) {
|
|
48
|
+
return initPromise;
|
|
49
|
+
}
|
|
50
|
+
isInitializing = true;
|
|
51
|
+
initPromise = (async () => {
|
|
52
|
+
try {
|
|
53
|
+
// Dynamic imports to avoid loading if not needed
|
|
54
|
+
const [lafs, conduit] = await Promise.all([
|
|
55
|
+
import('./lafs-core/lafs_core.js'),
|
|
56
|
+
import('./conduit-core/conduit_core.js'),
|
|
57
|
+
]);
|
|
58
|
+
// Initialize modules
|
|
59
|
+
await Promise.all([lafs.default(), conduit.default()]);
|
|
60
|
+
lafsModule = lafs;
|
|
61
|
+
conduitModule = conduit;
|
|
62
|
+
isInitialized = true;
|
|
63
|
+
}
|
|
64
|
+
catch (_error) {
|
|
65
|
+
throw new Error('WASM initialization failed. Ensure WASM files are present.');
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
await initPromise;
|
|
69
|
+
isInitializing = false;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if WASM is initialized and ready to use
|
|
73
|
+
*
|
|
74
|
+
* @returns true if WASM modules are loaded and initialized
|
|
75
|
+
*/
|
|
76
|
+
export function isWasmReady() {
|
|
77
|
+
return isInitialized;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* LAFS Core WASM exports
|
|
81
|
+
*
|
|
82
|
+
* Available after calling initWasm():
|
|
83
|
+
* - WasmLafsTransport - Transport type (Cli, Http, Grpc, Sdk)
|
|
84
|
+
* - WasmLafsMeta - Metadata for LAFS envelopes
|
|
85
|
+
* - WasmLafsEnvelope - The main LAFS response envelope
|
|
86
|
+
* - createTransport() - Helper to create transport from string
|
|
87
|
+
*/
|
|
88
|
+
export const lafs = {
|
|
89
|
+
/**
|
|
90
|
+
* LAFS Transport enum
|
|
91
|
+
* Use WasmLafsTransport.cli(), .http(), .grpc(), or .sdk()
|
|
92
|
+
*/
|
|
93
|
+
get WasmLafsTransport() {
|
|
94
|
+
if (!lafsModule)
|
|
95
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
96
|
+
return lafsModule.WasmLafsTransport;
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* LAFS Metadata constructor
|
|
100
|
+
* new WasmLafsMeta(operation: string, transport: string)
|
|
101
|
+
*/
|
|
102
|
+
get WasmLafsMeta() {
|
|
103
|
+
if (!lafsModule)
|
|
104
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
105
|
+
return lafsModule.WasmLafsMeta;
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* LAFS Envelope class
|
|
109
|
+
* Use WasmLafsEnvelope.createSuccess() or .createError()
|
|
110
|
+
*/
|
|
111
|
+
get WasmLafsEnvelope() {
|
|
112
|
+
if (!lafsModule)
|
|
113
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
114
|
+
return lafsModule.WasmLafsEnvelope;
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Helper function to create transport from string
|
|
118
|
+
* @param transport - "cli", "http", "grpc", or "sdk"
|
|
119
|
+
*/
|
|
120
|
+
get createTransport() {
|
|
121
|
+
if (!lafsModule)
|
|
122
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
123
|
+
return lafsModule.create_transport;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Conduit Core WASM exports
|
|
128
|
+
*
|
|
129
|
+
* Available after calling initWasm():
|
|
130
|
+
* - WasmConduitMessage - Agent-to-agent messages
|
|
131
|
+
* - WasmConduitState - Connection states (Disconnected, Connecting, Connected, etc.)
|
|
132
|
+
* - WasmCantMetadata - CANT parsing results
|
|
133
|
+
* - parseConduitMessage() - Parse message from JSON
|
|
134
|
+
* - createConduitState() - Create state from string
|
|
135
|
+
*/
|
|
136
|
+
export const conduit = {
|
|
137
|
+
/**
|
|
138
|
+
* Conduit Message constructor
|
|
139
|
+
* new WasmConduitMessage(id, from, content, timestamp)
|
|
140
|
+
*/
|
|
141
|
+
get WasmConduitMessage() {
|
|
142
|
+
if (!conduitModule)
|
|
143
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
144
|
+
return conduitModule.WasmConduitMessage;
|
|
145
|
+
},
|
|
146
|
+
/**
|
|
147
|
+
* Conduit State enum
|
|
148
|
+
* Use WasmConduitState.disconnected(), .connecting(), .connected(), etc.
|
|
149
|
+
*/
|
|
150
|
+
get WasmConduitState() {
|
|
151
|
+
if (!conduitModule)
|
|
152
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
153
|
+
return conduitModule.WasmConduitState;
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* CANT Metadata constructor
|
|
157
|
+
* new WasmCantMetadata(directiveType, addressesJson, taskRefsJson, tagsJson)
|
|
158
|
+
*/
|
|
159
|
+
get WasmCantMetadata() {
|
|
160
|
+
if (!conduitModule)
|
|
161
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
162
|
+
return conduitModule.WasmCantMetadata;
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* Parse a ConduitMessage from JSON string
|
|
166
|
+
* @param json - JSON string
|
|
167
|
+
* @returns WasmConduitMessage or undefined
|
|
168
|
+
*/
|
|
169
|
+
get parseConduitMessage() {
|
|
170
|
+
if (!conduitModule)
|
|
171
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
172
|
+
return conduitModule.parse_conduit_message;
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* Create a ConduitState from string
|
|
176
|
+
* @param state - "disconnected", "connecting", "connected", "reconnecting", "error"
|
|
177
|
+
*/
|
|
178
|
+
get createConduitState() {
|
|
179
|
+
if (!conduitModule)
|
|
180
|
+
throw new Error('WASM not initialized. Call initWasm() first.');
|
|
181
|
+
return conduitModule.create_conduit_state;
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,wBAAwB;AACxB,IAAI,UAAU,GAA0B,IAAI,CAAC;AAC7C,IAAI,aAAa,GAA6B,IAAI,CAAC;AACnD,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,IAAI,cAAc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;QACpF,OAAO,aAAa,CAAC,oBAAoB,CAAC;IAC5C,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Registry — Credential management and lifecycle for registered agents.
|
|
3
|
+
*
|
|
4
|
+
* Provides typed CRUD operations for agent credentials stored in the
|
|
5
|
+
* local project database (`.cleo/tasks.db`). API keys are encrypted at
|
|
6
|
+
* rest using AES-256-GCM with a machine-bound key.
|
|
7
|
+
*
|
|
8
|
+
* @see docs/specs/SIGNALDOCK-UNIFIED-AGENT-REGISTRY.md Section 3
|
|
9
|
+
* @module agent-registry
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Transport configuration
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
/** Transport-specific configuration stored per agent credential. */
|
|
17
|
+
export interface TransportConfig {
|
|
18
|
+
/** Polling interval in milliseconds (for HTTP polling transport). */
|
|
19
|
+
pollIntervalMs?: number;
|
|
20
|
+
/** SSE endpoint URL (for Server-Sent Events transport). */
|
|
21
|
+
sseEndpoint?: string;
|
|
22
|
+
/** WebSocket URL (for WebSocket transport). */
|
|
23
|
+
wsUrl?: string;
|
|
24
|
+
/** HTTP polling endpoint path (for HTTP polling transport). */
|
|
25
|
+
pollEndpoint?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// Agent credential
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
/** A registered agent's credentials and profile. */
|
|
33
|
+
export interface AgentCredential {
|
|
34
|
+
/** Unique agent identifier (e.g. 'cleo-core', 'forge-ts-opus'). */
|
|
35
|
+
agentId: string;
|
|
36
|
+
/** Human-readable display name. */
|
|
37
|
+
displayName: string;
|
|
38
|
+
/** API key for authentication (`sk_live_*`). Stored encrypted at rest. */
|
|
39
|
+
apiKey: string;
|
|
40
|
+
/** Base URL of the messaging API (default: api.signaldock.io, legacy: api.clawmsgr.com). */
|
|
41
|
+
apiBaseUrl: string;
|
|
42
|
+
/** Agent classification from the registry (e.g. 'code_dev', 'orchestrator'). */
|
|
43
|
+
classification?: string;
|
|
44
|
+
/** Privacy tier controlling discoverability. */
|
|
45
|
+
privacyTier: 'public' | 'discoverable' | 'private';
|
|
46
|
+
/** Agent capabilities (e.g. ['chat', 'tools', 'code-execution']). */
|
|
47
|
+
capabilities: string[];
|
|
48
|
+
/** Agent skills (e.g. ['coding', 'review', 'testing']). */
|
|
49
|
+
skills: string[];
|
|
50
|
+
/** Transport-specific configuration. */
|
|
51
|
+
transportConfig: TransportConfig;
|
|
52
|
+
/** Whether this agent is currently active. */
|
|
53
|
+
isActive: boolean;
|
|
54
|
+
/** ISO 8601 timestamp of last use (polling, sending, etc.). */
|
|
55
|
+
lastUsedAt?: string;
|
|
56
|
+
/** ISO 8601 creation timestamp. */
|
|
57
|
+
createdAt: string;
|
|
58
|
+
/** ISO 8601 last update timestamp. */
|
|
59
|
+
updatedAt: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// Registry API
|
|
64
|
+
// ============================================================================
|
|
65
|
+
|
|
66
|
+
/** Filter options for listing agent credentials. */
|
|
67
|
+
export interface AgentListFilter {
|
|
68
|
+
/** Filter by active/inactive status. */
|
|
69
|
+
active?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** CRUD and lifecycle operations for agent credentials. */
|
|
73
|
+
export interface AgentRegistryAPI {
|
|
74
|
+
/** Register a new agent credential. */
|
|
75
|
+
register(credential: Omit<AgentCredential, 'createdAt' | 'updatedAt'>): Promise<AgentCredential>;
|
|
76
|
+
|
|
77
|
+
/** Get a single agent credential by ID. Returns null if not found. */
|
|
78
|
+
get(agentId: string): Promise<AgentCredential | null>;
|
|
79
|
+
|
|
80
|
+
/** List agent credentials with optional filtering. */
|
|
81
|
+
list(filter?: AgentListFilter): Promise<AgentCredential[]>;
|
|
82
|
+
|
|
83
|
+
/** Update fields on an existing agent credential. */
|
|
84
|
+
update(
|
|
85
|
+
agentId: string,
|
|
86
|
+
updates: Partial<Omit<AgentCredential, 'agentId' | 'createdAt'>>,
|
|
87
|
+
): Promise<AgentCredential>;
|
|
88
|
+
|
|
89
|
+
/** Remove an agent credential permanently. */
|
|
90
|
+
remove(agentId: string): Promise<void>;
|
|
91
|
+
|
|
92
|
+
/** Rotate an agent's API key (generates new key on cloud, re-encrypts locally). */
|
|
93
|
+
rotateKey(agentId: string): Promise<{ agentId: string; newApiKey: string }>;
|
|
94
|
+
|
|
95
|
+
/** Get the most recently used active agent credential. Returns null if none. */
|
|
96
|
+
getActive(): Promise<AgentCredential | null>;
|
|
97
|
+
|
|
98
|
+
/** Mark an agent as recently used (updates `lastUsedAt`). */
|
|
99
|
+
markUsed(agentId: string): Promise<void>;
|
|
100
|
+
}
|
package/src/conduit.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conduit Protocol — Agent-to-agent communication interface.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* This is a CLIENT-SIDE interface. Implementations call a messaging
|
|
5
|
+
* backend (SignalDock REST API, local napi-rs, etc.). SignalDock is
|
|
6
|
+
* the canonical backend; it does NOT implement this TypeScript interface.
|
|
7
|
+
*
|
|
5
8
|
* CLEO Core defines the contract in @cleocode/contracts.
|
|
6
9
|
*
|
|
7
10
|
* This is the canonical TypeScript interface for the Conduit Protocol
|
|
@@ -81,16 +84,20 @@ export interface ConduitStateChange {
|
|
|
81
84
|
// ============================================================================
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
|
-
* The Conduit Protocol interface.
|
|
87
|
+
* The Conduit Protocol interface — high-level agent messaging.
|
|
88
|
+
*
|
|
89
|
+
* Conduit wraps a Transport adapter, adding messaging semantics.
|
|
85
90
|
*
|
|
86
91
|
* Implementations:
|
|
87
|
-
* -
|
|
88
|
-
* -
|
|
89
|
-
* -
|
|
92
|
+
* - `ConduitClient` (`@cleocode/core` — wraps any Transport)
|
|
93
|
+
* - `HttpTransport` (HTTP polling to cloud SignalDock API)
|
|
94
|
+
* - `LocalTransport` (napi-rs in-process — embedded SignalDock, future)
|
|
95
|
+
* - `SseTransport` (Server-Sent Events — real-time cloud, future)
|
|
90
96
|
*
|
|
91
97
|
* Consumers:
|
|
92
|
-
* -
|
|
93
|
-
* -
|
|
98
|
+
* - `@cleocode/cleo` CLI (`cleo agent watch/poll/send`)
|
|
99
|
+
* - `@cleocode/runtime` (background polling, SSE connections)
|
|
100
|
+
* - CleoOS Electron (embedded SignalDock via LocalTransport)
|
|
94
101
|
* - Agent spawners (deliver task assignments, collect results)
|
|
95
102
|
*/
|
|
96
103
|
export interface Conduit {
|
package/src/data-accessor.ts
CHANGED
|
@@ -17,6 +17,26 @@ import type { ArchivedTask } from './archive.js';
|
|
|
17
17
|
import type { Session } from './session.js';
|
|
18
18
|
import type { Task, TaskPriority, TaskSize, TaskStatus, TaskType } from './task.js';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Agent instance row shape for DataAccessor methods.
|
|
22
|
+
* Mirrors the agent_instances Drizzle table in core but avoids Drizzle dependency.
|
|
23
|
+
*/
|
|
24
|
+
export interface DataAccessorAgentInstance {
|
|
25
|
+
id: string;
|
|
26
|
+
agentType: string;
|
|
27
|
+
status: string;
|
|
28
|
+
sessionId: string | null;
|
|
29
|
+
taskId: string | null;
|
|
30
|
+
startedAt: string;
|
|
31
|
+
lastHeartbeat: string;
|
|
32
|
+
stoppedAt: string | null;
|
|
33
|
+
errorCount: number;
|
|
34
|
+
totalTasksCompleted: number;
|
|
35
|
+
capacity: string;
|
|
36
|
+
metadataJson: string | null;
|
|
37
|
+
parentAgentId: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
20
40
|
/** Archive-specific fields for task upsert. */
|
|
21
41
|
export interface ArchiveFields {
|
|
22
42
|
archivedAt?: string;
|
|
@@ -83,6 +103,7 @@ export interface TaskFieldUpdates {
|
|
|
83
103
|
modifiedBy?: string | null;
|
|
84
104
|
sessionId?: string | null;
|
|
85
105
|
updatedAt?: string | null;
|
|
106
|
+
assignee?: string | null;
|
|
86
107
|
}
|
|
87
108
|
|
|
88
109
|
/**
|
|
@@ -227,6 +248,41 @@ export interface DataAccessor {
|
|
|
227
248
|
|
|
228
249
|
/** Remove a single session by ID. */
|
|
229
250
|
removeSingleSession(sessionId: string): Promise<void>;
|
|
251
|
+
|
|
252
|
+
// ---- Agent instances ----
|
|
253
|
+
|
|
254
|
+
/** List agent instances with optional filters. Returns rows from agent_instances table. */
|
|
255
|
+
listAgentInstances(filters?: {
|
|
256
|
+
status?: string | string[];
|
|
257
|
+
agentType?: string | string[];
|
|
258
|
+
}): Promise<DataAccessorAgentInstance[]>;
|
|
259
|
+
|
|
260
|
+
/** Get a single agent instance by ID. Returns null if not found. */
|
|
261
|
+
getAgentInstance(agentId: string): Promise<DataAccessorAgentInstance | null>;
|
|
262
|
+
|
|
263
|
+
// ---- Agent task claiming ----
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Atomically claim a task for an agent.
|
|
267
|
+
*
|
|
268
|
+
* Uses `UPDATE ... WHERE assignee IS NULL OR assignee = agentId` to prevent
|
|
269
|
+
* race conditions. Throws if the task is already claimed by a different agent.
|
|
270
|
+
*
|
|
271
|
+
* @param taskId - ID of the task to claim.
|
|
272
|
+
* @param agentId - Agent identifier claiming the task.
|
|
273
|
+
* @throws {Error} When the task is not found or is already claimed by another agent.
|
|
274
|
+
*/
|
|
275
|
+
claimTask(taskId: string, agentId: string): Promise<void>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Release a claimed task, clearing its assignee.
|
|
279
|
+
*
|
|
280
|
+
* No-op if the task is not currently claimed.
|
|
281
|
+
*
|
|
282
|
+
* @param taskId - ID of the task to unclaim.
|
|
283
|
+
* @throws {Error} When the task is not found.
|
|
284
|
+
*/
|
|
285
|
+
unclaimTask(taskId: string): Promise<void>;
|
|
230
286
|
}
|
|
231
287
|
|
|
232
288
|
// Factory functions (createDataAccessor, getAccessor) live in @cleocode/core,
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
// === Provider Adapter Contracts ===
|
|
10
10
|
export type { AdapterHealthStatus, CLEOProviderAdapter } from './adapter.js';
|
|
11
|
+
// === Agent Registry (credential management) ===
|
|
12
|
+
export type {
|
|
13
|
+
AgentCredential,
|
|
14
|
+
AgentListFilter,
|
|
15
|
+
AgentRegistryAPI,
|
|
16
|
+
TransportConfig,
|
|
17
|
+
} from './agent-registry.js';
|
|
11
18
|
// === Archive Types ===
|
|
12
19
|
export type {
|
|
13
20
|
ArchiveCycleTimesReport,
|
|
@@ -76,6 +83,7 @@ export type {
|
|
|
76
83
|
ArchiveFields,
|
|
77
84
|
ArchiveFile,
|
|
78
85
|
DataAccessor,
|
|
86
|
+
DataAccessorAgentInstance,
|
|
79
87
|
QueryTasksResult,
|
|
80
88
|
TaskFieldUpdates,
|
|
81
89
|
TaskQueryFilters,
|
|
@@ -313,7 +321,12 @@ export type {
|
|
|
313
321
|
TesseraTemplate,
|
|
314
322
|
TesseraVariable,
|
|
315
323
|
} from './tessera.js';
|
|
316
|
-
|
|
324
|
+
// === Transport (low-level wire protocol) ===
|
|
325
|
+
export type {
|
|
326
|
+
AdapterTransportProvider,
|
|
327
|
+
Transport,
|
|
328
|
+
TransportConnectConfig,
|
|
329
|
+
} from './transport.js';
|
|
317
330
|
// === WarpChain Types ===
|
|
318
331
|
export type {
|
|
319
332
|
ChainShape,
|
|
@@ -329,3 +342,6 @@ export type {
|
|
|
329
342
|
WarpLink,
|
|
330
343
|
WarpStage,
|
|
331
344
|
} from './warp-chain.js';
|
|
345
|
+
|
|
346
|
+
// === WASM SDK (Rust crate bindings) ===
|
|
347
|
+
export * as wasm from './wasm/index.js';
|
package/src/lafs.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* LAFS (LLM-Agent-First Schema) unified envelope types.
|
|
3
3
|
*
|
|
4
4
|
* Defines canonical LAFS types inline (contracts has ZERO external dependencies).
|
|
5
|
-
* In the main CLEO codebase these are re-exported from @cleocode/lafs
|
|
5
|
+
* In the main CLEO codebase these are re-exported from @cleocode/lafs;
|
|
6
6
|
* here they are defined as plain interfaces for maximum portability.
|
|
7
7
|
*
|
|
8
8
|
* @epic T4654
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
|
-
// Canonical LAFS types (inlined from @cleocode/lafs
|
|
13
|
+
// Canonical LAFS types (inlined from @cleocode/lafs)
|
|
14
14
|
// ---------------------------------------------------------------------------
|
|
15
15
|
|
|
16
16
|
/** LAFS error category. */
|
package/src/task.ts
CHANGED
|
@@ -214,6 +214,9 @@ export interface Task {
|
|
|
214
214
|
* @task T060
|
|
215
215
|
*/
|
|
216
216
|
pipelineStage?: string | null;
|
|
217
|
+
|
|
218
|
+
/** Agent ID that has claimed/is assigned to this task. Null when unclaimed. */
|
|
219
|
+
assignee?: string | null;
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
// ---------------------------------------------------------------------------
|
package/src/transport.ts
CHANGED
|
@@ -1,12 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Transport
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Transport — Low-level wire protocol adapters for agent messaging.
|
|
3
|
+
*
|
|
4
|
+
* Transport is the HOW layer: it moves messages over the wire using
|
|
5
|
+
* HTTP polling, SSE, WebSocket, or in-process napi-rs calls.
|
|
6
|
+
*
|
|
7
|
+
* The Conduit interface (conduit.ts) wraps Transport to provide
|
|
8
|
+
* high-level messaging semantics (WHAT the agent wants to do).
|
|
9
|
+
*
|
|
10
|
+
* @see docs/specs/SIGNALDOCK-UNIFIED-AGENT-REGISTRY.md Section 4
|
|
11
|
+
* @module transport
|
|
5
12
|
*/
|
|
6
13
|
|
|
14
|
+
import type { TransportConfig } from './agent-registry.js';
|
|
15
|
+
import type { ConduitMessage } from './conduit.js';
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Transport connection config
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
/** Configuration passed to Transport.connect(). */
|
|
22
|
+
export interface TransportConnectConfig extends TransportConfig {
|
|
23
|
+
/** Agent ID to connect as. */
|
|
24
|
+
agentId: string;
|
|
25
|
+
/** API key for authentication. */
|
|
26
|
+
apiKey: string;
|
|
27
|
+
/** Base URL of the messaging API. */
|
|
28
|
+
apiBaseUrl: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Transport interface
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
/** Low-level wire transport for agent messaging. */
|
|
36
|
+
export interface Transport {
|
|
37
|
+
/** Transport name for logging/debugging (e.g. 'http', 'sse', 'ws', 'local'). */
|
|
38
|
+
readonly name: string;
|
|
39
|
+
|
|
40
|
+
/** Connect to the messaging backend. */
|
|
41
|
+
connect(config: TransportConnectConfig): Promise<void>;
|
|
42
|
+
|
|
43
|
+
/** Disconnect from the messaging backend. */
|
|
44
|
+
disconnect(): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/** Send a message payload. */
|
|
47
|
+
push(
|
|
48
|
+
to: string,
|
|
49
|
+
content: string,
|
|
50
|
+
options?: {
|
|
51
|
+
conversationId?: string;
|
|
52
|
+
replyTo?: string;
|
|
53
|
+
},
|
|
54
|
+
): Promise<{ messageId: string }>;
|
|
55
|
+
|
|
56
|
+
/** Poll for new messages (non-destructive peek). */
|
|
57
|
+
poll(options?: { limit?: number; since?: string }): Promise<ConduitMessage[]>;
|
|
58
|
+
|
|
59
|
+
/** Acknowledge processed messages (marks as delivered). */
|
|
60
|
+
ack(messageIds: string[]): Promise<void>;
|
|
61
|
+
|
|
62
|
+
/** Subscribe to real-time events (SSE/WebSocket). Returns unsubscribe. */
|
|
63
|
+
subscribe?(handler: (message: ConduitMessage) => void): () => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Legacy adapter (kept for backward compatibility during migration)
|
|
68
|
+
// ============================================================================
|
|
69
|
+
|
|
70
|
+
/** @deprecated Use Transport instead. Will be removed after unification. */
|
|
7
71
|
export interface AdapterTransportProvider {
|
|
8
|
-
/** Create a transport instance for inter-agent communication */
|
|
72
|
+
/** Create a transport instance for inter-agent communication. */
|
|
9
73
|
createTransport(): unknown;
|
|
10
|
-
/** Name of this transport type for logging/debugging */
|
|
74
|
+
/** Name of this transport type for logging/debugging. */
|
|
11
75
|
readonly transportName: string;
|
|
12
76
|
}
|