sideby 0.16.1 → 0.18.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.
Files changed (128) hide show
  1. package/README.md +7 -3
  2. package/ai-tasks.json +90 -0
  3. package/dist/build.json +1 -1
  4. package/dist/src/cli/commands.d.ts +25 -1
  5. package/dist/src/cli/commands.js +802 -15
  6. package/dist/src/cli/json-schemas.js +252 -1
  7. package/dist/src/cli/main.js +143 -4
  8. package/dist/src/core/after-install.d.ts +54 -0
  9. package/dist/src/core/after-install.js +78 -0
  10. package/dist/src/core/ask.d.ts +222 -0
  11. package/dist/src/core/ask.js +465 -0
  12. package/dist/src/core/attachments.d.ts +50 -0
  13. package/dist/src/core/attachments.js +442 -0
  14. package/dist/src/core/autostart.d.ts +118 -0
  15. package/dist/src/core/autostart.js +302 -0
  16. package/dist/src/core/brand-mark.d.ts +49 -11
  17. package/dist/src/core/brand-mark.js +116 -38
  18. package/dist/src/core/config.d.ts +102 -0
  19. package/dist/src/core/config.js +289 -11
  20. package/dist/src/core/desktop-app.d.ts +1 -1
  21. package/dist/src/core/desktop-app.js +2 -2
  22. package/dist/src/core/edit-settings.d.ts +24 -0
  23. package/dist/src/core/edit-settings.js +97 -0
  24. package/dist/src/core/handoff-brief.d.ts +4 -2
  25. package/dist/src/core/handoff-brief.js +6 -1
  26. package/dist/src/core/handoff-chain.d.ts +24 -0
  27. package/dist/src/core/handoff-chain.js +2 -0
  28. package/dist/src/core/handoff-run.d.ts +4 -3
  29. package/dist/src/core/handoff-run.js +14 -9
  30. package/dist/src/core/launch.d.ts +17 -4
  31. package/dist/src/core/launch.js +32 -24
  32. package/dist/src/core/local-build.d.ts +17 -5
  33. package/dist/src/core/local-build.js +61 -23
  34. package/dist/src/core/lock.d.ts +30 -0
  35. package/dist/src/core/lock.js +143 -0
  36. package/dist/src/core/probe.d.ts +78 -0
  37. package/dist/src/core/probe.js +127 -0
  38. package/dist/src/core/quota-levels.d.ts +6 -1
  39. package/dist/src/core/quota-levels.js +16 -5
  40. package/dist/src/core/same-login.d.ts +9 -4
  41. package/dist/src/core/same-login.js +9 -4
  42. package/dist/src/core/secret-file.d.ts +26 -0
  43. package/dist/src/core/secret-file.js +126 -7
  44. package/dist/src/core/task-spec.d.ts +95 -0
  45. package/dist/src/core/task-spec.js +209 -0
  46. package/dist/src/core/terminal.d.ts +93 -0
  47. package/dist/src/core/terminal.js +376 -0
  48. package/dist/src/core/update.d.ts +34 -12
  49. package/dist/src/core/update.js +96 -84
  50. package/dist/src/desktop/icon.js +12 -15
  51. package/dist/src/families/claude/ai-task.d.ts +8 -0
  52. package/dist/src/families/claude/ai-task.js +38 -0
  53. package/dist/src/families/claude/handoff-hook.js +4 -4
  54. package/dist/src/families/claude/index.js +6 -0
  55. package/dist/src/families/claude/quota-cache.d.ts +24 -7
  56. package/dist/src/families/claude/quota-cache.js +72 -21
  57. package/dist/src/families/codex/handoff-hook.js +4 -4
  58. package/dist/src/families/codex/index.js +16 -0
  59. package/dist/src/families/codex/login-key.d.ts +8 -0
  60. package/dist/src/families/codex/login-key.js +33 -0
  61. package/dist/src/families/grok/handoff-hook.js +4 -4
  62. package/dist/src/families/grok/index.js +4 -0
  63. package/dist/src/families/login-keys.d.ts +6 -0
  64. package/dist/src/families/login-keys.js +6 -0
  65. package/dist/src/families/pi/index.js +5 -0
  66. package/dist/src/handoff/hook.js +51 -30
  67. package/dist/src/handoff/levels.d.ts +24 -0
  68. package/dist/src/handoff/levels.js +70 -0
  69. package/dist/src/handoff/messages.d.ts +6 -3
  70. package/dist/src/handoff/messages.js +20 -7
  71. package/dist/src/handoff/reader.d.ts +6 -3
  72. package/dist/src/menubar/agent.d.ts +3 -0
  73. package/dist/src/menubar/agent.js +21 -0
  74. package/dist/src/menubar/script.d.ts +8 -0
  75. package/dist/src/menubar/script.js +457 -0
  76. package/dist/src/menubar/snapshot.d.ts +115 -0
  77. package/dist/src/menubar/snapshot.js +255 -0
  78. package/dist/src/menubar/strings.d.ts +87 -0
  79. package/dist/src/menubar/strings.js +88 -0
  80. package/dist/src/panel/background.js +15 -21
  81. package/dist/src/panel/handler.d.ts +41 -2
  82. package/dist/src/panel/handler.js +394 -10
  83. package/dist/src/panel/i18n.d.ts +205 -2
  84. package/dist/src/panel/i18n.js +441 -35
  85. package/dist/src/panel/page-logic.d.ts +301 -0
  86. package/dist/src/panel/page-logic.js +532 -0
  87. package/dist/src/panel/page-script.js +1135 -185
  88. package/dist/src/panel/page-styles.js +111 -32
  89. package/dist/src/panel/page.d.ts +12 -0
  90. package/dist/src/panel/page.js +7 -0
  91. package/dist/src/panel/server.d.ts +16 -2
  92. package/dist/src/panel/server.js +41 -13
  93. package/dist/src/plugins/check.d.ts +47 -0
  94. package/dist/src/plugins/check.js +544 -0
  95. package/dist/src/plugins/scaffold.d.ts +21 -0
  96. package/dist/src/plugins/scaffold.js +123 -0
  97. package/dist/src/quota/statusline-tap.js +1 -1
  98. package/dist/src/runtime.d.ts +19 -1
  99. package/dist/src/runtime.js +53 -14
  100. package/dist/src/types.d.ts +33 -0
  101. package/package.json +4 -3
  102. package/schemas/ask-choices.json +168 -0
  103. package/schemas/ask-print.json +87 -0
  104. package/schemas/ask.json +180 -0
  105. package/schemas/autostart.json +165 -0
  106. package/schemas/config-get.json +132 -0
  107. package/schemas/config-set.json +107 -0
  108. package/schemas/config.json +90 -7
  109. package/schemas/edit.json +119 -0
  110. package/schemas/error.json +4 -0
  111. package/schemas/families.json +4 -0
  112. package/schemas/key.json +93 -0
  113. package/schemas/list.json +4 -0
  114. package/schemas/local.json +1 -1
  115. package/schemas/menubar-snapshot.json +646 -0
  116. package/schemas/menubar-start.json +112 -0
  117. package/schemas/menubar.json +165 -0
  118. package/schemas/plugins-check.json +113 -0
  119. package/schemas/plugins-new.json +87 -0
  120. package/schemas/terminal.json +152 -0
  121. package/schemas/try.json +109 -0
  122. package/schemas/update.json +4 -0
  123. package/skills/sideby/SKILL.md +16 -6
  124. package/skills/sideby/references/accounts.md +1 -1
  125. package/skills/sideby/references/ai-tasks.md +126 -0
  126. package/skills/sideby/references/handoff.md +3 -1
  127. package/skills/sideby/references/panel.md +20 -0
  128. package/skills/sideby/references/update.md +1 -1
