@calliopelabs/cli 3.3.0 → 3.4.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.
- package/dist/attach.d.ts +85 -16
- package/dist/attach.d.ts.map +1 -1
- package/dist/attach.js +378 -113
- package/dist/attach.js.map +1 -1
- package/dist/bin.d.ts +1 -0
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +4 -2
- package/dist/bin.js.map +1 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +26 -36
- package/dist/policy.js.map +1 -1
- package/dist/runtime/permissions.d.ts +2 -0
- package/dist/runtime/permissions.d.ts.map +1 -1
- package/dist/runtime/permissions.js +33 -0
- package/dist/runtime/permissions.js.map +1 -1
- package/dist/runtime/turn.js +39 -14
- package/dist/runtime/turn.js.map +1 -1
- package/dist/sandbox/docker.d.ts.map +1 -1
- package/dist/sandbox/docker.js +7 -2
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/ui/error-boundary.js +1 -1
- package/dist/ui/error-boundary.js.map +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -1
- package/package.json +5 -1
package/dist/attach.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* `calliope attach` connects to a running agent host over the Agent Host
|
|
5
5
|
* Protocol (JSON-RPC over WebSocket) and follows a session another surface
|
|
6
6
|
* started (the IDE, desktop, AGTerm, Chat Studio), answering its tool-call
|
|
7
|
-
* confirmations from the terminal
|
|
7
|
+
* confirmations from the terminal, including any already waiting when it joins
|
|
8
|
+
* and those inside a subagent, which the session's `inputNeeded` lists (#394).
|
|
8
9
|
*
|
|
9
10
|
* calliope attach --url <ws-url> list the host's sessions
|
|
10
11
|
* calliope attach --url <ws-url> <session-uri> follow one, approve its tool calls
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
*/
|
|
22
23
|
/** Protocol versions offered in `initialize`; keep in step with calliope-vscode scripts/ahp-supported-versions.json. */
|
|
23
24
|
export declare const SUPPORTED_VERSIONS: string[];
|
|
25
|
+
export declare const ATTACH_TIMEOUT_MS = 60000;
|
|
24
26
|
export type FallbackReason = 'disabled' | 'unentitled' | 'auth' | 'version' | 'unreachable';
|
|
25
27
|
export declare const FALLBACK_EXIT = 3;
|
|
26
28
|
type Fail = {
|
|
@@ -32,10 +34,13 @@ export declare function isDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
|
32
34
|
/** A session's default chat channel: `ahp-chat://default/<base64url(session)>`. */
|
|
33
35
|
export declare function defaultChatUri(session: string): string;
|
|
34
36
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
+
* Classify authentication refusals before upgrading the transport. An authorized
|
|
38
|
+
* agent-host route answers a plain GET with 426 Upgrade Required.
|
|
37
39
|
*/
|
|
38
|
-
export declare function preflight(wsUrl: string, headers: Record<string, string>, fetchImpl?: typeof fetch
|
|
40
|
+
export declare function preflight(wsUrl: string, headers: Record<string, string>, fetchImpl?: typeof fetch, options?: {
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<Fail | undefined>;
|
|
39
44
|
/** Find (or start) the user's agent host on a JupyterHub; returns its WebSocket URL. */
|
|
40
45
|
export declare function resolveHubHost(opts: {
|
|
41
46
|
hubUrl: string;
|
|
@@ -58,19 +63,27 @@ interface Message {
|
|
|
58
63
|
message: string;
|
|
59
64
|
};
|
|
60
65
|
}
|
|
66
|
+
interface AttachSocket {
|
|
67
|
+
send(data: string): void;
|
|
68
|
+
close(): void;
|
|
69
|
+
terminate?(): void;
|
|
70
|
+
addEventListener(type: string, fn: (ev: any) => void): void;
|
|
71
|
+
}
|
|
61
72
|
/** The minimal JSON-RPC client attach needs, over any WebSocket-shaped object. */
|
|
62
73
|
export declare class AhpConnection {
|
|
63
74
|
private readonly ws;
|
|
64
75
|
private nextId;
|
|
65
76
|
private readonly pending;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
private failure?;
|
|
78
|
+
private onClosed?;
|
|
79
|
+
readonly actions: Array<(action: any, channel: string, serverSeq?: number) => void>;
|
|
80
|
+
set closed(callback: ((detail: string) => void) | undefined);
|
|
81
|
+
constructor(ws: AttachSocket);
|
|
82
|
+
private stop;
|
|
83
|
+
call(method: string, params: Record<string, unknown>, options?: {
|
|
84
|
+
timeoutMs?: number;
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
}): Promise<Message>;
|
|
74
87
|
dispatch(channel: string, clientSeq: number, action: Record<string, unknown>): void;
|
|
75
88
|
close(): void;
|
|
76
89
|
}
|
|
@@ -78,18 +91,74 @@ export declare class AhpConnection {
|
|
|
78
91
|
export declare function checkInitialize(msg: Message, supported?: string[]): Fail | undefined;
|
|
79
92
|
export interface FollowIo {
|
|
80
93
|
write: (s: string) => void;
|
|
81
|
-
/**
|
|
82
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Ask the user; resolves true to approve. Absent means read-only. `signal`
|
|
96
|
+
* aborts when the answer is no longer needed (answered elsewhere, turn over,
|
|
97
|
+
* connection closed); the prompt should then close and resolve false.
|
|
98
|
+
*/
|
|
99
|
+
approve?: (title: string, input: string, signal: AbortSignal) => Promise<boolean>;
|
|
83
100
|
/** Resolve after the next turn instead of following until the connection closes. */
|
|
84
101
|
once?: boolean;
|
|
85
102
|
}
|
|
103
|
+
/** A tool call as a chat snapshot or a session `inputNeeded` entry carries it. */
|
|
104
|
+
interface ToolCallState {
|
|
105
|
+
toolCallId: string;
|
|
106
|
+
status: string;
|
|
107
|
+
confirmationTitle?: unknown;
|
|
108
|
+
invocationMessage?: unknown;
|
|
109
|
+
toolInput?: unknown;
|
|
110
|
+
}
|
|
111
|
+
/** The part of a chat channel's `subscribe` snapshot (`result.snapshot`) that attach reads. */
|
|
112
|
+
export interface ChatSnapshot {
|
|
113
|
+
/** The snapshot's server sequence; later actions carry `serverSeq > fromSeq`. */
|
|
114
|
+
fromSeq?: number;
|
|
115
|
+
state?: {
|
|
116
|
+
activeTurn?: {
|
|
117
|
+
id: string;
|
|
118
|
+
responseParts?: Array<{
|
|
119
|
+
kind: string;
|
|
120
|
+
toolCall?: ToolCallState;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* One entry of a session's `inputNeeded`: input the session waits on in one of
|
|
127
|
+
* its chats, a subagent's included. A `toolConfirmation` is answered on `chat`,
|
|
128
|
+
* with `turnId`, without subscribing to that chat.
|
|
129
|
+
*/
|
|
130
|
+
export interface SessionInputRequest {
|
|
131
|
+
id: string;
|
|
132
|
+
kind: string;
|
|
133
|
+
chat: string;
|
|
134
|
+
turnId?: string;
|
|
135
|
+
toolCall?: ToolCallState;
|
|
136
|
+
}
|
|
137
|
+
/** The part of the session channel's `subscribe` snapshot that attach reads. */
|
|
138
|
+
export interface SessionSnapshot {
|
|
139
|
+
fromSeq?: number;
|
|
140
|
+
state?: {
|
|
141
|
+
inputNeeded?: SessionInputRequest[];
|
|
142
|
+
};
|
|
143
|
+
}
|
|
86
144
|
/**
|
|
87
145
|
* Render a session's chat actions and answer tool confirmations. Resolves when
|
|
88
146
|
* the connection closes, or after the next turn with `once`.
|
|
147
|
+
*
|
|
148
|
+
* `subscribed` is the chat channel's `subscribe` snapshot for a client joining
|
|
149
|
+
* a session already under way: the confirmations it shows waiting are asked
|
|
150
|
+
* first. `sessionSubscribed` is the session channel's: its `inputNeeded` lists
|
|
151
|
+
* the confirmations waiting in the session's other chats (a subagent's), which
|
|
152
|
+
* are answered on their own chat. Each channel's actions that arrive before its
|
|
153
|
+
* snapshot are held, then applied after it, skipping any the snapshot already
|
|
154
|
+
* includes.
|
|
89
155
|
*/
|
|
90
|
-
export declare function follow(conn: AhpConnection, session: string, io: FollowIo): {
|
|
156
|
+
export declare function follow(conn: AhpConnection, session: string, io: FollowIo, subscribed?: Promise<ChatSnapshot | undefined>, sessionSubscribed?: Promise<SessionSnapshot | undefined>): {
|
|
91
157
|
done: Promise<string>;
|
|
92
158
|
};
|
|
93
|
-
export declare function runAttach(args: string[], env?: NodeJS.ProcessEnv
|
|
159
|
+
export declare function runAttach(args: string[], env?: NodeJS.ProcessEnv, options?: {
|
|
160
|
+
timeoutMs?: number;
|
|
161
|
+
createSocket?: (url: string, headers: Record<string, string>) => AttachSocket;
|
|
162
|
+
}): Promise<number>;
|
|
94
163
|
export {};
|
|
95
164
|
//# sourceMappingURL=attach.d.ts.map
|
package/dist/attach.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../src/attach.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../src/attach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,wHAAwH;AACxH,eAAO,MAAM,kBAAkB,UAA8B,CAAC;AAC9D,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,aAAa,CAAC;AAC5F,eAAO,MAAM,aAAa,IAAI,CAAC;AAI/B,KAAK,IAAI,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAGlE,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAExE;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA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