@vellumai/assistant 0.11.4-dev.202608201811.0c1594d → 0.11.4-dev.202608202009.ccce214

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.11.4-dev.202608201811.0c1594d",
3
+ "version": "0.11.4-dev.202608202009.ccce214",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -237,7 +237,7 @@ describe("Invariant 2: no generic plaintext secret read API", () => {
237
237
  "tools/network/web-fetch.ts", // Firecrawl /scrape BYOK fetch provider API key lookup (firecrawl provider key)
238
238
  "workspace/default-provider-ensure.ts", // legacy anthropic echo disambiguation (vault key presence check)
239
239
  "providers/inference/connection-availability.ts", // shared (provider, connection) availability status (credential presence check only; value never leaves the helper)
240
- "plugin-api/resolve-credential.ts", // plugin-facing resolveCredential — reveal-equivalent plaintext read, scoped to the in-context plugin's own field
240
+ "plugin-api/resolve-credential.ts", // plugin-facing resolveCredential: reveal-equivalent plaintext read, scoped to the in-context plugin's own service
241
241
  "tools/credentials/store.ts", // shared credential write path (setSecureKeyAsync only; no reads) behind credentials/set and plugin-facing storeCredential
242
242
  ]);
243
243
 
@@ -102,21 +102,28 @@ describe("resolveCredential", () => {
102
102
  });
103
103
 
