@sayknow-cli/bridge-client 0.3.16 → 0.4.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.
@@ -1,156 +0,0 @@
1
- import type { BridgeClientCommand, BridgeCommandHelpers, BridgeCommandOptions } from "./commands";
2
- import type { BridgeFrame } from "./reference-consumer";
3
- export * from "./commands";
4
- export * from "./reference-consumer";
5
- export * from "./workflow-gate";
6
- import type { UnattendedDeclaration, WorkflowGate, WorkflowGateResolver } from "./workflow-gate";
7
- export type BridgeCapability = "events" | "prompt" | "permission" | "elicitation" | "ui.declarative" | "ui.editor" | "ui.terminal_input" | "host_tools" | "host_uri" | "client_bridge.read_text_file" | "client_bridge.write_text_file" | "client_bridge.create_terminal" | "workflow_gate";
8
- export type BridgeCommandScope = "prompt" | "control" | "bash" | "export" | "session" | "model" | "message:read" | "host_tools" | "host_uri" | "admin";
9
- export interface BridgeProtocolRange {
10
- min: number;
11
- max: number;
12
- }
13
- export interface BridgeHandshakeRequest {
14
- protocol_version_range: BridgeProtocolRange;
15
- capabilities: BridgeCapability[];
16
- requested_scopes: BridgeCommandScope[];
17
- last_seq?: number;
18
- unattended?: UnattendedDeclaration;
19
- }
20
- export interface BridgeHandshakeAccepted {
21
- status: "accepted";
22
- protocol_version: number;
23
- session_id: string;
24
- accepted_capabilities: BridgeCapability[];
25
- accepted_scopes: BridgeCommandScope[];
26
- unsupported: BridgeCapability[];
27
- endpoints: {
28
- events: string;
29
- commands: string;
30
- uiResponses: string;
31
- claimControl: string;
32
- hostToolResults: string;
33
- disconnectControl: string;
34
- hostUriResults: string;
35
- };
36
- frame_types: string[];
37
- accepted_unattended?: UnattendedDeclaration;
38
- }
39
- export interface BridgeHandshakeRejected {
40
- status: "rejected";
41
- reason: "incompatible_version" | "unauthorized" | "invalid_request";
42
- message: string;
43
- }
44
- export type BridgeFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
45
- export type BridgeHandshakeResponse = BridgeHandshakeAccepted | BridgeHandshakeRejected;
46
- export interface BridgeClientOptions {
47
- baseUrl: string;
48
- token: string;
49
- fetch?: BridgeFetch;
50
- allowInsecureLocalhost?: boolean;
51
- }
52
- export declare class BridgeClient implements BridgeCommandHelpers {
53
- #private;
54
- constructor(options: BridgeClientOptions);
55
- handshake(request: BridgeHandshakeRequest): Promise<BridgeHandshakeResponse>;
56
- command(command: BridgeClientCommand, sessionId: string, idempotencyKey: string): Promise<unknown>;
57
- prompt(sessionId: string, message: string, options?: {
58
- id?: string;
59
- images?: unknown[];
60
- streamingBehavior?: "steer" | "followUp";
61
- idempotencyKey?: string;
62
- }): Promise<unknown>;
63
- steer(sessionId: string, message: string, options?: {
64
- id?: string;
65
- images?: unknown[];
66
- idempotencyKey?: string;
67
- }): Promise<unknown>;
68
- followUp(sessionId: string, message: string, options?: {
69
- id?: string;
70
- images?: unknown[];
71
- idempotencyKey?: string;
72
- }): Promise<unknown>;
73
- bash(sessionId: string, command: string, options?: {
74
- id?: string;
75
- idempotencyKey?: string;
76
- }): Promise<unknown>;
77
- getState(sessionId: string, options?: {
78
- id?: string;
79
- idempotencyKey?: string;
80
- }): Promise<unknown>;
81
- getMessages(sessionId: string, options?: {
82
- id?: string;
83
- idempotencyKey?: string;
84
- }): Promise<unknown>;
85
- abort(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
86
- abortAndPrompt(sessionId: string, message: string, options?: {
87
- id?: string;
88
- images?: unknown[];
89
- idempotencyKey?: string;
90
- }): Promise<unknown>;
91
- newSession(sessionId: string, options?: BridgeCommandOptions & {
92
- parentSession?: string;
93
- }): Promise<unknown>;
94
- setTodos(sessionId: string, phases: unknown[], options?: BridgeCommandOptions): Promise<unknown>;
95
- setHostTools(sessionId: string, tools: unknown[], options?: BridgeCommandOptions): Promise<unknown>;
96
- setHostUriSchemes(sessionId: string, schemes: unknown[], options?: BridgeCommandOptions): Promise<unknown>;
97
- getPendingWorkflowGates(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
98
- setModel(sessionId: string, provider: string, modelId: string, options?: BridgeCommandOptions): Promise<unknown>;
99
- cycleModel(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
100
- getAvailableModels(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
101
- setThinkingLevel(sessionId: string, level: string, options?: BridgeCommandOptions): Promise<unknown>;
102
- cycleThinkingLevel(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
103
- setSteeringMode(sessionId: string, mode: "all" | "one-at-a-time", options?: BridgeCommandOptions): Promise<unknown>;
104
- setFollowUpMode(sessionId: string, mode: "all" | "one-at-a-time", options?: BridgeCommandOptions): Promise<unknown>;
105
- setInterruptMode(sessionId: string, mode: "immediate" | "wait", options?: BridgeCommandOptions): Promise<unknown>;
106
- compact(sessionId: string, options?: BridgeCommandOptions & {
107
- customInstructions?: string;
108
- }): Promise<unknown>;
109
- setAutoCompaction(sessionId: string, enabled: boolean, options?: BridgeCommandOptions): Promise<unknown>;
110
- setAutoRetry(sessionId: string, enabled: boolean, options?: BridgeCommandOptions): Promise<unknown>;
111
- abortRetry(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
112
- abortBash(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
113
- getSessionStats(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
114
- exportHtml(sessionId: string, options?: BridgeCommandOptions & {
115
- outputPath?: string;
116
- }): Promise<unknown>;
117
- switchSession(sessionId: string, sessionPath: string, options?: BridgeCommandOptions): Promise<unknown>;
118
- branch(sessionId: string, entryId: string, options?: BridgeCommandOptions): Promise<unknown>;
119
- getBranchMessages(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
120
- getLastAssistantText(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
121
- setSessionName(sessionId: string, name: string, options?: BridgeCommandOptions): Promise<unknown>;
122
- handoff(sessionId: string, options?: BridgeCommandOptions & {
123
- customInstructions?: string;
124
- }): Promise<unknown>;
125
- getLoginProviders(sessionId: string, options?: BridgeCommandOptions): Promise<unknown>;
126
- login(sessionId: string, providerId: string, options?: BridgeCommandOptions): Promise<unknown>;
127
- createIdempotencyKey(prefix?: string): string;
128
- events(sessionId: string, lastSeq?: number): AsyncGenerator<BridgeFrame>;
129
- claimControl(sessionId: string, ownerToken?: string): Promise<unknown>;
130
- disconnectControl(sessionId: string, ownerToken: string): Promise<unknown>;
131
- respondToUiRequest(sessionId: string, correlationId: string, ownerToken: string, response: unknown, idempotencyKey?: string): Promise<unknown>;
132
- /**
133
- * Answer a `workflow_gate` by posting to the UI-response endpoint and return
134
- * the gate resolution envelope. Authorization is bearer auth plus the
135
- * `control` scope; `ownerToken` is carried for idempotency/controller
136
- * correlation, not as the gate authorization boundary.
137
- */
138
- respondGate(sessionId: string, gateId: string, ownerToken: string, answer: unknown, options?: {
139
- idempotencyKey?: string;
140
- id?: string;
141
- }): Promise<unknown>;
142
- /**
143
- * Headless policy: stream the session's frames, route every received
144
- * `workflow_gate` to the agent `resolver`, and post its answer back. Yields
145
- * each handled gate. The resolver supplies the agent's memory-backed answer.
146
- */
147
- consumeWorkflowGates(sessionId: string, ownerToken: string, resolver: WorkflowGateResolver, options?: {
148
- lastSeq?: number;
149
- }): AsyncGenerator<{
150
- gate: WorkflowGate;
151
- answer: unknown;
152
- }>;
153
- respondToHostTool(sessionId: string, correlationId: string, result: unknown): Promise<unknown>;
154
- respondToHostUri(sessionId: string, correlationId: string, result: unknown): Promise<unknown>;
155
- connectEvents(sessionId: string, lastSeq?: number): Promise<Response>;
156
- }
@@ -1,20 +0,0 @@
1
- export interface BridgeFrame<TPayload = unknown> {
2
- protocol_version: number;
3
- session_id: string;
4
- seq: number;
5
- frame_id: string;
6
- correlation_id?: string;
7
- type: string;
8
- payload: TPayload;
9
- }
10
- export interface RenderedBridgeFrame {
11
- seq: number;
12
- type: string;
13
- html: string;
14
- }
15
- export declare function renderBridgeFrame(frame: BridgeFrame): RenderedBridgeFrame;
16
- export declare class ReferenceBridgeConsumer {
17
- #private;
18
- consume(frame: BridgeFrame): RenderedBridgeFrame;
19
- renderDocument(): string;
20
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Typed `workflow_gate` client helpers (#322).
3
- *
4
- * Mirrors the server-side workflow-gate contract for bridge consumers: a typed
5
- * gate frame, the response shape, a frame type-guard, and a headless policy that
6
- * routes received gates to an agent callback and posts answers back through the
7
- * existing owner-token ui-response flow.
8
- */
9
- import type { BridgeFrame } from "./reference-consumer";
10
- export type WorkflowGateStage = "deep-interview" | "ralplan" | "ultragoal";
11
- export type WorkflowGateKind = "question" | "approval" | "execution";
12
- export interface WorkflowGateOption {
13
- value: unknown;
14
- label: string;
15
- description?: string;
16
- }
17
- export interface WorkflowGate {
18
- type: "workflow_gate";
19
- gate_id: string;
20
- stage: WorkflowGateStage;
21
- kind: WorkflowGateKind;
22
- schema: unknown;
23
- schema_hash: string;
24
- options?: WorkflowGateOption[];
25
- context: Record<string, unknown>;
26
- created_at: string;
27
- required: true;
28
- }
29
- export interface WorkflowGateResponse {
30
- gate_id: string;
31
- answer: unknown;
32
- idempotency_key?: string;
33
- }
34
- /** Unattended declaration carried on the bridge handshake (#318/#319). */
35
- export interface UnattendedDeclaration {
36
- actor: string;
37
- budget: {
38
- max_tokens: number;
39
- max_tool_calls: number;
40
- max_wall_time_ms: number;
41
- max_cost_usd: number;
42
- };
43
- scopes: string[];
44
- action_allowlist: string[];
45
- }
46
- /** Type guard: is this bridge frame a fully-formed workflow_gate frame? */
47
- export declare function isWorkflowGateFrame(frame: BridgeFrame): frame is BridgeFrame<WorkflowGate>;
48
- /** A callback that produces an answer for a received gate (the agent's "memory"). */
49
- export type WorkflowGateResolver = (gate: WorkflowGate) => unknown | Promise<unknown>;