@open-document/core 0.14.3 → 0.15.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 (33) hide show
  1. package/dist/{build-4K9V8ysT.js → build-CBMroMqd.js} +1 -1
  2. package/dist/{check-B40JlWME.js → check-C2kIZr3f.js} +3 -3
  3. package/dist/cli/bin.js +9 -9
  4. package/dist/{context-Clm_nmr1.js → context-DGp1jwN5.js} +1 -1
  5. package/dist/{dev-De3pLYn_.js → dev-DmzGncKf.js} +1 -1
  6. package/dist/{diff-nU9ybiMk.js → diff-CMI_PVzz.js} +2 -2
  7. package/dist/{export-B9rrNBx2.js → export-BQMUBoBB.js} +3 -3
  8. package/dist/{import-C3542Wry.js → import-CiSRqZyo.js} +3 -3
  9. package/dist/ops/index.js +2 -2
  10. package/dist/{ops-ByJnGyuE.js → ops-DQbZmYRF.js} +1 -1
  11. package/dist/{preview-id9mj3IU.js → preview-CERhZ_FX.js} +1 -1
  12. package/dist/{session-CdkoJhi1.js → session-DdaKKd7_.js} +1007 -4
  13. package/dist/{templates-UJ_v7H-a.js → templates-CBeC-v7e.js} +3 -3
  14. package/dist/vite/index.js +1 -1
  15. package/package.json +1 -1
  16. package/src/agent/consent.ts +42 -0
  17. package/src/agent/provider.ts +24 -1
  18. package/src/agent/providers/antigravity-local.ts +193 -0
  19. package/src/agent/providers/antigravity.ts +656 -0
  20. package/src/agent/providers/index.ts +2 -1
  21. package/src/agent/runner.ts +4 -0
  22. package/src/agent/sandbox-sync.ts +178 -0
  23. package/src/agent/status.ts +33 -1
  24. package/src/agent/types.ts +21 -3
  25. package/src/app/components/agent/agent-panel.tsx +180 -42
  26. package/src/app/components/agent/connect-view.tsx +294 -26
  27. package/src/app/components/agent/provider-logo.tsx +4 -0
  28. package/src/app/lib/agent/use-agent.ts +14 -1
  29. package/src/app/lib/i18n-ja/agent-panel.ts +49 -0
  30. package/src/app/lib/i18n-ko/agent-panel.ts +48 -0
  31. package/src/app/lib/i18n-zh-cn/agent-panel.ts +46 -0
  32. package/src/app/lib/i18n-zh-tw/agent-panel.ts +46 -0
  33. package/src/app/lib/use-locale.ts +43 -0
