@songsid/agend 2.3.2-beta.11 → 2.3.2-beta.13

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 (50) hide show
  1. package/README.md +4 -0
  2. package/README.zh-TW.md +4 -0
  3. package/dist/auth-api.js +2 -0
  4. package/dist/auth-api.js.map +1 -1
  5. package/dist/backend/kiro-identity.d.ts +55 -0
  6. package/dist/backend/kiro-identity.js +218 -28
  7. package/dist/backend/kiro-identity.js.map +1 -1
  8. package/dist/backend/kiro.d.ts +2 -0
  9. package/dist/backend/kiro.js +25 -4
  10. package/dist/backend/kiro.js.map +1 -1
  11. package/dist/fleet-manager.js +2 -0
  12. package/dist/fleet-manager.js.map +1 -1
  13. package/dist/general-knowledge/skills/docker-install/SKILL.md +25 -0
  14. package/dist/general-knowledge/skills/web-appearance/SKILL.canvas-worker-off.md +3 -0
  15. package/dist/general-knowledge/skills/web-appearance/SKILL.md +3 -0
  16. package/dist/general-knowledge/skills/web-dashboard/SKILL.canvas-worker-off.md +15 -1
  17. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +15 -1
  18. package/dist/kiro-migrate.d.ts +5 -0
  19. package/dist/kiro-migrate.js +42 -4
  20. package/dist/kiro-migrate.js.map +1 -1
  21. package/dist/locale.js +28 -0
  22. package/dist/locale.js.map +1 -1
  23. package/dist/quickstart-api.d.ts +14 -0
  24. package/dist/quickstart-api.js +62 -11
  25. package/dist/quickstart-api.js.map +1 -1
  26. package/dist/settings-effect.js +5 -4
  27. package/dist/settings-effect.js.map +1 -1
  28. package/dist/setup-form.d.ts +2 -2
  29. package/dist/setup-form.js +124 -92
  30. package/dist/setup-form.js.map +1 -1
  31. package/dist/setup-i18n.d.ts +25 -0
  32. package/dist/setup-i18n.js +224 -0
  33. package/dist/setup-i18n.js.map +1 -0
  34. package/dist/ui/backend-signin.js +4 -3
  35. package/dist/ui/fleet-office-pack.d.ts +3 -2
  36. package/dist/ui/fleet-office-pack.js +16 -4
  37. package/dist/ui/fleet-office-zones.js +28 -4
  38. package/dist/ui/fleet-office.js +98 -14
  39. package/dist/ui/panel-settings.js +4 -2
  40. package/dist/ui/settings-discord.js +3 -2
  41. package/dist/ui/settings-strings.js +8 -2
  42. package/dist/ui/settings-token.js +3 -2
  43. package/dist/ui/settings-wizard.js +11 -6
  44. package/dist/ui/shared/setup-host-text.js +105 -0
  45. package/dist/ui/structured-signin.js +89 -38
  46. package/dist/web-office-store.d.ts +16 -0
  47. package/dist/web-office-store.js +44 -10
  48. package/dist/web-office-store.js.map +1 -1
  49. package/package.json +1 -1
  50. package/templates/windows-shortcuts.ps1 +18 -17
