@engenty/wizards-runtime 0.11.6 → 0.11.8

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 (117) hide show
  1. package/apps/runtime/dist/agents/architect.js +37 -53
  2. package/apps/runtime/dist/agents/company.js +4 -12
  3. package/apps/runtime/dist/agents/studio-assistant.js +57 -70
  4. package/apps/runtime/dist/agents/subscription.js +3 -6
  5. package/apps/runtime/dist/app.js +3 -0
  6. package/apps/runtime/dist/assistant/knows.js +19 -19
  7. package/apps/runtime/dist/auth/account.js +51 -12
  8. package/apps/runtime/dist/authoring/guide.js +20 -447
  9. package/apps/runtime/dist/browser/fast/run.js +18 -12
  10. package/apps/runtime/dist/cli/account.js +127 -10
  11. package/apps/runtime/dist/cli/main.js +4 -2
  12. package/apps/runtime/dist/connectors/mail.js +4 -3
  13. package/apps/runtime/dist/documents/parse.js +5 -14
  14. package/apps/runtime/dist/engine/decide.js +2 -1
  15. package/apps/runtime/dist/engine/runner.js +4 -3
  16. package/apps/runtime/dist/engine/steps.js +82 -91
  17. package/apps/runtime/dist/engine/template.js +2 -3
  18. package/apps/runtime/dist/harness/antigravity.js +2 -2
  19. package/apps/runtime/dist/harness/apple.js +4 -6
  20. package/apps/runtime/dist/harness/codex.js +5 -6
  21. package/apps/runtime/dist/harness/prompt.js +8 -8
  22. package/apps/runtime/dist/mcp/handler.js +5 -7
  23. package/apps/runtime/dist/mcp/tools.js +33 -54
  24. package/apps/runtime/dist/media/conversation.js +18 -23
  25. package/apps/runtime/dist/media/generate.js +18 -3
  26. package/apps/runtime/dist/media/transcribe.js +5 -4
  27. package/apps/runtime/dist/motion-graphics/project.js +19 -53
  28. package/apps/runtime/dist/motion-graphics/sounds.js +2 -1
  29. package/apps/runtime/dist/motion-graphics/step.js +31 -16
  30. package/apps/runtime/dist/open-command.js +31 -0
  31. package/apps/runtime/dist/prompts/README.md +48 -0
  32. package/apps/runtime/dist/prompts/architect.md +89 -0
  33. package/apps/runtime/dist/prompts/authoring.md +503 -0
  34. package/apps/runtime/dist/prompts/goose.md +229 -0
  35. package/apps/runtime/dist/prompts/mcp.md +156 -0
  36. package/apps/runtime/dist/prompts/safety.md +23 -0
  37. package/apps/runtime/dist/prompts/services.md +151 -0
  38. package/apps/runtime/dist/prompts/step.md +334 -0
  39. package/apps/runtime/dist/prompts/tools.md +330 -0
  40. package/apps/runtime/dist/prompts/voice.md +53 -0
  41. package/apps/runtime/dist/prompts.js +50 -0
  42. package/apps/runtime/dist/routes/studio.js +19 -1
  43. package/apps/runtime/dist/safety.js +45 -0
  44. package/apps/runtime/dist/sandbox/index.js +8 -3
  45. package/apps/runtime/dist/services/assistant-chats.js +5 -8
  46. package/apps/runtime/dist/services/brand.js +2 -7
  47. package/apps/runtime/dist/services/cloud.js +8 -4
  48. package/apps/runtime/dist/services/knowledge-model.js +17 -8
  49. package/apps/runtime/dist/services/knowledge.js +5 -9
  50. package/apps/runtime/dist/services/project-files.js +3 -8
  51. package/apps/runtime/dist/services/relevance.js +4 -3
  52. package/apps/runtime/dist/services/runs.js +6 -7
  53. package/apps/runtime/dist/services/site.js +2 -2
  54. package/apps/runtime/dist/services/translations.js +17 -10
  55. package/apps/runtime/dist/sync/client.js +116 -1
  56. package/apps/runtime/dist/tools/browser.js +36 -33
  57. package/apps/runtime/dist/tools/code.js +20 -6
  58. package/apps/runtime/dist/tools/connector.js +23 -9
  59. package/apps/runtime/dist/tools/index.js +14 -11
  60. package/apps/runtime/dist/tools/mail.js +5 -5
  61. package/apps/runtime/dist/tools/net-guard.js +4 -4
  62. package/apps/runtime/dist/tools/pages.js +3 -2
  63. package/apps/runtime/dist/tools/project.js +7 -8
  64. package/apps/runtime/dist/tools/store.js +14 -10
  65. package/apps/web/dist/assets/{AboutDialog-30Mc1_N_.js → AboutDialog-BWc0zi6S.js} +1 -1
  66. package/apps/web/dist/assets/{ChangelogDialog-Vjxg6JV8.js → ChangelogDialog-Ctkpgtt8.js} +1 -1
  67. package/apps/web/dist/assets/{CodeEditor-CmMRfVhS.js → CodeEditor-ydfkafOX.js} +1 -1
  68. package/apps/web/dist/assets/{EditorPage-Di5KB-Ei.js → EditorPage-C2lCK9wY.js} +1 -1
  69. package/apps/web/dist/assets/{FlowPreview-BkcO3iCf.js → FlowPreview-CPEK110v.js} +1 -1
  70. package/apps/web/dist/assets/{Harness-D_Hr80Fo.js → Harness-CeEYZGHB.js} +1 -1
  71. package/apps/web/dist/assets/Marketplace-_IfcAgYO.js +2 -0
  72. package/apps/web/dist/assets/{NewWizardChannels-BIzOtfc8.js → NewWizardChannels-Rq4Oc1OM.js} +1 -1
  73. package/apps/web/dist/assets/{NewWizardPage-BenzMrPD.js → NewWizardPage-CCR_U2vH.js} +1 -1
  74. package/apps/web/dist/assets/{OnboardingPage-DuckyzQr.js → OnboardingPage-CcaxqyzN.js} +1 -1
  75. package/apps/web/dist/assets/{PreviewPane-D9hmriSm.js → PreviewPane-By692ez7.js} +2 -2
  76. package/apps/web/dist/assets/{ProjectPage-A8Z8cS1E.js → ProjectPage-ClMgq06-.js} +1 -1
  77. package/apps/web/dist/assets/PublicRunner-BtUu5LCy.js +1 -0
  78. package/apps/web/dist/assets/{ReadOnly-DFn32cvo.js → ReadOnly-B2BSJ7ms.js} +1 -1
  79. package/apps/web/dist/assets/SettingsPage-DGHco15-.js +2 -0
  80. package/apps/web/dist/assets/{SetupPage-WNHH74hu.js → SetupPage-CNJY56MI.js} +1 -1
  81. package/apps/web/dist/assets/{SharePage-Bw4TRWtv.js → SharePage-ZolaYse9.js} +1 -1
  82. package/apps/web/dist/assets/changelog-CWPHX0Hf.js +1 -0
  83. package/apps/web/dist/assets/i18n-BX8GnEZT.js +55 -0
  84. package/apps/web/dist/assets/index-5U3h_chZ.js +34 -0
  85. package/apps/web/dist/assets/{index-Bha72INy.css → index-BYZBN0xx.css} +1 -1
  86. package/apps/web/dist/assets/{oss-credits-CZT1KRIp.js → oss-credits-Da4KrYmP.js} +1 -1
  87. package/apps/web/dist/assets/{phone-DymZ7rLO.js → phone-Dd7IVbpJ.js} +1 -1
  88. package/apps/web/dist/assets/{runners-UfKeoOe4.js → runners-XifDCQG3.js} +1 -1
  89. package/apps/web/dist/assets/{session-COf_im0l.js → session-BwtsznZF.js} +1 -1
  90. package/apps/web/dist/assets/{settings-menu-mtOjI15L.js → settings-menu-CS-fXrFW.js} +1 -1
  91. package/apps/web/dist/assets/{theme-DWoTWDAG.js → theme-CnRjADMg.js} +2 -2
  92. package/apps/web/dist/assets/ui-D719V_Yj.js +83 -0
  93. package/apps/web/dist/assets/{upload-BizIzwxa.js → upload-CYTDCrYd.js} +1 -1
  94. package/apps/web/dist/assets/{useMutation-BJfRETsQ.js → useMutation-CVVmJvyz.js} +1 -1
  95. package/apps/web/dist/assets/{volume-2-BGkyA8T9.js → volume-2-Do0dsjv2.js} +1 -1
  96. package/apps/web/dist/assets/{wrench-Be5zav03.js → wrench-C5syJD9J.js} +1 -1
  97. package/apps/web/dist/index.html +8 -9
  98. package/apps/web/dist/mcp/flow.html +87 -87
  99. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +5 -0
  100. package/node_modules/@engenty/wizards-shared/dist/run.js +10 -0
  101. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +3 -1
  102. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +2 -0
  103. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +0 -2
  104. package/node_modules/@engenty/wizards-shared/dist/surface.js +0 -29
  105. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +5 -0
  106. package/package.json +2 -2
  107. package/plugin/.claude-plugin/plugin.json +1 -1
  108. package/plugin/plugin.json +1 -1
  109. package/apps/runtime/dist/assistant/primer.js +0 -26
  110. package/apps/web/dist/assets/Marketplace-BxFBMUsi.js +0 -2
  111. package/apps/web/dist/assets/PublicRunner-QPvlEAxx.js +0 -1
  112. package/apps/web/dist/assets/SettingsPage-ByP15ndy.js +0 -2
  113. package/apps/web/dist/assets/changelog-Dr9tAFY9.js +0 -1
  114. package/apps/web/dist/assets/coins-DTH3SKgZ.js +0 -1
  115. package/apps/web/dist/assets/i18n-CLxuuhp_.js +0 -55
  116. package/apps/web/dist/assets/index-HhslPV6N.js +0 -34
  117. package/apps/web/dist/assets/ui-D_0Xdrjh.js +0 -83
