@niq.run/worker-sdk 0.8.0 → 0.9.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/README.md CHANGED
@@ -101,7 +101,7 @@ Properties are required unless wrapped in `s.optional(...)`; arrays, enums and
101
101
  free-form values are `s.array(...)`, `s.enumOf([...])`, `s.any()`.
102
102
 
103
103
  Both schemas ride `worker.ready`, so peers and the directory worker see them
104
- (`get_worker_info` → `parameters` / `response`). `response` is what lets an agent
104
+ (`describe` → `parameters` / `response`). `response` is what lets an agent
105
105
  — in particular a PTC script, written before anything runs — plan how to parse a
106
106
  reply; declare it whenever the reply is structured.
107
107
 
@@ -285,4 +285,37 @@ npm run build # tsc → dist/
285
285
  Early, moving fast. Pre-1.0; the wire protocol is stabilizing alongside
286
286
  `core/bus` and the Go `httptrans` transport.
287
287
 
288
- `node >= 18` (uses global `fetch` and `ReadableStream`).
288
+ `node >= 18` (uses global `fetch` and `ReadableStream`).
289
+ ## Interface worker
290
+
291
+ `InterfaceWorker` is the TS mirror of Go's `core/impl/iface`: a worker whose job
292
+ is a seam between the bus and an external world (a chat-platform bridge, an admin
293
+ UI, a notifier). It faces the bus like any worker, and holds `Backend`s behind it.
294
+
295
+ ```ts
296
+ import { InterfaceWorker, type Backend, type Handler } from "@niq.run/worker-sdk";
297
+
298
+ class FeishuBridge implements Backend {
299
+ private h?: Handler;
300
+ setHandler(h: Handler) { this.h = h; } // injected once, before start
301
+ async onMessage(text: string, to: string) {
302
+ await this.h!.send(createEvent("worker.input", { content: [{ type: "text", text }] }), to);
303
+ }
304
+ }
305
+
306
+ const worker = new InterfaceWorker({
307
+ id: "feishu",
308
+ channel, // any WorkerSideChannel (HTTPWorkerClient)
309
+ type: "interface",
310
+ backends: [new FeishuBridge()],
311
+ });
312
+ await worker.start();
313
+ ```
314
+
315
+ - `Handler.request(target, evt, opts?)` — send and await the correlated reply;
316
+ a `request.failed`/`request.rejected` rejects with `ReplyError` (its `.reply`
317
+ carries the event). Timed out → rejects; `stop()` fails whatever is in flight.
318
+ - `Handler.onEvent(fn, filter?)` — inbound interest; each registration is isolated,
319
+ so a throwing backend cannot break the loop or another backend.
320
+ - What it does NOT do: edit ACLs or render the global event stream. Those are the
321
+ app's own bus handles, the same split as in Go.
@@ -0,0 +1,150 @@
1
+ import { BaseWorker } from "./baseworker.js";
2
+ import type { HelpFunc } from "./help.js";
3
+ import { type Event, type EventTypeName, type Extension, type ExtensionHandler, type WorkerSideChannel } from "./types/index.js";
4
+ /**
5
+ * InterfaceWorker — the TypeScript half of niq's interface worker.
6
+ *
7
+ * A worker whose job is not a domain of its own but a seam between the bus and
8
+ * an external world (a chat platform bridge, an admin UI, a notifier). It faces
9
+ * the bus like every worker (identity, ACL, presence, discover, tools) and holds
10
+ * one or more {@link Backend}s behind it: the things that implement its
11
+ * capability.
12
+ *
13
+ * Mirrors Go's `core/impl/iface`:
14
+ *
15
+ * Backend.setHandler(handler) the worker injects the handles, once, before
16
+ * any event is delivered
17
+ * Handler.send/broadcast outbound as this worker
18
+ * Handler.request send + await the correlated reply
19
+ * Handler.onEvent(filter, fn) interest in inbound events (fan-out, isolated)
20
+ *
21
+ * It is NOT a bus control plane: editing ACLs and rendering the global event
22
+ * stream belong to the app's own bus handles, not here.
23
+ */
24
+ /** A filter for inbound interest: event types, or omitted for everything. */
25
+ export type EventFilter = readonly string[];
26
+ /** What a backend may do on the bus, as this worker's identity. */
27
+ export interface Handler {
28
+ /** The worker id this handler speaks as. */
29
+ readonly id: string;
30
+ /** Send a directed event to the given targets. */
31
+ send(evt: Event, ...targets: string[]): Promise<void>;
32
+ /** Publish to every identity subscribing to the event type. */
33
+ broadcast(evt: Event): Promise<void>;
34
+ /**
35
+ * Send and wait for the correlated `request.completed`, with the reply's error
36
+ * message surfaced for `request.failed` / `request.rejected`.
37
+ *
38
+ * The correlation is not a new protocol — the reply is an ordinary event
39
+ * addressed to this worker — but only the side holding the channel can pair it,
40
+ * so this is the one place that owns ids, the wait and the timeout.
41
+ */
42
+ request(target: string, evt: Event, opts?: RequestOptions): Promise<Event>;
43
+ /**
44
+ * Register interest in inbound events. Returns an unsubscribe function.
45
+ * Delivery is per registration, in arrival order; a throwing subscriber cannot
46
+ * break the worker's loop or another subscriber.
47
+ */
48
+ onEvent(fn: (evt: Event) => void, filter?: EventFilter): () => void;
49
+ }
50
+ export interface RequestOptions {
51
+ /** Override the worker's default request timeout. */
52
+ timeoutMs?: number;
53
+ }
54
+ /** One outward-facing surface: the thing behind the worker. */
55
+ export interface Backend {
56
+ /**
57
+ * Receive the handles for reaching the bus, and register inbound interest.
58
+ *
59
+ * Called exactly ONCE, before the worker starts its loop and before any event
60
+ * is delivered, so the backend can build its outward side already knowing how
61
+ * to reach inward.
62
+ */
63
+ setHandler(handler: Handler): void;
64
+ }
65
+ /**
66
+ * A backend that needs a lifetime of its own: a WebSocket connection, a render
67
+ * loop, a subscription pump. `start()` runs after every backend has its handler;
68
+ * `stop()` runs in reverse order when the worker stops.
69
+ */
70
+ export interface Runnable {
71
+ start(): Promise<void>;
72
+ stop(): Promise<void>;
73
+ }
74
+ /**
75
+ * The part of the worker a backend needs to serve its own tools: register the
76
+ * extension (schema included, so it rides `worker.ready`), then reply. The
77
+ * worker itself satisfies it, so a backend is wired by
78
+ * `backend.registerTools(worker)` — mirroring Go's `iface.ToolHost`.
79
+ */
80
+ export interface ToolHost {
81
+ register(ext: Extension, handler: ExtensionHandler): void;
82
+ registerReadme(description: string, text: () => string, params?: Record<string, unknown>): void;
83
+ registerHelp(guides?: Record<string, HelpFunc>): void;
84
+ replyCompleted(callerID: string, callID: string, result: unknown, traceID?: string): Promise<void>;
85
+ replyFailed(callerID: string, callID: string, errorMessage: string, traceID?: string): Promise<void>;
86
+ }
87
+ export interface InterfaceWorkerOptions {
88
+ /** Worker identity on the bus. */
89
+ id: string;
90
+ /** Worker-side channel (already constructed; `start` connects it). */
91
+ channel: WorkerSideChannel;
92
+ /** The outward-facing surfaces this worker bridges to. */
93
+ backends?: Backend[];
94
+ /** Type label announced via `worker.ready` (e.g. "interface"). */
95
+ type?: string;
96
+ /** Presence contract: the events this worker declares it emits. */
97
+ publishes?: Record<string, unknown>[];
98
+ /** Default request timeout in ms (default 30s, mirroring Go). */
99
+ requestTimeoutMs?: number;
100
+ }
101
+ /** The default request timeout, matching Go's `iface.DefaultRequestTimeout`. */
102
+ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
103
+ /** A failed or rejected reply. Carries the reply event for inspection. */
104
+ export declare class ReplyError extends Error {
105
+ readonly reply: Event;
106
+ constructor(reply: Event);
107
+ }
108
+ export declare class InterfaceWorker extends BaseWorker {
109
+ private readonly backends;
110
+ private readonly typ;
111
+ private readonly publishes?;
112
+ private readonly requestTimeoutMs;
113
+ private readonly handler;
114
+ private readonly pending;
115
+ private readonly subs;
116
+ private loop?;
117
+ private stopping;
118
+ constructor(opts: InterfaceWorkerOptions);
119
+ /**
120
+ * Connect, inject the handler into every backend, then serve.
121
+ *
122
+ * Injection happens BEFORE the loop starts, so a backend can build its outward
123
+ * side already knowing how to reach inward.
124
+ */
125
+ start(): Promise<void>;
126
+ /** Leave the bus: stop backends, fail in-flight requests, close. */
127
+ stop(): Promise<void>;
128
+ /** Waits for the serving loop to end (it ends when the channel closes). */
129
+ done(): Promise<void>;
130
+ private serve;
131
+ /**
132
+ * One inbound event: a reply resolves its pending request, a served tool is
133
+ * answered by the extension registry, everything else is a message for the
134
+ * backends.
135
+ */
136
+ private dispatch;
137
+ /** Whether the extension registry handles this event type. */
138
+ private serves;
139
+ private resolve;
140
+ /** Fan out to interested subscriptions, reporting whether any took it. */
141
+ private publish;
142
+ /** Isolates a failing subscriber: one broken backend must not stop the rest. */
143
+ private deliver;
144
+ private newHandler;
145
+ private request;
146
+ private onEvent;
147
+ }
148
+ /** Convenience: build a reply event for a pending request. */
149
+ export declare function replyEvent(type: EventTypeName, requestId: string, payload: Record<string, unknown>, traceId?: string): Event;
150
+ //# sourceMappingURL=i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
@@ -0,0 +1,227 @@
1
+ import { BaseWorker } from "./baseworker.js";
2
+ import { createEvent } from "./createEvent.js";
3
+ import { newId } from "./id.js";
4
+ import { EventType, } from "./types/index.js";
5
+ /** The default request timeout, matching Go's `iface.DefaultRequestTimeout`. */
6
+ export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
7
+ /** A failed or rejected reply. Carries the reply event for inspection. */
8
+ export class ReplyError extends Error {
9
+ reply;
10
+ constructor(reply) {
11
+ super(replyErrorMessage(reply));
12
+ this.name = "ReplyError";
13
+ this.reply = reply;
14
+ }
15
+ }
16
+ function replyErrorMessage(reply) {
17
+ const payload = reply.payload ?? {};
18
+ for (const key of ["error", "reason"]) {
19
+ const v = payload[key];
20
+ if (typeof v === "string" && v && v !== "<nil>")
21
+ return v;
22
+ }
23
+ return `reply ${reply.type} without a message`;
24
+ }
25
+ export class InterfaceWorker extends BaseWorker {
26
+ backends;
27
+ typ;
28
+ publishes;
29
+ requestTimeoutMs;
30
+ handler;
31
+ pending = new Map();
32
+ subs = new Set();
33
+ loop;
34
+ stopping = false;
35
+ constructor(opts) {
36
+ super({ id: opts.id, channel: opts.channel });
37
+ this.backends = opts.backends ?? [];
38
+ this.typ = opts.type ?? "interface";
39
+ this.publishes = opts.publishes;
40
+ this.requestTimeoutMs = opts.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
41
+ this.handler = this.newHandler();
42
+ }
43
+ /**
44
+ * Connect, inject the handler into every backend, then serve.
45
+ *
46
+ * Injection happens BEFORE the loop starts, so a backend can build its outward
47
+ * side already knowing how to reach inward.
48
+ */
49
+ async start() {
50
+ await this.channel.connect();
51
+ for (const backend of this.backends) {
52
+ backend.setHandler(this.handler);
53
+ }
54
+ // Then give each backend its own lifetime: a backend whose start fails would
55
+ // leave the worker deaf, so it is a start error.
56
+ for (const backend of this.backends) {
57
+ const runnable = backend;
58
+ if (typeof runnable.start === "function") {
59
+ await runnable.start();
60
+ }
61
+ }
62
+ await this.announceReady(this.typ, this.publishes);
63
+ this.loop = this.serve();
64
+ }
65
+ /** Leave the bus: stop backends, fail in-flight requests, close. */
66
+ async stop() {
67
+ this.stopping = true;
68
+ // Backends stop first, in reverse, so a backend's last delivery can still
69
+ // reach the bus.
70
+ for (let i = this.backends.length - 1; i >= 0; i -= 1) {
71
+ const runnable = this.backends[i];
72
+ if (typeof runnable.stop === "function") {
73
+ try {
74
+ await runnable.stop();
75
+ }
76
+ catch (err) {
77
+ console.warn(`[iface ${this.id}] backend stop failed:`, err);
78
+ }
79
+ }
80
+ }
81
+ for (const [id, p] of this.pending) {
82
+ clearTimeout(p.timer);
83
+ p.reject(new Error(`interface worker stopped while waiting for request ${id}`));
84
+ }
85
+ this.pending.clear();
86
+ for (const sub of this.subs)
87
+ sub.active = false;
88
+ this.subs.clear();
89
+ await this.channel.close();
90
+ }
91
+ /** Waits for the serving loop to end (it ends when the channel closes). */
92
+ async done() {
93
+ await this.loop;
94
+ }
95
+ async serve() {
96
+ for await (const evt of this.channel.events()) {
97
+ if (this.stopping)
98
+ return;
99
+ this.dispatch(evt);
100
+ }
101
+ }
102
+ /**
103
+ * One inbound event: a reply resolves its pending request, a served tool is
104
+ * answered by the extension registry, everything else is a message for the
105
+ * backends.
106
+ */
107
+ dispatch(evt) {
108
+ if (this.resolve(evt)) {
109
+ // A reply is also an inbound event: a backend watching the conversation may
110
+ // want to render it.
111
+ this.publish(evt);
112
+ return;
113
+ }
114
+ // Order matters. A served tool is answered by the extension registry; any
115
+ // other event belongs to the backends, and a message a backend consumes is NOT
116
+ // a "no handler" error — that reply is only for events nobody wants. Asking
117
+ // the subscriptions first keeps a forwarded message from being answered with
118
+ // request.failed just because it carried a request id.
119
+ if (!this.serves(evt.type) && this.publish(evt))
120
+ return;
121
+ this.dispatchExtension(evt);
122
+ }
123
+ /** Whether the extension registry handles this event type. */
124
+ serves(type) {
125
+ return this.extensions().some((ext) => ext.event === type);
126
+ }
127
+ resolve(evt) {
128
+ if (evt.type !== EventType.RequestCompleted &&
129
+ evt.type !== EventType.RequestFailed &&
130
+ evt.type !== EventType.RequestRejected) {
131
+ return false;
132
+ }
133
+ const id = evt.request_id;
134
+ if (!id)
135
+ return false;
136
+ const p = this.pending.get(id);
137
+ if (!p)
138
+ return false;
139
+ this.pending.delete(id);
140
+ clearTimeout(p.timer);
141
+ if (evt.type === EventType.RequestCompleted)
142
+ p.resolve(evt);
143
+ else
144
+ p.reject(new ReplyError(evt));
145
+ return true;
146
+ }
147
+ /** Fan out to interested subscriptions, reporting whether any took it. */
148
+ publish(evt) {
149
+ let taken = false;
150
+ for (const sub of this.subs) {
151
+ if (!sub.active)
152
+ continue;
153
+ if (sub.filter && sub.filter.length > 0 && !sub.filter.includes(evt.type)) {
154
+ continue;
155
+ }
156
+ taken = true;
157
+ this.deliver(sub, evt);
158
+ }
159
+ return taken;
160
+ }
161
+ /** Isolates a failing subscriber: one broken backend must not stop the rest. */
162
+ deliver(sub, evt) {
163
+ try {
164
+ sub.fn(evt);
165
+ }
166
+ catch (err) {
167
+ console.warn(`[iface ${this.id}] subscriber failed on ${evt.type}:`, err);
168
+ }
169
+ }
170
+ newHandler() {
171
+ return {
172
+ id: this.id,
173
+ send: (evt, ...targets) => {
174
+ if (targets.length === 0) {
175
+ return Promise.reject(new Error("iface: send needs at least one target (use broadcast for everyone)"));
176
+ }
177
+ return this.channel.send(evt, ...targets);
178
+ },
179
+ broadcast: (evt) => this.channel.broadcast(evt),
180
+ request: (target, evt, opts) => this.request(target, evt, opts),
181
+ onEvent: (fn, filter) => this.onEvent(fn, filter),
182
+ };
183
+ }
184
+ request(target, evt, opts) {
185
+ if (!target)
186
+ return Promise.reject(new Error("iface: request needs a target"));
187
+ if (!evt.trace_id)
188
+ evt.trace_id = newId();
189
+ if (!evt.request_id)
190
+ evt.request_id = newId();
191
+ const id = evt.request_id;
192
+ const timeout = opts?.timeoutMs ?? this.requestTimeoutMs;
193
+ return new Promise((resolve, reject) => {
194
+ if (this.stopping) {
195
+ reject(new Error("iface: worker is stopped"));
196
+ return;
197
+ }
198
+ const timer = setTimeout(() => {
199
+ this.pending.delete(id);
200
+ reject(new Error(`iface: timed out after ${timeout}ms waiting for a reply from ${target}`));
201
+ }, timeout);
202
+ this.pending.set(id, { resolve, reject, timer });
203
+ this.channel.send(evt, target).catch((err) => {
204
+ clearTimeout(timer);
205
+ this.pending.delete(id);
206
+ reject(err instanceof Error ? err : new Error(String(err)));
207
+ });
208
+ });
209
+ }
210
+ onEvent(fn, filter) {
211
+ const sub = { fn, filter, active: true };
212
+ this.subs.add(sub);
213
+ return () => {
214
+ sub.active = false;
215
+ this.subs.delete(sub);
216
+ };
217
+ }
218
+ }
219
+ /** Convenience: build a reply event for a pending request. */
220
+ export function replyEvent(type, requestId, payload, traceId) {
221
+ const evt = createEvent(type, payload);
222
+ evt.request_id = requestId;
223
+ if (traceId)
224
+ evt.trace_id = traceId;
225
+ return evt;
226
+ }
227
+ //# sourceMappingURL=iface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iface.js","sourceRoot":"","sources":["../src/iface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,SAAS,GAMV,MAAM,kBAAkB,CAAC;AAyH1B,gFAAgF;AAChF,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAQjD,0EAA0E;AAC1E,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,KAAK,CAAQ;IAEtB,YAAY,KAAY;QACtB,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,KAAY;IACr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C,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,OAAO,CAAC,EAAwB,EAAE,MAAoB;QAC5D,MAAM,GAAG,GAAiB,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,GAAG,EAAE;YACV,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC;CACF;AAED,8DAA8D;AAC9D,MAAM,UAAU,UAAU,CAAC,IAAmB,EAAE,SAAiB,EAAE,OAAgC,EAAE,OAAgB;IACnH,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC;IAC3B,IAAI,OAAO;QAAE,GAAG,CAAC,QAAQ,GAAG,OAAO,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { HTTPWorkerClient } from "./client.js";
2
2
  export type { HTTPWorkerClientOptions } from "./client.js";