@@ -193,7 +193,10 @@ register("settings", {
193
193
  wizardAgentNewName: "New agent name",
194
194
  wizardTopicNotCarried: "Its topic ({0}) is in the chat of its old connection, so it is not carried over: in the new chat it has no topic until one is bound.",
195
195
  wizardTopicGeneral: "It is the General agent: in the new chat it takes that chat's General topic.",
196
- wizardNeedDir: "Enter an absolute working directory.",
196
+ wizardNeedDir: "A working directory must be an absolute path, or leave it empty.",
197
+ wizardDir: "Working directory (optional)",
198
+ wizardDirDefault: "Leave it empty and the agent gets its own folder, {0}, which AgEnD creates. A path you enter must be absolute.",
199
+ wizardDirDefaultName: "Leave it empty and the agent gets its own folder in AgEnD's workspaces, which AgEnD creates. A path you enter must be absolute.",
197
200
  wizardTelegramHint: "Create a bot with @BotFather, then add it to a group.",
198
201
  wizardDiscordHint: "Create an application in the Discord developer portal and invite the bot to your server.",
199
202
  wizardToken: "Bot token",
@@ -843,7 +846,10 @@ register("settings", {
843
846
  wizardAgentNewName: "新 agent 名稱",
844
847
  wizardTopicNotCarried: "它的 topic({0})屬於舊連線的聊天室,不會帶過去:在新的聊天室裡,綁定新的 topic 之前它沒有 topic。",
845
848
  wizardTopicGeneral: "它是 General agent:在新的聊天室裡會改用那裡的 General topic。",
846
- wizardNeedDir: "請輸入絕對路徑的工作目錄。",
849
+ wizardNeedDir: "工作目錄必須是絕對路徑,或留空。",
850
+ wizardDir: "工作目錄(選填)",
851
+ wizardDirDefault: "留空的話,agent 會有自己的資料夾 {0},由 AgEnD 建立。若要填寫,必須是絕對路徑。",
852
+ wizardDirDefaultName: "留空的話,agent 會在 AgEnD 的 workspaces 裡有自己的資料夾,由 AgEnD 建立。若要填寫,必須是絕對路徑。",
847
853
  wizardTelegramHint: "用 @BotFather 建立 bot,然後把它加進一個群組。",
848
854
  wizardDiscordHint: "在 Discord 開發者後台建立應用程式,並把 bot 邀請到你的伺服器。",
849
855
  wizardToken: "Bot token",
@@ -4,7 +4,8 @@
4
4
  // lives in this field's state only: never in storage, a URL, a label or the page's other state, and the server never
5
5
  // hands it back — afterwards a connection shows "Token set · @bot".
6
6
  import { html, useState } from "/assets/app-html.js";
7
- import { t } from "/assets/app-i18n.js";
7
+ import { t, lang } from "/assets/app-i18n.js";
8
+ import { hostText } from "/assets/setup-host-text.js";
8
9
  import { useTypedText } from "/assets/text-undo.js";
9
10
  import { Icon } from "/assets/ui-icons.js";
10
11
  import { api } from "./settings-confirm.js";
@@ -24,7 +25,7 @@ export async function verifyBotToken(platform, token) {
24
25
  .catch(() => ({ ok: false, body: {} }));
25
26
  // A Discord bot's invite and portal page come with it (#1519 P3).
26
27
  if (res.ok && res.body && res.body.identity) return { ...res.body.identity, invite: res.body.invite_url || null, portal: res.body.portal_url || null };
27
- return { valid: false, reason: (res.body && res.body.error) || tn("verifyFailed") };
28
+ return { valid: false, reason: hostText(res.body && res.body.error, lang()) || tn("verifyFailed") };
28
29
  }
29
30
 
30
31
  /** A bot's name as it is addressed: @name, once. */
@@ -3,7 +3,8 @@
3
3
  // to the ordinary Apply: the app's runner (settings-apply.js) posts the apply and watches its job, with the same
4
4
  // progress, deadline and restart recovery as every other change.
5
5
  import { html, useEffect, useRef, useState } from "/assets/app-html.js";
6
- import { t } from "/assets/app-i18n.js";
6
+ import { t, lang } from "/assets/app-i18n.js";
7
+ import { hostText } from "/assets/setup-host-text.js";
7
8
  import { useTypedText } from "/assets/text-undo.js";
8
9
  import { useLease } from "/assets/app-ctx.js";
9
10
  import { Dialog } from "/assets/ui-dialog.js";
@@ -16,6 +17,8 @@ import { DiscordServerPicker } from "./settings-discord.js";
16
17
 
17
18
  const tn = (k, ...v) => t(`settings.${k}`, ...v);
18
19
  const STEPS = 4;
20
+ // #2726: the host's words (English) or code, in the page's language.
21
+ const said = (text) => hostText(text, lang());
19
22
  const post = (path, body) => api(path, { method: "POST", body: JSON.stringify(body) }).catch(() => ({ ok: false, status: 0, body: { error: tn("failed") } }));
20
23
 
21
24
  export function SetupWizard({ ctx, onClose }) {
@@ -83,14 +86,15 @@ export function SetupWizard({ ctx, onClose }) {
83
86
  if (!lease.current()) return;
84
87
  if (rev.current !== at) { setBusy(""); return; }
85
88
  setBusy("");
86
- if (!res.ok) { setErr((res.body && res.body.error) || tn("applyFailed")); return; }
89
+ if (!res.ok) { setErr(said(res.body && res.body.error) || tn("applyFailed")); return; }
87
90
  if (res.body.found) setW((x) => ({ ...x, offset: res.body.offset, group_id: String(res.body.found.groupId), admin_user_id: String(res.body.found.userId) }));
88
91
  else { setW((x) => ({ ...x, offset: res.body.offset })); setErr(tn("wizardNoStartYet")); }
89
92
  };
90
93
  const next = async () => {
91
94
  setErr("");
92
95
  if (w.step === 1) {
93
- if (w.agent !== "existing" && !w.working_directory.startsWith("/")) { setErr(tn("wizardNeedDir")); return; }
96
+ // #2726: none is the agent's own workspace (the server fills it in); one that is given is absolute.
97
+ if (w.agent !== "existing" && w.working_directory && !w.working_directory.startsWith("/")) { setErr(tn("wizardNeedDir")); return; }
94
98
  setW({ ...w, step: 2 }); return;
95
99
  }
96
100
  if (w.step === 2) { setW({ ...w, step: 3 }); return; }
@@ -104,7 +108,7 @@ export function SetupWizard({ ctx, onClose }) {
104
108
  if (!lease.current()) return;
105
109
  setBusy("");
106
110
  if (rev.current !== at) return;
107
- if (!res.ok) { setErr((res.body && res.body.error) || tn("applyFailed")); return; }
111
+ if (!res.ok) { setErr(said(res.body && res.body.error) || tn("applyFailed")); return; }
108
112
  setW((x) => ({ ...x, plan: res.body, step: 4 }));
109
113
  return;
110
114
  }
@@ -140,7 +144,8 @@ export function SetupWizard({ ctx, onClose }) {
140
144
  <p class="note">${tn("wizardAgentExistingNote")}</p></div>` : html`${which}<div class="field"><label for="wz-be">${tn("wizardBackend")}</label>
141
145
  <${Select} id="wz-be" value=${w.backend} onChange=${set("backend")} options=${w.env.backends && w.env.backends.length ? w.env.backends : BACKENDS} />
142
146
  <p class="note">${w.env.backends && w.env.backends.length ? tn("wizardBackendFound", w.env.backends.join(", ")) : tn("wizardBackendNone")}</p></div>
143
- <div class="field"><label for="wz-wd">${tn("workingDir")}</label><input id="wz-wd" type="text" placeholder="/home/you/projects/app" value=${dirText} onInput=${(e) => set("working_directory")(onDirText(e.target.value))} /></div>
147
+ <div class="field"><label for="wz-wd">${tn("wizardDir")}</label><input id="wz-wd" type="text" placeholder="/home/you/projects/app" aria-describedby="wz-wd-note" value=${dirText} onInput=${(e) => set("working_directory")(onDirText(e.target.value))} />
148
+ <p class="note" id="wz-wd-note">${w.env.workspaces_dir && w.instance_name ? tn("wizardDirDefault", `${w.env.workspaces_dir}/${w.instance_name}`) : tn("wizardDirDefaultName")}</p></div>
144
149
  <div class="field"><label for="wz-name">${agents.length ? tn("wizardAgentNewName") : tn("wizardAgentName")}</label><input id="wz-name" type="text" value=${nameText} onInput=${(e) => set("instance_name")(onNameText(e.target.value))} /></div>`;
145
150
  } else if (w.step === 2) {
146
151
  body = html`<div class="seg-inline" role="group" aria-label=${tn("wizardPlatform")}>
@@ -169,7 +174,7 @@ export function SetupWizard({ ctx, onClose }) {
169
174
  ${w.plan.instance && w.plan.instance.topic ? html`<p class="feedback warning">${w.plan.instance.topic.to == null
170
175
  ? tn("wizardTopicNotCarried", w.plan.instance.topic.from) : tn("wizardTopicGeneral")}</p>` : null}
171
176
  <${Drawer} title=${tn("advancedSection")}><${TokenEnvNote} name=${w.plan.token_env} /></${Drawer}>
172
- ${(w.plan.warnings || []).map((x, i) => html`<p key=${i} class="feedback warning">${x}</p>`)}`;
177
+ ${(w.plan.warnings || []).map((x, i) => html`<p key=${i} class="feedback warning">${said(x)}</p>`)}`;
173
178
  }
174
179
  return html`<${Dialog} title=${tn("wizardTitle")} onClose=${onClose} wide=${true} busy=${busy === tn("wizardCommitting")}
175
180
  actions=${html`<button type="button" class="btn" disabled=${w.step === 1 || !!busy} onClick=${() => setW({ ...w, step: w.step - 1 })}>${tn("wizardBack")}</button>
@@ -0,0 +1,105 @@
1
+ // #2726: what the setup host and the wizard's routes answer with — English words, or a code — in English and 繁體中文.
2
+ // One table for every page that shows them: the setup pages (src/setup-i18n.ts pastes this module into them, before any
3
+ // fleet, with its `export`s taken out) and the dashboard's Setup wizard and Apply (/assets/setup-host-text.js). Plain
4
+ // script with no imports and no closing script tag, so it can be pasted as it is.
5
+
6
+ /**
7
+ * The host's English words → 繁體中文. `{0}`, `{1}` are the parts that vary (a name, a count). Kept to the exact wording
8
+ * of the host (setup-host.ts, quickstart-api.ts, token-env-name.ts, the provider probes); tests/setup-i18n-2726.test.ts
9
+ * drives each source and checks it is here.
10
+ */
11
+ export const HOST_MESSAGES = [
12
+ // The code page (setup-host.ts redeem / afterFailure / the cookie gate).
13
+ ["incorrect — {0} attempts left", "代碼不正確 —— 還可以再試 {0} 次"],
14
+ ["incorrect — {0} attempt left", "代碼不正確 —— 還可以再試 {0} 次"],
15
+ ["too many failed attempts — run `agend setup` again on the host", "錯誤次數太多 —— 請在主機上再執行一次 `agend setup`"],
16
+ ["enter the setup code", "請輸入設定代碼"],
17
+ ["enter the setup code first", "請先輸入設定代碼"],
18
+ ["cross-site request rejected", "已拒絕跨站請求"],
19
+ ["not found", "找不到"],
20
+ // Finishing (setup-host.ts finishSetup / status).
21
+ ["Setup changed; review and confirm again.", "設定已改變;請重新檢查並再確認一次。"],
22
+ ["Setup confirmation unavailable.", "無法取得設定確認。"],
23
+ // The wizard's validation (quickstart-api.ts validateWizardInput, validateWebOnlyInput).
24
+ ["working_directory must be an absolute path, or empty for the agent's own workspace", "工作目錄必須是絕對路徑,或留空讓 agent 使用自己的資料夾"],
25
+ ["instance_name must be [A-Za-z0-9._-], and not only dots", "agent 名稱只能用英文字母、數字和 . _ -,而且不能只有句點"],
26
+ ["backend must be a known backend", "請選擇一個支援的後端"],
27
+ ["{0} does not apply to a web-only setup", "只用網頁的設定不使用 {0}"],
28
+ ["platform must be telegram or discord", "平台必須是 Telegram 或 Discord"],
29
+ ["token_env must be an UPPER_SNAKE env var name", "環境變數名稱只能用大寫英文字母、數字和底線(例如 AGEND_BOT_TOKEN)"],
30
+ // A specific wording before the general one it would also match (the first that matches is used).
31
+ ["guild id must be numeric", "伺服器 id 必須是數字"],
32
+ ["{0} must be numeric", "{0} 必須是數字"],
33
+ ["Your Discord user ID is required: enter 17–20 digits, without a leading zero.", "Discord 使用者 ID 必填:請輸入 17–20 位數字,開頭不能是 0。"],
34
+ ["Your Telegram user ID is required: enter 1–20 positive digits, without a leading zero.", "Telegram 使用者 ID 必填:請輸入 1–20 位正整數字,開頭不能是 0。"],
35
+ // Conflicts (agentConflict, newConnectionConflict, webOnlyConflict, token-env-name.ts).
36
+ ["an agent called \"{0}\" already exists — connect it as an existing agent, or choose another name", "已經有名為「{0}」的 agent —— 請把它當作既有的 agent 連接,或換一個名稱"],
37
+ ["there is no agent called \"{0}\"", "沒有名為「{0}」的 agent"],
38
+ ["a connection called \"{0}\" already exists — a new connection never replaces one", "已經有名為「{0}」的連線 —— 新的連線不會取代既有的連線"],
39
+ ["this fleet already has a chat connection — add the agent with New agent instead", "這個 fleet 已經有聊天連線 —— 請改用「新增 Agent」加入 agent"],
40
+ ["{0} is reserved", "{0} 是保留名稱"],
41
+ ["{0} already holds the token of the \"{1}\" connection — a new connection never replaces one; use Replace token on that connection", "{0} 已經存著「{1}」連線的 token —— 新的連線不會取代它;請在那個連線上用「更換 token」"],
42
+ ["{0} is no longer free (it was taken after this setup was planned) — plan it again", "{0} 已被使用(在這次設定規劃之後)—— 請重新產生一次"],
43
+ ["the data dir's .env cannot be read: {0}", "無法讀取資料目錄的 .env:{0}"],
44
+ // Requests and writes (quickstart-api.ts handlers).
45
+ ["token required", "請輸入 bot token"],
46
+ ["invalid JSON", "請求內容不是有效的 JSON"],
47
+ ["bad request", "請求無效"],
48
+ ["unknown probe", "不支援的檢查"],
49
+ ["fleet not loaded", "設定尚未載入"],
50
+ ["another secret operation is still running", "另一個寫入 token 的操作還在進行中"],
51
+ ["setup cleanup failed; inspect configuration on the host", "設定的復原失敗;請在主機上檢查設定"],
52
+ ["setup was not committed", "設定沒有寫入"],
53
+ ["Token verification is not permitted over a public link", "公開連結不能驗證 token"],
54
+ ["This bot token is already being polled by the running fleet. Enter the group id by hand, or stop AgEnD first.", "執行中的 fleet 正在使用這個 bot token。請手動輸入群組 id,或先停止 AgEnD。"],
55
+ ["Another process is already reading this bot's updates. Stop it, or enter the group id by hand.", "另一個程式正在讀取這個 bot 的訊息。請停止它,或手動輸入群組 id。"],
56
+ ["Discord replied {0}", "Discord 回應 {0}"],
57
+ ["Telegram replied {0}", "Telegram 回應 {0}"],
58
+ // The plan's warning (quickstart-api.ts planQuickstart and the web-only plan).
59
+ ["{0} was not found on this host; the agent will fail to start until it is installed.", "這台主機上找不到 {0};安裝之前,agent 會無法啟動。"],
60
+ ];
61
+
62
+ /** What the host answers with a code instead of words (the confirmation gate, settings-effect.ts; the finish step). */
63
+ export const HOST_CODES = {
64
+ en: {
65
+ invalid_quickstart: "This setup is not valid. Review it and try again.",
66
+ connection_exists: "That connection already exists — a new connection never replaces one.",
67
+ agent_conflict: "That agent name is taken, or that agent does not exist.",
68
+ too_many_pending_changes: "Too many changes are waiting for confirmation. Deal with them on the host first.",
69
+ idempotency_key_reused: "This request was already sent with different content. Review it and send it again.",
70
+ settings_confirmation_unavailable: "Host confirmation is not available right now. Try again shortly.",
71
+ session_required: "This setup session has ended. Reopen setup on the host.",
72
+ invalid_json: "The request was not valid JSON.",
73
+ invalid_settings_body: "The request was not valid.",
74
+ signin_cleanup_failed: "The login process could not be confirmed closed. Close it on the host and restart setup before retrying.",
75
+ },
76
+ "zh-TW": {
77
+ invalid_quickstart: "這份設定無效。請檢查後再試一次。",
78
+ connection_exists: "這個連線已存在 —— 新的連線不會取代既有的連線。",
79
+ agent_conflict: "這個 agent 名稱已被使用,或那個 agent 不存在。",
80
+ too_many_pending_changes: "等待確認的變更太多。請先在主機上處理它們。",
81
+ idempotency_key_reused: "這個請求已經用不同的內容送出過。請重新檢查後再送出。",
82
+ settings_confirmation_unavailable: "目前無法要求主機確認。請稍後再試。",
83
+ session_required: "這個設定工作階段已結束。請在主機上重新開啟設定。",
84
+ invalid_json: "請求內容不是有效的 JSON。",
85
+ invalid_settings_body: "請求無效。",
86
+ signin_cleanup_failed: "無法確認登入程序已關閉。請在主機上關閉它,並重新開始設定後再試。",
87
+ },
88
+ };
89
+
90
+ const patterns = HOST_MESSAGES.map(([en, zh]) => ({
91
+ zh, holes: [...en.matchAll(/\{(\d)\}/g)].map((m) => m[1]),
92
+ pattern: new RegExp("^" + en.split(/\{\d\}/).map((part) => part.replace(/[.*+?^$|()[\]{}\\]/g, "\\$&")).join("(.+?)") + "$"),
93
+ }));
94
+
95
+ /** The host's words, or its code, in `lang` ("en" | "zh-TW"); anything it does not know stays as it came. */
96
+ export function hostText(text, lang) {
97
+ if (typeof text !== "string") return text;
98
+ if (Object.hasOwn(HOST_CODES.en, text)) return (HOST_CODES[lang] || HOST_CODES.en)[text];
99
+ if (lang !== "zh-TW") return text;
100
+ for (const { zh, holes, pattern } of patterns) {
101
+ const found = pattern.exec(text);
102
+ if (found) { let out = zh; holes.forEach((hole, i) => { out = out.split("{" + hole + "}").join(found[i + 1]); }); return out; }
103
+ }
104
+ return text;
105
+ }
@@ -1,24 +1,71 @@
1
1
  /* Shared browser controls. No terminal relay, provider output or secrets in diagnostics. */
2
- const NAMES = { "kiro-cli": "Kiro", "claude-code": "Claude Code", codex: "Codex", antigravity: "Antigravity (console fallback)" };
3
- const CHOICES = { builder_id: "Builder ID", google: "Google", github: "GitHub", organization: "Your organization", subscription: "Claude subscription", console: "Anthropic Console" };
4
- const ERRORS = {
5
- unsupported_prompt: "This CLI screen is not supported. Cancel and use the console fallback.",
6
- cleanup_failed: "The login process could not be confirmed closed. Close it on the host and restart setup before retrying.",
7
- signin_cleanup_failed: "The login process could not be confirmed closed. Close it on the host and restart setup before retrying.",
8
- signin_action_stale: "That prompt changed or was already answered. Refresh its status; do not submit it again.",
9
- signin_console_only: "This backend uses the explicit console fallback.",
10
- backend_signin_local_only: "Backend sign-in is available only on this computer. Use the local setup page, or sign in later.",
11
- signin_session_expired: "This setup session has ended. Reopen setup on the host.",
12
- expired: "This login attempt expired. Start a new attempt.",
13
- auth_unconfirmed: "The CLI exited, but credentials could not be verified. Retry or sign in later.",
14
- provider_rejected: "The provider rejected this sign-in. Retry or sign in later.",
2
+ // #2726: in English and 繁體中文 — served alone to the setup page (no dashboard i18n there), so its words live here.
3
+ export const SIGNIN_STRINGS = {
4
+ en: {
5
+ heading: "Sign in your AI backends",
6
+ lead: "Use the controls here; no terminal typing is needed for Kiro, Claude Code or Codex. You can sign in later from the dashboard.",
7
+ check: "Check sign-ins", skipped: "Sign in later · remains in Needs you", valid: "Signed in ✓", notInstalled: "Not installed on this host",
8
+ consoleOnly: "Use the explicit console fallback, or sign in later.", needed: "Sign-in needed", waiting: "Waiting for the CLI…", login: "Login: {0}",
9
+ openProvider: "Open provider sign-in", deviceCode: "Device code:", answerSent: "Answer sent. Waiting for the next screen; it will not be sent twice.",
10
+ cancel: "Cancel sign-in", signIn: "Sign in", signInAgain: "Sign in again", later: "Sign in later", submit: "Submit {0}",
11
+ relogin: "Sign in again? Kiro will sign out its existing account first.", ready: "You can continue setup.",
12
+ field_code: "Paste the returned code", field_start_url: "Organization Start URL", field_region: "AWS region",
13
+ phase_method: "method", phase_code: "code", phase_start_url: "start URL", phase_region: "region", phase_authorization: "authorization",
14
+ choice_organization: "Your organization", choice_subscription: "Claude subscription",
15
+ antigravity: "Antigravity (console fallback)",
16
+ error: "Could not complete sign-in. Check status, retry, or sign in later.",
17
+ error_unsupported_prompt: "This CLI screen is not supported. Cancel and use the console fallback.",
18
+ error_cleanup_failed: "The login process could not be confirmed closed. Close it on the host and restart setup before retrying.",
19
+ error_signin_cleanup_failed: "The login process could not be confirmed closed. Close it on the host and restart setup before retrying.",
20
+ error_signin_action_stale: "That prompt changed or was already answered. Refresh its status; do not submit it again.",
21
+ error_signin_console_only: "This backend uses the explicit console fallback.",
22
+ error_backend_signin_local_only: "Backend sign-in is available only on this computer. Use the local setup page, or sign in later.",
23
+ error_signin_session_expired: "This setup session has ended. Reopen setup on the host.",
24
+ error_expired: "This login attempt expired. Start a new attempt.",
25
+ error_auth_unconfirmed: "The CLI exited, but credentials could not be verified. Retry or sign in later.",
26
+ error_provider_rejected: "The provider rejected this sign-in. Retry or sign in later.",
27
+ },
28
+ "zh-TW": {
29
+ heading: "登入你的 AI 後端",
30
+ lead: "用這裡的按鈕操作;Kiro、Claude Code 和 Codex 都不需要在終端機輸入。也可以之後再從儀表板登入。",
31
+ check: "檢查登入狀態", skipped: "稍後登入 · 會留在「等你回應」", valid: "已登入 ✓", notInstalled: "這台主機上沒有安裝",
32
+ consoleOnly: "請改用主控台備援,或稍後登入。", needed: "需要登入", waiting: "等待 CLI 回應…", login: "登入:{0}",
33
+ openProvider: "開啟登入頁", deviceCode: "裝置代碼:", answerSent: "已送出。等待下一個畫面;不會重複送出。",
34
+ cancel: "取消登入", signIn: "登入", signInAgain: "重新登入", later: "稍後登入", submit: "送出{0}",
35
+ relogin: "要重新登入嗎?Kiro 會先登出目前的帳號。", ready: "可以繼續設定了。",
36
+ field_code: "貼上取得的代碼", field_start_url: "組織的 Start URL", field_region: "AWS 區域",
37
+ phase_method: "選擇方式", phase_code: "代碼", phase_start_url: "Start URL", phase_region: "區域", phase_authorization: "授權",
38
+ choice_organization: "你的組織", choice_subscription: "Claude 訂閱",
39
+ antigravity: "Antigravity(主控台備援)",
40
+ error: "無法完成登入。請檢查狀態、重試,或稍後登入。",
41
+ error_unsupported_prompt: "不支援這個 CLI 畫面。請取消並改用主控台備援。",
42
+ error_cleanup_failed: "無法確認登入程序已關閉。請在主機上關閉它,並重新開始設定後再試。",
43
+ error_signin_cleanup_failed: "無法確認登入程序已關閉。請在主機上關閉它,並重新開始設定後再試。",
44
+ error_signin_action_stale: "這個畫面已改變或已回答過。請重新整理狀態,不要再送一次。",
45
+ error_signin_console_only: "這個後端使用主控台備援。",
46
+ error_backend_signin_local_only: "後端登入只能在這台電腦上進行。請使用本機的設定頁,或稍後登入。",
47
+ error_signin_session_expired: "這個設定工作階段已結束。請在主機上重新開啟設定。",
48
+ error_expired: "這次登入已過期。請重新開始。",
49
+ error_auth_unconfirmed: "CLI 已結束,但無法確認憑證。請重試或稍後登入。",
50
+ error_provider_rejected: "平台拒絕了這次登入。請重試或稍後登入。",
51
+ },
15
52
  };
53
+ const NAMES = { "kiro-cli": "Kiro", "claude-code": "Claude Code", codex: "Codex", antigravity: "Antigravity" };
54
+ const CHOICES = { builder_id: "Builder ID", google: "Google", github: "GitHub", organization: null, subscription: null, console: "Anthropic Console" };
55
+ /** The page's language, as its <html lang> says (the setup page and the dashboard both keep it current). */
56
+ const pageLang = doc => /^zh/i.test(doc?.documentElement?.lang || "") ? "zh-TW" : "en";
16
57
 
17
- export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, changed = () => {} } = {}) {
58
+ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, changed = () => {}, lang } = {}) {
18
59
  const doc = root.ownerDocument;
19
60
  let view = null, busy = false, disposed = false, timer = null, generation = 0, message = "", rendered = "";
61
+ const language = () => (lang ? lang() : pageLang(doc)) === "zh-TW" ? "zh-TW" : "en";
62
+ const tr = (key, value) => { const text = SIGNIN_STRINGS[language()][key] ?? SIGNIN_STRINGS.en[key] ?? key; return value === undefined ? text : text.split("{0}").join(value); };
20
63
  const el = (tag, text, parent = root) => { const node = doc.createElement(tag); if (text) node.textContent = text; parent.append(node); return node; };
21
- const errorText = code => ERRORS[code] || "Could not complete sign-in. Check status, retry, or sign in later.";
64
+ // An error is kept as its code, so it is said again in the other language when that changes.
65
+ const errorText = code => SIGNIN_STRINGS.en["error_" + code] ? tr("error_" + code) : tr("error");
66
+ const name = backend => backend === "antigravity" ? tr("antigravity") : NAMES[backend] || backend;
67
+ const choiceName = choice => CHOICES[choice] ?? tr("choice_" + choice);
68
+ const phaseName = phase => SIGNIN_STRINGS.en["phase_" + phase] ? tr("phase_" + phase) : phase.replaceAll("_", " ");
22
69
  const button = (parent, label, action) => { const b = el("button", label, parent); b.type = "button"; b.disabled = busy; b.onclick = action; return b; };
23
70
  const request = async data => {
24
71
  const response = await fetcher(endpoint, { method: data ? "POST" : "GET", cache: "no-store", headers: { "Content-Type": "application/json" }, ...(data ? { body: JSON.stringify(data) } : {}) });
@@ -31,64 +78,64 @@ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, change
31
78
  if (busy || disposed) return;
32
79
  busy = true; generation++; message = ""; render();
33
80
  try { const next = await request(data); if (!disposed) accept(next); }
34
- catch (error) { if (!disposed) message = errorText(error?.message); }
81
+ catch (error) { if (!disposed) message = String(error?.message || "error"); }
35
82
  finally { busy = false; if (!disposed) render(); }
36
83
  }
37
84
  function render() {
38
- const signature = JSON.stringify([view, busy, message]);
85
+ const signature = JSON.stringify([view, busy, message, language()]);
39
86
  if (disposed || rendered === signature) return;
40
87
  rendered = signature; root.replaceChildren();
41
- el("h2", "Sign in your AI backends");
42
- el("p", "Use the controls here; no terminal typing is needed for Kiro, Claude Code or Codex. You can sign in later from the dashboard.");
43
- if (message) { const alert = el("p", message); alert.setAttribute("role", "alert"); }
44
- if (!view) { button(root, "Check sign-ins", () => perform({ operation: "refresh" })); return; }
88
+ el("h2", tr("heading"));
89
+ el("p", tr("lead"));
90
+ if (message) { const alert = el("p", errorText(message)); alert.setAttribute("role", "alert"); }
91
+ if (!view) { button(root, tr("check"), () => perform({ operation: "refresh" })); return; }
45
92
  for (const backend of view.selected) {
46
93
  const card = el("section"); card.dataset.backend = backend;
47
- el("h3", NAMES[backend] || backend, card);
94
+ el("h3", name(backend), card);
48
95
  const state = view.states[backend], pending = view.pending.includes(backend), skipped = view.skipped.includes(backend);
49
- el("p", skipped ? "Sign in later · remains in Needs you" : state === "valid" ? "Signed in ✓" : state === "not_installed" ? "Not installed on this host" : state === "console_only" ? "Use the explicit console fallback, or sign in later." : "Sign-in needed", card);
96
+ el("p", tr(skipped ? "skipped" : state === "valid" ? "valid" : state === "not_installed" ? "notInstalled" : state === "console_only" ? "consoleOnly" : "needed"), card);
50
97
  const login = view.login?.backend === backend ? view.login : null;
51
98
  const active = login && login.phase !== "done" && !(login.phase === "failed" && login.reason);
52
99
  if (active) {
53
- el("p", login.phase === "waiting" || login.phase === "starting" ? "Waiting for the CLI…" : "Login: " + login.phase.replaceAll("_", " "), card);
100
+ el("p", login.phase === "waiting" || login.phase === "starting" ? tr("waiting") : tr("login", phaseName(login.phase)), card);
54
101
  if (login.phase === "method" && login.canAct) for (const choice of login.choices || []) {
55
- if (CHOICES[choice]) button(card, CHOICES[choice], () => perform({ operation: "input", id: login.id, revision: login.revision, action: { kind: "method", choice } }));
102
+ if (Object.hasOwn(CHOICES, choice)) button(card, choiceName(choice), () => perform({ operation: "input", id: login.id, revision: login.revision, action: { kind: "method", choice } }));
56
103
  }
57
104
  if (login.url) {
58
105
  // The host already allowlists these; still never turn a non-HTTPS URL into a link.
59
106
  let url; try { url = new URL(login.url); } catch {}
60
107
  if (url?.protocol === "https:" && !url.username && !url.password) {
61
- const link = el("a", "Open provider sign-in", card); link.href = url.href; link.target = "_blank"; link.rel = "noopener noreferrer";
108
+ const link = el("a", tr("openProvider"), card); link.href = url.href; link.target = "_blank"; link.rel = "noopener noreferrer";
62
109
  }
63
110
  }
64
- if (login.code) { el("p", "Device code:", card); el("code", login.code, card); }
111
+ if (login.code) { el("p", tr("deviceCode"), card); el("code", login.code, card); }
65
112
  if (login.canAct && ["code", "start_url", "region"].includes(login.phase)) {
66
- const label = el("label", { code: "Paste the returned code", start_url: "Organization Start URL", region: "AWS region" }[login.phase], card);
113
+ const label = el("label", tr("field_" + login.phase), card);
67
114
  const input = el("input", null, label); input.type = login.phase === "code" ? "password" : "text"; input.autocomplete = "off"; input.spellcheck = false;
68
115
  input.setAttribute("aria-label", label.textContent); input.disabled = busy;
69
- button(card, "Submit " + login.phase.replaceAll("_", " "), () => { const value = input.value; input.value = ""; void perform({ operation: "input", id: login.id, revision: login.revision, action: { kind: login.phase, value } }); });
116
+ button(card, tr("submit", phaseName(login.phase)), () => { const value = input.value; input.value = ""; void perform({ operation: "input", id: login.id, revision: login.revision, action: { kind: login.phase, value } }); });
70
117
  }
71
- if (["method", "code", "start_url", "region"].includes(login.phase) && !login.canAct) el("p", "Answer sent. Waiting for the next screen; it will not be sent twice.", card);
72
- button(card, "Cancel sign-in", () => perform({ operation: "cancel" }));
118
+ if (["method", "code", "start_url", "region"].includes(login.phase) && !login.canAct) el("p", tr("answerSent"), card);
119
+ button(card, tr("cancel"), () => perform({ operation: "cancel" }));
73
120
  } else {
74
121
  if (login?.reason && login.reason !== "cancelled") el("p", errorText(login.reason), card);
75
122
  const usable = !["antigravity"].includes(backend) && state !== "not_installed";
76
- if (usable) button(card, state === "valid" ? "Sign in again" : "Sign in", () => {
123
+ if (usable) button(card, tr(state === "valid" ? "signInAgain" : "signIn"), () => {
77
124
  const relogin = state === "valid";
78
- if (relogin && !globalThis.confirm("Sign in again? Kiro will sign out its existing account first.")) return;
125
+ if (relogin && !globalThis.confirm(tr("relogin"))) return;
79
126
  void perform({ operation: "start", backend, relogin });
80
127
  });
81
128
  }
82
- if (pending && !skipped) button(card, "Sign in later", () => perform({ operation: "skip", backend }));
129
+ if (pending && !skipped) button(card, tr("later"), () => perform({ operation: "skip", backend }));
83
130
  }
84
- button(root, "Check sign-ins", () => perform({ operation: "refresh" }));
85
- if (view.ready) el("p", "You can continue setup.");
131
+ button(root, tr("check"), () => perform({ operation: "refresh" }));
132
+ if (view.ready) el("p", tr("ready"));
86
133
  }
87
134
  async function poll() {
88
135
  if (disposed) return;
89
136
  const before = generation;
90
137
  if (!busy) try { const next = await request(); if (!disposed && before === generation) { accept(next); render(); } }
91
- catch (error) { if (!disposed && before === generation) { message = errorText(error?.message); render(); } }
138
+ catch (error) { if (!disposed && before === generation) { message = String(error?.message || "error"); render(); } }
92
139
  if (!disposed) timer = setTimeout(poll, 1000);
93
140
  }
94
141
  render(); void poll();
@@ -98,6 +145,8 @@ export function mountStructuredSignIns(root, { endpoint, fetcher = fetch, change
98
145
  return perform({ operation: "select", backends: [...new Set([...view.selected, ...backends])] });
99
146
  },
100
147
  addBackend(backend) { if (view && NAMES[backend] && !view.selected.includes(backend)) return perform({ operation: "select", backends: [...view.selected, backend] }); },
148
+ /** Draw it again in the page's language now (it also follows on its next poll). */
149
+ relabel() { render(); },
101
150
  dispose() { disposed = true; generation++; clearTimeout(timer); root.replaceChildren(); },
102
151
  };
103
152
  }
@@ -111,5 +160,7 @@ if (setupRoot) {
111
160
  const observer = new MutationObserver(select); if (backend) observer.observe(backend, { childList: true });
112
161
  // Initial GET may finish after the environment list, so also observe our readiness result.
113
162
  const ready = new MutationObserver(select); ready.observe(setupRoot, { attributes: true, attributeFilter: ["data-ready"] });
114
- addEventListener("pagehide", () => { observer.disconnect(); ready.disconnect(); cards.dispose(); }, { once: true });
163
+ // #2726: the page's language toggle changes <html lang>; the cards follow at once.
164
+ const language = new MutationObserver(() => cards.relabel()); language.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
165
+ addEventListener("pagehide", () => { observer.disconnect(); ready.disconnect(); language.disconnect(); cards.dispose(); }, { once: true });
115
166
  }
@@ -58,6 +58,21 @@ export type OfficeWrite = {
58
58
  };
59
59
  /** A whole list of offices, as a person sends it: every rule, or a refusal naming where it broke. */
60
60
  export declare function checkOffices(raw: unknown, packOf?: OverridePack): OfficeCheck;
61
+ /** The overrides parts kept beside the offices on disk, apart from the rest (#2665 night places, #2691 seat reservations). */
62
+ declare const BESIDE: readonly ["furnitureNight", "seatFor"];
63
+ type Beside = (typeof BESIDE)[number];
64
+ type OnDisk = {
65
+ offices: Office[];
66
+ overrides?: Record<string, LayoutOverrides>;
67
+ } & {
68
+ [K in Beside]?: Record<string, NonNullable<LayoutOverrides[K]>>;
69
+ };
70
+ /**
71
+ * #2665/#2706: what goes on disk — the offices without their overrides; beside them, by office id, each office's
72
+ * overrides without those parts, and each part on its own (none: no key). The maps have no prototype (#2708 review), so
73
+ * an id is always an own key; exported for tests.
74
+ */
75
+ export declare function officesOnDisk(offices: Office[]): OnDisk;
61
76
  export declare class OfficeStore {
62
77
  private readonly packOf?;
63
78
  private state;
@@ -111,3 +126,4 @@ export declare class OfficeWriteLimiter {
111
126
  /** Count an accepted save. */
112
127
  record(person: string): void;
113
128
  }
129
+ export {};
@@ -32,6 +32,17 @@
32
32
  * { version: 1, rev, offices: [ … ], furnitureNight: { … }, seatFor: { "<office id>": { "<area>": { "<slot>": { for, lend } } } } }
33
33
  *
34
34
  * — each read back on its own: reservations that no longer check leave the night places (and the office) in.
35
+ *
36
+ * #2706: the rest of an office's overrides are kept beside it too, by office id, never in its entry — 2.3.1 refuses an
37
+ * entry with an `overrides` key, drops that office on read, and its next save deletes it. So 2.3.1 (and a host before
38
+ * #2513) keeps every office, only without its layout —
39
+ *
40
+ * { version: 1, rev, offices: [ { id, name, skin, members } … ], overrides: { "<office id>": { pack, seats, … } }, furnitureNight: { … }, seatFor: { … } }
41
+ *
42
+ * — and a 2.3.2 beta before #2706 reads every office the same way (it looks for overrides in the entry only). Read
43
+ * here, an office's overrides come from beside it, else (a file a beta before #2706 wrote) from its entry, and the next
44
+ * write moves them beside it. Overrides that do not check leave the office in, without them (and so without its night
45
+ * places and reservations, which go on them).
35
46
  */
36
47
  import { readFileSync } from "node:fs";
37
48
  import { join } from "node:path";
@@ -44,6 +55,8 @@ export const OFFICE_LIMITS = {
44
55
  /** The page's own office (fleet-office-model.js AUTO_ID): never a stored one's id. */
45
56
  export const AUTO_OFFICE_ID = "auto";
46
57
  const ID = /^[A-Za-z0-9_-]{1,40}$/;
58
+ /** #2708 review: ids an object already has a meaning for — never an office's (its overrides are kept in maps by office id). */
59
+ const INHERITED_IDS = new Set(["__proto__", "constructor", "prototype"]);
47
60
  const POINT_ID = /^[A-Za-z0-9_.:-]{1,64}$/;
48
61
  const CONTROL = /[\u0000-\u001f\u007f]/;
49
62
  class Refused extends Error {
@@ -145,6 +158,8 @@ function office(v, at, packOf) {
145
158
  throw new Refused(`${at}.id`, "1–40 letters, digits, _ or -");
146
159
  if (v.id === AUTO_OFFICE_ID)
147
160
  throw new Refused(`${at}.id`, `"${AUTO_OFFICE_ID}" is the page's own office`);
161
+ if (INHERITED_IDS.has(v.id))
162
+ throw new Refused(`${at}.id`, "not __proto__, constructor or prototype");
148
163
  const skin = v.skin === undefined ? "pixel" : typeof v.skin === "string" && ID.test(v.skin) ? v.skin : null;
149
164
  if (skin === null)
150
165
  throw new Refused(`${at}.skin`, "1–40 letters, digits, _ or -");
@@ -175,28 +190,34 @@ export function checkOffices(raw, packOf) {
175
190
  throw err;
176
191
  }
177
192
  }
178
- /** The overrides kept beside the offices on disk, never inside them (#2665 night places, #2691 seat reservations). */
193
+ /** The overrides parts kept beside the offices on disk, apart from the rest (#2665 night places, #2691 seat reservations). */
179
194
  const BESIDE = ["furnitureNight", "seatFor"];
180
- /** #2665: what goes on disk — the offices without those overrides, and each beside them by office id (none: no key). */
181
- function onDisk(offices) {
195
+ /**
196
+ * #2665/#2706: what goes on disk — the offices without their overrides; beside them, by office id, each office's
197
+ * overrides without those parts, and each part on its own (none: no key). The maps have no prototype (#2708 review), so
198
+ * an id is always an own key; exported for tests.
199
+ */
200
+ export function officesOnDisk(offices) {
182
201
  const out = { offices: [] };
183
202
  out.offices = offices.map(o => {
184
- if (!o.overrides || !BESIDE.some(k => o.overrides[k] !== undefined))
203
+ if (!o.overrides)
185
204
  return o;
186
- const rest = { ...o.overrides };
205
+ const { overrides, ...entry } = o, rest = { ...overrides };
187
206
  for (const k of BESIDE) {
188
207
  if (rest[k] === undefined)
189
208
  continue;
190
- (out[k] ??= {})[o.id] = rest[k];
209
+ (out[k] ??= Object.create(null))[o.id] = rest[k];
191
210
  delete rest[k];
192
211
  }
193
- return { ...o, overrides: rest };
212
+ (out.overrides ??= Object.create(null))[o.id] = rest;
213
+ return entry;
194
214
  });
195
215
  return out;
196
216
  }
217
+ const own = (side, id) => isObj(side) && Object.prototype.hasOwnProperty.call(side, id);
197
218
  /** #2665: a stored office with its `key` overrides (kept beside it on disk, in `side`) back on its overrides. */
198
219
  function withBeside(raw, key, side) {
199
- if (!isObj(raw) || !isObj(side) || typeof raw.id !== "string" || !Object.prototype.hasOwnProperty.call(side, raw.id) || !isObj(raw.overrides))
220
+ if (!isObj(raw) || typeof raw.id !== "string" || !own(side, raw.id) || !isObj(raw.overrides))
200
221
  return raw;
201
222
  return { ...raw, overrides: { ...raw.overrides, [key]: side[raw.id] } };
202
223
  }
@@ -236,8 +257,21 @@ export class OfficeStore {
236
257
  }
237
258
  };
238
259
  for (const raw of doc.offices.slice(0, OFFICE_LIMITS.offices)) {
260
+ // #2706: the office first, without overrides; then its overrides (beside it, else in its entry: a beta before
261
+ // #2706 wrote them there), left out when they do not check, the office kept.
262
+ if (!isObj(raw))
263
+ continue;
264
+ const { overrides: inEntry, ...entry } = raw;
265
+ let cur = entry, o = read(entry);
266
+ const ov = typeof raw.id === "string" && own(doc.overrides, raw.id) ? doc.overrides[raw.id] : inEntry;
267
+ if (o && ov !== undefined) {
268
+ const next = { ...entry, overrides: ov }, r = read(next);
269
+ if (r) {
270
+ cur = next;
271
+ o = r;
272
+ }
273
+ }
239
274
  // Each kept beside put back in turn: one that does not check is left out, the office and the rest kept.
240
- let cur = raw, o = read(raw);
241
275
  for (const k of BESIDE) {
242
276
  const next = o ? withBeside(cur, k, doc[k]) : cur;
243
277
  if (next === cur)
@@ -282,7 +316,7 @@ export class OfficeStore {
282
316
  return checked;
283
317
  const rev = s.rev + 1;
284
318
  try {
285
- atomicWriteFileSync(this.path, JSON.stringify({ version: 1, rev, ...onDisk(checked.offices) }, null, 2) + "\n", { mode: 0o600 });
319
+ atomicWriteFileSync(this.path, JSON.stringify({ version: 1, rev, ...officesOnDisk(checked.offices) }, null, 2) + "\n", { mode: 0o600 });
286
320
  }
287
321
  catch (err) {
288
322
  return { ok: false, status: 503, error: "offices_write_failed", detail: err.message };