stoops 0.1.0 → 0.2.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.

Potentially problematic release.


This version of stoops might be problematic. Click here for more details.

@@ -0,0 +1,201 @@
1
+ import { P as Participant, M as Message, a as PaginatedResult, E as EventCategory, R as RoomEvent, b as Room, C as Channel } from './index-DlxJ95ki.js';
2
+
3
+ /**
4
+ * RoomDataSource — abstraction over room data access.
5
+ *
6
+ * Allows tool handlers and EventProcessor to work against either a local
7
+ * Room object or a remote HTTP API. This is the critical enabler for
8
+ * client-side agent runtimes that connect to remote stoop servers.
9
+ */
10
+
11
+ /**
12
+ * Uniform interface for reading/writing room data.
13
+ *
14
+ * Implemented by:
15
+ * - `LocalRoomDataSource` — wraps a Room + Channel for in-process access
16
+ * - `RemoteRoomDataSource` — wraps HTTP calls to a stoop server (Phase 5)
17
+ */
18
+ interface RoomDataSource {
19
+ readonly roomId: string;
20
+ listParticipants(): Participant[];
21
+ getMessage(id: string): Promise<Message | null>;
22
+ searchMessages(query: string, limit?: number, cursor?: string | null): Promise<PaginatedResult<Message>>;
23
+ getMessages(limit?: number, cursor?: string | null): Promise<PaginatedResult<Message>>;
24
+ getEvents(category?: EventCategory | null, limit?: number, cursor?: string | null): Promise<PaginatedResult<RoomEvent>>;
25
+ sendMessage(content: string, replyToId?: string, image?: {
26
+ url: string;
27
+ mimeType: string;
28
+ sizeBytes: number;
29
+ } | null): Promise<Message>;
30
+ emitEvent?(event: RoomEvent): Promise<void>;
31
+ }
32
+ /**
33
+ * LocalRoomDataSource — wraps a Room + Channel for in-process access.
34
+ *
35
+ * Used by app-path consumers (ClaudeSession, LangGraphSession) and the
36
+ * CLI server's EventProcessor. Transparent — all calls delegate directly
37
+ * to the Room and Channel.
38
+ */
39
+ declare class LocalRoomDataSource implements RoomDataSource {
40
+ private _room;
41
+ private _channel;
42
+ constructor(_room: Room, _channel: Channel);
43
+ get roomId(): string;
44
+ /** Direct access to the underlying Room (for backward compat / internal use). */
45
+ get room(): Room;
46
+ /** Direct access to the underlying Channel (for backward compat / internal use). */
47
+ get channel(): Channel;
48
+ listParticipants(): Participant[];
49
+ getMessage(id: string): Promise<Message | null>;
50
+ searchMessages(query: string, limit?: number, cursor?: string | null): Promise<PaginatedResult<Message>>;
51
+ getMessages(limit?: number, cursor?: string | null): Promise<PaginatedResult<Message>>;
52
+ getEvents(category?: EventCategory | null, limit?: number, cursor?: string | null): Promise<PaginatedResult<RoomEvent>>;
53
+ sendMessage(content: string, replyToId?: string, image?: {
54
+ url: string;
55
+ mimeType: string;
56
+ sizeBytes: number;
57
+ } | null): Promise<Message>;
58
+ emitEvent(event: RoomEvent): Promise<void>;
59
+ }
60
+
61
+ /**
62
+ * Shared interfaces for stoops agent infrastructure.
63
+ *
64
+ * Two layers:
65
+ *
66
+ * EventProcessor ──deliver()──► Consumer (ClaudeSession, LangGraphSession, tmux, etc.)
67
+ *
68
+ * EventProcessor owns the event loop, engagement, formatting.
69
+ * Consumers own LLM delivery, MCP servers, compaction, stats.
70
+ */
71
+
72
+ /**
73
+ * A structured content item delivered to the consumer.
74
+ *
75
+ * Text parts carry formatted event text; image parts carry the URL of an
76
+ * attached image so vision-capable consumers can see it natively.
77
+ */
78
+ type ContentPart = {
79
+ type: "text";
80
+ text: string;
81
+ } | {
82
+ type: "image";
83
+ url: string;
84
+ };
85
+ /**
86
+ * A resolved room connection: the data source, the room's display name,
87
+ * and optional direct room/channel references for backward compatibility.
88
+ *
89
+ * Tool handlers and EventProcessor use `dataSource` for all data access.
90
+ * Direct `room`/`channel` access is kept for app-path consumers that need it.
91
+ */
92
+ interface RoomConnection {
93
+ dataSource: RoomDataSource;
94
+ /** Present for local (app-path) rooms; absent for remote rooms. */
95
+ room?: Room;
96
+ /** Present for local (app-path) rooms; absent for remote rooms. */
97
+ channel?: Channel;
98
+ name: string;
99
+ }
100
+ /**
101
+ * Maps room names (and identifiers) to their live connections.
102
+ *
103
+ * Implemented by `EventProcessor`. Tool handlers and sessions receive a
104
+ * `RoomResolver` so they can look up rooms by the names the LLM uses.
105
+ */
106
+ interface RoomResolver {
107
+ /** Resolve a room by display name, identifier slug, or room ID. Returns null if unknown. */
108
+ resolve(roomName: string): RoomConnection | null;
109
+ /** List all currently connected rooms with metadata. */
110
+ listAll(): Array<{
111
+ name: string;
112
+ roomId: string;
113
+ identifier?: string;
114
+ mode: string;
115
+ participantCount: number;
116
+ lastMessage?: string;
117
+ }>;
118
+ }
119
+ /**
120
+ * A single tool call or result recorded during an LLM evaluation.
121
+ * Used for trace logging and observability.
122
+ */
123
+ interface QueryTurn {
124
+ type: "tool_use" | "tool_result";
125
+ tool: string;
126
+ content: unknown;
127
+ }
128
+ /**
129
+ * Stats from one complete LLM evaluation (one `session.process()` call).
130
+ * Reported via `LLMSessionOptions.onQueryComplete` after every evaluation.
131
+ */
132
+ interface LLMQueryStats {
133
+ totalCostUsd: number;
134
+ durationMs: number;
135
+ durationApiMs: number;
136
+ numTurns: number;
137
+ inputTokens: number;
138
+ outputTokens: number;
139
+ cacheReadInputTokens: number;
140
+ cacheCreationInputTokens: number;
141
+ isError: boolean;
142
+ contextPct: number;
143
+ input: string;
144
+ turns: QueryTurn[];
145
+ }
146
+ /**
147
+ * LLM session interface — the consumer side of the EventProcessor split.
148
+ *
149
+ * Each instance represents one agent's persistent conversation.
150
+ * `process()` is the delivery method — EventProcessor calls it via the
151
+ * `deliver` callback passed to `run()`.
152
+ */
153
+ interface ILLMSession {
154
+ start(): Promise<void>;
155
+ stop(): Promise<void>;
156
+ process(parts: ContentPart[]): Promise<void>;
157
+ setApiKey(key: string): void;
158
+ }
159
+ /** Agent identity fields. */
160
+ interface AgentIdentity {
161
+ selfId?: string;
162
+ selfIdentifier?: string;
163
+ identity?: string;
164
+ apiKey?: string;
165
+ }
166
+ /** Callbacks that bridge the session to the EventProcessor. */
167
+ interface ProcessorBridge {
168
+ isEventSeen?: (eventId: string) => boolean;
169
+ markEventsSeen?: (eventIds: string[]) => void;
170
+ assignRef?: (messageId: string) => string;
171
+ resolveRef?: (ref: string) => string | undefined;
172
+ onContextCompacted?: () => void;
173
+ onToolUse?: (toolName: string, status: "started" | "completed") => void;
174
+ }
175
+ /** Session-level callbacks and settings. */
176
+ interface SessionCallbacks {
177
+ onQueryComplete?: (stats: LLMQueryStats) => void;
178
+ resolveParticipantIdentifier?: (id: string) => string | null;
179
+ autoCompactPct?: number;
180
+ }
181
+ /**
182
+ * Options for LLM session consumers.
183
+ *
184
+ * These are callbacks the session calls to integrate with the EventProcessor:
185
+ * event tracking, ref resolution, stats reporting, and context management.
186
+ * The caller assembles these by wiring EventProcessor methods.
187
+ */
188
+ interface LLMSessionOptions extends AgentIdentity, ProcessorBridge, SessionCallbacks {
189
+ }
190
+ /** Subset of ProcessorBridge used by tool handlers and MCP server. */
191
+ type ToolHandlerOptions = Pick<ProcessorBridge, "isEventSeen" | "markEventsSeen" | "assignRef" | "resolveRef">;
192
+ /** Claude-specific session options. */
193
+ interface ClaudeSessionOptions extends LLMSessionOptions {
194
+ pathToClaudeCodeExecutable?: string;
195
+ }
196
+ /** LangGraph-specific session options. */
197
+ interface LangGraphSessionOptions extends LLMSessionOptions {
198
+ drainEventQueue?: () => ContentPart[][] | null;
199
+ }
200
+
201
+ export { type AgentIdentity as A, type ClaudeSessionOptions as C, type ILLMSession as I, type LangGraphSessionOptions as L, type ProcessorBridge as P, type QueryTurn as Q, type RoomResolver as R, type SessionCallbacks as S, type ToolHandlerOptions as T, type ContentPart as a, type RoomConnection as b, type RoomDataSource as c, type LLMQueryStats as d, type LLMSessionOptions as e, LocalRoomDataSource as f };
package/package.json CHANGED
@@ -1,27 +1,85 @@
1
1
  {
2
2
  "name": "stoops",
3
- "version": "0.1.0",
4
- "description": "Real-time multi-agent chat framework. Coming soon.",
3
+ "version": "0.2.0",
4
+ "description": "A group chat for humans and Claude Code agents",
5
+ "keywords": [
6
+ "ai",
7
+ "agents",
8
+ "mcp",
9
+ "claude",
10
+ "claude-code",
11
+ "rooms",
12
+ "chat",
13
+ "multi-agent",
14
+ "llm",
15
+ "collaborative"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/izzat5233/stoops.git"
20
+ },
21
+ "homepage": "https://github.com/izzat5233/stoops",
22
+ "bugs": {
23
+ "url": "https://github.com/izzat5233/stoops/issues"
24
+ },
5
25
  "type": "module",
6
26
  "main": "./dist/index.js",
7
- "files": ["dist"],
27
+ "types": "./dist/index.d.ts",
28
+ "bin": {
29
+ "stoops": "./dist/cli/index.js"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
8
34
  "exports": {
9
35
  ".": {
10
- "import": "./dist/index.js"
36
+ "import": "./dist/index.js",
37
+ "types": "./dist/index.d.ts"
38
+ },
39
+ "./agent": {
40
+ "import": "./dist/agent/index.js",
41
+ "types": "./dist/agent/index.d.ts"
42
+ },
43
+ "./claude": {
44
+ "import": "./dist/claude/index.js",
45
+ "types": "./dist/claude/index.d.ts"
46
+ },
47
+ "./langgraph": {
48
+ "import": "./dist/langgraph/index.js",
49
+ "types": "./dist/langgraph/index.d.ts"
11
50
  }
12
51
  },
13
52
  "scripts": {
14
- "build": "tsup"
15
- },
16
- "keywords": ["agents", "multi-agent", "chat", "real-time", "ai"],
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/izzat5233/stoops"
53
+ "build": "tsup",
54
+ "watch": "tsup --watch",
55
+ "test": "vitest run",
56
+ "test:watch": "vitest",
57
+ "typecheck": "tsc --noEmit"
20
58
  },
21
59
  "author": "Izzat Alsharif <work@izzatalsharif.com>",
22
60
  "license": "MIT",
61
+ "dependencies": {
62
+ "@modelcontextprotocol/sdk": "^1.27.1",
63
+ "ink": "^6.8.0",
64
+ "react": "^19.2.4",
65
+ "uuid": "^11.0.0",
66
+ "zod": "^4.0.0"
67
+ },
68
+ "optionalDependencies": {
69
+ "@anthropic-ai/claude-agent-sdk": "^0.2.12",
70
+ "@langchain/anthropic": "^1.0.0",
71
+ "@langchain/core": "^1.0.0",
72
+ "@langchain/langgraph": "^1.0.0",
73
+ "@langchain/mcp-adapters": "^1.1.3",
74
+ "langchain": "^1.0.0"
75
+ },
23
76
  "devDependencies": {
77
+ "@types/node": "^25.2.3",
78
+ "@types/react": "^19.2.14",
79
+ "@types/uuid": "^10.0.0",
24
80
  "tsup": "^8.0.0",
25
- "typescript": "^5.7.0"
81
+ "tsx": "^4.0.0",
82
+ "typescript": "^5.7.0",
83
+ "vitest": "^3.0.0"
26
84
  }
27
85
  }