@bubblebrain-ai/bubble 0.0.54 → 0.0.56
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 +43 -0
- package/dist/agent/input-controller.d.ts +3 -0
- package/dist/agent/input-controller.js +13 -0
- package/dist/agent.js +7 -1
- package/dist/context/budget.js +7 -2
- package/dist/model-catalog.d.ts +1 -1
- package/dist/model-catalog.js +12 -2
- package/dist/model-pricing.d.ts +1 -5
- package/dist/model-pricing.js +0 -0
- package/dist/provider-ai-sdk.js +5 -0
- package/dist/provider-ark-responses.d.ts +12 -2
- package/dist/provider-ark-responses.js +68 -13
- package/dist/provider-registry.js +34 -10
- package/dist/provider.js +7 -1
- package/dist/sdk/index.d.ts +97 -6
- package/dist/sdk/index.js +445 -34
- package/dist/sdk/replay-event-log.d.ts +19 -0
- package/dist/sdk/replay-event-log.js +72 -0
- package/dist/sdk/session-turn-coordinator.d.ts +45 -0
- package/dist/sdk/session-turn-coordinator.js +227 -0
- package/dist/tui/app.js +5 -3
- package/dist/tui/controller/controller.js +12 -6
- package/dist/tui/fullscreen.js +2 -1
- package/dist/tui/model/image-paste.js +9 -10
- package/dist/types.d.ts +14 -2
- package/package.json +1 -1
package/dist/sdk/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type { ResolvedSubagentRoute } from "../agent/categories.js";
|
|
|
21
21
|
import { type QuestionAnswer, type QuestionRequest } from "../question/controller.js";
|
|
22
22
|
import { SkillRegistry } from "../skills/registry.js";
|
|
23
23
|
import type { SkillSummary } from "../skills/types.js";
|
|
24
|
-
import type { AgentEvent, ContentPart, Message, PermissionMode, Provider, ThinkingLevel } from "../types.js";
|
|
24
|
+
import type { AgentEvent, AgentRunInput, ContentPart, Message, PermissionMode, Provider, ThinkingLevel } from "../types.js";
|
|
25
25
|
export interface BubbleSdkOptions {
|
|
26
26
|
/** Fallback working directory for sessions created without an explicit cwd. */
|
|
27
27
|
defaultCwd?: string;
|
|
@@ -81,6 +81,62 @@ export interface SdkSessionRef {
|
|
|
81
81
|
id: string;
|
|
82
82
|
cwd: string;
|
|
83
83
|
}
|
|
84
|
+
export interface SdkSessionRunState {
|
|
85
|
+
/** A turn owns the session slot, including setup and teardown. */
|
|
86
|
+
active: boolean;
|
|
87
|
+
queuedTurns: number;
|
|
88
|
+
pendingSteers: number;
|
|
89
|
+
phase: "idle" | "reserved" | "starting" | "active" | "stopping" | "deleted";
|
|
90
|
+
}
|
|
91
|
+
export type SdkSteerOutcome = Extract<AgentEvent, {
|
|
92
|
+
type: "input_applied" | "input_queued" | "input_rejected";
|
|
93
|
+
}>;
|
|
94
|
+
export type SdkSteerResult = {
|
|
95
|
+
accepted: true;
|
|
96
|
+
disposition: "steered";
|
|
97
|
+
input: AgentRunInput;
|
|
98
|
+
outcome: Promise<SdkSteerOutcome>;
|
|
99
|
+
} | {
|
|
100
|
+
accepted: true;
|
|
101
|
+
disposition: "queued";
|
|
102
|
+
input: AgentRunInput;
|
|
103
|
+
turnId: string;
|
|
104
|
+
outcome: Promise<SdkSteerOutcome>;
|
|
105
|
+
} | {
|
|
106
|
+
accepted: false;
|
|
107
|
+
disposition: "rejected";
|
|
108
|
+
reason: "unknown_session" | "session_deleted" | "ownership_conflict";
|
|
109
|
+
};
|
|
110
|
+
export interface SdkSessionEvent {
|
|
111
|
+
sequence: number;
|
|
112
|
+
sessionId: string;
|
|
113
|
+
turnId: string;
|
|
114
|
+
event: AgentEvent;
|
|
115
|
+
/**
|
|
116
|
+
* Present only on the synthesized record that ends a turn abnormally.
|
|
117
|
+
* Replay subscribers use it to tell "turn failed" from "turn still running";
|
|
118
|
+
* the per-turn runTurn() iterator instead surfaces the thrown error.
|
|
119
|
+
*/
|
|
120
|
+
terminal?: SdkSessionTerminal;
|
|
121
|
+
}
|
|
122
|
+
export interface SdkSessionTerminal {
|
|
123
|
+
kind: "failed" | "cancelled";
|
|
124
|
+
message: string;
|
|
125
|
+
}
|
|
126
|
+
export interface SdkStopOptions {
|
|
127
|
+
/** Match Claude-style interruption: queued messages survive by default. */
|
|
128
|
+
cancelQueued?: boolean;
|
|
129
|
+
}
|
|
130
|
+
export interface SdkSessionHandle extends SdkSessionRef {
|
|
131
|
+
/** Events from every turn in this session. Opening another handle reconnects from sequence 1. */
|
|
132
|
+
readonly events: AsyncIterable<SdkSessionEvent>;
|
|
133
|
+
/** Reconnect after the last sequence the host durably processed. */
|
|
134
|
+
eventsFrom(afterSequence: number): AsyncIterable<SdkSessionEvent>;
|
|
135
|
+
send(options: RunTurnOptions): AsyncGenerator<AgentEvent>;
|
|
136
|
+
steer(content: string): SdkSteerResult;
|
|
137
|
+
stop(options?: SdkStopOptions): number;
|
|
138
|
+
close(): void;
|
|
139
|
+
}
|
|
84
140
|
export declare class BubbleSdk {
|
|
85
141
|
readonly userConfig: UserConfig;
|
|
86
142
|
readonly registry: ProviderRegistry;
|
|
@@ -88,8 +144,13 @@ export declare class BubbleSdk {
|
|
|
88
144
|
private readonly mcpEnabled;
|
|
89
145
|
private readonly cwdBySession;
|
|
90
146
|
private readonly bashAllowlists;
|
|
91
|
-
private readonly
|
|
147
|
+
private readonly turnCoordinator;
|
|
148
|
+
private readonly turnRuntimes;
|
|
149
|
+
private readonly lastTurnOptions;
|
|
92
150
|
private readonly mcpToolsByCwd;
|
|
151
|
+
private readonly inputIdNonce;
|
|
152
|
+
private nextTurnInputPrefix;
|
|
153
|
+
private nextDetachedInputId;
|
|
93
154
|
/** id -> {cwd,file} rebuilt from disk so sessions survive host restarts. */
|
|
94
155
|
private sessionIndex;
|
|
95
156
|
constructor(options?: BubbleSdkOptions);
|
|
@@ -98,10 +159,21 @@ export declare class BubbleSdk {
|
|
|
98
159
|
cwd?: string;
|
|
99
160
|
id?: string;
|
|
100
161
|
}): SdkSessionRef;
|
|
162
|
+
openSession(sessionId: string): SdkSessionHandle;
|
|
101
163
|
getHistory(sessionId: string): Message[];
|
|
102
|
-
deleteSession(sessionId: string): void
|
|
103
|
-
/**
|
|
104
|
-
stop(sessionId: string):
|
|
164
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
165
|
+
/** Interrupt the active turn. Queued turns survive unless cancelQueued is true. */
|
|
166
|
+
stop(sessionId: string, options?: SdkStopOptions): number;
|
|
167
|
+
/** Cancel queued turns without interrupting the turn that owns the session slot. */
|
|
168
|
+
clearQueue(sessionId: string): number;
|
|
169
|
+
getSessionRunState(sessionId: string): SdkSessionRunState;
|
|
170
|
+
/**
|
|
171
|
+
* Add text to the turn that currently owns the session slot. Every accepted
|
|
172
|
+
* input exposes an outcome promise, independent of event-stream consumption.
|
|
173
|
+
*/
|
|
174
|
+
steer(sessionId: string, content: string): SdkSteerResult;
|
|
175
|
+
enqueueTurn(sessionId: string, options: RunTurnOptions): AsyncGenerator<AgentEvent>;
|
|
176
|
+
queueTurn(sessionId: string, options: RunTurnOptions): AsyncGenerator<AgentEvent>;
|
|
105
177
|
listSkills(cwd?: string): SkillSummary[];
|
|
106
178
|
/** Configured providers + default model, for a host's model picker. */
|
|
107
179
|
getModelConfig(): {
|
|
@@ -113,7 +185,25 @@ export declare class BubbleSdk {
|
|
|
113
185
|
hasApiKey: boolean;
|
|
114
186
|
}>;
|
|
115
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* Reserve and start a session turn immediately. Execution is driven by the
|
|
190
|
+
* SDK's own pump, not by consumption of the returned iterator: the iterator
|
|
191
|
+
* is a replay subscription, so a host may drop it (or reconnect later via
|
|
192
|
+
* `openSession`) without stalling or cancelling the turn. Cancel with
|
|
193
|
+
* `stop()`, the options signal, or `deleteSession()`.
|
|
194
|
+
*/
|
|
116
195
|
runTurn(sessionId: string, options: RunTurnOptions): AsyncGenerator<AgentEvent>;
|
|
196
|
+
private startOwnedTurn;
|
|
197
|
+
private pumpTurn;
|
|
198
|
+
private runReservedTurn;
|
|
199
|
+
private runtimesForSession;
|
|
200
|
+
private settleSteerFromEvent;
|
|
201
|
+
private handleSteerEvent;
|
|
202
|
+
private rejectOutstandingSteers;
|
|
203
|
+
private queuePendingSteer;
|
|
204
|
+
private queueDetachedInput;
|
|
205
|
+
private publishSessionEvent;
|
|
206
|
+
private ownerForSession;
|
|
117
207
|
private bashAllowlistFor;
|
|
118
208
|
/**
|
|
119
209
|
* Default cross-provider subagent factory over this SDK instance's own
|
|
@@ -141,6 +231,7 @@ export declare function attachTurnCost(event: AgentEvent, providerId: string, mo
|
|
|
141
231
|
*/
|
|
142
232
|
export declare function rewriteSkillInvocationPrompt(prompt: string | ContentPart[], registry: SkillRegistry): string | ContentPart[];
|
|
143
233
|
export { Agent, AgentAbortError, type AgentOptions, type AgentRunOptions } from "../agent.js";
|
|
234
|
+
export { AgentRunInputQueue } from "../agent/input-controller.js";
|
|
144
235
|
export { SessionManager, getSessionsDir, type SessionSummary, type UserTurn, type RewindResult, } from "../session.js";
|
|
145
236
|
export { PermissionAwareApprovalController } from "../approval/controller.js";
|
|
146
237
|
export { BashAllowlist } from "../approval/session-cache.js";
|
|
@@ -164,4 +255,4 @@ export { ExternalHookController } from "../hooks/controller.js";
|
|
|
164
255
|
export { calculateUsageCost, getModelPricing, type ModelPricing, type PricingCurrency, } from "../model-pricing.js";
|
|
165
256
|
export { registry as slashCommandRegistry } from "../slash-commands/index.js";
|
|
166
257
|
export type { SlashCommandContext } from "../slash-commands/types.js";
|
|
167
|
-
export type { AgentEvent, ContentPart, Message, PermissionMode, Provider, ThinkingLevel, TokenUsage, UsageCost, ToolRegistryEntry, ToolResult, ToolUpdate, } from "../types.js";
|
|
258
|
+
export type { AgentEvent, AgentInputController, AgentRunInput, ContentPart, Message, PermissionMode, Provider, ThinkingLevel, TokenUsage, UsageCost, ToolRegistryEntry, ToolResult, ToolUpdate, } from "../types.js";
|