@blade-hq/agent-client 1.1.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.
Files changed (39) hide show
  1. package/README.md +351 -0
  2. package/dist/auth-login.d.ts +29 -0
  3. package/dist/auth.d.ts +8 -0
  4. package/dist/blade-client.d.ts +113 -0
  5. package/dist/commands/embedded.d.ts +32 -0
  6. package/dist/commands/protocol.d.ts +38 -0
  7. package/dist/commands/registry.d.ts +21 -0
  8. package/dist/index.d.ts +37 -0
  9. package/dist/index.js +4182 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/resources/auth.d.ts +34 -0
  12. package/dist/resources/headless.d.ts +33 -0
  13. package/dist/resources/sessions.d.ts +263 -0
  14. package/dist/rest.d.ts +21 -0
  15. package/dist/schemas/background.d.ts +16 -0
  16. package/dist/schemas/event.d.ts +51 -0
  17. package/dist/schemas/message-utils.d.ts +48 -0
  18. package/dist/schemas/message.d.ts +83 -0
  19. package/dist/schemas/projection.d.ts +87 -0
  20. package/dist/schemas/session.d.ts +126 -0
  21. package/dist/schemas/solution.d.ts +101 -0
  22. package/dist/schemas/task.d.ts +12 -0
  23. package/dist/session/agent-session.d.ts +179 -0
  24. package/dist/session/events.d.ts +143 -0
  25. package/dist/session/hub.d.ts +44 -0
  26. package/dist/session/state.d.ts +57 -0
  27. package/dist/shared/projection/builder.d.ts +59 -0
  28. package/dist/shared/projection/helpers.d.ts +34 -0
  29. package/dist/shared/projection/history.d.ts +12 -0
  30. package/dist/shared/projection/index.d.ts +3 -0
  31. package/dist/shared/projection/state.d.ts +22 -0
  32. package/dist/socket.d.ts +9 -0
  33. package/dist/types/index.d.ts +8 -0
  34. package/dist/types/rest.d.ts +17315 -0
  35. package/dist/types/sdk-profile.d.ts +47 -0
  36. package/dist/types/socket-events.d.ts +401 -0
  37. package/dist/version.d.ts +45 -0
  38. package/package.json +29 -0
  39. package/public-api.md +1103 -0