@@ -77,6 +77,15 @@ export declare function attentionReasons(a: LogicAccount, health: {
77
77
  fail: number;
78
78
  warn: number;
79
79
  } | null, now: number, warn: number): string[];
80
+ /**
81
+ * The one status badge an account row shows after its name (spec §3.27), most important first: `health-fail`
82
+ * (needs fixing), `quota-high` (running low), the other attention labels (`signed-out`, `not-installed`,
83
+ * `health-warn`), then `next` (recommended) and last `api`. Null when none applies. `reasons` are attentionReasons'.
84
+ */
85
+ export declare function rowBadge(reasons: string[], opts: {
86
+ next?: boolean;
87
+ api?: boolean;
88
+ }): string | null;
80
89
  /**
81
90
  * The most serious reason an Account needs a look, as a message key and its values for the Panel to show where the
82
91
  * attention count is: `why.<reason>`; for `quota-high` the fullest live window at or over `warn`, with its label and
@@ -195,6 +204,44 @@ export declare function switchFailure(e: {
195
204
  network?: boolean;
196
205
  status?: number;
197
206
  }): 'wait' | 'check' | 'fail';
207
+ /**
208
+ * What a request that may swap the server's code (an Update, a Local Build switch; spec §3.23) has done. `failure` is
209
+ * how the request failed (`switchFailure`), null for an answer. `landed` is what a fresh read of the state says
210
+ * (the version runs, the switch is in place), null while the state cannot be read. `waitedOut`: the wait for the new
211
+ * code is over. Without an answer only the state can confirm success; until the wait is over the page keeps reading.
212
+ */
213
+ export declare function codeSwapOutcome(s: {
214
+ failure: 'wait' | 'check' | 'fail' | null;
215
+ landed: boolean | null;
216
+ waitedOut: boolean;
217
+ }): 'done' | 'waiting' | 'failed' | 'unknown';
218
+ /**
219
+ * Runs a request that may swap the server's code (an Update, a Local Build switch; spec §3.23). A background Panel
220
+ * restarting from the new code drops the answer, and a Portal moving to it may answer 5xx: without an answer only a
221
+ * fresh read of the state that shows the change counts as success (`codeSwapOutcome`). Each wait starts when the
222
+ * previous step ended, never before the request (an install can take longer than a wait): `windowMs` to confirm the
223
+ * change, reading every `pollMs` and once more at the end, then `windowMs` for the new build, which `reload`s the
224
+ * page. `done(answer)` returns false to stop after it; `stuck` when no new build came, `fail(error)` when the change
225
+ * did not happen, `unknown` when the state never answered.
226
+ */
227
+ export declare function runCodeSwap(io: {
228
+ send: () => Promise<unknown>;
229
+ /** Reads the state; true when this read answered. */
230
+ readState: () => Promise<boolean>;
231
+ /** What the state just read says: the change is in place (true), is not (false), or cannot tell (null). */
232
+ landed: () => boolean | null;
233
+ newBuild: () => boolean;
234
+ reload: () => void;
235
+ now: () => number;
236
+ pause: (ms: number) => Promise<void>;
237
+ windowMs: number;
238
+ pollMs: number;
239
+ confirming: () => void;
240
+ done: (answer: unknown) => boolean;
241
+ stuck: () => void;
242
+ fail: (error: unknown) => void;
243
+ unknown: () => void;
244
+ }): Promise<void>;
198
245
  export declare function panelFixes(f: {
199
246
  code?: string;
200
247
  }, skillUpdatable: boolean): boolean;
