@ai-ecoverse/slicc-spectrum 1.91.0 → 1.94.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.
@@ -50,7 +50,7 @@ export declare class SliccApprovals extends ModelElement {
50
50
  } | null;
51
51
  arming: number;
52
52
  constructor();
53
- static styles: import("lit").CSSResult[];
53
+ static styles: (import("lit").CSSResult[] | import("lit").CSSResult)[];
54
54
  protected subscribe(model: SliccModel): Array<() => void>;
55
55
  disconnectedCallback(): void;
56
56
  decide(approval: Approval, decision: ApprovalDecision): Promise<void>;
@@ -36,6 +36,7 @@ export declare class SliccChat extends ThemedElement {
36
36
  protected firstUpdated(): void;
37
37
  focus(): void;
38
38
  get busyReason(): string | null;
39
- static closedAfter: number;
39
+ static get closedAfter(): number;
40
+ static set closedAfter(after: number);
40
41
  render(): TemplateResult;
41
42
  }
@@ -23,7 +23,8 @@ export interface PromptOptions {
23
23
  }
24
24
  export declare function focused(): HTMLElement | null;
25
25
  export declare function themeOf(node: Node | null): Element;
26
- export declare const dialogStyles: import("lit").CSSResult;
26
+ export declare const dialogFrame: import("lit").CSSResult;
27
+ export declare const dialogStyles: import("lit").CSSResult[];
27
28
  export declare class SliccConfirm extends LitElement {
28
29
  #private;
29
30
  static properties: {
@@ -40,7 +41,7 @@ export declare class SliccConfirm extends LitElement {
40
41
  cancel: string;
41
42
  trigger: HTMLElement | null;
42
43
  constructor();
43
- static styles: import("lit").CSSResult;
44
+ static styles: import("lit").CSSResult[];
44
45
  get result(): Promise<boolean>;
45
46
  protected firstUpdated(): Promise<void>;
46
47
  disconnectedCallback(): void;
@@ -70,7 +71,7 @@ export declare class SliccPrompt extends LitElement {
70
71
  trigger: HTMLElement | null;
71
72
  submit: ((value: string) => Promise<void>) | null;
72
73
  constructor();
73
- static styles: import("lit").CSSResult;
74
+ static styles: import("lit").CSSResult[];
74
75
  get result(): Promise<string | null>;
75
76
  protected firstUpdated(): Promise<void>;
76
77
  disconnectedCallback(): void;
@@ -50,7 +50,7 @@ export declare class SliccFreezerImport extends LitElement {
50
50
  trigger: HTMLElement | null;
51
51
  allowed: () => boolean;
52
52
  constructor();
53
- static styles: import("lit").CSSResult[];
53
+ static styles: (import("lit").CSSResult[] | import("lit").CSSResult)[];
54
54
  get result(): Promise<ImportOutcome>;
55
55
  protected firstUpdated(): void;
56
56
  disconnectedCallback(): void;
@@ -82,7 +82,7 @@ export declare class SliccGuestInvite extends LitElement {
82
82
  cones: readonly GuestCone[];
83
83
  trigger: HTMLElement | null;
84
84
  constructor();
85
- static styles: import("lit").CSSResult[];
85
+ static styles: (import("lit").CSSResult[] | import("lit").CSSResult)[];
86
86
  get result(): Promise<GuestSeat | null>;
87
87
  protected firstUpdated(): void;
88
88
  disconnectedCallback(): void;
@@ -7,7 +7,7 @@ import '@adobe/spectrum-wc-icons/swc-icon-info-circle.js';
7
7
  import '@spectrum-web-components/menu/sp-menu-item.js';
8
8
  import '@spectrum-web-components/picker/sp-picker.js';
9
9
  import { nothing, type PropertyValues, type TemplateResult } from 'lit';
10
- import type { AuditEntry, ImportCandidate, ImportKind, LinkedDevice, PendingRequest, PolicyEntry, PutOptions, SecretView, SliccModel, VaultPort } from '../model/types.js';
10
+ import type { AuditEntry, EndpointsEntry, ImportCandidate, ImportKind, LinkedDevice, PendingRequest, PolicyEntry, PutOptions, SecretView, SliccModel, VaultPort } from '../model/types.js';
11
11
  import { ThemedElement } from './base.js';
12
12
  import { type PopupDetail } from './vault.js';
13
13
  export declare function until(at: number, now?: number): string;
@@ -23,7 +23,8 @@ export declare function byName(a: SecretView, b: SecretView): number;
23
23
  export declare function sourceLine(secret: SecretView, devices: readonly LinkedDevice[]): string;
24
24
  export declare function revealed(name: string, entries: readonly AuditEntry[], now?: number, more?: boolean): TemplateResult | null;
25
25
  export declare function changes(entry: PolicyEntry, devices: readonly LinkedDevice[]): string[][];
26
- export declare function auditLine(entry: AuditEntry, devices: readonly LinkedDevice[]): TemplateResult;
26
+ export declare function endpointsLine(entry: EndpointsEntry, named?: (provider: string) => string): TemplateResult;
27
+ export declare function auditLine(entry: AuditEntry, devices: readonly LinkedDevice[], named?: (provider: string) => string): TemplateResult;
27
28
  export declare function merged(...pages: ReadonlyArray<readonly AuditEntry[]>): AuditEntry[];
28
29
  export declare function replaceable(secret: SecretView): boolean;
29
30
  export declare function filename(now?: number): string;
@@ -85,6 +86,15 @@ export declare class SliccSecrets extends ThemedElement {
85
86
  busy: {
86
87
  state: boolean;
87
88
  };
89
+ unpinning: {
90
+ state: boolean;
91
+ };
92
+ unpinned: {
93
+ state: boolean;
94
+ };
95
+ unpinFailure: {
96
+ state: boolean;
97
+ };
88
98
  problem: {
89
99
  state: boolean;
90
100
  };
@@ -118,6 +128,12 @@ export declare class SliccSecrets extends ThemedElement {
118
128
  failure: string | null;
119
129
  form: SecretForm | null;
120
130
  busy: boolean;
131
+ unpinning: string | null;
132
+ unpinned: ReadonlySet<string>;
133
+ unpinFailure: {
134
+ key: string;
135
+ message: string;
136
+ } | null;
121
137
  problem: string | null;
122
138
  invalid: string | null;
123
139
  said: Said | null;
@@ -1,9 +1,16 @@
1
+ import '@adobe/spectrum-wc/components/action-button/swc-action-button.js';
1
2
  import '@adobe/spectrum-wc/components/button/swc-button.js';
3
+ import '@adobe/spectrum-wc/components/close-button/swc-close-button.js';
2
4
  import '@adobe/spectrum-wc/components/status-light/swc-status-light.js';
5
+ import '@adobe/spectrum-wc/components/tooltip/swc-tooltip.js';
6
+ import '@adobe/spectrum-wc-icons/swc-icon-add.js';
3
7
  import '@adobe/spectrum-wc-icons/swc-icon-alert-triangle.js';
8
+ import '@adobe/spectrum-wc-icons/swc-icon-checkmark.js';
9
+ import '@adobe/spectrum-wc-icons/swc-icon-delete.js';
4
10
  import { type TemplateResult } from 'lit';
5
- import type { Account, SliccModel } from '../model/types.js';
11
+ import type { Account, ProviderOption, SliccModel } from '../model/types.js';
6
12
  import { ThemedElement } from './base.js';
13
+ export declare function matchProviders(options: readonly ProviderOption[], query: string): ProviderOption[];
7
14
  export declare class SliccSettings extends ThemedElement {
8
15
  #private;
9
16
  static properties: {
@@ -25,6 +32,18 @@ export declare class SliccSettings extends ThemedElement {
25
32
  blocked: {
26
33
  state: boolean;
27
34
  };
35
+ picking: {
36
+ state: boolean;
37
+ };
38
+ adding: {
39
+ state: boolean;
40
+ };
41
+ query: {
42
+ state: boolean;
43
+ };
44
+ filled: {
45
+ state: boolean;
46
+ };
28
47
  };
29
48
  pending: ReadonlySet<string>;
30
49
  entering: string | null;
@@ -38,6 +57,10 @@ export declare class SliccSettings extends ThemedElement {
38
57
  message: string;
39
58
  } | null;
40
59
  blocked: boolean;
60
+ picking: boolean;
61
+ adding: ProviderOption | null;
62
+ query: string;
63
+ filled: ReadonlySet<string>;
41
64
  constructor();
42
65
  static styles: import("lit").CSSResult[];
43
66
  protected subscribe(model: SliccModel): Array<() => void>;
@@ -46,5 +69,6 @@ export declare class SliccSettings extends ThemedElement {
46
69
  connect(id: string, secret?: string, fields?: Record<string, string>): Promise<void>;
47
70
  keep(account: Account, value: string, fields?: Record<string, string>): Promise<void>;
48
71
  get busyReason(): string | null;
72
+ protected updated(changed: Map<PropertyKey, unknown>): void;
49
73
  render(): TemplateResult;
50
74
  }
@@ -0,0 +1,12 @@
1
+ export declare const continuing = "Continue in the sign-in window that opened.";
2
+ export declare const closed = "Closed the sign-in window? Cancel, then Log in again.";
3
+ export declare const signInWait: {
4
+ closedAfter: number;
5
+ };
6
+ export declare function signInText(waited?: boolean): string;
7
+ export declare class SignInWaits {
8
+ #private;
9
+ constructor(update: () => void);
10
+ waited(key: string): boolean;
11
+ done(key: string): void;
12
+ }
@@ -33,7 +33,7 @@ export declare class SliccValueRequest extends ThemedElement {
33
33
  } | null;
34
34
  blocked: boolean;
35
35
  constructor();
36
- static styles: import("lit").CSSResult[];
36
+ static styles: (import("lit").CSSResult[] | import("lit").CSSResult)[];
37
37
  connectedCallback(): void;
38
38
  disconnectedCallback(): void;
39
39
  protected subscribe(model: SliccModel): Array<() => void>;
@@ -30,7 +30,7 @@ export interface DummyOptions {
30
30
  vault?: VaultScenario | 'off';
31
31
  guests?: GuestsScenario | 'off';
32
32
  accounts?: 'settings' | 'vault';
33
- providers?: 'connected' | 'none';
33
+ providers?: 'connected' | 'none' | 'all';
34
34
  hold?: AgentHold['reason'] | 'off';
35
35
  readonly?: 'version' | 'off';
36
36
  browser?: BrowserScenario;
@@ -0,0 +1,4 @@
1
+ import type { Account, ProviderOption } from '../model/types.js';
2
+ export declare const providerFixtures: readonly ProviderOption[];
3
+ export declare function providerAccount(option: ProviderOption): Account;
4
+ export declare function providerAccounts(rows: readonly Account[]): Account[];
@@ -1,5 +1,5 @@
1
1
  import { Emitter } from '../model/emitter.js';
2
- import type { Account, ModelOption, Settings, SettingsEvents, SettingsPort } from '../model/types.js';
2
+ import type { Account, ModelOption, ProviderOption, Settings, SettingsEvents, SettingsPort } from '../model/types.js';
3
3
  import type { Clock } from './clock.js';
4
4
  export declare const dummySettingsKey = "slicc-ui.settings";
5
5
  export declare const signInClosed = "The sign-in window was closed before it finished.";
@@ -8,13 +8,16 @@ export declare class DummySettings extends Emitter<SettingsEvents> implements Se
8
8
  readonly connects: Array<{
9
9
  id: string;
10
10
  gesture: boolean | null;
11
+ fields?: Record<string, string>;
11
12
  }>;
12
- constructor(defaults: Settings, models: readonly ModelOption[], accounts: readonly Account[], storage: Storage | null, clock: Clock, keys?: readonly string[], gated?: boolean, login?: 'ok' | 'fail');
13
+ providers?: () => readonly ProviderOption[];
14
+ remove?: (id: string) => Promise<void>;
15
+ constructor(defaults: Settings, models: readonly ModelOption[], accounts: readonly Account[], storage: Storage | null, clock: Clock, keys?: readonly string[], gated?: boolean, login?: 'ok' | 'fail', providers?: readonly ProviderOption[]);
13
16
  get(): Settings;
14
17
  update(patch: Partial<Settings>): void;
15
18
  models(): readonly ModelOption[];
16
19
  accounts(): readonly Account[];
17
- connect(id: string, secret?: string): Promise<void>;
20
+ connect(id: string, secret?: string, fields?: Record<string, string>): Promise<void>;
18
21
  cancel(id: string): void;
19
22
  disconnect(id: string): void;
20
23
  }
@@ -1,13 +1,14 @@
1
1
  import { Emitter } from '../model/emitter.js';
2
- import type { AuditEntry, AuditPage, Availability, ButtonConfig, ButtonEvent, ButtonMessage, ErrorCode, ImportKind, ImportPick, ImportResult, PolicyNotice, PopupIntent, PutOptions, RecordKind, RefusedRule, RequestState, SealResult, SecretView, VaultButton, VaultEvents, VaultList, VaultPort, VaultStatus } from '../model/types.js';
2
+ import type { AuditEntry, AuditPage, Availability, ButtonConfig, ButtonEvent, ButtonMessage, ErrorCode, ImportKind, ImportPick, ImportResult, PolicyNotice, PopupIntent, PutOptions, RecordKind, RefusedRule, RequestState, SealResult, SecretView, VaultButton, VaultEndpointChange, VaultEvents, VaultList, VaultPort, VaultStatus } from '../model/types.js';
3
3
  import type { Clock } from './clock.js';
4
- export type VaultScenario = 'empty' | 'secrets' | 'policy' | 'notice' | 'locked' | 'request' | 'backup' | 'waiting' | 'purged';
4
+ export type VaultScenario = 'empty' | 'secrets' | 'policy' | 'notice' | 'locked' | 'request' | 'backup' | 'waiting' | 'purged' | 'endpoints-fail';
5
5
  export declare function vaultSecrets(now?: number): SecretView[];
6
6
  export declare function accountRecords(now?: number): SecretView[];
7
7
  export declare function vaultAudit(now?: number): AuditEntry[];
8
8
  export declare function vaultOlder(now?: number): AuditEntry[];
9
9
  export declare function vaultRefused(): RefusedRule[];
10
10
  export declare function vaultPurged(now?: number): AuditEntry;
11
+ export declare function vaultPinned(now?: number): AuditEntry;
11
12
  export declare function vaultPolicy(now?: number): AuditEntry;
12
13
  export declare function vaultNotice(now?: number): PolicyNotice;
13
14
  export declare function vaultFixtures(scenario: VaultScenario, now?: number): {
@@ -36,11 +37,13 @@ export declare class DummyVault extends Emitter<VaultEvents> implements VaultPor
36
37
  request?: string;
37
38
  options?: PutOptions;
38
39
  }[];
40
+ endpointChanges: VaultEndpointChange[];
39
41
  cancelled: string[];
40
42
  imports: DummyImport[];
41
43
  exported: number;
42
44
  acknowledged: string[];
43
45
  constructor(scenario: VaultScenario, time: Clock, records?: readonly SecretView[]);
46
+ endpoints(change: VaultEndpointChange): Promise<void>;
44
47
  status(): VaultStatus | null;
45
48
  list(): VaultList | null;
46
49
  availability(): Availability;
@@ -51,6 +54,7 @@ export declare class DummyVault extends Emitter<VaultEvents> implements VaultPor
51
54
  audit(before?: number, limit?: number): Promise<AuditPage>;
52
55
  put(name: string, value: string, request?: string, options?: PutOptions): Promise<SealResult>;
53
56
  cancel(request: string): Promise<RequestState>;
57
+ unpin(names: string[]): Promise<void>;
54
58
  remove(name: string, kind?: RecordKind): Promise<SealResult>;
55
59
  restore(name: string, kind?: RecordKind): Promise<SealResult>;
56
60
  import(kind: ImportKind, bytes: Uint8Array, options?: {
@@ -19,9 +19,10 @@ export type { LeadersScenario, NetworkScenario, TailnetScenario } from './dummy/
19
19
  export { DummyNetwork, forgottenDevice, joinUrl, leadersFixtures, linksFixtures, networkFixtures, pairedDevice, pairingCode, pairingRefused, pairingStopped, tailnetFixtures, } from './dummy/network.js';
20
20
  export type { NoticeScenario } from './dummy/notices.js';
21
21
  export { DummyNotices, noticeFixtures } from './dummy/notices.js';
22
+ export { providerAccount, providerAccounts, providerFixtures } from './dummy/providers.js';
22
23
  export type { TabsScenario } from './dummy/tabs.js';
23
24
  export { DummyTabs, tabsFixtures } from './dummy/tabs.js';
24
25
  export type { DummyUpdatesOptions, PackageConfirm, PackageScenario, UpdateScenario, } from './dummy/updates.js';
25
26
  export { DummyUpdates, packageFixtures, updateFixtures } from './dummy/updates.js';
26
27
  export type { VaultScenario } from './dummy/vault.js';
27
- export { DummyVault, DummyVaultButton, vaultAudit, vaultFixtures, vaultNotice, vaultOlder, vaultPolicy, vaultPurged, vaultRefused, vaultSecrets, } from './dummy/vault.js';
28
+ export { DummyVault, DummyVaultButton, vaultAudit, vaultFixtures, vaultNotice, vaultOlder, vaultPinned, vaultPolicy, vaultPurged, vaultRefused, vaultSecrets, } from './dummy/vault.js';
@@ -464,11 +464,50 @@ export interface Account {
464
464
  secret?: 'api-key' | 'token';
465
465
  store?: 'vault';
466
466
  fields?: AccountField[];
467
+ keyUrl?: string;
468
+ description?: string;
469
+ vaultName?: string;
467
470
  }
468
471
  export interface AccountField {
469
472
  name: string;
470
473
  label: string;
471
474
  required?: boolean;
475
+ placeholder?: string;
476
+ help?: string;
477
+ customBase?: true;
478
+ options?: readonly AccountFieldOption[];
479
+ value?: string;
480
+ }
481
+ export interface AccountFieldOption {
482
+ value: string;
483
+ label: string;
484
+ }
485
+ export interface ModelEndpoint {
486
+ name: string;
487
+ url: string;
488
+ }
489
+ export interface McpEndpoint {
490
+ server: string;
491
+ url: string;
492
+ }
493
+ export interface EndpointSet {
494
+ model?: ModelEndpoint[];
495
+ mcp?: McpEndpoint[];
496
+ }
497
+ export interface VaultEndpointChange {
498
+ add?: EndpointSet;
499
+ remove?: EndpointSet;
500
+ }
501
+ export type ProviderAuth = 'api-key' | 'oauth' | 'fields' | 'local';
502
+ export interface ProviderOption {
503
+ id: string;
504
+ name: string;
505
+ description?: string;
506
+ auth: ProviderAuth;
507
+ fields?: AccountField[];
508
+ keyUrl?: string;
509
+ needs?: 'cors-free-transport';
510
+ vaultName?: string;
472
511
  }
473
512
  export interface ModelOption {
474
513
  id: string;
@@ -483,6 +522,7 @@ export interface ModelOption {
483
522
  export interface SettingsEvents {
484
523
  settings: Settings;
485
524
  accounts: readonly Account[];
525
+ providers?: readonly ProviderOption[];
486
526
  }
487
527
  export interface SettingsPort extends Subscribable<SettingsEvents> {
488
528
  get(): Settings;
@@ -492,6 +532,8 @@ export interface SettingsPort extends Subscribable<SettingsEvents> {
492
532
  connect(id: string, secret?: string, fields?: Record<string, string>): Promise<void>;
493
533
  disconnect(id: string): void;
494
534
  cancel?(id: string): void;
535
+ providers?(): readonly ProviderOption[];
536
+ remove?(id: string): Promise<void>;
495
537
  }
496
538
  export type MemoryTag = 'user' | 'feedback' | 'project';
497
539
  export interface Memory {
@@ -1132,10 +1174,22 @@ export interface EndpointsEntry {
1132
1174
  at: number;
1133
1175
  uid: null;
1134
1176
  tag: null;
1135
- purged: Array<{
1177
+ purged?: Array<{
1136
1178
  provider: string;
1137
- url: string;
1179
+ host?: string;
1180
+ url?: string;
1138
1181
  }>;
1182
+ adopted?: Array<{
1183
+ server: string;
1184
+ host: string;
1185
+ }>;
1186
+ pinned?: EndpointPin;
1187
+ unpinned?: EndpointPin;
1188
+ }
1189
+ export interface EndpointPin {
1190
+ name?: string;
1191
+ server: string;
1192
+ host: string;
1139
1193
  }
1140
1194
  export interface PolicyEntry {
1141
1195
  type: 'policy';
@@ -1298,6 +1352,7 @@ export interface VaultPort extends Subscribable<VaultEvents> {
1298
1352
  put?(name: string, value: string, request?: string, options?: PutOptions): Promise<SealResult>;
1299
1353
  cancel?(request: string): Promise<RequestState>;
1300
1354
  remove?(name: string, kind?: RecordKind): Promise<SealResult>;
1355
+ unpin?(names: string[]): Promise<void>;
1301
1356
  restore?(name: string, kind?: RecordKind): Promise<SealResult>;
1302
1357
  import?(kind: ImportKind, bytes: Uint8Array, options?: {
1303
1358
  password?: string;
@@ -1306,6 +1361,7 @@ export interface VaultPort extends Subscribable<VaultEvents> {
1306
1361
  export?(passphrase: string): Promise<Uint8Array>;
1307
1362
  lock?(): Promise<void>;
1308
1363
  dismissBackupReminder?(): Promise<void>;
1364
+ endpoints?(change: VaultEndpointChange): Promise<void>;
1309
1365
  button(): VaultButton;
1310
1366
  }
1311
1367
  export type GuestGate = 'user' | 'cone' | 'agent' | `scoop:${string}` | 'off';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-spectrum",
3
- "version": "1.91.0",
3
+ "version": "1.94.0",
4
4
  "description": "Web components for SLICC on Spectrum Web Components: the terminal, the app shell and its surfaces",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,118 +0,0 @@
1
- import {
2
- Emitter
3
- } from "./chunk-T5NHW4KC.js";
4
-
5
- // src/dummy/clock.ts
6
- function clock(delay) {
7
- return {
8
- delay,
9
- sleep: (ticks = 1) => new Promise((resolve) => setTimeout(resolve, delay * ticks))
10
- };
11
- }
12
-
13
- // src/dummy/settings.ts
14
- var dummySettingsKey = "slicc-ui.settings";
15
- var signInClosed = "The sign-in window was closed before it finished.";
16
- var DummySettings = class extends Emitter {
17
- #settings;
18
- #accounts;
19
- #models;
20
- #storage;
21
- #clock;
22
- #keys;
23
- #signIns = /* @__PURE__ */ new Map();
24
- #gated;
25
- #fails;
26
- connects = [];
27
- constructor(defaults, models, accounts, storage, clock2, keys = [dummySettingsKey], gated = false, login) {
28
- super();
29
- this.#fails = login === "fail";
30
- this.#gated = gated;
31
- this.#keys = keys;
32
- this.#storage = storage;
33
- this.#clock = clock2;
34
- this.#models = models;
35
- this.#accounts = accounts.map((account) => ({ ...account }));
36
- this.#settings = { ...defaults, ...this.#load() };
37
- }
38
- #load() {
39
- try {
40
- const saved = this.#keys.map((key) => this.#storage?.getItem(key)).find((value) => value != null);
41
- return JSON.parse(saved ?? "{}");
42
- } catch {
43
- return {};
44
- }
45
- }
46
- get() {
47
- return { ...this.#settings };
48
- }
49
- update(patch) {
50
- this.#settings = { ...this.#settings, ...patch };
51
- this.#storage?.setItem(this.#keys[0], JSON.stringify(this.#settings));
52
- this.emit("settings", this.get());
53
- }
54
- models() {
55
- if (!this.#gated) return this.#models;
56
- const live = new Set(
57
- this.#accounts.filter((account) => account.status === "connected").map((account) => account.provider)
58
- );
59
- return this.#models.filter((option) => live.has(option.provider));
60
- }
61
- accounts() {
62
- return this.#accounts.map((account) => ({ ...account }));
63
- }
64
- #set(id, patch) {
65
- this.#accounts = this.#accounts.map(
66
- (account) => account.id === id ? { ...account, ...patch } : account
67
- );
68
- this.emit("accounts", this.accounts());
69
- }
70
- async connect(id, secret) {
71
- const activation = globalThis.navigator?.userActivation;
72
- this.connects.push({ id, gesture: activation ? activation.isActive : null });
73
- const account = this.#accounts.find((candidate) => candidate.id === id);
74
- if (account && account.auth !== "api-key" && !await this.#signIn(account)) return;
75
- if (account && account.auth !== "api-key" && this.#fails) {
76
- this.#set(id, { status: account.status });
77
- throw new Error(signInClosed);
78
- }
79
- if (account?.auth === "api-key" || !account) await this.#clock.sleep(10);
80
- if (account?.auth === "api-key" && account.store !== "vault" && !secret)
81
- throw new Error(
82
- `${account.provider} needs ${account.secret === "token" ? "a token" : "an API key"}`
83
- );
84
- const identity = account?.group === "mcp" ? account.identity : account?.auth === "api-key" ? "API key" : account?.identity || `${id}-user@example.com`;
85
- this.#set(id, { status: "connected", identity });
86
- }
87
- #signIn(account) {
88
- const before = this.#signIns.get(account.id)?.before ?? account.status;
89
- this.#signIns.get(account.id)?.stop();
90
- this.#set(account.id, { status: "signing-in" });
91
- return new Promise((resolve) => {
92
- const stop = () => {
93
- this.#signIns.delete(account.id);
94
- this.#set(account.id, { status: before });
95
- resolve(false);
96
- };
97
- this.#signIns.set(account.id, { before, stop });
98
- void this.#clock.sleep(100).then(() => {
99
- if (this.#signIns.get(account.id)?.stop !== stop) return;
100
- this.#signIns.delete(account.id);
101
- resolve(true);
102
- });
103
- });
104
- }
105
- cancel(id) {
106
- this.#signIns.get(id)?.stop();
107
- }
108
- disconnect(id) {
109
- this.#set(id, { status: "disconnected" });
110
- }
111
- };
112
-
113
- export {
114
- clock,
115
- dummySettingsKey,
116
- DummySettings
117
- };
118
- //# sourceMappingURL=chunk-VRFAMBWK.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/dummy/clock.ts", "../src/dummy/settings.ts"],
4
- "sourcesContent": ["export interface Clock {\n delay: number;\n sleep(ticks?: number): Promise<void>;\n}\n\nexport function clock(delay: number): Clock {\n return {\n delay,\n sleep: (ticks = 1) => new Promise((resolve) => setTimeout(resolve, delay * ticks)),\n };\n}\n", "import { Emitter } from '../model/emitter.ts';\nimport type {\n Account,\n AccountStatus,\n ModelOption,\n Settings,\n SettingsEvents,\n SettingsPort,\n} from '../model/types.ts';\nimport type { Clock } from './clock.ts';\n\nexport const dummySettingsKey = 'slicc-ui.settings';\nexport const signInClosed = 'The sign-in window was closed before it finished.';\n\nexport class DummySettings extends Emitter<SettingsEvents> implements SettingsPort {\n #settings: Settings;\n #accounts: Account[];\n #models: readonly ModelOption[];\n #storage: Storage | null;\n #clock: Clock;\n #keys: readonly string[];\n #signIns = new Map<string, { before: AccountStatus; stop: () => void }>();\n #gated: boolean;\n #fails: boolean;\n readonly connects: Array<{ id: string; gesture: boolean | null }> = [];\n\n constructor(\n defaults: Settings,\n models: readonly ModelOption[],\n accounts: readonly Account[],\n storage: Storage | null,\n clock: Clock,\n keys: readonly string[] = [dummySettingsKey],\n gated = false,\n login?: 'ok' | 'fail'\n ) {\n super();\n this.#fails = login === 'fail';\n this.#gated = gated;\n this.#keys = keys;\n this.#storage = storage;\n this.#clock = clock;\n this.#models = models;\n this.#accounts = accounts.map((account) => ({ ...account }));\n this.#settings = { ...defaults, ...this.#load() };\n }\n\n #load(): Partial<Settings> {\n try {\n const saved = this.#keys\n .map((key) => this.#storage?.getItem(key))\n .find((value) => value != null);\n return JSON.parse(saved ?? '{}');\n } catch {\n return {};\n }\n }\n\n get(): Settings {\n return { ...this.#settings };\n }\n\n update(patch: Partial<Settings>): void {\n this.#settings = { ...this.#settings, ...patch };\n this.#storage?.setItem(this.#keys[0], JSON.stringify(this.#settings));\n this.emit('settings', this.get());\n }\n\n models(): readonly ModelOption[] {\n if (!this.#gated) return this.#models;\n const live = new Set(\n this.#accounts\n .filter((account) => account.status === 'connected')\n .map((account) => account.provider)\n );\n return this.#models.filter((option) => live.has(option.provider));\n }\n\n accounts(): readonly Account[] {\n return this.#accounts.map((account) => ({ ...account }));\n }\n\n #set(id: string, patch: Partial<Account>): void {\n this.#accounts = this.#accounts.map((account) =>\n account.id === id ? { ...account, ...patch } : account\n );\n this.emit('accounts', this.accounts());\n }\n\n async connect(id: string, secret?: string): Promise<void> {\n const activation = (globalThis.navigator as Navigator | undefined)?.userActivation;\n this.connects.push({ id, gesture: activation ? activation.isActive : null });\n const account = this.#accounts.find((candidate) => candidate.id === id);\n if (account && account.auth !== 'api-key' && !(await this.#signIn(account))) return;\n if (account && account.auth !== 'api-key' && this.#fails) {\n this.#set(id, { status: account.status });\n throw new Error(signInClosed);\n }\n if (account?.auth === 'api-key' || !account) await this.#clock.sleep(10);\n if (account?.auth === 'api-key' && account.store !== 'vault' && !secret)\n throw new Error(\n `${account.provider} needs ${account.secret === 'token' ? 'a token' : 'an API key'}`\n );\n const identity =\n account?.group === 'mcp'\n ? account.identity\n : account?.auth === 'api-key'\n ? 'API key'\n : account?.identity || `${id}-user@example.com`;\n this.#set(id, { status: 'connected', identity });\n }\n\n #signIn(account: Account): Promise<boolean> {\n const before = this.#signIns.get(account.id)?.before ?? account.status;\n this.#signIns.get(account.id)?.stop();\n this.#set(account.id, { status: 'signing-in' });\n return new Promise((resolve) => {\n const stop = () => {\n this.#signIns.delete(account.id);\n this.#set(account.id, { status: before });\n resolve(false);\n };\n this.#signIns.set(account.id, { before, stop });\n void this.#clock.sleep(100).then(() => {\n if (this.#signIns.get(account.id)?.stop !== stop) return;\n this.#signIns.delete(account.id);\n resolve(true);\n });\n });\n }\n\n cancel(id: string): void {\n this.#signIns.get(id)?.stop();\n }\n\n disconnect(id: string): void {\n this.#set(id, { status: 'disconnected' });\n }\n}\n"],
5
- "mappings": ";;;;;AAKO,SAAS,MAAM,OAAsB;AAC1C,SAAO;AAAA,IACL;AAAA,IACA,OAAO,CAAC,QAAQ,MAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,QAAQ,KAAK,CAAC;AAAA,EACnF;AACF;;;ACCO,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAErB,IAAM,gBAAN,cAA4B,QAAgD;AAAA,EACjF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW,oBAAI,IAAyD;AAAA,EACxE;AAAA,EACA;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