@@ -10,6 +10,7 @@ import { detectHarnesses } from "../harness/index.js";
10
10
  import { managed, publicPlans, tenantInfo, tenantUsage } from "../manage.js";
11
11
  import { classWays, waysIn } from "../models.js";
12
12
  import { pluginToolsOf } from "../plugins/registry.js";
13
+ import { prompt } from "../prompts.js";
13
14
  import { earlierChats, readChat, searchChats } from "../services/assistant-chats.js";
14
15
  import { asLang, marketplaceDetail, searchMarketplace } from "../services/marketplace.js";
15
16
  import { listWizards } from "../services/wizards.js";
@@ -35,7 +36,6 @@ async function usageOf(tenantId) {
35
36
  }
36
37
  return (await res.json());
37
38
  }
38
- const NOT_LINKED = "This install is not linked to an account. Settings › Account signs one in; then credits, cloud publishing and plans apply. Docs and the gallery work without one.";
39
39
  export function knowsTools(ctx) {
40
40
  const { user } = ctx;
41
41
  // The entries this turn's searches found, so show_templates needs no second request.
@@ -43,7 +43,7 @@ export function knowsTools(ctx) {
43
43
  return {
44
44
  docs_search: createTool({
45
45
  id: "docs_search",
46
- description: "Search the engenty wizards user guide and plugin guide of this installed version. Gives the best sections with an excerpt and their engenty.ai/docs link. Use it before you explain how something works.",
46
+ description: prompt("goose", "tool.docs_search"),
47
47
  inputSchema: z.object({ query: z.string().min(2).max(200) }),
48
48
  execute: async ({ query }) => {
49
49
  ctx.doing(serverText(ctx.lang, "doingReadGuide"));
@@ -52,7 +52,7 @@ export function knowsTools(ctx) {
52
52
  }),
53
53
  docs_read: createTool({
54
54
  id: "docs_read",
55
- description: "Read one page of the guides by its id from docs_search (user/steps, dev/plugins/tools), from a character on.",
55
+ description: prompt("goose", "tool.docs_read"),
56
56
  inputSchema: z.object({
57
57
  page: z.string().min(1).max(200),
58
58
  from: z.number().int().min(0).optional(),
@@ -64,7 +64,7 @@ export function knowsTools(ctx) {
64
64
  }),
65
65
  authoring_guide: createTool({
66
66
  id: "authoring_guide",
67
- description: "The authoring guide the wizard editor and AI apps build with: how a wizard is written (steps, fields, flows, tools, outputs, model classes). Long: read it in parts with `from`.",
67
+ description: prompt("goose", "tool.authoring_guide"),
68
68
  inputSchema: z.object({ from: z.number().int().min(0).optional() }),
69
69
  execute: ({ from }) => attempt(async () => {
70
70
  ctx.doing(serverText(ctx.lang, "doingAuthoringGuide"));
@@ -78,7 +78,7 @@ export function knowsTools(ctx) {
78
78
  }),
79
79
  gallery_search: createTool({
80
80
  id: "gallery_search",
81
- description: "Search the gallery of wizard templates (engenty.ai/wizards and the plugins' starters): title, pitch, what it needs that this install has no model for, and its price per run in credits.",
81
+ description: prompt("goose", "tool.gallery_search"),
82
82
  inputSchema: z.object({ query: z.string().max(200).optional() }),
83
83
  execute: ({ query }) => attempt(async () => {
84
84
  ctx.doing(serverText(ctx.lang, "doingGallery"));
@@ -109,7 +109,7 @@ export function knowsTools(ctx) {
109
109
  }),
110
110
  gallery_detail: createTool({
111
111
  id: "gallery_detail",
112
- description: "One template of the gallery: what it does, its steps, what it makes and needs.",
112
+ description: prompt("goose", "tool.gallery_detail"),
113
113
  inputSchema: z.object({ id: z.string().min(1).max(120) }),
114
114
  execute: ({ id }) => attempt(async () => {
115
115
  const detail = await marketplaceDetail(id, asLang(ctx.lang));
@@ -122,7 +122,7 @@ export function knowsTools(ctx) {
122
122
  }),
123
123
  show_templates: createTool({
124
124
  id: "show_templates",
125
- description: "Show templates of the gallery as cards under your answer, in the order given. A card shows the title, the pitch, the time, the cost and what it makes; the person opens it to see the steps and make a wizard of it.",
125
+ description: prompt("goose", "tool.show_templates"),
126
126
  inputSchema: z.object({ ids: z.array(z.string().min(1).max(120)).min(1).max(6) }),
127
127
  execute: ({ ids }) => attempt(async () => {
128
128
  const entries = [];
@@ -144,7 +144,7 @@ export function knowsTools(ctx) {
144
144
  }),
145
145
  plans: createTool({
146
146
  id: "plans",
147
- description: "The plans organizations can be on (Free, Pro, Team): price a month, monthly credits, limits, and the credit packages to buy on top. Live from the account service.",
147
+ description: prompt("goose", "tool.plans"),
148
148
  inputSchema: z.object({}),
149
149
  execute: () => attempt(async () => {
150
150
  ctx.doing(serverText(ctx.lang, "doingPlans"));
@@ -154,7 +154,7 @@ export function knowsTools(ctx) {
154
154
  }),
155
155
  account: createTool({
156
156
  id: "account",
157
- description: "The person, their organization, their role, the organization's plan, the credit balance and credits that end on a date.",
157
+ description: prompt("goose", "tool.account"),
158
158
  inputSchema: z.object({}),
159
159
  execute: () => attempt(async () => {
160
160
  ctx.doing(serverText(ctx.lang, "doingAccount"));
@@ -169,14 +169,14 @@ export function knowsTools(ctx) {
169
169
  };
170
170
  }
171
171
  if (!(await linkedAccount())) {
172
- return { linked: false, note: NOT_LINKED };
172
+ return { linked: false, note: prompt("goose", "note.not_linked") };
173
173
  }
174
174
  const overview = await accountOverview();
175
175
  if (!overview) {
176
176
  return {
177
177
  linked: true,
178
178
  signedIn: false,
179
- note: "The sign-in ran out: Settings › Account signs in again.",
179
+ note: prompt("goose", "note.signed_out"),
180
180
  };
181
181
  }
182
182
  return {
@@ -192,16 +192,16 @@ export function knowsTools(ctx) {
192
192
  }),
193
193
  usage: createTool({
194
194
  id: "usage",
195
- description: "Credits the organization used per month (the last three), and the runs and wizards that cost the most.",
195
+ description: prompt("goose", "tool.usage"),
196
196
  inputSchema: z.object({}),
197
197
  execute: () => attempt(async () => {
198
198
  ctx.doing(serverText(ctx.lang, "doingUsage"));
199
199
  if (!(managed || (await linkedAccount()))) {
200
- return { linked: false, note: NOT_LINKED };
200
+ return { linked: false, note: prompt("goose", "note.not_linked") };
201
201
  }
202
202
  const usage = await usageOf(user.tenantId);
203
203
  if (!usage) {
204
- return { note: "The sign-in ran out: Settings › Account signs in again." };
204
+ return { note: prompt("goose", "note.signed_out") };
205
205
  }
206
206
  const runIds = [...new Set(usage.months.flatMap((m) => m.runs.map((r) => r.runId)))];
207
207
  const runs = runIds.length
@@ -236,7 +236,7 @@ export function knowsTools(ctx) {
236
236
  }),
237
237
  wizards: createTool({
238
238
  id: "wizards",
239
- description: "The space's wizards: title, description, published or draft, whether its link is on, steps, last change.",
239
+ description: prompt("goose", "tool.wizards"),
240
240
  inputSchema: z.object({}),
241
241
  execute: () => attempt(async () => {
242
242
  if (!ctx.project) {
@@ -258,7 +258,7 @@ export function knowsTools(ctx) {
258
258
  }),
259
259
  runs: createTool({
260
260
  id: "runs",
261
- description: "The space's latest runs, newest first: wizard, test or live, status, the error of a failed one.",
261
+ description: prompt("goose", "tool.runs"),
262
262
  inputSchema: z.object({
263
263
  status: z.enum(["failed", "done", "running", "waiting_input", "cancelled"]).optional(),
264
264
  limit: z.number().int().min(1).max(40).optional(),
@@ -294,7 +294,7 @@ export function knowsTools(ctx) {
294
294
  }),
295
295
  models: createTool({
296
296
  id: "models",
297
- description: "What thinks and makes for this install, per model class: an installed AI client, an own key, a local model, credits, or nothing (with the problem). Also which AI clients are installed and signed in.",
297
+ description: prompt("goose", "tool.models"),
298
298
  inputSchema: z.object({}),
299
299
  execute: () => attempt(async () => {
300
300
  ctx.doing(serverText(ctx.lang, "doingModels"));
@@ -313,7 +313,7 @@ export function knowsTools(ctx) {
313
313
  }),
314
314
  chats_search: createTool({
315
315
  id: "chats_search",
316
- description: "Search the person's earlier chats with you (their messages and summaries) for words: what was asked, changed or decided before.",
316
+ description: prompt("goose", "tool.chats_search"),
317
317
  inputSchema: z.object({ query: z.string().min(3).max(200) }),
318
318
  execute: ({ query }) => attempt(async () => {
319
319
  ctx.doing(serverText(ctx.lang, "doingEarlierChats"));
@@ -332,7 +332,7 @@ export function knowsTools(ctx) {
332
332
  }),
333
333
  chat_read: createTool({
334
334
  id: "chat_read",
335
- description: "Read one earlier chat by its id (from chats_search): its summary and messages.",
335
+ description: prompt("goose", "tool.chat_read"),
336
336
  inputSchema: z.object({ id: z.string().min(1).max(40) }),
337
337
  execute: ({ id }) => attempt(async () => {
338
338
  const chat = await readChat(user, id);
@@ -21,6 +21,8 @@ function redirectUri() {
21
21
  /**
22
22
  * The address that links an account. `signup`: the person has none yet — the account's sign-up
23
23
  * page takes the invitation code (`code` fills it in) and goes on to the same sign-in.
24
+ * `organization` (its id or address) names the organization to sign in to: a member gets it
25
+ * without the picker, a switch.
24
26
  */
25
27
  export async function startLink(options = {}) {
26
28
  const d = await discovery(env.local.accountUrl);
@@ -36,6 +38,7 @@ export async function startLink(options = {}) {
36
38
  code_challenge: createHash("sha256").update(verifier).digest("base64url"),
37
39
  code_challenge_method: "S256",
38
40
  state: seal(state),
41
+ ...(options.organization ? { organization: options.organization } : {}),
39
42
  }).toString();
40
43
  if (!options.signup) {
41
44
  return url.toString();
@@ -50,21 +53,47 @@ export async function startLink(options = {}) {
50
53
  return signUp.toString();
51
54
  }
52
55
  let cached = null;
56
+ /** The organization last written to the settings, so an unchanged one is not written again. */
57
+ let rememberedOrganization = null;
53
58
  /**
54
59
  * Keeps what the token endpoint handed out: the refresh token in the vault, the account in the
55
- * settings. The browser flow (finishLink) and the device flow (device.ts) end here alike.
60
+ * settings. The browser flow (finishLink) and the device flow (device.ts) end here alike. A
61
+ * token for another organization than before is a switch: the sync of the one before is
62
+ * forgotten first, so nothing of it goes up to the new one (sync/client.ts).
56
63
  */
57
64
  export async function keep(tokens) {
58
65
  const claims = unverifiedClaims(tokens.access_token);
59
66
  if (!claims) {
60
67
  throw new Error("The account's token names no tenant.");
61
68
  }
69
+ const before = await linkedAccount();
70
+ const switched = Boolean(before && before.tenantId !== claims.tenantId);
71
+ const oldRefresh = switched ? await vaultGet(REFRESH) : null;
72
+ if (switched) {
73
+ cached = null;
74
+ // Loaded here: the sync reads the account this module keeps.
75
+ const [{ forgetCloud }, sync, { withTenant }, { LOCAL_TENANT }] = await Promise.all([
76
+ import("../services/cloud.js"),
77
+ import("../sync/client.js"),
78
+ import("../db/client.js"),
79
+ import("../tenants/tenant.js"),
80
+ ]);
81
+ // The browser's callback and a terminal come here without the install's tenant.
82
+ await withTenant(LOCAL_TENANT, async () => {
83
+ await sync.noteSyncedSpaces();
84
+ await forgetCloud();
85
+ await sync.keepUnsyncedHere();
86
+ });
87
+ rememberedOrganization = null;
88
+ await deleteSetting(ORGANIZATION);
89
+ }
62
90
  if (tokens.refresh_token) {
63
91
  await vaultSet(REFRESH, tokens.refresh_token);
64
92
  }
65
93
  cached = {
66
94
  token: tokens.access_token,
67
95
  expiresAt: Date.now() + (tokens.expires_in ?? 600) * 1000,
96
+ tenantId: claims.tenantId,
68
97
  };
69
98
  const account = {
70
99
  userId: claims.userId,
@@ -73,8 +102,23 @@ export async function keep(tokens) {
73
102
  email: claims.email,
74
103
  };
75
104
  await writeSetting("account", account);
105
+ if (oldRefresh && oldRefresh !== tokens.refresh_token) {
106
+ await revoke(oldRefresh);
107
+ }
76
108
  return account;
77
109
  }
110
+ /** Ends a refresh token at the Manage-App; a Manage-App out of reach lets it run out by itself. */
111
+ async function revoke(refresh) {
112
+ const d = await discovery(env.local.accountUrl).catch(() => null);
113
+ if (d?.revocation_endpoint) {
114
+ await fetch(d.revocation_endpoint, {
115
+ method: "POST",
116
+ headers: { "content-type": "application/x-www-form-urlencoded" },
117
+ body: new URLSearchParams({ token: refresh, client_id: CLIENT.id }),
118
+ signal: AbortSignal.timeout(10_000),
119
+ }).catch(() => undefined);
120
+ }
121
+ }
78
122
  export async function finishLink(code, rawState) {
79
123
  const state = unseal(rawState);
80
124
  if (!state || state.exp < Date.now()) {
@@ -95,7 +139,11 @@ export function linkedAccount() {
95
139
  /** A fresh access token of the linked account, or null when none is linked (or it was revoked). */
96
140
  export async function accountToken() {
97
141
  if (cached && cached.expiresAt - Date.now() > 60_000) {
98
- return cached.token;
142
+ // `wizards account switch` in a terminal changes the account under a runtime that runs.
143
+ if ((await linkedAccount())?.tenantId === cached.tenantId) {
144
+ return cached.token;
145
+ }
146
+ cached = null;
99
147
  }
100
148
  // One refresh at a time: a refresh token is used once, a second caller would be refused.
101
149
  refreshing ??= refreshAccount().finally(() => {
@@ -121,15 +169,7 @@ async function refreshAccount() {
121
169
  export async function unlink() {
122
170
  const refresh = await vaultGet(REFRESH);
123
171
  if (refresh) {
124
- const d = await discovery(env.local.accountUrl).catch(() => null);
125
- if (d?.revocation_endpoint) {
126
- await fetch(d.revocation_endpoint, {
127
- method: "POST",
128
- headers: { "content-type": "application/x-www-form-urlencoded" },
129
- body: new URLSearchParams({ token: refresh, client_id: CLIENT.id }),
130
- signal: AbortSignal.timeout(10_000),
131
- }).catch(() => undefined);
132
- }
172
+ await revoke(refresh);
133
173
  }
134
174
  cached = null;
135
175
  await vaultDelete(REFRESH);
@@ -140,7 +180,6 @@ export async function unlink() {
140
180
  export function knownOrganization() {
141
181
  return readSetting(ORGANIZATION);
142
182
  }
143
- let rememberedOrganization = null;
144
183
  async function rememberOrganization(tenant) {
145
184
  const same = `${tenant.id}\n${tenant.name}\n${tenant.balanceCredits}`;
146
185
  if (same === rememberedOrganization) {