@@ -302,5 +349,259 @@ export declare function remoteControlSummary(groups: readonly {
302
349
  export declare function remoteControlTodo<G extends {
303
350
  state: string;
304
351
  }>(groups: readonly G[], to: 'on' | 'off'): G[];
352
+ /**
353
+ * Where a menu or popover goes next to its anchor, all in viewport pixels. It opens below when its whole height fits
354
+ * there, else above when it fits there, else on the side with more room, its height capped at that room so it scrolls
355
+ * inside. Below `margin` from each edge and `gap` from the anchor. When neither side has even `min` pixels (a tiny
356
+ * window, an anchor near an edge), it takes the whole height of the window instead, over the anchor. Horizontally it
357
+ * lines up with the anchor's left edge (`start`) or right edge (`end`), kept inside the window.
358
+ */
359
+ export declare function menuPlacement(anchor: {
360
+ top: number;
361
+ bottom: number;
362
+ left: number;
363
+ right: number;
364
+ }, size: {
365
+ width: number;
366
+ height: number;
367
+ }, view: {
368
+ width: number;
369
+ height: number;
370
+ }, align: 'start' | 'end', gap?: number, margin?: number, min?: number): {
371
+ left: number;
372
+ top: number;
373
+ maxHeight: number;
374
+ above: boolean;
375
+ };
305
376
  /** The key a Same Login group keeps its folded state under: its members, in a fixed order. */
306
377
  export declare function loginKey(refs: readonly string[]): string;
378
+ /**
379
+ * `text` without key-shaped strings (spec §3.28), each replaced by `[key removed]`. First, anywhere in a word, URLs
380
+ * and query strings included: a known key prefix (`sk-`, which covers `sk-ant-` and `sk-proj-`, `xai-`, `gsk_`,
381
+ * `AIza`, `ghp_`, `github_pat_`) followed by 16 or more token characters, an AWS access key id (`AKIA` or `ASIA` and
382
+ * 16 capitals or digits), and a JWT (three base64url parts joined by dots, the first starting `eyJ`). Then any run of
383
+ * 32 or more letters, digits, `_`, `-` or `+` that mixes letters and digits, unless the whitespace-free word it sits
384
+ * in is a URL or a file path (it has a `/`); a 40-character git SHA is such a run. Everything else, whitespace and
385
+ * newlines included, stays as it was. `removed` says whether anything was taken out, so the caller can point the
386
+ * user to the key box.
387
+ */
388
+ export declare function stripSecrets(text: string): {
389
+ text: string;
390
+ removed: boolean;
391
+ };
392
+ /** The kinds of AI Task (spec §3.28); anything else is refused. */
393
+ export declare const AI_TASK_KINDS: readonly ['free', 'fix', 'quota', 'account', 'host', 'plugin', 'terminal', 'handoff'];
394
+ export type AiTaskKind = (typeof AI_TASK_KINDS)[number];
395
+ /**
396
+ * The message keys of the AI dialog for `task` (spec §3.28 "每个入口的提示"): its title, the text box placeholder and
397
+ * the example chips. Each comes from the task's own key (`ask.title.<task>`, `ask.ph.<task>`, `ask.ex.<task>.1` to
398
+ * `.3`) when `has` knows it, otherwise from `free`'s: `ask.title`, `ask.ph.free` and `freeChips`.
399
+ */
400
+ export declare function askCopy(task: string, has: (key: string) => boolean, freeChips: readonly string[]): {
401
+ title: string;
402
+ placeholder: string;
403
+ chips: string[];
404
+ };
405
+ /**
406
+ * Whether the Panel hands its AI Tasks to the Portal around it (ADR-0030): createPanelHandler was given
407
+ * `ask: { bridge: 'postMessage' }` and the page sits in a frame. A Panel opened on its own is its own parent; it keeps
408
+ * its header "Let AI do it" button and its own dialog. The page decides this when it loads.
409
+ */
410
+ export declare function askBridged(boot: {
411
+ ask?: {
412
+ bridge?: string;
413
+ } | null;
414
+ }, win: {
415
+ parent: unknown;
416
+ }): boolean;
417
+ /**
418
+ * Hands an AI Task to the Portal around the Panel (ADR-0030) when `askBridged` says so: posts
419
+ * `{ type: 'local-tools:ask', version: 1, preset, native: { task, text, context }, text }` to the parent with the
420
+ * Panel's own origin as the target, and says it did, so the Panel opens no dialog of its own. Otherwise posts nothing
421
+ * and returns false.
422
+ */
423
+ export declare function askBridge(boot: {
424
+ ask?: {
425
+ bridge?: string;
426
+ } | null;
427
+ }, opts: {
428
+ task?: string;
429
+ text?: string;
430
+ context?: object | null;
431
+ } | undefined, win: {
432
+ parent: {
433
+ postMessage(message: unknown, targetOrigin: string): void;
434
+ } | null;
435
+ location: {
436
+ origin: string;
437
+ };
438
+ }): boolean;
439
+ /**
440
+ * The "Attached files" section of a Task Prompt (spec §3.28 "附件"), in `lang` (`zh`, otherwise English): one line
441
+ * per file with its absolute path and kind, plus how to look at a video. Empty without files. `heading` goes before
442
+ * the section title, so a prompt with Markdown headings (`## `, a Task Spec from a Portal) gets one of its level.
443
+ * sideby's own Task Prompts and the ones a Portal hands over (ADR-0030) share it, word for word.
444
+ */
445
+ export declare function attachedSection(files: readonly {
446
+ path: string;
447
+ kind: string;
448
+ }[], lang: string, heading?: string): string;
449
+ /**
450
+ * The Task Prompt of an AI Task (spec §3.28), in `lang` (`zh`, otherwise English): what to do, the context given,
451
+ * the fixed rules, pointers for the task and the invitation to contribute. For `free` the user's `text` is what to
452
+ * do; for the other tasks it follows the task's own sentence. `text` and every context string go through `strip`
453
+ * (pass `stripSecrets`), so no key-shaped string reaches the prompt; the caller still checks `text` itself to warn
454
+ * the user. Context carries only what the caller passes, never a credential value.
455
+ */
456
+ export declare function taskPrompt(input: {
457
+ task: string;
458
+ text?: string;
459
+ context?: {
460
+ account?: string;
461
+ family?: string;
462
+ findings?: readonly {
463
+ code?: string;
464
+ account?: string;
465
+ item?: string;
466
+ message: string;
467
+ hint?: string;
468
+ }[];
469
+ quotaReason?: string;
470
+ version?: string;
471
+ /** The custom terminal command saved now (`terminal` task). */
472
+ terminalCustom?: string;
473
+ /** Names of the supported terminals installed on this computer (`terminal` task). */
474
+ terminals?: readonly string[];
475
+ /** Auto Handoff facts, one per line, as `handoffTaskFacts` gives them (`handoff` task). */
476
+ handoff?: readonly string[];
477
+ };
478
+ /** Files saved for the task (spec §3.28 "附件"): absolute paths and their kind. */
479
+ attachments?: readonly {
480
+ path: string;
481
+ kind: string;
482
+ }[];
483
+ lang: string;
484
+ }, strip: (text: string) => {
485
+ text: string;
486
+ removed: boolean;
487
+ }): string;
488
+ /**
489
+ * The accounts an AI Task can start (spec §3.28), in the order the dialog lists them: signed-in subscription
490
+ * accounts first, then API accounts, each by ref. A subscription that is not signed in cannot start one.
491
+ */
492
+ export declare function aiTaskAccounts<A extends {
493
+ ref: string;
494
+ kind?: string;
495
+ login?: string;
496
+ }>(accounts: readonly A[]): A[];
497
+ /**
498
+ * Whether a quota cell offers "Ask AI why" (spec §3.28): it shows no data or an error the user cannot fix with a
499
+ * button of its own. Quota that is off (it has its own switch), an API account and a Family without a public source
500
+ * do not.
501
+ */
502
+ export declare function quotaAskable(reason: string | undefined): boolean;
503
+ /** A file size for an attachment tile (spec §3.28 "附件"): KB below 1 MB, MB with one decimal from there. */
504
+ export declare function fileSize(bytes: number): string;
505
+ /** Findings as an AI Task's context carries them: only the fields a Task Prompt shows. */
506
+ export declare function taskFindings(findings: readonly {
507
+ code?: string;
508
+ account?: string;
509
+ item?: string;
510
+ message: string;
511
+ hint?: string;
512
+ }[]): {
513
+ code?: string;
514
+ account?: string;
515
+ item?: string;
516
+ message: string;
517
+ hint?: string;
518
+ }[];
519
+ /**
520
+ * The theme and language the Panel shows (spec §3.29). A Panel that can write takes them from config `panel`; a
521
+ * read-only one from what this browser saved. `language` is empty for the browser's own language.
522
+ */
523
+ export declare function panelPrefs(config: {
524
+ theme?: string;
525
+ language?: string;
526
+ }, local: {
527
+ theme: string;
528
+ lang: string;
529
+ }, fromConfig: boolean): {
530
+ theme: string;
531
+ language: string;
532
+ };
533
+ /**
534
+ * What this browser's own choice adds to config `panel` the first time this version opens (spec §3.29): only keys
535
+ * config does not have yet, and only a choice the person made, not a default. Null when nothing is to be written.
536
+ */
537
+ export declare function panelMigration(config: {
538
+ theme?: string;
539
+ language?: string;
540
+ }, local: {
541
+ theme: string;
542
+ lang: string;
543
+ }): {
544
+ theme?: string;
545
+ language?: string;
546
+ } | null;
547
+ /**
548
+ * The line under the start-at-login switch (spec §3.29) as a message key, whether it is on, whether the switch can
549
+ * be moved, and the action beside it: `fix` turns it on again so it starts this sideby. Read-only: no switch, no action.
550
+ */
551
+ export declare function autostartNote(s: {
552
+ supported: boolean;
553
+ state: string;
554
+ current: boolean;
555
+ } | null, readOnly: boolean): {
556
+ key: string;
557
+ on: boolean;
558
+ toggle: boolean;
559
+ action: 'fix' | null;
560
+ };
561
+ /**
562
+ * The facts an Auto Handoff AI Task carries (spec §3.29), one per line, named as `sideby handoff status --json`
563
+ * names them: the settings, the order per Family, and where each account's quota comes from. Account refs only,
564
+ * never an email. `status` is the readiness, when the page has it.
565
+ */
566
+ export declare function handoffTaskFacts(settings: {
567
+ auto: boolean;
568
+ sameFamily: boolean;
569
+ threshold: number;
570
+ prepareAt: number;
571
+ waitIfResetWithinMinutes?: number;
572
+ countdownSeconds?: number;
573
+ families?: Record<string, {
574
+ policy: string;
575
+ order: readonly string[];
576
+ }>;
577
+ }, starters: readonly string[], accounts: readonly LogicAccount[], now: number, status?: {
578
+ families?: readonly {
579
+ family: string;
580
+ ready: boolean;
581
+ problems: readonly string[];
582
+ }[];
583
+ nextSteps?: readonly string[];
584
+ } | null): string[];
585
+ /**
586
+ * Whether a click on `target` inside a foldable row leaves the row as it is: a control, a tooltip, or anything in
587
+ * the open details, whose lines (a Same Login row's directories among them) are there to use, not to close the row.
588
+ */
589
+ export declare function foldSkips(target: {
590
+ closest(selector: string): unknown;
591
+ }): boolean;
592
+ /** The Panel's layout bands, widest first; page-styles.ts hangs its narrow-screen rules on them. */
593
+ export type WidthTier = 'wide' | 'medium' | 'narrow' | 'phone';
594
+ /** The layout band for a viewport `width` in CSS pixels: up to 560 phone, up to 760 narrow, up to 1100 medium. */
595
+ export declare function widthTier(width: number): WidthTier;
596
+ /**
597
+ * Follows a viewport width that changes frame by frame (a window being dragged, a Portal's sidebar sliding open
598
+ * around the Panel's frame) and calls `apply` with the new band as soon as the width crosses into one, so the layout
599
+ * moves together with the sliding edge instead of after it. For `settleMs` after that (restarted while the width keeps
600
+ * moving) it only notes further crossings, then applies the band the width came to rest in if that differs, so one
601
+ * gesture changes the layout at most twice and never flickers on every frame. Returns the function to call with each
602
+ * new width.
603
+ */
604
+ export declare function widthFollower<T>(shown: T, tierOf: (width: number) => T, apply: (tier: T) => void, settleMs: number, timers: {
605
+ set: (fn: () => void, ms: number) => unknown;
606
+ clear: (id: unknown) => void;
607
+ }): (width: number) => void;