@niq.run/worker-sdk 0.5.0 → 0.7.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 +5 -2
- package/dist/baseworker.d.ts +36 -4
- package/dist/baseworker.d.ts.map +1 -1
- package/dist/baseworker.js +79 -13
- package/dist/baseworker.js.map +1 -1
- package/dist/types/extension.d.ts +11 -4
- package/dist/types/extension.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,7 +164,8 @@ const line = replyText(evt.payload); // string verbatim, else JSON
|
|
|
164
164
|
`BaseWorker` (mirrors Go `pkg/baseworker`) layers the shared worker plumbing
|
|
165
165
|
on top of a `WorkerSideChannel`: an extension registry (what the worker
|
|
166
166
|
responds to and how), tool-request reply plumbing, and the `worker.ready`
|
|
167
|
-
presence announcement.
|
|
167
|
+
presence announcement. Presence is transient (live-only, never persisted), and
|
|
168
|
+
a `worker.discover` is answered automatically with a directed `worker.ready`.
|
|
168
169
|
|
|
169
170
|
```ts
|
|
170
171
|
import { BaseWorker, HTTPWorkerClient, parseToolCall, EventType } from "@niq.run/worker-sdk";
|
|
@@ -190,7 +191,9 @@ worker.register(
|
|
|
190
191
|
);
|
|
191
192
|
|
|
192
193
|
await worker.channel.connect();
|
|
193
|
-
|
|
194
|
+
// Broadcast worker.ready (transient, self excluded) and remember the contract,
|
|
195
|
+
// so a later worker.discover is answered directly — no extra code needed here.
|
|
196
|
+
await worker.announceReady("echo");
|
|
194
197
|
|
|
195
198
|
for await (const evt of worker.channel.events()) {
|
|
196
199
|
if (!worker.dispatchExtension(evt)) {
|
package/dist/baseworker.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare class BaseWorker {
|
|
|
15
15
|
readonly subscriptions: EventPattern[];
|
|
16
16
|
readonly channel: WorkerSideChannel;
|
|
17
17
|
private readonly regs;
|
|
18
|
+
/** The contract last announced, so a `worker.discover` can be answered. */
|
|
19
|
+
private announced;
|
|
18
20
|
constructor(opts: {
|
|
19
21
|
id: string;
|
|
20
22
|
subscriptions?: EventPattern[];
|
|
@@ -33,23 +35,53 @@ export declare class BaseWorker {
|
|
|
33
35
|
* Route an event to the registered extension matching its event type.
|
|
34
36
|
* Returns whether a handler ran; the first matching registration wins. Async
|
|
35
37
|
* handlers are not awaited.
|
|
38
|
+
*
|
|
39
|
+
* An `internal` extension is self-scoped: a request from any other worker is
|
|
40
|
+
* refused before the handler runs (a `request.rejected` when the event carries
|
|
41
|
+
* a request id). The bus stamps the sender's worker id, so a peer cannot pose
|
|
42
|
+
* as the owner.
|
|
43
|
+
*
|
|
44
|
+
* A request that matches no extension is answered with `request.failed` rather
|
|
45
|
+
* than dropped, so the caller's pending call cannot wait forever on a worker
|
|
46
|
+
* that does not serve that event.
|
|
47
|
+
*
|
|
48
|
+
* `worker.discover` is protocol traffic rather than an extension: it is
|
|
49
|
+
* answered here with the contract last passed to {@link announceReady} (a
|
|
50
|
+
* directed, transient `worker.ready` to the asker), mirroring Go's
|
|
51
|
+
* AnnounceReadyTo. Presence is live-only and never persisted, so a peer that
|
|
52
|
+
* starts later — or a UI that cannot read presence from history — learns the
|
|
53
|
+
* worker's tools by asking.
|
|
36
54
|
*/
|
|
37
55
|
dispatchExtension(evt: Event): boolean;
|
|
38
56
|
/** Snapshot of the registered extensions (insertion order). */
|
|
39
57
|
extensions(): Extension[];
|
|
40
58
|
/**
|
|
41
59
|
* Render the registry into the `worker.ready` "watch" wire format.
|
|
42
|
-
* `
|
|
43
|
-
* peer-facing broadcast leaves them out (they are not
|
|
60
|
+
* `includeInternal` controls whether Internal extensions are rendered: a
|
|
61
|
+
* peer-facing broadcast leaves them out (they are not advertised to peers;
|
|
62
|
+
* visibility only — the bus ACL, not this parameter, gates dispatch).
|
|
44
63
|
*/
|
|
45
|
-
watchEntries(
|
|
64
|
+
watchEntries(includeInternal: boolean): Record<string, unknown>[];
|
|
46
65
|
/**
|
|
47
66
|
* Broadcast this worker's presence on the bus: the externally callable
|
|
48
|
-
* contract (
|
|
67
|
+
* contract (Internal left out), self excluded via `exclude_worker_id`.
|
|
49
68
|
* `publishes` is the wire form of the events this worker declares it emits
|
|
50
69
|
* (`worker.ready` "publishes").
|
|
70
|
+
*
|
|
71
|
+
* The contract is remembered, so {@link dispatchExtension} can answer a
|
|
72
|
+
* `worker.discover` with it. The event is transient: presence is delivered
|
|
73
|
+
* live and never written to the durable event log (mirroring Go).
|
|
51
74
|
*/
|
|
52
75
|
announceReady(workerType: string, publishes?: Record<string, unknown>[]): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Send this worker's presence directly to one target instead of broadcasting
|
|
78
|
+
* it — the answer to a `worker.discover`, and the direct equivalent of Go's
|
|
79
|
+
* AnnounceReadyTo. Omitted arguments reuse the contract last announced with
|
|
80
|
+
* {@link announceReady}; with no contract announced yet, nothing is sent.
|
|
81
|
+
*/
|
|
82
|
+
announceReadyTo(target: string, workerType?: string, publishes?: Record<string, unknown>[]): Promise<void>;
|
|
83
|
+
/** Render one `worker.ready` event from a declared contract. */
|
|
84
|
+
private presenceEvent;
|
|
53
85
|
/**
|
|
54
86
|
* Answer a request caller with a request.completed result.
|
|
55
87
|
*
|
package/dist/baseworker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseworker.d.ts","sourceRoot":"","sources":["../src/baseworker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAK1B;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,aAAa,EAAE,YAAY,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAGjB;
|
|
1
|
+
{"version":3,"file":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CACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,MAAM,CAIR"}
|
package/dist/baseworker.js
CHANGED
|
@@ -17,6 +17,8 @@ export class BaseWorker {
|
|
|
17
17
|
subscriptions;
|
|
18
18
|
channel;
|
|
19
19
|
regs = new Map();
|
|
20
|
+
/** The contract last announced, so a `worker.discover` can be answered. */
|
|
21
|
+
announced = null;
|
|
20
22
|
constructor(opts) {
|
|
21
23
|
this.id = opts.id;
|
|
22
24
|
this.subscriptions = opts.subscriptions ?? [];
|
|
@@ -44,14 +46,47 @@ export class BaseWorker {
|
|
|
44
46
|
* Route an event to the registered extension matching its event type.
|
|
45
47
|
* Returns whether a handler ran; the first matching registration wins. Async
|
|
46
48
|
* handlers are not awaited.
|
|
49
|
+
*
|
|
50
|
+
* An `internal` extension is self-scoped: a request from any other worker is
|
|
51
|
+
* refused before the handler runs (a `request.rejected` when the event carries
|
|
52
|
+
* a request id). The bus stamps the sender's worker id, so a peer cannot pose
|
|
53
|
+
* as the owner.
|
|
54
|
+
*
|
|
55
|
+
* A request that matches no extension is answered with `request.failed` rather
|
|
56
|
+
* than dropped, so the caller's pending call cannot wait forever on a worker
|
|
57
|
+
* that does not serve that event.
|
|
58
|
+
*
|
|
59
|
+
* `worker.discover` is protocol traffic rather than an extension: it is
|
|
60
|
+
* answered here with the contract last passed to {@link announceReady} (a
|
|
61
|
+
* directed, transient `worker.ready` to the asker), mirroring Go's
|
|
62
|
+
* AnnounceReadyTo. Presence is live-only and never persisted, so a peer that
|
|
63
|
+
* starts later — or a UI that cannot read presence from history — learns the
|
|
64
|
+
* worker's tools by asking.
|
|
47
65
|
*/
|
|
48
66
|
dispatchExtension(evt) {
|
|
67
|
+
if (evt.type === EventType.WorkerDiscover) {
|
|
68
|
+
const asker = evt.worker_id;
|
|
69
|
+
if (asker && asker !== this.id)
|
|
70
|
+
void this.announceReadyTo(asker);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
49
73
|
for (const { ext, handler } of this.regs.values()) {
|
|
50
74
|
if (ext.event !== evt.type)
|
|
51
75
|
continue;
|
|
76
|
+
if (ext.internal && evt.worker_id !== this.id) {
|
|
77
|
+
if (evt.request_id) {
|
|
78
|
+
void this.replyRejected(evt.worker_id, evt.request_id, `internal capability: only ${this.id} may invoke it`, evt.trace_id);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
52
82
|
void handler(evt);
|
|
53
83
|
return true;
|
|
54
84
|
}
|
|
85
|
+
// No registration matched: answer a request so the caller cannot hang on a
|
|
86
|
+
// silent drop. Notifications have nothing waiting.
|
|
87
|
+
if (evt.request_id) {
|
|
88
|
+
void this.replyFailed(evt.worker_id, evt.request_id, `no handler for event ${evt.type}`, evt.trace_id);
|
|
89
|
+
}
|
|
55
90
|
return false;
|
|
56
91
|
}
|
|
57
92
|
/** Snapshot of the registered extensions (insertion order). */
|
|
@@ -60,13 +95,14 @@ export class BaseWorker {
|
|
|
60
95
|
}
|
|
61
96
|
/**
|
|
62
97
|
* Render the registry into the `worker.ready` "watch" wire format.
|
|
63
|
-
* `
|
|
64
|
-
* peer-facing broadcast leaves them out (they are not
|
|
98
|
+
* `includeInternal` controls whether Internal extensions are rendered: a
|
|
99
|
+
* peer-facing broadcast leaves them out (they are not advertised to peers;
|
|
100
|
+
* visibility only — the bus ACL, not this parameter, gates dispatch).
|
|
65
101
|
*/
|
|
66
|
-
watchEntries(
|
|
102
|
+
watchEntries(includeInternal) {
|
|
67
103
|
const out = [];
|
|
68
104
|
for (const ext of this.extensions()) {
|
|
69
|
-
if (ext.
|
|
105
|
+
if (ext.internal && !includeInternal)
|
|
70
106
|
continue;
|
|
71
107
|
const entry = {
|
|
72
108
|
event: ext.event,
|
|
@@ -84,19 +120,17 @@ export class BaseWorker {
|
|
|
84
120
|
}
|
|
85
121
|
/**
|
|
86
122
|
* Broadcast this worker's presence on the bus: the externally callable
|
|
87
|
-
* contract (
|
|
123
|
+
* contract (Internal left out), self excluded via `exclude_worker_id`.
|
|
88
124
|
* `publishes` is the wire form of the events this worker declares it emits
|
|
89
125
|
* (`worker.ready` "publishes").
|
|
126
|
+
*
|
|
127
|
+
* The contract is remembered, so {@link dispatchExtension} can answer a
|
|
128
|
+
* `worker.discover` with it. The event is transient: presence is delivered
|
|
129
|
+
* live and never written to the durable event log (mirroring Go).
|
|
90
130
|
*/
|
|
91
131
|
async announceReady(workerType, publishes) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
watch: this.watchEntries(false),
|
|
95
|
-
};
|
|
96
|
-
if (publishes && publishes.length > 0) {
|
|
97
|
-
payload["publishes"] = publishes;
|
|
98
|
-
}
|
|
99
|
-
const presence = createEvent(EventType.WorkerReady, payload);
|
|
132
|
+
this.announced = { workerType, publishes };
|
|
133
|
+
const presence = this.presenceEvent(this.announced);
|
|
100
134
|
presence.exclude_worker_id = this.id;
|
|
101
135
|
try {
|
|
102
136
|
await this.channel.broadcast(presence);
|
|
@@ -105,6 +139,38 @@ export class BaseWorker {
|
|
|
105
139
|
// Presence announcements are best-effort, mirroring Go.
|
|
106
140
|
}
|
|
107
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Send this worker's presence directly to one target instead of broadcasting
|
|
144
|
+
* it — the answer to a `worker.discover`, and the direct equivalent of Go's
|
|
145
|
+
* AnnounceReadyTo. Omitted arguments reuse the contract last announced with
|
|
146
|
+
* {@link announceReady}; with no contract announced yet, nothing is sent.
|
|
147
|
+
*/
|
|
148
|
+
async announceReadyTo(target, workerType, publishes) {
|
|
149
|
+
const announced = workerType !== undefined
|
|
150
|
+
? { workerType, publishes }
|
|
151
|
+
: this.announced;
|
|
152
|
+
if (!announced)
|
|
153
|
+
return;
|
|
154
|
+
try {
|
|
155
|
+
await this.channel.send(this.presenceEvent(announced), target);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Presence announcements are best-effort, mirroring Go.
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/** Render one `worker.ready` event from a declared contract. */
|
|
162
|
+
presenceEvent(announced) {
|
|
163
|
+
const payload = {
|
|
164
|
+
type: announced.workerType,
|
|
165
|
+
watch: this.watchEntries(false),
|
|
166
|
+
};
|
|
167
|
+
if (announced.publishes && announced.publishes.length > 0) {
|
|
168
|
+
payload["publishes"] = announced.publishes;
|
|
169
|
+
}
|
|
170
|
+
const presence = createEvent(EventType.WorkerReady, payload);
|
|
171
|
+
presence.transient = true; // presence: live-only, not durable history
|
|
172
|
+
return presence;
|
|
173
|
+
}
|
|
108
174
|
// ── Tool-serving helpers ──
|
|
109
175
|
//
|
|
110
176
|
// The repetitive parts every tool-serving worker repeats: replying to a
|
package/dist/baseworker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseworker.js","sourceRoot":"","sources":["../src/baseworker.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IACZ,EAAE,CAAS;IACX,aAAa,CAAiB;IAC9B,OAAO,CAAoB;IAEnB,IAAI,GAAG,IAAI,GAAG,EAG5B,CAAC;IAEJ,YAAY,IAIX;QACC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAc,EAAE,OAAyB;QAChD,MAAM,UAAU,GAAc,EAAE,GAAG,GAAG,EAAE,CAAC;QACzC,IAAI,GAAG,CAAC,UAAU,KAAK,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IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CACpB,IAA6B,EAC7B,GAAW,EACX,GAAW;IAEX,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2EAA2E;AAC3E,uEAAuE;AACvE,sDAAsD;AACtD,SAAS,YAAY,CAAC,GAAc;IAClC,OAAO,GAAG,GAAG,CAAC,KAAK,MAAM,CAAC;AAC5B,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -27,11 +27,18 @@ export interface Extension {
|
|
|
27
27
|
/** The event type the extension responds to — its identity. */
|
|
28
28
|
event: string;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* Internal marks an extension that belongs to the worker's OWN view: it is
|
|
31
|
+
* not advertised in the peer-facing `worker.ready` announcement (directory /
|
|
32
|
+
* WebUI / PTC), and a request from any other worker is refused before the
|
|
33
|
+
* handler runs (a `request.rejected` when the event carries a request id). The
|
|
34
|
+
* declaring worker still invokes it normally, and the self-directed ready
|
|
35
|
+
* keeps it in its own tool list.
|
|
36
|
+
*
|
|
37
|
+
* This is a scope rule, not a general access control: it says the capability
|
|
38
|
+
* is meaningful only to its owner. Whether another worker may address this one
|
|
39
|
+
* at all is still the bus ACL's job.
|
|
33
40
|
*/
|
|
34
|
-
|
|
41
|
+
internal?: boolean;
|
|
35
42
|
description?: string;
|
|
36
43
|
/**
|
|
37
44
|
* The request's JSON Schema — what a caller must pass as the event payload.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/types/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpE,uFAAuF;AACvF,MAAM,WAAW,QAAQ;IACvB,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB"}
|