@vellumai/assistant 0.8.9 → 0.8.10-dev.202606092334.09948c8
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/AGENTS.md +1 -1
- package/examples/plugins/echo/README.md +3 -3
- package/node_modules/@vellumai/skill-host-contracts/src/tool-types.ts +2 -0
- package/openapi.yaml +38 -12
- package/package.json +1 -1
- package/scripts/sync-llm-catalog.ts +2 -0
- package/src/__tests__/agent-loop-exit-reason.test.ts +21 -15
- package/src/__tests__/approval-cascade.test.ts +1 -0
- package/src/__tests__/build-persisted-content.test.ts +75 -1
- package/src/__tests__/compaction-events.test.ts +1 -0
- package/src/__tests__/config-managed-gemini-defaults.test.ts +2 -46
- package/src/__tests__/context-overflow-reducer.test.ts +264 -124
- package/src/__tests__/context-window-manager-overflow-rung.test.ts +351 -0
- package/src/__tests__/conversation-abort-tool-results.test.ts +1 -0
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +11 -0
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +90 -49
- package/src/__tests__/conversation-agent-loop.test.ts +113 -64
- package/src/__tests__/conversation-confirmation-signals.test.ts +1 -0
- package/src/__tests__/conversation-fork-crud.test.ts +110 -0
- package/src/__tests__/conversation-process-callsite.test.ts +1 -0
- package/src/__tests__/conversation-provider-retry-repair.test.ts +48 -48
- package/src/__tests__/conversation-queue.test.ts +1 -0
- package/src/__tests__/conversation-runtime-assembly.test.ts +119 -8
- package/src/__tests__/conversation-slash-queue.test.ts +1 -0
- package/src/__tests__/conversation-slash-unknown.test.ts +1 -0
- package/src/__tests__/conversation-speed-override.test.ts +1 -0
- package/src/__tests__/conversation-surfaces-app-control.test.ts +4 -1
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +91 -142
- package/src/__tests__/conversation-tool-setup-skill-attribution.test.ts +116 -0
- package/src/__tests__/conversation-tool-setup-test-helpers.ts +98 -0
- package/src/__tests__/conversation-workspace-cache-state.test.ts +1 -0
- package/src/__tests__/conversation-workspace-injection.test.ts +1 -0
- package/src/__tests__/conversation-workspace-tool-tracking.test.ts +1 -0
- package/src/__tests__/corrected-target.test.ts +93 -0
- package/src/__tests__/credential-execution-feature-gates.test.ts +3 -5
- package/src/__tests__/credential-security-invariants.test.ts +1 -0
- package/src/__tests__/embedding-managed-proxy-selection.test.ts +6 -40
- package/src/__tests__/external-plugin-loader.test.ts +0 -1
- package/src/__tests__/guardian-routing-invariants.test.ts +91 -0
- package/src/__tests__/history-repair-hook.test.ts +2 -0
- package/src/__tests__/host-app-control-proxy.test.ts +45 -0
- package/src/__tests__/llm-catalog-parity.test.ts +4 -0
- package/src/__tests__/memory-retrieval-hook.test.ts +29 -15
- package/src/__tests__/notification-decision-strategy.test.ts +3 -3
- package/src/__tests__/persistence-secret-redaction.test.ts +78 -0
- package/src/__tests__/plugin-bootstrap.test.ts +82 -73
- package/src/__tests__/plugin-tool-contribution.test.ts +7 -4
- package/src/__tests__/plugin-types.test.ts +0 -8
- package/src/__tests__/provider-catalog-visibility.test.ts +1 -9
- package/src/__tests__/retry-thinking-adaptive-only.test.ts +245 -0
- package/src/__tests__/server-history-render.test.ts +39 -0
- package/src/__tests__/skills.test.ts +123 -0
- package/src/__tests__/title-generate-hook.test.ts +2 -0
- package/src/__tests__/tool-audit-listener.test.ts +51 -0
- package/src/__tests__/tool-executor-lifecycle-events.test.ts +32 -0
- package/src/__tests__/tool-start-timestamp.test.ts +218 -0
- package/src/agent/loop.ts +26 -39
- package/src/api/events/tool-result.ts +9 -0
- package/src/api/events/tool-use-start.ts +7 -0
- package/src/api/responses/conversation-message.ts +91 -14
- package/src/approvals/guardian-request-resolvers.ts +26 -0
- package/src/cli/commands/channel-verification-sessions.ts +6 -6
- package/src/cli/commands/inference-providers.ts +0 -8
- package/src/cli/commands/plugins.ts +2 -2
- package/src/cli/lib/__tests__/install-from-github.test.ts +174 -18
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-details.test.ts +1 -1
- package/src/cli/lib/__tests__/plugin-marketplace.test.ts +1 -1
- package/src/cli/lib/__tests__/search-plugins.test.ts +11 -11
- package/src/cli/lib/install-from-github.ts +130 -19
- package/src/cli/lib/plugin-catalog-cache.ts +1 -1
- package/src/cli/lib/plugin-details.ts +4 -4
- package/src/cli/lib/plugin-marketplace.ts +2 -2
- package/src/cli/lib/search-plugins.ts +6 -6
- package/src/config/bundled-skills/skill-management/SKILL.md +89 -1
- package/src/config/env-registry.ts +12 -0
- package/src/config/feature-flag-registry.json +0 -80
- package/src/config/loader.ts +5 -22
- package/src/config/seed-inference-profiles.ts +1 -1
- package/src/config/skills.ts +101 -47
- package/src/context/strip-injections.ts +7 -4
- package/src/daemon/conversation-agent-loop-handlers.ts +102 -6
- package/src/daemon/conversation-agent-loop.ts +126 -270
- package/src/daemon/conversation-runtime-assembly.ts +44 -8
- package/src/daemon/conversation-tool-setup.ts +9 -1
- package/src/daemon/conversation.ts +13 -0
- package/src/daemon/external-plugins-bootstrap.ts +33 -87
- package/src/daemon/handlers/config-channels.ts +11 -2
- package/src/daemon/handlers/shared.ts +9 -1
- package/src/daemon/handlers/skills.ts +6 -2
- package/src/daemon/host-app-control-proxy.ts +72 -57
- package/src/daemon/message-protocol.ts +0 -7
- package/src/daemon/message-types/skills.ts +4 -0
- package/src/events/tool-audit-listener.ts +7 -1
- package/src/memory/__tests__/tool-invocation-test-helpers.ts +69 -0
- package/src/memory/conversation-crud.ts +44 -1
- package/src/memory/db-init.ts +4 -0
- package/src/memory/embedding-backend.ts +5 -22
- package/src/memory/memory-retrospective-startup-cleanup.ts +1 -1
- package/src/memory/migrations/275-tool-invocations-add-skill-id.test.ts +81 -0
- package/src/memory/migrations/275-tool-invocations-add-skill-id.ts +20 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.test.ts +68 -0
- package/src/memory/migrations/276-tool-invocations-created-at-id-index.ts +20 -0
- package/src/memory/migrations/index.ts +2 -0
- package/src/memory/schema/conversations.ts +3 -0
- package/src/memory/tool-execution-events-store.test.ts +162 -0
- package/src/memory/tool-execution-events-store.ts +73 -0
- package/src/memory/tool-usage-store.ts +4 -3
- package/src/memory/v2/__tests__/injected-block-slugs.test.ts +51 -0
- package/src/memory/v2/activation-store.ts +50 -1
- package/src/memory/v2/injected-block-slugs.ts +30 -0
- package/src/notifications/__tests__/copy-composer.test.ts +244 -0
- package/src/notifications/access-request-copy.ts +298 -0
- package/src/notifications/adapters/slack.ts +3 -3
- package/src/notifications/adapters/telegram.ts +2 -1
- package/src/notifications/copy-composer.ts +49 -267
- package/src/notifications/decision-engine.ts +16 -35
- package/src/notifications/home-feed-side-effect.ts +1 -6
- package/src/platform/client.ts +1 -3
- package/src/platform/feature-gate.ts +3 -12
- package/src/plugin-api/constants.ts +2 -0
- package/src/plugin-api/index.ts +37 -6
- package/src/plugin-api/types.ts +75 -0
- package/src/plugins/defaults/compaction/compact.ts +39 -1
- package/src/plugins/defaults/compaction/context-overflow-reducer.ts +240 -32
- package/src/plugins/defaults/compaction/corrected-target.ts +53 -0
- package/src/plugins/defaults/compaction/window-manager.ts +195 -1
- package/src/plugins/defaults/index.ts +24 -0
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +76 -112
- package/src/plugins/defaults/memory-retrieval/hooks/{user-prompt-submit-temp.ts → user-prompt-submit.ts} +36 -67
- package/src/plugins/defaults/memory-retrieval/package.json +14 -0
- package/src/plugins/external-api.ts +1 -1
- package/src/plugins/types.ts +5 -51
- package/src/providers/inference/__tests__/base-url-route-validation.test.ts +1 -2
- package/src/providers/model-catalog.ts +57 -1
- package/src/providers/registry.ts +0 -8
- package/src/providers/retry.ts +35 -7
- package/src/runtime/routes/__tests__/acp-routes.test.ts +151 -0
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +0 -62
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +4 -4
- package/src/runtime/routes/acp-routes.test.ts +106 -0
- package/src/runtime/routes/acp-routes.ts +248 -2
- package/src/runtime/routes/browser-tabs-routes.ts +1 -1
- package/src/runtime/routes/channel-verification-routes.ts +14 -5
- package/src/runtime/routes/chatgpt-subscription-auth-routes.ts +0 -14
- package/src/runtime/routes/inbound-stages/acl-enforcement.ts +33 -34
- package/src/runtime/routes/inference-provider-connection-routes.ts +0 -45
- package/src/runtime/routes/plugins-routes.ts +3 -3
- package/src/runtime/verification-outbound-actions.ts +147 -2
- package/src/runtime/verification-templates.ts +29 -3
- package/src/telemetry/types.ts +25 -1
- package/src/telemetry/usage-telemetry-reporter.test.ts +141 -7
- package/src/telemetry/usage-telemetry-reporter.ts +63 -7
- package/src/tools/executor.ts +4 -1
- package/src/tools/skills/load.ts +11 -6
- package/src/tools/terminal/safe-env.ts +1 -0
- package/src/tools/types.ts +10 -0
- package/src/__tests__/plugin-skill-contribution.test.ts +0 -355
- package/src/daemon/message-types/browser.ts +0 -10
- package/src/notifications/__tests__/emit-signal-home-feed.test.ts +0 -187
- package/src/plugins/plugin-skill-contributions.ts +0 -292
|
@@ -45,7 +45,7 @@ const DOWNLOAD_HOST = "https://files.test/";
|
|
|
45
45
|
* Build a `fetch` that serves the GitHub Contents API from an in-memory tree.
|
|
46
46
|
*
|
|
47
47
|
* `tree` is keyed by full canonical-repo path (e.g.
|
|
48
|
-
* `
|
|
48
|
+
* `plugins/simple-memory/package.json`) and maps each entry to a
|
|
49
49
|
* file's content (`string`/`Uint8Array`) or `null` for an explicit directory.
|
|
50
50
|
* Directory listings are derived from the key set; file `download_url`s point
|
|
51
51
|
* at {@link DOWNLOAD_HOST} and are served with the stored bytes.
|
|
@@ -64,7 +64,7 @@ function makeContentsFetch(opts: {
|
|
|
64
64
|
*/
|
|
65
65
|
manifestStatus?: number;
|
|
66
66
|
}): FetchLike {
|
|
67
|
-
const MANIFEST_URL = `https://api.github.com/repos/${CANON_REPO}/contents/
|
|
67
|
+
const MANIFEST_URL = `https://api.github.com/repos/${CANON_REPO}/contents/plugins/marketplace.json`;
|
|
68
68
|
const CONTENTS = `https://api.github.com/repos/${CANON_REPO}/contents/`;
|
|
69
69
|
const { tree } = opts;
|
|
70
70
|
|
|
@@ -136,13 +136,13 @@ function makeContentsFetch(opts: {
|
|
|
136
136
|
}) as FetchLike;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
/** First-party fixture: keys are relative to `
|
|
139
|
+
/** First-party fixture: keys are relative to `plugins/`. */
|
|
140
140
|
function fixtureFetch(
|
|
141
141
|
tree: Record<string, Uint8Array | string | null>,
|
|
142
142
|
): FetchLike {
|
|
143
143
|
const full: Record<string, Uint8Array | string | null> = {};
|
|
144
144
|
for (const [key, value] of Object.entries(tree)) {
|
|
145
|
-
full[`
|
|
145
|
+
full[`plugins/${key}`] = value;
|
|
146
146
|
}
|
|
147
147
|
return makeContentsFetch({ tree: full });
|
|
148
148
|
}
|
|
@@ -200,12 +200,12 @@ const unusedGitRunner: GitRunner = async (args) => {
|
|
|
200
200
|
* Read the real, committed caveman adapter stub from the repo so the
|
|
201
201
|
* integration test exercises the adapter that ships rather than a fixture
|
|
202
202
|
* copy that could drift from it. Returns every stub file keyed by its
|
|
203
|
-
* Contents-API path (`
|
|
203
|
+
* Contents-API path (`plugins/caveman/<rel>`) so the fetch fake
|
|
204
204
|
* serves the whole stub — package.json, the adapter, and its templates — to
|
|
205
205
|
* the real postinstall runner. Resolves the stub relative to this test file.
|
|
206
206
|
*/
|
|
207
207
|
function readRealCavemanStub(): Record<string, string> {
|
|
208
|
-
const repoRel = "
|
|
208
|
+
const repoRel = "plugins/caveman";
|
|
209
209
|
const stubDir = join(import.meta.dir, "../../../../../", repoRel);
|
|
210
210
|
const tree: Record<string, string> = {};
|
|
211
211
|
const walk = (relDir: string): void => {
|
|
@@ -458,9 +458,7 @@ describe("installPlugin — first-party", () => {
|
|
|
458
458
|
const base = fixtureFetch({ "demo/package.json": "{}" });
|
|
459
459
|
const fetch: FetchLike = async (input, init) => {
|
|
460
460
|
const url = typeof input === "string" ? input : input.toString();
|
|
461
|
-
const match = /\/contents\/
|
|
462
|
-
url,
|
|
463
|
-
);
|
|
461
|
+
const match = /\/contents\/plugins\/demo\?ref=([^&]+)/.exec(url);
|
|
464
462
|
if (match) listRef = decodeURIComponent(match[1]!);
|
|
465
463
|
return base(url, init);
|
|
466
464
|
};
|
|
@@ -489,7 +487,7 @@ describe("installPlugin — first-party", () => {
|
|
|
489
487
|
JSON.stringify([
|
|
490
488
|
{
|
|
491
489
|
name: "../escape",
|
|
492
|
-
path: "
|
|
490
|
+
path: "plugins/demo/../escape",
|
|
493
491
|
type: "file",
|
|
494
492
|
download_url: `${DOWNLOAD_HOST}escape`,
|
|
495
493
|
},
|
|
@@ -685,7 +683,7 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
685
683
|
|
|
686
684
|
test("overlays a curated adapter stub and runs its postinstall transform", async () => {
|
|
687
685
|
// GIVEN caveman is whitelisted externally
|
|
688
|
-
// AND we curate an adapter stub for it at
|
|
686
|
+
// AND we curate an adapter stub for it at plugins/caveman —
|
|
689
687
|
// the real, committed stub (package.json + postinstall.ts + templates), so
|
|
690
688
|
// this test exercises the adapter that ships, not a fixture copy of it
|
|
691
689
|
const fetch = makeContentsFetch({
|
|
@@ -697,7 +695,12 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
697
695
|
// terse-mode ruleset in skills/caveman/SKILL.md
|
|
698
696
|
const runGit = fakeGitRunner({
|
|
699
697
|
tree: {
|
|
700
|
-
"package.json":
|
|
698
|
+
"package.json": JSON.stringify({
|
|
699
|
+
name: "caveman-installer",
|
|
700
|
+
version: "0.1.0",
|
|
701
|
+
description: "Caveman installer.",
|
|
702
|
+
license: "MIT",
|
|
703
|
+
}),
|
|
701
704
|
".claude-plugin/plugin.json": JSON.stringify({
|
|
702
705
|
name: "caveman",
|
|
703
706
|
description: "Ultra-compressed communication mode.",
|
|
@@ -723,6 +726,12 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
723
726
|
expect(pkg.name).toBe("caveman");
|
|
724
727
|
expect(pkg.peerDependencies["@vellumai/plugin-api"]).toBeString();
|
|
725
728
|
expect(pkg.scripts?.postinstall).toBeUndefined();
|
|
729
|
+
// AND every other upstream manifest field is preserved verbatim — only
|
|
730
|
+
// `name` and the peer dep are touched, so the installed plugin reports the
|
|
731
|
+
// upstream `version` (and description, license, …) rather than the stub's
|
|
732
|
+
expect(pkg.version).toBe("0.1.0");
|
|
733
|
+
expect(pkg.description).toBe("Caveman installer.");
|
|
734
|
+
expect(pkg.license).toBe("MIT");
|
|
726
735
|
|
|
727
736
|
// AND a pre-model-call hook is synthesized carrying the upstream ruleset,
|
|
728
737
|
// so caveman actually runs (terse mode injected on the user-facing call)
|
|
@@ -737,9 +746,156 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
737
746
|
expect(hook).not.toContain("description: terse mode");
|
|
738
747
|
});
|
|
739
748
|
|
|
749
|
+
test("falls back to the stub manifest when the upstream ships no package.json", async () => {
|
|
750
|
+
// GIVEN caveman is whitelisted with the real curated adapter stub
|
|
751
|
+
const fetch = makeContentsFetch({
|
|
752
|
+
tree: readRealCavemanStub(),
|
|
753
|
+
manifest: CAVEMAN_MANIFEST,
|
|
754
|
+
});
|
|
755
|
+
// AND the upstream clone has NO package.json — only the Claude Code
|
|
756
|
+
// manifest and the terse-mode ruleset the adapter reads
|
|
757
|
+
const runGit = fakeGitRunner({
|
|
758
|
+
tree: {
|
|
759
|
+
".claude-plugin/plugin.json": JSON.stringify({ name: "caveman" }),
|
|
760
|
+
"skills/caveman/SKILL.md":
|
|
761
|
+
"---\nname: caveman\n---\n\nCAVEMAN MODE. Drop filler words.",
|
|
762
|
+
},
|
|
763
|
+
commit: "63a91ecadbf4c4719a4602a5abb00883f9966034",
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// WHEN we install (real postinstall runner)
|
|
767
|
+
await installPlugin(
|
|
768
|
+
{ name: "caveman", ref: "main" },
|
|
769
|
+
{ fetch, runGit, workspacePluginsDir: pluginsDir },
|
|
770
|
+
);
|
|
771
|
+
|
|
772
|
+
// THEN the overlaid stub is the only manifest available, so it becomes the
|
|
773
|
+
// base: the loader still gets a matching `name` and the peer dep, and the
|
|
774
|
+
// spent stub `postinstall` is dropped so no install machinery is shipped
|
|
775
|
+
const pkg = JSON.parse(
|
|
776
|
+
readFileSync(join(pluginsDir, "caveman", "package.json"), "utf-8"),
|
|
777
|
+
);
|
|
778
|
+
expect(pkg.name).toBe("caveman");
|
|
779
|
+
expect(pkg.peerDependencies["@vellumai/plugin-api"]).toBeString();
|
|
780
|
+
expect(pkg.scripts?.postinstall).toBeUndefined();
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
test("strips a clone-supplied bunfig.toml so its preload can't run before the adapter", async () => {
|
|
784
|
+
// GIVEN caveman is whitelisted with the real, committed adapter stub
|
|
785
|
+
const fetch = makeContentsFetch({
|
|
786
|
+
tree: readRealCavemanStub(),
|
|
787
|
+
manifest: CAVEMAN_MANIFEST,
|
|
788
|
+
});
|
|
789
|
+
// AND the upstream clone is a valid Claude Code plugin that ALSO smuggles a
|
|
790
|
+
// `bunfig.toml` whose `preload` points at attacker code in the clone. Bun
|
|
791
|
+
// loads `$cwd/bunfig.toml` and runs `preload` before the entry point, so an
|
|
792
|
+
// un-stripped config would execute `evil.ts` (writing a `pwned` sentinel)
|
|
793
|
+
// ahead of the curated adapter — arbitrary code execution.
|
|
794
|
+
const runGit = fakeGitRunner({
|
|
795
|
+
tree: {
|
|
796
|
+
"package.json": '{"name":"caveman-installer"}',
|
|
797
|
+
".claude-plugin/plugin.json": JSON.stringify({
|
|
798
|
+
name: "caveman",
|
|
799
|
+
description: "Ultra-compressed communication mode.",
|
|
800
|
+
}),
|
|
801
|
+
"skills/caveman/SKILL.md":
|
|
802
|
+
"---\nname: caveman\ndescription: terse mode\n---\n\nCAVEMAN MODE. Drop filler words. Keep technical substance.",
|
|
803
|
+
"bunfig.toml": 'preload = ["./evil.ts"]\n',
|
|
804
|
+
"evil.ts":
|
|
805
|
+
'import { writeFileSync } from "node:fs";\nwriteFileSync("pwned", "pwned");\n',
|
|
806
|
+
},
|
|
807
|
+
commit: "63a91ecadbf4c4719a4602a5abb00883f9966034",
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
// WHEN we install with the real postinstall runner (real `bun` subprocess)
|
|
811
|
+
const result = await installPlugin(
|
|
812
|
+
{ name: "caveman", ref: "main" },
|
|
813
|
+
{ fetch, runGit, workspacePluginsDir: pluginsDir },
|
|
814
|
+
);
|
|
815
|
+
|
|
816
|
+
// THEN the adapter still ran and produced a valid Vellum plugin
|
|
817
|
+
const target = join(pluginsDir, "caveman");
|
|
818
|
+
expect(result.commit).toBe("63a91ecadbf4c4719a4602a5abb00883f9966034");
|
|
819
|
+
expect(
|
|
820
|
+
readFileSync(join(target, "hooks", "pre-model-call.ts"), "utf-8"),
|
|
821
|
+
).toContain("CAVEMAN MODE. Drop filler words.");
|
|
822
|
+
// AND the upstream bunfig.toml was dropped before `bun` ran, so its preload
|
|
823
|
+
// never fired — no sentinel was written — and the config never persists in
|
|
824
|
+
// the installed plugin
|
|
825
|
+
expect(existsSync(join(target, "pwned"))).toBe(false);
|
|
826
|
+
expect(existsSync(join(target, "bunfig.toml"))).toBe(false);
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
test("drops a clone-supplied bunfig.toml regardless of filename case", async () => {
|
|
830
|
+
// GIVEN a raw external clone (no adapter stub) that smuggles a Bun config
|
|
831
|
+
// under an uppercase name. The macOS install target is case-insensitive, so
|
|
832
|
+
// Bun would still open a `BUNFIG.TOML`; a case-sensitive skip would miss it.
|
|
833
|
+
const fetch = makeContentsFetch({ tree: {}, manifest: CAVEMAN_MANIFEST });
|
|
834
|
+
const runGit = fakeGitRunner({
|
|
835
|
+
tree: {
|
|
836
|
+
"package.json": '{"name":"caveman"}',
|
|
837
|
+
"BUNFIG.TOML": 'preload = ["./evil.ts"]\n',
|
|
838
|
+
},
|
|
839
|
+
commit: "63a91ecadbf4c4719a4602a5abb00883f9966034",
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
// WHEN we install
|
|
843
|
+
await installPlugin(
|
|
844
|
+
{ name: "caveman", ref: "main" },
|
|
845
|
+
{ fetch, runGit, workspacePluginsDir: pluginsDir },
|
|
846
|
+
);
|
|
847
|
+
|
|
848
|
+
// THEN the uppercase Bun config was dropped while the plugin's own files
|
|
849
|
+
// were materialized
|
|
850
|
+
const target = join(pluginsDir, "caveman");
|
|
851
|
+
expect(existsSync(join(target, "BUNFIG.TOML"))).toBe(false);
|
|
852
|
+
expect(readFileSync(join(target, "package.json"), "utf-8")).toBe(
|
|
853
|
+
'{"name":"caveman"}',
|
|
854
|
+
);
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
test("stages the clone outside the served plugins/ directory", async () => {
|
|
858
|
+
// GIVEN caveman is whitelisted externally (raw clone, no adapter stub)
|
|
859
|
+
const fetch = makeContentsFetch({ tree: {}, manifest: CAVEMAN_MANIFEST });
|
|
860
|
+
// AND a git runner that records the working directory it clones into
|
|
861
|
+
const cloneCwds: string[] = [];
|
|
862
|
+
const runGit: GitRunner = async (args, { cwd }) => {
|
|
863
|
+
if (args[0] === "fetch") {
|
|
864
|
+
cloneCwds.push(cwd);
|
|
865
|
+
mkdirSync(join(cwd, ".git"), { recursive: true });
|
|
866
|
+
writeFileSync(join(cwd, "package.json"), '{"name":"caveman"}');
|
|
867
|
+
return { stdout: "" };
|
|
868
|
+
}
|
|
869
|
+
if (args[0] === "rev-parse") {
|
|
870
|
+
return { stdout: "63a91ecadbf4c4719a4602a5abb00883f9966034\n" };
|
|
871
|
+
}
|
|
872
|
+
return { stdout: "" };
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
// WHEN we install
|
|
876
|
+
const result = await installPlugin(
|
|
877
|
+
{ name: "caveman", ref: "main" },
|
|
878
|
+
{ fetch, runGit, workspacePluginsDir: pluginsDir },
|
|
879
|
+
);
|
|
880
|
+
|
|
881
|
+
// THEN the half-built clone was staged in a sibling directory, never inside
|
|
882
|
+
// the served plugins/ tree — so the daemon's source watcher and startup
|
|
883
|
+
// loader can't observe the un-adapted clone (wrong name, no peer dep) and
|
|
884
|
+
// log spurious name-mismatch / missing-peer-dependency warnings mid-install
|
|
885
|
+
expect(cloneCwds).toHaveLength(1);
|
|
886
|
+
expect(dirname(cloneCwds[0]!)).toBe(
|
|
887
|
+
join(dirname(pluginsDir), ".plugins-staging"),
|
|
888
|
+
);
|
|
889
|
+
|
|
890
|
+
// AND the finished plugin still lands inside plugins/, with no staging
|
|
891
|
+
// artifact left behind in the served directory
|
|
892
|
+
expect(result.target).toBe(join(pluginsDir, "caveman"));
|
|
893
|
+
expect(readdirSync(pluginsDir)).toEqual(["caveman"]);
|
|
894
|
+
});
|
|
895
|
+
|
|
740
896
|
test("does not run a postinstall for a raw clone without an adapter stub", async () => {
|
|
741
897
|
// GIVEN caveman is whitelisted but we curate NO adapter stub for it
|
|
742
|
-
// (the Contents API has no
|
|
898
|
+
// (the Contents API has no plugins/caveman directory)
|
|
743
899
|
const fetch = makeContentsFetch({ tree: {}, manifest: CAVEMAN_MANIFEST });
|
|
744
900
|
const runGit = fakeGitRunner({
|
|
745
901
|
tree: { "package.json": '{"name":"caveman"}', "hooks/init.ts": "//" },
|
|
@@ -767,11 +923,11 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
767
923
|
// GIVEN a whitelisted plugin with a curated stub declaring a postinstall
|
|
768
924
|
const fetch = makeContentsFetch({
|
|
769
925
|
tree: {
|
|
770
|
-
"
|
|
926
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
771
927
|
name: "caveman",
|
|
772
928
|
scripts: { postinstall: "bun ./postinstall.ts" },
|
|
773
929
|
}),
|
|
774
|
-
"
|
|
930
|
+
"plugins/caveman/postinstall.ts": "// adapter",
|
|
775
931
|
},
|
|
776
932
|
manifest: CAVEMAN_MANIFEST,
|
|
777
933
|
});
|
|
@@ -801,7 +957,7 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
801
957
|
// rather than the supported `bun <script>` adapter convention
|
|
802
958
|
const fetch = makeContentsFetch({
|
|
803
959
|
tree: {
|
|
804
|
-
"
|
|
960
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
805
961
|
name: "caveman",
|
|
806
962
|
scripts: { postinstall: "rm -rf /" },
|
|
807
963
|
}),
|
|
@@ -832,11 +988,11 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
832
988
|
// with a postinstall + adapter script, but no hooks/tools of its own)
|
|
833
989
|
const fetch = makeContentsFetch({
|
|
834
990
|
tree: {
|
|
835
|
-
"
|
|
991
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
836
992
|
name: "caveman",
|
|
837
993
|
scripts: { postinstall: "bun ./postinstall.ts" },
|
|
838
994
|
}),
|
|
839
|
-
"
|
|
995
|
+
"plugins/caveman/postinstall.ts": "// adapter",
|
|
840
996
|
},
|
|
841
997
|
manifestStatus: 500,
|
|
842
998
|
});
|
|
@@ -33,7 +33,7 @@ function fileEntry(name: string, downloadUrl: string): ContentEntry {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
interface FixtureConfig {
|
|
36
|
-
/** Manifest object served at `
|
|
36
|
+
/** Manifest object served at `plugins/marketplace.json`. Omit for 404. */
|
|
37
37
|
marketplace?: unknown;
|
|
38
38
|
/** Directory listings keyed by `<owner>/<repo>[/<path>]`. Missing key → 404. */
|
|
39
39
|
listings?: Record<string, ContentEntry[]>;
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "../plugin-marketplace.js";
|
|
17
17
|
|
|
18
18
|
const MANIFEST_URL_PREFIX =
|
|
19
|
-
"https://api.github.com/repos/vellum-ai/vellum-assistant/contents/
|
|
19
|
+
"https://api.github.com/repos/vellum-ai/vellum-assistant/contents/plugins/marketplace.json";
|
|
20
20
|
|
|
21
21
|
// External marketplace refs must be full commit SHAs (immutable). Fixtures use
|
|
22
22
|
// realistic 40-char hex object names rather than tags/branches.
|
|
@@ -18,16 +18,16 @@ import {
|
|
|
18
18
|
/**
|
|
19
19
|
* Build a GitHub Contents API fixture from an in-memory directory listing.
|
|
20
20
|
*
|
|
21
|
-
* `entries` maps each name under `
|
|
21
|
+
* `entries` maps each name under `plugins/` to its `type`. The
|
|
22
22
|
* fixture answers GET requests against
|
|
23
|
-
* - `https://api.github.com/repos/vellum-ai/vellum-assistant/contents/
|
|
23
|
+
* - `https://api.github.com/repos/vellum-ai/vellum-assistant/contents/plugins...`
|
|
24
24
|
* and returns 500 for anything else (forces test bugs to surface loudly).
|
|
25
25
|
*/
|
|
26
26
|
function fixtureFetch(
|
|
27
27
|
entries: Record<string, "dir" | "file" | "symlink" | "submodule">,
|
|
28
28
|
): FetchLike {
|
|
29
29
|
const PREFIX_API =
|
|
30
|
-
"https://api.github.com/repos/vellum-ai/vellum-assistant/contents/
|
|
30
|
+
"https://api.github.com/repos/vellum-ai/vellum-assistant/contents/plugins";
|
|
31
31
|
|
|
32
32
|
return (async (input: RequestInfo | URL) => {
|
|
33
33
|
const url = typeof input === "string" ? input : input.toString();
|
|
@@ -36,12 +36,12 @@ function fixtureFetch(
|
|
|
36
36
|
}
|
|
37
37
|
const body = Object.entries(entries).map(([name, type]) => ({
|
|
38
38
|
name,
|
|
39
|
-
path: `
|
|
39
|
+
path: `plugins/${name}`,
|
|
40
40
|
type,
|
|
41
41
|
size: type === "file" ? 1 : 0,
|
|
42
42
|
download_url:
|
|
43
43
|
type === "file"
|
|
44
|
-
? `https://raw.githubusercontent.com/vellum-ai/vellum-assistant/main/
|
|
44
|
+
? `https://raw.githubusercontent.com/vellum-ai/vellum-assistant/main/plugins/${name}`
|
|
45
45
|
: null,
|
|
46
46
|
}));
|
|
47
47
|
return new Response(JSON.stringify(body), {
|
|
@@ -68,7 +68,7 @@ describe("searchPlugins", () => {
|
|
|
68
68
|
"memory-graph",
|
|
69
69
|
"simple-memory",
|
|
70
70
|
]);
|
|
71
|
-
expect(result.matches[0]!.path).toBe("
|
|
71
|
+
expect(result.matches[0]!.path).toBe("plugins/memory-graph");
|
|
72
72
|
expect(result.query).toBe("memory");
|
|
73
73
|
expect(result.ref).toBe("main");
|
|
74
74
|
});
|
|
@@ -164,7 +164,7 @@ describe("searchPlugins", () => {
|
|
|
164
164
|
JSON.stringify([
|
|
165
165
|
{
|
|
166
166
|
name: "simple-memory",
|
|
167
|
-
path: "
|
|
167
|
+
path: "plugins/simple-memory",
|
|
168
168
|
type: "dir",
|
|
169
169
|
size: 0,
|
|
170
170
|
download_url: null,
|
|
@@ -294,7 +294,7 @@ describe("searchPlugins", () => {
|
|
|
294
294
|
JSON.stringify([
|
|
295
295
|
{
|
|
296
296
|
name: "simple-memory",
|
|
297
|
-
path: "
|
|
297
|
+
path: "plugins/simple-memory",
|
|
298
298
|
type: "dir",
|
|
299
299
|
size: 0,
|
|
300
300
|
download_url: null,
|
|
@@ -321,7 +321,7 @@ describe("searchPlugins", () => {
|
|
|
321
321
|
},
|
|
322
322
|
{
|
|
323
323
|
name: "simple-memory",
|
|
324
|
-
path: "
|
|
324
|
+
path: "plugins/simple-memory",
|
|
325
325
|
source: { kind: "first-party" },
|
|
326
326
|
},
|
|
327
327
|
]);
|
|
@@ -383,7 +383,7 @@ describe("searchPlugins", () => {
|
|
|
383
383
|
JSON.stringify([
|
|
384
384
|
{
|
|
385
385
|
name: "caveman",
|
|
386
|
-
path: "
|
|
386
|
+
path: "plugins/caveman",
|
|
387
387
|
type: "dir",
|
|
388
388
|
size: 0,
|
|
389
389
|
download_url: null,
|
|
@@ -422,7 +422,7 @@ describe("searchPlugins", () => {
|
|
|
422
422
|
JSON.stringify([
|
|
423
423
|
{
|
|
424
424
|
name: "simple-memory",
|
|
425
|
-
path: "
|
|
425
|
+
path: "plugins/simple-memory",
|
|
426
426
|
type: "dir",
|
|
427
427
|
size: 0,
|
|
428
428
|
download_url: null,
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
* A name resolves to one of two sources, materialized into
|
|
5
5
|
* `<workspacePluginsDir>/<name>/` so the daemon discovers it on next start:
|
|
6
6
|
* 1. A whitelisted external ecosystem plugin, when the name matches an entry
|
|
7
|
-
* in the curated `
|
|
7
|
+
* in the curated `plugins/marketplace.json` manifest. The
|
|
8
8
|
* pinned `owner/repo[/path]@ref` (see {@link ./plugin-marketplace}) is
|
|
9
9
|
* fetched with a shallow `git` clone at that ref — one network operation
|
|
10
10
|
* regardless of repo size, immune to GitHub's unauthenticated API
|
|
11
11
|
* rate-limit, and recording the exact resolved commit for provenance.
|
|
12
12
|
* When we curate an adapter stub for the plugin (an
|
|
13
|
-
* `
|
|
13
|
+
* `plugins/<name>/` directory in this repo with a
|
|
14
14
|
* `scripts.postinstall` command), the stub is overlaid onto the clone and
|
|
15
15
|
* its postinstall runs to translate a foreign-ecosystem layout into the
|
|
16
16
|
* shape Vellum's loader runs (see {@link applyAdapterStub}).
|
|
17
17
|
* 2. Otherwise the first-party convention
|
|
18
|
-
* `vellum-ai/vellum-assistant/
|
|
18
|
+
* `vellum-ai/vellum-assistant/plugins/<name>/` at the
|
|
19
19
|
* configured ref, fetched via the GitHub Contents API (a small handful of
|
|
20
20
|
* in-repo files — cloning the whole monorepo to install one would be
|
|
21
21
|
* wasteful).
|
|
@@ -54,7 +54,7 @@ const execFileAsync = promisify(execFile);
|
|
|
54
54
|
|
|
55
55
|
const PLUGIN_SOURCE_OWNER = "vellum-ai";
|
|
56
56
|
const PLUGIN_SOURCE_REPO = "vellum-assistant";
|
|
57
|
-
const PLUGIN_SOURCE_PATH_PREFIX = "
|
|
57
|
+
const PLUGIN_SOURCE_PATH_PREFIX = "plugins";
|
|
58
58
|
/** Default git ref to fetch from when callers don't override. */
|
|
59
59
|
export const DEFAULT_PLUGIN_REF = "main";
|
|
60
60
|
|
|
@@ -230,7 +230,7 @@ function sourceLabel(source: PluginFetchSource): string {
|
|
|
230
230
|
: `${source.owner}/${source.repo}`;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
/** First-party `
|
|
233
|
+
/** First-party `plugins/<name>` coordinates at a given ref. */
|
|
234
234
|
function firstPartySource(name: string, ref: string): PluginFetchSource {
|
|
235
235
|
return {
|
|
236
236
|
kind: "first-party",
|
|
@@ -245,9 +245,9 @@ function firstPartySource(name: string, ref: string): PluginFetchSource {
|
|
|
245
245
|
* Resolve a plugin name to concrete GitHub coordinates.
|
|
246
246
|
*
|
|
247
247
|
* A name claimed by the curated marketplace resolves to its pinned external
|
|
248
|
-
* repo; any other name resolves to the first-party `
|
|
248
|
+
* repo; any other name resolves to the first-party `plugins/<name>`
|
|
249
249
|
* convention. The marketplace is external-only by construction — a same-named
|
|
250
|
-
* `
|
|
250
|
+
* `plugins/<name>` directory is the plugin's optional *adapter
|
|
251
251
|
* stub* (a curated `package.json` + postinstall script overlaid onto the clone
|
|
252
252
|
* to translate it into Vellum's shape; see {@link applyAdapterStub}), not a
|
|
253
253
|
* standalone first-party plugin. So letting the marketplace win the name is
|
|
@@ -288,7 +288,7 @@ async function resolvePluginSource(
|
|
|
288
288
|
/**
|
|
289
289
|
* Reject plugin names that could escape the canonical source path or the
|
|
290
290
|
* install target. The source convention is a flat namespace under
|
|
291
|
-
* `
|
|
291
|
+
* `plugins/`, so a legitimate name is a single path segment
|
|
292
292
|
* built from kebab-case alphanumerics.
|
|
293
293
|
*
|
|
294
294
|
* Exported so callers (e.g. the CLI input prompt) can validate up front
|
|
@@ -353,10 +353,19 @@ export async function installPlugin(
|
|
|
353
353
|
throw new PluginAlreadyInstalledError(name, target);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
// Stage
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
|
|
356
|
+
// Stage *outside* the served `plugins/` directory. The daemon watches that
|
|
357
|
+
// directory and its startup loader enumerates it, so a staging dir living
|
|
358
|
+
// inside it is observed mid-install — before the adapter overlay runs, an
|
|
359
|
+
// external clone still carries its upstream `package.json` (wrong name, no
|
|
360
|
+
// plugin-api peer dep), which the loader rejects with spurious name-mismatch
|
|
361
|
+
// and missing-peer-dependency warnings. Staging in a sibling directory keeps
|
|
362
|
+
// the half-built tree invisible until the final swap. The root is on the
|
|
363
|
+
// same filesystem as the target, so that swap stays an atomic rename.
|
|
364
|
+
// `process.pid` keeps concurrent installs of the same plugin from clobbering
|
|
365
|
+
// each other's staging.
|
|
366
|
+
const stagingRoot = join(dirname(pluginsDir), ".plugins-staging");
|
|
367
|
+
mkdirSync(stagingRoot, { recursive: true });
|
|
368
|
+
const stagingDir = join(stagingRoot, `${name}.installing.${process.pid}`);
|
|
360
369
|
if (existsSync(stagingDir)) {
|
|
361
370
|
rmSync(stagingDir, { recursive: true, force: true });
|
|
362
371
|
}
|
|
@@ -431,6 +440,9 @@ export async function installPlugin(
|
|
|
431
440
|
// Atomic-ish swap: rmSync + renameSync. On POSIX the rename itself is
|
|
432
441
|
// atomic, so the only window where the target is absent is between the
|
|
433
442
|
// rm and the rename — and at that point the staging dir is fully populated.
|
|
443
|
+
// Ensure the served `plugins/` directory exists: staging now lives outside
|
|
444
|
+
// it, so the target's parent is no longer created as a side effect.
|
|
445
|
+
mkdirSync(pluginsDir, { recursive: true });
|
|
434
446
|
if (existsSync(target)) {
|
|
435
447
|
rmSync(target, { recursive: true, force: true });
|
|
436
448
|
}
|
|
@@ -534,14 +546,16 @@ const POSTINSTALL_TIMEOUT_MS = 60_000;
|
|
|
534
546
|
* Overlay our curated adapter stub onto a freshly cloned external plugin and
|
|
535
547
|
* run its postinstall transform, returning whether a transform ran.
|
|
536
548
|
*
|
|
537
|
-
* The stub lives at `
|
|
549
|
+
* The stub lives at `plugins/<name>/` in our own repo and carries
|
|
538
550
|
* a `package.json` (with a `scripts.postinstall` adapter command) plus the
|
|
539
551
|
* adapter script it names. We fetch it via the Contents API — a couple of
|
|
540
|
-
* small files, well within the rate limit — and copy it over the clone
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
* the
|
|
552
|
+
* small files, well within the rate limit — and copy it over the clone so the
|
|
553
|
+
* postinstall we run is ours, never the upstream repo's lifecycle script. The
|
|
554
|
+
* overlaid stub `package.json` exists only to name that adapter; the installed
|
|
555
|
+
* plugin's manifest is rebuilt from the upstream `package.json` afterwards (see
|
|
556
|
+
* {@link normalizeInstalledManifest}). Absent a stub (the common case for a
|
|
557
|
+
* plugin already in Vellum shape), nothing is overlaid and the clone is
|
|
558
|
+
* installed as-is.
|
|
545
559
|
*
|
|
546
560
|
* On any adapter failure the error propagates so {@link installPlugin} rolls
|
|
547
561
|
* back staging — better to fail loudly than ship a half-transformed plugin.
|
|
@@ -552,6 +566,11 @@ async function applyAdapterStub(
|
|
|
552
566
|
stagingDir: string,
|
|
553
567
|
deps: InstallPluginDeps,
|
|
554
568
|
): Promise<boolean> {
|
|
569
|
+
// Capture the cloned upstream manifest before the stub overlay replaces it,
|
|
570
|
+
// so the installed plugin can preserve it verbatim except for the two fields
|
|
571
|
+
// the Vellum loader requires (name + plugin-api peer dep).
|
|
572
|
+
const upstreamPkg = readPackageJson(join(stagingDir, "package.json"));
|
|
573
|
+
|
|
555
574
|
const stubFileCount = await copyDir(
|
|
556
575
|
PLUGIN_SOURCE_OWNER,
|
|
557
576
|
PLUGIN_SOURCE_REPO,
|
|
@@ -571,9 +590,89 @@ async function applyAdapterStub(
|
|
|
571
590
|
} catch (err) {
|
|
572
591
|
throw new PluginPostinstallError(name, subprocessErrorText(err));
|
|
573
592
|
}
|
|
593
|
+
|
|
594
|
+
normalizeInstalledManifest(name, stagingDir, upstreamPkg);
|
|
574
595
|
return true;
|
|
575
596
|
}
|
|
576
597
|
|
|
598
|
+
/**
|
|
599
|
+
* Default `@vellumai/plugin-api` peer-dependency range stamped onto an adapted
|
|
600
|
+
* plugin that doesn't already declare one.
|
|
601
|
+
*/
|
|
602
|
+
const PLUGIN_API_PEER_RANGE = ">=0.8.0";
|
|
603
|
+
|
|
604
|
+
type PackageManifest = Record<string, unknown>;
|
|
605
|
+
|
|
606
|
+
/** Parse the `package.json` at `path`, or null if it's absent or unparseable. */
|
|
607
|
+
function readPackageJson(path: string): PackageManifest | null {
|
|
608
|
+
if (!existsSync(path)) return null;
|
|
609
|
+
try {
|
|
610
|
+
const parsed: unknown = JSON.parse(readFileSync(path, "utf8"));
|
|
611
|
+
return typeof parsed === "object" &&
|
|
612
|
+
parsed !== null &&
|
|
613
|
+
!Array.isArray(parsed)
|
|
614
|
+
? (parsed as PackageManifest)
|
|
615
|
+
: null;
|
|
616
|
+
} catch {
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Write the installed plugin's final `package.json` after the adapter has run.
|
|
623
|
+
*
|
|
624
|
+
* A curated adapter stub deliberately overlays its own `package.json` onto the
|
|
625
|
+
* clone so the installer can find and run the stub's `scripts.postinstall`.
|
|
626
|
+
* That stub is install-time machinery, not the plugin's manifest, so once the
|
|
627
|
+
* adapter has run we rebuild the manifest from the upstream `package.json`
|
|
628
|
+
* captured before the overlay — preserving its `version`, `description`,
|
|
629
|
+
* `license`, and every other field — and mutate only what the Vellum loader
|
|
630
|
+
* requires: `name` must equal the install directory, and `@vellumai/plugin-api`
|
|
631
|
+
* must be declared as a peer dependency. The spent `postinstall` script is
|
|
632
|
+
* dropped so the installed plugin carries no install-time machinery.
|
|
633
|
+
*
|
|
634
|
+
* When the upstream repo shipped no `package.json`, the overlaid stub is the
|
|
635
|
+
* only manifest available, so it becomes the base instead.
|
|
636
|
+
*/
|
|
637
|
+
function normalizeInstalledManifest(
|
|
638
|
+
name: string,
|
|
639
|
+
stagingDir: string,
|
|
640
|
+
upstreamPkg: PackageManifest | null,
|
|
641
|
+
): void {
|
|
642
|
+
const manifestPath = join(stagingDir, "package.json");
|
|
643
|
+
const base = upstreamPkg ?? readPackageJson(manifestPath) ?? {};
|
|
644
|
+
|
|
645
|
+
const peer =
|
|
646
|
+
typeof base.peerDependencies === "object" && base.peerDependencies !== null
|
|
647
|
+
? (base.peerDependencies as Record<string, unknown>)
|
|
648
|
+
: {};
|
|
649
|
+
const existingRange = peer["@vellumai/plugin-api"];
|
|
650
|
+
|
|
651
|
+
const manifest: PackageManifest = {
|
|
652
|
+
...base,
|
|
653
|
+
name,
|
|
654
|
+
peerDependencies: {
|
|
655
|
+
...peer,
|
|
656
|
+
"@vellumai/plugin-api":
|
|
657
|
+
typeof existingRange === "string"
|
|
658
|
+
? existingRange
|
|
659
|
+
: PLUGIN_API_PEER_RANGE,
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
if (typeof manifest.scripts === "object" && manifest.scripts !== null) {
|
|
664
|
+
const scripts = { ...(manifest.scripts as Record<string, unknown>) };
|
|
665
|
+
delete scripts.postinstall;
|
|
666
|
+
if (Object.keys(scripts).length === 0) {
|
|
667
|
+
delete manifest.scripts;
|
|
668
|
+
} else {
|
|
669
|
+
manifest.scripts = scripts;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
674
|
+
}
|
|
675
|
+
|
|
577
676
|
/**
|
|
578
677
|
* Resolve the absolute path of the adapter script named by the (overlaid stub)
|
|
579
678
|
* `package.json`'s `scripts.postinstall`, or `null` when there is no stub
|
|
@@ -695,7 +794,8 @@ function pluginPostinstallEnv(bun: string): NodeJS.ProcessEnv {
|
|
|
695
794
|
|
|
696
795
|
/**
|
|
697
796
|
* Recursively copy regular files from `srcRoot` into `destDir`, skipping the
|
|
698
|
-
* top-level `.git` directory
|
|
797
|
+
* top-level `.git` directory, a top-level `bunfig.toml` (see below), and any
|
|
798
|
+
* symlinks. Returns the file count.
|
|
699
799
|
*/
|
|
700
800
|
function copyTreeSkippingGit(srcRoot: string, destDir: string): number {
|
|
701
801
|
let count = 0;
|
|
@@ -705,6 +805,17 @@ function copyTreeSkippingGit(srcRoot: string, destDir: string): number {
|
|
|
705
805
|
// Drop git metadata and symlinks: the loader follows neither, and a
|
|
706
806
|
// symlink could otherwise point outside the staging tree.
|
|
707
807
|
if (relDir === "" && entry.name === ".git") continue;
|
|
808
|
+
// Drop a top-level `bunfig.toml`. The adapter postinstall runs `bun` with
|
|
809
|
+
// its cwd at the staged root, and Bun auto-loads `$cwd/bunfig.toml` as
|
|
810
|
+
// project config — including a `preload` list it executes before the
|
|
811
|
+
// entry point. An upstream config would therefore run arbitrary code
|
|
812
|
+
// ahead of the curated adapter, defeating the command/env guards. Bun
|
|
813
|
+
// reads only the cwd's file (it neither walks up nor descends), so
|
|
814
|
+
// dropping it at the root closes the vector; a Vellum plugin never
|
|
815
|
+
// consumes `bunfig.toml`. Match case-insensitively because the macOS
|
|
816
|
+
// install target's filesystem is case-insensitive, where Bun would still
|
|
817
|
+
// open a clone-supplied `BUNFIG.TOML`.
|
|
818
|
+
if (relDir === "" && entry.name.toLowerCase() === "bunfig.toml") continue;
|
|
708
819
|
if (entry.isSymbolicLink()) continue;
|
|
709
820
|
|
|
710
821
|
const rel = relDir ? join(relDir, entry.name) : entry.name;
|