gloomberb 0.20.3 → 0.20.4
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/package.json +1 -1
- package/src/account/auth-dialog.tsx +17 -0
- package/src/api-client/data.ts +6 -0
- package/src/api-client/fx-interventions.ts +64 -0
- package/src/api-client/index.ts +1 -0
- package/src/api-client/release-summaries.ts +21 -0
- package/src/app/keybindings/actions.ts +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +245 -66
- package/src/cli/commands/market.ts +77 -1
- package/src/cli/commands/news-search.ts +1 -3
- package/src/cli/commands/plugins.ts +27 -5
- package/src/cli/commands/system.ts +19 -3
- package/src/cli/commands/ticker.ts +60 -19
- package/src/cli/index.ts +8 -8
- package/src/cli/pane-functions/function-help.ts +3 -3
- package/src/cli/report-tables.ts +18 -6
- package/src/cli/result.ts +15 -7
- package/src/cli/types.ts +2 -0
- package/src/components/chart/composite/axis-overlays.tsx +22 -0
- package/src/components/chart/composite/composite-chart.tsx +54 -13
- package/src/components/chart/composite/event-captions.ts +109 -0
- package/src/components/chart/composite/event-guides.ts +74 -0
- package/src/components/chart/composite/rasterizer.ts +2 -0
- package/src/components/chart/composite/text-renderer.ts +2 -0
- package/src/components/chart/composite/types.ts +31 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +5 -5
- package/src/components/command-bar/routes/root/provider-search.ts +5 -4
- package/src/components/command-bar/routes/ticker-search/results.ts +51 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +3 -2
- package/src/components/layout/detached-pane-shell.tsx +1 -1
- package/src/components/layout/floating-pane.tsx +5 -1
- package/src/components/layout/pane/footer/index.tsx +21 -14
- package/src/components/layout/pane/footer/model.ts +6 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +10 -5
- package/src/components/layout/shell/active-drag.ts +149 -105
- package/src/components/layout/shell/drag/drop-zones.ts +162 -0
- package/src/components/layout/shell/drag/index.ts +47 -218
- package/src/components/layout/shell/drag/live.ts +10 -3
- package/src/components/layout/shell/drag/overlays.tsx +182 -5
- package/src/components/layout/shell/drag/runtime.ts +29 -6
- package/src/components/layout/shell/drag/shared-edges.ts +156 -0
- package/src/components/layout/shell/index.tsx +11 -6
- package/src/components/layout/shell/menu.ts +11 -2
- package/src/components/layout/shell/native/pointer-runtime.ts +25 -0
- package/src/components/layout/shell/native/window-state.ts +2 -2
- package/src/components/layout/shell/pane/layers.tsx +71 -7
- package/src/components/layout/shell/terminal-pointer-runtime.ts +18 -9
- package/src/components/layout/shell/window-mode/index.ts +8 -10
- package/src/components/layout/window-edit/mode.ts +39 -7
- package/src/components/layout/window-edit/presentation.ts +1 -1
- package/src/components/onboarding/onboarding-keyboard.ts +4 -0
- package/src/components/onboarding/onboarding-wizard.tsx +8 -3
- package/src/components/ui/button.tsx +2 -0
- package/src/components/ui/choice-dialog.tsx +1 -0
- package/src/components/ui/data-table/index.tsx +4 -3
- package/src/components/ui/list-view.tsx +7 -12
- package/src/components/ui/loading.tsx +10 -3
- package/src/components/ui/menu.tsx +6 -2
- package/src/components/ui/quote.ts +14 -1
- package/src/data/config/layout.ts +5 -2
- package/src/docs/snapshot.json +29 -5
- package/src/i18n/es.ts +9 -8
- package/src/i18n/ja.ts +9 -8
- package/src/i18n/ko.ts +9 -8
- package/src/i18n/zh-cn.ts +9 -8
- package/src/i18n/zh-tw.ts +9 -8
- package/src/layout/pane-manager/floating-actions.ts +17 -0
- package/src/layout/pane-manager/floating-stack.ts +187 -0
- package/src/layout/pane-manager/floating.ts +4 -2
- package/src/layout/pane-manager/gridlock.ts +5 -1
- package/src/layout/pane-manager/index.ts +11 -0
- package/src/layout/pane-manager/layout-state.ts +10 -3
- package/src/market-data/futures-board.ts +46 -1
- package/src/market-data/futures-contract.ts +12 -3
- package/src/market-data/fx-interventions.ts +270 -0
- package/src/news/news-model.ts +44 -2
- package/src/plugins/builtin/alerts/cli.ts +4 -4
- package/src/plugins/builtin/alerts/format.ts +1 -2
- package/src/plugins/builtin/alerts/headless.ts +1 -2
- package/src/plugins/builtin/alerts/move-checks.ts +12 -6
- package/src/plugins/builtin/alerts/move.ts +30 -9
- package/src/plugins/builtin/alerts/pane.tsx +0 -2
- package/src/plugins/builtin/alerts/storage.ts +4 -2
- package/src/plugins/builtin/alerts/types.ts +12 -0
- package/src/plugins/builtin/changelog/index.tsx +292 -101
- package/src/plugins/builtin/changelog/versions.ts +293 -0
- package/src/plugins/builtin/chart-composer/intervention-events.ts +105 -0
- package/src/plugins/builtin/chart-composer/pane.tsx +21 -7
- package/src/plugins/builtin/chat/message/render-state.ts +2 -5
- package/src/plugins/builtin/cloud/askg/attached-pane.tsx +10 -5
- package/src/plugins/builtin/cloud/askg/controller.ts +141 -5
- package/src/plugins/builtin/cloud/askg/executor.ts +113 -4
- package/src/plugins/builtin/cloud/askg/manifest.ts +28 -13
- package/src/plugins/builtin/cloud/askg/model.ts +14 -4
- package/src/plugins/builtin/cloud/askg/pane.tsx +70 -46
- package/src/plugins/builtin/cloud/askg/turn-parts.tsx +70 -0
- package/src/plugins/builtin/cloud/terminal-relay/engine.ts +50 -130
- package/src/plugins/builtin/cloud/terminal-relay/policy.ts +327 -7
- package/src/plugins/builtin/cloud/terminal-relay/prompts.tsx +2 -1
- package/src/plugins/builtin/cloud/terminal-relay/redact.ts +47 -6
- package/src/plugins/builtin/commodities-energy/index.tsx +1 -3
- package/src/plugins/builtin/commodities-energy/view-state.ts +3 -0
- package/src/plugins/builtin/cot/headless.ts +14 -2
- package/src/plugins/builtin/earnings/index.tsx +2 -2
- package/src/plugins/builtin/futures/index.tsx +25 -4
- package/src/plugins/builtin/futures/model.ts +28 -32
- package/src/plugins/builtin/futures/series.ts +4 -3
- package/src/plugins/builtin/futures/table.tsx +16 -9
- package/src/plugins/builtin/futures/use-board-terms.ts +3 -3
- package/src/plugins/builtin/help/index.tsx +3 -3
- package/src/plugins/builtin/help/keybindings-editor.tsx +18 -4
- package/src/plugins/builtin/layout-manager/index.tsx +8 -8
- package/src/plugins/builtin/news/headless.ts +2 -2
- package/src/plugins/builtin/news/index.tsx +3 -3
- package/src/plugins/builtin/perps/markets-section.tsx +5 -2
- package/src/plugins/builtin/plugin-marketplace/pane.tsx +11 -11
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +3 -1
- package/src/plugins/builtin/research/event-model.ts +9 -1
- package/src/plugins/builtin/research/event-sources.ts +22 -0
- package/src/plugins/builtin/research/headless.ts +3 -3
- package/src/plugins/builtin/shared/cloud-upgrade.ts +27 -3
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +54 -5
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +28 -13
- package/src/plugins/builtin/ticker-detail/pane.tsx +7 -2
- package/src/plugins/installer.ts +45 -0
- package/src/remote/resources.ts +12 -1
- package/src/remote/schema.ts +1 -0
- package/src/remote/semantic-helpers.ts +29 -1
- package/src/remote/semantic-tree.tsx +32 -15
- package/src/renderers/cloudflare/worker.ts +16 -1
- package/src/renderers/dom/styles.css +40 -6
- package/src/renderers/share/layout-view.tsx +1 -1
- package/src/sources/gloomberb-cloud/news.ts +35 -12
- package/src/state/opening-ticker-panes.ts +47 -0
- package/src/test-support/cli-context.ts +2 -0
- package/src/test-support/preload.ts +4 -1
- package/src/tickers/instrument-kind.ts +23 -3
- package/src/types/config.ts +5 -0
- package/src/types/context-menu.ts +2 -0
- package/src/types/plugin-commands.ts +140 -0
- package/src/types/plugin-context.ts +125 -0
- package/src/types/plugin-contributions.ts +55 -0
- package/src/types/plugin-definition.ts +234 -0
- package/src/types/plugin-notifications.ts +38 -0
- package/src/types/plugin-pane-settings.ts +114 -0
- package/src/types/plugin-pane-templates.ts +160 -0
- package/src/types/plugin-panes.ts +221 -0
- package/src/types/plugin-reports.ts +35 -0
- package/src/types/plugin-shared.ts +14 -0
- package/src/types/plugin-state.ts +71 -0
- package/src/types/plugin.ts +14 -1169
- package/src/ui/index.tsx +14 -3
- package/src/updater/github-releases.ts +23 -0
- package/src/utils/cli-output.ts +22 -9
|
@@ -4,7 +4,13 @@ import {
|
|
|
4
4
|
type ASKGToolResultOutcome,
|
|
5
5
|
type ASKGTransport,
|
|
6
6
|
} from "../../../../api-client/askg";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
CONFIRMATION_WAITING_NOTE,
|
|
9
|
+
toolCallRemainingMs,
|
|
10
|
+
type ASKGToolExecutor,
|
|
11
|
+
type ASKGToolGate,
|
|
12
|
+
type ASKGToolPreview,
|
|
13
|
+
} from "./executor";
|
|
8
14
|
import {
|
|
9
15
|
activeTurn,
|
|
10
16
|
askgReducer,
|
|
@@ -167,6 +173,15 @@ export class ASKGSessionController {
|
|
|
167
173
|
private sessionRequest: Promise<ASKGSessionStartResponse> | null = null;
|
|
168
174
|
private manifest: ASKGControllerManifest | null = null;
|
|
169
175
|
private readonly confirmations = new Map<string, (answer: ConfirmationAnswer) => void>();
|
|
176
|
+
/**
|
|
177
|
+
* Calls that change the app, or ask first, take turns here (enterLane): each
|
|
178
|
+
* decides whether to ask, asks and runs before the next one starts, so at
|
|
179
|
+
* most one question is ever open and nothing it would press changes under
|
|
180
|
+
* it. Reads run at once.
|
|
181
|
+
*/
|
|
182
|
+
private laneTail: Promise<void> = Promise.resolve();
|
|
183
|
+
/** Calls waiting for their turn, by tool call id; a question that opens refuses them. */
|
|
184
|
+
private readonly queued = new Map<string, () => void>();
|
|
170
185
|
private readonly toolTasks = new Set<Promise<void>>();
|
|
171
186
|
private turnAbort: AbortController | null = null;
|
|
172
187
|
/** Ratings of one answer go out in the order they were made. */
|
|
@@ -409,11 +424,66 @@ export class ASKGSessionController {
|
|
|
409
424
|
return;
|
|
410
425
|
}
|
|
411
426
|
|
|
427
|
+
const refuse = (): Promise<void> => this.deliver({
|
|
428
|
+
turnId: call.turnId,
|
|
429
|
+
toolCallId: call.toolCallId,
|
|
430
|
+
status: "denied",
|
|
431
|
+
truncated: false,
|
|
432
|
+
elapsedMs: Math.max(0, this.now() - startedAt),
|
|
433
|
+
note: CONFIRMATION_WAITING_NOTE,
|
|
434
|
+
});
|
|
435
|
+
// Decided before anything is awaited, so two calls that arrive together
|
|
436
|
+
// take turns in the order they came.
|
|
437
|
+
const exclusive = this.takesTurns(call);
|
|
438
|
+
if (exclusive && this.confirmations.size > 0) {
|
|
439
|
+
await refuse();
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
const turn = exclusive ? this.enterLane(call.toolCallId) : null;
|
|
443
|
+
|
|
412
444
|
try {
|
|
445
|
+
if (turn && !(await turn.ready)) {
|
|
446
|
+
await refuse();
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
|
|
450
|
+
// Its turn came after the server stopped waiting for it.
|
|
451
|
+
if (turn && toolCallRemainingMs(call, this.now()) <= 0) {
|
|
452
|
+
await this.deliver({
|
|
453
|
+
turnId: call.turnId,
|
|
454
|
+
toolCallId: call.toolCallId,
|
|
455
|
+
status: "timeout",
|
|
456
|
+
truncated: false,
|
|
457
|
+
elapsedMs: Math.max(0, this.now() - startedAt),
|
|
458
|
+
note: "Tool call timed out.",
|
|
459
|
+
});
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
// A call that acts on what is on screen goes by the policy shared with
|
|
463
|
+
// the terminal relay: a press asks, a scroll does not, and nothing acts
|
|
464
|
+
// on a confirmation or while one waits.
|
|
465
|
+
const gate = await this.gateCall(call, signal);
|
|
466
|
+
if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
|
|
467
|
+
if (gate?.kind === "refusal") {
|
|
468
|
+
await this.deliver({
|
|
469
|
+
turnId: call.turnId,
|
|
470
|
+
toolCallId: call.toolCallId,
|
|
471
|
+
status: "denied",
|
|
472
|
+
truncated: false,
|
|
473
|
+
elapsedMs: Math.max(0, this.now() - startedAt),
|
|
474
|
+
note: gate.message,
|
|
475
|
+
});
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
// This app's own manifest says which tools ask first, whatever the frame says.
|
|
479
|
+
const asks = requiresLocalConfirmation(call)
|
|
480
|
+
|| this.manifest?.tools.find((tool) => tool.name === call.name)?.confirm === "always"
|
|
481
|
+
|| gate?.kind === "ask";
|
|
413
482
|
let confirmed = false;
|
|
414
483
|
let confirmedChange: string | undefined;
|
|
415
|
-
if (
|
|
416
|
-
|
|
484
|
+
if (asks) {
|
|
485
|
+
// A UI action is described by the control it presses; there is no dry run for it.
|
|
486
|
+
const preview = gate?.kind === "ask" ? null : await this.previewCall(call, signal);
|
|
417
487
|
// The turn ended or moved on while the app looked.
|
|
418
488
|
if (signal?.aborted || this.toolRowStatus(call.toolCallId) !== "pending") return;
|
|
419
489
|
if (preview?.kind === "refusal") {
|
|
@@ -425,10 +495,14 @@ export class ASKGSessionController {
|
|
|
425
495
|
if (preview?.kind === "no-change") {
|
|
426
496
|
confirmed = true;
|
|
427
497
|
} else {
|
|
498
|
+
// One question at a time: every call still waiting for its turn is refused.
|
|
499
|
+
this.refuseQueued();
|
|
428
500
|
this.dispatch({
|
|
429
501
|
type: "tool-awaiting-confirmation",
|
|
430
502
|
toolCallId: call.toolCallId,
|
|
431
|
-
...(
|
|
503
|
+
...(gate?.kind === "ask"
|
|
504
|
+
? { title: gate.title, ...(gate.lines.length > 0 ? { preview: gate.lines.join("\n") } : {}) }
|
|
505
|
+
: preview?.kind === "change" ? { preview: preview.summary } : {}),
|
|
432
506
|
});
|
|
433
507
|
const answer = await this.awaitConfirmation(
|
|
434
508
|
call.toolCallId,
|
|
@@ -470,8 +544,10 @@ export class ASKGSessionController {
|
|
|
470
544
|
return;
|
|
471
545
|
}
|
|
472
546
|
const payload = await executor.execute(call, {
|
|
473
|
-
confirmed: confirmed || !
|
|
547
|
+
confirmed: confirmed || !asks,
|
|
474
548
|
...(confirmedChange ? { confirmedChange } : {}),
|
|
549
|
+
...(gate ? { gate } : {}),
|
|
550
|
+
promptOpen: () => this.confirmationOpen(call.toolCallId),
|
|
475
551
|
...(signal ? { signal } : {}),
|
|
476
552
|
});
|
|
477
553
|
await this.deliver(payload);
|
|
@@ -481,7 +557,67 @@ export class ASKGSessionController {
|
|
|
481
557
|
));
|
|
482
558
|
} finally {
|
|
483
559
|
this.confirmations.delete(call.toolCallId);
|
|
560
|
+
turn?.leave();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Whether a call takes turns with the others: anything but a read this
|
|
566
|
+
* app's manifest knows, and anything that asks first. A tool the manifest
|
|
567
|
+
* does not know waits its turn too; the executor refuses it anyway.
|
|
568
|
+
*/
|
|
569
|
+
private takesTurns(call: ASKGToolCallEvent): boolean {
|
|
570
|
+
const tool = this.manifest?.tools.find((entry) => entry.name === call.name);
|
|
571
|
+
return !tool
|
|
572
|
+
|| tool.writeTier !== "read"
|
|
573
|
+
|| call.writeTier !== "read"
|
|
574
|
+
|| tool.confirm === "always"
|
|
575
|
+
|| requiresLocalConfirmation(call);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** Queues a call behind the ones before it; `ready` is false when a question opened while it waited. */
|
|
579
|
+
private enterLane(toolCallId: string): { ready: Promise<boolean>; leave: () => void } {
|
|
580
|
+
const ahead = this.laneTail;
|
|
581
|
+
let leave!: () => void;
|
|
582
|
+
const left = new Promise<void>((resolve) => {
|
|
583
|
+
leave = resolve;
|
|
584
|
+
});
|
|
585
|
+
this.laneTail = ahead.then(() => left);
|
|
586
|
+
const ready = new Promise<boolean>((resolve) => {
|
|
587
|
+
this.queued.set(toolCallId, () => resolve(false));
|
|
588
|
+
void ahead.then(() => {
|
|
589
|
+
this.queued.delete(toolCallId);
|
|
590
|
+
resolve(true);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
return { ready, leave };
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
private refuseQueued(): void {
|
|
597
|
+
for (const refuse of this.queued.values()) refuse();
|
|
598
|
+
this.queued.clear();
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* The shared policy's word on a call that acts on what is on screen or a
|
|
603
|
+
* confirmed operation it describes; null for any other call. Throws when
|
|
604
|
+
* it cannot tell, and the call does not run.
|
|
605
|
+
*/
|
|
606
|
+
private async gateCall(call: ASKGToolCallEvent, signal?: AbortSignal): Promise<ASKGToolGate | null> {
|
|
607
|
+
const manifest = this.manifest ?? await this.options.loadManifest();
|
|
608
|
+
this.manifest = manifest;
|
|
609
|
+
return await this.options.getExecutor(manifest)?.gate(call, {
|
|
610
|
+
promptOpen: this.confirmationOpen(call.toolCallId),
|
|
611
|
+
...(signal ? { signal } : {}),
|
|
612
|
+
}) ?? null;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** A confirmation other than this call's waits for the person. */
|
|
616
|
+
private confirmationOpen(toolCallId: string): boolean {
|
|
617
|
+
for (const pending of this.confirmations.keys()) {
|
|
618
|
+
if (pending !== toolCallId) return true;
|
|
484
619
|
}
|
|
620
|
+
return false;
|
|
485
621
|
}
|
|
486
622
|
|
|
487
623
|
/**
|
|
@@ -22,6 +22,12 @@ import {
|
|
|
22
22
|
type ToolResultStatus,
|
|
23
23
|
} from "./protocol";
|
|
24
24
|
import { normalizeJson } from "./json";
|
|
25
|
+
import {
|
|
26
|
+
redactRelayResult,
|
|
27
|
+
redactResource,
|
|
28
|
+
storedCredentials,
|
|
29
|
+
withoutStoredCredentials,
|
|
30
|
+
} from "../terminal-relay/redact";
|
|
25
31
|
import {
|
|
26
32
|
capToolNote,
|
|
27
33
|
joinToolNotes,
|
|
@@ -33,6 +39,7 @@ import {
|
|
|
33
39
|
remoteRequestForTool,
|
|
34
40
|
resolveRemoteToolBinding,
|
|
35
41
|
toolExecutionTimeoutMs,
|
|
42
|
+
type RemoteToolBinding,
|
|
36
43
|
} from "./manifest";
|
|
37
44
|
import {
|
|
38
45
|
ASKGUndoManager,
|
|
@@ -40,6 +47,7 @@ import {
|
|
|
40
47
|
type InProcessRemoteControlHandler,
|
|
41
48
|
} from "./undo";
|
|
42
49
|
import { logFailure } from "../../../../utils/log-failure";
|
|
50
|
+
import { describeConfirmedOperation, planUiCall, UiCallRefusal, type UiCallPlan } from "../terminal-relay/policy";
|
|
43
51
|
|
|
44
52
|
interface HeadlessExecution {
|
|
45
53
|
result: unknown;
|
|
@@ -68,11 +76,33 @@ export interface ASKGToolExecutorDependencies {
|
|
|
68
76
|
|
|
69
77
|
interface ASKGToolExecutionOptions {
|
|
70
78
|
signal?: AbortSignal;
|
|
79
|
+
/** The person approved this call (or a dry run found nothing to approve). */
|
|
71
80
|
confirmed?: boolean;
|
|
72
81
|
/** The confirmKey of the preview the person approved, so the app does not ask again. */
|
|
73
82
|
confirmedChange?: string;
|
|
83
|
+
/** The gate the call was asked about with, checked again right before it runs. */
|
|
84
|
+
gate?: ASKGToolGate;
|
|
85
|
+
/** One of Ask Gloom's confirmations waits for the person. */
|
|
86
|
+
promptOpen?: () => boolean;
|
|
74
87
|
}
|
|
75
88
|
|
|
89
|
+
/**
|
|
90
|
+
* What the per-operation policy shared with the terminal relay
|
|
91
|
+
* (terminal-relay/policy.ts) says about a call that acts on what is on
|
|
92
|
+
* screen (a press, a submit, a command-bar row), or about a confirmed
|
|
93
|
+
* operation it describes (a layout delete, by the layout's name).
|
|
94
|
+
*/
|
|
95
|
+
export type ASKGToolGate =
|
|
96
|
+
/** Refused before anything is asked: it aims at a confirmation, or one is open. */
|
|
97
|
+
| { kind: "refusal"; message: string }
|
|
98
|
+
/** Scroll, select, setValue, focus, a row that opens a ticker or a pane. */
|
|
99
|
+
| { kind: "silent"; recheck: UiCallPlan["recheck"] }
|
|
100
|
+
/** Asks first, naming the control and its pane, the row it opens, or the layout it deletes. */
|
|
101
|
+
| { kind: "ask"; title: string; lines: string[]; recheck: UiCallPlan["recheck"] };
|
|
102
|
+
|
|
103
|
+
/** Why a call that changes the app did not run while one of Ask Gloom's questions waited (controller.ts). */
|
|
104
|
+
export const CONFIRMATION_WAITING_NOTE = "Gloom is waiting for the person to answer a confirmation, and nothing else that changes the app runs until then. This call did not run; retry it after they answer.";
|
|
105
|
+
|
|
76
106
|
/**
|
|
77
107
|
* What a call needing approval will change, from the operation's own dry run:
|
|
78
108
|
* the list and listing it resolved rather than the arguments as sent.
|
|
@@ -95,6 +125,11 @@ export interface ASKGToolExecutor {
|
|
|
95
125
|
): Promise<ToolResultPayload>;
|
|
96
126
|
/** Null when the call has no dry run that says more than its arguments. */
|
|
97
127
|
preview?(call: ASKGToolCallEvent, signal?: AbortSignal): Promise<ASKGToolPreview | null>;
|
|
128
|
+
/**
|
|
129
|
+
* Null when the policy has nothing to add for the call. Throws when it
|
|
130
|
+
* cannot tell (the screen could not be read): the call does not run.
|
|
131
|
+
*/
|
|
132
|
+
gate(call: ASKGToolCallEvent, options: { promptOpen: boolean; signal?: AbortSignal }): Promise<ASKGToolGate | null>;
|
|
98
133
|
undo(token: string, signal?: AbortSignal): Promise<AppliedUndo>;
|
|
99
134
|
}
|
|
100
135
|
|
|
@@ -238,6 +273,15 @@ function inferRemoteRowCount(value: unknown): number | undefined {
|
|
|
238
273
|
return 1;
|
|
239
274
|
}
|
|
240
275
|
|
|
276
|
+
/**
|
|
277
|
+
* An app resource or operation result as an assistant may read it, by the
|
|
278
|
+
* same rules as the terminal relay: configuration without its credentials
|
|
279
|
+
* and broker settings, and no secret-named or typed-password value anywhere.
|
|
280
|
+
*/
|
|
281
|
+
function redactRemoteData(binding: RemoteToolBinding, args: Record<string, JsonValue>, data: unknown): unknown {
|
|
282
|
+
return redactRelayResult(binding.kind === "resource" ? redactResource(String(args.resource), data) : data);
|
|
283
|
+
}
|
|
284
|
+
|
|
241
285
|
/**
|
|
242
286
|
* How much longer the server waits for this call, by its frame: its timeout,
|
|
243
287
|
* and never past the time it expires.
|
|
@@ -342,20 +386,67 @@ export function createASKGToolExecutor(
|
|
|
342
386
|
?? defaultHeadlessExecutor(dependencies.registry, dependencies.context);
|
|
343
387
|
const undoManager = dependencies.undoManager ?? new ASKGUndoManager(dependencies.remoteHandler);
|
|
344
388
|
|
|
389
|
+
const readResource = async (resource: string, signal?: AbortSignal): Promise<unknown> => {
|
|
390
|
+
const response = await runWithDeadline(
|
|
391
|
+
() => dependencies.remoteHandler({ type: "get", resource }),
|
|
392
|
+
PREVIEW_TIMEOUT_MS,
|
|
393
|
+
signal,
|
|
394
|
+
);
|
|
395
|
+
if (!response.ok) throw new Error(response.error.message);
|
|
396
|
+
return response.data;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const gate = async (
|
|
400
|
+
call: ASKGToolCallEvent,
|
|
401
|
+
{ promptOpen, signal }: { promptOpen: boolean; signal?: AbortSignal },
|
|
402
|
+
): Promise<ASKGToolGate | null> => {
|
|
403
|
+
if (manifests.get(call.name)?.source !== "remote-op") return null;
|
|
404
|
+
const binding = resolveRemoteToolBinding(call.name);
|
|
405
|
+
if (binding?.kind !== "operation") return null;
|
|
406
|
+
const read = (resource: string) => readResource(resource, signal);
|
|
407
|
+
try {
|
|
408
|
+
const plan = await planUiCall(binding.operation, call.args, { read, promptOpen });
|
|
409
|
+
if (plan) {
|
|
410
|
+
return plan.confirm
|
|
411
|
+
? {
|
|
412
|
+
kind: "ask",
|
|
413
|
+
title: plan.confirm.title,
|
|
414
|
+
lines: plan.confirm.lines.map(({ label, value }) => `${label}: ${value}`),
|
|
415
|
+
recheck: plan.recheck,
|
|
416
|
+
}
|
|
417
|
+
: { kind: "silent", recheck: plan.recheck };
|
|
418
|
+
}
|
|
419
|
+
const described = await describeConfirmedOperation(binding.operation, call.args, read);
|
|
420
|
+
if (!described) return null;
|
|
421
|
+
const recheck = described.recheck;
|
|
422
|
+
return {
|
|
423
|
+
kind: "ask",
|
|
424
|
+
title: described.confirm.title,
|
|
425
|
+
lines: described.confirm.lines.map(({ label, value }) => `${label}: ${value}`),
|
|
426
|
+
recheck: async () => (recheck ? recheck() : null),
|
|
427
|
+
};
|
|
428
|
+
} catch (error) {
|
|
429
|
+
if (error instanceof UiCallRefusal) return { kind: "refusal", message: error.message };
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
|
|
345
434
|
const execute = async (
|
|
346
435
|
call: ASKGToolCallEvent,
|
|
347
436
|
options: ASKGToolExecutionOptions = {},
|
|
348
437
|
): Promise<ToolResultPayload> => {
|
|
349
438
|
const startedAt = now();
|
|
439
|
+
// Whatever leaves the app, a pane function's rows included, without a credential the config stores.
|
|
440
|
+
const credentials = storedCredentials(dependencies.context?.config);
|
|
350
441
|
const base = (value: ExecutionValue): ToolResultPayload => withBoundedPayload({
|
|
351
442
|
turnId: call.turnId,
|
|
352
443
|
toolCallId: call.toolCallId,
|
|
353
444
|
status: value.status,
|
|
354
|
-
...(value.result !== undefined ? { result: normalizeJson(value.result) } : {}),
|
|
445
|
+
...(value.result !== undefined ? { result: withoutStoredCredentials(normalizeJson(value.result), credentials) } : {}),
|
|
355
446
|
...(value.rowCount !== undefined ? { rowCount: value.rowCount } : {}),
|
|
356
447
|
truncated: value.truncated ?? false,
|
|
357
448
|
elapsedMs: Math.max(0, now() - startedAt),
|
|
358
|
-
...(value.note ? { note: capToolNote(value.note) } : {}),
|
|
449
|
+
...(value.note ? { note: capToolNote(withoutStoredCredentials(value.note, credentials)) } : {}),
|
|
359
450
|
...(value.rev ? { rev: value.rev } : {}),
|
|
360
451
|
...(value.undoToken ? { undoToken: value.undoToken } : {}),
|
|
361
452
|
});
|
|
@@ -373,6 +464,17 @@ export function createASKGToolExecutor(
|
|
|
373
464
|
if ((manifest.confirm === "always" || call.requiresConfirmation) && !options.confirmed) {
|
|
374
465
|
return base({ status: "denied", note: "This tool call requires local confirmation." });
|
|
375
466
|
}
|
|
467
|
+
const promptOpen = () => options.promptOpen?.() ?? false;
|
|
468
|
+
let screenGate: ASKGToolGate | null;
|
|
469
|
+
try {
|
|
470
|
+
screenGate = options.gate ?? await gate(call, { promptOpen: promptOpen(), ...(options.signal ? { signal: options.signal } : {}) });
|
|
471
|
+
} catch (error) {
|
|
472
|
+
return base({ status: "error", note: toolErrorNote(error) });
|
|
473
|
+
}
|
|
474
|
+
if (screenGate?.kind === "refusal") return base({ status: "denied", note: screenGate.message });
|
|
475
|
+
if (screenGate?.kind === "ask" && !options.confirmed) {
|
|
476
|
+
return base({ status: "denied", note: "This tool call requires local confirmation." });
|
|
477
|
+
}
|
|
376
478
|
|
|
377
479
|
const timeoutMs = Math.min(toolExecutionTimeoutMs(manifest), toolCallRemainingMs(call, now()));
|
|
378
480
|
try {
|
|
@@ -403,6 +505,12 @@ export function createASKGToolExecutor(
|
|
|
403
505
|
}
|
|
404
506
|
}
|
|
405
507
|
|
|
508
|
+
// The last look before it acts: the screen may have changed while the person decided.
|
|
509
|
+
const stale = await screenGate?.recheck(promptOpen());
|
|
510
|
+
if (stale) return { status: "denied", note: stale };
|
|
511
|
+
// Nothing that changes the app runs while one of Ask Gloom's questions waits.
|
|
512
|
+
if (manifest.writeTier !== "read" && promptOpen()) return { status: "denied", note: CONFIRMATION_WAITING_NOTE };
|
|
513
|
+
|
|
406
514
|
const response = await dependencies.remoteHandler(remoteRequestForTool(binding, call.args), {
|
|
407
515
|
signal,
|
|
408
516
|
...(options.confirmed && options.confirmedChange ? { confirmed: options.confirmedChange } : {}),
|
|
@@ -410,7 +518,7 @@ export function createASKGToolExecutor(
|
|
|
410
518
|
if (!response.ok) {
|
|
411
519
|
return {
|
|
412
520
|
status: "error",
|
|
413
|
-
result: { code: response.error.code, ...(response.error.details !== undefined ? { details: response.error.details } : {}) },
|
|
521
|
+
result: redactRemoteData(binding, call.args, { code: response.error.code, ...(response.error.details !== undefined ? { details: response.error.details } : {}) }),
|
|
414
522
|
note: toolErrorNote(response.error.message),
|
|
415
523
|
};
|
|
416
524
|
}
|
|
@@ -425,7 +533,7 @@ export function createASKGToolExecutor(
|
|
|
425
533
|
}
|
|
426
534
|
return {
|
|
427
535
|
status: "ok",
|
|
428
|
-
result: response.data,
|
|
536
|
+
result: redactRemoteData(binding, call.args, response.data),
|
|
429
537
|
rowCount: inferRemoteRowCount(response.data),
|
|
430
538
|
...(undoNote ? { note: undoNote } : {}),
|
|
431
539
|
...(response.rev ? { rev: response.rev } : response.state?.rev ? { rev: response.state.rev } : {}),
|
|
@@ -471,6 +579,7 @@ export function createASKGToolExecutor(
|
|
|
471
579
|
return {
|
|
472
580
|
execute,
|
|
473
581
|
preview,
|
|
582
|
+
gate,
|
|
474
583
|
undo: (token, signal) => undoManager.undo(token, signal),
|
|
475
584
|
};
|
|
476
585
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
remoteOperationToolName,
|
|
9
9
|
} from "../../../../remote/schema";
|
|
10
10
|
import type { RemoteControlRequest } from "../../../../remote/types";
|
|
11
|
+
import { operationPolicy } from "../terminal-relay/policy";
|
|
11
12
|
import type {
|
|
12
13
|
HeadlessPaneDefinition,
|
|
13
14
|
PaneDef,
|
|
@@ -29,7 +30,8 @@ const REMOTE_TOOL_TIMEOUT_MS = 10_000;
|
|
|
29
30
|
/**
|
|
30
31
|
* A tool that asks first waits for a person to read the prompt and click, so
|
|
31
32
|
* the server holds the call this long: the minute the terminal relay gives a
|
|
32
|
-
* confirmation. A
|
|
33
|
+
* confirmation. A UI action that may ask declares it too. A server from
|
|
34
|
+
* before the window holds either 10 s.
|
|
33
35
|
*/
|
|
34
36
|
const CONFIRM_TOOL_TIMEOUT_MS = 60_000;
|
|
35
37
|
const REMOTE_RESOURCE_TOOL_NAME = "app.get_resource";
|
|
@@ -193,7 +195,7 @@ function remoteCandidates(registry: PaneFunctionCatalog): ManifestCandidate[] {
|
|
|
193
195
|
description: descriptor.description,
|
|
194
196
|
writeTier: descriptor.writeTier,
|
|
195
197
|
inputSchema: descriptor.inputSchema,
|
|
196
|
-
...remoteConfirmation(descriptor.writeTier),
|
|
198
|
+
...remoteConfirmation(operationsByName.get(descriptor.name)!.id, descriptor.writeTier),
|
|
197
199
|
},
|
|
198
200
|
}));
|
|
199
201
|
|
|
@@ -226,21 +228,34 @@ function remoteCandidates(registry: PaneFunctionCatalog): ManifestCandidate[] {
|
|
|
226
228
|
return candidates;
|
|
227
229
|
}
|
|
228
230
|
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Account and broker writes ask first, and so does every operation the
|
|
233
|
+
* per-operation policy confirms each time (terminal-relay/policy.ts); they get
|
|
234
|
+
* the minute that takes. A UI action is asked about call by call instead
|
|
235
|
+
* (executor.ts), since scrolling or selecting asks nothing, so it says
|
|
236
|
+
* `never` and still declares the minute: the server holds it that long, and
|
|
237
|
+
* a scroll answers as soon as it ran.
|
|
238
|
+
*/
|
|
239
|
+
function remoteConfirmation(
|
|
240
|
+
operation: string,
|
|
241
|
+
writeTier: ClientToolManifest["writeTier"],
|
|
242
|
+
): Pick<ClientToolManifest, "confirm" | "timeoutMs"> {
|
|
243
|
+
const { policy } = operationPolicy(operation);
|
|
244
|
+
if (writeTier === "user-data" || writeTier === "broker" || policy === "confirm") {
|
|
245
|
+
return { confirm: "always", timeoutMs: CONFIRM_TOOL_TIMEOUT_MS };
|
|
246
|
+
}
|
|
247
|
+
if (policy === "local-ui" || policy === "navigation") return { confirm: "never", timeoutMs: CONFIRM_TOOL_TIMEOUT_MS };
|
|
248
|
+
return { confirm: "never", timeoutMs: REMOTE_TOOL_TIMEOUT_MS };
|
|
234
249
|
}
|
|
235
250
|
|
|
236
251
|
/**
|
|
237
|
-
* How long a call may run once it starts. A tool that
|
|
238
|
-
* window for the person and the
|
|
239
|
-
* budget of every app action, counted from the approval rather
|
|
240
|
-
* call. The server's deadline for the call still bounds it.
|
|
252
|
+
* How long a call may run once it starts. A tool that may ask first declares
|
|
253
|
+
* the window for the person and the action together; an app action itself
|
|
254
|
+
* keeps the budget of every app action, counted from the approval rather
|
|
255
|
+
* than from the call. The server's deadline for the call still bounds it.
|
|
241
256
|
*/
|
|
242
|
-
export function toolExecutionTimeoutMs(manifest: Pick<ClientToolManifest, "confirm" | "timeoutMs">): number {
|
|
243
|
-
return manifest.confirm === "always"
|
|
257
|
+
export function toolExecutionTimeoutMs(manifest: Pick<ClientToolManifest, "confirm" | "source" | "timeoutMs">): number {
|
|
258
|
+
return manifest.confirm === "always" || manifest.source === "remote-op"
|
|
244
259
|
? Math.min(manifest.timeoutMs, REMOTE_TOOL_TIMEOUT_MS)
|
|
245
260
|
: manifest.timeoutMs;
|
|
246
261
|
}
|
|
@@ -50,6 +50,11 @@ export interface ASKGToolRow {
|
|
|
50
50
|
requiresConfirmation: boolean;
|
|
51
51
|
/** Dry run description shown before a `user-data` or `broker` call runs. */
|
|
52
52
|
preview?: JsonValue;
|
|
53
|
+
/**
|
|
54
|
+
* What the approval asks, when the call says more than its tool: the
|
|
55
|
+
* control a UI action presses, by label and role.
|
|
56
|
+
*/
|
|
57
|
+
confirmTitle?: string;
|
|
53
58
|
rowCount?: number;
|
|
54
59
|
elapsedMs?: number;
|
|
55
60
|
truncated?: boolean;
|
|
@@ -152,8 +157,11 @@ export type ASKGAction =
|
|
|
152
157
|
| { type: "feedback"; turnId: string; feedback: ASKGTurnFeedback | null }
|
|
153
158
|
| { type: "feedback-unavailable" }
|
|
154
159
|
| { type: "event"; event: ASKGSseEvent }
|
|
155
|
-
/**
|
|
156
|
-
|
|
160
|
+
/**
|
|
161
|
+
* `preview` is what the app resolved the call to, in place of the server's
|
|
162
|
+
* account of its arguments; `title` names what a UI action will press.
|
|
163
|
+
*/
|
|
164
|
+
| { type: "tool-awaiting-confirmation"; toolCallId: string; preview?: string; title?: string }
|
|
157
165
|
| { type: "tool-running"; toolCallId: string }
|
|
158
166
|
| { type: "tool-result"; payload: ToolResultPayload }
|
|
159
167
|
| { type: "tool-expanded"; toolCallId: string; expanded: boolean }
|
|
@@ -166,8 +174,9 @@ export type ASKGAction =
|
|
|
166
174
|
| { type: "reset" };
|
|
167
175
|
|
|
168
176
|
/**
|
|
169
|
-
* Tiers that never run without the user saying so. `read` is silent
|
|
170
|
-
* `ui-write`
|
|
177
|
+
* Tiers that never run without the user saying so. `read` is silent; a
|
|
178
|
+
* `ui-write` call that presses something on screen is asked about call by
|
|
179
|
+
* call (executor.ts gate), the rest of `ui-write` is reversible.
|
|
171
180
|
*/
|
|
172
181
|
export function requiresLocalConfirmation(call: {
|
|
173
182
|
writeTier: WriteTier;
|
|
@@ -483,6 +492,7 @@ export function askgReducer(
|
|
|
483
492
|
...row,
|
|
484
493
|
status: "awaiting-confirmation",
|
|
485
494
|
...(action.preview !== undefined ? { preview: action.preview } : {}),
|
|
495
|
+
...(action.title !== undefined ? { confirmTitle: action.title } : {}),
|
|
486
496
|
}));
|
|
487
497
|
case "tool-running":
|
|
488
498
|
return patchToolRow(state, action.toolCallId, (row) => ({ ...row, status: "running" }));
|