anyclaude-sdk 0.6.0 → 0.6.1
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/queue.d.ts +13 -2
- package/dist/queue.js +21 -2
- package/package.json +1 -1
package/dist/queue.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ContentBlockParam } from './types/index.js';
|
|
2
2
|
export type QueuedContent = string | ContentBlockParam[];
|
|
3
3
|
export interface QueuedMessage {
|
|
4
|
+
/** Stable id for this queued item — use it to `remove()` a single message. */
|
|
5
|
+
id: string;
|
|
4
6
|
content: QueuedContent;
|
|
5
7
|
/** Epoch ms when enqueued. */
|
|
6
8
|
at: number;
|
|
@@ -8,10 +10,19 @@ export interface QueuedMessage {
|
|
|
8
10
|
export declare class MessageQueue {
|
|
9
11
|
private items;
|
|
10
12
|
private listeners;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Enqueue a user message to be delivered at the next turn boundary.
|
|
15
|
+
* Returns the item's stable `id` (pass it to `remove()` to cancel just this one).
|
|
16
|
+
*/
|
|
17
|
+
push(content: QueuedContent): string;
|
|
13
18
|
/** Remove and return the oldest queued message (FIFO), or undefined if empty. */
|
|
14
19
|
shift(): QueuedMessage | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Remove a single pending message by its `id` (e.g. a per-pill ✕ in the UI).
|
|
22
|
+
* Returns true if an item was removed. No-op if the id isn't pending — already
|
|
23
|
+
* drained (shifted) items can't be cancelled.
|
|
24
|
+
*/
|
|
25
|
+
remove(id: string): boolean;
|
|
15
26
|
peek(): QueuedMessage | undefined;
|
|
16
27
|
get size(): number;
|
|
17
28
|
/** Snapshot of pending messages (does not drain). */
|
package/dist/queue.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { uuid } from './util/ids.js';
|
|
1
2
|
export class MessageQueue {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.items = [];
|
|
4
5
|
this.listeners = new Set();
|
|
5
6
|
}
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Enqueue a user message to be delivered at the next turn boundary.
|
|
9
|
+
* Returns the item's stable `id` (pass it to `remove()` to cancel just this one).
|
|
10
|
+
*/
|
|
7
11
|
push(content) {
|
|
8
|
-
|
|
12
|
+
const id = uuid();
|
|
13
|
+
this.items.push({ id, content, at: Date.now() });
|
|
9
14
|
this.emit();
|
|
15
|
+
return id;
|
|
10
16
|
}
|
|
11
17
|
/** Remove and return the oldest queued message (FIFO), or undefined if empty. */
|
|
12
18
|
shift() {
|
|
@@ -15,6 +21,19 @@ export class MessageQueue {
|
|
|
15
21
|
this.emit();
|
|
16
22
|
return m;
|
|
17
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Remove a single pending message by its `id` (e.g. a per-pill ✕ in the UI).
|
|
26
|
+
* Returns true if an item was removed. No-op if the id isn't pending — already
|
|
27
|
+
* drained (shifted) items can't be cancelled.
|
|
28
|
+
*/
|
|
29
|
+
remove(id) {
|
|
30
|
+
const i = this.items.findIndex((m) => m.id === id);
|
|
31
|
+
if (i < 0)
|
|
32
|
+
return false;
|
|
33
|
+
this.items.splice(i, 1);
|
|
34
|
+
this.emit();
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
18
37
|
peek() {
|
|
19
38
|
return this.items[0];
|
|
20
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anyclaude-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Standalone, browser-compatible SDK providing Claude Code agent capabilities (tools, tool loop, multi-turn, MCP, sub-agents, sessions) against any OpenAI/Anthropic-compatible LLM endpoint. Runs in the browser (WebContainer), Node, and Bun — no backend required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|