3
3
  export { BaseWorker, parseToolCall, argString, argInt } from "./baseworker.js";
4
+ export { InterfaceWorker, ReplyError, DEFAULT_REQUEST_TIMEOUT_MS, replyEvent, } from "./iface.js";
5
+ export type { Backend as IfaceBackend, Handler as IfaceHandler, Runnable as IfaceRunnable, ToolHost as IfaceToolHost, EventFilter, InterfaceWorkerOptions, RequestOptions, } from "./iface.js";
4
6
  export type { HelpFunc } from "./help.js";
5
7
  export { replyValue, replyText } from "./reply.js";
6
8
  export { s, isOptionalSchema, type JsonSchema } from "./schema.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":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WorkerClient } from "./client.js";
2
2
  export { BaseWorker, parseToolCall, argString, argInt } from "./baseworker.js";
3
+ export { InterfaceWorker, ReplyError, DEFAULT_REQUEST_TIMEOUT_MS, replyEvent, } from "./iface.js";
3
4
  export { replyValue, replyText } from "./reply.js";
4
5
  export { s, isOptionalSchema } from "./schema.js";
5
6
  export { parseCliArgs, busConnFromArgs, runWorkerApp, BUS_CLI_FLAGS } from "./cli.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG/E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAe,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EACL,SAAS,GAcV,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EACL,eAAe,EACf,UAAU,EACV,0BAA0B,EAC1B,UAAU,GACX,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAe,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EACL,SAAS,GAcV,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niq.run/worker-sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "TypeScript SDK for authoring niq Workers that connect to a niq bus over HTTP (SSE + POST).",
5
5
  "repository": {
6
6
  "type": "git",