@thinkwell/conductor 0.5.4 → 0.5.6

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.
@@ -1,90 +1,53 @@
1
- /**
2
- * Central message queue for the conductor
3
- *
4
- * All routing flows through this queue, preserving message ordering.
5
- * The queue supports async iteration, allowing the conductor's main loop
6
- * to consume messages as they arrive.
7
- */
8
- /**
9
- * A message queue with async iteration support.
10
- *
11
- * Messages can be pushed from multiple sources (client, proxies, agent)
12
- * and are consumed in order by the conductor's event loop.
13
- */
14
1
  export class MessageQueue {
15
- queue = [];
16
- resolvers = [];
17
- closed = false;
18
- /**
19
- * Push a message onto the queue.
20
- *
21
- * If there's a waiting consumer, the message is delivered immediately.
22
- * Otherwise, it's buffered until the next consumer is ready.
23
- */
24
- push(message) {
25
- if (this.closed) {
26
- return;
27
- }
28
- if (this.resolvers.length > 0) {
29
- const resolve = this.resolvers.shift();
30
- resolve(message);
31
- }
32
- else {
33
- this.queue.push(message);
34
- }
2
+ queue = [];
3
+ resolvers = [];
4
+ closed = !1;
5
+ /**
6
+ * Push a message onto the queue.
7
+ *
8
+ * If there's a waiting consumer, the message is delivered immediately.
9
+ * Otherwise, it's buffered until the next consumer is ready.
10
+ */
11
+ push(message) {
12
+ this.closed || (this.resolvers.length > 0 ? this.resolvers.shift()(message) : this.queue.push(message));
13
+ }
14
+ /**
15
+ * Close the queue, causing the async iterator to complete.
16
+ */
17
+ close() {
18
+ this.closed = !0;
19
+ for (const resolve of this.resolvers)
20
+ resolve({ type: "shutdown" });
21
+ this.resolvers = [];
22
+ }
23
+ /**
24
+ * Check if the queue has been closed
25
+ */
26
+ isClosed() {
27
+ return this.closed;
28
+ }
29
+ /**
30
+ * Async iterator for consuming messages.
31
+ *
32
+ * This allows the conductor to use `for await` to process messages:
33
+ * ```typescript
34
+ * for await (const msg of messageQueue) {
35
+ * await handleMessage(msg);
36
+ * }
37
+ * ```
38
+ */
39
+ async *[Symbol.asyncIterator]() {
40
+ for (; !this.closed; ) {
41
+ let message;
42
+ if (this.queue.length > 0 ? message = this.queue.shift() : message = await new Promise((resolve) => {
43
+ this.resolvers.push(resolve);
44
+ }), message.type === "shutdown")
45
+ return;
46
+ yield message;
35
47
  }
36
- /**
37
- * Close the queue, causing the async iterator to complete.
38
- */
39
- close() {
40
- this.closed = true;
41
- // Wake up any waiting consumers so they can exit
42
- for (const resolve of this.resolvers) {
43
- // Push a shutdown message to signal completion
44
- resolve({ type: "shutdown" });
45
- }
46
- this.resolvers = [];
47
- }
48
- /**
49
- * Check if the queue has been closed
50
- */
51
- isClosed() {
52
- return this.closed;
53
- }
54
- /**
55
- * Async iterator for consuming messages.
56
- *
57
- * This allows the conductor to use `for await` to process messages:
58
- * ```typescript
59
- * for await (const msg of messageQueue) {
60
- * await handleMessage(msg);
61
- * }
62
- * ```
63
- */
64
- async *[Symbol.asyncIterator]() {
65
- while (!this.closed) {
66
- let message;
67
- if (this.queue.length > 0) {
68
- message = this.queue.shift();
69
- }
70
- else {
71
- message = await new Promise((resolve) => {
72
- this.resolvers.push(resolve);
73
- });
74
- }
75
- // Check for shutdown message
76
- if (message.type === "shutdown") {
77
- return;
78
- }
79
- yield message;
80
- }
81
- // Drain any remaining messages in the queue
82
- while (this.queue.length > 0) {
83
- const message = this.queue.shift();
84
- if (message.type !== "shutdown") {
85
- yield message;
86
- }
87
- }
48
+ for (; this.queue.length > 0; ) {
49
+ const message = this.queue.shift();
50
+ message.type !== "shutdown" && (yield message);
88
51
  }
52
+ }
89
53
  }
90
- //# sourceMappingURL=message-queue.js.map
package/dist/types.js CHANGED
@@ -1,13 +1,6 @@
1
- /**
2
- * Internal types for the conductor
3
- */
4
- /**
5
- * Role relationships - encode at runtime what Rust does at compile time
6
- */
7
1
  export const ROLE_COUNTERPART = {
8
- client: "agent",
9
- agent: "client",
10
- proxy: "conductor",
11
- conductor: "proxy",
2
+ client: "agent",
3
+ agent: "client",
4
+ proxy: "conductor",
5
+ conductor: "proxy"
12
6
  };
13
- //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkwell/conductor",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "TypeScript conductor for ACP proxy chains - orchestrates message routing between clients, proxies, and agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "author": "David Herman",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@thinkwell/protocol": "0.5.4"
29
+ "@thinkwell/protocol": "0.5.6"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^24.10.4",
@@ -34,7 +34,8 @@
34
34
  "typescript": "^5.7.2"
35
35
  },
36
36
  "scripts": {
37
- "build": "tsc",
37
+ "build": "tsc && tsx ../../scripts/strip-features.ts --mode=release",
38
+ "build:debug": "tsc",
38
39
  "clean": "rm -rf dist",
39
40
  "test": "node --test --import tsx src/**/*.test.ts"
40
41
  }