@vellumai/assistant 0.8.8-dev.202606082331.c911d0c → 0.8.8-dev.202606090218.6bcb462
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/openapi.yaml +15 -114
- package/package.json +1 -1
- package/src/__tests__/anthropic-provider.test.ts +23 -8
- package/src/__tests__/conversation-tool-setup-app-refresh.test.ts +73 -4
- package/src/__tests__/published-app-updater.test.ts +138 -0
- package/src/api/responses/memory-v3-selection-log.ts +19 -10
- package/src/cli/commands/__tests__/memory-v3.test.ts +191 -210
- package/src/cli/commands/memory-v3.ts +57 -199
- package/src/config/call-site-defaults.ts +0 -1
- package/src/config/schemas/__tests__/memory-v3.test.ts +25 -9
- package/src/config/schemas/call-site-catalog.ts +0 -7
- package/src/config/schemas/llm.ts +0 -1
- package/src/config/schemas/memory-v3.ts +58 -8
- package/src/daemon/tool-side-effects.ts +15 -0
- package/src/memory/v2/__tests__/consolidation-job.test.ts +4 -97
- package/src/memory/v2/__tests__/page-store.test.ts +22 -0
- package/src/memory/v2/consolidation-job.ts +2 -72
- package/src/memory/v2/types.ts +5 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/capabilities.test.ts +19 -66
- package/src/plugins/defaults/memory-v3-shadow/__tests__/dense.test.ts +181 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/edge.test.ts +247 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/live-integration.test.ts +139 -129
- package/src/plugins/defaults/memory-v3-shadow/__tests__/maintain-job.test.ts +332 -164
- package/src/plugins/defaults/memory-v3-shadow/__tests__/orchestrate.test.ts +516 -293
- package/src/plugins/defaults/memory-v3-shadow/__tests__/pool-select.test.ts +306 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/render-injection.test.ts +51 -21
- package/src/plugins/defaults/memory-v3-shadow/__tests__/section-dense-store.test.ts +402 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/section-needle.test.ts +135 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/sections.test.ts +125 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/selection-log-store.test.ts +66 -11
- package/src/plugins/defaults/memory-v3-shadow/__tests__/shadow-integration.test.ts +446 -0
- package/src/plugins/defaults/memory-v3-shadow/__tests__/shadow-plugin.test.ts +271 -110
- package/src/plugins/defaults/memory-v3-shadow/__tests__/types.test.ts +0 -22
- package/src/plugins/defaults/memory-v3-shadow/capabilities.ts +26 -62
- package/src/plugins/defaults/memory-v3-shadow/dense.ts +97 -0
- package/src/plugins/defaults/memory-v3-shadow/edge.ts +252 -0
- package/src/plugins/defaults/memory-v3-shadow/injector.ts +3 -2
- package/src/plugins/defaults/memory-v3-shadow/maintain-job.ts +415 -181
- package/src/plugins/defaults/memory-v3-shadow/orchestrate.ts +196 -56
- package/src/plugins/defaults/memory-v3-shadow/page-content.ts +39 -2
- package/src/plugins/defaults/memory-v3-shadow/pool-select.ts +204 -0
- package/src/plugins/defaults/memory-v3-shadow/render-injection.ts +15 -7
- package/src/plugins/defaults/memory-v3-shadow/section-dense-store.ts +236 -0
- package/src/plugins/defaults/memory-v3-shadow/section-needle.ts +200 -0
- package/src/plugins/defaults/memory-v3-shadow/sections.ts +115 -0
- package/src/plugins/defaults/memory-v3-shadow/selection-log-store.ts +75 -3
- package/src/plugins/defaults/memory-v3-shadow/shadow-plugin.ts +111 -78
- package/src/plugins/defaults/memory-v3-shadow/types.ts +52 -19
- package/src/plugins/defaults/memory-v3-shadow/working-set.ts +4 -1
- package/src/providers/anthropic/client.ts +9 -10
- package/src/runtime/routes/app-management-routes.ts +3 -0
- package/src/runtime/routes/memory-v3-routes.ts +64 -314
- package/src/services/published-app-updater.ts +30 -8
- package/src/plugins/defaults/memory-v3-shadow/__tests__/assign.test.ts +0 -242
- package/src/plugins/defaults/memory-v3-shadow/__tests__/core.test.ts +0 -39
- package/src/plugins/defaults/memory-v3-shadow/__tests__/health.test.ts +0 -219
- package/src/plugins/defaults/memory-v3-shadow/__tests__/needle.test.ts +0 -107
- package/src/plugins/defaults/memory-v3-shadow/__tests__/provider-blocks.test.ts +0 -13
- package/src/plugins/defaults/memory-v3-shadow/__tests__/reconcile.test.ts +0 -274
- package/src/plugins/defaults/memory-v3-shadow/__tests__/router.test.ts +0 -337
- package/src/plugins/defaults/memory-v3-shadow/__tests__/selector.test.ts +0 -470
- package/src/plugins/defaults/memory-v3-shadow/__tests__/snapshot.test.ts +0 -168
- package/src/plugins/defaults/memory-v3-shadow/__tests__/tree.test.ts +0 -192
- package/src/plugins/defaults/memory-v3-shadow/assign.ts +0 -272
- package/src/plugins/defaults/memory-v3-shadow/core.ts +0 -26
- package/src/plugins/defaults/memory-v3-shadow/health.ts +0 -0
- package/src/plugins/defaults/memory-v3-shadow/needle.ts +0 -115
- package/src/plugins/defaults/memory-v3-shadow/provider-blocks.ts +0 -26
- package/src/plugins/defaults/memory-v3-shadow/reconcile.ts +0 -527
- package/src/plugins/defaults/memory-v3-shadow/router.ts +0 -190
- package/src/plugins/defaults/memory-v3-shadow/selector.ts +0 -226
- package/src/plugins/defaults/memory-v3-shadow/snapshot.ts +0 -209
- package/src/plugins/defaults/memory-v3-shadow/tree.ts +0 -174
- package/src/util/map-limit.ts +0 -27
package/openapi.yaml
CHANGED
|
@@ -480,6 +480,8 @@ paths:
|
|
|
480
480
|
type: string
|
|
481
481
|
createdAt:
|
|
482
482
|
type: number
|
|
483
|
+
updatedAt:
|
|
484
|
+
type: number
|
|
483
485
|
version:
|
|
484
486
|
type: string
|
|
485
487
|
contentId:
|
|
@@ -488,6 +490,7 @@ paths:
|
|
|
488
490
|
- id
|
|
489
491
|
- name
|
|
490
492
|
- createdAt
|
|
493
|
+
- updatedAt
|
|
491
494
|
- version
|
|
492
495
|
- contentId
|
|
493
496
|
additionalProperties: false
|
|
@@ -15854,10 +15857,10 @@ paths:
|
|
|
15854
15857
|
type: object
|
|
15855
15858
|
properties: {}
|
|
15856
15859
|
additionalProperties: false
|
|
15857
|
-
/v1/memory/v3/
|
|
15860
|
+
/v1/memory/v3/backfill-sections:
|
|
15858
15861
|
post:
|
|
15859
|
-
operationId:
|
|
15860
|
-
summary:
|
|
15862
|
+
operationId: memory_v3_backfillsections_post
|
|
15863
|
+
summary: "One-time: embed every page's sections (incl synthetic skill/CLI rows) into the dense store"
|
|
15861
15864
|
tags:
|
|
15862
15865
|
- memory
|
|
15863
15866
|
responses:
|
|
@@ -15868,31 +15871,16 @@ paths:
|
|
|
15868
15871
|
schema:
|
|
15869
15872
|
type: object
|
|
15870
15873
|
properties:
|
|
15871
|
-
|
|
15872
|
-
type:
|
|
15873
|
-
|
|
15874
|
-
type:
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
type: number
|
|
15878
|
-
danglingRefs:
|
|
15879
|
-
type: number
|
|
15880
|
-
novelClusters:
|
|
15881
|
-
type: number
|
|
15882
|
-
oversizedLeaves:
|
|
15883
|
-
type: number
|
|
15884
|
-
tinyLeaves:
|
|
15885
|
-
type: number
|
|
15886
|
-
required:
|
|
15887
|
-
- unassigned
|
|
15888
|
-
- danglingRefs
|
|
15889
|
-
- novelClusters
|
|
15890
|
-
- oversizedLeaves
|
|
15891
|
-
- tinyLeaves
|
|
15892
|
-
additionalProperties: false
|
|
15874
|
+
articles:
|
|
15875
|
+
type: number
|
|
15876
|
+
sections:
|
|
15877
|
+
type: number
|
|
15878
|
+
failures:
|
|
15879
|
+
type: number
|
|
15893
15880
|
required:
|
|
15894
|
-
-
|
|
15895
|
-
-
|
|
15881
|
+
- articles
|
|
15882
|
+
- sections
|
|
15883
|
+
- failures
|
|
15896
15884
|
additionalProperties: false
|
|
15897
15885
|
/v1/memory/v3/rebuild-index:
|
|
15898
15886
|
post:
|
|
@@ -15914,93 +15902,6 @@ paths:
|
|
|
15914
15902
|
required:
|
|
15915
15903
|
- ok
|
|
15916
15904
|
additionalProperties: false
|
|
15917
|
-
/v1/memory/v3/reconcile:
|
|
15918
|
-
post:
|
|
15919
|
-
operationId: memory_v3_reconcile_post
|
|
15920
|
-
summary: v1 convergence/prune pass over page+core refs (no rename detection without a prior snapshot)
|
|
15921
|
-
tags:
|
|
15922
|
-
- memory
|
|
15923
|
-
responses:
|
|
15924
|
-
"200":
|
|
15925
|
-
description: Successful response
|
|
15926
|
-
content:
|
|
15927
|
-
application/json:
|
|
15928
|
-
schema:
|
|
15929
|
-
type: object
|
|
15930
|
-
properties:
|
|
15931
|
-
renames:
|
|
15932
|
-
type: array
|
|
15933
|
-
items:
|
|
15934
|
-
type: object
|
|
15935
|
-
properties:
|
|
15936
|
-
id:
|
|
15937
|
-
type: string
|
|
15938
|
-
oldPath:
|
|
15939
|
-
type: string
|
|
15940
|
-
newPath:
|
|
15941
|
-
type: string
|
|
15942
|
-
required:
|
|
15943
|
-
- oldPath
|
|
15944
|
-
- newPath
|
|
15945
|
-
additionalProperties: false
|
|
15946
|
-
deleted:
|
|
15947
|
-
type: array
|
|
15948
|
-
items:
|
|
15949
|
-
type: string
|
|
15950
|
-
prunedCore:
|
|
15951
|
-
type: array
|
|
15952
|
-
items:
|
|
15953
|
-
type: string
|
|
15954
|
-
required:
|
|
15955
|
-
- renames
|
|
15956
|
-
- deleted
|
|
15957
|
-
- prunedCore
|
|
15958
|
-
additionalProperties: false
|
|
15959
|
-
/v1/memory/v3/set-core:
|
|
15960
|
-
post:
|
|
15961
|
-
operationId: memory_v3_setcore_post
|
|
15962
|
-
summary: Add/remove always-on core leaves (validates + previews cost)
|
|
15963
|
-
tags:
|
|
15964
|
-
- memory
|
|
15965
|
-
responses:
|
|
15966
|
-
"200":
|
|
15967
|
-
description: Successful response
|
|
15968
|
-
content:
|
|
15969
|
-
application/json:
|
|
15970
|
-
schema:
|
|
15971
|
-
type: object
|
|
15972
|
-
properties:
|
|
15973
|
-
nextCore:
|
|
15974
|
-
type: array
|
|
15975
|
-
items:
|
|
15976
|
-
type: string
|
|
15977
|
-
alwaysOnPageCount:
|
|
15978
|
-
type: number
|
|
15979
|
-
written:
|
|
15980
|
-
type: boolean
|
|
15981
|
-
required:
|
|
15982
|
-
- nextCore
|
|
15983
|
-
- alwaysOnPageCount
|
|
15984
|
-
- written
|
|
15985
|
-
additionalProperties: false
|
|
15986
|
-
requestBody:
|
|
15987
|
-
required: true
|
|
15988
|
-
content:
|
|
15989
|
-
application/json:
|
|
15990
|
-
schema:
|
|
15991
|
-
type: object
|
|
15992
|
-
properties:
|
|
15993
|
-
add:
|
|
15994
|
-
type: array
|
|
15995
|
-
items:
|
|
15996
|
-
type: string
|
|
15997
|
-
remove:
|
|
15998
|
-
type: array
|
|
15999
|
-
items:
|
|
16000
|
-
type: string
|
|
16001
|
-
write:
|
|
16002
|
-
type: boolean
|
|
16003
|
-
additionalProperties: false
|
|
16004
15905
|
/v1/messages:
|
|
16005
15906
|
get:
|
|
16006
15907
|
operationId: messages_get
|
package/package.json
CHANGED
|
@@ -2,7 +2,11 @@ import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
|
2
2
|
|
|
3
3
|
import type { Anthropic } from "@anthropic-ai/sdk";
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
ContentBlock,
|
|
7
|
+
Message,
|
|
8
|
+
ToolDefinition,
|
|
9
|
+
} from "../providers/types.js";
|
|
6
10
|
|
|
7
11
|
// ---------------------------------------------------------------------------
|
|
8
12
|
// Mock Anthropic SDK — must be before importing the provider
|
|
@@ -102,7 +106,6 @@ mock.module("@anthropic-ai/sdk", () => ({
|
|
|
102
106
|
}));
|
|
103
107
|
|
|
104
108
|
// Import after mocking
|
|
105
|
-
import { cachedTextBlock } from "../plugins/defaults/memory-v3-shadow/provider-blocks.js";
|
|
106
109
|
import { AnthropicProvider } from "../providers/anthropic/client.js";
|
|
107
110
|
import {
|
|
108
111
|
isPlaceholderSentinelText,
|
|
@@ -138,6 +141,18 @@ function toolResultMsg(toolUseId: string, content: string): Message {
|
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
// A stable prefix text block carrying a 1h-TTL cache_control breakpoint, as a
|
|
145
|
+
// caller may stamp before the provider sees it. The internal ContentBlock type
|
|
146
|
+
// omits cache_control (only the provider transforms it onto the wire), so reach
|
|
147
|
+
// it via a cast.
|
|
148
|
+
function cachedPrefixBlock(text: string): ContentBlock {
|
|
149
|
+
return {
|
|
150
|
+
type: "text",
|
|
151
|
+
text,
|
|
152
|
+
cache_control: { type: "ephemeral", ttl: "1h" },
|
|
153
|
+
} as unknown as ContentBlock;
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
const sampleTools: ToolDefinition[] = [
|
|
142
157
|
{
|
|
143
158
|
name: "file_read",
|
|
@@ -325,13 +340,13 @@ describe("AnthropicProvider — Cache-Control Characterization", () => {
|
|
|
325
340
|
});
|
|
326
341
|
|
|
327
342
|
test("preserves a caller's 1h block cache_control and sends the extended-cache beta (non-Haiku)", async () => {
|
|
328
|
-
//
|
|
329
|
-
//
|
|
343
|
+
// A caller that stamps a stable prefix block with a 1h TTL: the non-Haiku
|
|
344
|
+
// path must forward it unchanged and send the beta header.
|
|
330
345
|
await provider.sendMessage([
|
|
331
346
|
{
|
|
332
347
|
role: "user",
|
|
333
348
|
content: [
|
|
334
|
-
|
|
349
|
+
cachedPrefixBlock("stable pages block"),
|
|
335
350
|
{ type: "text", text: "volatile current message" },
|
|
336
351
|
],
|
|
337
352
|
},
|
|
@@ -349,7 +364,7 @@ describe("AnthropicProvider — Cache-Control Characterization", () => {
|
|
|
349
364
|
|
|
350
365
|
test("strips ttl from a caller's block cache_control and omits the beta for Haiku", async () => {
|
|
351
366
|
// Haiku doesn't support the extended-cache-ttl beta, so a caller-stamped
|
|
352
|
-
// 1h ttl
|
|
367
|
+
// 1h ttl on a message block must be stripped before sending.
|
|
353
368
|
const haiku = new AnthropicProvider(
|
|
354
369
|
"sk-ant-test",
|
|
355
370
|
"claude-haiku-4-5-20251001",
|
|
@@ -358,7 +373,7 @@ describe("AnthropicProvider — Cache-Control Characterization", () => {
|
|
|
358
373
|
{
|
|
359
374
|
role: "user",
|
|
360
375
|
content: [
|
|
361
|
-
|
|
376
|
+
cachedPrefixBlock("stable pages block"),
|
|
362
377
|
{ type: "text", text: "volatile current message" },
|
|
363
378
|
],
|
|
364
379
|
},
|
|
@@ -385,7 +400,7 @@ describe("AnthropicProvider — Cache-Control Characterization", () => {
|
|
|
385
400
|
{
|
|
386
401
|
role: "user",
|
|
387
402
|
content: [
|
|
388
|
-
|
|
403
|
+
cachedPrefixBlock("stable pages block"),
|
|
389
404
|
{ type: "text", text: "volatile current message" },
|
|
390
405
|
],
|
|
391
406
|
},
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Regression tests for app surface refresh and eventing side effects in
|
|
3
3
|
* createToolExecutor (conversation-tool-setup.ts).
|
|
4
4
|
*
|
|
5
|
-
* Tests verify that app_refresh, app_create, and app_delete hooks
|
|
6
|
-
* correctly, and that
|
|
7
|
-
*
|
|
5
|
+
* Tests verify that app_refresh, app_update, app_create, and app_delete hooks
|
|
6
|
+
* fire correctly, and that non-hooked tools (app_file_edit, app_file_write) do
|
|
7
|
+
* not trigger side effects.
|
|
8
8
|
*
|
|
9
9
|
* File-change detection for file_write/file_edit is handled by
|
|
10
10
|
* AppSourceWatcher (see app-source-watcher.test.ts).
|
|
@@ -248,6 +248,76 @@ describe("session-tool-setup app refresh side effects", () => {
|
|
|
248
248
|
});
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
+
// ── app_update ──────────────────────────────────────────────────────
|
|
252
|
+
|
|
253
|
+
describe("app_update", () => {
|
|
254
|
+
test("triggers refreshSurfacesForApp and broadcast on success", async () => {
|
|
255
|
+
const ctx = makeCtx();
|
|
256
|
+
const executor = makeFakeExecutor({
|
|
257
|
+
content: '{"updated":true,"appId":"app-7"}',
|
|
258
|
+
isError: false,
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const toolFn = createToolExecutor(
|
|
262
|
+
executor as unknown as ToolExecutor,
|
|
263
|
+
noopPrompter,
|
|
264
|
+
noopSecretPrompter,
|
|
265
|
+
ctx,
|
|
266
|
+
noopLifecycleHandler,
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
await toolFn("app_update", { app_id: "app-7" });
|
|
270
|
+
|
|
271
|
+
expect(refreshSpy).toHaveBeenCalledTimes(1);
|
|
272
|
+
expect((refreshSpy.mock.calls as unknown[][])[0][1]).toBe("app-7");
|
|
273
|
+
expectAppChangeBroadcast("app-7");
|
|
274
|
+
expect(updatePublishedSpy).toHaveBeenCalledTimes(1);
|
|
275
|
+
expect((updatePublishedSpy.mock.calls as unknown[][])[0][0]).toBe(
|
|
276
|
+
"app-7",
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("skips side effects when result is an error", async () => {
|
|
281
|
+
const ctx = makeCtx();
|
|
282
|
+
const executor = makeFakeExecutor({
|
|
283
|
+
content: "Error: not found",
|
|
284
|
+
isError: true,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const toolFn = createToolExecutor(
|
|
288
|
+
executor as unknown as ToolExecutor,
|
|
289
|
+
noopPrompter,
|
|
290
|
+
noopSecretPrompter,
|
|
291
|
+
ctx,
|
|
292
|
+
noopLifecycleHandler,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
await toolFn("app_update", { app_id: "app-err" });
|
|
296
|
+
|
|
297
|
+
expect(refreshSpy).not.toHaveBeenCalled();
|
|
298
|
+
expect(broadcastSpy).not.toHaveBeenCalled();
|
|
299
|
+
expect(updatePublishedSpy).not.toHaveBeenCalled();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test("skips side effects when app_id is missing", async () => {
|
|
303
|
+
const ctx = makeCtx();
|
|
304
|
+
const executor = makeFakeExecutor({ content: "{}", isError: false });
|
|
305
|
+
|
|
306
|
+
const toolFn = createToolExecutor(
|
|
307
|
+
executor as unknown as ToolExecutor,
|
|
308
|
+
noopPrompter,
|
|
309
|
+
noopSecretPrompter,
|
|
310
|
+
ctx,
|
|
311
|
+
noopLifecycleHandler,
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
await toolFn("app_update", {});
|
|
315
|
+
|
|
316
|
+
expect(refreshSpy).not.toHaveBeenCalled();
|
|
317
|
+
expect(broadcastSpy).not.toHaveBeenCalled();
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
251
321
|
// ── app_create side effects ─────────────────────────────────────────
|
|
252
322
|
|
|
253
323
|
describe("app_create side effects", () => {
|
|
@@ -518,7 +588,6 @@ describe("session-tool-setup app refresh side effects", () => {
|
|
|
518
588
|
"write_file",
|
|
519
589
|
"shell",
|
|
520
590
|
"app_list",
|
|
521
|
-
"app_update",
|
|
522
591
|
"app_file_edit",
|
|
523
592
|
"app_file_write",
|
|
524
593
|
]) {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests that the auto-redeploy path deploys the app's *effective* HTML
|
|
3
|
+
* (dist/index.html for multifile apps) rather than the empty `htmlDefinition`.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
7
|
+
|
|
8
|
+
import type { AppDefinition } from "../memory/app-store.js";
|
|
9
|
+
|
|
10
|
+
// ── Mocks ───────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
let mockApp: AppDefinition | null = null;
|
|
13
|
+
let mockIsMultifile = false;
|
|
14
|
+
let mockEffectiveHtml = "";
|
|
15
|
+
// A directory that does not exist on disk, so the multifile dist-existence
|
|
16
|
+
// guard reads `false` from the real fs without mocking node:fs (which would
|
|
17
|
+
// leak across test files).
|
|
18
|
+
let mockAppDir = "/tmp/__vellum_test_nonexistent__/app-1";
|
|
19
|
+
|
|
20
|
+
mock.module("../memory/app-store.js", () => ({
|
|
21
|
+
getApp: () => mockApp,
|
|
22
|
+
getAppDirPath: () => mockAppDir,
|
|
23
|
+
isMultifileApp: () => mockIsMultifile,
|
|
24
|
+
resolveEffectiveAppHtml: () => mockEffectiveHtml,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
let mockPublishedPage: {
|
|
28
|
+
id: string;
|
|
29
|
+
projectSlug?: string;
|
|
30
|
+
htmlHash: string;
|
|
31
|
+
} | null = null;
|
|
32
|
+
const updatePublishedPageSpy = mock(() => {});
|
|
33
|
+
|
|
34
|
+
mock.module("../memory/published-pages-store.js", () => ({
|
|
35
|
+
getActivePublishedPageByAppId: () => mockPublishedPage,
|
|
36
|
+
updatePublishedPage: updatePublishedPageSpy,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const deploySpy = mock(async (_args: { html: string; name: string }) => ({
|
|
40
|
+
deploymentId: "dep-1",
|
|
41
|
+
url: "https://example.vercel.app",
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
mock.module("../services/vercel-deploy.js", () => ({
|
|
45
|
+
deployHtmlToVercel: deploySpy,
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
// credentialBroker.serverUse invokes execute(token) and reports success.
|
|
49
|
+
mock.module("../tools/credentials/broker.js", () => ({
|
|
50
|
+
credentialBroker: {
|
|
51
|
+
serverUse: async ({
|
|
52
|
+
execute,
|
|
53
|
+
}: {
|
|
54
|
+
execute: (token: string) => Promise<unknown>;
|
|
55
|
+
}) => {
|
|
56
|
+
await execute("test-token");
|
|
57
|
+
return { success: true };
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const { updatePublishedAppDeployment } =
|
|
63
|
+
await import("../services/published-app-updater.js");
|
|
64
|
+
|
|
65
|
+
function makeApp(overrides: Partial<AppDefinition> = {}): AppDefinition {
|
|
66
|
+
return {
|
|
67
|
+
id: "app-1",
|
|
68
|
+
name: "App",
|
|
69
|
+
schemaJson: "{}",
|
|
70
|
+
htmlDefinition: "",
|
|
71
|
+
createdAt: 1,
|
|
72
|
+
updatedAt: 2,
|
|
73
|
+
...overrides,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ── Tests ───────────────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
describe("updatePublishedAppDeployment", () => {
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
mockApp = makeApp();
|
|
82
|
+
mockIsMultifile = false;
|
|
83
|
+
mockEffectiveHtml = "";
|
|
84
|
+
mockPublishedPage = { id: "pp-1", projectSlug: "slug", htmlHash: "old" };
|
|
85
|
+
mockAppDir = "/tmp/__vellum_test_nonexistent__/app-1";
|
|
86
|
+
deploySpy.mockClear();
|
|
87
|
+
updatePublishedPageSpy.mockClear();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("deploys the resolved effective HTML, not the empty htmlDefinition", async () => {
|
|
91
|
+
// htmlDefinition is "" (as it is for every multifile app); the real
|
|
92
|
+
// content comes from resolveEffectiveAppHtml. isMultifile=false here keeps
|
|
93
|
+
// the dist guard out of the way so the assertion targets the html source.
|
|
94
|
+
mockApp = makeApp({ htmlDefinition: "" });
|
|
95
|
+
mockEffectiveHtml = "<html><body>real app</body></html>";
|
|
96
|
+
|
|
97
|
+
await updatePublishedAppDeployment("app-1");
|
|
98
|
+
|
|
99
|
+
expect(deploySpy).toHaveBeenCalledTimes(1);
|
|
100
|
+
expect(deploySpy.mock.calls[0][0].html).toBe(
|
|
101
|
+
"<html><body>real app</body></html>",
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("skips deploy when a multifile app has no compiled output", async () => {
|
|
106
|
+
mockIsMultifile = true;
|
|
107
|
+
mockApp = makeApp({ formatVersion: 2 });
|
|
108
|
+
mockEffectiveHtml = "<p>App compilation failed.</p>";
|
|
109
|
+
// mockAppDir does not exist → dist/index.html is absent.
|
|
110
|
+
|
|
111
|
+
await updatePublishedAppDeployment("app-1");
|
|
112
|
+
|
|
113
|
+
expect(deploySpy).not.toHaveBeenCalled();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test("skips deploy when content hash is unchanged", async () => {
|
|
117
|
+
const html = "<html>same</html>";
|
|
118
|
+
mockEffectiveHtml = html;
|
|
119
|
+
const { createHash } = await import("node:crypto");
|
|
120
|
+
mockPublishedPage = {
|
|
121
|
+
id: "pp-1",
|
|
122
|
+
htmlHash: createHash("sha256").update(html).digest("hex"),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
await updatePublishedAppDeployment("app-1");
|
|
126
|
+
|
|
127
|
+
expect(deploySpy).not.toHaveBeenCalled();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("skips deploy when the app has no active published page", async () => {
|
|
131
|
+
mockPublishedPage = null;
|
|
132
|
+
mockEffectiveHtml = "<html>x</html>";
|
|
133
|
+
|
|
134
|
+
await updatePublishedAppDeployment("app-1");
|
|
135
|
+
|
|
136
|
+
expect(deploySpy).not.toHaveBeenCalled();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wire contract for the memory v3 selection set surfaced in the inspector's
|
|
3
3
|
* Memory tab. Mirrors the return value of `getMemoryV3SelectionForInspector`
|
|
4
|
-
* in `assistant/src/memory
|
|
4
|
+
* in `assistant/src/plugins/defaults/memory-v3-shadow/selection-log-store.ts`.
|
|
5
5
|
*
|
|
6
6
|
* Canonical wire-contract source. Assistant code imports the types directly
|
|
7
7
|
* from this file via relative paths; external consumers (web client, gateway,
|
|
@@ -12,19 +12,27 @@
|
|
|
12
12
|
* `live` / `shadow` reflect the CURRENT `memory-v3-live` / `memory-v3-shadow`
|
|
13
13
|
* flag state, not the per-turn history (the selection rows don't record which
|
|
14
14
|
* mode was active when they were written). When `live` is true the rendered
|
|
15
|
-
* `injectedText`
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* `injectedText` reflects the live selection; when only `shadow` is true it is
|
|
16
|
+
* the block that WOULD have been injected.
|
|
17
|
+
*
|
|
18
|
+
* `injectedText` is APPROXIMATE, not a verbatim record. It is re-rendered from
|
|
19
|
+
* the persisted selection rows, which store slug/source/pinned but NOT the
|
|
20
|
+
* matched-section identity. A page that live injection sent as a single matched
|
|
21
|
+
* section is re-rendered here as its FULL page (the section ordinal isn't
|
|
22
|
+
* persisted), so the text can differ from what was actually sent to the model.
|
|
23
|
+
* The selected slug set is exact — only the rendered text is full-page
|
|
24
|
+
* approximate. Persisting the per-turn injected section is a documented
|
|
25
|
+
* follow-up.
|
|
19
26
|
*/
|
|
20
27
|
|
|
21
28
|
import { z } from "zod";
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* One selected page in the v3 set. `source` is the lane that surfaced it —
|
|
25
|
-
* the daemon emits `
|
|
26
|
-
* schema stays a permissive string so a new lane label
|
|
27
|
-
* on the FE. `pinned` marks a slug carried
|
|
32
|
+
* the daemon emits `needle`, `dense`, `edge`, or `carry-forward` — but the
|
|
33
|
+
* schema stays a permissive string so a new lane label (or a historical
|
|
34
|
+
* pre-lane row) doesn't break parsing on the FE. `pinned` marks a slug carried
|
|
35
|
+
* forward across turns.
|
|
28
36
|
*/
|
|
29
37
|
export const MemoryV3SelectionRowSchema = z.object({
|
|
30
38
|
slug: z.string(),
|
|
@@ -36,8 +44,9 @@ export type MemoryV3SelectionRow = z.infer<typeof MemoryV3SelectionRowSchema>;
|
|
|
36
44
|
|
|
37
45
|
/**
|
|
38
46
|
* Memory v3 selection log shape. `injectedText` is the rendered
|
|
39
|
-
* `<memory>…</memory>` block for the selection
|
|
40
|
-
*
|
|
47
|
+
* `<memory>…</memory>` block for the selection — APPROXIMATE: re-rendered from
|
|
48
|
+
* the persisted rows, with full pages where live injection used a matched
|
|
49
|
+
* section (the section identity isn't persisted). See the file header.
|
|
41
50
|
*/
|
|
42
51
|
export const MemoryV3SelectionLogSchema = z.object({
|
|
43
52
|
turn: z.number(),
|