@vellumai/assistant 0.8.9-dev.202606091946.122706e → 0.8.9-dev.202606092047.e63da55
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/examples/plugins/echo/README.md +3 -3
- package/openapi.yaml +9 -9
- package/package.json +1 -1
- package/src/__tests__/conversation-fork-crud.test.ts +110 -0
- package/src/__tests__/conversation-runtime-assembly.test.ts +46 -2
- package/src/__tests__/external-plugin-loader.test.ts +0 -1
- package/src/__tests__/skills.test.ts +2 -2
- package/src/agent/loop.ts +11 -14
- package/src/cli/commands/plugins.ts +2 -2
- package/src/cli/lib/__tests__/install-from-github.test.ts +15 -17
- 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 +9 -9
- 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/skills.ts +13 -10
- package/src/daemon/conversation-agent-loop.ts +10 -7
- package/src/daemon/conversation-runtime-assembly.ts +7 -0
- package/src/daemon/handlers/skills.ts +3 -2
- package/src/memory/conversation-crud.ts +44 -1
- 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/plugins/defaults/memory-retrieval/hooks/post-compact.ts +47 -30
- package/src/plugins/defaults/memory-retrieval/hooks/user-prompt-submit.ts +5 -1
- package/src/plugins/external-api.ts +1 -1
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +4 -4
- package/src/runtime/routes/plugins-routes.ts +3 -3
|
@@ -16,8 +16,8 @@ to eyeball which hooks fire during a conversation.
|
|
|
16
16
|
|
|
17
17
|
For the full plugin authoring guide — manifest shape, every contribution
|
|
18
18
|
surface, hook patterns, and conventions — see
|
|
19
|
-
[`
|
|
20
|
-
[`simple-memory`](../../../../
|
|
19
|
+
[`plugins/README.md`](../../../../plugins/README.md).
|
|
20
|
+
[`simple-memory`](../../../../plugins/simple-memory/) is the
|
|
21
21
|
canonical reference implementation that exercises every wired surface.
|
|
22
22
|
|
|
23
23
|
## What it does
|
|
@@ -115,7 +115,7 @@ vellum restart
|
|
|
115
115
|
|
|
116
116
|
## Next steps
|
|
117
117
|
|
|
118
|
-
- Read [`
|
|
118
|
+
- Read [`plugins/README.md`](../../../../plugins/README.md)
|
|
119
119
|
for the full plugin authoring guide: manifest shape, every contribution
|
|
120
120
|
surface, hook patterns (observe / transform), tool contributions, and
|
|
121
121
|
conventions.
|
package/openapi.yaml
CHANGED
|
@@ -19475,11 +19475,11 @@ paths:
|
|
|
19475
19475
|
operationId: plugins_install_post
|
|
19476
19476
|
summary: Install a plugin
|
|
19477
19477
|
description:
|
|
19478
|
-
"Install a plugin by name from the canonical source — a whitelisted `
|
|
19479
|
-
|
|
19480
|
-
|
|
19481
|
-
|
|
19482
|
-
|
|
19478
|
+
"Install a plugin by name from the canonical source — a whitelisted `plugins/marketplace.json` entry, else
|
|
19479
|
+
the first-party `plugins/<name>/` convention. Always resolves against the curated default git ref (no
|
|
19480
|
+
caller-supplied ref): installing from an unreviewed revision would bypass the marketplace/first-party curation
|
|
19481
|
+
boundary and let attacker-controlled code be loaded. Materializes the plugin under
|
|
19482
|
+
`<workspaceDir>/plugins/<name>/`; the assistant must be restarted to load it. Mirrors the CLI's `assistant
|
|
19483
19483
|
plugins install <name>`. An already-installed name without `force` returns 409; a name that resolves to nothing
|
|
19484
19484
|
returns 404. Sibling to `POST /v1/skills/install`."
|
|
19485
19485
|
tags:
|
|
@@ -19541,9 +19541,9 @@ paths:
|
|
|
19541
19541
|
operationId: plugins_search_get
|
|
19542
19542
|
summary: Search the plugin catalog
|
|
19543
19543
|
description:
|
|
19544
|
-
List installable plugins from the canonical `vellum-ai/vellum-assistant` catalog at
|
|
19545
|
-
|
|
19546
|
-
|
|
19544
|
+
List installable plugins from the canonical `vellum-ai/vellum-assistant` catalog at `plugins/`. The query
|
|
19545
|
+
is an ECMAScript regex matched case-insensitively against the directory name (e.g. `memory`, `^simple`). Empty
|
|
19546
|
+
query returns every entry. Mirrors the CLI's `assistant plugins search`.
|
|
19547
19547
|
tags:
|
|
19548
19548
|
- plugins
|
|
19549
19549
|
responses:
|
|
@@ -19571,7 +19571,7 @@ paths:
|
|
|
19571
19571
|
path:
|
|
19572
19572
|
type: string
|
|
19573
19573
|
description:
|
|
19574
|
-
"Human-readable origin: a repo-relative path (`
|
|
19574
|
+
"Human-readable origin: a repo-relative path (`plugins/<name>`) for first-party plugins or a
|
|
19575
19575
|
`github:owner/repo@ref` locator for external ones."
|
|
19576
19576
|
description:
|
|
19577
19577
|
description: Short description, when known (external entries only today).
|
package/package.json
CHANGED
|
@@ -922,6 +922,116 @@ describe("forkConversation", () => {
|
|
|
922
922
|
expect(loadGraphMemoryState(fork.id)).toBeNull();
|
|
923
923
|
});
|
|
924
924
|
|
|
925
|
+
test("truncated fork seeds everInjected from inherited memory attachments", async () => {
|
|
926
|
+
const source = createConversation("Truncated seed thread");
|
|
927
|
+
await addMessage(source.id, "user", "first turn", {
|
|
928
|
+
metadata: {
|
|
929
|
+
memoryInjectedBlock:
|
|
930
|
+
"# memory/concepts/topics/page-a.md\nSummary A\n\n# memory/concepts/topics/page-b.md\nSummary B",
|
|
931
|
+
},
|
|
932
|
+
skipIndexing: true,
|
|
933
|
+
});
|
|
934
|
+
await addMessage(source.id, "assistant", "first reply", {
|
|
935
|
+
skipIndexing: true,
|
|
936
|
+
});
|
|
937
|
+
const boundaryMessage = await addMessage(source.id, "user", "second turn", {
|
|
938
|
+
metadata: {
|
|
939
|
+
memoryInjectedBlock: "# memory/concepts/topics/page-c.md\nSummary C",
|
|
940
|
+
},
|
|
941
|
+
skipIndexing: true,
|
|
942
|
+
});
|
|
943
|
+
await addMessage(source.id, "assistant", "second reply", {
|
|
944
|
+
skipIndexing: true,
|
|
945
|
+
});
|
|
946
|
+
// Past the fork boundary — its attachment must NOT be claimed.
|
|
947
|
+
await addMessage(source.id, "user", "third turn", {
|
|
948
|
+
metadata: {
|
|
949
|
+
memoryInjectedBlock: "# memory/concepts/topics/page-d.md\nSummary D",
|
|
950
|
+
},
|
|
951
|
+
skipIndexing: true,
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
const db = getDb();
|
|
955
|
+
db.insert(activationState)
|
|
956
|
+
.values({
|
|
957
|
+
conversationId: source.id,
|
|
958
|
+
messageId: "parent-msg",
|
|
959
|
+
stateJson: JSON.stringify({ "topics/page-d": 0.9 }),
|
|
960
|
+
everInjectedJson: JSON.stringify([
|
|
961
|
+
{ slug: "topics/page-a", turn: 1 },
|
|
962
|
+
{ slug: "topics/page-b", turn: 1 },
|
|
963
|
+
{ slug: "topics/page-c", turn: 2 },
|
|
964
|
+
{ slug: "topics/page-d", turn: 3 },
|
|
965
|
+
]),
|
|
966
|
+
currentTurn: 3,
|
|
967
|
+
updatedAt: 1_700_000_000_000,
|
|
968
|
+
})
|
|
969
|
+
.run();
|
|
970
|
+
|
|
971
|
+
const fork = forkConversation({
|
|
972
|
+
conversationId: source.id,
|
|
973
|
+
throughMessageId: boundaryMessage.id,
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
const childState = await hydrateActivationState(db, fork.id);
|
|
977
|
+
expect(childState).not.toBeNull();
|
|
978
|
+
// Exactly the slugs whose attachments live in the copied history —
|
|
979
|
+
// page-d (injected past the boundary) stays re-injectable.
|
|
980
|
+
expect(childState?.everInjected.map((e) => e.slug).sort()).toEqual([
|
|
981
|
+
"topics/page-a",
|
|
982
|
+
"topics/page-b",
|
|
983
|
+
"topics/page-c",
|
|
984
|
+
]);
|
|
985
|
+
expect(childState?.everInjected.every((e) => e.turn === 0)).toBe(true);
|
|
986
|
+
// Activation scores and the turn counter start fresh, matching the
|
|
987
|
+
// graph tracker (also not copied for truncated forks).
|
|
988
|
+
expect(childState?.state).toEqual({});
|
|
989
|
+
expect(childState?.currentTurn).toBe(0);
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
test("truncated fork ignores attachments behind an inherited compaction boundary", async () => {
|
|
993
|
+
const source = createConversation("Compacted truncated thread");
|
|
994
|
+
await addMessage(source.id, "user", "compacted turn", {
|
|
995
|
+
metadata: {
|
|
996
|
+
memoryInjectedBlock:
|
|
997
|
+
"# memory/concepts/topics/page-compacted.md\nOld summary",
|
|
998
|
+
},
|
|
999
|
+
skipIndexing: true,
|
|
1000
|
+
});
|
|
1001
|
+
await addMessage(source.id, "assistant", "compacted reply", {
|
|
1002
|
+
skipIndexing: true,
|
|
1003
|
+
});
|
|
1004
|
+
const boundaryMessage = await addMessage(source.id, "user", "live turn", {
|
|
1005
|
+
metadata: {
|
|
1006
|
+
memoryInjectedBlock: "# memory/concepts/topics/page-live.md\nSummary",
|
|
1007
|
+
},
|
|
1008
|
+
skipIndexing: true,
|
|
1009
|
+
});
|
|
1010
|
+
await addMessage(source.id, "assistant", "live reply", {
|
|
1011
|
+
skipIndexing: true,
|
|
1012
|
+
});
|
|
1013
|
+
await addMessage(source.id, "user", "past boundary", {
|
|
1014
|
+
skipIndexing: true,
|
|
1015
|
+
});
|
|
1016
|
+
// First two messages sit behind the compaction boundary: their
|
|
1017
|
+
// attachments are not rendered, so the fork must not claim them.
|
|
1018
|
+
getDb()
|
|
1019
|
+
.update(conversations)
|
|
1020
|
+
.set({ contextCompactedMessageCount: 2 })
|
|
1021
|
+
.where(eq(conversations.id, source.id))
|
|
1022
|
+
.run();
|
|
1023
|
+
|
|
1024
|
+
const fork = forkConversation({
|
|
1025
|
+
conversationId: source.id,
|
|
1026
|
+
throughMessageId: boundaryMessage.id,
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
const childState = await hydrateActivationState(getDb(), fork.id);
|
|
1030
|
+
expect(childState?.everInjected.map((e) => e.slug)).toEqual([
|
|
1031
|
+
"topics/page-live",
|
|
1032
|
+
]);
|
|
1033
|
+
});
|
|
1034
|
+
|
|
925
1035
|
test("defaults conversationType to standard and inherits the parent's group", async () => {
|
|
926
1036
|
const source = createConversation("Default inheritance thread");
|
|
927
1037
|
await addMessage(source.id, "user", "first message", {
|
|
@@ -64,6 +64,7 @@ mock.module("../daemon/date-context.js", () => ({
|
|
|
64
64
|
formatTurnTimestamp: () => FIXED_TURN_TIMESTAMP,
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
+
import { resolveCallSiteConfig } from "../config/llm-resolver.js";
|
|
67
68
|
import { LLMSchema } from "../config/schemas/llm.js";
|
|
68
69
|
import {
|
|
69
70
|
clearConversations,
|
|
@@ -1037,8 +1038,7 @@ describe("applyRuntimeInjections — injection mode", () => {
|
|
|
1037
1038
|
conversationId: "injection-mode-conv",
|
|
1038
1039
|
trust: { sourceChannel: "vellum", trustClass: "guardian" },
|
|
1039
1040
|
isNonInteractive: false,
|
|
1040
|
-
|
|
1041
|
-
modelProfile: null,
|
|
1041
|
+
modelProfileKey: null,
|
|
1042
1042
|
actorContext: null,
|
|
1043
1043
|
};
|
|
1044
1044
|
await postCompact(postCompactCtx);
|
|
@@ -1576,6 +1576,50 @@ describe("resolveTurnModelProfileLabel", () => {
|
|
|
1576
1576
|
// THEN the raw key stands in for the missing label
|
|
1577
1577
|
expect(label).toBe("deep (claude-opus-4)");
|
|
1578
1578
|
});
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* A key naming a `mix` profile must announce the arm the turn's provider
|
|
1582
|
+
* calls actually run on. The conversation id is threaded as the selection
|
|
1583
|
+
* seed so the announced model is a deterministic function of the
|
|
1584
|
+
* conversation, matching the seeded expansion the provider layer performs.
|
|
1585
|
+
*/
|
|
1586
|
+
test("announces the seeded mix arm so it matches the turn's model", () => {
|
|
1587
|
+
// GIVEN a mix profile routing between two models
|
|
1588
|
+
const llm = LLMSchema.parse({
|
|
1589
|
+
default: { provider: "anthropic", model: "claude-sonnet-4-7" },
|
|
1590
|
+
profiles: {
|
|
1591
|
+
a: { label: "Arm A", provider: "anthropic", model: "model-a" },
|
|
1592
|
+
b: { label: "Arm B", provider: "anthropic", model: "model-b" },
|
|
1593
|
+
ab: {
|
|
1594
|
+
label: "AB",
|
|
1595
|
+
mix: [
|
|
1596
|
+
{ profile: "a", weight: 50 },
|
|
1597
|
+
{ profile: "b", weight: 50 },
|
|
1598
|
+
],
|
|
1599
|
+
},
|
|
1600
|
+
},
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
// AND the model the provider calls resolve to for this conversation's seed
|
|
1604
|
+
const seededModel = resolveCallSiteConfig("mainAgent", llm, {
|
|
1605
|
+
overrideProfile: "ab",
|
|
1606
|
+
selectionSeed: "conv-seed-1",
|
|
1607
|
+
}).model;
|
|
1608
|
+
|
|
1609
|
+
// WHEN the label is resolved with the same conversation seed
|
|
1610
|
+
const label = resolveTurnModelProfileLabel(
|
|
1611
|
+
"ab",
|
|
1612
|
+
"mainAgent",
|
|
1613
|
+
llm,
|
|
1614
|
+
"conv-seed-1",
|
|
1615
|
+
);
|
|
1616
|
+
|
|
1617
|
+
// THEN the announced model is the seeded arm (deterministic, not re-rolled)
|
|
1618
|
+
expect(label).toBe(`AB (${seededModel})`);
|
|
1619
|
+
expect(
|
|
1620
|
+
resolveTurnModelProfileLabel("ab", "mainAgent", llm, "conv-seed-1"),
|
|
1621
|
+
).toBe(label);
|
|
1622
|
+
});
|
|
1579
1623
|
});
|
|
1580
1624
|
|
|
1581
1625
|
// ---------------------------------------------------------------------------
|
|
@@ -304,7 +304,7 @@ describe("plugin-resident skills", () => {
|
|
|
304
304
|
const skill = loadSkillCatalog().find((s) => s.id === "caveman");
|
|
305
305
|
expect(skill).toBeDefined();
|
|
306
306
|
expect(skill!.source).toBe("plugin");
|
|
307
|
-
expect(skill!.
|
|
307
|
+
expect(skill!.owner).toEqual({ kind: "plugin", id: "caveman" });
|
|
308
308
|
});
|
|
309
309
|
|
|
310
310
|
test("loadSkillBySelector loads a plugin-resident skill body", () => {
|
|
@@ -321,7 +321,7 @@ describe("plugin-resident skills", () => {
|
|
|
321
321
|
expect(result.skill).toBeDefined();
|
|
322
322
|
expect(result.skill!.source).toBe("plugin");
|
|
323
323
|
expect(result.skill!.body).toBe("Full plugin skill body");
|
|
324
|
-
expect(result.skill!.
|
|
324
|
+
expect(result.skill!.owner).toEqual({ kind: "plugin", id: "caveman" });
|
|
325
325
|
});
|
|
326
326
|
|
|
327
327
|
test("ignores plugin directories without a package.json (staging/stray dirs)", () => {
|
package/src/agent/loop.ts
CHANGED
|
@@ -511,15 +511,14 @@ export interface AgentLoopRunOptions {
|
|
|
511
511
|
*/
|
|
512
512
|
isNonInteractive?: boolean;
|
|
513
513
|
/**
|
|
514
|
-
* The
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
* re-
|
|
519
|
-
*
|
|
520
|
-
* `null` when omitted.
|
|
514
|
+
* The turn's resolved inference-profile key, or `null` when the active
|
|
515
|
+
* profile is unchanged since the last notified one. Forwarded to
|
|
516
|
+
* {@link postCompact}, which renders the `model_profile:` label from it so
|
|
517
|
+
* post-compaction re-injection re-emits the turn-start profile rather than
|
|
518
|
+
* re-deriving the change-detected value (which flips once the notification is
|
|
519
|
+
* persisted mid-turn). Defaults to `null` when omitted.
|
|
521
520
|
*/
|
|
522
|
-
|
|
521
|
+
modelProfileKey?: string | null;
|
|
523
522
|
/**
|
|
524
523
|
* Inbound actor identity and trust fields for the unified `<turn_context>`
|
|
525
524
|
* block, or `null` on guardian turns. Resolved once by the orchestrator at
|
|
@@ -717,7 +716,7 @@ export class AgentLoop {
|
|
|
717
716
|
onEvent: (event: AgentEvent) => void | Promise<void>,
|
|
718
717
|
overrideProfile: string | null,
|
|
719
718
|
isNonInteractive: boolean,
|
|
720
|
-
|
|
719
|
+
modelProfileKey: string | null,
|
|
721
720
|
actorContext: InboundActorContext | null,
|
|
722
721
|
): Promise<Message[] | null> {
|
|
723
722
|
await onEvent({ type: "context_compacting" });
|
|
@@ -775,9 +774,7 @@ export class AgentLoop {
|
|
|
775
774
|
conversationId: this.conversationId,
|
|
776
775
|
trust,
|
|
777
776
|
isNonInteractive,
|
|
778
|
-
|
|
779
|
-
mode: "full",
|
|
780
|
-
modelProfile,
|
|
777
|
+
modelProfileKey,
|
|
781
778
|
actorContext,
|
|
782
779
|
};
|
|
783
780
|
// The hook writes the re-injected history back onto the context; read it
|
|
@@ -800,7 +797,7 @@ export class AgentLoop {
|
|
|
800
797
|
resolveContextWindow,
|
|
801
798
|
compactInPlace = false,
|
|
802
799
|
isNonInteractive = false,
|
|
803
|
-
|
|
800
|
+
modelProfileKey = null,
|
|
804
801
|
actorContext = null,
|
|
805
802
|
} = options;
|
|
806
803
|
let history = [...messages];
|
|
@@ -928,7 +925,7 @@ export class AgentLoop {
|
|
|
928
925
|
onEvent,
|
|
929
926
|
resolveEffectiveOverrideProfile() ?? null,
|
|
930
927
|
isNonInteractive,
|
|
931
|
-
|
|
928
|
+
modelProfileKey,
|
|
932
929
|
actorContext,
|
|
933
930
|
);
|
|
934
931
|
if (compacted) {
|
|
@@ -55,7 +55,7 @@ Examples:
|
|
|
55
55
|
plugins
|
|
56
56
|
.command("install <name>")
|
|
57
57
|
.description(
|
|
58
|
-
"Install a plugin from vellum-ai/vellum-assistant/
|
|
58
|
+
"Install a plugin from vellum-ai/vellum-assistant/plugins/<name>",
|
|
59
59
|
)
|
|
60
60
|
.option("--force", "Overwrite an existing install")
|
|
61
61
|
.option(
|
|
@@ -150,7 +150,7 @@ Examples:
|
|
|
150
150
|
plugins
|
|
151
151
|
.command("search <query>")
|
|
152
152
|
.description(
|
|
153
|
-
"Search vellum-ai/vellum-assistant/
|
|
153
|
+
"Search vellum-ai/vellum-assistant/plugins for plugin names matching <query> (case-insensitive regex)",
|
|
154
154
|
)
|
|
155
155
|
.option("--json", "Emit machine-readable JSON instead of a table")
|
|
156
156
|
.action(async (query: string, opts: { json?: boolean }) => {
|
|
@@ -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({
|
|
@@ -897,7 +895,7 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
897
895
|
|
|
898
896
|
test("does not run a postinstall for a raw clone without an adapter stub", async () => {
|
|
899
897
|
// GIVEN caveman is whitelisted but we curate NO adapter stub for it
|
|
900
|
-
// (the Contents API has no
|
|
898
|
+
// (the Contents API has no plugins/caveman directory)
|
|
901
899
|
const fetch = makeContentsFetch({ tree: {}, manifest: CAVEMAN_MANIFEST });
|
|
902
900
|
const runGit = fakeGitRunner({
|
|
903
901
|
tree: { "package.json": '{"name":"caveman"}', "hooks/init.ts": "//" },
|
|
@@ -925,11 +923,11 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
925
923
|
// GIVEN a whitelisted plugin with a curated stub declaring a postinstall
|
|
926
924
|
const fetch = makeContentsFetch({
|
|
927
925
|
tree: {
|
|
928
|
-
"
|
|
926
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
929
927
|
name: "caveman",
|
|
930
928
|
scripts: { postinstall: "bun ./postinstall.ts" },
|
|
931
929
|
}),
|
|
932
|
-
"
|
|
930
|
+
"plugins/caveman/postinstall.ts": "// adapter",
|
|
933
931
|
},
|
|
934
932
|
manifest: CAVEMAN_MANIFEST,
|
|
935
933
|
});
|
|
@@ -959,7 +957,7 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
959
957
|
// rather than the supported `bun <script>` adapter convention
|
|
960
958
|
const fetch = makeContentsFetch({
|
|
961
959
|
tree: {
|
|
962
|
-
"
|
|
960
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
963
961
|
name: "caveman",
|
|
964
962
|
scripts: { postinstall: "rm -rf /" },
|
|
965
963
|
}),
|
|
@@ -990,11 +988,11 @@ describe("installPlugin — marketplace resolution", () => {
|
|
|
990
988
|
// with a postinstall + adapter script, but no hooks/tools of its own)
|
|
991
989
|
const fetch = makeContentsFetch({
|
|
992
990
|
tree: {
|
|
993
|
-
"
|
|
991
|
+
"plugins/caveman/package.json": JSON.stringify({
|
|
994
992
|
name: "caveman",
|
|
995
993
|
scripts: { postinstall: "bun ./postinstall.ts" },
|
|
996
994
|
}),
|
|
997
|
-
"
|
|
995
|
+
"plugins/caveman/postinstall.ts": "// adapter",
|
|
998
996
|
},
|
|
999
997
|
manifestStatus: 500,
|
|
1000
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,
|