@@ -0,0 +1,178 @@
1
+ import { createHash } from 'node:crypto';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+
5
+ // The Interactions API takes inline sources up to 1 MB a file and 2 MB in all.
6
+ export const INLINE_FILE_LIMIT = 1024 * 1024;
7
+ export const INLINE_TOTAL_LIMIT = 2 * 1024 * 1024;
8
+ export const SANDBOX_ROOT = '/workspace';
9
+
10
+ export type UploadFile = { rel: string; content: string; hash: string };
11
+
12
+ export type UploadPlan = {
13
+ files: UploadFile[];
14
+ // Workspace-relative paths left behind: binary, too large, or over budget.
15
+ skipped: string[];
16
+ };
17
+
18
+ export function hashBytes(data: Uint8Array | string): string {
19
+ return createHash('sha1').update(data).digest('hex');
20
+ }
21
+
22
+ const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'out']);
23
+
24
+ async function walk(dir: string): Promise<string[]> {
25
+ let entries: import('node:fs').Dirent[];
26
+ try {
27
+ entries = await fs.readdir(dir, { withFileTypes: true });
28
+ } catch {
29
+ return [];
30
+ }
31
+ const files: string[] = [];
32
+ for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
33
+ const full = path.join(dir, entry.name);
34
+ if (entry.isDirectory()) {
35
+ if (!SKIP_DIRS.has(entry.name)) files.push(...(await walk(full)));
36
+ } else if (entry.isFile()) {
37
+ files.push(full);
38
+ }
39
+ }
40
+ return files;
41
+ }
42
+
43
+ function toPosix(rel: string): string {
44
+ return rel.split(path.sep).join('/');
45
+ }
46
+
47
+ const decoder = new TextDecoder('utf-8', { fatal: true });
48
+
49
+ export function decodeText(data: Uint8Array): string | null {
50
+ if (data.includes(0)) return null;
51
+ try {
52
+ return decoder.decode(data);
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+
58
+ // The document folder goes first so the skills are what a tight budget drops.
59
+ export async function collectUploads(cwd: string, roots: string[]): Promise<UploadPlan> {
60
+ const files: UploadFile[] = [];
61
+ const skipped: string[] = [];
62
+ let total = 0;
63
+ for (const root of roots) {
64
+ for (const file of await walk(root)) {
65
+ const rel = toPosix(path.relative(cwd, file));
66
+ const data = await fs.readFile(file).catch(() => null);
67
+ const content = data && data.byteLength <= INLINE_FILE_LIMIT ? decodeText(data) : null;
68
+ if (!data || content === null || total + data.byteLength > INLINE_TOTAL_LIMIT) {
69
+ skipped.push(rel);
70
+ continue;
71
+ }
72
+ total += data.byteLength;
73
+ files.push({ rel, content, hash: hashBytes(data) });
74
+ }
75
+ }
76
+ return { files, skipped };
77
+ }
78
+
79
+ export type TarEntry = { path: string; data: Uint8Array };
80
+
81
+ function readString(block: Uint8Array, start: number, length: number): string {
82
+ const slice = block.subarray(start, start + length);
83
+ const end = slice.indexOf(0);
84
+ return new TextDecoder().decode(end === -1 ? slice : slice.subarray(0, end));
85
+ }
86
+
87
+ function parsePax(data: Uint8Array): Record<string, string> {
88
+ const out: Record<string, string> = {};
89
+ const text = new TextDecoder().decode(data);
90
+ let i = 0;
91
+ while (i < text.length) {
92
+ const space = text.indexOf(' ', i);
93
+ if (space === -1) break;
94
+ const len = Number.parseInt(text.slice(i, space), 10);
95
+ if (!Number.isFinite(len) || len <= 0) break;
96
+ const record = text.slice(space + 1, i + len - 1);
97
+ const eq = record.indexOf('=');
98
+ if (eq !== -1) out[record.slice(0, eq)] = record.slice(eq + 1);
99
+ i += len;
100
+ }
101
+ return out;
102
+ }
103
+
104
+ // Regular files only, with ustar prefixes, pax `path` records and GNU long
105
+ // names; enough for the sandbox snapshot, which is all this reads.
106
+ export function readTar(buffer: Uint8Array): TarEntry[] {
107
+ const entries: TarEntry[] = [];
108
+ let offset = 0;
109
+ let longName: string | null = null;
110
+ while (offset + 512 <= buffer.length) {
111
+ const header = buffer.subarray(offset, offset + 512);
112
+ if (header.every((b) => b === 0)) break;
113
+ const size = Number.parseInt(readString(header, 124, 12).trim() || '0', 8);
114
+ const type = String.fromCharCode(header[156] || 48);
115
+ const dataStart = offset + 512;
116
+ const data = buffer.subarray(dataStart, dataStart + size);
117
+ offset = dataStart + Math.ceil(size / 512) * 512;
118
+
119
+ if (type === 'x') {
120
+ longName = parsePax(data).path ?? longName;
121
+ continue;
122
+ }
123
+ if (type === 'L') {
124
+ longName = readString(data, 0, data.length);
125
+ continue;
126
+ }
127
+ if (type === 'g') continue;
128
+ const prefix = readString(header, 345, 155);
129
+ const name =
130
+ longName ?? (prefix ? `${prefix}/${readString(header, 0, 100)}` : readString(header, 0, 100));
131
+ longName = null;
132
+ if (type === '0' || type === '\0' || type === '7') entries.push({ path: name, data });
133
+ }
134
+ return entries;
135
+ }
136
+
137
+ // Maps a snapshot path back to a workspace-relative one, or null when it falls
138
+ // outside the folder this turn may write.
139
+ export function snapshotRel(entryPath: string, writableRel: string): string | null {
140
+ let p = entryPath
141
+ .replace(/\\/g, '/')
142
+ .replace(/^(\.\/)+/, '')
143
+ .replace(/^\/+/, '');
144
+ const root = SANDBOX_ROOT.replace(/^\/+/, '');
145
+ if (!p.startsWith(`${root}/`)) return null;
146
+ p = path.posix.normalize(p.slice(root.length + 1));
147
+ if (p.startsWith('../') || p === '..' || path.posix.isAbsolute(p)) return null;
148
+ const base = writableRel.replace(/\/+$/, '');
149
+ return p.startsWith(`${base}/`) ? p : null;
150
+ }
151
+
152
+ export type WriteDecision =
153
+ | { rel: string; action: 'write'; data: Uint8Array }
154
+ | { rel: string; action: 'conflict'; data: Uint8Array };
155
+
156
+ /**
157
+ * What to do with each file the agent left in its sandbox. A file it did not
158
+ * change is skipped; a changed or new one is written unless the local copy
159
+ * moved on since the upload (someone edited it during the turn), in which
160
+ * case the agent's version is a conflict and the local file is left alone.
161
+ * `uploaded` and `local` map workspace-relative paths to content hashes; a
162
+ * missing key means the file did not exist.
163
+ */
164
+ export function decideWrites(
165
+ entries: { rel: string; data: Uint8Array }[],
166
+ uploaded: Map<string, string>,
167
+ local: Map<string, string>,
168
+ ): WriteDecision[] {
169
+ const decisions: WriteDecision[] = [];
170
+ for (const { rel, data } of entries) {
171
+ const before = uploaded.get(rel);
172
+ if (before !== undefined && before === hashBytes(data)) continue;
173
+ const now = local.get(rel);
174
+ const action = now === before ? 'write' : 'conflict';
175
+ decisions.push({ rel, action, data });
176
+ }
177
+ return decisions;
178
+ }
@@ -1,3 +1,4 @@
1
+ import { hasConsent } from './consent.ts';
1
2
  import { commandVersion, findOnPath, resolveWorkspacePackage } from './detect.ts';
2
3
  import { type PackageManager, runCommand } from './install.ts';
3
4
  import type { AgentProvider } from './provider.ts';
@@ -9,6 +10,34 @@ async function providerStatus(
9
10
  userCwd: string,
10
11
  provider: AgentProvider,
11
12
  ): Promise<AgentProviderStatus> {
13
+ const consent = provider.consentVersion
14
+ ? {
15
+ version: provider.consentVersion,
16
+ accepted: await hasConsent(userCwd, provider.id, provider.consentVersion),
17
+ }
18
+ : null;
19
+ const runtime = provider.runtime ? await provider.runtime(userCwd) : null;
20
+ const shared = { preview: provider.preview === true, consent, runtime };
21
+ if (provider.auth === 'api-key') {
22
+ const [keyFound, models] = await Promise.all([
23
+ provider.hasKey ? provider.hasKey(userCwd) : Promise.resolve(false),
24
+ provider.models(),
25
+ ]);
26
+ return {
27
+ id: provider.id,
28
+ name: provider.name,
29
+ sdkPackage: '',
30
+ sdkVersion: null,
31
+ cliCommand: '',
32
+ cliFound: false,
33
+ cliVersion: null,
34
+ ready: keyFound && consent?.accepted !== false,
35
+ models,
36
+ auth: 'api-key',
37
+ keyFound,
38
+ ...shared,
39
+ };
40
+ }
12
41
  const sdk = resolveWorkspacePackage(userCwd, provider.sdkPackage);
13
42
  const cliPath = findOnPath(provider.cliCommand);
14
43
  const [cliVersion, models] = await Promise.all([
@@ -23,8 +52,11 @@ async function providerStatus(
23
52
  cliCommand: provider.cliCommand,
24
53
  cliFound: cliPath !== null,
25
54
  cliVersion,
26
- ready: sdk !== null,
55
+ ready: sdk !== null && consent?.accepted !== false,
27
56
  models,
57
+ auth: 'sdk',
58
+ keyFound: null,
59
+ ...shared,
28
60
  };
29
61
  }
30
62
 
@@ -1,6 +1,8 @@
1
- // Codex only: Anthropic does not allow a third-party product to run on a reader's
2
- // claude.ai login, so Claude Code is not offered here. A new agent is one more id.
3
- export const AGENT_PROVIDER_IDS = ['codex'] as const;
1
+ // Anthropic does not allow a third-party product to run on a reader's claude.ai
2
+ // login, so Claude Code is not offered here. Antigravity runs on the user's own
3
+ // Gemini API key, never their Antigravity sign-in, for the same reason. A new
4
+ // agent is one more id.
5
+ export const AGENT_PROVIDER_IDS = ['codex', 'antigravity'] as const;
4
6
 
5
7
  export type AgentProviderId = (typeof AGENT_PROVIDER_IDS)[number];
6
8
 
@@ -33,6 +35,22 @@ export type AgentProviderStatus = {
33
35
  cliVersion: string | null;
34
36
  ready: boolean;
35
37
  models: AgentModelOption[];
38
+ // 'sdk' agents connect by installing their SDK beside a signed-in CLI;
39
+ // 'api-key' agents need a key in the environment and nothing installed.
40
+ auth: AgentProviderAuth;
41
+ preview: boolean;
42
+ keyFound: boolean | null;
43
+ // Terms the user accepts before the panel may run this agent.
44
+ consent: { version: string; accepted: boolean } | null;
45
+ runtime: AgentRuntime | null;
46
+ };
47
+
48
+ export type AgentProviderAuth = 'sdk' | 'api-key';
49
+
50
+ export type AgentRuntime = {
51
+ mode: 'local' | 'cloud';
52
+ localSupported: boolean;
53
+ localVersion: string | null;
36
54
  };
37
55
 
38
56
  export type AgentStatus = {
@@ -44,11 +44,12 @@ import type {
44
44
  AgentEffort,
45
45
  AgentModelOption,
46
46
  AgentProviderId,
47
+ AgentProviderStatus,
47
48
  AgentTurnContext,
48
49
  RespondPayload,
49
50
  } from '../../../agent/types';
50
51
  import { Composer, ContextChip } from './composer';
51
- import { ConnectView } from './connect-view';
52
+ import { ConnectView, PreviewBadge, ProviderConsent } from './connect-view';
52
53
  import { HistoryView } from './history-view';
53
54
  import { ProviderLogo } from './provider-logo';
54
55
  import { Transcript } from './transcript';
@@ -77,6 +78,19 @@ export function AgentPanel({
77
78
  const textareaRef = useRef<HTMLTextAreaElement>(null);
78
79
  const running = session?.status === 'running';
79
80
  const showConnect = !loading && (!connected || manage);
81
+ // An agent that only waits for its terms is offered right in the chat, so
82
+ // trying it never means finding the manage view first.
83
+ // Kept while its setup runs too: accepting flips the terms to accepted at
84
+ // once, and the card must stay to show local mode getting ready.
85
+ const [enablingId, setEnablingId] = useState<AgentProviderId | null>(null);
86
+ const pendingAgent =
87
+ status?.providers.find(
88
+ (p) =>
89
+ p.id === enablingId ||
90
+ (p.auth === 'api-key' && p.keyFound && p.consent && !p.consent.accepted),
91
+ ) ?? null;
92
+ const [dismissedPromo, setDismissedPromo] = useState(readPromoHidden);
93
+ const promoHidden = pendingAgent !== null && dismissedPromo === pendingAgent.id;
80
94
 
81
95
  useEffect(() => {
82
96
  if (status) void autoConnect();
@@ -290,7 +304,13 @@ export function AgentPanel({
290
304
  <p className="px-4 py-5 text-[12px] text-muted-foreground">{t.agent.statusLoading}…</p>
291
305
  ) : showConnect ? (
292
306
  <div className="min-h-0 flex-1 overflow-y-auto">
293
- <ConnectView />
307
+ <ConnectView
308
+ onConnected={() => {
309
+ setManage(false);
310
+ setView('chat');
311
+ setActiveSession(null);
312
+ }}
313
+ />
294
314
  </div>
295
315
  ) : view === 'history' ? (
296
316
  <HistoryView
@@ -323,6 +343,23 @@ export function AgentPanel({
323
343
  <NewDocState providerName={providerName} />
324
344
  ) : (
325
345
  <EmptyState
346
+ promo={
347
+ pendingAgent && !promoHidden ? (
348
+ <EnableAgentCard
349
+ provider={pendingAgent}
350
+ onStart={() => setEnablingId(pendingAgent.id)}
351
+ onCancel={() => setEnablingId(null)}
352
+ onEnabled={() => {
353
+ setEnablingId(null);
354
+ setActiveSession(null);
355
+ }}
356
+ onDismiss={() => {
357
+ setDismissedPromo(pendingAgent.id);
358
+ writePromoHidden(pendingAgent.id);
359
+ }}
360
+ />
361
+ ) : null
362
+ }
326
363
  pendingComments={pendingComments}
327
364
  hasDoc={Boolean(context.docId)}
328
365
  onCreate={createDoc}
@@ -380,13 +417,18 @@ function ModelMenu({
380
417
  }) {
381
418
  const t = useLocale();
382
419
  const [open, setOpen] = useState(false);
383
- const providers = status?.enabled ? status.providers : [];
420
+ // A key-based agent without its key is set up from the manage view; it is
421
+ // not a choice here, so a Codex-only workspace keeps its single list.
422
+ const providers = status?.enabled
423
+ ? status.providers.filter((p) => p.auth !== 'api-key' || p.keyFound)
424
+ : [];
384
425
  const [tab, setTab] = useState<AgentProviderId | null>(providerId);
385
426
  const shownId = tab ?? providerId ?? providers[0]?.id ?? null;
386
427
  const shown = providers.find((p) => p.id === shownId) ?? null;
387
428
  const choice = shown?.ready ? resolveModelChoice(shown.models, modelChoices[shown.id]) : null;
388
429
  const selectedModel = shown?.id === providerId ? (model ?? choice?.model) : choice?.model;
389
430
  const selectedEffort = shown?.id === providerId ? effort : (choice?.effort ?? null);
431
+ const current = providers.find((p) => p.id === providerId) ?? null;
390
432
 
391
433
  return (
392
434
  <Popover
@@ -406,6 +448,7 @@ function ModelMenu({
406
448
  <span aria-hidden className="size-1.5 rounded-full bg-muted-foreground/50" />
407
449
  )}
408
450
  <span className="truncate">{model ? modelLabel(model, t) : t.agent.title}</span>
451
+ {current?.preview && <PreviewBadge />}
409
452
  {effort && (
410
453
  <span className="shrink-0 font-normal text-muted-foreground">
411
454
  {t.agent.efforts[effort]}
@@ -424,26 +467,37 @@ function ModelMenu({
424
467
  aria-selected={p.id === shownId}
425
468
  onClick={() => setTab(p.id)}
426
469
  className={cn(
427
- 'flex h-7 flex-1 items-center justify-center gap-1.5 rounded-[5px] text-[12px] font-medium text-muted-foreground outline-none transition-colors duration-100 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30',
470
+ 'flex h-7 min-w-0 flex-1 basis-0 items-center justify-center gap-1.5 rounded-[5px] px-2 text-[12px] font-medium text-muted-foreground outline-none transition-colors duration-100 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/30',
428
471
  p.id === shownId && 'bg-background text-foreground shadow-edge',
429
472
  )}
430
473
  >
431
474
  <ProviderLogo provider={p.id} className="size-3.5 shrink-0" />
432
- {p.name}
475
+ <span className="truncate">{p.name}</span>
433
476
  </button>
434
477
  ))}
435
478
  </div>
436
479
  )}
437
480
 
481
+ {shown?.preview && (
482
+ <p className="mb-1 flex items-start gap-1.5 px-2 pt-1 text-[11px] leading-relaxed text-muted-foreground">
483
+ <PreviewBadge className="mt-px" />
484
+ <span>{t.agent.previewHint}</span>
485
+ </p>
486
+ )}
487
+
438
488
  {shown && !shown.ready ? (
439
489
  <div className="flex flex-col items-start gap-2 px-2 py-2.5">
440
490
  <p className="text-[12px] leading-relaxed text-muted-foreground">
441
- {shown.cliFound
442
- ? format(t.agent.connectInstallHint, {
443
- pkg: shown.sdkPackage,
444
- pm: status?.packageManager ?? 'npm',
491
+ {shown.auth === 'api-key'
492
+ ? format(shown.keyFound ? t.agent.notReadyTerms : t.agent.notReadyApiKey, {
493
+ name: shown.name,
445
494
  })
446
- : format(t.agent.cliHint, { name: shown.name })}
495
+ : shown.cliFound
496
+ ? format(t.agent.connectInstallHint, {
497
+ pkg: shown.sdkPackage,
498
+ pm: status?.packageManager ?? 'npm',
499
+ })
500
+ : format(t.agent.cliHint, { name: shown.name })}
447
501
  </p>
448
502
  <Button
449
503
  size="xs"
@@ -570,6 +624,7 @@ function NewDocState({ providerName }: { providerName: string }) {
570
624
  }
571
625
 
572
626
  function EmptyState({
627
+ promo,
573
628
  pendingComments,
574
629
  hasDoc,
575
630
  onCreate,
@@ -577,6 +632,7 @@ function EmptyState({
577
632
  onTheme,
578
633
  onEdit,
579
634
  }: {
635
+ promo: ReactNode;
580
636
  pendingComments: number;
581
637
  hasDoc: boolean;
582
638
  onCreate: () => void;
@@ -586,42 +642,47 @@ function EmptyState({
586
642
  }) {
587
643
  const t = useLocale();
588
644
  return (
589
- <div className="flex min-h-0 flex-1 flex-col justify-end overflow-y-auto px-4 py-5">
590
- <span className="eyebrow">{t.agent.title}</span>
591
- <h2 className="mt-1.5 font-heading text-[15px] font-semibold tracking-tight">
592
- {t.agent.emptyTitle}
593
- </h2>
594
- <p className="mt-1 text-[12.5px] text-muted-foreground">{t.agent.emptyHint}</p>
595
- <div className="mt-4 flex flex-col gap-1.5">
596
- {hasDoc && pendingComments > 0 && (
645
+ // `justify-end` would clip whatever overflows the top, so a long card (the
646
+ // terms) is pushed down with an auto margin instead and still scrolls.
647
+ <div className="flex min-h-0 flex-1 flex-col overflow-y-auto px-4 py-5">
648
+ <div className="mt-auto">
649
+ <span className="eyebrow">{t.agent.title}</span>
650
+ <h2 className="mt-1.5 font-heading text-[15px] font-semibold tracking-tight">
651
+ {t.agent.emptyTitle}
652
+ </h2>
653
+ <p className="mt-1 text-[12.5px] text-muted-foreground">{t.agent.emptyHint}</p>
654
+ <div className="mt-4 flex flex-col gap-1.5">
655
+ {promo}
656
+ {hasDoc && pendingComments > 0 && (
657
+ <QuickAction
658
+ icon={<MessageSquare />}
659
+ label={`${t.agent.quickApply} · ${format(plural(pendingComments, t.agent.pendingComments), { count: pendingComments })}`}
660
+ hint={t.agent.quickApplyHint}
661
+ tone="brand"
662
+ onClick={onApply}
663
+ />
664
+ )}
665
+ {hasDoc && (
666
+ <QuickAction
667
+ icon={<Pencil />}
668
+ label={t.agent.quickEdit}
669
+ hint={t.agent.quickEditHint}
670
+ onClick={onEdit}
671
+ />
672
+ )}
597
673
  <QuickAction
598
- icon={<MessageSquare />}
599
- label={`${t.agent.quickApply} · ${format(plural(pendingComments, t.agent.pendingComments), { count: pendingComments })}`}
600
- hint={t.agent.quickApplyHint}
601
- tone="brand"
602
- onClick={onApply}
674
+ icon={<Presentation />}
675
+ label={t.agent.quickCreate}
676
+ hint={t.agent.quickCreateHint}
677
+ onClick={onCreate}
603
678
  />
604
- )}
605
- {hasDoc && (
606
679
  <QuickAction
607
- icon={<Pencil />}
608
- label={t.agent.quickEdit}
609
- hint={t.agent.quickEditHint}
610
- onClick={onEdit}
680
+ icon={<Palette />}
681
+ label={t.agent.quickTheme}
682
+ hint={t.agent.quickThemeHint}
683
+ onClick={onTheme}
611
684
  />
612
- )}
613
- <QuickAction
614
- icon={<Presentation />}
615
- label={t.agent.quickCreate}
616
- hint={t.agent.quickCreateHint}
617
- onClick={onCreate}
618
- />
619
- <QuickAction
620
- icon={<Palette />}
621
- label={t.agent.quickTheme}
622
- hint={t.agent.quickThemeHint}
623
- onClick={onTheme}
624
- />
685
+ </div>
625
686
  </div>
626
687
  </div>
627
688
  );
@@ -693,3 +754,80 @@ function BetaBadge() {
693
754
  </Tooltip>
694
755
  );
695
756
  }
757
+
758
+ const PROMO_KEY = 'open-doc:agent-promo-hidden';
759
+
760
+ function readPromoHidden(): string | null {
761
+ try {
762
+ return localStorage.getItem(PROMO_KEY);
763
+ } catch {
764
+ return null;
765
+ }
766
+ }
767
+
768
+ function writePromoHidden(id: string): void {
769
+ try {
770
+ localStorage.setItem(PROMO_KEY, id);
771
+ } catch {}
772
+ }
773
+
774
+ function EnableAgentCard({
775
+ provider,
776
+ onStart,
777
+ onCancel,
778
+ onEnabled,
779
+ onDismiss,
780
+ }: {
781
+ provider: AgentProviderStatus;
782
+ onStart: () => void;
783
+ onCancel: () => void;
784
+ onEnabled: () => void;
785
+ onDismiss: () => void;
786
+ }) {
787
+ const t = useLocale();
788
+ const [open, setOpen] = useState(false);
789
+ return (
790
+ <div
791
+ data-agent-enable={provider.id}
792
+ className="mb-1.5 rounded-[8px] border border-border bg-card p-3 shadow-edge"
793
+ >
794
+ <h3 className="flex items-center gap-1.5 font-heading text-[13px] font-semibold tracking-tight">
795
+ <ProviderLogo provider={provider.id} className="size-3.5 shrink-0" />
796
+ {format(t.agent.enableTitle, { name: provider.name })}
797
+ {provider.preview && <PreviewBadge />}
798
+ </h3>
799
+ {open ? (
800
+ <div className="mt-3 border-t border-border pt-3">
801
+ <ProviderConsent
802
+ provider={provider}
803
+ onCancel={() => {
804
+ setOpen(false);
805
+ onCancel();
806
+ }}
807
+ onDone={onEnabled}
808
+ />
809
+ </div>
810
+ ) : (
811
+ <>
812
+ <p className="mt-1 text-[11.5px] leading-relaxed text-muted-foreground">
813
+ {t.agent.enableHint}
814
+ </p>
815
+ <div className="mt-2.5 flex items-center gap-2">
816
+ <Button
817
+ size="sm"
818
+ onClick={() => {
819
+ setOpen(true);
820
+ onStart();
821
+ }}
822
+ >
823
+ {t.agent.enable}
824
+ </Button>
825
+ <Button size="sm" variant="ghost" onClick={onDismiss}>
826
+ {t.agent.enableLater}
827
+ </Button>
828
+ </div>
829
+ </>
830
+ )}
831
+ </div>
832
+ );
833
+ }