104
104
  describe("plugin scoping", () => {
105
- test("allows a plugin to resolve a credential whose field matches its name", async () => {
106
- seedCredential("openai", "acme", "scoped-secret");
107
- const value = await runInPluginContext("acme", () =>
108
- resolveCredential("openai/acme"),
105
+ test("allows a plugin to resolve a credential whose service matches its name", async () => {
106
+ seedCredential("imessage", "api_key", "comms-key");
107
+ const value = await runInPluginContext("imessage", () =>
108
+ resolveCredential("imessage/api_key"),
109
109
  );
110
- expect(value).toBe("scoped-secret");
110
+ expect(value).toBe("comms-key");
111
111
  });
112
112
 
113
- test("blocks a plugin from resolving a credential whose field differs from its name", async () => {
113
+ test("blocks a plugin from resolving another service", async () => {
114
114
  seedCredential("openai", "api_key", "sk-secret");
115
115
  await expect(
116
116
  runInPluginContext("acme", () => resolveCredential("openai/api_key")),
117
117
  ).rejects.toThrow(/out of scope/);
118
118
  });
119
119
 
120
+ test("blocks a plugin from resolving another service even when the field matches its name", async () => {
121
+ seedCredential("openai", "acme", "scoped-secret");
122
+ await expect(
123
+ runInPluginContext("acme", () => resolveCredential("openai/acme")),
124
+ ).rejects.toThrow(/out of scope/);
125
+ });
126
+
120
127
  test("does not read the secure backend when out of scope", async () => {
121
128
  seedCredential("openai", "api_key", "sk-secret");
122
129
  getSpy.mockClear();
@@ -126,15 +133,17 @@ describe("resolveCredential", () => {
126
133
  expect(getSpy).not.toHaveBeenCalled();
127
134
  });
128
135
 
129
- test("scoping applies by field only, across any service", async () => {
130
- seedCredential("stripe", "acme", "stripe-secret");
131
- seedCredential("openai", "acme", "openai-secret");
136
+ test("scoping applies to every field under the plugin's service", async () => {
137
+ seedCredential("imessage", "api_key", "comms-key");
138
+ seedCredential("imessage", "photon_project_id", "proj-id");
132
139
  await expect(
133
- runInPluginContext("acme", () => resolveCredential("stripe/acme")),
134
- ).resolves.toBe("stripe-secret");
140
+ runInPluginContext("imessage", () => resolveCredential("imessage/api_key")),
141
+ ).resolves.toBe("comms-key");
135
142
  await expect(
136
- runInPluginContext("acme", () => resolveCredential("openai/acme")),
137
- ).resolves.toBe("openai-secret");
143
+ runInPluginContext("imessage", () =>
144
+ resolveCredential("imessage/photon_project_id"),
145
+ ),
146
+ ).resolves.toBe("proj-id");
138
147
  });
139
148
  });
140
149
  });
@@ -40,7 +40,7 @@ const TEST_DIR = join(
40
40
  );
41
41
  const META_PATH = join(TEST_DIR, "metadata.json");
42
42
 
43
- /** The plugin every scoped case runs as: it owns the `acme` field. */
43
+ /** The plugin every scoped case runs as: it owns the `acme` service. */
44
44
  const PLUGIN = "acme";
45
45
 
46
46
  /** Run `fn` as the plugin would: inside its execution context. */
@@ -108,53 +108,53 @@ afterAll(() => {
108
108
  describe("storeCredential", () => {
109
109
  test("creates a credential from a service/field ref", async () => {
110
110
  const stored = await asPlugin(() =>
111
- storeCredential("openai/acme", "sk-secret"),
111
+ storeCredential("acme/api_key", "sk-secret"),
112
112
  );
113
113
 
114
- expect(stored.service).toBe("openai");
115
- expect(stored.field).toBe(PLUGIN);
114
+ expect(stored.service).toBe("acme");
115
+ expect(stored.field).toBe("api_key");
116
116
  expect(stored.credentialId).toBeTruthy();
117
- expect(secureStore.get(credentialKey("openai", "acme"))).toBe("sk-secret");
118
- expect(getCredentialMetadata("openai", "acme")?.credentialId).toBe(
117
+ expect(secureStore.get(credentialKey("acme", "api_key"))).toBe("sk-secret");
118
+ expect(getCredentialMetadata("acme", "api_key")?.credentialId).toBe(
119
119
  stored.credentialId,
120
120
  );
121
121
  });
122
122
 
123
123
  test("stores a value that resolveCredential reads back", async () => {
124
- await asPlugin(() => storeCredential("openai/acme", "sk-secret"));
124
+ await asPlugin(() => storeCredential("acme/api_key", "sk-secret"));
125
125
  await expect(
126
- asPlugin(() => resolveCredential("openai/acme")),
126
+ asPlugin(() => resolveCredential("acme/api_key")),
127
127
  ).resolves.toBe("sk-secret");
128
128
  });
129
129
 
130
130
  test("trims edge whitespace from the value", async () => {
131
- await asPlugin(() => storeCredential("openai/acme", " sk-secret\n"));
132
- expect(secureStore.get(credentialKey("openai", "acme"))).toBe("sk-secret");
131
+ await asPlugin(() => storeCredential("acme/api_key", " sk-secret\n"));
132
+ expect(secureStore.get(credentialKey("acme", "api_key"))).toBe("sk-secret");
133
133
  });
134
134
 
135
135
  test("records label and description on the credential metadata", async () => {
136
136
  await asPlugin(() =>
137
- storeCredential("openai/acme", "sk-secret", {
137
+ storeCredential("acme/api_key", "sk-secret", {
138
138
  label: "Acme key",
139
139
  description: "Used by the acme plugin",
140
140
  }),
141
141
  );
142
142
 
143
- const metadata = getCredentialMetadata("openai", "acme");
143
+ const metadata = getCredentialMetadata("acme", "api_key");
144
144
  expect(metadata?.alias).toBe("Acme key");
145
145
  expect(metadata?.usageDescription).toBe("Used by the acme plugin");
146
146
  });
147
147
 
148
148
  test("replaces the value of an existing credential named by UUID", async () => {
149
149
  const first = await asPlugin(() =>
150
- storeCredential("openai/acme", "sk-old"),
150
+ storeCredential("acme/api_key", "sk-old"),
151
151
  );
152
152
  const second = await asPlugin(() =>
153
153
  storeCredential(first.credentialId, "sk-new"),
154
154
  );
155
155
 
156
156
  expect(second).toEqual(first);
157
- expect(secureStore.get(credentialKey("openai", "acme"))).toBe("sk-new");
157
+ expect(secureStore.get(credentialKey("acme", "api_key"))).toBe("sk-new");
158
158
  });
159
159
 
160
160
  test("rejects a ref that names no credential and is not service/field", async () => {
@@ -166,7 +166,7 @@ describe("storeCredential", () => {
166
166
 
167
167
  test("rejects an empty value", async () => {
168
168
  await expect(
169
- asPlugin(() => storeCredential("openai/acme", " ")),
169
+ asPlugin(() => storeCredential("acme/api_key", " ")),
170
170
  ).rejects.toThrow(/value is required/);
171
171
  expect(setSpy).not.toHaveBeenCalled();
172
172
  });
@@ -174,19 +174,19 @@ describe("storeCredential", () => {
174
174
  test("surfaces a failed secure-backend write", async () => {
175
175
  writeSucceeds = false;
176
176
  await expect(
177
- asPlugin(() => storeCredential("openai/acme", "sk-secret")),
177
+ asPlugin(() => storeCredential("acme/api_key", "sk-secret")),
178
178
  ).rejects.toThrow(CredentialStoreError);
179
- expect(getCredentialMetadata("openai", "acme")).toBeUndefined();
179
+ expect(getCredentialMetadata("acme", "api_key")).toBeUndefined();
180
180
  });
181
181
 
182
182
  test("scrubs the stored value from recent transcripts", async () => {
183
- await asPlugin(() => storeCredential("openai/acme", "sk-secret"));
183
+ await asPlugin(() => storeCredential("acme/api_key", "sk-secret"));
184
184
  expect(scrubSpy).toHaveBeenCalledWith("sk-secret");
185
185
  });
186
186
 
187
187
  test("skips the transcript scrub when asked", async () => {
188
188
  await asPlugin(() =>
189
- storeCredential("openai/acme", "sk-secret", {
189
+ storeCredential("acme/api_key", "sk-secret", {
190
190
  skipTranscriptScrub: true,
191
191
  }),
192
192
  );
@@ -194,8 +194,8 @@ describe("storeCredential", () => {
194
194
  });
195
195
 
196
196
  test("reconciles the manual-token connection for the service", async () => {
197
- await asPlugin(() => storeCredential("openai/acme", "sk-secret"));
198
- expect(syncSpy).toHaveBeenCalledWith("openai");
197
+ await asPlugin(() => storeCredential("acme/api_key", "sk-secret"));
198
+ expect(syncSpy).toHaveBeenCalledWith("acme");
199
199
  });
200
200
 
201
201
  describe("plugin scoping", () => {
@@ -203,14 +203,14 @@ describe("storeCredential", () => {
203
203
  // A plugin's module body is evaluated outside any context. An unscoped
204
204
  // branch there would let top-level code overwrite the user's own
205
205
  // credentials, so the write is refused instead.
206
- await expect(storeCredential("openai/acme", "sk-secret")).rejects.toThrow(
206
+ await expect(storeCredential("acme/api_key", "sk-secret")).rejects.toThrow(
207
207
  /requires an active plugin execution context/,
208
208
  );
209
209
  expect(setSpy).not.toHaveBeenCalled();
210
- expect(getCredentialMetadata("openai", "acme")).toBeUndefined();
210
+ expect(getCredentialMetadata("acme", "api_key")).toBeUndefined();
211
211
  });
212
212
 
213
- test("blocks a plugin from storing a credential whose field differs from its name", async () => {
213
+ test("blocks a plugin from storing a credential it does not own", async () => {
214
214
  await expect(
215
215
  asPlugin(() => storeCredential("openai/api_key", "sk-secret")),
216
216
  ).rejects.toThrow(/out of scope/);
@@ -244,17 +244,24 @@ describe("storeCredential", () => {
244
244
  );
245
245
  });
246
246
 
247
- test("scoping applies by field only, across any service", async () => {
247
+ test("blocks a plugin from storing another service even when the field matches its name", async () => {
248
+ await expect(
249
+ asPlugin(() => storeCredential("openai/acme", "sk-secret")),
250
+ ).rejects.toThrow(/out of scope/);
251
+ expect(setSpy).not.toHaveBeenCalled();
252
+ });
253
+
254
+ test("allows a plugin to store multiple fields under its own service", async () => {
248
255
  await asPlugin(async () => {
249
- await storeCredential("stripe/acme", "stripe-secret");
250
- await storeCredential("openai/acme", "openai-secret");
256
+ await storeCredential("acme/api_key", "key-secret");
257
+ await storeCredential("acme/token", "token-secret");
251
258
  });
252
259
 
253
- expect(secureStore.get(credentialKey("stripe", "acme"))).toBe(
254
- "stripe-secret",
260
+ expect(secureStore.get(credentialKey("acme", "api_key"))).toBe(
261
+ "key-secret",
255
262
  );
256
- expect(secureStore.get(credentialKey("openai", "acme"))).toBe(
257
- "openai-secret",
263
+ expect(secureStore.get(credentialKey("acme", "token"))).toBe(
264
+ "token-secret",
258
265
  );
259
266
  });
260
267
  });
@@ -16,6 +16,8 @@
16
16
  * - under --json the consent listing, the prompt, and the cancellation line
17
17
  * all go to stderr, leaving stdout a pure JSON document
18
18
  * - inspect renders the schedules surface block
19
+ * - install prints a setup-skill hint when `skills/setup` or
20
+ * `skills/<name>-setup` is present on the installed tree
19
21
  *
20
22
  * The installers are replaced by fakes that stage a fixture tree and run the
21
23
  * real `confirmStagedOrAbort` gate, so the command's consent callback is
@@ -76,6 +78,10 @@ let ipcResults: Array<{
76
78
 
77
79
  let inspectResult: PluginInspection | null = null;
78
80
 
81
+ /** On-disk tree returned as the fake install `target` so post-install walks work. */
82
+ let installTarget: string | null = null;
83
+ const installTargetDirs: string[] = [];
84
+
79
85
  // ---------------------------------------------------------------------------
80
86
  // Mocks
81
87
  // ---------------------------------------------------------------------------
@@ -123,7 +129,7 @@ async function runFakeInstall(
123
129
  await stageAndConfirm(name, deps?.confirmStaged);
124
130
  return {
125
131
  name,
126
- target: `/plugins/${name}`,
132
+ target: installTarget ?? `/plugins/${name}`,
127
133
  fileCount: 3,
128
134
  ref: "main",
129
135
  commit: "a".repeat(40),
@@ -253,6 +259,7 @@ beforeEach(() => {
253
259
  upgradePluginCalls = [];
254
260
  ipcResults = [];
255
261
  inspectResult = null;
262
+ installTarget = null;
256
263
  // Platform features on by default, so a plain name install takes the
257
264
  // platform-tarball branch.
258
265
  delete process.env.VELLUM_DISABLE_PLATFORM;
@@ -260,6 +267,10 @@ beforeEach(() => {
260
267
  });
261
268
 
262
269
  afterEach(() => {
270
+ for (const dir of installTargetDirs) {
271
+ rmSync(dir, { recursive: true, force: true });
272
+ }
273
+ installTargetDirs.length = 0;
263
274
  if (savedDisablePlatform === undefined) {
264
275
  delete process.env.VELLUM_DISABLE_PLATFORM;
265
276
  } else {
@@ -346,6 +357,7 @@ describe("plugins install - declared-schedules consent", () => {
346
357
  expect(confirmCalls.length).toBe(0);
347
358
  expect(r.stdout).not.toContain("declares");
348
359
  expect(r.stdout).not.toContain("schedule");
360
+ expect(r.stdout).not.toContain("to help set up this plugin");
349
361
  expect(r.stdout).toContain('Installed plugin "example"');
350
362
  expect(r.exitCode).toBe(0);
351
363
  });
@@ -690,3 +702,47 @@ describe("plugins inspect - schedules surface", () => {
690
702
  expect(r.exitCode).toBe(0);
691
703
  });
692
704
  });
705
+
706
+ describe("plugins install - setup skill hint", () => {
707
+ function writeSetupSkill(skillId: string): void {
708
+ const dir = mkdtempSync(join(tmpdir(), "plugins-cmd-target-"));
709
+ installTargetDirs.push(dir);
710
+ mkdirSync(join(dir, "skills", skillId), { recursive: true });
711
+ writeFileSync(
712
+ join(dir, "skills", skillId, "SKILL.md"),
713
+ "---\nname: setup\ndescription: Set up the plugin.\n---\n",
714
+ );
715
+ installTarget = dir;
716
+ }
717
+
718
+ test("points at skills/setup after a successful install", async () => {
719
+ writeSetupSkill("setup");
720
+
721
+ const r = await runCommand(["plugins", "install", "example"]);
722
+
723
+ expect(r.stdout).toContain('Installed plugin "example"');
724
+ expect(r.stdout).toContain(
725
+ "Load the setup skill to help set up this plugin",
726
+ );
727
+ expect(r.exitCode).toBe(0);
728
+ });
729
+
730
+ test("points at skills/<name>-setup when that is the shipped id", async () => {
731
+ writeSetupSkill("imessage-setup");
732
+
733
+ const r = await runCommand(["plugins", "install", "imessage"]);
734
+
735
+ expect(r.stdout).toContain(
736
+ "Load the imessage-setup skill to help set up this plugin",
737
+ );
738
+ expect(r.exitCode).toBe(0);
739
+ });
740
+
741
+ test("prints no setup hint when the plugin ships no setup skill", async () => {
742
+ const r = await runCommand(["plugins", "install", "example"]);
743
+
744
+ expect(r.stdout).toContain('Installed plugin "example"');
745
+ expect(r.stdout).not.toContain("to help set up this plugin");
746
+ expect(r.exitCode).toBe(0);
747
+ });
748
+ });
@@ -54,6 +54,10 @@ during the install, and the install asks for confirmation before finalizing:
54
54
  schedules run automatically in the background once the plugin is installed.
55
55
  Pass --force to skip the prompt (required for non-interactive installs).
56
56
 
57
+ A plugin that ships a setup skill (skills/setup/ or
58
+ skills/<name>-setup/) prints a line after install telling the user to
59
+ load that skill to finish setup.
60
+
57
61
  A GitHub URL (anything containing a slash) installs directly from that repo,
58
62
  bypassing the marketplace whitelist. Such a plugin is UNTRUSTED — it has not
59
63
  been reviewed and its hooks/tools run with full assistant access — so the
@@ -301,6 +301,16 @@ export function registerPluginsCommand(program: Command): void {
301
301
  console.log(
302
302
  `Installed ${label} "${result.name}" (${result.fileCount} file${result.fileCount === 1 ? "" : "s"})${pinned} → ${result.target}`,
303
303
  );
304
+ const { skills } = libs.surfaces.detectPluginSurfaces(
305
+ result.target,
306
+ );
307
+ const setupSkill = libs.surfaces.findPluginSetupSkill(
308
+ result.name,
309
+ skills,
310
+ );
311
+ if (setupSkill !== undefined) {
312
+ console.log(libs.surfaces.formatPluginSetupHint(setupSkill));
313
+ }
304
314
  } catch (err) {
305
315
  if (err instanceof libs.installGitHub.PluginInstallDeclinedError) {
306
316
  // The consent gate already printed the outcome and set the exit
@@ -17,7 +17,11 @@ import { tmpdir } from "node:os";
17
17
  import { join } from "node:path";
18
18
  import { afterEach, beforeEach, describe, expect, test } from "bun:test";
19
19
 
20
- import { detectPluginSurfaces } from "../plugin-surfaces.js";
20
+ import {
21
+ detectPluginSurfaces,
22
+ findPluginSetupSkill,
23
+ formatPluginSetupHint,
24
+ } from "../plugin-surfaces.js";
21
25
 
22
26
  let pluginDir: string;
23
27
 
@@ -188,3 +192,30 @@ describe("detectPluginSurfaces", () => {
188
192
  expect(detectPluginSurfaces(pluginDir).schedules).toEqual([]);
189
193
  });
190
194
  });
195
+
196
+ describe("findPluginSetupSkill", () => {
197
+ test("prefers the generic setup id when both conventions are present", () => {
198
+ expect(
199
+ findPluginSetupSkill("imessage", ["setup", "imessage-setup", "other"]),
200
+ ).toBe("setup");
201
+ });
202
+
203
+ test("falls back to <plugin-name>-setup", () => {
204
+ expect(findPluginSetupSkill("imessage", ["imessage-setup"])).toBe(
205
+ "imessage-setup",
206
+ );
207
+ });
208
+
209
+ test("returns undefined when the plugin ships no setup skill", () => {
210
+ expect(findPluginSetupSkill("imessage", ["imessage-send"])).toBeUndefined();
211
+ expect(findPluginSetupSkill("imessage", [])).toBeUndefined();
212
+ });
213
+ });
214
+
215
+ describe("formatPluginSetupHint", () => {
216
+ test("names the skill in the install-command copy", () => {
217
+ expect(formatPluginSetupHint("imessage-setup")).toBe(
218
+ "Load the imessage-setup skill to help set up this plugin",
219
+ );
220
+ });
221
+ });
@@ -216,6 +216,33 @@ function listSchedules(schedulesDir: string): PluginScheduleSurface[] {
216
216
  );
217
217
  }
218
218
 
219
+ /**
220
+ * Skill id a plugin ships for first-run setup, if any.
221
+ *
222
+ * Convention: `skills/setup/SKILL.md` or `skills/<plugin-name>-setup/SKILL.md`.
223
+ * The directory name is the id `skill_load` uses. `setup` wins when both exist
224
+ * so the generic name is the standard; `<plugin-name>-setup` covers plugins
225
+ * that already ship that form.
226
+ */
227
+ export function findPluginSetupSkill(
228
+ pluginName: string,
229
+ skillIds: readonly string[],
230
+ ): string | undefined {
231
+ if (skillIds.includes("setup")) {
232
+ return "setup";
233
+ }
234
+ const named = `${pluginName}-setup`;
235
+ if (skillIds.includes(named)) {
236
+ return named;
237
+ }
238
+ return undefined;
239
+ }
240
+
241
+ /** Install-command copy pointing at a plugin's setup skill. */
242
+ export function formatPluginSetupHint(skillId: string): string {
243
+ return `Load the ${skillId} skill to help set up this plugin`;
244
+ }
245
+
219
246
  /**
220
247
  * Detect the {@link PluginSurfaces} an installed plugin contributes by walking
221
248
  * its install tree at `pluginDir`. Surface types with no contributions come
@@ -144,8 +144,16 @@
144
144
  "id": "fork-from-message",
145
145
  "scope": "client",
146
146
  "key": "fork-from-message",
147
- "label": "Fork from Message",
148
- "description": "Show the fork affordance: 'Fork from here' on messages and 'Fork Conversation' in the thread menu. Staff-only: the client also requires the viewer to be Vellum staff, so enabling this for a non-staff account still shows nothing.",
147
+ "label": "Internal Thread Actions (legacy key)",
148
+ "description": "Legacy key for `internal-thread-actions`. The client grants the internal thread affordances when either key is enabled, so the platform may serve the gate under either name. Declared here so the flag mapper keeps the value instead of dropping it as undeclared.",
149
+ "defaultEnabled": false
150
+ },
151
+ {
152
+ "id": "internal-thread-actions",
153
+ "scope": "client",
154
+ "key": "internal-thread-actions",
155
+ "label": "Internal Thread Actions",
156
+ "description": "Show the internal-only thread affordances: 'Fork from here' on messages, 'Fork Conversation', 'Analyze Conversation', and 'Copy conversation ID' in the thread menu, plus the LLM inspector surfaces. Staff-only: the client also requires the viewer to be Vellum staff, so enabling this for a non-staff account still shows nothing.",
149
157
  "defaultEnabled": false
150
158
  },
151
159
  {
@@ -0,0 +1,15 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { credentialInPluginScope } from "./credential-scope.js";
4
+
5
+ describe("credentialInPluginScope", () => {
6
+ test("allows every field under the plugin's own service", () => {
7
+ expect(credentialInPluginScope("imessage", "imessage")).toBe(true);
8
+ expect(credentialInPluginScope("acme", "acme")).toBe(true);
9
+ });
10
+
11
+ test("blocks another service, even when the field matches the plugin name", () => {
12
+ expect(credentialInPluginScope("acme", "openai")).toBe(false);
13
+ expect(credentialInPluginScope("imessage", "openai")).toBe(false);
14
+ });
15
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Whether a plugin may read or write a credential named `service/field`.
3
+ *
4
+ * The plugin's manifest name is the service it owns. Plugin `imessage` may
5
+ * resolve `imessage/api_key` and `imessage/photon_project_id`, and nothing
6
+ * under another service (`openai/api_key`, `openai/imessage`). The check is
7
+ * name equality only; it does not look the credential up.
8
+ */
9
+ export function credentialInPluginScope(
10
+ pluginName: string,
11
+ service: string,
12
+ ): boolean {
13
+ return service === pluginName;
14
+ }
@@ -170,7 +170,7 @@ export { doesSupportVision } from "./vision-support.js";
170
170
  // Resolve a stored credential to its plaintext value — the same value
171
171
  // `assistant credentials reveal` prints — from a UUID or a "service/field"
172
172
  // reference. When a plugin is in context, resolution is scoped to credentials
173
- // whose `field` matches the plugin's manifest name; outside any plugin it is
173
+ // whose service matches the plugin's manifest name; outside any plugin it is
174
174
  // unscoped. Throws CredentialResolutionError when the ref does not resolve, the
175
175
  // store is unreachable, or the credential is out of the plugin's scope.
176
176
  export {
@@ -179,7 +179,7 @@ export {
179
179
  } from "./resolve-credential.js";
180
180
  // Store a credential's plaintext value (the same write `assistant credentials
181
181
  // set` performs), creating it or replacing an existing one, named by UUID or a
182
- // "service/field" reference. A plugin may only write credentials whose `field`
182
+ // "service/field" reference. A plugin may only write credentials whose service
183
183
  // matches its manifest name, and the write fails closed with no plugin in
184
184
  // context. Throws CredentialStoreError when there is no calling plugin, the ref
185
185
  // is malformed, the value is invalid, the store rejects the write, or the
@@ -12,16 +12,17 @@
12
12
  * When a plugin is in context (its hook, tool, or one of its own
13
13
  * `/x/plugins/<name>/` routes is executing, tracked by
14
14
  * {@link ../plugins/plugin-execution-context.getCurrentPluginName}), resolution
15
- * is restricted: the plugin may only resolve credentials whose `field` equals
16
- * the plugin's own manifest name. A plugin named `acme` can therefore read
17
- * `openai/acme` or `stripe/acme` but not `openai/api_key`. Outside any plugin
18
- * context (host-internal callers, CLI, tests) the resolver is unscoped and
19
- * behaves like a direct reveal.
15
+ * is restricted: the plugin may only resolve credentials whose `service`
16
+ * equals its manifest name (`imessage/api_key` for plugin `imessage`). It
17
+ * cannot read another service (`openai/api_key`, `openai/imessage`). Outside
18
+ * any plugin context (host-internal callers, CLI, tests) the resolver is
19
+ * unscoped and behaves like a direct reveal.
20
20
  */
21
21
 
22
22
  import { getCurrentPluginName } from "../plugins/plugin-execution-context.js";
23
23
  import { getSecureKeyResultAsync } from "../security/secure-keys.js";
24
24
  import { resolveCredentialRef } from "../tools/credentials/resolve.js";
25
+ import { credentialInPluginScope } from "./credential-scope.js";
25
26
 
26
27
  /**
27
28
  * Raised when a credential cannot be resolved: the reference does not match a
@@ -49,13 +50,16 @@ export async function resolveCredential(ref: string): Promise<string> {
49
50
  throw new CredentialResolutionError(`Credential not found: ${ref}`);
50
51
  }
51
52
 
52
- // Scope the resolution to the plugin in context, if any. The field-name gate
53
+ // Scope the resolution to the plugin in context, if any. The ownership gate
53
54
  // is enforced before the plaintext is read so an out-of-scope plugin never
54
55
  // touches the secure backend.
55
56
  const pluginName = getCurrentPluginName();
56
- if (pluginName !== undefined && resolved.field !== pluginName) {
57
+ if (
58
+ pluginName !== undefined &&
59
+ !credentialInPluginScope(pluginName, resolved.service)
60
+ ) {
57
61
  throw new CredentialResolutionError(
58
- `Plugin "${pluginName}" may only resolve credentials whose field matches its name; ` +
62
+ `Plugin "${pluginName}" may only resolve credentials under its own service; ` +
59
63
  `"${resolved.service}/${resolved.field}" is out of scope.`,
60
64
  );
61
65
  }
@@ -11,9 +11,10 @@
11
11
  *
12
12
  * ## Plugin scoping
13
13
  *
14
- * A plugin may only write credentials whose `field` equals its manifest name,
15
- * so `acme` writes `openai/acme` or `stripe/acme` but never `openai/api_key`.
16
- * The name comes from the execution context
14
+ * A plugin may only write credentials whose `service` equals its manifest
15
+ * name (`imessage/api_key` for plugin `imessage`). It cannot write another
16
+ * service (`openai/api_key`, `openai/imessage`). The name comes from the
17
+ * execution context
17
18
  * ({@link ../plugins/plugin-execution-context.getCurrentPluginName}), which the
18
19
  * host establishes around a plugin's hook, tool, and route invocations.
19
20
  *
@@ -32,6 +33,7 @@ import { getCurrentPluginName } from "../plugins/plugin-execution-context.js";
32
33
  import { parseServiceFieldRef } from "../tools/credentials/ref-parse.js";
33
34
  import { resolveCredentialRef } from "../tools/credentials/resolve.js";
34
35
  import { storeCredentialValue } from "../tools/credentials/store.js";
36
+ import { credentialInPluginScope } from "./credential-scope.js";
35
37
 
36
38
  /**
37
39
  * Raised when a credential cannot be stored: the reference is malformed, the
@@ -98,9 +100,9 @@ export async function storeCredential(
98
100
  }
99
101
 
100
102
  const target = resolveStoreTarget(ref);
101
- if (target.field !== pluginName) {
103
+ if (!credentialInPluginScope(pluginName, target.service)) {
102
104
  throw new CredentialStoreError(
103
- `Plugin "${pluginName}" may only store credentials whose field matches its name; ` +
105
+ `Plugin "${pluginName}" may only store credentials under its own service; ` +
104
106
  `"${target.service}/${target.field}" is out of scope.`,
105
107
  );
106
108
  }