@@ -0,0 +1,59 @@
1
+ import type { TurnProjection } from "../../schemas/projection";
2
+ export interface RawEvent {
3
+ type: string;
4
+ payload: Record<string, unknown>;
5
+ }
6
+ export type ProjectionUpdate = {
7
+ kind: "upsert";
8
+ turn: TurnProjection;
9
+ } | {
10
+ kind: "workspace_changed";
11
+ loopId: string;
12
+ toolCallId?: string;
13
+ toolName?: string;
14
+ };
15
+ export declare class ClientProjectionBuilder {
16
+ private activeTurns;
17
+ private lastTurnIds;
18
+ private latestTurns;
19
+ private loopDescriptions;
20
+ private pendingChildPauses;
21
+ private pendingMemoryRefs;
22
+ private activeCompactions;
23
+ private seq;
24
+ private syntheticCounter;
25
+ private displayNameResolver;
26
+ constructor(displayNameResolver?: (name: string) => string);
27
+ processBatch(events: RawEvent[]): ProjectionUpdate[];
28
+ processEvent(event: RawEvent): ProjectionUpdate[] | null;
29
+ reset(): void;
30
+ seedSequence(maxSeq: number): void;
31
+ private onMemoryInject;
32
+ private onLoopTurn;
33
+ private onModeChange;
34
+ private onPlanStatusUpdate;
35
+ private onWorkspaceChanged;
36
+ private onAgentStart;
37
+ private onBgStarted;
38
+ private onBgTasksCompleted;
39
+ private onAskUserAnswer;
40
+ private onUserMessage;
41
+ private onDelta;
42
+ private onToolCallCreated;
43
+ private onResponseDone;
44
+ private onToolResultDone;
45
+ private onToolResultDelta;
46
+ private onToolUi;
47
+ private onToolBridge;
48
+ private onToolApprovalRequired;
49
+ private onChildPause;
50
+ private onChatEnd;
51
+ private onAgentEnd;
52
+ private onCompaction;
53
+ private syncPatch;
54
+ private finalize;
55
+ private shouldFinalizeAfterToolResults;
56
+ private collectLoopUpdates;
57
+ private nextSeq;
58
+ private nextTurnId;
59
+ }
@@ -0,0 +1,34 @@
1
+ import type { ContentBlock, PendingQuestionRef, ToolCallProjection, TurnProjection } from "../../schemas/projection";
2
+ import type { TurnState } from "./state";
3
+ export declare function upsertToolCall(state: TurnState, toolCallId: string, toolName: string, displayName: string, args: string): void;
4
+ export declare function applyToolResult(state: TurnState, toolCallId: string, result: unknown, status: ToolCallProjection["status"], durationMs: number | null, sourceLoop: {
5
+ loop_name: string;
6
+ description: string;
7
+ } | null): void;
8
+ export declare function appendToolResultDelta(state: TurnState, toolCallId: string, delta: string): void;
9
+ export declare function appendTextBlock(state: TurnState, blockType: ContentBlock["type"], content: unknown): void;
10
+ export declare function appendToolCallArguments(state: TurnState, toolCallId: string, delta: string): void;
11
+ export declare function buildSystemNotificationTurn(sequence: number, turnId: string, loopId: string, notificationType: string, status: string, title: string, detail: string | null, metadata: Record<string, unknown>): TurnProjection;
12
+ export declare function buildSystemNotificationBlock(notificationType: string, status: string, title: string, detail: string | null, metadata: Record<string, unknown>): ContentBlock;
13
+ export declare function buildMarkerTurn(sequence: number, turnId: string, loopId: string, blockType: ContentBlock["type"], content: unknown): TurnProjection;
14
+ export declare function buildCompactionTurn(sequence: number, compactionId: string, loopId: string, status: TurnProjection["status"], data: Record<string, unknown>): TurnProjection;
15
+ export interface ChildPauseInfo {
16
+ parentLoopName: string;
17
+ parentToolCallId: string;
18
+ childLoopName: string;
19
+ childToolCallId: string;
20
+ description: string;
21
+ }
22
+ export declare function setToolCallStatus(turn: TurnState | TurnProjection | null | undefined, toolCallId: string, status: ToolCallProjection["status"], result: unknown, pendingQuestionRef: PendingQuestionRef | null): void;
23
+ export declare function applyAskUserPauseToTurn(turn: TurnState | TurnProjection | null | undefined, pauseToolData: Record<string, unknown>, toolCallId: string, childLoopName: string, description: string, displayNameResolver: (name: string) => string): void;
24
+ export declare function applyChildPauseToParent(parentTurn: TurnState | TurnProjection | null | undefined, parentToolCallId: string, childLoopName: string, childToolCallId: string, description: string, displayNameResolver: (name: string) => string): void;
25
+ export declare function sourceLoopFor(loopId: string, loopDescriptions: Map<string, string>): {
26
+ loop_name: string;
27
+ description: string;
28
+ } | null;
29
+ export declare function normalizeChildPause(pausePayload: Record<string, unknown>): {
30
+ pauseToolData: Record<string, unknown>;
31
+ childLoopName: string;
32
+ childToolCallId: string;
33
+ description: string;
34
+ };
@@ -0,0 +1,12 @@
1
+ import type { TurnProjection } from "../../schemas/projection";
2
+ export interface RawHistoryEntry {
3
+ id?: string;
4
+ kind?: string;
5
+ loop_name?: string;
6
+ message?: Record<string, unknown>;
7
+ data?: Record<string, unknown>;
8
+ timestamp?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ /** Rebuild completed UI turns from raw persisted history entries. */
12
+ export declare function projectHistory(entries: RawHistoryEntry[]): TurnProjection[];
@@ -0,0 +1,3 @@
1
+ export { ClientProjectionBuilder, type RawEvent, type ProjectionUpdate } from "./builder";
2
+ export { type TurnState, createTurnState, snapshot, PAUSE_TOOL_NAMES } from "./state";
3
+ export { projectHistory, type RawHistoryEntry } from "./history";
@@ -0,0 +1,22 @@
1
+ import type { ContentBlock, MemoryRef, ToolCallProjection, TurnProjection } from "../../schemas/projection";
2
+ export interface TurnState {
3
+ turnId: string;
4
+ loopId: string;
5
+ role: "user" | "assistant" | "system";
6
+ model: string | null;
7
+ startedAt: number;
8
+ contextWindow: number;
9
+ blocks: ContentBlock[];
10
+ toolCalls: ToolCallProjection[];
11
+ usage: Record<string, unknown> | null;
12
+ memoryRefs: MemoryRef[] | null;
13
+ parentForkToolCallId: string | null;
14
+ }
15
+ export declare function createTurnState(turnId: string, loopId: string, opts?: {
16
+ model?: string | null;
17
+ contextWindow?: number;
18
+ memoryRefs?: MemoryRef[] | null;
19
+ }): TurnState;
20
+ export declare function snapshot(state: TurnState, sequence: number, status: TurnProjection["status"]): TurnProjection;
21
+ export declare const PAUSE_TOOL_NAMES: Set<string>;
22
+ export declare function toolStatusFromResult(result: unknown): ToolCallProjection["status"];
@@ -0,0 +1,9 @@
1
+ import { type Socket } from "socket.io-client";
2
+ import { type AuthOptions } from "./auth";
3
+ import type { ClientToServerEvents, ServerToClientEvents } from "./types/socket-events";
4
+ export type TypedSocket = Socket<ServerToClientEvents, ClientToServerEvents>;
5
+ export interface CreateSocketOptions extends AuthOptions {
6
+ baseUrl: string;
7
+ path?: string;
8
+ }
9
+ export declare function createSocket(options: CreateSocketOptions): TypedSocket;
@@ -0,0 +1,8 @@
1
+ import type { components, paths } from "./rest";
2
+ import type { ChatEndPayload, ChatSendPayload, ClientToServerEvents, ServerToClientEvents, SessionUpdatedPayload, SystemErrorPayload, SystemNotificationPayload } from "./socket-events";
3
+ export type RestPaths = paths;
4
+ export type RestComponents = components;
5
+ export type Session = paths["/api/sessions/{session_id}"]["get"]["responses"]["200"]["content"]["application/json"];
6
+ export type SessionList = paths["/api/sessions"]["get"]["responses"]["200"]["content"]["application/json"];
7
+ export type SkillList = paths["/api/skills"]["get"]["responses"]["200"]["content"]["application/json"];
8
+ export type { ChatEndPayload, ChatSendPayload, ClientToServerEvents, ServerToClientEvents, SessionUpdatedPayload, SystemErrorPayload, SystemNotificationPayload, };