@holon-run/uxc-daemon-client 0.14.0 → 0.15.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.cjs +6 -67
- package/dist/index.d.cts +19 -82
- package/dist/index.d.ts +19 -82
- package/dist/index.js +6 -67
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,9 @@ var UxcDaemonClient = class {
|
|
|
73
73
|
async daemonSessions() {
|
|
74
74
|
return this.request("daemon.sessions");
|
|
75
75
|
}
|
|
76
|
+
async daemonSessionKill(sessionKey) {
|
|
77
|
+
return this.request("daemon.session.kill", { session_key: sessionKey });
|
|
78
|
+
}
|
|
76
79
|
async call(args) {
|
|
77
80
|
return this.request("runtime.invoke", {
|
|
78
81
|
request_id: requestId("call"),
|
|
@@ -107,48 +110,6 @@ var UxcDaemonClient = class {
|
|
|
107
110
|
});
|
|
108
111
|
return generateTypeScriptClient(schema, args.emitter);
|
|
109
112
|
}
|
|
110
|
-
async subscribeStart(args) {
|
|
111
|
-
const mode = args.mode ?? (args.pollConfig ? "poll" : "stream");
|
|
112
|
-
if (mode === "poll" && !args.pollConfig) {
|
|
113
|
-
throw new Error("pollConfig is required when mode is 'poll'");
|
|
114
|
-
}
|
|
115
|
-
if (mode !== "poll" && args.pollConfig) {
|
|
116
|
-
throw new Error("pollConfig is only valid when mode is 'poll'");
|
|
117
|
-
}
|
|
118
|
-
return this.request("subscription.start", {
|
|
119
|
-
request_id: requestId("subscribe"),
|
|
120
|
-
endpoint: args.endpoint,
|
|
121
|
-
sink: args.sink ?? "memory:",
|
|
122
|
-
operation_id: args.operationId ?? null,
|
|
123
|
-
args: args.args ?? null,
|
|
124
|
-
resource_uri: args.resourceUri ?? null,
|
|
125
|
-
read_resource: args.readResource ?? false,
|
|
126
|
-
transport_hint: args.transportHint ?? null,
|
|
127
|
-
subprotocols: [],
|
|
128
|
-
initial_text_frames: [],
|
|
129
|
-
mode,
|
|
130
|
-
poll_config: args.pollConfig ?? null,
|
|
131
|
-
ephemeral: args.ephemeral ?? (args.sink ?? "memory:") === "memory:",
|
|
132
|
-
options: normalizeOptions(args.options)
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
async subscribeList() {
|
|
136
|
-
return this.request("subscription.list");
|
|
137
|
-
}
|
|
138
|
-
async subscribeStatus(jobId) {
|
|
139
|
-
return this.request("subscription.status", { job_id: jobId });
|
|
140
|
-
}
|
|
141
|
-
async subscribeStop(jobId) {
|
|
142
|
-
return this.request("subscription.stop", { job_id: jobId });
|
|
143
|
-
}
|
|
144
|
-
async subscriptionEvents(args) {
|
|
145
|
-
return this.request("subscription.events", {
|
|
146
|
-
job_id: args.jobId,
|
|
147
|
-
after_seq: args.afterSeq ?? 0,
|
|
148
|
-
limit: args.limit ?? 100,
|
|
149
|
-
wait_ms: args.waitMs ?? 15e3
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
113
|
async sourceEnsure(args) {
|
|
153
114
|
return this.request("source.ensure", {
|
|
154
115
|
namespace: args.namespace,
|
|
@@ -171,6 +132,9 @@ var UxcDaemonClient = class {
|
|
|
171
132
|
source_key: sourceKey
|
|
172
133
|
});
|
|
173
134
|
}
|
|
135
|
+
async sourceList() {
|
|
136
|
+
return this.request("source.list");
|
|
137
|
+
}
|
|
174
138
|
async sourceStop(namespace, sourceKey) {
|
|
175
139
|
return this.request("source.stop", {
|
|
176
140
|
namespace,
|
|
@@ -199,31 +163,6 @@ var UxcDaemonClient = class {
|
|
|
199
163
|
before_offset: beforeOffset
|
|
200
164
|
});
|
|
201
165
|
}
|
|
202
|
-
async *subscribeEvents(jobId, options = {}) {
|
|
203
|
-
let afterSeq = options.afterSeq ?? 0;
|
|
204
|
-
while (true) {
|
|
205
|
-
if (options.signal?.aborted) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const batch = await this.subscriptionEvents({
|
|
209
|
-
jobId,
|
|
210
|
-
afterSeq,
|
|
211
|
-
limit: options.limit,
|
|
212
|
-
waitMs: options.waitMs
|
|
213
|
-
});
|
|
214
|
-
for (const event of batch.events) {
|
|
215
|
-
afterSeq = event.seq;
|
|
216
|
-
yield event;
|
|
217
|
-
}
|
|
218
|
-
if (batch.status !== "running" && batch.events.length === 0) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (batch.events.length === 0 && batch.status === "running") {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
afterSeq = batch.next_after_seq;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
166
|
async request(method, params) {
|
|
228
167
|
await this.ensureDaemon();
|
|
229
168
|
try {
|
package/dist/index.d.cts
CHANGED
|
@@ -74,30 +74,6 @@ type RuntimeResult<TData = unknown, TMeta = Record<string, unknown>> = Omit<Runt
|
|
|
74
74
|
data: TData;
|
|
75
75
|
meta: TMeta;
|
|
76
76
|
};
|
|
77
|
-
interface SubscriptionEventEnvelope {
|
|
78
|
-
version: string;
|
|
79
|
-
job_id: string;
|
|
80
|
-
seq: number;
|
|
81
|
-
timestamp_unix: number;
|
|
82
|
-
protocol: string;
|
|
83
|
-
source_kind: string;
|
|
84
|
-
event_kind: string;
|
|
85
|
-
data?: unknown;
|
|
86
|
-
meta?: unknown;
|
|
87
|
-
}
|
|
88
|
-
interface SubscribeStartResponse {
|
|
89
|
-
job_id: string;
|
|
90
|
-
mode: "stream" | "poll";
|
|
91
|
-
protocol: string;
|
|
92
|
-
endpoint: string;
|
|
93
|
-
sink: string;
|
|
94
|
-
resource_uri?: string | null;
|
|
95
|
-
status: string;
|
|
96
|
-
}
|
|
97
|
-
interface SubscribeStopResponse {
|
|
98
|
-
job_id: string;
|
|
99
|
-
stopped: boolean;
|
|
100
|
-
}
|
|
101
77
|
interface ManagedSourceSpec {
|
|
102
78
|
endpoint: string;
|
|
103
79
|
operation_id?: string | null;
|
|
@@ -133,6 +109,15 @@ interface ManagedSourceView {
|
|
|
133
109
|
stopped_at_unix?: number | null;
|
|
134
110
|
last_error?: string | null;
|
|
135
111
|
}
|
|
112
|
+
interface ManagedSourceListEntry {
|
|
113
|
+
namespace: string;
|
|
114
|
+
source_key: string;
|
|
115
|
+
status: string;
|
|
116
|
+
run_id: string;
|
|
117
|
+
stream_id: string;
|
|
118
|
+
updated_at_unix: number;
|
|
119
|
+
last_error?: string | null;
|
|
120
|
+
}
|
|
136
121
|
interface ManagedSourceStopResponse {
|
|
137
122
|
namespace: string;
|
|
138
123
|
source_key: string;
|
|
@@ -170,28 +155,6 @@ interface ManagedStreamTrimResponse {
|
|
|
170
155
|
stream_id: string;
|
|
171
156
|
trimmed: number;
|
|
172
157
|
}
|
|
173
|
-
interface SubscriptionJobView {
|
|
174
|
-
job_id: string;
|
|
175
|
-
mode: "stream" | "poll";
|
|
176
|
-
endpoint: string;
|
|
177
|
-
protocol: string;
|
|
178
|
-
sink: string;
|
|
179
|
-
resource_uri?: string | null;
|
|
180
|
-
status: string;
|
|
181
|
-
durable: boolean;
|
|
182
|
-
auto_resume: boolean;
|
|
183
|
-
resume_strategy: string;
|
|
184
|
-
created_at_unix: number;
|
|
185
|
-
started_at_unix?: number | null;
|
|
186
|
-
stopped_at_unix?: number | null;
|
|
187
|
-
last_event_at_unix?: number | null;
|
|
188
|
-
last_error?: string | null;
|
|
189
|
-
restart_count: number;
|
|
190
|
-
last_resume_at_unix?: number | null;
|
|
191
|
-
last_resume_error?: string | null;
|
|
192
|
-
reconnect_count: number;
|
|
193
|
-
written_events: number;
|
|
194
|
-
}
|
|
195
158
|
interface DaemonStatus {
|
|
196
159
|
running: boolean;
|
|
197
160
|
pid?: number | null;
|
|
@@ -202,14 +165,15 @@ interface DaemonStatus {
|
|
|
202
165
|
mcp_stdio_sessions: number;
|
|
203
166
|
mcp_http_sessions: number;
|
|
204
167
|
mcp_reuse_hits: number;
|
|
168
|
+
managed_sources: number;
|
|
169
|
+
managed_sources_running: number;
|
|
170
|
+
managed_streams: number;
|
|
205
171
|
log_file?: string | null;
|
|
206
172
|
}
|
|
207
|
-
interface
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
next_after_seq: number;
|
|
212
|
-
has_more: boolean;
|
|
173
|
+
interface DaemonSessionKillResponse {
|
|
174
|
+
session_key: string;
|
|
175
|
+
child_pid: number | null;
|
|
176
|
+
killed: boolean;
|
|
213
177
|
}
|
|
214
178
|
interface UxcDaemonClientOptions {
|
|
215
179
|
socketPath?: string;
|
|
@@ -224,19 +188,6 @@ interface GenerateTypeScriptClientOptions {
|
|
|
224
188
|
packageImport?: string;
|
|
225
189
|
includeSchemaJson?: boolean;
|
|
226
190
|
}
|
|
227
|
-
interface SubscribeStartArgs {
|
|
228
|
-
endpoint: string;
|
|
229
|
-
resourceUri?: string;
|
|
230
|
-
operationId?: string;
|
|
231
|
-
args?: Record<string, unknown>;
|
|
232
|
-
mode?: "stream" | "poll";
|
|
233
|
-
pollConfig?: PollSubscriptionConfig;
|
|
234
|
-
options?: RuntimeInvokeOptions;
|
|
235
|
-
sink?: `file:${string}` | "memory:";
|
|
236
|
-
ephemeral?: boolean;
|
|
237
|
-
readResource?: boolean;
|
|
238
|
-
transportHint?: "websocket" | "discord_gateway" | "slack_socket_mode" | "feishu_long_connection";
|
|
239
|
-
}
|
|
240
191
|
interface PollSubscriptionConfig {
|
|
241
192
|
interval_secs: number;
|
|
242
193
|
extract_items_pointer: string;
|
|
@@ -277,6 +228,7 @@ declare class UxcDaemonClient {
|
|
|
277
228
|
constructor(options?: UxcDaemonClientOptions);
|
|
278
229
|
daemonStatus(): Promise<DaemonStatus>;
|
|
279
230
|
daemonSessions(): Promise<unknown[]>;
|
|
231
|
+
daemonSessionKill(sessionKey: string): Promise<DaemonSessionKillResponse>;
|
|
280
232
|
call(args: {
|
|
281
233
|
endpoint: string;
|
|
282
234
|
operation: string;
|
|
@@ -292,22 +244,13 @@ declare class UxcDaemonClient {
|
|
|
292
244
|
options?: RuntimeInvokeOptions;
|
|
293
245
|
emitter?: GenerateTypeScriptClientOptions;
|
|
294
246
|
}): Promise<string>;
|
|
295
|
-
subscribeStart(args: SubscribeStartArgs): Promise<SubscribeStartResponse>;
|
|
296
|
-
subscribeList(): Promise<SubscriptionJobView[]>;
|
|
297
|
-
subscribeStatus(jobId: string): Promise<SubscriptionJobView>;
|
|
298
|
-
subscribeStop(jobId: string): Promise<SubscribeStopResponse>;
|
|
299
|
-
subscriptionEvents(args: {
|
|
300
|
-
jobId: string;
|
|
301
|
-
afterSeq?: number;
|
|
302
|
-
limit?: number;
|
|
303
|
-
waitMs?: number;
|
|
304
|
-
}): Promise<SubscriptionEventsResponse>;
|
|
305
247
|
sourceEnsure(args: {
|
|
306
248
|
namespace: string;
|
|
307
249
|
sourceKey: string;
|
|
308
250
|
spec: ManagedSourceSpec;
|
|
309
251
|
}): Promise<ManagedSourceEnsureResponse>;
|
|
310
252
|
sourceStatus(namespace: string, sourceKey: string): Promise<ManagedSourceView>;
|
|
253
|
+
sourceList(): Promise<ManagedSourceListEntry[]>;
|
|
311
254
|
sourceStop(namespace: string, sourceKey: string): Promise<ManagedSourceStopResponse>;
|
|
312
255
|
sourceDelete(namespace: string, sourceKey: string): Promise<ManagedSourceDeleteResponse>;
|
|
313
256
|
streamRead(args: {
|
|
@@ -317,16 +260,10 @@ declare class UxcDaemonClient {
|
|
|
317
260
|
}): Promise<ManagedStreamReadResponse>;
|
|
318
261
|
streamInfo(streamId: string): Promise<ManagedStreamInfo>;
|
|
319
262
|
streamTrim(streamId: string, beforeOffset: number): Promise<ManagedStreamTrimResponse>;
|
|
320
|
-
subscribeEvents(jobId: string, options?: {
|
|
321
|
-
afterSeq?: number;
|
|
322
|
-
limit?: number;
|
|
323
|
-
waitMs?: number;
|
|
324
|
-
signal?: AbortSignal;
|
|
325
|
-
}): AsyncIterable<SubscriptionEventEnvelope>;
|
|
326
263
|
request<T>(method: string, params?: unknown): Promise<T>;
|
|
327
264
|
private ensureDaemon;
|
|
328
265
|
private requestOnce;
|
|
329
266
|
}
|
|
330
267
|
declare function generateTypeScriptClient(schema: CodegenHostSchemaV1, options?: GenerateTypeScriptClientOptions): string;
|
|
331
268
|
|
|
332
|
-
export { type CodegenHostSchemaV1, type CodegenOperationV1, DaemonRpcError, type DaemonStatus, type GenerateTypeScriptClientOptions, type ManagedSourceDeleteResponse, type ManagedSourceEnsureResponse, type ManagedSourceSpec, type ManagedSourceStopResponse, type ManagedSourceView, type ManagedStreamEvent, type ManagedStreamInfo, type ManagedStreamReadResponse, type ManagedStreamTrimResponse, type PollSubscriptionConfig, type RuntimeInvokeOptions, type RuntimeInvokeResponse, type RuntimeMeta, type RuntimeResult,
|
|
269
|
+
export { type CodegenHostSchemaV1, type CodegenOperationV1, DaemonRpcError, type DaemonSessionKillResponse, type DaemonStatus, type GenerateTypeScriptClientOptions, type ManagedSourceDeleteResponse, type ManagedSourceEnsureResponse, type ManagedSourceListEntry, type ManagedSourceSpec, type ManagedSourceStopResponse, type ManagedSourceView, type ManagedStreamEvent, type ManagedStreamInfo, type ManagedStreamReadResponse, type ManagedStreamTrimResponse, type PollSubscriptionConfig, type RuntimeInvokeOptions, type RuntimeInvokeResponse, type RuntimeMeta, type RuntimeResult, UxcDaemonClient, type UxcDaemonClientOptions, generateTypeScriptClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -74,30 +74,6 @@ type RuntimeResult<TData = unknown, TMeta = Record<string, unknown>> = Omit<Runt
|
|
|
74
74
|
data: TData;
|
|
75
75
|
meta: TMeta;
|
|
76
76
|
};
|
|
77
|
-
interface SubscriptionEventEnvelope {
|
|
78
|
-
version: string;
|
|
79
|
-
job_id: string;
|
|
80
|
-
seq: number;
|
|
81
|
-
timestamp_unix: number;
|
|
82
|
-
protocol: string;
|
|
83
|
-
source_kind: string;
|
|
84
|
-
event_kind: string;
|
|
85
|
-
data?: unknown;
|
|
86
|
-
meta?: unknown;
|
|
87
|
-
}
|
|
88
|
-
interface SubscribeStartResponse {
|
|
89
|
-
job_id: string;
|
|
90
|
-
mode: "stream" | "poll";
|
|
91
|
-
protocol: string;
|
|
92
|
-
endpoint: string;
|
|
93
|
-
sink: string;
|
|
94
|
-
resource_uri?: string | null;
|
|
95
|
-
status: string;
|
|
96
|
-
}
|
|
97
|
-
interface SubscribeStopResponse {
|
|
98
|
-
job_id: string;
|
|
99
|
-
stopped: boolean;
|
|
100
|
-
}
|
|
101
77
|
interface ManagedSourceSpec {
|
|
102
78
|
endpoint: string;
|
|
103
79
|
operation_id?: string | null;
|
|
@@ -133,6 +109,15 @@ interface ManagedSourceView {
|
|
|
133
109
|
stopped_at_unix?: number | null;
|
|
134
110
|
last_error?: string | null;
|
|
135
111
|
}
|
|
112
|
+
interface ManagedSourceListEntry {
|
|
113
|
+
namespace: string;
|
|
114
|
+
source_key: string;
|
|
115
|
+
status: string;
|
|
116
|
+
run_id: string;
|
|
117
|
+
stream_id: string;
|
|
118
|
+
updated_at_unix: number;
|
|
119
|
+
last_error?: string | null;
|
|
120
|
+
}
|
|
136
121
|
interface ManagedSourceStopResponse {
|
|
137
122
|
namespace: string;
|
|
138
123
|
source_key: string;
|
|
@@ -170,28 +155,6 @@ interface ManagedStreamTrimResponse {
|
|
|
170
155
|
stream_id: string;
|
|
171
156
|
trimmed: number;
|
|
172
157
|
}
|
|
173
|
-
interface SubscriptionJobView {
|
|
174
|
-
job_id: string;
|
|
175
|
-
mode: "stream" | "poll";
|
|
176
|
-
endpoint: string;
|
|
177
|
-
protocol: string;
|
|
178
|
-
sink: string;
|
|
179
|
-
resource_uri?: string | null;
|
|
180
|
-
status: string;
|
|
181
|
-
durable: boolean;
|
|
182
|
-
auto_resume: boolean;
|
|
183
|
-
resume_strategy: string;
|
|
184
|
-
created_at_unix: number;
|
|
185
|
-
started_at_unix?: number | null;
|
|
186
|
-
stopped_at_unix?: number | null;
|
|
187
|
-
last_event_at_unix?: number | null;
|
|
188
|
-
last_error?: string | null;
|
|
189
|
-
restart_count: number;
|
|
190
|
-
last_resume_at_unix?: number | null;
|
|
191
|
-
last_resume_error?: string | null;
|
|
192
|
-
reconnect_count: number;
|
|
193
|
-
written_events: number;
|
|
194
|
-
}
|
|
195
158
|
interface DaemonStatus {
|
|
196
159
|
running: boolean;
|
|
197
160
|
pid?: number | null;
|
|
@@ -202,14 +165,15 @@ interface DaemonStatus {
|
|
|
202
165
|
mcp_stdio_sessions: number;
|
|
203
166
|
mcp_http_sessions: number;
|
|
204
167
|
mcp_reuse_hits: number;
|
|
168
|
+
managed_sources: number;
|
|
169
|
+
managed_sources_running: number;
|
|
170
|
+
managed_streams: number;
|
|
205
171
|
log_file?: string | null;
|
|
206
172
|
}
|
|
207
|
-
interface
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
next_after_seq: number;
|
|
212
|
-
has_more: boolean;
|
|
173
|
+
interface DaemonSessionKillResponse {
|
|
174
|
+
session_key: string;
|
|
175
|
+
child_pid: number | null;
|
|
176
|
+
killed: boolean;
|
|
213
177
|
}
|
|
214
178
|
interface UxcDaemonClientOptions {
|
|
215
179
|
socketPath?: string;
|
|
@@ -224,19 +188,6 @@ interface GenerateTypeScriptClientOptions {
|
|
|
224
188
|
packageImport?: string;
|
|
225
189
|
includeSchemaJson?: boolean;
|
|
226
190
|
}
|
|
227
|
-
interface SubscribeStartArgs {
|
|
228
|
-
endpoint: string;
|
|
229
|
-
resourceUri?: string;
|
|
230
|
-
operationId?: string;
|
|
231
|
-
args?: Record<string, unknown>;
|
|
232
|
-
mode?: "stream" | "poll";
|
|
233
|
-
pollConfig?: PollSubscriptionConfig;
|
|
234
|
-
options?: RuntimeInvokeOptions;
|
|
235
|
-
sink?: `file:${string}` | "memory:";
|
|
236
|
-
ephemeral?: boolean;
|
|
237
|
-
readResource?: boolean;
|
|
238
|
-
transportHint?: "websocket" | "discord_gateway" | "slack_socket_mode" | "feishu_long_connection";
|
|
239
|
-
}
|
|
240
191
|
interface PollSubscriptionConfig {
|
|
241
192
|
interval_secs: number;
|
|
242
193
|
extract_items_pointer: string;
|
|
@@ -277,6 +228,7 @@ declare class UxcDaemonClient {
|
|
|
277
228
|
constructor(options?: UxcDaemonClientOptions);
|
|
278
229
|
daemonStatus(): Promise<DaemonStatus>;
|
|
279
230
|
daemonSessions(): Promise<unknown[]>;
|
|
231
|
+
daemonSessionKill(sessionKey: string): Promise<DaemonSessionKillResponse>;
|
|
280
232
|
call(args: {
|
|
281
233
|
endpoint: string;
|
|
282
234
|
operation: string;
|
|
@@ -292,22 +244,13 @@ declare class UxcDaemonClient {
|
|
|
292
244
|
options?: RuntimeInvokeOptions;
|
|
293
245
|
emitter?: GenerateTypeScriptClientOptions;
|
|
294
246
|
}): Promise<string>;
|
|
295
|
-
subscribeStart(args: SubscribeStartArgs): Promise<SubscribeStartResponse>;
|
|
296
|
-
subscribeList(): Promise<SubscriptionJobView[]>;
|
|
297
|
-
subscribeStatus(jobId: string): Promise<SubscriptionJobView>;
|
|
298
|
-
subscribeStop(jobId: string): Promise<SubscribeStopResponse>;
|
|
299
|
-
subscriptionEvents(args: {
|
|
300
|
-
jobId: string;
|
|
301
|
-
afterSeq?: number;
|
|
302
|
-
limit?: number;
|
|
303
|
-
waitMs?: number;
|
|
304
|
-
}): Promise<SubscriptionEventsResponse>;
|
|
305
247
|
sourceEnsure(args: {
|
|
306
248
|
namespace: string;
|
|
307
249
|
sourceKey: string;
|
|
308
250
|
spec: ManagedSourceSpec;
|
|
309
251
|
}): Promise<ManagedSourceEnsureResponse>;
|
|
310
252
|
sourceStatus(namespace: string, sourceKey: string): Promise<ManagedSourceView>;
|
|
253
|
+
sourceList(): Promise<ManagedSourceListEntry[]>;
|
|
311
254
|
sourceStop(namespace: string, sourceKey: string): Promise<ManagedSourceStopResponse>;
|
|
312
255
|
sourceDelete(namespace: string, sourceKey: string): Promise<ManagedSourceDeleteResponse>;
|
|
313
256
|
streamRead(args: {
|
|
@@ -317,16 +260,10 @@ declare class UxcDaemonClient {
|
|
|
317
260
|
}): Promise<ManagedStreamReadResponse>;
|
|
318
261
|
streamInfo(streamId: string): Promise<ManagedStreamInfo>;
|
|
319
262
|
streamTrim(streamId: string, beforeOffset: number): Promise<ManagedStreamTrimResponse>;
|
|
320
|
-
subscribeEvents(jobId: string, options?: {
|
|
321
|
-
afterSeq?: number;
|
|
322
|
-
limit?: number;
|
|
323
|
-
waitMs?: number;
|
|
324
|
-
signal?: AbortSignal;
|
|
325
|
-
}): AsyncIterable<SubscriptionEventEnvelope>;
|
|
326
263
|
request<T>(method: string, params?: unknown): Promise<T>;
|
|
327
264
|
private ensureDaemon;
|
|
328
265
|
private requestOnce;
|
|
329
266
|
}
|
|
330
267
|
declare function generateTypeScriptClient(schema: CodegenHostSchemaV1, options?: GenerateTypeScriptClientOptions): string;
|
|
331
268
|
|
|
332
|
-
export { type CodegenHostSchemaV1, type CodegenOperationV1, DaemonRpcError, type DaemonStatus, type GenerateTypeScriptClientOptions, type ManagedSourceDeleteResponse, type ManagedSourceEnsureResponse, type ManagedSourceSpec, type ManagedSourceStopResponse, type ManagedSourceView, type ManagedStreamEvent, type ManagedStreamInfo, type ManagedStreamReadResponse, type ManagedStreamTrimResponse, type PollSubscriptionConfig, type RuntimeInvokeOptions, type RuntimeInvokeResponse, type RuntimeMeta, type RuntimeResult,
|
|
269
|
+
export { type CodegenHostSchemaV1, type CodegenOperationV1, DaemonRpcError, type DaemonSessionKillResponse, type DaemonStatus, type GenerateTypeScriptClientOptions, type ManagedSourceDeleteResponse, type ManagedSourceEnsureResponse, type ManagedSourceListEntry, type ManagedSourceSpec, type ManagedSourceStopResponse, type ManagedSourceView, type ManagedStreamEvent, type ManagedStreamInfo, type ManagedStreamReadResponse, type ManagedStreamTrimResponse, type PollSubscriptionConfig, type RuntimeInvokeOptions, type RuntimeInvokeResponse, type RuntimeMeta, type RuntimeResult, UxcDaemonClient, type UxcDaemonClientOptions, generateTypeScriptClient };
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,9 @@ var UxcDaemonClient = class {
|
|
|
37
37
|
async daemonSessions() {
|
|
38
38
|
return this.request("daemon.sessions");
|
|
39
39
|
}
|
|
40
|
+
async daemonSessionKill(sessionKey) {
|
|
41
|
+
return this.request("daemon.session.kill", { session_key: sessionKey });
|
|
42
|
+
}
|
|
40
43
|
async call(args) {
|
|
41
44
|
return this.request("runtime.invoke", {
|
|
42
45
|
request_id: requestId("call"),
|
|
@@ -71,48 +74,6 @@ var UxcDaemonClient = class {
|
|
|
71
74
|
});
|
|
72
75
|
return generateTypeScriptClient(schema, args.emitter);
|
|
73
76
|
}
|
|
74
|
-
async subscribeStart(args) {
|
|
75
|
-
const mode = args.mode ?? (args.pollConfig ? "poll" : "stream");
|
|
76
|
-
if (mode === "poll" && !args.pollConfig) {
|
|
77
|
-
throw new Error("pollConfig is required when mode is 'poll'");
|
|
78
|
-
}
|
|
79
|
-
if (mode !== "poll" && args.pollConfig) {
|
|
80
|
-
throw new Error("pollConfig is only valid when mode is 'poll'");
|
|
81
|
-
}
|
|
82
|
-
return this.request("subscription.start", {
|
|
83
|
-
request_id: requestId("subscribe"),
|
|
84
|
-
endpoint: args.endpoint,
|
|
85
|
-
sink: args.sink ?? "memory:",
|
|
86
|
-
operation_id: args.operationId ?? null,
|
|
87
|
-
args: args.args ?? null,
|
|
88
|
-
resource_uri: args.resourceUri ?? null,
|
|
89
|
-
read_resource: args.readResource ?? false,
|
|
90
|
-
transport_hint: args.transportHint ?? null,
|
|
91
|
-
subprotocols: [],
|
|
92
|
-
initial_text_frames: [],
|
|
93
|
-
mode,
|
|
94
|
-
poll_config: args.pollConfig ?? null,
|
|
95
|
-
ephemeral: args.ephemeral ?? (args.sink ?? "memory:") === "memory:",
|
|
96
|
-
options: normalizeOptions(args.options)
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async subscribeList() {
|
|
100
|
-
return this.request("subscription.list");
|
|
101
|
-
}
|
|
102
|
-
async subscribeStatus(jobId) {
|
|
103
|
-
return this.request("subscription.status", { job_id: jobId });
|
|
104
|
-
}
|
|
105
|
-
async subscribeStop(jobId) {
|
|
106
|
-
return this.request("subscription.stop", { job_id: jobId });
|
|
107
|
-
}
|
|
108
|
-
async subscriptionEvents(args) {
|
|
109
|
-
return this.request("subscription.events", {
|
|
110
|
-
job_id: args.jobId,
|
|
111
|
-
after_seq: args.afterSeq ?? 0,
|
|
112
|
-
limit: args.limit ?? 100,
|
|
113
|
-
wait_ms: args.waitMs ?? 15e3
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
77
|
async sourceEnsure(args) {
|
|
117
78
|
return this.request("source.ensure", {
|
|
118
79
|
namespace: args.namespace,
|
|
@@ -135,6 +96,9 @@ var UxcDaemonClient = class {
|
|
|
135
96
|
source_key: sourceKey
|
|
136
97
|
});
|
|
137
98
|
}
|
|
99
|
+
async sourceList() {
|
|
100
|
+
return this.request("source.list");
|
|
101
|
+
}
|
|
138
102
|
async sourceStop(namespace, sourceKey) {
|
|
139
103
|
return this.request("source.stop", {
|
|
140
104
|
namespace,
|
|
@@ -163,31 +127,6 @@ var UxcDaemonClient = class {
|
|
|
163
127
|
before_offset: beforeOffset
|
|
164
128
|
});
|
|
165
129
|
}
|
|
166
|
-
async *subscribeEvents(jobId, options = {}) {
|
|
167
|
-
let afterSeq = options.afterSeq ?? 0;
|
|
168
|
-
while (true) {
|
|
169
|
-
if (options.signal?.aborted) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const batch = await this.subscriptionEvents({
|
|
173
|
-
jobId,
|
|
174
|
-
afterSeq,
|
|
175
|
-
limit: options.limit,
|
|
176
|
-
waitMs: options.waitMs
|
|
177
|
-
});
|
|
178
|
-
for (const event of batch.events) {
|
|
179
|
-
afterSeq = event.seq;
|
|
180
|
-
yield event;
|
|
181
|
-
}
|
|
182
|
-
if (batch.status !== "running" && batch.events.length === 0) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (batch.events.length === 0 && batch.status === "running") {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
afterSeq = batch.next_after_seq;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
130
|
async request(method, params) {
|
|
192
131
|
await this.ensureDaemon();
|
|
193
132
|
try {
|