@cortexkit/opencode-openai-auth 0.11.1 → 1.0.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/README.md +15 -26
- package/dist/index-766sfrh5.js +1 -0
- package/dist/index-8kj7sa1p.js +12 -0
- package/dist/index-8rqfbhfw.js +221 -0
- package/dist/index-b3q3j39x.js +2 -0
- package/dist/index-bmd7x5aq.js +2 -0
- package/dist/index-eqh53k8v.js +2 -0
- package/dist/{index-sdt2d2ra.js → index-hy9030jh.js} +1 -1
- package/dist/index-jyr8y8k4.js +7 -0
- package/dist/index-rv08jmd4.js +2 -0
- package/dist/index.d.ts +578 -145
- package/dist/index.js +1 -110
- package/dist/pool-lifecycle-DbDmgabd.d.ts +2430 -0
- package/dist/port-file-Do3lQIEk.d.ts +29 -0
- package/dist/protocol-BOBdkqqm.d.ts +198 -0
- package/dist/rpc/port-file.d.ts +4 -17
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.d.ts +2 -2
- package/dist/rpc/protocol.js +1 -0
- package/dist/rpc/rpc-client.d.ts +5 -4
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.d.ts +2 -0
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/sidebar-state-D6cUKgkm.d.ts +385 -0
- package/dist/sidebar-state.d.ts +2 -2
- package/dist/sidebar-state.js +1 -1
- package/dist/token-util-wdza526f.js +1 -0
- package/dist/{token-9823y0pc.js → token-ypk61xj0.js} +1 -1
- package/dist/tui-preferences.js +5 -2
- package/dist/tui.d.ts +9 -4
- package/dist/v2/server.d.ts +54 -0
- package/dist/v2/server.js +4 -0
- package/package.json +21 -9
- package/src/tui/entry.mjs +26 -25
- package/src/tui-compiled/raw/logger.js +24 -0
- package/src/tui-compiled/raw/rpc/protocol.js +3 -0
- package/src/tui-compiled/raw/rpc/rpc-client.js +7 -0
- package/src/tui-compiled/raw/rpc/rpc-dir.js +27 -0
- package/src/tui-compiled/raw/selector.js +21 -0
- package/src/tui-compiled/raw/shared/0332701351b3eeec-format.js +138 -0
- package/src/tui-compiled/raw/shared/04a6357627de5ed0-errors.js +38 -0
- package/src/tui-compiled/raw/shared/053cc17b5419261e-codec.js +12 -0
- package/src/tui-compiled/raw/shared/0766d78c6f481f18-watcher.js +157 -0
- package/src/tui-compiled/raw/shared/08eef45626a94992-reserved.js +13 -0
- package/src/tui-compiled/raw/shared/39c3cb05738fcf6d-projection.js +134 -0
- package/src/tui-compiled/raw/shared/3c2d4169d00f907e-tui-support.js +5 -0
- package/src/tui-compiled/raw/shared/3e7d45a77c6ad4d5-index.js +4 -0
- package/src/tui-compiled/raw/shared/415792e85d80819e-capture-sink.js +13 -0
- package/src/tui-compiled/raw/shared/42ae93ab554fcec2-open-url.js +28 -0
- package/src/tui-compiled/raw/shared/43fc9e6b994519c7-refresh-lock.js +136 -0
- package/src/tui-compiled/raw/shared/458b934e92490331-mutate.js +500 -0
- package/src/tui-compiled/raw/shared/45bf5343bbbf9add-admission.js +142 -0
- package/src/tui-compiled/raw/shared/46f3dff1266160e8-client.js +2 -0
- package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +48 -0
- package/src/tui-compiled/raw/shared/4f36d333d081d040-merge.js +162 -0
- package/src/tui-compiled/raw/shared/54eba94fd64c8c3c-index.js +7 -0
- package/src/tui-compiled/raw/shared/7211cfec06a298bc-atomic-write.js +80 -0
- package/src/tui-compiled/raw/shared/754d6017f8e419cf-builtins.js +534 -0
- package/src/tui-compiled/raw/shared/75bd8c3bd63b315f-identity.js +79 -0
- package/src/tui-compiled/raw/shared/7a91bb630e6f4804-index.js +1 -0
- package/src/tui-compiled/raw/shared/826342a4b6a8b89b-model.js +16 -0
- package/src/tui-compiled/raw/shared/83068c0dbe8a6f13-publication.js +304 -0
- package/src/tui-compiled/raw/shared/836fc615de6afbd9-settings.js +120 -0
- package/src/tui-compiled/raw/shared/83bc3ba9d0fe2761-runtime.js +68 -0
- package/src/tui-compiled/raw/shared/8a18abe4fa2977c8-menu.js +300 -0
- package/src/tui-compiled/raw/shared/901e149c5a0dbbff-sticky.js +339 -0
- package/src/tui-compiled/raw/shared/9020c407ce64f672-ordered.js +58 -0
- package/src/tui-compiled/raw/shared/905bffc0220f43d0-map.js +105 -0
- package/src/tui-compiled/raw/shared/94820e324f2b4c09-seam.js +301 -0
- package/src/tui-compiled/raw/shared/97484d9bb98c705b-provider-state.js +226 -0
- package/src/tui-compiled/raw/shared/9968e3cade6969a1-index.js +2 -0
- package/src/tui-compiled/raw/shared/9b4da614c45f9cd0-lock-constants.js +14 -0
- package/src/tui-compiled/raw/shared/9d3fc9e37456504e-refresh.js +225 -0
- package/src/tui-compiled/raw/shared/9deae3c4da4fd63b-hooks.js +34 -0
- package/src/tui-compiled/raw/shared/a09b6a533c11858f-tui-preferences.js +77 -0
- package/src/tui-compiled/raw/shared/a62a27a204266acd-attribution.js +60 -0
- package/src/tui-compiled/raw/shared/a910277ac43a8626-pull.js +143 -0
- package/src/tui-compiled/raw/shared/b85c5301fddcb98a-paths.js +5 -0
- package/src/tui-compiled/raw/shared/c14988621dc60a75-port-file.js +217 -0
- package/src/tui-compiled/raw/shared/c64d7afbc14ca125-sidebar-file.js +157 -0
- package/src/tui-compiled/raw/shared/c6b176708c446d6d-pins.js +34 -0
- package/src/tui-compiled/raw/shared/c7d252bedee01600-pi.js +206 -0
- package/src/tui-compiled/raw/shared/c852a15cfe489d12-pool.js +120 -0
- package/src/tui-compiled/raw/shared/cc9e0702a752cea7-index.js +3 -0
- package/src/tui-compiled/raw/shared/cd94316a888b0a8e-schema.js +754 -0
- package/src/tui-compiled/raw/shared/d319517e3ea6ad70-redact.js +83 -0
- package/src/tui-compiled/raw/shared/d5a8f1061ee2f114-index.js +5 -0
- package/src/tui-compiled/raw/shared/d669d72c40e9e116-logger.js +19 -0
- package/src/tui-compiled/raw/shared/d7dcba96fea1685c-engine.js +246 -0
- package/src/tui-compiled/raw/shared/dbef697d1df1cd84-index.js +5 -0
- package/src/tui-compiled/raw/shared/e4acc4cb713f300c-protocol.js +3 -0
- package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +501 -0
- package/src/tui-compiled/raw/shared/ec971142548df90e-index.js +6 -0
- package/src/tui-compiled/raw/shared/f37fcefc7aedbf25-error.js +11 -0
- package/src/tui-compiled/raw/shared/fbcdcd0f925e74c0-rpc-client.js +253 -0
- package/src/tui-compiled/raw/shared/fd45e82f2f9c0a0d-torn.js +294 -0
- package/src/tui-compiled/raw/shared/fe02abeadc535f77-rows.js +1258 -0
- package/src/tui-compiled/raw/sidebar-state.js +960 -0
- package/src/tui-compiled/raw/tui/command-dialogs.tsx +424 -0
- package/src/tui-compiled/raw/tui-preferences.js +135 -0
- package/src/tui-compiled/raw/tui.tsx +135 -143
- package/src/tui-compiled/runtime/logger.js +24 -0
- package/src/tui-compiled/runtime/rpc/protocol.js +3 -0
- package/src/tui-compiled/runtime/rpc/rpc-client.js +7 -0
- package/src/tui-compiled/runtime/rpc/rpc-dir.js +27 -0
- package/src/tui-compiled/runtime/selector.js +21 -0
- package/src/tui-compiled/runtime/shared/0332701351b3eeec-format.js +138 -0
- package/src/tui-compiled/runtime/shared/04a6357627de5ed0-errors.js +38 -0
- package/src/tui-compiled/runtime/shared/053cc17b5419261e-codec.js +12 -0
- package/src/tui-compiled/runtime/shared/0766d78c6f481f18-watcher.js +157 -0
- package/src/tui-compiled/runtime/shared/08eef45626a94992-reserved.js +13 -0
- package/src/tui-compiled/runtime/shared/39c3cb05738fcf6d-projection.js +134 -0
- package/src/tui-compiled/runtime/shared/3c2d4169d00f907e-tui-support.js +5 -0
- package/src/tui-compiled/runtime/shared/3e7d45a77c6ad4d5-index.js +4 -0
- package/src/tui-compiled/runtime/shared/415792e85d80819e-capture-sink.js +13 -0
- package/src/tui-compiled/runtime/shared/42ae93ab554fcec2-open-url.js +28 -0
- package/src/tui-compiled/runtime/shared/43fc9e6b994519c7-refresh-lock.js +136 -0
- package/src/tui-compiled/runtime/shared/458b934e92490331-mutate.js +500 -0
- package/src/tui-compiled/runtime/shared/45bf5343bbbf9add-admission.js +142 -0
- package/src/tui-compiled/runtime/shared/46f3dff1266160e8-client.js +2 -0
- package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +48 -0
- package/src/tui-compiled/runtime/shared/4f36d333d081d040-merge.js +162 -0
- package/src/tui-compiled/runtime/shared/54eba94fd64c8c3c-index.js +7 -0
- package/src/tui-compiled/runtime/shared/7211cfec06a298bc-atomic-write.js +80 -0
- package/src/tui-compiled/runtime/shared/754d6017f8e419cf-builtins.js +534 -0
- package/src/tui-compiled/runtime/shared/75bd8c3bd63b315f-identity.js +79 -0
- package/src/tui-compiled/runtime/shared/7a91bb630e6f4804-index.js +1 -0
- package/src/tui-compiled/runtime/shared/826342a4b6a8b89b-model.js +16 -0
- package/src/tui-compiled/runtime/shared/83068c0dbe8a6f13-publication.js +304 -0
- package/src/tui-compiled/runtime/shared/836fc615de6afbd9-settings.js +120 -0
- package/src/tui-compiled/runtime/shared/83bc3ba9d0fe2761-runtime.js +68 -0
- package/src/tui-compiled/runtime/shared/8a18abe4fa2977c8-menu.js +300 -0
- package/src/tui-compiled/runtime/shared/901e149c5a0dbbff-sticky.js +339 -0
- package/src/tui-compiled/runtime/shared/9020c407ce64f672-ordered.js +58 -0
- package/src/tui-compiled/runtime/shared/905bffc0220f43d0-map.js +105 -0
- package/src/tui-compiled/runtime/shared/94820e324f2b4c09-seam.js +301 -0
- package/src/tui-compiled/runtime/shared/97484d9bb98c705b-provider-state.js +226 -0
- package/src/tui-compiled/runtime/shared/9968e3cade6969a1-index.js +2 -0
- package/src/tui-compiled/runtime/shared/9b4da614c45f9cd0-lock-constants.js +14 -0
- package/src/tui-compiled/runtime/shared/9d3fc9e37456504e-refresh.js +225 -0
- package/src/tui-compiled/runtime/shared/9deae3c4da4fd63b-hooks.js +34 -0
- package/src/tui-compiled/runtime/shared/a09b6a533c11858f-tui-preferences.js +77 -0
- package/src/tui-compiled/runtime/shared/a62a27a204266acd-attribution.js +60 -0
- package/src/tui-compiled/runtime/shared/a910277ac43a8626-pull.js +143 -0
- package/src/tui-compiled/runtime/shared/b85c5301fddcb98a-paths.js +5 -0
- package/src/tui-compiled/runtime/shared/c14988621dc60a75-port-file.js +217 -0
- package/src/tui-compiled/runtime/shared/c64d7afbc14ca125-sidebar-file.js +157 -0
- package/src/tui-compiled/runtime/shared/c6b176708c446d6d-pins.js +34 -0
- package/src/tui-compiled/runtime/shared/c7d252bedee01600-pi.js +206 -0
- package/src/tui-compiled/runtime/shared/c852a15cfe489d12-pool.js +120 -0
- package/src/tui-compiled/runtime/shared/cc9e0702a752cea7-index.js +3 -0
- package/src/tui-compiled/runtime/shared/cd94316a888b0a8e-schema.js +754 -0
- package/src/tui-compiled/runtime/shared/d319517e3ea6ad70-redact.js +83 -0
- package/src/tui-compiled/runtime/shared/d5a8f1061ee2f114-index.js +5 -0
- package/src/tui-compiled/runtime/shared/d669d72c40e9e116-logger.js +19 -0
- package/src/tui-compiled/runtime/shared/d7dcba96fea1685c-engine.js +246 -0
- package/src/tui-compiled/runtime/shared/dbef697d1df1cd84-index.js +5 -0
- package/src/tui-compiled/runtime/shared/e4acc4cb713f300c-protocol.js +3 -0
- package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +501 -0
- package/src/tui-compiled/runtime/shared/ec971142548df90e-index.js +6 -0
- package/src/tui-compiled/runtime/shared/f37fcefc7aedbf25-error.js +11 -0
- package/src/tui-compiled/runtime/shared/fbcdcd0f925e74c0-rpc-client.js +253 -0
- package/src/tui-compiled/runtime/shared/fd45e82f2f9c0a0d-torn.js +294 -0
- package/src/tui-compiled/runtime/shared/fe02abeadc535f77-rows.js +1258 -0
- package/src/tui-compiled/runtime/sidebar-state.js +960 -0
- package/src/tui-compiled/runtime/tui/command-dialogs.js +378 -0
- package/src/tui-compiled/runtime/tui-preferences.js +135 -0
- package/src/tui-compiled/runtime/{tui.tsx → tui.js} +288 -316
- package/dist/index-4effjmr6.js +0 -2
- package/dist/index-9ehhb051.js +0 -2
- package/dist/index-g3hsdjh4.js +0 -2
- package/dist/index-hh52v8sb.js +0 -2
- package/dist/index-jwn4r3sw.js +0 -1
- package/dist/index-sq36b120.js +0 -211
- package/dist/internal-BTndPmW2.d.ts +0 -914
- package/dist/quota-normalize-08hpp51v.js +0 -1
- package/dist/sidebar-state-CoKYKcLn.d.ts +0 -220
- package/dist/token-util-ypgz7rge.js +0 -1
- package/src/tui-compiled/raw/core-account-paths.ts +0 -114
- package/src/tui-compiled/raw/core-custody-state.ts +0 -243
- package/src/tui-compiled/raw/logger.ts +0 -53
- package/src/tui-compiled/raw/rpc-port-file.ts +0 -177
- package/src/tui-compiled/raw/rpc-protocol.ts +0 -12
- package/src/tui-compiled/raw/rpc-rpc-client.ts +0 -82
- package/src/tui-compiled/raw/rpc-rpc-dir.ts +0 -46
- package/src/tui-compiled/raw/sidebar-state.ts +0 -1659
- package/src/tui-compiled/raw/tui-command-dialogs.tsx +0 -1096
- package/src/tui-compiled/raw/tui-preferences.ts +0 -328
- package/src/tui-compiled/runtime/core-account-paths.ts +0 -114
- package/src/tui-compiled/runtime/core-custody-state.ts +0 -243
- package/src/tui-compiled/runtime/logger.ts +0 -53
- package/src/tui-compiled/runtime/rpc-port-file.ts +0 -177
- package/src/tui-compiled/runtime/rpc-protocol.ts +0 -12
- package/src/tui-compiled/runtime/rpc-rpc-client.ts +0 -82
- package/src/tui-compiled/runtime/rpc-rpc-dir.ts +0 -46
- package/src/tui-compiled/runtime/sidebar-state.ts +0 -1659
- package/src/tui-compiled/runtime/tui-command-dialogs.tsx +0 -855
- package/src/tui-compiled/runtime/tui-preferences.ts +0 -328
- package/src/tui-compiled/shared/internal.ts +0 -6
- package/src/tui-compiled/shared/logger.ts +0 -264
- package/src/tui-compiled/shared/paths.ts +0 -33
- package/src/tui-compiled/shared/refresh-file-lock.ts +0 -384
- package/src/tui-compiled/shared/util/error.ts +0 -9
- package/src/tui-compiled/shared/util/open-url.ts +0 -30
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// The Pi renderer: walks the same menu model the OpenCode dialog draws, with
|
|
2
|
+
// Pi's extension UI (`select`, `confirm`, `input`, `notify`). It sees only the
|
|
3
|
+
// payloads the menu's seam produces, and applies actions through the menu,
|
|
4
|
+
// so the confirmation and input checks are the same as on OpenCode.
|
|
5
|
+
/**
|
|
6
|
+
* Shows `entries` with `select` and returns the chosen value. Labels are made
|
|
7
|
+
* unique, since `select` answers with the label.
|
|
8
|
+
*/
|
|
9
|
+
async function pick(ui, title, entries) {
|
|
10
|
+
const byLabel = new Map();
|
|
11
|
+
const labels = [];
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
let label = entry.label;
|
|
14
|
+
for (let n = 2; byLabel.has(label); n++)
|
|
15
|
+
label = `${entry.label} (${n})`;
|
|
16
|
+
byLabel.set(label, entry.value);
|
|
17
|
+
labels.push(label);
|
|
18
|
+
}
|
|
19
|
+
const chosen = await ui.select(title, labels);
|
|
20
|
+
return chosen === undefined ? undefined : byLabel.get(chosen);
|
|
21
|
+
}
|
|
22
|
+
function withLines(title, lines) {
|
|
23
|
+
return lines.length > 0 ? `${title}\n${lines.join('\n')}` : title;
|
|
24
|
+
}
|
|
25
|
+
/** A row as one line of text: its label, then its status when it has one. */
|
|
26
|
+
function rowText(item) {
|
|
27
|
+
return item.status ? `${item.label} · ${item.status}` : item.label;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The read-only part of a section's select title: its lines, then each item
|
|
31
|
+
* that has no actions, under its group's header. Such an item does nothing
|
|
32
|
+
* when chosen, so it is shown as text rather than offered as an option. Pi's
|
|
33
|
+
* `select` cannot put text between options, so the headers of groups whose
|
|
34
|
+
* rows are all selectable are not shown.
|
|
35
|
+
*/
|
|
36
|
+
function sectionText(section) {
|
|
37
|
+
const text = [...section.lines];
|
|
38
|
+
let header;
|
|
39
|
+
for (const item of section.items) {
|
|
40
|
+
if (item.actions.length > 0)
|
|
41
|
+
continue;
|
|
42
|
+
if (item.group !== undefined && item.group !== header)
|
|
43
|
+
text.push(item.group);
|
|
44
|
+
header = item.group;
|
|
45
|
+
text.push(item.group !== undefined ? ` ${rowText(item)}` : rowText(item));
|
|
46
|
+
}
|
|
47
|
+
return text;
|
|
48
|
+
}
|
|
49
|
+
function itemTitle(item) {
|
|
50
|
+
const lines = item.detail ? [item.detail] : [];
|
|
51
|
+
for (const [name, value] of Object.entries(item.facts ?? {}))
|
|
52
|
+
lines.push(`${name}: ${String(value)}`);
|
|
53
|
+
return withLines(rowText(item), lines);
|
|
54
|
+
}
|
|
55
|
+
/** One knob's value, or undefined when the user backed out or typed nonsense. */
|
|
56
|
+
async function askKnob(ui, knob) {
|
|
57
|
+
switch (knob.kind) {
|
|
58
|
+
case 'choice': {
|
|
59
|
+
const value = await pick(ui, knob.label, knob.choices.map((choice) => ({
|
|
60
|
+
label: choice.value === knob.value
|
|
61
|
+
? `${choice.label} (current)`
|
|
62
|
+
: choice.label,
|
|
63
|
+
value: choice.value,
|
|
64
|
+
})));
|
|
65
|
+
return value === undefined ? undefined : { value };
|
|
66
|
+
}
|
|
67
|
+
case 'toggle': {
|
|
68
|
+
const value = await pick(ui, knob.label, [
|
|
69
|
+
{ label: knob.value ? 'On (current)' : 'On', value: true },
|
|
70
|
+
{ label: knob.value ? 'Off' : 'Off (current)', value: false },
|
|
71
|
+
]);
|
|
72
|
+
return value === undefined ? undefined : { value };
|
|
73
|
+
}
|
|
74
|
+
case 'number': {
|
|
75
|
+
const range = knob.min !== undefined && knob.max !== undefined
|
|
76
|
+
? ` (${knob.min}-${knob.max}${knob.required ? '' : ', empty clears'})`
|
|
77
|
+
: knob.required
|
|
78
|
+
? ''
|
|
79
|
+
: ' (empty clears)';
|
|
80
|
+
const typed = await ui.input(`${knob.label}${range}`, knob.value !== undefined ? String(knob.value) : undefined);
|
|
81
|
+
if (typed === undefined)
|
|
82
|
+
return undefined;
|
|
83
|
+
const text = typed.trim();
|
|
84
|
+
if (text === '')
|
|
85
|
+
return knob.required && knob.value !== undefined
|
|
86
|
+
? { value: knob.value }
|
|
87
|
+
: { value: null };
|
|
88
|
+
const number = Number(text);
|
|
89
|
+
if (!Number.isFinite(number)) {
|
|
90
|
+
ui.notify(`${knob.label} needs a number.`, 'error');
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return { value: number };
|
|
94
|
+
}
|
|
95
|
+
case 'text': {
|
|
96
|
+
const typed = await ui.input(knob.label, knob.value ?? knob.placeholder);
|
|
97
|
+
if (typed === undefined)
|
|
98
|
+
return undefined;
|
|
99
|
+
const text = typed.trim();
|
|
100
|
+
if (text === '')
|
|
101
|
+
return knob.required && knob.value !== undefined
|
|
102
|
+
? { value: knob.value }
|
|
103
|
+
: { value: null };
|
|
104
|
+
return { value: text };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function askValues(ui, action) {
|
|
109
|
+
const values = {};
|
|
110
|
+
for (const knob of action.knobs) {
|
|
111
|
+
const answer = await askKnob(ui, knob);
|
|
112
|
+
if (!answer)
|
|
113
|
+
return undefined;
|
|
114
|
+
values[knob.id] = answer.value;
|
|
115
|
+
}
|
|
116
|
+
return values;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Runs one invocation of the slash command on Pi: sections, then an item or
|
|
120
|
+
* a section action, then the action's inputs and confirmation; after each
|
|
121
|
+
* apply the user is back in the same section with the refreshed menu. Each
|
|
122
|
+
* section's list ends with Back, which returns to the section list; backing
|
|
123
|
+
* out of the section list ends the invocation.
|
|
124
|
+
*/
|
|
125
|
+
export async function runPiCommandMenu(menu, ui, options = {}) {
|
|
126
|
+
const invocation = {
|
|
127
|
+
...(options.sessionId !== undefined
|
|
128
|
+
? { sessionId: options.sessionId }
|
|
129
|
+
: {}),
|
|
130
|
+
notify: (message, kind) => ui.notify(message, kind),
|
|
131
|
+
};
|
|
132
|
+
let model = (await menu.open(invocation)).menu;
|
|
133
|
+
for (;;) {
|
|
134
|
+
const chosen = await pick(ui, model.title, model.sections.map((section) => ({
|
|
135
|
+
label: section.lines[0]
|
|
136
|
+
? `${section.title}: ${section.lines[0]}`
|
|
137
|
+
: section.title,
|
|
138
|
+
value: section.id,
|
|
139
|
+
})));
|
|
140
|
+
if (chosen === undefined)
|
|
141
|
+
return;
|
|
142
|
+
for (;;) {
|
|
143
|
+
const section = model.sections.find((entry) => entry.id === chosen);
|
|
144
|
+
if (!section)
|
|
145
|
+
break;
|
|
146
|
+
// Only rows that do something are options; the rest is title text.
|
|
147
|
+
const entries = [
|
|
148
|
+
...section.items
|
|
149
|
+
.filter((item) => item.actions.length > 0)
|
|
150
|
+
.map((item) => ({
|
|
151
|
+
label: rowText(item),
|
|
152
|
+
value: { kind: 'item', item },
|
|
153
|
+
})),
|
|
154
|
+
...section.actions.map((action) => ({
|
|
155
|
+
label: action.label,
|
|
156
|
+
value: { kind: 'action', action },
|
|
157
|
+
})),
|
|
158
|
+
];
|
|
159
|
+
const text = sectionText(section);
|
|
160
|
+
if (entries.length === 0 && text.length === 0) {
|
|
161
|
+
ui.notify('Nothing to do here.');
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
const choice = await pick(ui, withLines(section.title, text), [
|
|
165
|
+
...entries,
|
|
166
|
+
{ label: 'Back', value: { kind: 'back' } },
|
|
167
|
+
]);
|
|
168
|
+
if (!choice || choice.kind === 'back')
|
|
169
|
+
break;
|
|
170
|
+
let action;
|
|
171
|
+
let item;
|
|
172
|
+
if (choice.kind === 'item') {
|
|
173
|
+
item = choice.item;
|
|
174
|
+
action = await pick(ui, itemTitle(item), item.actions.map((entry) => ({ label: entry.label, value: entry })));
|
|
175
|
+
if (!action)
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
action = choice.action;
|
|
180
|
+
}
|
|
181
|
+
const values = await askValues(ui, action);
|
|
182
|
+
if (!values)
|
|
183
|
+
continue;
|
|
184
|
+
if (action.confirm) {
|
|
185
|
+
const yes = await ui.confirm(action.label, action.confirm.message);
|
|
186
|
+
if (!yes) {
|
|
187
|
+
ui.notify('Cancelled.');
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const result = await menu.apply({
|
|
192
|
+
command: model.command,
|
|
193
|
+
sectionId: section.id,
|
|
194
|
+
...(item ? { itemId: item.id } : {}),
|
|
195
|
+
actionId: action.id,
|
|
196
|
+
values,
|
|
197
|
+
...(action.confirm ? { confirmed: true } : {}),
|
|
198
|
+
...(options.sessionId !== undefined
|
|
199
|
+
? { sessionId: options.sessionId }
|
|
200
|
+
: {}),
|
|
201
|
+
}, invocation);
|
|
202
|
+
ui.notify(result.text, result.ok ? 'info' : 'error');
|
|
203
|
+
model = result.menu;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { recordQuota } from "./a62a27a204266acd-attribution.js";
|
|
2
|
+
import { initializePool, readPool, } from "./458b934e92490331-mutate.js";
|
|
3
|
+
import { updateProviderStateRow, } from "./97484d9bb98c705b-provider-state.js";
|
|
4
|
+
import { publication, publishRoster, } from "./83068c0dbe8a6f13-publication.js";
|
|
5
|
+
import { PullScheduler } from "./a910277ac43a8626-pull.js";
|
|
6
|
+
import { refreshRow, } from "./9d3fc9e37456504e-refresh.js";
|
|
7
|
+
import { POOL_LOCK_DEFAULTS, } from "./43fc9e6b994519c7-refresh-lock.js";
|
|
8
|
+
import { addRow, disableRow, enableRow, recordRowIdentity, removeRow, reorderRows, replaceRow, rotateRow, } from "./fe02abeadc535f77-rows.js";
|
|
9
|
+
import { POOL_SCHEMA_VERSION, } from "./cd94316a888b0a8e-schema.js";
|
|
10
|
+
import { readPoolSettings, updatePoolSettings, } from "./836fc615de6afbd9-settings.js";
|
|
11
|
+
/**
|
|
12
|
+
* Process-wide memory per config file: ids whose per-row entry a library
|
|
13
|
+
* write dropped (not reused in this process), and rows a load-time pull
|
|
14
|
+
* already fired for.
|
|
15
|
+
*/
|
|
16
|
+
const processMemory = new Map();
|
|
17
|
+
function memoryFor(configPath) {
|
|
18
|
+
let memory = processMemory.get(configPath);
|
|
19
|
+
if (!memory) {
|
|
20
|
+
memory = { removedIds: new Set(), firedAtLoad: new Set() };
|
|
21
|
+
processMemory.set(configPath, memory);
|
|
22
|
+
}
|
|
23
|
+
return memory;
|
|
24
|
+
}
|
|
25
|
+
function toLoad(result) {
|
|
26
|
+
if (result.status === 'ready')
|
|
27
|
+
return {
|
|
28
|
+
status: 'ready',
|
|
29
|
+
schemaVersion: POOL_SCHEMA_VERSION,
|
|
30
|
+
rows: result.rows,
|
|
31
|
+
};
|
|
32
|
+
if (result.status === 'pending-migration')
|
|
33
|
+
return {
|
|
34
|
+
status: 'pending-migration',
|
|
35
|
+
roster: Array.isArray(result.config.accounts)
|
|
36
|
+
? result.config.accounts
|
|
37
|
+
: [],
|
|
38
|
+
};
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
export function openPoolStore(options) {
|
|
42
|
+
const memory = memoryFor(options.configPath);
|
|
43
|
+
const lockDefaults = {
|
|
44
|
+
...POOL_LOCK_DEFAULTS,
|
|
45
|
+
...options.lockOptions,
|
|
46
|
+
};
|
|
47
|
+
const ctx = {
|
|
48
|
+
provider: options.provider,
|
|
49
|
+
configPath: options.configPath,
|
|
50
|
+
statePath: options.statePath,
|
|
51
|
+
codec: options.quota,
|
|
52
|
+
...(options.providerState ? { providerState: options.providerState } : {}),
|
|
53
|
+
now: options.now ?? Date.now,
|
|
54
|
+
storeLocks: options.storeLocks ?? [
|
|
55
|
+
{ name: 'save', path: options.configPath },
|
|
56
|
+
{ name: 'save', path: options.statePath },
|
|
57
|
+
],
|
|
58
|
+
lockDefaults,
|
|
59
|
+
lockEnv: {
|
|
60
|
+
now: options.now ?? Date.now,
|
|
61
|
+
...(options.onLockEvent ? { onLockEvent: options.onLockEvent } : {}),
|
|
62
|
+
...(options.onLockStep ? { onLockStep: options.onLockStep } : {}),
|
|
63
|
+
},
|
|
64
|
+
removedIds: memory.removedIds,
|
|
65
|
+
requireCredentialStamps: options.requireCredentialStamps === true,
|
|
66
|
+
requireRemovedFingerprint: options.requireRemovedFingerprint === true,
|
|
67
|
+
...(options.logger ? { logger: options.logger } : {}),
|
|
68
|
+
...(options.onStep ? { onStep: options.onStep } : {}),
|
|
69
|
+
...(options.hold ? { hold: options.hold } : {}),
|
|
70
|
+
};
|
|
71
|
+
const pulls = new PullScheduler(() => rt, options.pull, options.onPullFailure, memory.firedAtLoad, options.logger);
|
|
72
|
+
const rt = {
|
|
73
|
+
ctx,
|
|
74
|
+
providerLock: options.providerLock ?? {
|
|
75
|
+
name: `provider-${encodeURIComponent(options.provider)}`,
|
|
76
|
+
path: options.statePath,
|
|
77
|
+
},
|
|
78
|
+
rowLockOptions: options.rowLockOptions ?? {},
|
|
79
|
+
firePull: (id, reason) => pulls.fire(id, reason),
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
async load() {
|
|
83
|
+
const result = await readPool(ctx);
|
|
84
|
+
if (result.status === 'ready') {
|
|
85
|
+
// A torn row is no candidate, but its pull is fired too: the pull
|
|
86
|
+
// completes the row on disk before reading it, so an interrupted
|
|
87
|
+
// replace of an OAuth row heals at the next load.
|
|
88
|
+
for (const row of result.rows)
|
|
89
|
+
if ((row.candidate || (row.torn && row.enabled)) &&
|
|
90
|
+
row.type === 'oauth' &&
|
|
91
|
+
row.needsFirstReading)
|
|
92
|
+
pulls.fire(row.id, 'load');
|
|
93
|
+
}
|
|
94
|
+
return toLoad(result);
|
|
95
|
+
},
|
|
96
|
+
async read() {
|
|
97
|
+
return toLoad(await readPool(ctx));
|
|
98
|
+
},
|
|
99
|
+
async initialize(input = {}) {
|
|
100
|
+
return { status: await initializePool(ctx, input.dropKeys ?? []) };
|
|
101
|
+
},
|
|
102
|
+
add: (input, callOptions) => addRow(rt, input, callOptions),
|
|
103
|
+
publishRoster: (plan, callOptions) => publishRoster(rt, plan, callOptions),
|
|
104
|
+
publication: (operationId) => publication(rt, operationId),
|
|
105
|
+
replace: (id, credential, input, callOptions) => replaceRow(rt, id, credential, input, callOptions),
|
|
106
|
+
rotate: (id, credential, input, callOptions) => rotateRow(rt, id, credential, input, callOptions),
|
|
107
|
+
updateProviderState: (id, fence, mutator, callOptions) => updateProviderStateRow(rt, id, fence, mutator, callOptions),
|
|
108
|
+
disable: (id, reason, callOptions) => disableRow(rt, id, reason, callOptions),
|
|
109
|
+
enable: (id, callOptions) => enableRow(rt, id, callOptions),
|
|
110
|
+
remove: (id, callOptions) => removeRow(rt, id, callOptions),
|
|
111
|
+
reorder: (ids, callOptions) => reorderRows(rt, ids, callOptions),
|
|
112
|
+
readSettings: () => readPoolSettings(rt),
|
|
113
|
+
updateSettings: (mutator, callOptions) => updatePoolSettings(rt, mutator, callOptions),
|
|
114
|
+
recordIdentity: (id, identity, attribution, callOptions) => recordRowIdentity(rt, id, identity, attribution, callOptions),
|
|
115
|
+
refresh: (id, provider, callOptions) => refreshRow(rt, id, provider, callOptions),
|
|
116
|
+
recordQuota: (id, attribution, observation) => recordQuota(rt, id, attribution, observation),
|
|
117
|
+
requestReading: (id) => pulls.fire(id, 'admission'),
|
|
118
|
+
pullsSettled: () => pulls.settled(),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createCaptureSink } from "./415792e85d80819e-capture-sink.js";
|
|
2
|
+
export { createLogger, createLoggerInstance, flushForTest, flushLogs, initLogger, resetLoggerForTest, setLogLevel, } from "./d7dcba96fea1685c-engine.js";
|
|
3
|
+
export { createRedactor, redact, redactStrings } from "./d319517e3ea6ad70-redact.js";
|