@gravity-rail/cli 0.13.0 → 0.14.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.
@@ -37,6 +37,16 @@ declare const DEFAULT_PROFILE = "default";
37
37
  * Dev profiles imported from dev-realms.json are token-only (accessToken +
38
38
  * optional workspaceUuid) — no OAuth client registration.
39
39
  */
40
+ /**
41
+ * A cached org-scoped SSO session (`gr_sess_...`) obtained via browser step-up.
42
+ * Replayed as the `X-Org-Session` header so subsequent invocations skip the
43
+ * browser until the session expires (GRA-6995).
44
+ */
45
+ interface StoredOrgSession {
46
+ session: string;
47
+ /** ISO expiry; treated as a cache miss once passed. */
48
+ expiresAt?: string;
49
+ }
40
50
  interface CLICredentials {
41
51
  clientId?: string;
42
52
  clientSecret?: string;
@@ -45,6 +55,11 @@ interface CLICredentials {
45
55
  expiresAt?: string;
46
56
  /** Default workspace UUID (workspace/member profiles from dev-realms). */
47
57
  workspaceUuid?: string;
58
+ /**
59
+ * Cached org-scoped SSO sessions keyed by organization UUID. Populated by the
60
+ * org-auth step-up handler; independent of the account token's own expiry.
61
+ */
62
+ orgSessions?: Record<string, StoredOrgSession>;
48
63
  }
49
64
  interface ProfileSummary {
50
65
  name: string;
@@ -110,6 +125,18 @@ declare class CredentialsManager {
110
125
  * Pass a profile name to clear a specific account without touching others.
111
126
  */
112
127
  clear(env: string, profile?: string): void;
128
+ /**
129
+ * Read a cached org-scoped SSO session for an org, if present and unexpired.
130
+ * Independent of the account token's expiry — a valid org session is reusable
131
+ * even while the account token is being refreshed.
132
+ */
133
+ getOrgSession(env: string, profile: string | undefined, orgUuid: string): string | undefined;
134
+ /**
135
+ * Cache an org-scoped SSO session under an existing profile, keyed by org UUID.
136
+ * No-op when the profile does not exist — org sessions only attach to a
137
+ * logged-in account profile (never create a token-less profile row).
138
+ */
139
+ setOrgSession(env: string, profile: string | undefined, orgUuid: string, session: string, expiresAt?: string): void;
113
140
  getCacheDir(): string;
114
141
  /** Absolute path of the credentials file for `env` (for docs / `auth list`). */
115
142
  getCredentialsFilePath(env: string): string;
@@ -1,5 +1,5 @@
1
- import { a as CLICredentials, E as EnvironmentConfig, C as CredentialsManager, b as ConciergeAppContextPayload } from './cli-client-context-C5l8lg7h.js';
2
- export { d as CALLBACK_PATH, e as CALLBACK_PORT, D as DEFAULT_PROFILE, f as ENVIRONMENTS, P as ProfileSummary, R as REDIRECT_URI, g as getEnvironmentConfig } from './cli-client-context-C5l8lg7h.js';
1
+ import { a as CLICredentials, E as EnvironmentConfig, C as CredentialsManager, b as ConciergeAppContextPayload } from './cli-client-context-D81-ym1X.js';
2
+ export { d as CALLBACK_PATH, e as CALLBACK_PORT, D as DEFAULT_PROFILE, f as ENVIRONMENTS, P as ProfileSummary, R as REDIRECT_URI, g as getEnvironmentConfig } from './cli-client-context-D81-ym1X.js';
3
3
 
4
4
  /**
5
5
  * CLI OAuth2 authentication utilities
@@ -170,7 +170,34 @@ declare class AGUIClient {
170
170
  */
171
171
  streamRequest(request: AguiRequestBody, onEvent: (event: AGUIEvent) => void, options?: AguiStreamOptions): Promise<void>;
172
172
  private postStream;
173
+ /**
174
+ * Subscribe to the chat's persistent AG-UI event feed and surface
175
+ * server-initiated turns that arrive while we're idle between our own turns.
176
+ *
177
+ * The feed at ``/chats/{chatId}/events`` replays every AG-UI event for the
178
+ * chat across all turns (assistant events plus user-message echoes). It never
179
+ * self-terminates — it ends only on disconnect. On reconnect we send
180
+ * ``Last-Event-ID`` so the server replays the gap. The loop reconnects with
181
+ * capped exponential backoff and resolves quietly once ``signal`` aborts;
182
+ * it never throws except when required args are missing (callers gate on
183
+ * availability, so that path is a programming error).
184
+ */
185
+ subscribeToFeed(opts: {
186
+ onEvent: (event: AGUIEvent) => void;
187
+ signal: AbortSignal;
188
+ onDebug?: (msg: string) => void;
189
+ }): Promise<void>;
173
190
  }
191
+ /**
192
+ * Parse a Server-Sent Events stream body into AG-UI events.
193
+ *
194
+ * Shared by ``AGUIClient.postStream`` (per-turn POST) and ``subscribeToFeed``
195
+ * (persistent GET feed). Surfaces ``data:`` frames as parsed events, ``id:``
196
+ * frames via ``onId`` (feed reconnect uses the last id as ``Last-Event-ID``),
197
+ * and ignores SSE comment frames (``: turn-done``, keepalives). ``onId`` is
198
+ * optional — the POST path has no use for entry ids.
199
+ */
200
+ declare function parseSseStream(body: ReadableStream<Uint8Array>, onEvent: (event: AGUIEvent, eventName?: string) => void, onId?: (id: string) => void): Promise<void>;
174
201
  interface AguiStreamOptions {
175
202
  autoApprove?: boolean;
176
203
  }
@@ -200,4 +227,4 @@ declare function getTextDelta(event: AGUIEvent): string | null;
200
227
  */
201
228
  declare function getErrorMessage(event: AGUIEvent): string | null;
202
229
 
203
- export { type ChatMessage as AGUIChatMessage, AGUIClient, type AGUIClientOptions, type AGUIEvent, type AGUIEventType, type AuthResult, CLICredentials, CredentialsManager, EnvironmentConfig, type OAuthFlowOptions, type SelectFromListOptions, type SelectResult, clearScreen, formatTimestamp, generatePKCE, getErrorMessage, getTextDelta, isErrorEvent, isTextContentEvent, openBrowser, performOAuthFlow, printMessage, printTable, refreshAccessToken, selectFromList, startCallbackServer, wrapText };
230
+ export { type ChatMessage as AGUIChatMessage, AGUIClient, type AGUIClientOptions, type AGUIEvent, type AGUIEventType, type AuthResult, CLICredentials, CredentialsManager, EnvironmentConfig, type OAuthFlowOptions, type SelectFromListOptions, type SelectResult, clearScreen, formatTimestamp, generatePKCE, getErrorMessage, getTextDelta, isErrorEvent, isTextContentEvent, openBrowser, parseSseStream, performOAuthFlow, printMessage, printTable, refreshAccessToken, selectFromList, startCallbackServer, wrapText };
package/dist/cli-utils.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  isErrorEvent,
16
16
  isTextContentEvent,
17
17
  openBrowser,
18
+ parseSseStream,
18
19
  performOAuthFlow,
19
20
  printMessage,
20
21
  printTable,
@@ -22,7 +23,7 @@ import {
22
23
  selectFromList,
23
24
  startCallbackServer,
24
25
  wrapText
25
- } from "./chunk-SIV2WU2I.js";
26
+ } from "./chunk-PODEUTUQ.js";
26
27
  export {
27
28
  AGUIClient,
28
29
  CALLBACK_PATH,
@@ -40,6 +41,7 @@ export {
40
41
  isErrorEvent,
41
42
  isTextContentEvent,
42
43
  openBrowser,
44
+ parseSseStream,
43
45
  performOAuthFlow,
44
46
  printMessage,
45
47
  printTable,
@@ -2,10 +2,10 @@ import {
2
2
  AuthRequiredError,
3
3
  CLIError,
4
4
  handleError
5
- } from "./chunk-WZVMWN3S.js";
5
+ } from "./chunk-3T7A5PSF.js";
6
6
  export {
7
7
  AuthRequiredError,
8
8
  CLIError,
9
9
  handleError
10
10
  };
11
- //# sourceMappingURL=errors-YHGVIDPO.js.map
11
+ //# sourceMappingURL=errors-CFRLSAGA.js.map