veryfront 0.1.164 → 0.1.169
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/esm/deno.js +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
- package/esm/src/agent/runtime/chat-stream-handler.js +22 -0
- package/esm/src/agent/runtime/runtime-tool-types.d.ts +10 -0
- package/esm/src/agent/runtime/runtime-tool-types.d.ts.map +1 -1
- package/esm/src/internal-agents/ag-ui-sse.d.ts +1 -0
- package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
- package/esm/src/internal-agents/ag-ui-sse.js +49 -0
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts +3 -0
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/adapter.js +39 -59
- package/esm/src/rendering/orchestrator/pipeline.d.ts +1 -0
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +4 -1
- package/esm/src/routing/api/module-loader/loader.d.ts +3 -0
- package/esm/src/routing/api/module-loader/loader.d.ts.map +1 -1
- package/esm/src/routing/api/module-loader/loader.js +56 -55
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/runtime/chat-stream-handler.ts +25 -0
- package/src/src/agent/runtime/runtime-tool-types.ts +3 -0
- package/src/src/internal-agents/ag-ui-sse.ts +56 -0
- package/src/src/platform/adapters/fs/veryfront/adapter.ts +68 -85
- package/src/src/rendering/orchestrator/pipeline.ts +18 -2
- package/src/src/routing/api/module-loader/loader.ts +116 -99
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-stream-handler.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/chat-stream-handler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;KAAE,CAAC;CAChF;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,KAAK,IAAI,CAAC;CACZ;AA4FD,wBAAgB,iBAAiB,IAAI,eAAe,CAQnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,+BAA+B,EAC3C,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,CAAC,EAAE,mBAAmB,EAC/B,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,IAAI,CAAC,CAmPf"}
|
|
@@ -121,6 +121,28 @@ export function processStream(result, state, controller, encoder, textPartId, ca
|
|
|
121
121
|
callbacks?.onChunk?.(typedPart.text);
|
|
122
122
|
break;
|
|
123
123
|
}
|
|
124
|
+
case "reasoning-start": {
|
|
125
|
+
sendSSE(controller, encoder, {
|
|
126
|
+
type: "reasoning-start",
|
|
127
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
128
|
+
});
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case "reasoning-delta": {
|
|
132
|
+
sendSSE(controller, encoder, {
|
|
133
|
+
type: "reasoning-delta",
|
|
134
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
135
|
+
delta: typeof typedPart.delta === "string" ? typedPart.delta : "",
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
case "reasoning-end": {
|
|
140
|
+
sendSSE(controller, encoder, {
|
|
141
|
+
type: "reasoning-end",
|
|
142
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
143
|
+
});
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
124
146
|
case "tool-input-start": {
|
|
125
147
|
const toolId = typedPart.id;
|
|
126
148
|
state.toolCalls.set(toolId, {
|
|
@@ -48,6 +48,16 @@ export type RuntimeToolCallRepairFunction = (context: RuntimeToolCallRepairConte
|
|
|
48
48
|
export type RuntimeStreamPart = {
|
|
49
49
|
type: "text-delta";
|
|
50
50
|
text: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: "reasoning-start";
|
|
53
|
+
id: string;
|
|
54
|
+
} | {
|
|
55
|
+
type: "reasoning-delta";
|
|
56
|
+
id: string;
|
|
57
|
+
delta: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "reasoning-end";
|
|
60
|
+
id: string;
|
|
51
61
|
} | {
|
|
52
62
|
type: "tool-input-start";
|
|
53
63
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-tool-types.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/runtime-tool-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACt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,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACnC"}
|
|
1
|
+
{"version":3,"file":"runtime-tool-types.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/runtime-tool-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACtC,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC1C,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B;I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A,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACC;IACA,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GACC;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,IAAI,CAAC;CACV,GACC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACnC"}
|
|
@@ -13,6 +13,7 @@ export interface RunFinishedMetadata {
|
|
|
13
13
|
export interface StreamTransformState {
|
|
14
14
|
messageId: string | null;
|
|
15
15
|
textOpen: boolean;
|
|
16
|
+
reasoningMessageId: string | null;
|
|
16
17
|
sawVisibleOutput: boolean;
|
|
17
18
|
sawTerminalError: boolean;
|
|
18
19
|
metadata: RunFinishedMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ag-ui-sse.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/ag-ui-sse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOvD,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ag-ui-sse.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/ag-ui-sse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOvD,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE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false,
|
|
10
|
+
reasoningMessageId: null,
|
|
10
11
|
sawVisibleOutput: false,
|
|
11
12
|
sawTerminalError: false,
|
|
12
13
|
metadata: {},
|
|
@@ -41,6 +42,17 @@ const agUiEventPayloadSchemas = {
|
|
|
41
42
|
TextMessageEnd: z.object({
|
|
42
43
|
messageId: z.string().min(1),
|
|
43
44
|
}),
|
|
45
|
+
ReasoningMessageStart: z.object({
|
|
46
|
+
messageId: z.string().min(1),
|
|
47
|
+
role: z.literal("reasoning"),
|
|
48
|
+
}),
|
|
49
|
+
ReasoningMessageContent: z.object({
|
|
50
|
+
messageId: z.string().min(1),
|
|
51
|
+
delta: z.string(),
|
|
52
|
+
}),
|
|
53
|
+
ReasoningMessageEnd: z.object({
|
|
54
|
+
messageId: z.string().min(1),
|
|
55
|
+
}),
|
|
44
56
|
ToolCallStart: z.object({
|
|
45
57
|
toolCallId: z.string().min(1),
|
|
46
58
|
toolCallName: z.string().min(1),
|
|
@@ -114,6 +126,20 @@ function getMessageId(state, event) {
|
|
|
114
126
|
}
|
|
115
127
|
return state.messageId;
|
|
116
128
|
}
|
|
129
|
+
function getReasoningMessageId(state, event) {
|
|
130
|
+
if (typeof event.id === "string" && event.id.length > 0) {
|
|
131
|
+
state.reasoningMessageId = state.messageId
|
|
132
|
+
? `${state.messageId}:reasoning:${event.id}`
|
|
133
|
+
: event.id;
|
|
134
|
+
return state.reasoningMessageId;
|
|
135
|
+
}
|
|
136
|
+
if (!state.reasoningMessageId) {
|
|
137
|
+
state.reasoningMessageId = state.messageId
|
|
138
|
+
? `${state.messageId}:reasoning:${dntShim.crypto.randomUUID()}`
|
|
139
|
+
: dntShim.crypto.randomUUID();
|
|
140
|
+
}
|
|
141
|
+
return state.reasoningMessageId;
|
|
142
|
+
}
|
|
117
143
|
function applyDataMetadata(state, event) {
|
|
118
144
|
const data = event.data && typeof event.data === "object" && !Array.isArray(event.data)
|
|
119
145
|
? event.data
|
|
@@ -184,6 +210,29 @@ export function mapRuntimeEventToAgUi(state, event) {
|
|
|
184
210
|
payload: { messageId: getMessageId(state, event) },
|
|
185
211
|
}];
|
|
186
212
|
}
|
|
213
|
+
case "reasoning-start":
|
|
214
|
+
state.sawVisibleOutput = true;
|
|
215
|
+
return [{
|
|
216
|
+
event: "ReasoningMessageStart",
|
|
217
|
+
payload: { messageId: getReasoningMessageId(state, event), role: "reasoning" },
|
|
218
|
+
}];
|
|
219
|
+
case "reasoning-delta":
|
|
220
|
+
state.sawVisibleOutput = true;
|
|
221
|
+
return [{
|
|
222
|
+
event: "ReasoningMessageContent",
|
|
223
|
+
payload: {
|
|
224
|
+
messageId: getReasoningMessageId(state, event),
|
|
225
|
+
delta: typeof event.delta === "string" ? event.delta : "",
|
|
226
|
+
},
|
|
227
|
+
}];
|
|
228
|
+
case "reasoning-end": {
|
|
229
|
+
const messageId = getReasoningMessageId(state, event);
|
|
230
|
+
state.reasoningMessageId = null;
|
|
231
|
+
return [{
|
|
232
|
+
event: "ReasoningMessageEnd",
|
|
233
|
+
payload: { messageId },
|
|
234
|
+
}];
|
|
235
|
+
}
|
|
187
236
|
case "tool-input-start":
|
|
188
237
|
state.sawVisibleOutput = true;
|
|
189
238
|
return [{
|
|
@@ -29,6 +29,9 @@ export declare class VeryfrontFSAdapter implements FSAdapter {
|
|
|
29
29
|
private contentContext;
|
|
30
30
|
/** Whether running in proxy mode (shared adapter with per-request OAuth tokens) */
|
|
31
31
|
private proxyMode;
|
|
32
|
+
private getCurrentFileListCacheKey;
|
|
33
|
+
private getCachedFileListSync;
|
|
34
|
+
private getCachedFileListAsync;
|
|
32
35
|
constructor(config: FSAdapterConfig);
|
|
33
36
|
initialize(): Promise<void>;
|
|
34
37
|
private isPersistentCacheInvalidated;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../../src/src/platform/adapters/fs/veryfront/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EAEV,cAAc,EACd,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,IAAI,GAAG,IAAI;IAK7C,gBAAgB,IAAI,MAAM,GAAG,IAAI;IAIjC,kBAAkB,IAAI,IAAI;IAK1B,iBAAiB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAoCxD,iBAAiB,IAAI,sBAAsB,GAAG,IAAI;IAWlD,SAAS,IAAI,kBAAkB;YAIjB,iBAAiB;IAK/B;;;;;OAKG;YACW,uBAAuB;CAgFtC"}
|
|
@@ -44,6 +44,33 @@ export class VeryfrontFSAdapter {
|
|
|
44
44
|
contentContext = null;
|
|
45
45
|
/** Whether running in proxy mode (shared adapter with per-request OAuth tokens) */
|
|
46
46
|
proxyMode;
|
|
47
|
+
getCurrentFileListCacheKey() {
|
|
48
|
+
return this.contentContext ? buildFileListCacheKey(this.contentContext) : undefined;
|
|
49
|
+
}
|
|
50
|
+
getCachedFileListSync() {
|
|
51
|
+
const cacheKey = this.getCurrentFileListCacheKey();
|
|
52
|
+
if (!cacheKey)
|
|
53
|
+
return undefined;
|
|
54
|
+
return this.cache.get(cacheKey);
|
|
55
|
+
}
|
|
56
|
+
async getCachedFileListAsync(noContextMessage, lookupLabel, missReason) {
|
|
57
|
+
const cacheKey = this.getCurrentFileListCacheKey();
|
|
58
|
+
if (!cacheKey) {
|
|
59
|
+
logger.debug(noContextMessage);
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const files = await this.cache.getAsync(cacheKey);
|
|
63
|
+
logger.debug(`${lookupLabel} lookup`, {
|
|
64
|
+
cacheKey,
|
|
65
|
+
hasResult: !!files,
|
|
66
|
+
resultSize: files?.length ?? 0,
|
|
67
|
+
hasContent: files?.filter((file) => !!file.content)?.length ?? 0,
|
|
68
|
+
});
|
|
69
|
+
if (!files?.length) {
|
|
70
|
+
this.scheduleFileListWarmup(missReason, cacheKey);
|
|
71
|
+
}
|
|
72
|
+
return { cacheKey, files };
|
|
73
|
+
}
|
|
47
74
|
constructor(config) {
|
|
48
75
|
this.invalidationCallbacks = config.invalidationCallbacks ?? {};
|
|
49
76
|
const vf = config.veryfront;
|
|
@@ -86,39 +113,12 @@ export class VeryfrontFSAdapter {
|
|
|
86
113
|
getReleaseId: () => this.contentContext?.releaseId ?? null,
|
|
87
114
|
getContentContext: () => this.contentContext,
|
|
88
115
|
getFileList: async () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
94
|
-
const result = await this.cache.getAsync(cacheKey);
|
|
95
|
-
logger.debug("getFileList lookup", {
|
|
96
|
-
cacheKey,
|
|
97
|
-
hasResult: !!result,
|
|
98
|
-
resultSize: result?.length ?? 0,
|
|
99
|
-
});
|
|
100
|
-
if (!result?.length) {
|
|
101
|
-
this.scheduleFileListWarmup("getFileList miss", cacheKey);
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
116
|
+
const cached = await this.getCachedFileListAsync("getFileList: no contentContext", "getFileList", "getFileList miss");
|
|
117
|
+
return cached?.files;
|
|
104
118
|
},
|
|
105
119
|
hasCachedFileList: async () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
111
|
-
const result = await this.cache.getAsync(cacheKey);
|
|
112
|
-
const hasResult = Array.isArray(result) && result.length > 0;
|
|
113
|
-
logger.debug("hasCachedFileList lookup", {
|
|
114
|
-
cacheKey,
|
|
115
|
-
hasResult,
|
|
116
|
-
resultSize: result?.length ?? 0,
|
|
117
|
-
});
|
|
118
|
-
if (!hasResult) {
|
|
119
|
-
this.scheduleFileListWarmup("hasCachedFileList miss", cacheKey);
|
|
120
|
-
}
|
|
121
|
-
return hasResult;
|
|
120
|
+
const cached = await this.getCachedFileListAsync("hasCachedFileList: no contentContext", "hasCachedFileList", "hasCachedFileList miss");
|
|
121
|
+
return Array.isArray(cached?.files) && cached.files.length > 0;
|
|
122
122
|
},
|
|
123
123
|
isPersistentCacheInvalidated: (prefix) => this.isPersistentCacheInvalidated(prefix),
|
|
124
124
|
isReleaseBeingInvalidated: (releaseId) => this.isPersistentCacheInvalidated(buildFileCacheKeyPrefix({
|
|
@@ -129,22 +129,8 @@ export class VeryfrontFSAdapter {
|
|
|
129
129
|
};
|
|
130
130
|
this.statOps = new StatOperations(this.client, this.cache, this.normalizer, contentContextGetter);
|
|
131
131
|
this.readOps = new ReadOperations(this.client, this.cache, this.normalizer, contentContextGetter, (path) => this.statOps.getOriginalApiPath(path), async () => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
137
|
-
const result = await this.cache.getAsync(cacheKey);
|
|
138
|
-
logger.debug("getFileListCache lookup", {
|
|
139
|
-
cacheKey,
|
|
140
|
-
hasResult: !!result,
|
|
141
|
-
resultSize: result?.length ?? 0,
|
|
142
|
-
hasContent: result?.filter((f) => f.content)?.length ?? 0,
|
|
143
|
-
});
|
|
144
|
-
if (!result?.length) {
|
|
145
|
-
this.scheduleFileListWarmup("getFileListCache miss", cacheKey);
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
132
|
+
const cached = await this.getCachedFileListAsync("getFileListCache: no contentContext", "getFileListCache", "getFileListCache miss");
|
|
133
|
+
return cached?.files;
|
|
148
134
|
});
|
|
149
135
|
this.dirOps = new DirectoryOperations(this.client, this.cache, this.normalizer, contentContextGetter);
|
|
150
136
|
this.wsManager = new WebSocketManager({
|
|
@@ -419,16 +405,16 @@ export class VeryfrontFSAdapter {
|
|
|
419
405
|
});
|
|
420
406
|
return [];
|
|
421
407
|
}
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
|
|
408
|
+
const cached = await this.getCachedFileListAsync("getAllSourceFiles: no contentContext", "getAllSourceFiles", "getAllSourceFiles miss");
|
|
409
|
+
const cacheKey = cached?.cacheKey;
|
|
410
|
+
const files = cached?.files;
|
|
411
|
+
if (!cacheKey || !files?.length) {
|
|
425
412
|
logger.debug("getAllSourceFiles cache miss or empty", {
|
|
426
413
|
cacheKey,
|
|
427
414
|
initialized: this.initialized,
|
|
428
415
|
hasFiles: !!files,
|
|
429
416
|
fileCount: files?.length ?? 0,
|
|
430
417
|
});
|
|
431
|
-
this.scheduleFileListWarmup("getAllSourceFiles miss", cacheKey);
|
|
432
418
|
return [];
|
|
433
419
|
}
|
|
434
420
|
const fileSummary = summarizeFileList(files);
|
|
@@ -442,18 +428,12 @@ export class VeryfrontFSAdapter {
|
|
|
442
428
|
return files;
|
|
443
429
|
}
|
|
444
430
|
getEntityIdForPath(path) {
|
|
445
|
-
if (!this.contentContext)
|
|
446
|
-
return undefined;
|
|
447
431
|
const normalizedPath = this.normalizer.normalize(path);
|
|
448
|
-
const
|
|
449
|
-
const cachedFiles = this.cache.get(cacheKey);
|
|
432
|
+
const cachedFiles = this.getCachedFileListSync();
|
|
450
433
|
return cachedFiles?.find((f) => f.path === normalizedPath)?.id;
|
|
451
434
|
}
|
|
452
435
|
getFilePathByEntityId(entityId) {
|
|
453
|
-
|
|
454
|
-
return undefined;
|
|
455
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
456
|
-
const cachedFiles = this.cache.get(cacheKey);
|
|
436
|
+
const cachedFiles = this.getCachedFileListSync();
|
|
457
437
|
return cachedFiles?.find((f) => f.id === entityId)?.path;
|
|
458
438
|
}
|
|
459
439
|
async getFilePathByEntityIdAsync(entityId) {
|
|
@@ -71,6 +71,7 @@ export declare class RenderPipeline {
|
|
|
71
71
|
* Shared by both renderPage() and resolvePageData() to keep behavior aligned.
|
|
72
72
|
*/
|
|
73
73
|
private resolveDataFetching;
|
|
74
|
+
private applyFetchedDataResults;
|
|
74
75
|
renderPage(slug: string, options?: RenderOptions): Promise<RenderResult>;
|
|
75
76
|
/** Resolve page data for SPA client-side navigation without rendering HTML. */
|
|
76
77
|
resolvePageData(slug: string, options?: RenderOptions): Promise<PageDataResponse>;
|
|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nB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,qBAAqB,EAAE,sBAAsB,CAAC;CAC1E;AAeD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,MAAM,EAAE,oBAAoB;IAaxC;;;OAGG;IACH,gBAAgB,IAAI,IAAI;IAKxB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,sBAAsB;YAIhB,0BAA0B;IAaxC;;;;;;;;;OASG;YACW,qBAAqB;IAyDnC;;;OAGG;YACW,mBAAmB;IAiGjC,OAAO,CAAC,uBAAuB;IAkCzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA+P9E,+EAA+E;IACzE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgMvF;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;CAetB"}
|
|
@@ -196,6 +196,10 @@ export class RenderPipeline {
|
|
|
196
196
|
return { ...job, result: null, error: error };
|
|
197
197
|
}
|
|
198
198
|
})), DATA_FETCH_TIMEOUT_MS, `Data fetch for ${slug}`), { "render.data_job_count": dataJobs.length });
|
|
199
|
+
this.applyFetchedDataResults(slug, dataResults, pageProps, layoutProps);
|
|
200
|
+
return { params, pageProps, layoutProps };
|
|
201
|
+
}
|
|
202
|
+
applyFetchedDataResults(slug, dataResults, pageProps, layoutProps) {
|
|
199
203
|
for (const { type, id, result, error } of dataResults) {
|
|
200
204
|
if (error)
|
|
201
205
|
throw error;
|
|
@@ -222,7 +226,6 @@ export class RenderPipeline {
|
|
|
222
226
|
layoutProps.set(id, result.props);
|
|
223
227
|
}
|
|
224
228
|
}
|
|
225
|
-
return { params, pageProps, layoutProps };
|
|
226
229
|
}
|
|
227
230
|
async renderPage(slug, options) {
|
|
228
231
|
const pipelineStartTime = performance.now();
|
|
@@ -8,4 +8,7 @@ export declare function loadVeryfrontExportsMap(projectDir: string, fs: FileSyst
|
|
|
8
8
|
import?: string;
|
|
9
9
|
}>>;
|
|
10
10
|
export declare function rewriteNodeExternalImports(code: string, projectDir: string, fs: FileSystem, userDeps: Map<string, string>): Promise<string>;
|
|
11
|
+
export declare function rewriteCompiledBinaryVeryfrontImports(code: string): string;
|
|
12
|
+
export declare function rewriteCompiledBinaryUserDependencyImports(code: string, userDeps: Map<string, string>): string;
|
|
13
|
+
export declare function rewriteDenoNpmDependencyImports(code: string, projectDir: string, fs: FileSystem, userDeps: Map<string, string>): Promise<string>;
|
|
11
14
|
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../../src/src/routing/api/module-loader/loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAI9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AA4KjE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAejE;AAgBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAyBtF;AAuaD,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAUxF;AAED,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,UAAU,EACd,aAAa,EAAE,cAAc,UAAU,EAAE,aAAa,GACrD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBxB;AAED,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB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E,MAAM,EAClB,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,MAAM,CAAC,CA6EjB;AAED,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB1E;AAED,wBAAgB,0CAA0C,CACxD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAoDR;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
|
|
@@ -615,6 +615,59 @@ export async function rewriteNodeExternalImports(code, projectDir, fs, userDeps)
|
|
|
615
615
|
});
|
|
616
616
|
return transformed;
|
|
617
617
|
}
|
|
618
|
+
export function rewriteCompiledBinaryVeryfrontImports(code) {
|
|
619
|
+
let transformed = code;
|
|
620
|
+
transformed = transformed.replace(/from\s+["']veryfront["']/g, 'from "./_vf_runtime.mjs"');
|
|
621
|
+
transformed = transformed.replace(/import\s*\(\s*["']veryfront["']\s*\)/g, 'import("./_vf_runtime.mjs")');
|
|
622
|
+
transformed = transformed.replace(/from\s+["']veryfront\/([^"']+)["']/g, (_match, subpath) => `from "./_vf_${subpath.replace(/\//g, "_")}.mjs"`);
|
|
623
|
+
transformed = transformed.replace(/import\s*\(\s*["']veryfront\/([^"']+)["']\s*\)/g, (_match, subpath) => `import("./_vf_${subpath.replace(/\//g, "_")}.mjs")`);
|
|
624
|
+
return transformed;
|
|
625
|
+
}
|
|
626
|
+
export function rewriteCompiledBinaryUserDependencyImports(code, userDeps) {
|
|
627
|
+
let transformed = code;
|
|
628
|
+
for (const name of userDeps.keys()) {
|
|
629
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
630
|
+
transformed = transformed.replace(new RegExp(`import\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"), (_, localName) => `const ${localName} = __vf_interopDefault(require("${name}"))`);
|
|
631
|
+
transformed = transformed.replace(new RegExp(`import\\s+(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"), (_, bindings) => `const ${toCjsDestructureBindings(bindings)} = require("${name}")`);
|
|
632
|
+
transformed = transformed.replace(new RegExp(`import\\s+\\*\\s+as\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"), (_, localName) => `const ${localName} = require("${name}")`);
|
|
633
|
+
transformed = transformed.replace(new RegExp(`import\\s+(\\w+)\\s*,\\s*(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"), (_, defaultName, bindings) => {
|
|
634
|
+
const tmp = `__vf_tmp_${defaultName}`;
|
|
635
|
+
return `const ${tmp} = require("${name}"); const ${defaultName} = __vf_interopDefault(${tmp}); const ${toCjsDestructureBindings(bindings)} = ${tmp}`;
|
|
636
|
+
});
|
|
637
|
+
transformed = transformed.replace(new RegExp(`import\\s+(\\w+|\\*\\s+as\\s+\\w+|\\{[^}]+\\})\\s+from\\s+["']${escaped}(/[^"']+)["']`, "g"), (_, binding, subpath) => {
|
|
638
|
+
const trimmedBinding = String(binding).trim();
|
|
639
|
+
if (trimmedBinding.startsWith("{")) {
|
|
640
|
+
return `const ${toCjsDestructureBindings(trimmedBinding)} = require("${name}${subpath}")`;
|
|
641
|
+
}
|
|
642
|
+
const name_ = trimmedBinding.startsWith("*")
|
|
643
|
+
? trimmedBinding.replace(/\*\s+as\s+/, "")
|
|
644
|
+
: trimmedBinding;
|
|
645
|
+
return `const ${name_} = require("${name}${subpath}")`;
|
|
646
|
+
});
|
|
647
|
+
transformed = transformed.replace(new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"), (_, subpath) => `Promise.resolve(require("${name}${subpath || ""}"))`);
|
|
648
|
+
}
|
|
649
|
+
return transformed;
|
|
650
|
+
}
|
|
651
|
+
export async function rewriteDenoNpmDependencyImports(code, projectDir, fs, userDeps) {
|
|
652
|
+
let transformed = code;
|
|
653
|
+
for (const [name, version] of userDeps) {
|
|
654
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
655
|
+
let resolvedVersion = version;
|
|
656
|
+
try {
|
|
657
|
+
const pkgPath = pathHelper.join(projectDir, "node_modules", name, "package.json");
|
|
658
|
+
const pkgContent = await fs.readTextFile(pkgPath);
|
|
659
|
+
const pkg = JSON.parse(pkgContent);
|
|
660
|
+
if (pkg.version)
|
|
661
|
+
resolvedVersion = pkg.version;
|
|
662
|
+
}
|
|
663
|
+
catch (_) {
|
|
664
|
+
/* expected: installed package.json may not exist, fall back to declared range */
|
|
665
|
+
}
|
|
666
|
+
transformed = transformed.replace(new RegExp(`from\\s+["']${escaped}(/[^"']*)?["']`, "g"), (_, subpath) => `from "npm:${name}@${resolvedVersion}${subpath || ""}"`);
|
|
667
|
+
transformed = transformed.replace(new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"), (_, subpath) => `import("npm:${name}@${resolvedVersion}${subpath || ""}")`);
|
|
668
|
+
}
|
|
669
|
+
return transformed;
|
|
670
|
+
}
|
|
618
671
|
async function rewriteExternalImports(code, projectDir, fs, userDeps = new Map()) {
|
|
619
672
|
let transformed = code;
|
|
620
673
|
if (isNode) {
|
|
@@ -640,67 +693,15 @@ async function rewriteExternalImports(code, projectDir, fs, userDeps = new Map()
|
|
|
640
693
|
// injected by the esbuild banner) to load CJS packages from node_modules,
|
|
641
694
|
// since npm: specifiers only work for packages embedded at compile time.
|
|
642
695
|
if (isCompiledBinary()) {
|
|
643
|
-
|
|
644
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
645
|
-
// Default imports: import foo from "pkg" → const foo = __vf_interopDefault(require("pkg"))
|
|
646
|
-
// interopDefault unwraps .default for ESM packages transpiled to CJS
|
|
647
|
-
transformed = transformed.replace(new RegExp(`import\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"), (_, localName) => `const ${localName} = __vf_interopDefault(require("${name}"))`);
|
|
648
|
-
// Named imports: import { a, b } from "pkg" → const { a, b } = require("pkg")
|
|
649
|
-
transformed = transformed.replace(new RegExp(`import\\s+(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"), (_, bindings) => `const ${toCjsDestructureBindings(bindings)} = require("${name}")`);
|
|
650
|
-
// Namespace imports: import * as foo from "pkg" → const foo = require("pkg")
|
|
651
|
-
transformed = transformed.replace(new RegExp(`import\\s+\\*\\s+as\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"), (_, localName) => `const ${localName} = require("${name}")`);
|
|
652
|
-
// Mixed imports: import foo, { bar } from "pkg"
|
|
653
|
-
transformed = transformed.replace(new RegExp(`import\\s+(\\w+)\\s*,\\s*(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"), (_, defaultName, bindings) => {
|
|
654
|
-
const tmp = `__vf_tmp_${defaultName}`;
|
|
655
|
-
return `const ${tmp} = require("${name}"); const ${defaultName} = __vf_interopDefault(${tmp}); const ${toCjsDestructureBindings(bindings)} = ${tmp}`;
|
|
656
|
-
});
|
|
657
|
-
// Subpath static imports: from "pkg/sub" → require("pkg/sub")
|
|
658
|
-
transformed = transformed.replace(new RegExp(`import\\s+(\\w+|\\*\\s+as\\s+\\w+|\\{[^}]+\\})\\s+from\\s+["']${escaped}(/[^"']+)["']`, "g"), (_, binding, subpath) => {
|
|
659
|
-
const trimmedBinding = String(binding).trim();
|
|
660
|
-
if (trimmedBinding.startsWith("{")) {
|
|
661
|
-
return `const ${toCjsDestructureBindings(trimmedBinding)} = require("${name}${subpath}")`;
|
|
662
|
-
}
|
|
663
|
-
const name_ = trimmedBinding.startsWith("*")
|
|
664
|
-
? trimmedBinding.replace(/\*\s+as\s+/, "")
|
|
665
|
-
: trimmedBinding;
|
|
666
|
-
return `const ${name_} = require("${name}${subpath}")`;
|
|
667
|
-
});
|
|
668
|
-
// Dynamic imports: import("pkg") → Promise.resolve(require("pkg"))
|
|
669
|
-
transformed = transformed.replace(new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"), (_, subpath) => `Promise.resolve(require("${name}${subpath || ""}"))`);
|
|
670
|
-
}
|
|
696
|
+
transformed = rewriteCompiledBinaryUserDependencyImports(transformed, userDeps);
|
|
671
697
|
}
|
|
672
698
|
else {
|
|
673
|
-
|
|
674
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
675
|
-
// Resolve exact installed version from node_modules (falls back to range)
|
|
676
|
-
let resolvedVersion = version;
|
|
677
|
-
try {
|
|
678
|
-
const pkgPath = pathHelper.join(projectDir, "node_modules", name, "package.json");
|
|
679
|
-
const pkgContent = await fs.readTextFile(pkgPath);
|
|
680
|
-
const pkg = JSON.parse(pkgContent);
|
|
681
|
-
if (pkg.version)
|
|
682
|
-
resolvedVersion = pkg.version;
|
|
683
|
-
}
|
|
684
|
-
catch (_) {
|
|
685
|
-
/* expected: installed package.json may not exist, fall back to declared range */
|
|
686
|
-
}
|
|
687
|
-
// Static: from "pkg" and from "pkg/sub"
|
|
688
|
-
transformed = transformed.replace(new RegExp(`from\\s+["']${escaped}(/[^"']*)?["']`, "g"), (_, subpath) => `from "npm:${name}@${resolvedVersion}${subpath || ""}"`);
|
|
689
|
-
// Dynamic: import("pkg") and import("pkg/sub")
|
|
690
|
-
transformed = transformed.replace(new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"), (_, subpath) => `import("npm:${name}@${resolvedVersion}${subpath || ""}")`);
|
|
691
|
-
}
|
|
699
|
+
transformed = await rewriteDenoNpmDependencyImports(transformed, projectDir, fs, userDeps);
|
|
692
700
|
}
|
|
693
701
|
// In compiled binaries, "veryfront" resolves to embedded source that can't be
|
|
694
702
|
// imported from external temp files. Rewrite to use local runtime shims.
|
|
695
703
|
if (isCompiledBinary()) {
|
|
696
|
-
|
|
697
|
-
transformed = transformed.replace(/from\s+["']veryfront["']/g, 'from "./_vf_runtime.mjs"');
|
|
698
|
-
// Dynamic root imports: import("veryfront")
|
|
699
|
-
transformed = transformed.replace(/import\s*\(\s*["']veryfront["']\s*\)/g, 'import("./_vf_runtime.mjs")');
|
|
700
|
-
// Subpath static imports: from "veryfront/agent" → from "./_vf_agent.mjs"
|
|
701
|
-
transformed = transformed.replace(/from\s+["']veryfront\/([^"']+)["']/g, (_match, subpath) => `from "./_vf_${subpath.replace(/\//g, "_")}.mjs"`);
|
|
702
|
-
// Subpath dynamic imports: import("veryfront/agent") → import("./_vf_agent.mjs")
|
|
703
|
-
transformed = transformed.replace(/import\s*\(\s*["']veryfront\/([^"']+)["']\s*\)/g, (_match, subpath) => `import("./_vf_${subpath.replace(/\//g, "_")}.mjs")`);
|
|
704
|
+
transformed = rewriteCompiledBinaryVeryfrontImports(transformed);
|
|
704
705
|
}
|
|
705
706
|
}
|
|
706
707
|
return transformed;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.169";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -200,6 +200,31 @@ export function processStream(
|
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
+
case "reasoning-start": {
|
|
204
|
+
sendSSE(controller, encoder, {
|
|
205
|
+
type: "reasoning-start",
|
|
206
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
207
|
+
});
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
case "reasoning-delta": {
|
|
212
|
+
sendSSE(controller, encoder, {
|
|
213
|
+
type: "reasoning-delta",
|
|
214
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
215
|
+
delta: typeof typedPart.delta === "string" ? typedPart.delta : "",
|
|
216
|
+
});
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
case "reasoning-end": {
|
|
221
|
+
sendSSE(controller, encoder, {
|
|
222
|
+
type: "reasoning-end",
|
|
223
|
+
id: typeof typedPart.id === "string" ? typedPart.id : "reasoning",
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
|
|
203
228
|
case "tool-input-start": {
|
|
204
229
|
const toolId = typedPart.id;
|
|
205
230
|
state.toolCalls.set(toolId, {
|
|
@@ -59,6 +59,9 @@ export type RuntimeToolCallRepairFunction = (
|
|
|
59
59
|
|
|
60
60
|
export type RuntimeStreamPart =
|
|
61
61
|
| { type: "text-delta"; text: string }
|
|
62
|
+
| { type: "reasoning-start"; id: string }
|
|
63
|
+
| { type: "reasoning-delta"; id: string; delta: string }
|
|
64
|
+
| { type: "reasoning-end"; id: string }
|
|
62
65
|
| {
|
|
63
66
|
type: "tool-input-start";
|
|
64
67
|
id: string;
|
|
@@ -20,6 +20,7 @@ export interface RunFinishedMetadata {
|
|
|
20
20
|
export interface StreamTransformState {
|
|
21
21
|
messageId: string | null;
|
|
22
22
|
textOpen: boolean;
|
|
23
|
+
reasoningMessageId: string | null;
|
|
23
24
|
sawVisibleOutput: boolean;
|
|
24
25
|
sawTerminalError: boolean;
|
|
25
26
|
metadata: RunFinishedMetadata;
|
|
@@ -29,6 +30,7 @@ export function createStreamTransformState(): StreamTransformState {
|
|
|
29
30
|
return {
|
|
30
31
|
messageId: null,
|
|
31
32
|
textOpen: false,
|
|
33
|
+
reasoningMessageId: null,
|
|
32
34
|
sawVisibleOutput: false,
|
|
33
35
|
sawTerminalError: false,
|
|
34
36
|
metadata: {},
|
|
@@ -64,6 +66,17 @@ const agUiEventPayloadSchemas = {
|
|
|
64
66
|
TextMessageEnd: z.object({
|
|
65
67
|
messageId: z.string().min(1),
|
|
66
68
|
}),
|
|
69
|
+
ReasoningMessageStart: z.object({
|
|
70
|
+
messageId: z.string().min(1),
|
|
71
|
+
role: z.literal("reasoning"),
|
|
72
|
+
}),
|
|
73
|
+
ReasoningMessageContent: z.object({
|
|
74
|
+
messageId: z.string().min(1),
|
|
75
|
+
delta: z.string(),
|
|
76
|
+
}),
|
|
77
|
+
ReasoningMessageEnd: z.object({
|
|
78
|
+
messageId: z.string().min(1),
|
|
79
|
+
}),
|
|
67
80
|
ToolCallStart: z.object({
|
|
68
81
|
toolCallId: z.string().min(1),
|
|
69
82
|
toolCallName: z.string().min(1),
|
|
@@ -151,6 +164,23 @@ function getMessageId(state: StreamTransformState, event: RuntimeDataEvent): str
|
|
|
151
164
|
return state.messageId;
|
|
152
165
|
}
|
|
153
166
|
|
|
167
|
+
function getReasoningMessageId(state: StreamTransformState, event: RuntimeDataEvent): string {
|
|
168
|
+
if (typeof event.id === "string" && event.id.length > 0) {
|
|
169
|
+
state.reasoningMessageId = state.messageId
|
|
170
|
+
? `${state.messageId}:reasoning:${event.id}`
|
|
171
|
+
: event.id;
|
|
172
|
+
return state.reasoningMessageId;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!state.reasoningMessageId) {
|
|
176
|
+
state.reasoningMessageId = state.messageId
|
|
177
|
+
? `${state.messageId}:reasoning:${dntShim.crypto.randomUUID()}`
|
|
178
|
+
: dntShim.crypto.randomUUID();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return state.reasoningMessageId;
|
|
182
|
+
}
|
|
183
|
+
|
|
154
184
|
function applyDataMetadata(state: StreamTransformState, event: RuntimeDataEvent): void {
|
|
155
185
|
const data = event.data && typeof event.data === "object" && !Array.isArray(event.data)
|
|
156
186
|
? event.data as Record<string, unknown>
|
|
@@ -231,6 +261,32 @@ export function mapRuntimeEventToAgUi(
|
|
|
231
261
|
}];
|
|
232
262
|
}
|
|
233
263
|
|
|
264
|
+
case "reasoning-start":
|
|
265
|
+
state.sawVisibleOutput = true;
|
|
266
|
+
return [{
|
|
267
|
+
event: "ReasoningMessageStart",
|
|
268
|
+
payload: { messageId: getReasoningMessageId(state, event), role: "reasoning" },
|
|
269
|
+
}];
|
|
270
|
+
|
|
271
|
+
case "reasoning-delta":
|
|
272
|
+
state.sawVisibleOutput = true;
|
|
273
|
+
return [{
|
|
274
|
+
event: "ReasoningMessageContent",
|
|
275
|
+
payload: {
|
|
276
|
+
messageId: getReasoningMessageId(state, event),
|
|
277
|
+
delta: typeof event.delta === "string" ? event.delta : "",
|
|
278
|
+
},
|
|
279
|
+
}];
|
|
280
|
+
|
|
281
|
+
case "reasoning-end": {
|
|
282
|
+
const messageId = getReasoningMessageId(state, event);
|
|
283
|
+
state.reasoningMessageId = null;
|
|
284
|
+
return [{
|
|
285
|
+
event: "ReasoningMessageEnd",
|
|
286
|
+
payload: { messageId },
|
|
287
|
+
}];
|
|
288
|
+
}
|
|
289
|
+
|
|
234
290
|
case "tool-input-start":
|
|
235
291
|
state.sawVisibleOutput = true;
|
|
236
292
|
return [{
|
|
@@ -70,6 +70,44 @@ export class VeryfrontFSAdapter implements FSAdapter {
|
|
|
70
70
|
/** Whether running in proxy mode (shared adapter with per-request OAuth tokens) */
|
|
71
71
|
private proxyMode: boolean;
|
|
72
72
|
|
|
73
|
+
private getCurrentFileListCacheKey(): string | undefined {
|
|
74
|
+
return this.contentContext ? buildFileListCacheKey(this.contentContext) : undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private getCachedFileListSync<T extends { path: string; id?: string }>(): T[] | undefined {
|
|
78
|
+
const cacheKey = this.getCurrentFileListCacheKey();
|
|
79
|
+
if (!cacheKey) return undefined;
|
|
80
|
+
return this.cache.get(cacheKey) as T[] | undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private async getCachedFileListAsync<T extends { path: string }>(
|
|
84
|
+
noContextMessage: string,
|
|
85
|
+
lookupLabel: string,
|
|
86
|
+
missReason: string,
|
|
87
|
+
): Promise<{ cacheKey: string; files: T[] | undefined } | undefined> {
|
|
88
|
+
const cacheKey = this.getCurrentFileListCacheKey();
|
|
89
|
+
if (!cacheKey) {
|
|
90
|
+
logger.debug(noContextMessage);
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const files = await this.cache.getAsync<T[]>(cacheKey);
|
|
95
|
+
logger.debug(`${lookupLabel} lookup`, {
|
|
96
|
+
cacheKey,
|
|
97
|
+
hasResult: !!files,
|
|
98
|
+
resultSize: files?.length ?? 0,
|
|
99
|
+
hasContent: (files as Array<{ content?: string }> | undefined)?.filter((file) =>
|
|
100
|
+
!!file.content
|
|
101
|
+
)?.length ?? 0,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (!files?.length) {
|
|
105
|
+
this.scheduleFileListWarmup(missReason, cacheKey);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return { cacheKey, files };
|
|
109
|
+
}
|
|
110
|
+
|
|
73
111
|
constructor(config: FSAdapterConfig) {
|
|
74
112
|
this.invalidationCallbacks = config.invalidationCallbacks ?? {};
|
|
75
113
|
const vf = config.veryfront;
|
|
@@ -120,56 +158,23 @@ export class VeryfrontFSAdapter implements FSAdapter {
|
|
|
120
158
|
getReleaseId: () => this.contentContext?.releaseId ?? null,
|
|
121
159
|
getContentContext: () => this.contentContext,
|
|
122
160
|
getFileList: async () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
path: string;
|
|
133
|
-
content?: string;
|
|
134
|
-
type?: string;
|
|
135
|
-
size?: number;
|
|
136
|
-
updated_at?: string;
|
|
137
|
-
}>
|
|
138
|
-
>(cacheKey);
|
|
139
|
-
|
|
140
|
-
logger.debug("getFileList lookup", {
|
|
141
|
-
cacheKey,
|
|
142
|
-
hasResult: !!result,
|
|
143
|
-
resultSize: result?.length ?? 0,
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
if (!result?.length) {
|
|
147
|
-
this.scheduleFileListWarmup("getFileList miss", cacheKey);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return result;
|
|
161
|
+
const cached = await this.getCachedFileListAsync<{
|
|
162
|
+
id?: string;
|
|
163
|
+
path: string;
|
|
164
|
+
content?: string;
|
|
165
|
+
type?: string;
|
|
166
|
+
size?: number;
|
|
167
|
+
updated_at?: string;
|
|
168
|
+
}>("getFileList: no contentContext", "getFileList", "getFileList miss");
|
|
169
|
+
return cached?.files;
|
|
151
170
|
},
|
|
152
171
|
hasCachedFileList: async () => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const result = await this.cache.getAsync<Array<{ path: string }>>(cacheKey);
|
|
160
|
-
const hasResult = Array.isArray(result) && result.length > 0;
|
|
161
|
-
|
|
162
|
-
logger.debug("hasCachedFileList lookup", {
|
|
163
|
-
cacheKey,
|
|
164
|
-
hasResult,
|
|
165
|
-
resultSize: result?.length ?? 0,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
if (!hasResult) {
|
|
169
|
-
this.scheduleFileListWarmup("hasCachedFileList miss", cacheKey);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return hasResult;
|
|
172
|
+
const cached = await this.getCachedFileListAsync<{ path: string }>(
|
|
173
|
+
"hasCachedFileList: no contentContext",
|
|
174
|
+
"hasCachedFileList",
|
|
175
|
+
"hasCachedFileList miss",
|
|
176
|
+
);
|
|
177
|
+
return Array.isArray(cached?.files) && cached.files.length > 0;
|
|
173
178
|
},
|
|
174
179
|
isPersistentCacheInvalidated: (prefix: string) => this.isPersistentCacheInvalidated(prefix),
|
|
175
180
|
isReleaseBeingInvalidated: (releaseId: string) =>
|
|
@@ -196,28 +201,12 @@ export class VeryfrontFSAdapter implements FSAdapter {
|
|
|
196
201
|
contentContextGetter,
|
|
197
202
|
(path) => this.statOps.getOriginalApiPath(path),
|
|
198
203
|
async () => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
205
|
-
const result = await this.cache.getAsync<Array<{ path: string; content?: string }>>(
|
|
206
|
-
cacheKey,
|
|
204
|
+
const cached = await this.getCachedFileListAsync<{ path: string; content?: string }>(
|
|
205
|
+
"getFileListCache: no contentContext",
|
|
206
|
+
"getFileListCache",
|
|
207
|
+
"getFileListCache miss",
|
|
207
208
|
);
|
|
208
|
-
|
|
209
|
-
logger.debug("getFileListCache lookup", {
|
|
210
|
-
cacheKey,
|
|
211
|
-
hasResult: !!result,
|
|
212
|
-
resultSize: result?.length ?? 0,
|
|
213
|
-
hasContent: result?.filter((f) => f.content)?.length ?? 0,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
if (!result?.length) {
|
|
217
|
-
this.scheduleFileListWarmup("getFileListCache miss", cacheKey);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return result;
|
|
209
|
+
return cached?.files;
|
|
221
210
|
},
|
|
222
211
|
);
|
|
223
212
|
|
|
@@ -560,17 +549,21 @@ export class VeryfrontFSAdapter implements FSAdapter {
|
|
|
560
549
|
return [];
|
|
561
550
|
}
|
|
562
551
|
|
|
563
|
-
const
|
|
564
|
-
|
|
552
|
+
const cached = await this.getCachedFileListAsync<{ path: string; content?: string }>(
|
|
553
|
+
"getAllSourceFiles: no contentContext",
|
|
554
|
+
"getAllSourceFiles",
|
|
555
|
+
"getAllSourceFiles miss",
|
|
556
|
+
);
|
|
557
|
+
const cacheKey = cached?.cacheKey;
|
|
558
|
+
const files = cached?.files;
|
|
565
559
|
|
|
566
|
-
if (!files?.length) {
|
|
560
|
+
if (!cacheKey || !files?.length) {
|
|
567
561
|
logger.debug("getAllSourceFiles cache miss or empty", {
|
|
568
562
|
cacheKey,
|
|
569
563
|
initialized: this.initialized,
|
|
570
564
|
hasFiles: !!files,
|
|
571
565
|
fileCount: files?.length ?? 0,
|
|
572
566
|
});
|
|
573
|
-
this.scheduleFileListWarmup("getAllSourceFiles miss", cacheKey);
|
|
574
567
|
return [];
|
|
575
568
|
}
|
|
576
569
|
|
|
@@ -588,24 +581,14 @@ export class VeryfrontFSAdapter implements FSAdapter {
|
|
|
588
581
|
}
|
|
589
582
|
|
|
590
583
|
getEntityIdForPath(path: string): string | undefined {
|
|
591
|
-
if (!this.contentContext) return undefined;
|
|
592
|
-
|
|
593
584
|
const normalizedPath = this.normalizer.normalize(path);
|
|
594
|
-
const
|
|
595
|
-
const cachedFiles = this.cache.get(cacheKey) as
|
|
596
|
-
| Array<{ id?: string; path: string }>
|
|
597
|
-
| undefined;
|
|
585
|
+
const cachedFiles = this.getCachedFileListSync<{ id?: string; path: string }>();
|
|
598
586
|
|
|
599
587
|
return cachedFiles?.find((f) => f.path === normalizedPath)?.id;
|
|
600
588
|
}
|
|
601
589
|
|
|
602
590
|
getFilePathByEntityId(entityId: string): string | undefined {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const cacheKey = buildFileListCacheKey(this.contentContext);
|
|
606
|
-
const cachedFiles = this.cache.get(cacheKey) as
|
|
607
|
-
| Array<{ id?: string; path: string }>
|
|
608
|
-
| undefined;
|
|
591
|
+
const cachedFiles = this.getCachedFileListSync<{ id?: string; path: string }>();
|
|
609
592
|
|
|
610
593
|
return cachedFiles?.find((f) => f.id === entityId)?.path;
|
|
611
594
|
}
|
|
@@ -111,6 +111,13 @@ interface DataResolutionResult {
|
|
|
111
111
|
layoutProps: Map<string, Record<string, unknown>>;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
interface FetchedDataResult {
|
|
115
|
+
type: "page" | "layout";
|
|
116
|
+
id: string;
|
|
117
|
+
result: Awaited<ReturnType<RenderPipeline["dataFetcher"]["fetchData"]>> | null;
|
|
118
|
+
error: Error | null;
|
|
119
|
+
}
|
|
120
|
+
|
|
114
121
|
export class RenderPipeline {
|
|
115
122
|
private config: RenderPipelineConfig;
|
|
116
123
|
private dataFetcher: DataFetcher;
|
|
@@ -322,6 +329,17 @@ export class RenderPipeline {
|
|
|
322
329
|
{ "render.data_job_count": dataJobs.length },
|
|
323
330
|
);
|
|
324
331
|
|
|
332
|
+
this.applyFetchedDataResults(slug, dataResults, pageProps, layoutProps);
|
|
333
|
+
|
|
334
|
+
return { params, pageProps, layoutProps };
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private applyFetchedDataResults(
|
|
338
|
+
slug: string,
|
|
339
|
+
dataResults: FetchedDataResult[],
|
|
340
|
+
pageProps: Record<string, unknown>,
|
|
341
|
+
layoutProps: Map<string, Record<string, unknown>>,
|
|
342
|
+
): void {
|
|
325
343
|
for (const { type, id, result, error } of dataResults) {
|
|
326
344
|
if (error) throw error;
|
|
327
345
|
if (!result) continue;
|
|
@@ -348,8 +366,6 @@ export class RenderPipeline {
|
|
|
348
366
|
layoutProps.set(id, result.props as Record<string, unknown>);
|
|
349
367
|
}
|
|
350
368
|
}
|
|
351
|
-
|
|
352
|
-
return { params, pageProps, layoutProps };
|
|
353
369
|
}
|
|
354
370
|
|
|
355
371
|
async renderPage(slug: string, options?: RenderOptions): Promise<RenderResult> {
|
|
@@ -800,6 +800,119 @@ export async function rewriteNodeExternalImports(
|
|
|
800
800
|
return transformed;
|
|
801
801
|
}
|
|
802
802
|
|
|
803
|
+
export function rewriteCompiledBinaryVeryfrontImports(code: string): string {
|
|
804
|
+
let transformed = code;
|
|
805
|
+
|
|
806
|
+
transformed = transformed.replace(
|
|
807
|
+
/from\s+["']veryfront["']/g,
|
|
808
|
+
'from "./_vf_runtime.mjs"',
|
|
809
|
+
);
|
|
810
|
+
transformed = transformed.replace(
|
|
811
|
+
/import\s*\(\s*["']veryfront["']\s*\)/g,
|
|
812
|
+
'import("./_vf_runtime.mjs")',
|
|
813
|
+
);
|
|
814
|
+
transformed = transformed.replace(
|
|
815
|
+
/from\s+["']veryfront\/([^"']+)["']/g,
|
|
816
|
+
(_match, subpath: string) => `from "./_vf_${subpath.replace(/\//g, "_")}.mjs"`,
|
|
817
|
+
);
|
|
818
|
+
transformed = transformed.replace(
|
|
819
|
+
/import\s*\(\s*["']veryfront\/([^"']+)["']\s*\)/g,
|
|
820
|
+
(_match, subpath: string) => `import("./_vf_${subpath.replace(/\//g, "_")}.mjs")`,
|
|
821
|
+
);
|
|
822
|
+
|
|
823
|
+
return transformed;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export function rewriteCompiledBinaryUserDependencyImports(
|
|
827
|
+
code: string,
|
|
828
|
+
userDeps: Map<string, string>,
|
|
829
|
+
): string {
|
|
830
|
+
let transformed = code;
|
|
831
|
+
|
|
832
|
+
for (const name of userDeps.keys()) {
|
|
833
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
834
|
+
transformed = transformed.replace(
|
|
835
|
+
new RegExp(`import\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"),
|
|
836
|
+
(_, localName) => `const ${localName} = __vf_interopDefault(require("${name}"))`,
|
|
837
|
+
);
|
|
838
|
+
transformed = transformed.replace(
|
|
839
|
+
new RegExp(`import\\s+(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"),
|
|
840
|
+
(_, bindings) => `const ${toCjsDestructureBindings(bindings)} = require("${name}")`,
|
|
841
|
+
);
|
|
842
|
+
transformed = transformed.replace(
|
|
843
|
+
new RegExp(`import\\s+\\*\\s+as\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"),
|
|
844
|
+
(_, localName) => `const ${localName} = require("${name}")`,
|
|
845
|
+
);
|
|
846
|
+
transformed = transformed.replace(
|
|
847
|
+
new RegExp(
|
|
848
|
+
`import\\s+(\\w+)\\s*,\\s*(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`,
|
|
849
|
+
"g",
|
|
850
|
+
),
|
|
851
|
+
(_, defaultName, bindings) => {
|
|
852
|
+
const tmp = `__vf_tmp_${defaultName}`;
|
|
853
|
+
return `const ${tmp} = require("${name}"); const ${defaultName} = __vf_interopDefault(${tmp}); const ${
|
|
854
|
+
toCjsDestructureBindings(bindings)
|
|
855
|
+
} = ${tmp}`;
|
|
856
|
+
},
|
|
857
|
+
);
|
|
858
|
+
transformed = transformed.replace(
|
|
859
|
+
new RegExp(
|
|
860
|
+
`import\\s+(\\w+|\\*\\s+as\\s+\\w+|\\{[^}]+\\})\\s+from\\s+["']${escaped}(/[^"']+)["']`,
|
|
861
|
+
"g",
|
|
862
|
+
),
|
|
863
|
+
(_, binding, subpath) => {
|
|
864
|
+
const trimmedBinding = String(binding).trim();
|
|
865
|
+
if (trimmedBinding.startsWith("{")) {
|
|
866
|
+
return `const ${toCjsDestructureBindings(trimmedBinding)} = require("${name}${subpath}")`;
|
|
867
|
+
}
|
|
868
|
+
const name_ = trimmedBinding.startsWith("*")
|
|
869
|
+
? trimmedBinding.replace(/\*\s+as\s+/, "")
|
|
870
|
+
: trimmedBinding;
|
|
871
|
+
return `const ${name_} = require("${name}${subpath}")`;
|
|
872
|
+
},
|
|
873
|
+
);
|
|
874
|
+
transformed = transformed.replace(
|
|
875
|
+
new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"),
|
|
876
|
+
(_, subpath) => `Promise.resolve(require("${name}${subpath || ""}"))`,
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
return transformed;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
export async function rewriteDenoNpmDependencyImports(
|
|
884
|
+
code: string,
|
|
885
|
+
projectDir: string,
|
|
886
|
+
fs: FileSystem,
|
|
887
|
+
userDeps: Map<string, string>,
|
|
888
|
+
): Promise<string> {
|
|
889
|
+
let transformed = code;
|
|
890
|
+
|
|
891
|
+
for (const [name, version] of userDeps) {
|
|
892
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
893
|
+
let resolvedVersion = version;
|
|
894
|
+
try {
|
|
895
|
+
const pkgPath = pathHelper.join(projectDir, "node_modules", name, "package.json");
|
|
896
|
+
const pkgContent = await fs.readTextFile(pkgPath);
|
|
897
|
+
const pkg = JSON.parse(pkgContent) as { version?: string };
|
|
898
|
+
if (pkg.version) resolvedVersion = pkg.version;
|
|
899
|
+
} catch (_) {
|
|
900
|
+
/* expected: installed package.json may not exist, fall back to declared range */
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
transformed = transformed.replace(
|
|
904
|
+
new RegExp(`from\\s+["']${escaped}(/[^"']*)?["']`, "g"),
|
|
905
|
+
(_, subpath) => `from "npm:${name}@${resolvedVersion}${subpath || ""}"`,
|
|
906
|
+
);
|
|
907
|
+
transformed = transformed.replace(
|
|
908
|
+
new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"),
|
|
909
|
+
(_, subpath) => `import("npm:${name}@${resolvedVersion}${subpath || ""}")`,
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
return transformed;
|
|
914
|
+
}
|
|
915
|
+
|
|
803
916
|
async function rewriteExternalImports(
|
|
804
917
|
code: string,
|
|
805
918
|
projectDir: string,
|
|
@@ -839,111 +952,15 @@ async function rewriteExternalImports(
|
|
|
839
952
|
// injected by the esbuild banner) to load CJS packages from node_modules,
|
|
840
953
|
// since npm: specifiers only work for packages embedded at compile time.
|
|
841
954
|
if (isCompiledBinary()) {
|
|
842
|
-
|
|
843
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
844
|
-
// Default imports: import foo from "pkg" → const foo = __vf_interopDefault(require("pkg"))
|
|
845
|
-
// interopDefault unwraps .default for ESM packages transpiled to CJS
|
|
846
|
-
transformed = transformed.replace(
|
|
847
|
-
new RegExp(`import\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"),
|
|
848
|
-
(_, localName) => `const ${localName} = __vf_interopDefault(require("${name}"))`,
|
|
849
|
-
);
|
|
850
|
-
// Named imports: import { a, b } from "pkg" → const { a, b } = require("pkg")
|
|
851
|
-
transformed = transformed.replace(
|
|
852
|
-
new RegExp(`import\\s+(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`, "g"),
|
|
853
|
-
(_, bindings) => `const ${toCjsDestructureBindings(bindings)} = require("${name}")`,
|
|
854
|
-
);
|
|
855
|
-
// Namespace imports: import * as foo from "pkg" → const foo = require("pkg")
|
|
856
|
-
transformed = transformed.replace(
|
|
857
|
-
new RegExp(`import\\s+\\*\\s+as\\s+(\\w+)\\s+from\\s+["']${escaped}["']`, "g"),
|
|
858
|
-
(_, localName) => `const ${localName} = require("${name}")`,
|
|
859
|
-
);
|
|
860
|
-
// Mixed imports: import foo, { bar } from "pkg"
|
|
861
|
-
transformed = transformed.replace(
|
|
862
|
-
new RegExp(
|
|
863
|
-
`import\\s+(\\w+)\\s*,\\s*(\\{[^}]+\\})\\s+from\\s+["']${escaped}["']`,
|
|
864
|
-
"g",
|
|
865
|
-
),
|
|
866
|
-
(_, defaultName, bindings) => {
|
|
867
|
-
const tmp = `__vf_tmp_${defaultName}`;
|
|
868
|
-
return `const ${tmp} = require("${name}"); const ${defaultName} = __vf_interopDefault(${tmp}); const ${
|
|
869
|
-
toCjsDestructureBindings(bindings)
|
|
870
|
-
} = ${tmp}`;
|
|
871
|
-
},
|
|
872
|
-
);
|
|
873
|
-
// Subpath static imports: from "pkg/sub" → require("pkg/sub")
|
|
874
|
-
transformed = transformed.replace(
|
|
875
|
-
new RegExp(
|
|
876
|
-
`import\\s+(\\w+|\\*\\s+as\\s+\\w+|\\{[^}]+\\})\\s+from\\s+["']${escaped}(/[^"']+)["']`,
|
|
877
|
-
"g",
|
|
878
|
-
),
|
|
879
|
-
(_, binding, subpath) => {
|
|
880
|
-
const trimmedBinding = String(binding).trim();
|
|
881
|
-
if (trimmedBinding.startsWith("{")) {
|
|
882
|
-
return `const ${
|
|
883
|
-
toCjsDestructureBindings(trimmedBinding)
|
|
884
|
-
} = require("${name}${subpath}")`;
|
|
885
|
-
}
|
|
886
|
-
const name_ = trimmedBinding.startsWith("*")
|
|
887
|
-
? trimmedBinding.replace(/\*\s+as\s+/, "")
|
|
888
|
-
: trimmedBinding;
|
|
889
|
-
return `const ${name_} = require("${name}${subpath}")`;
|
|
890
|
-
},
|
|
891
|
-
);
|
|
892
|
-
// Dynamic imports: import("pkg") → Promise.resolve(require("pkg"))
|
|
893
|
-
transformed = transformed.replace(
|
|
894
|
-
new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"),
|
|
895
|
-
(_, subpath) => `Promise.resolve(require("${name}${subpath || ""}"))`,
|
|
896
|
-
);
|
|
897
|
-
}
|
|
955
|
+
transformed = rewriteCompiledBinaryUserDependencyImports(transformed, userDeps);
|
|
898
956
|
} else {
|
|
899
|
-
|
|
900
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
901
|
-
// Resolve exact installed version from node_modules (falls back to range)
|
|
902
|
-
let resolvedVersion = version;
|
|
903
|
-
try {
|
|
904
|
-
const pkgPath = pathHelper.join(projectDir, "node_modules", name, "package.json");
|
|
905
|
-
const pkgContent = await fs.readTextFile(pkgPath);
|
|
906
|
-
const pkg = JSON.parse(pkgContent) as { version?: string };
|
|
907
|
-
if (pkg.version) resolvedVersion = pkg.version;
|
|
908
|
-
} catch (_) {
|
|
909
|
-
/* expected: installed package.json may not exist, fall back to declared range */
|
|
910
|
-
}
|
|
911
|
-
// Static: from "pkg" and from "pkg/sub"
|
|
912
|
-
transformed = transformed.replace(
|
|
913
|
-
new RegExp(`from\\s+["']${escaped}(/[^"']*)?["']`, "g"),
|
|
914
|
-
(_, subpath) => `from "npm:${name}@${resolvedVersion}${subpath || ""}"`,
|
|
915
|
-
);
|
|
916
|
-
// Dynamic: import("pkg") and import("pkg/sub")
|
|
917
|
-
transformed = transformed.replace(
|
|
918
|
-
new RegExp(`import\\s*\\(\\s*["']${escaped}(/[^"']*)?["']\\s*\\)`, "g"),
|
|
919
|
-
(_, subpath) => `import("npm:${name}@${resolvedVersion}${subpath || ""}")`,
|
|
920
|
-
);
|
|
921
|
-
}
|
|
957
|
+
transformed = await rewriteDenoNpmDependencyImports(transformed, projectDir, fs, userDeps);
|
|
922
958
|
}
|
|
923
959
|
|
|
924
960
|
// In compiled binaries, "veryfront" resolves to embedded source that can't be
|
|
925
961
|
// imported from external temp files. Rewrite to use local runtime shims.
|
|
926
962
|
if (isCompiledBinary()) {
|
|
927
|
-
|
|
928
|
-
transformed = transformed.replace(
|
|
929
|
-
/from\s+["']veryfront["']/g,
|
|
930
|
-
'from "./_vf_runtime.mjs"',
|
|
931
|
-
);
|
|
932
|
-
// Dynamic root imports: import("veryfront")
|
|
933
|
-
transformed = transformed.replace(
|
|
934
|
-
/import\s*\(\s*["']veryfront["']\s*\)/g,
|
|
935
|
-
'import("./_vf_runtime.mjs")',
|
|
936
|
-
);
|
|
937
|
-
// Subpath static imports: from "veryfront/agent" → from "./_vf_agent.mjs"
|
|
938
|
-
transformed = transformed.replace(
|
|
939
|
-
/from\s+["']veryfront\/([^"']+)["']/g,
|
|
940
|
-
(_match, subpath: string) => `from "./_vf_${subpath.replace(/\//g, "_")}.mjs"`,
|
|
941
|
-
);
|
|
942
|
-
// Subpath dynamic imports: import("veryfront/agent") → import("./_vf_agent.mjs")
|
|
943
|
-
transformed = transformed.replace(
|
|
944
|
-
/import\s*\(\s*["']veryfront\/([^"']+)["']\s*\)/g,
|
|
945
|
-
(_match, subpath: string) => `import("./_vf_${subpath.replace(/\//g, "_")}.mjs")`,
|
|
946
|
-
);
|
|
963
|
+
transformed = rewriteCompiledBinaryVeryfrontImports(transformed);
|
|
947
964
|
}
|
|
948
965
|
}
|
|
949
966
|
|