@agimon-ai/po-artifact 0.0.0-alpha.2 → 0.0.0-alpha.21
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/LICENSE +149 -21
- package/README.md +1 -1
- package/dist/apiContracts.cjs +10 -2
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +10 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{artifactFiles-Bo5Mhwq0.cjs → artifactFiles-BmBU9Olm.cjs} +138 -76
- package/dist/artifactFiles-BmBU9Olm.cjs.map +1 -0
- package/dist/{artifactFiles-B8w_HQXv.mjs → artifactFiles-DyIkevXc.mjs} +119 -57
- package/dist/artifactFiles-DyIkevXc.mjs.map +1 -0
- package/dist/artifactFiles.cjs +7 -1
- package/dist/artifactFiles.d.mts +14 -1
- package/dist/artifactFiles.d.mts.map +1 -1
- package/dist/artifactFiles.mjs +3 -1
- package/dist/artifacts-Bhobz1nK.mjs +38 -0
- package/dist/artifacts-Bhobz1nK.mjs.map +1 -0
- package/dist/artifacts-DG_b7DZH.cjs +85 -0
- package/dist/artifacts-DG_b7DZH.cjs.map +1 -0
- package/dist/artifacts-sIj4Xaeu.d.mts +32 -0
- package/dist/artifacts-sIj4Xaeu.d.mts.map +1 -0
- package/dist/extensions/native.mjs +640 -32
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +163 -44
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +161 -42
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +848 -136
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.d.mts +8 -19
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +20 -20
- package/dist/artifactFiles-B8w_HQXv.mjs.map +0 -1
- package/dist/artifactFiles-Bo5Mhwq0.cjs.map +0 -1
|
@@ -2,13 +2,76 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_artifactFiles = require("../artifactFiles-
|
|
5
|
+
const require_artifactFiles = require("../artifactFiles-BmBU9Olm.cjs");
|
|
6
|
+
const require_artifacts = require("../artifacts-DG_b7DZH.cjs");
|
|
6
7
|
let node_path = require("node:path");
|
|
7
8
|
node_path = require_artifactFiles.__toESM(node_path, 1);
|
|
8
|
-
let
|
|
9
|
+
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
9
10
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
11
|
+
let _deepseek_ai_cordis = require("@deepseek-ai/cordis");
|
|
10
12
|
let node_timers = require("node:timers");
|
|
11
13
|
let hono = require("hono");
|
|
14
|
+
//#region src/services/artifacts/index.ts
|
|
15
|
+
/** Roots come only from admitted host configuration, never a file request. */
|
|
16
|
+
function createArtifactStorage(environment) {
|
|
17
|
+
const policies = /* @__PURE__ */ new Map();
|
|
18
|
+
return {
|
|
19
|
+
async rootForSession(sessionId, admittedEnvironment = environment) {
|
|
20
|
+
const root = require_artifactFiles.artifactRoot(sessionId, admittedEnvironment);
|
|
21
|
+
try {
|
|
22
|
+
await require_artifactFiles.ensureArtifactRoot(root);
|
|
23
|
+
return root;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof require_artifactFiles.ArtifactAccessError && error.status === 404) return void 0;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
sessions: (admittedEnvironment = environment) => require_artifactFiles.listArtifactSessions(admittedEnvironment),
|
|
30
|
+
registerWorkflowVisibility(policy) {
|
|
31
|
+
const owner = Symbol("workflow visibility");
|
|
32
|
+
policies.set(owner, policy);
|
|
33
|
+
return () => {
|
|
34
|
+
policies.delete(owner);
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
workflowVisible: (relativePath, kind) => policies.size > 0 && [...policies.values()].every((policy) => policy(relativePath, kind))
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Publish the same storage instance used by this scope's artifact reader. */
|
|
41
|
+
var ArtifactsService = class extends _deepseek_ai_cordis.Service {
|
|
42
|
+
storage;
|
|
43
|
+
constructor(context, storage) {
|
|
44
|
+
super(context, require_artifacts.ARTIFACTS_SERVICE);
|
|
45
|
+
this.storage = storage;
|
|
46
|
+
}
|
|
47
|
+
rootForSession(sessionId, environment) {
|
|
48
|
+
return this.storage.rootForSession(sessionId, environment);
|
|
49
|
+
}
|
|
50
|
+
sessions(environment) {
|
|
51
|
+
return this.storage.sessions(environment);
|
|
52
|
+
}
|
|
53
|
+
registerWorkflowVisibility(policy) {
|
|
54
|
+
return this.storage.registerWorkflowVisibility(policy);
|
|
55
|
+
}
|
|
56
|
+
workflowVisible(relativePath, kind) {
|
|
57
|
+
return this.storage.workflowVisible(relativePath, kind);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function createArtifactsPlugin(storage) {
|
|
61
|
+
return (context) => {
|
|
62
|
+
new ArtifactsService(context, storage);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/extensions/(backend)/root.server.ts
|
|
67
|
+
var root_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ host }) => {
|
|
68
|
+
const storage = createArtifactStorage(Object.freeze({ ...host.context.environment }));
|
|
69
|
+
return {
|
|
70
|
+
value: storage,
|
|
71
|
+
services: [createArtifactsPlugin(storage)]
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
12
75
|
//#region src/types/artifacts.ts
|
|
13
76
|
const artifactsChannelType = "artifacts";
|
|
14
77
|
//#endregion
|
|
@@ -26,8 +89,9 @@ async function prepareArtifactRoot(root) {
|
|
|
26
89
|
throw error;
|
|
27
90
|
}
|
|
28
91
|
}
|
|
29
|
-
function createArtifactSession({ host }) {
|
|
92
|
+
function createArtifactSession({ host }, storage) {
|
|
30
93
|
const environment = Object.freeze({ ...host.context.environment });
|
|
94
|
+
const artifactStorage = storage ?? createArtifactStorage(environment);
|
|
31
95
|
let active;
|
|
32
96
|
let timer;
|
|
33
97
|
let pending;
|
|
@@ -37,7 +101,10 @@ function createArtifactSession({ host }) {
|
|
|
37
101
|
const runtime = active;
|
|
38
102
|
if (!runtime || closed) return Promise.resolve();
|
|
39
103
|
pending = (async () => {
|
|
40
|
-
const snapshot =
|
|
104
|
+
const snapshot = {
|
|
105
|
+
...await require_artifactFiles.listArtifacts(runtime.root, artifactStorage.workflowVisible),
|
|
106
|
+
...environment.PO_SESSION_TEMP_DIR ? { temporaryRoot: environment.PO_SESSION_TEMP_DIR } : {}
|
|
107
|
+
};
|
|
41
108
|
if (closed || active !== runtime) return;
|
|
42
109
|
const fingerprint = JSON.stringify(snapshot);
|
|
43
110
|
if (fingerprint === runtime.fingerprint) return;
|
|
@@ -53,7 +120,7 @@ function createArtifactSession({ host }) {
|
|
|
53
120
|
timer = (0, node_timers.setTimeout)(() => {
|
|
54
121
|
timer = void 0;
|
|
55
122
|
refresh().finally(schedule);
|
|
56
|
-
},
|
|
123
|
+
}, require_artifacts.ARTIFACT_REFRESH_MS);
|
|
57
124
|
};
|
|
58
125
|
const stop = async () => {
|
|
59
126
|
active = void 0;
|
|
@@ -105,9 +172,13 @@ function createArtifactSession({ host }) {
|
|
|
105
172
|
//#endregion
|
|
106
173
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/serverRoot.ts
|
|
107
174
|
const createArtifactServerRoot = (context) => {
|
|
108
|
-
const
|
|
175
|
+
const storage = context.root;
|
|
176
|
+
const runtime = createArtifactSession(context, storage);
|
|
109
177
|
return {
|
|
110
|
-
value:
|
|
178
|
+
value: {
|
|
179
|
+
...runtime,
|
|
180
|
+
storage
|
|
181
|
+
},
|
|
111
182
|
activities: runtime.activities,
|
|
112
183
|
onDispose: runtime.onDispose
|
|
113
184
|
};
|
|
@@ -120,7 +191,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)(creat
|
|
|
120
191
|
function snapshotOf(value) {
|
|
121
192
|
if (typeof value !== "object" || value === null) return false;
|
|
122
193
|
const snapshot = value;
|
|
123
|
-
return Array.isArray(snapshot.items) && (snapshot.error === void 0 || typeof snapshot.error === "string") && snapshot.items.every((item) => typeof item === "object" && item !== null && typeof item.path === "string" && typeof item.name === "string" && typeof item.size === "number" && Number.isFinite(item.size) && typeof item.modifiedAt === "number" && Number.isFinite(item.modifiedAt));
|
|
194
|
+
return Array.isArray(snapshot.items) && (snapshot.error === void 0 || typeof snapshot.error === "string") && (snapshot.temporaryRoot === void 0 || typeof snapshot.temporaryRoot === "string") && snapshot.items.every((item) => typeof item === "object" && item !== null && typeof item.path === "string" && typeof item.name === "string" && typeof item.size === "number" && Number.isFinite(item.size) && typeof item.modifiedAt === "number" && Number.isFinite(item.modifiedAt));
|
|
124
195
|
}
|
|
125
196
|
function createArtifactsChannel() {
|
|
126
197
|
return {
|
|
@@ -143,7 +214,10 @@ function createArtifactsChannel() {
|
|
|
143
214
|
(async () => {
|
|
144
215
|
let snapshot;
|
|
145
216
|
try {
|
|
146
|
-
snapshot =
|
|
217
|
+
snapshot = {
|
|
218
|
+
...await require_artifactFiles.listArtifacts(require_artifactFiles.artifactRoot(scope.sessionId, scope.environment ?? {})),
|
|
219
|
+
...scope.environment?.PO_SESSION_TEMP_DIR ? { temporaryRoot: scope.environment.PO_SESSION_TEMP_DIR } : {}
|
|
220
|
+
};
|
|
147
221
|
} catch (error) {
|
|
148
222
|
snapshot = {
|
|
149
223
|
items: [],
|
|
@@ -176,32 +250,44 @@ const routes = {
|
|
|
176
250
|
list: {
|
|
177
251
|
method: "GET",
|
|
178
252
|
path: "/",
|
|
253
|
+
query: ["scope"],
|
|
179
254
|
response: void 0
|
|
180
255
|
},
|
|
181
256
|
preview: {
|
|
182
257
|
method: "GET",
|
|
183
258
|
path: "/preview",
|
|
184
|
-
query: ["path"],
|
|
259
|
+
query: ["path", "scope"],
|
|
185
260
|
response: void 0
|
|
186
261
|
},
|
|
187
262
|
content: {
|
|
188
263
|
method: "GET",
|
|
189
264
|
path: "/content",
|
|
190
|
-
query: ["path"],
|
|
265
|
+
query: ["path", "scope"],
|
|
191
266
|
raw: true
|
|
192
267
|
}
|
|
193
268
|
};
|
|
194
269
|
//#endregion
|
|
195
270
|
//#region src/services/artifactsApi/index.ts
|
|
196
|
-
function createArtifactsApi(root) {
|
|
271
|
+
function createArtifactsApi(root, options = {}) {
|
|
197
272
|
const app = new hono.Hono();
|
|
273
|
+
const selectedRoot = (scope) => {
|
|
274
|
+
if (scope === void 0 || scope === "artifacts") return root;
|
|
275
|
+
if (scope !== "temporary") throw new require_artifactFiles.ArtifactAccessError("Invalid file scope.", 400);
|
|
276
|
+
if (!options.temporaryRoot) throw new require_artifactFiles.ArtifactAccessError("Temporary files are unavailable for this session.", 404);
|
|
277
|
+
return options.temporaryRoot;
|
|
278
|
+
};
|
|
198
279
|
app.onError((error, context) => context.json({ error: error instanceof require_artifactFiles.ArtifactAccessError ? error.message : "The artifact could not be read." }, error instanceof require_artifactFiles.ArtifactAccessError ? error.status : 500));
|
|
199
280
|
app.get(routes.list.path, async (context) => {
|
|
200
|
-
const
|
|
201
|
-
|
|
281
|
+
const selected = selectedRoot(context.req.query("scope"));
|
|
282
|
+
const snapshot = await require_artifactFiles.listArtifacts(selected, selected === root ? options.workflowVisible : () => true);
|
|
283
|
+
return context.json({
|
|
284
|
+
...snapshot,
|
|
285
|
+
...options.temporaryRoot ? { temporaryRoot: options.temporaryRoot } : {}
|
|
286
|
+
}, snapshot.error === void 0 ? 200 : 500);
|
|
202
287
|
});
|
|
203
288
|
app.get(routes.preview.path, async (context) => {
|
|
204
|
-
const
|
|
289
|
+
const selected = selectedRoot(context.req.query("scope"));
|
|
290
|
+
const file = await require_artifactFiles.openArtifact(selected, context.req.query("path"), selected === root ? options.workflowVisible : () => true);
|
|
205
291
|
try {
|
|
206
292
|
const preview = {
|
|
207
293
|
path: file.path,
|
|
@@ -213,7 +299,7 @@ function createArtifactsApi(root) {
|
|
|
213
299
|
unavailable: true,
|
|
214
300
|
reason: "This artifact is too large for a text preview."
|
|
215
301
|
});
|
|
216
|
-
const bytes = await require_artifactFiles.readArtifactBytes(file.handle,
|
|
302
|
+
const bytes = await require_artifactFiles.readArtifactBytes(file.handle, require_artifacts.MAX_PREVIEW_BYTES + 1);
|
|
217
303
|
if (bytes.byteLength > 1048576) return context.json({
|
|
218
304
|
...preview,
|
|
219
305
|
unavailable: true,
|
|
@@ -233,7 +319,8 @@ function createArtifactsApi(root) {
|
|
|
233
319
|
}
|
|
234
320
|
});
|
|
235
321
|
app.get(routes.content.path, async (context) => {
|
|
236
|
-
const
|
|
322
|
+
const selected = selectedRoot(context.req.query("scope"));
|
|
323
|
+
const file = await require_artifactFiles.openArtifact(selected, context.req.query("path"), selected === root ? options.workflowVisible : () => true);
|
|
237
324
|
try {
|
|
238
325
|
if (file.stat.size > 26214400) throw new require_artifactFiles.ArtifactAccessError("This artifact is too large to download.", 413);
|
|
239
326
|
const version = `"${file.stat.dev}-${file.stat.ino}-${file.stat.size}-${file.stat.mtimeMs}-${file.stat.ctimeMs}"`;
|
|
@@ -297,19 +384,25 @@ function createArtifactsApi(root) {
|
|
|
297
384
|
});
|
|
298
385
|
return app;
|
|
299
386
|
}
|
|
387
|
+
function createArtifactApi(storage) {
|
|
388
|
+
return {
|
|
389
|
+
basePath: "artifacts",
|
|
390
|
+
start(context) {
|
|
391
|
+
if (!context.sessionId) throw new Error("Artifacts requires a session identity.");
|
|
392
|
+
const app = createArtifactsApi(require_artifactFiles.artifactRoot(context.sessionId, context.environment ?? {}), {
|
|
393
|
+
temporaryRoot: context.environment?.PO_SESSION_TEMP_DIR,
|
|
394
|
+
workflowVisible: storage?.workflowVisible
|
|
395
|
+
});
|
|
396
|
+
return {
|
|
397
|
+
fetch: (request) => app.fetch(request),
|
|
398
|
+
close: () => void 0
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
300
403
|
//#endregion
|
|
301
404
|
//#region src/extensions/workspaces/sessions/(backend)/api/artifacts/route.server.ts
|
|
302
|
-
var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)({
|
|
303
|
-
basePath: "artifacts",
|
|
304
|
-
start(context) {
|
|
305
|
-
if (!context.sessionId) throw new Error("Artifacts requires a session identity.");
|
|
306
|
-
const app = createArtifactsApi(require_artifactFiles.artifactRoot(context.sessionId, context.environment ?? {}));
|
|
307
|
-
return {
|
|
308
|
-
fetch: (request) => app.fetch(request),
|
|
309
|
-
close: () => void 0
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
});
|
|
405
|
+
var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({ root }) => createArtifactApi(root.storage));
|
|
313
406
|
//#endregion
|
|
314
407
|
//#region src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts
|
|
315
408
|
var before_agent_start_server_default = (0, _agimon_ai_po_core_extensionFile.defineHook)((context) => context.root.beforeAgentStart);
|
|
@@ -319,45 +412,71 @@ var tool_execution_end_server_default = (0, _agimon_ai_po_core_extensionFile.def
|
|
|
319
412
|
//#endregion
|
|
320
413
|
//#region generated/server.ts
|
|
321
414
|
const at = (value, context) => typeof value === "function" ? value(context) : value;
|
|
415
|
+
/* v8 ignore next -- generated normalization branch */
|
|
416
|
+
const defined = (values) => values.filter((value) => value !== void 0);
|
|
322
417
|
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
323
418
|
...identity,
|
|
324
419
|
...value
|
|
325
420
|
};
|
|
326
|
-
const
|
|
421
|
+
const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
327
422
|
name: "@agimon-ai/po-artifact",
|
|
328
|
-
providerOverrides: (0,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
423
|
+
providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default$1, root_server_default),
|
|
424
|
+
injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({
|
|
425
|
+
global: [root_server_default$1],
|
|
426
|
+
workspace: [root_server_default$1],
|
|
427
|
+
session: [root_server_default$1, root_server_default]
|
|
428
|
+
}),
|
|
429
|
+
global: async (context) => {
|
|
430
|
+
const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
|
|
431
|
+
return {
|
|
432
|
+
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
|
|
433
|
+
get channels() {
|
|
434
|
+
return [() => via({ frameType: "artifacts" }, artifacts_server_default())];
|
|
435
|
+
},
|
|
436
|
+
services: [...scopeGlobal.services ?? []]
|
|
437
|
+
};
|
|
438
|
+
},
|
|
439
|
+
workspace: async (context) => {
|
|
440
|
+
const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
|
|
441
|
+
return {
|
|
442
|
+
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal),
|
|
443
|
+
get channels() {
|
|
444
|
+
return defined([context.hosted("global") ? void 0 : () => via({ frameType: "artifacts" }, artifacts_server_default())]);
|
|
445
|
+
},
|
|
446
|
+
services: [...scopeGlobal.services ?? []]
|
|
447
|
+
};
|
|
448
|
+
},
|
|
335
449
|
session: async (context) => {
|
|
336
|
-
const
|
|
337
|
-
const
|
|
450
|
+
const scopeGlobal = await context.scopeRoot("global", root_server_default$1, context);
|
|
451
|
+
const contextGlobal = {
|
|
338
452
|
...context,
|
|
453
|
+
root: scopeGlobal.value
|
|
454
|
+
};
|
|
455
|
+
const scopeSession = await context.scopeRoot("session", root_server_default, contextGlobal);
|
|
456
|
+
const contextSession = {
|
|
457
|
+
...contextGlobal,
|
|
339
458
|
root: scopeSession.value
|
|
340
459
|
};
|
|
341
460
|
return {
|
|
342
|
-
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeSession),
|
|
461
|
+
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeGlobal, scopeSession),
|
|
343
462
|
get api() {
|
|
344
463
|
return [at(route_server_default, contextSession)];
|
|
345
464
|
},
|
|
346
465
|
get channels() {
|
|
347
|
-
return [() => via({ frameType: "artifacts" }, artifacts_server_default())];
|
|
466
|
+
return defined([context.hosted("global") ? void 0 : () => via({ frameType: "artifacts" }, artifacts_server_default())]);
|
|
348
467
|
},
|
|
349
468
|
get hooks() {
|
|
350
469
|
return [via({ event: "before_agent_start" }, at(before_agent_start_server_default, contextSession)), via({ event: "tool_execution_end" }, at(tool_execution_end_server_default, contextSession))];
|
|
351
470
|
},
|
|
352
|
-
services: [...scopeSession.services ?? []],
|
|
471
|
+
services: [...scopeGlobal.services ?? [], ...scopeSession.services ?? []],
|
|
353
472
|
get activities() {
|
|
354
|
-
return [...scopeSession.activities ?? []];
|
|
473
|
+
return [...scopeGlobal.activities ?? [], ...scopeSession.activities ?? []];
|
|
355
474
|
}
|
|
356
475
|
};
|
|
357
476
|
}
|
|
358
477
|
});
|
|
359
478
|
//#endregion
|
|
360
|
-
exports.default =
|
|
361
|
-
exports.
|
|
479
|
+
exports.default = serverPlugin;
|
|
480
|
+
exports.serverPlugin = serverPlugin;
|
|
362
481
|
|
|
363
482
|
//# sourceMappingURL=server.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["ensureArtifactRoot","ArtifactAccessError","listArtifacts","setTimeout","ARTIFACT_REFRESH_MS","artifactRoot","defineRoot","listArtifacts","artifactRoot","defineChannel","Hono","ArtifactAccessError","listArtifacts","openArtifact","readArtifactBytes","MAX_PREVIEW_BYTES","path","artifactRoot","defineRoute","defineHook","defineHook","defineServerPlugin","composeServerProviderOverrides","rootSession","channelArtifacts","composeRootHooks","apiRoute","hookBeforeAgentStart","hookToolExecutionEnd"],"sources":["../../src/types/artifacts.ts","../../src/services/artifactSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/serverRoot.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/artifactChannel/index.ts","../../src/extensions/(backend)/channel/artifacts.server.ts","../../src/types/apiRoutes.ts","../../src/services/artifactsApi/index.ts","../../src/extensions/workspaces/sessions/(backend)/api/artifacts/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.ts","../../generated/server.ts"],"sourcesContent":["export interface ArtifactItem {\n /** Relative to the current session's artifact directory. */\n path: string;\n name: string;\n size: number;\n modifiedAt: number;\n}\n\nexport interface ArtifactSnapshot {\n items: ArtifactItem[];\n error?: string;\n}\n\nexport interface ArtifactPreview {\n path: string;\n content: string;\n mimeType: string;\n unavailable?: boolean;\n reason?: string;\n}\n\nexport const artifactsChannelType = 'artifacts';\n","import { clearTimeout, setTimeout } from 'node:timers';\n\nimport type { DoomHeadlessActivity, DoomHeadlessExecutionContext, DoomHeadlessHook } from '@agimon-ai/po-core/headless';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { ARTIFACT_REFRESH_MS } from '../../constants/artifacts';\nimport { artifactsChannelType } from '../../types/artifacts';\nimport { ArtifactAccessError, artifactRoot, ensureArtifactRoot, listArtifacts } from '../artifactFiles';\n\n/**\n * Creates the session artifact folder. Resolves false when the host has no artifact folder\n * (the edge build in M1 rejects with a 404); Node never rejects with that status here.\n */\nasync function prepareArtifactRoot(root: string): Promise<boolean> {\n try {\n await ensureArtifactRoot(root);\n return true;\n } catch (error) {\n if (error instanceof ArtifactAccessError && error.status === 404) return false;\n throw error;\n }\n}\n\nexport function createArtifactSession({ host }: DoomServerPluginContext) {\n const environment = Object.freeze({ ...host.context.environment });\n let active: { context: DoomHeadlessExecutionContext; root: string; fingerprint?: string } | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let pending: Promise<void> | undefined;\n let closed = false;\n\n const refresh = (): Promise<void> => {\n if (pending) return pending;\n const runtime = active;\n if (!runtime || closed) return Promise.resolve();\n pending = (async () => {\n const snapshot = await listArtifacts(runtime.root);\n if (closed || active !== runtime) return;\n const fingerprint = JSON.stringify(snapshot);\n if (fingerprint === runtime.fingerprint) return;\n runtime.fingerprint = fingerprint;\n host.context.directEvents?.publish(artifactsChannelType, runtime.context.sessionId, snapshot);\n })().finally(() => {\n pending = undefined;\n });\n return pending;\n };\n const schedule = (): void => {\n if (!active || closed) return;\n timer = setTimeout(() => {\n timer = undefined;\n void refresh().finally(schedule);\n }, ARTIFACT_REFRESH_MS);\n };\n const stop = async (): Promise<void> => {\n active = undefined;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n await pending;\n };\n const activity: DoomHeadlessActivity = {\n name: 'artifacts',\n async start(context) {\n if (closed) throw new Error('Artifact session is closed.');\n await stop();\n const root = artifactRoot(context.sessionId, environment);\n if (!(await prepareArtifactRoot(root))) return stop;\n if (closed) throw new Error('Artifact session is closed.');\n active = { context, root };\n await refresh();\n schedule();\n return stop;\n },\n };\n const beforeAgentStart: DoomHeadlessHook = {\n event: 'before_agent_start',\n async handle(event, context) {\n const root = artifactRoot(context.sessionId, environment);\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n if (!(await prepareArtifactRoot(root))) return { systemPrompt };\n const declaration = `Session artifact folder: ${root}`;\n if (systemPrompt.includes(declaration)) return { systemPrompt };\n return {\n systemPrompt:\n `${systemPrompt}\\n\\n${declaration}\\nSave user-designated artifacts and important deliverable documents in this folder, using descriptive filenames. Keep ordinary repository source edits in their existing locations. Do not move existing documents or overwrite artifacts without the user's intent. This folder belongs only to the current session.`.trim(),\n };\n },\n };\n const toolExecutionEnd: DoomHeadlessHook = {\n event: 'tool_execution_end',\n handle(_event, context) {\n return active?.context.sessionId === context.sessionId ? refresh() : undefined;\n },\n };\n return {\n activities: [activity],\n beforeAgentStart,\n toolExecutionEnd,\n onDispose: async () => {\n closed = true;\n await stop();\n },\n };\n}\n","import type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport { createArtifactSession } from '../../../../../services/artifactSession';\n\nexport const createArtifactServerRoot = (context: DoomServerPluginContext) => {\n const runtime = createArtifactSession(context);\n return { value: runtime, activities: runtime.activities, onDispose: runtime.onDispose };\n};\nexport type ArtifactServerScope = ReturnType<typeof createArtifactServerRoot>['value'];\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createArtifactServerRoot } from './_lib/serverRoot';\n\nexport default defineRoot(createArtifactServerRoot);\n","import type { DoomHubChannel } from '@agimon-ai/po-core/hubChannel';\n\nimport { artifactsChannelType, type ArtifactSnapshot } from '../../types/artifacts';\nimport { artifactRoot, listArtifacts } from '../artifactFiles';\n\nfunction snapshotOf(value: unknown): value is ArtifactSnapshot {\n if (typeof value !== 'object' || value === null) return false;\n const snapshot = value as Partial<ArtifactSnapshot>;\n return (\n Array.isArray(snapshot.items) &&\n (snapshot.error === undefined || typeof snapshot.error === 'string') &&\n snapshot.items.every(\n (item) =>\n typeof item === 'object' &&\n item !== null &&\n typeof item.path === 'string' &&\n typeof item.name === 'string' &&\n typeof item.size === 'number' &&\n Number.isFinite(item.size) &&\n typeof item.modifiedAt === 'number' &&\n Number.isFinite(item.modifiedAt),\n )\n );\n}\n\nexport function createArtifactsChannel(): DoomHubChannel {\n return {\n frameType: artifactsChannelType,\n start(host) {\n const sessions = new Map<string, { snapshot?: ArtifactSnapshot; unsubscribe: () => void }>();\n return {\n payloadFor(scope) {\n return sessions.get(scope.sessionId)?.snapshot;\n },\n sessionAdded(scope) {\n sessions.get(scope.sessionId)?.unsubscribe();\n const state: { snapshot?: ArtifactSnapshot; unsubscribe: () => void } = { unsubscribe: () => undefined };\n sessions.set(scope.sessionId, state);\n state.unsubscribe = host.directEvents.subscribe(\n artifactsChannelType,\n scope.sessionId,\n (snapshot) => {\n if (!snapshotOf(snapshot) || sessions.get(scope.sessionId) !== state) return;\n state.snapshot = snapshot;\n host.publish(scope.sessionId, snapshot);\n },\n { replayLatest: true },\n );\n void (async () => {\n let snapshot: ArtifactSnapshot;\n try {\n snapshot = await listArtifacts(artifactRoot(scope.sessionId, scope.environment ?? {}));\n } catch (error) {\n snapshot = {\n items: [],\n error: error instanceof Error ? error.message : 'The artifact folder could not be read.',\n };\n }\n // A live session event wins over the earlier seed read.\n if (sessions.get(scope.sessionId) !== state || state.snapshot !== undefined) return;\n state.snapshot = snapshot;\n host.publish(scope.sessionId, snapshot);\n })();\n },\n sessionRemoved(sessionId) {\n sessions.get(sessionId)?.unsubscribe();\n sessions.delete(sessionId);\n },\n close() {\n for (const state of sessions.values()) state.unsubscribe();\n sessions.clear();\n },\n };\n },\n };\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createArtifactsChannel } from '../../../services/artifactChannel';\n\nexport default defineChannel(createArtifactsChannel);\n","import type { ApiResponseOf, ApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { ArtifactPreview, ArtifactSnapshot } from './artifacts';\n\nconst routes = {\n list: {\n method: 'GET',\n path: '/',\n response: undefined as unknown as ApiResponseOf<ArtifactSnapshot>,\n },\n preview: {\n method: 'GET',\n path: '/preview',\n query: ['path'],\n response: undefined as unknown as ApiResponseOf<ArtifactPreview>,\n },\n content: {\n method: 'GET',\n path: '/content',\n query: ['path'],\n raw: true,\n },\n} as const satisfies ApiRoutes;\n\nexport default routes;\n","import path from 'node:path';\n\nimport type { DoomApi, DoomApiContext } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { MAX_CONTENT_BYTES, MAX_PREVIEW_BYTES } from '../../constants/artifacts';\nimport routes from '../../types/apiRoutes';\nimport type { ArtifactPreview } from '../../types/artifacts';\nimport { ArtifactAccessError, artifactRoot, listArtifacts, openArtifact, readArtifactBytes } from '../artifactFiles';\n\nexport function createArtifactsApi(root: string): Hono {\n const app = new Hono();\n app.onError((error, context) =>\n context.json(\n { error: error instanceof ArtifactAccessError ? error.message : 'The artifact could not be read.' },\n error instanceof ArtifactAccessError ? error.status : 500,\n ),\n );\n app.get(routes.list.path, async (context) => {\n const snapshot = await listArtifacts(root);\n return context.json(snapshot, snapshot.error === undefined ? 200 : 500);\n });\n app.get(routes.preview.path, async (context) => {\n const file = await openArtifact(root, context.req.query('path'));\n try {\n const preview: ArtifactPreview = { path: file.path, content: '', mimeType: file.mimeType };\n if (file.stat.size > MAX_PREVIEW_BYTES) {\n return context.json({\n ...preview,\n unavailable: true,\n reason: 'This artifact is too large for a text preview.',\n });\n }\n const bytes = await readArtifactBytes(file.handle, MAX_PREVIEW_BYTES + 1);\n if (bytes.byteLength > MAX_PREVIEW_BYTES)\n return context.json({\n ...preview,\n unavailable: true,\n reason: 'This artifact is too large for a text preview.',\n });\n if (bytes.subarray(0, 8192).includes(0))\n return context.json({ ...preview, unavailable: true, reason: 'This artifact is binary.' });\n return context.json({ ...preview, content: new TextDecoder().decode(bytes) });\n } finally {\n await file.handle.close();\n }\n });\n app.get(routes.content.path, async (context) => {\n const file = await openArtifact(root, context.req.query('path'));\n try {\n if (file.stat.size > MAX_CONTENT_BYTES)\n throw new ArtifactAccessError('This artifact is too large to download.', 413);\n const version = `\"${file.stat.dev}-${file.stat.ino}-${file.stat.size}-${file.stat.mtimeMs}-${file.stat.ctimeMs}\"`;\n const name = encodeURIComponent(path.basename(file.path)).replace(\n /[!'()*]/gu,\n (value) => `%${value.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n const headers = new Headers({\n 'content-type': file.mimeType,\n 'content-disposition': `attachment; filename*=UTF-8''${name}`,\n 'cache-control': 'no-store',\n 'x-content-type-options': 'nosniff',\n 'content-security-policy': \"default-src 'none'; sandbox\",\n 'accept-ranges': 'bytes',\n etag: version,\n });\n const expectedVersion = context.req.header('if-match');\n if (expectedVersion !== undefined && expectedVersion !== version)\n return new Response(null, { status: 412, headers });\n let start = 0;\n let end = file.stat.size - 1;\n const range = context.req.header('range');\n if (range !== undefined) {\n const match = /^bytes=(\\d*)-(\\d*)$/u.exec(range);\n if (\n !match ||\n (!match[1] && !match[2]) ||\n file.stat.size === 0 ||\n [match[1], match[2]].some((value) => value !== '' && !Number.isSafeInteger(Number(value)))\n ) {\n headers.set('content-range', `bytes */${file.stat.size}`);\n return new Response(null, { status: 416, headers });\n }\n if (match[1] === '') {\n const suffix = Number(match[2]);\n start = suffix > 0 ? Math.max(0, file.stat.size - suffix) : file.stat.size;\n } else {\n start = Number(match[1]);\n end = match[2] === '' ? end : Math.min(end, Number(match[2]));\n }\n if (start > end || start >= file.stat.size) {\n headers.set('content-range', `bytes */${file.stat.size}`);\n return new Response(null, { status: 416, headers });\n }\n headers.set('content-range', `bytes ${start}-${end}/${file.stat.size}`);\n }\n const bytes = await readArtifactBytes(file.handle, Math.max(0, end - start + 1), start);\n const after = await file.handle.stat();\n if (after.size !== file.stat.size || after.mtimeMs !== file.stat.mtimeMs || after.ctimeMs !== file.stat.ctimeMs)\n return new Response(null, { status: 412, headers });\n headers.set('content-length', String(bytes.byteLength));\n return new Response(bytes, { status: range === undefined ? 200 : 206, headers });\n } finally {\n await file.handle.close();\n }\n });\n return app;\n}\n\nexport const api: DoomApi = {\n basePath: 'artifacts',\n start(context: DoomApiContext) {\n if (!context.sessionId) throw new Error('Artifacts requires a session identity.');\n const app = createArtifactsApi(artifactRoot(context.sessionId, context.environment ?? {}));\n return { fetch: (request) => app.fetch(request), close: () => undefined };\n },\n};\n","import { defineRoute } from '@agimon-ai/po-core/extensionFile';\n\nimport { api } from '../../../../../../services/artifactsApi';\n\nexport default defineRoute(api);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport type { ArtifactServerScope } from '../_lib/serverRoot';\n\nexport default defineHook(\n (context: WithRoot<DoomServerPluginContext, ArtifactServerScope>) => context.root.beforeAgentStart,\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport type { ArtifactServerScope } from '../_lib/serverRoot';\n\nexport default defineHook(\n (context: WithRoot<DoomServerPluginContext, ArtifactServerScope>) => context.root.toolExecutionEnd,\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelArtifacts from '../src/extensions/(backend)/channel/artifacts.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/artifacts/route.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookToolExecutionEnd from '../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-artifact',\n providerOverrides: composeServerProviderOverrides(rootSession),\n global: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'artifacts' }, channelArtifacts())]; },\n }),\n workspace: () => ({\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'artifacts' }, channelArtifacts())]; },\n }),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'artifacts' }, channelArtifacts())]; },\n get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'tool_execution_end' }, at(hookToolExecutionEnd, contextSession))]; },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,uBAAuB;;;;;;;ACRpC,eAAe,oBAAoB,MAAgC;CACjE,IAAI;EACF,MAAMA,sBAAAA,mBAAmB,IAAI;EAC7B,OAAO;CACT,SAAS,OAAO;EACd,IAAI,iBAAiBC,sBAAAA,uBAAuB,MAAM,WAAW,KAAK,OAAO;EACzE,MAAM;CACR;AACF;AAEA,SAAgB,sBAAsB,EAAE,QAAiC;CACvE,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,KAAK,QAAQ,YAAY,CAAC;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,SAAS;CAEb,MAAM,gBAA+B;EACnC,IAAI,SAAS,OAAO;EACpB,MAAM,UAAU;EAChB,IAAI,CAAC,WAAW,QAAQ,OAAO,QAAQ,QAAQ;EAC/C,WAAW,YAAY;GACrB,MAAM,WAAW,MAAMC,sBAAAA,cAAc,QAAQ,IAAI;GACjD,IAAI,UAAU,WAAW,SAAS;GAClC,MAAM,cAAc,KAAK,UAAU,QAAQ;GAC3C,IAAI,gBAAgB,QAAQ,aAAa;GACzC,QAAQ,cAAc;GACtB,KAAK,QAAQ,cAAc,QAAQ,sBAAsB,QAAQ,QAAQ,WAAW,QAAQ;EAC9F,EAAA,CAAG,CAAC,CAAC,cAAc;GACjB,UAAU,KAAA;EACZ,CAAC;EACD,OAAO;CACT;CACA,MAAM,iBAAuB;EAC3B,IAAI,CAAC,UAAU,QAAQ;EACvB,SAAA,GAAQC,Y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AE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,SAAA,GAAQC,+BAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,oBAAA,GAAmBC,+BAAAA,+BAAAA,CAA+BC,mBAAW;CAC7D,eAAe,EACb,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,YAAY,GAAGC,yBAAiB,CAAC,CAAC;CAAG,EAC5H;CACA,kBAAkB,EAChB,IAAI,WAAgD;EAAE,OAAO,OAAO,IAAI,EAAE,WAAW,YAAY,GAAGA,yBAAiB,CAAC,CAAC;CAAG,EAC5H;CACA,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMD,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,MAAsC;IAAE,OAAO,CAAC,GAAGC,sBAAU,cAAc,CAAC;GAAG;GACnF,IAAI,WAAgD;IAAE,OAAO,OAAO,IAAI,EAAE,WAAW,YAAY,GAAGF,yBAAiB,CAAC,CAAC;GAAG;GAC1H,IAAI,QAA0C;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGG,mCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,mCAAsB,cAAc,CAAC,CAAC;GAAG;GACzN,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["artifactRoot","ensureArtifactRoot","ArtifactAccessError","listArtifactSessions","Service","ARTIFACTS_SERVICE","defineRoot","ensureArtifactRoot","ArtifactAccessError","listArtifacts","setTimeout","ARTIFACT_REFRESH_MS","artifactRoot","defineRoot","listArtifacts","artifactRoot","defineChannel","Hono","ArtifactAccessError","listArtifacts","openArtifact","readArtifactBytes","MAX_PREVIEW_BYTES","path","artifactRoot","defineRoute","defineHook","defineHook","defineServerPlugin","composeServerProviderOverrides","rootGlobal","rootSession","composeRootInjects","composeRootHooks","channelArtifacts","apiRoute","hookBeforeAgentStart","hookToolExecutionEnd"],"sources":["../../src/services/artifacts/index.ts","../../src/extensions/(backend)/root.server.ts","../../src/types/artifacts.ts","../../src/services/artifactSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/serverRoot.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/artifactChannel/index.ts","../../src/extensions/(backend)/channel/artifacts.server.ts","../../src/types/apiRoutes.ts","../../src/services/artifactsApi/index.ts","../../src/extensions/workspaces/sessions/(backend)/api/artifacts/route.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.ts","../../generated/server.ts"],"sourcesContent":["import { type Context, Service } from '@deepseek-ai/cordis';\n\nimport { ARTIFACTS_SERVICE } from '../../constants/artifacts';\nimport type { ArtifactWorkflowVisibility } from '../../types/artifacts';\nimport { ArtifactAccessError, artifactRoot, ensureArtifactRoot, listArtifactSessions } from '../artifactFiles';\nimport type { ArtifactStorage } from './type';\n\n/** Roots come only from admitted host configuration, never a file request. */\nexport function createArtifactStorage(environment: Readonly<Record<string, string | undefined>>): ArtifactStorage {\n const policies = new Map<symbol, ArtifactWorkflowVisibility>();\n return {\n async rootForSession(sessionId, admittedEnvironment = environment) {\n const root = artifactRoot(sessionId, admittedEnvironment);\n try {\n await ensureArtifactRoot(root);\n return root;\n } catch (error) {\n if (error instanceof ArtifactAccessError && error.status === 404) return undefined;\n throw error;\n }\n },\n sessions: (admittedEnvironment = environment) => listArtifactSessions(admittedEnvironment),\n registerWorkflowVisibility(policy) {\n const owner = Symbol('workflow visibility');\n policies.set(owner, policy);\n return () => {\n policies.delete(owner);\n };\n },\n workflowVisible: (relativePath, kind) =>\n policies.size > 0 && [...policies.values()].every((policy) => policy(relativePath, kind)),\n };\n}\n\n/** Publish the same storage instance used by this scope's artifact reader. */\nexport class ArtifactsService extends Service implements ArtifactStorage {\n constructor(\n context: Context,\n private readonly storage: ArtifactStorage,\n ) {\n super(context, ARTIFACTS_SERVICE);\n }\n rootForSession(sessionId: string, environment?: Readonly<Record<string, string | undefined>>) {\n return this.storage.rootForSession(sessionId, environment);\n }\n sessions(environment?: Readonly<Record<string, string | undefined>>) {\n return this.storage.sessions(environment);\n }\n registerWorkflowVisibility(policy: ArtifactWorkflowVisibility) {\n return this.storage.registerWorkflowVisibility(policy);\n }\n workflowVisible(relativePath: string, kind: 'file' | 'directory') {\n return this.storage.workflowVisible(relativePath, kind);\n }\n}\n\nexport function createArtifactsPlugin(storage: ArtifactStorage): (context: Context) => void {\n return (context) => {\n new ArtifactsService(context, storage);\n };\n}\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n 'po/artifacts': ArtifactsService;\n }\n}\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createArtifactStorage, createArtifactsPlugin } from '../../services/artifacts';\n\nexport default defineRoot(({ host }: PoServerPluginContext) => {\n const storage = createArtifactStorage(Object.freeze({ ...host.context.environment }));\n return { value: storage, services: [createArtifactsPlugin(storage)] };\n});\n","export type ArtifactScope = 'artifacts' | 'temporary';\n\n/** Workflow owns the visibility of its reserved artifact subtree. */\nexport type ArtifactWorkflowVisibility = (relativePath: string, kind: 'file' | 'directory') => boolean;\n\nexport interface ArtifactItem {\n /** Relative to the current session's artifact directory. */\n path: string;\n name: string;\n size: number;\n modifiedAt: number;\n}\n\nexport interface ArtifactSnapshot {\n items: ArtifactItem[];\n /** Host-admitted root used only to recognize session temporary-file references. */\n temporaryRoot?: string;\n error?: string;\n}\n\nexport interface ArtifactPreview {\n path: string;\n content: string;\n mimeType: string;\n unavailable?: boolean;\n reason?: string;\n}\n\nexport const artifactsChannelType = 'artifacts';\n","import { clearTimeout, setTimeout } from 'node:timers';\n\nimport type { PoHeadlessActivity, PoHeadlessExecutionContext, PoHeadlessHook } from '@agimon-ai/po-core/headless';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { ARTIFACT_REFRESH_MS } from '../../constants/artifacts';\nimport { artifactsChannelType } from '../../types/artifacts';\nimport { ArtifactAccessError, artifactRoot, ensureArtifactRoot, listArtifacts } from '../artifactFiles';\nimport { createArtifactStorage } from '../artifacts';\nimport type { ArtifactStorage } from '../artifacts/type';\n\n/**\n * Creates the session artifact folder. Resolves false when the host has no artifact folder\n * (the edge build in M1 rejects with a 404); Node never rejects with that status here.\n */\nasync function prepareArtifactRoot(root: string): Promise<boolean> {\n try {\n await ensureArtifactRoot(root);\n return true;\n } catch (error) {\n if (error instanceof ArtifactAccessError && error.status === 404) return false;\n throw error;\n }\n}\n\nexport function createArtifactSession({ host }: PoServerPluginContext, storage?: ArtifactStorage) {\n const environment = Object.freeze({ ...host.context.environment });\n const artifactStorage = storage ?? createArtifactStorage(environment);\n let active: { context: PoHeadlessExecutionContext; root: string; fingerprint?: string } | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let pending: Promise<void> | undefined;\n let closed = false;\n\n const refresh = (): Promise<void> => {\n if (pending) return pending;\n const runtime = active;\n if (!runtime || closed) return Promise.resolve();\n pending = (async () => {\n const snapshot = {\n ...(await listArtifacts(runtime.root, artifactStorage.workflowVisible)),\n ...(environment.PO_SESSION_TEMP_DIR ? { temporaryRoot: environment.PO_SESSION_TEMP_DIR } : {}),\n };\n if (closed || active !== runtime) return;\n const fingerprint = JSON.stringify(snapshot);\n if (fingerprint === runtime.fingerprint) return;\n runtime.fingerprint = fingerprint;\n host.context.directEvents?.publish(artifactsChannelType, runtime.context.sessionId, snapshot);\n })().finally(() => {\n pending = undefined;\n });\n return pending;\n };\n const schedule = (): void => {\n if (!active || closed) return;\n timer = setTimeout(() => {\n timer = undefined;\n void refresh().finally(schedule);\n }, ARTIFACT_REFRESH_MS);\n };\n const stop = async (): Promise<void> => {\n active = undefined;\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n await pending;\n };\n const activity: PoHeadlessActivity = {\n name: 'artifacts',\n async start(context) {\n if (closed) throw new Error('Artifact session is closed.');\n await stop();\n const root = artifactRoot(context.sessionId, environment);\n if (!(await prepareArtifactRoot(root))) return stop;\n if (closed) throw new Error('Artifact session is closed.');\n active = { context, root };\n await refresh();\n schedule();\n return stop;\n },\n };\n const beforeAgentStart: PoHeadlessHook = {\n event: 'before_agent_start',\n async handle(event, context) {\n const root = artifactRoot(context.sessionId, environment);\n const systemPrompt = typeof event.systemPrompt === 'string' ? event.systemPrompt : '';\n if (!(await prepareArtifactRoot(root))) return { systemPrompt };\n const declaration = `Session artifact folder: ${root}`;\n if (systemPrompt.includes(declaration)) return { systemPrompt };\n return {\n systemPrompt:\n `${systemPrompt}\\n\\n${declaration}\\nSave user-designated artifacts and important deliverable documents in this folder, using descriptive filenames. Keep ordinary repository source edits in their existing locations. Do not move existing documents or overwrite artifacts without the user's intent. This folder belongs only to the current session.`.trim(),\n };\n },\n };\n const toolExecutionEnd: PoHeadlessHook = {\n event: 'tool_execution_end',\n handle(_event, context) {\n return active?.context.sessionId === context.sessionId ? refresh() : undefined;\n },\n };\n return {\n activities: [activity],\n beforeAgentStart,\n toolExecutionEnd,\n onDispose: async () => {\n closed = true;\n await stop();\n },\n };\n}\n","import type { WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ArtifactStorage } from '../../../../../services/artifacts/type';\nimport { createArtifactSession } from '../../../../../services/artifactSession';\n\nexport const createArtifactServerRoot = (context: WithRoot<PoServerPluginContext, ArtifactStorage>) => {\n const storage = context.root;\n const runtime = createArtifactSession(context, storage);\n return { value: { ...runtime, storage }, activities: runtime.activities, onDispose: runtime.onDispose };\n};\nexport type ArtifactServerScope = ReturnType<typeof createArtifactServerRoot>['value'];\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\n\nimport { createArtifactServerRoot } from './_lib/serverRoot';\n\nexport default defineRoot(createArtifactServerRoot);\n","import type { PoHubChannel } from '@agimon-ai/po-core/hubChannel';\n\nimport { artifactsChannelType, type ArtifactSnapshot } from '../../types/artifacts';\nimport { artifactRoot, listArtifacts } from '../artifactFiles';\n\nfunction snapshotOf(value: unknown): value is ArtifactSnapshot {\n if (typeof value !== 'object' || value === null) return false;\n const snapshot = value as Partial<ArtifactSnapshot>;\n return (\n Array.isArray(snapshot.items) &&\n (snapshot.error === undefined || typeof snapshot.error === 'string') &&\n (snapshot.temporaryRoot === undefined || typeof snapshot.temporaryRoot === 'string') &&\n snapshot.items.every(\n (item) =>\n typeof item === 'object' &&\n item !== null &&\n typeof item.path === 'string' &&\n typeof item.name === 'string' &&\n typeof item.size === 'number' &&\n Number.isFinite(item.size) &&\n typeof item.modifiedAt === 'number' &&\n Number.isFinite(item.modifiedAt),\n )\n );\n}\n\nexport function createArtifactsChannel(): PoHubChannel {\n return {\n frameType: artifactsChannelType,\n start(host) {\n const sessions = new Map<string, { snapshot?: ArtifactSnapshot; unsubscribe: () => void }>();\n return {\n payloadFor(scope) {\n return sessions.get(scope.sessionId)?.snapshot;\n },\n sessionAdded(scope) {\n sessions.get(scope.sessionId)?.unsubscribe();\n const state: { snapshot?: ArtifactSnapshot; unsubscribe: () => void } = { unsubscribe: () => undefined };\n sessions.set(scope.sessionId, state);\n state.unsubscribe = host.directEvents.subscribe(\n artifactsChannelType,\n scope.sessionId,\n (snapshot) => {\n if (!snapshotOf(snapshot) || sessions.get(scope.sessionId) !== state) return;\n state.snapshot = snapshot;\n host.publish(scope.sessionId, snapshot);\n },\n { replayLatest: true },\n );\n void (async () => {\n let snapshot: ArtifactSnapshot;\n try {\n snapshot = {\n ...(await listArtifacts(artifactRoot(scope.sessionId, scope.environment ?? {}))),\n ...(scope.environment?.PO_SESSION_TEMP_DIR\n ? { temporaryRoot: scope.environment.PO_SESSION_TEMP_DIR }\n : {}),\n };\n } catch (error) {\n snapshot = {\n items: [],\n error: error instanceof Error ? error.message : 'The artifact folder could not be read.',\n };\n }\n // A live session event wins over the earlier seed read.\n if (sessions.get(scope.sessionId) !== state || state.snapshot !== undefined) return;\n state.snapshot = snapshot;\n host.publish(scope.sessionId, snapshot);\n })();\n },\n sessionRemoved(sessionId) {\n sessions.get(sessionId)?.unsubscribe();\n sessions.delete(sessionId);\n },\n close() {\n for (const state of sessions.values()) state.unsubscribe();\n sessions.clear();\n },\n };\n },\n };\n}\n","import { defineChannel } from '@agimon-ai/po-core/extensionFile';\n\nimport { createArtifactsChannel } from '../../../services/artifactChannel';\n\nexport default defineChannel(createArtifactsChannel);\n","import type { ApiResponseOf, ApiRoutes } from '@agimon-ai/po-core/web';\n\nimport type { ArtifactPreview, ArtifactSnapshot } from './artifacts';\n\nconst routes = {\n list: {\n method: 'GET',\n path: '/',\n query: ['scope'],\n response: undefined as unknown as ApiResponseOf<ArtifactSnapshot>,\n },\n preview: {\n method: 'GET',\n path: '/preview',\n query: ['path', 'scope'],\n response: undefined as unknown as ApiResponseOf<ArtifactPreview>,\n },\n content: {\n method: 'GET',\n path: '/content',\n query: ['path', 'scope'],\n raw: true,\n },\n} as const satisfies ApiRoutes;\n\nexport default routes;\n","import path from 'node:path';\n\nimport type { PoApi, PoApiContext } from '@agimon-ai/po-core/packageApi';\nimport { Hono } from 'hono';\n\nimport { MAX_CONTENT_BYTES, MAX_PREVIEW_BYTES } from '../../constants/artifacts';\nimport routes from '../../types/apiRoutes';\nimport type { ArtifactPreview, ArtifactWorkflowVisibility } from '../../types/artifacts';\nimport { ArtifactAccessError, artifactRoot, listArtifacts, openArtifact, readArtifactBytes } from '../artifactFiles';\nimport type { ArtifactStorage } from '../artifacts/type';\n\nexport function createArtifactsApi(\n root: string,\n options: { temporaryRoot?: string; workflowVisible?: ArtifactWorkflowVisibility } = {},\n): Hono {\n const app = new Hono();\n const selectedRoot = (scope: string | undefined): string => {\n if (scope === undefined || scope === 'artifacts') return root;\n if (scope !== 'temporary') throw new ArtifactAccessError('Invalid file scope.', 400);\n if (!options.temporaryRoot) throw new ArtifactAccessError('Temporary files are unavailable for this session.', 404);\n return options.temporaryRoot;\n };\n app.onError((error, context) =>\n context.json(\n { error: error instanceof ArtifactAccessError ? error.message : 'The artifact could not be read.' },\n error instanceof ArtifactAccessError ? error.status : 500,\n ),\n );\n app.get(routes.list.path, async (context) => {\n const selected = selectedRoot(context.req.query('scope'));\n const snapshot = await listArtifacts(selected, selected === root ? options.workflowVisible : () => true);\n return context.json(\n { ...snapshot, ...(options.temporaryRoot ? { temporaryRoot: options.temporaryRoot } : {}) },\n snapshot.error === undefined ? 200 : 500,\n );\n });\n app.get(routes.preview.path, async (context) => {\n const selected = selectedRoot(context.req.query('scope'));\n const file = await openArtifact(\n selected,\n context.req.query('path'),\n selected === root ? options.workflowVisible : () => true,\n );\n try {\n const preview: ArtifactPreview = { path: file.path, content: '', mimeType: file.mimeType };\n if (file.stat.size > MAX_PREVIEW_BYTES) {\n return context.json({\n ...preview,\n unavailable: true,\n reason: 'This artifact is too large for a text preview.',\n });\n }\n const bytes = await readArtifactBytes(file.handle, MAX_PREVIEW_BYTES + 1);\n if (bytes.byteLength > MAX_PREVIEW_BYTES)\n return context.json({\n ...preview,\n unavailable: true,\n reason: 'This artifact is too large for a text preview.',\n });\n if (bytes.subarray(0, 8192).includes(0))\n return context.json({ ...preview, unavailable: true, reason: 'This artifact is binary.' });\n return context.json({ ...preview, content: new TextDecoder().decode(bytes) });\n } finally {\n await file.handle.close();\n }\n });\n app.get(routes.content.path, async (context) => {\n const selected = selectedRoot(context.req.query('scope'));\n const file = await openArtifact(\n selected,\n context.req.query('path'),\n selected === root ? options.workflowVisible : () => true,\n );\n try {\n if (file.stat.size > MAX_CONTENT_BYTES)\n throw new ArtifactAccessError('This artifact is too large to download.', 413);\n const version = `\"${file.stat.dev}-${file.stat.ino}-${file.stat.size}-${file.stat.mtimeMs}-${file.stat.ctimeMs}\"`;\n const name = encodeURIComponent(path.basename(file.path)).replace(\n /[!'()*]/gu,\n (value) => `%${value.charCodeAt(0).toString(16).toUpperCase()}`,\n );\n const headers = new Headers({\n 'content-type': file.mimeType,\n 'content-disposition': `attachment; filename*=UTF-8''${name}`,\n 'cache-control': 'no-store',\n 'x-content-type-options': 'nosniff',\n 'content-security-policy': \"default-src 'none'; sandbox\",\n 'accept-ranges': 'bytes',\n etag: version,\n });\n const expectedVersion = context.req.header('if-match');\n if (expectedVersion !== undefined && expectedVersion !== version)\n return new Response(null, { status: 412, headers });\n let start = 0;\n let end = file.stat.size - 1;\n const range = context.req.header('range');\n if (range !== undefined) {\n const match = /^bytes=(\\d*)-(\\d*)$/u.exec(range);\n if (\n !match ||\n (!match[1] && !match[2]) ||\n file.stat.size === 0 ||\n [match[1], match[2]].some((value) => value !== '' && !Number.isSafeInteger(Number(value)))\n ) {\n headers.set('content-range', `bytes */${file.stat.size}`);\n return new Response(null, { status: 416, headers });\n }\n if (match[1] === '') {\n const suffix = Number(match[2]);\n start = suffix > 0 ? Math.max(0, file.stat.size - suffix) : file.stat.size;\n } else {\n start = Number(match[1]);\n end = match[2] === '' ? end : Math.min(end, Number(match[2]));\n }\n if (start > end || start >= file.stat.size) {\n headers.set('content-range', `bytes */${file.stat.size}`);\n return new Response(null, { status: 416, headers });\n }\n headers.set('content-range', `bytes ${start}-${end}/${file.stat.size}`);\n }\n const bytes = await readArtifactBytes(file.handle, Math.max(0, end - start + 1), start);\n const after = await file.handle.stat();\n if (after.size !== file.stat.size || after.mtimeMs !== file.stat.mtimeMs || after.ctimeMs !== file.stat.ctimeMs)\n return new Response(null, { status: 412, headers });\n headers.set('content-length', String(bytes.byteLength));\n return new Response(bytes, { status: range === undefined ? 200 : 206, headers });\n } finally {\n await file.handle.close();\n }\n });\n return app;\n}\n\nexport function createArtifactApi(storage?: ArtifactStorage): PoApi {\n return {\n basePath: 'artifacts',\n start(context: PoApiContext) {\n if (!context.sessionId) throw new Error('Artifacts requires a session identity.');\n const app = createArtifactsApi(artifactRoot(context.sessionId, context.environment ?? {}), {\n temporaryRoot: context.environment?.PO_SESSION_TEMP_DIR,\n workflowVisible: storage?.workflowVisible,\n });\n return { fetch: (request) => app.fetch(request), close: () => undefined };\n },\n };\n}\n\nexport const api: PoApi = createArtifactApi();\n","import { defineRoute, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport { createArtifactApi } from '../../../../../../services/artifactsApi';\nimport type { ArtifactServerScope } from '../../_lib/serverRoot';\n\nexport default defineRoute(({ root }: WithRoot<PoServerPluginContext, ArtifactServerScope>) =>\n createArtifactApi(root.storage),\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ArtifactServerScope } from '../_lib/serverRoot';\n\nexport default defineHook(\n (context: WithRoot<PoServerPluginContext, ArtifactServerScope>) => context.root.beforeAgentStart,\n);\n","import { defineHook, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverPlugin';\n\nimport type { ArtifactServerScope } from '../_lib/serverRoot';\n\nexport default defineHook(\n (context: WithRoot<PoServerPluginContext, ArtifactServerScope>) => context.root.toolExecutionEnd,\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverPlugin';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\nimport { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\n\nimport rootGlobal from '../src/extensions/(backend)/root.server';\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport channelArtifacts from '../src/extensions/(backend)/channel/artifacts.server';\nimport apiRoute from '../src/extensions/workspaces/sessions/(backend)/api/artifacts/route.server';\nimport hookBeforeAgentStart from '../src/extensions/workspaces/sessions/(backend)/hook/before-agent-start.server';\nimport hookToolExecutionEnd from '../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const serverPlugin = defineServerPlugin({\n name: '@agimon-ai/po-artifact',\n providerOverrides: composeServerProviderOverrides(rootGlobal, rootSession),\n injects: composeRootInjects({ global: [rootGlobal], workspace: [rootGlobal], session: [rootGlobal, rootSession] }),\n global: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n get channels(): PoServerSessionPlugin['channels'] { return [() => via({ frameType: 'artifacts' }, channelArtifacts())]; },\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n workspace: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n return {\n ...composeRootHooks(scopeGlobal),\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'artifacts' }, channelArtifacts())]); },\n services: [...(scopeGlobal.services ?? [])],\n };\n },\n session: async (context) => {\n const scopeGlobal = await context.scopeRoot('global', rootGlobal, context);\n const contextGlobal = { ...context, root: scopeGlobal.value };\n const scopeSession = await context.scopeRoot('session', rootSession, contextGlobal);\n const contextSession = { ...contextGlobal, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeGlobal, scopeSession),\n get api(): PoServerSessionPlugin['api'] { return [at(apiRoute, contextSession)]; },\n get channels(): PoServerSessionPlugin['channels'] { return defined([context.hosted('global') ? undefined : () => via({ frameType: 'artifacts' }, channelArtifacts())]); },\n get hooks(): PoServerSessionPlugin['hooks'] { return [via({ event: 'before_agent_start' }, at(hookBeforeAgentStart, contextSession)), via({ event: 'tool_execution_end' }, at(hookToolExecutionEnd, contextSession))]; },\n services: [...(scopeGlobal.services ?? []), ...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeGlobal.activities ?? []), ...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default serverPlugin;\n"],"mappings":";;;;;;;;;;;;;;;AAQA,SAAgB,sBAAsB,aAA4E;CAChH,MAAM,2BAAW,IAAI,IAAwC;CAC7D,OAAO;EACL,MAAM,eAAe,WAAW,sBAAsB,aAAa;GACjE,MAAM,OAAOA,sBAAAA,aAAa,WAAW,mBAAmB;GACxD,IAAI;IACF,MAAMC,sBAAAA,mBAAmB,IAAI;IAC7B,OAAO;GACT,SAAS,OAAO;IACd,IAAI,iBAAiBC,sBAAAA,uBAAuB,MAAM,WAAW,KAAK,OAAO,KAAA;IACzE,MAAM;GACR;EACF;EACA,WAAW,sBAAsB,gBAAgBC,sBAAAA,qBAAqB,mBAAmB;EACzF,2BAA2B,QAAQ;GACjC,MAAM,QAAQ,OAAO,qBAAqB;GAC1C,SAAS,IAAI,OAAO,MAAM;GAC1B,aAAa;IACX,SAAS,OAAO,KAAK;GACvB;EACF;EACA,kBAAkB,cAAc,SAC9B,SAAS,OAAO,KAAK,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,OAAO,WAAW,OAAO,cAAc,IAAI,CAAC;CAC5F;AACF;;AAGA,IAAa,mBAAb,cAAsCC,oBAAAA,QAAmC;CAGpD;CAFnB,YACE,SACA,SACA;EACA,MAAM,SAASC,kBAAAA,iBAAiB;EAFf,KAAA,UAAA;CAGnB;CACA,eAAe,WAAmB,aAA4D;EAC5F,OAAO,KAAK,QAAQ,eAAe,WAAW,WAAW;CAC3D;CACA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YAAY;EAAM;EAC5D,MAAM,eAAe,MAAM,QAAQ,UAAU,WAAWC,qBAAa,aAAa;EAClF,MAAM,iBAAiB;GAAE,GAAG;GAAe,MAAM,aAAa;EAAM;EACpE,OAAO;GACL,IAAA,GAAGE,iCAAAA,iBAAAA,CAAiB,aAAa,YAAY;GAC7C,IAAI,MAAoC;IAAE,OAAO,CAAC,GAAGE,sBAAU,cAAc,CAAC;GAAG;GACjF,IAAI,WAA8C;IAAE,OAAO,QAAQ,CAAC,QAAQ,OAAO,QAAQ,IAAI,KAAA,UAAkB,IAAI,EAAE,WAAW,YAAY,GAAGD,yBAAiB,CAAC,CAAC,CAAC;GAAG;GACxK,IAAI,QAAwC;IAAE,OAAO,CAAC,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGE,mCAAsB,cAAc,CAAC,GAAG,IAAI,EAAE,OAAO,qBAAqB,GAAG,GAAGC,mCAAsB,cAAc,CAAC,CAAC;GAAG;GACvN,UAAU,CAAC,GAAI,YAAY,YAAY,CAAC,GAAI,GAAI,aAAa,YAAY,CAAC,CAAE;GAC5E,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,YAAY,cAAc,CAAC,GAAI,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EAC1I;CACF;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region generated/server.d.ts
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const serverPlugin: import("@agimon-ai/po-core/serverPlugin").PoServerPlugin;
|
|
3
3
|
//#endregion
|
|
4
|
-
export {
|
|
4
|
+
export { serverPlugin as default };
|
|
5
5
|
//# sourceMappingURL=server.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../../generated/server.ts"],"mappings":";qBAqBa,wDAAY"}
|