@alisio/core 0.1.0-alpha.9 → 0.1.1

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.
Files changed (187) hide show
  1. package/README.md +52 -7
  2. package/dist/agents/active.d.ts +99 -0
  3. package/dist/agents/active.js +218 -0
  4. package/dist/agents/capabilities.d.ts +26 -0
  5. package/dist/agents/capabilities.js +120 -0
  6. package/dist/agents/create-agent-skill.d.ts +11 -0
  7. package/dist/agents/create-agent-skill.js +60 -0
  8. package/dist/agents/definitions.d.ts +88 -0
  9. package/dist/agents/definitions.js +404 -0
  10. package/dist/agents/draft.d.ts +41 -0
  11. package/dist/agents/draft.js +133 -0
  12. package/dist/agents/service.d.ts +57 -0
  13. package/dist/agents/service.js +86 -0
  14. package/dist/agents/templates.d.ts +8 -0
  15. package/dist/agents/templates.js +102 -0
  16. package/dist/analysis/capabilities.d.ts +48 -0
  17. package/dist/analysis/capabilities.js +90 -0
  18. package/dist/analysis/data/csv.d.ts +46 -0
  19. package/dist/analysis/data/csv.js +240 -0
  20. package/dist/analysis/data/datasets.d.ts +132 -0
  21. package/dist/analysis/data/datasets.js +441 -0
  22. package/dist/analysis/data/describe.d.ts +27 -0
  23. package/dist/analysis/data/describe.js +103 -0
  24. package/dist/analysis/data/engine-client.d.ts +58 -0
  25. package/dist/analysis/data/engine-client.js +304 -0
  26. package/dist/analysis/data/engine-entry.d.ts +1 -0
  27. package/dist/analysis/data/engine-entry.js +59 -0
  28. package/dist/analysis/data/engine-source.d.ts +4 -0
  29. package/dist/analysis/data/engine-source.js +6 -0
  30. package/dist/analysis/data/engine-types.d.ts +86 -0
  31. package/dist/analysis/data/engine-types.js +7 -0
  32. package/dist/analysis/data/infer.d.ts +42 -0
  33. package/dist/analysis/data/infer.js +118 -0
  34. package/dist/analysis/data/ingest-worker.d.ts +17 -0
  35. package/dist/analysis/data/ingest-worker.js +365 -0
  36. package/dist/analysis/data/json.d.ts +19 -0
  37. package/dist/analysis/data/json.js +44 -0
  38. package/dist/analysis/data/query-worker.d.ts +12 -0
  39. package/dist/analysis/data/query-worker.js +75 -0
  40. package/dist/analysis/data/rows.d.ts +39 -0
  41. package/dist/analysis/data/rows.js +120 -0
  42. package/dist/analysis/data/sql-guard.d.ts +20 -0
  43. package/dist/analysis/data/sql-guard.js +129 -0
  44. package/dist/analysis/data/stats.d.ts +18 -0
  45. package/dist/analysis/data/stats.js +77 -0
  46. package/dist/analysis/install-hints.d.ts +33 -0
  47. package/dist/analysis/install-hints.js +144 -0
  48. package/dist/analysis/janitor.d.ts +60 -0
  49. package/dist/analysis/janitor.js +264 -0
  50. package/dist/analysis/jobs.d.ts +94 -0
  51. package/dist/analysis/jobs.js +165 -0
  52. package/dist/analysis/oci.d.ts +129 -0
  53. package/dist/analysis/oci.js +330 -0
  54. package/dist/analysis/python/sources.d.ts +2 -0
  55. package/dist/analysis/python/sources.js +10 -0
  56. package/dist/analysis/requirements.d.ts +32 -0
  57. package/dist/analysis/requirements.js +73 -0
  58. package/dist/analysis/rerun.d.ts +40 -0
  59. package/dist/analysis/rerun.js +136 -0
  60. package/dist/analysis/runtime-manager.d.ts +146 -0
  61. package/dist/analysis/runtime-manager.js +472 -0
  62. package/dist/analysis/status.d.ts +21 -0
  63. package/dist/analysis/status.js +52 -0
  64. package/dist/application.d.ts +105 -3
  65. package/dist/application.js +446 -18
  66. package/dist/artifacts/kinds.d.ts +35 -0
  67. package/dist/artifacts/kinds.js +177 -0
  68. package/dist/artifacts/publisher.d.ts +7 -0
  69. package/dist/artifacts/publisher.js +29 -0
  70. package/dist/artifacts/store.d.ts +119 -0
  71. package/dist/artifacts/store.js +581 -0
  72. package/dist/background/janitor.d.ts +22 -0
  73. package/dist/background/janitor.js +62 -0
  74. package/dist/background/mirror.d.ts +14 -0
  75. package/dist/background/mirror.js +41 -0
  76. package/dist/background/notify.d.ts +58 -0
  77. package/dist/background/notify.js +172 -0
  78. package/dist/background/output.d.ts +46 -0
  79. package/dist/background/output.js +179 -0
  80. package/dist/background/service.d.ts +137 -0
  81. package/dist/background/service.js +410 -0
  82. package/dist/background/store.d.ts +103 -0
  83. package/dist/background/store.js +195 -0
  84. package/dist/changelog/data.d.ts +6 -0
  85. package/dist/changelog/data.js +306 -0
  86. package/dist/changelog/index.d.ts +5 -0
  87. package/dist/changelog/index.js +7 -0
  88. package/dist/changelog/parse.d.ts +53 -0
  89. package/dist/changelog/parse.js +160 -0
  90. package/dist/commands/builtins.d.ts +10 -0
  91. package/dist/commands/builtins.js +161 -0
  92. package/dist/commands/catalog.d.ts +86 -0
  93. package/dist/commands/catalog.js +304 -0
  94. package/dist/config.d.ts +206 -6
  95. package/dist/config.js +426 -20
  96. package/dist/core/compaction.js +13 -2
  97. package/dist/core/contracts.d.ts +180 -3
  98. package/dist/core/opt-in.d.ts +12 -0
  99. package/dist/core/opt-in.js +12 -0
  100. package/dist/core/output-limit.d.ts +34 -0
  101. package/dist/core/output-limit.js +39 -0
  102. package/dist/core/run-stats.d.ts +16 -0
  103. package/dist/core/run-stats.js +8 -0
  104. package/dist/core/runner.d.ts +134 -4
  105. package/dist/core/runner.js +780 -138
  106. package/dist/core/timeout.d.ts +15 -0
  107. package/dist/core/timeout.js +61 -0
  108. package/dist/core/truncation.d.ts +30 -0
  109. package/dist/core/truncation.js +83 -0
  110. package/dist/goal/blockers.d.ts +45 -0
  111. package/dist/goal/blockers.js +51 -0
  112. package/dist/goal/budget.d.ts +24 -0
  113. package/dist/goal/budget.js +53 -0
  114. package/dist/goal/command.d.ts +36 -0
  115. package/dist/goal/command.js +98 -0
  116. package/dist/goal/format.d.ts +19 -0
  117. package/dist/goal/format.js +102 -0
  118. package/dist/goal/host.d.ts +29 -0
  119. package/dist/goal/host.js +42 -0
  120. package/dist/goal/index.d.ts +9 -0
  121. package/dist/goal/index.js +9 -0
  122. package/dist/goal/machine.d.ts +186 -0
  123. package/dist/goal/machine.js +344 -0
  124. package/dist/goal/prompts.d.ts +10 -0
  125. package/dist/goal/prompts.js +75 -0
  126. package/dist/goal/service.d.ts +113 -0
  127. package/dist/goal/service.js +273 -0
  128. package/dist/goal/store.d.ts +59 -0
  129. package/dist/goal/store.js +184 -0
  130. package/dist/index.d.ts +50 -5
  131. package/dist/index.js +49 -4
  132. package/dist/mcp/connector.js +38 -6
  133. package/dist/mcp/rich.d.ts +41 -0
  134. package/dist/mcp/rich.js +362 -0
  135. package/dist/permissions/modes.d.ts +72 -0
  136. package/dist/permissions/modes.js +98 -0
  137. package/dist/plan/exit-plan.d.ts +25 -0
  138. package/dist/plan/exit-plan.js +130 -0
  139. package/dist/plan/state.d.ts +102 -0
  140. package/dist/plan/state.js +165 -0
  141. package/dist/plugins/host.d.ts +34 -1
  142. package/dist/plugins/host.js +143 -9
  143. package/dist/providers/settings.d.ts +15 -0
  144. package/dist/providers/settings.js +38 -0
  145. package/dist/reload.d.ts +75 -0
  146. package/dist/reload.js +204 -0
  147. package/dist/resources/context.js +6 -1
  148. package/dist/runtime/access.d.ts +62 -0
  149. package/dist/runtime/access.js +115 -0
  150. package/dist/runtime/blobs.d.ts +51 -0
  151. package/dist/runtime/blobs.js +177 -0
  152. package/dist/runtime/diff.d.ts +23 -0
  153. package/dist/runtime/diff.js +154 -0
  154. package/dist/runtime/ids.d.ts +8 -0
  155. package/dist/runtime/ids.js +32 -0
  156. package/dist/runtime/paths.d.ts +11 -0
  157. package/dist/runtime/paths.js +17 -1
  158. package/dist/runtime/process.d.ts +22 -0
  159. package/dist/runtime/process.js +100 -15
  160. package/dist/runtime/sqlite.d.ts +2 -0
  161. package/dist/runtime/sqlite.js +18 -0
  162. package/dist/runtime/store.d.ts +91 -3
  163. package/dist/runtime/store.js +465 -11
  164. package/dist/runtime/zip.d.ts +24 -0
  165. package/dist/runtime/zip.js +126 -0
  166. package/dist/sessions/children.js +17 -1
  167. package/dist/sessions/side-questions.d.ts +57 -0
  168. package/dist/sessions/side-questions.js +161 -0
  169. package/dist/tools/analysis.d.ts +37 -0
  170. package/dist/tools/analysis.js +573 -0
  171. package/dist/tools/artifacts.d.ts +14 -0
  172. package/dist/tools/artifacts.js +143 -0
  173. package/dist/tools/background.d.ts +7 -0
  174. package/dist/tools/background.js +165 -0
  175. package/dist/tools/data.d.ts +7 -0
  176. package/dist/tools/data.js +160 -0
  177. package/dist/tools/execute.d.ts +5 -0
  178. package/dist/tools/execute.js +15 -3
  179. package/dist/tools/goal.d.ts +19 -0
  180. package/dist/tools/goal.js +126 -0
  181. package/dist/tools/search.d.ts +17 -3
  182. package/dist/tools/search.js +153 -0
  183. package/dist/tools/standard.d.ts +4 -1
  184. package/dist/tools/standard.js +99 -18
  185. package/dist/version.d.ts +5 -3
  186. package/dist/version.js +35 -6
  187. package/package.json +2 -2
@@ -0,0 +1,177 @@
1
+ const MB = 1024 * 1024;
2
+ const TEXT_PREVIEW = 2 * MB;
3
+ /** Tables are read through paged queries, not loaded whole: the limit is the ingestion limit. */
4
+ const TABLE_PREVIEW = 200 * MB;
5
+ const UTF8 = "; charset=utf-8";
6
+ const OOXML = "application/vnd.openxmlformats-officedocument";
7
+ const text = (kind, mimeType, previewMax = TEXT_PREVIEW) => ({
8
+ kind,
9
+ mimeType,
10
+ magic: "text",
11
+ previewMax,
12
+ });
13
+ const RULES = {
14
+ html: text("dashboard", `text/html${UTF8}`, 20 * MB),
15
+ htm: text("dashboard", `text/html${UTF8}`, 20 * MB),
16
+ md: text("document", `text/markdown${UTF8}`),
17
+ markdown: text("document", `text/markdown${UTF8}`),
18
+ pdf: { kind: "document", mimeType: "application/pdf", magic: "pdf", previewMax: 50 * MB },
19
+ docx: { kind: "document", mimeType: `${OOXML}.wordprocessingml.document`, magic: "zip" },
20
+ pptx: { kind: "document", mimeType: `${OOXML}.presentationml.presentation`, magic: "zip" },
21
+ odt: { kind: "document", mimeType: "application/vnd.oasis.opendocument.text", magic: "zip" },
22
+ // Tables open in SpreadsheetView (phase 3): CSV/TSV may be windows-1252 or UTF-16, which the
23
+ // ingestion decodes, so their bytes only have to look like delimited text, not like UTF-8.
24
+ csv: {
25
+ kind: "spreadsheet",
26
+ mimeType: `text/csv${UTF8}`,
27
+ magic: "delimited",
28
+ previewMax: TABLE_PREVIEW,
29
+ },
30
+ tsv: {
31
+ kind: "spreadsheet",
32
+ mimeType: `text/tab-separated-values${UTF8}`,
33
+ magic: "delimited",
34
+ previewMax: TABLE_PREVIEW,
35
+ },
36
+ xlsx: {
37
+ kind: "spreadsheet",
38
+ mimeType: `${OOXML}.spreadsheetml.sheet`,
39
+ magic: "zip",
40
+ previewMax: TABLE_PREVIEW,
41
+ },
42
+ png: { kind: "image", mimeType: "image/png", magic: "png", previewMax: 20 * MB },
43
+ jpg: { kind: "image", mimeType: "image/jpeg", magic: "jpeg", previewMax: 20 * MB },
44
+ jpeg: { kind: "image", mimeType: "image/jpeg", magic: "jpeg", previewMax: 20 * MB },
45
+ gif: { kind: "image", mimeType: "image/gif", magic: "gif", previewMax: 20 * MB },
46
+ webp: { kind: "image", mimeType: "image/webp", magic: "webp", previewMax: 20 * MB },
47
+ svg: text("image", "image/svg+xml", 20 * MB),
48
+ json: text("data", "application/json"),
49
+ geojson: text("data", "application/json"),
50
+ zip: { kind: "archive", mimeType: "application/zip", magic: "zip" },
51
+ };
52
+ for (const ext of ["txt", "log", "sql", "yaml", "yml", "xml", "py", "js", "ts", "r"])
53
+ RULES[ext] = text("code", `text/plain${UTF8}`);
54
+ export const DOWNLOAD_ONLY = { kind: "file", mimeType: "application/octet-stream" };
55
+ /** Lower-case extension without the dot (`""` when none). */
56
+ export const extensionOf = (fileName) => {
57
+ const base = fileName.split(/[\\/]/).pop() ?? "";
58
+ const dot = base.lastIndexOf(".");
59
+ return dot > 0 ? base.slice(dot + 1).toLowerCase() : "";
60
+ };
61
+ const startsWith = (bytes, signature, at = 0) => bytes.length >= at + signature.length && signature.every((b, i) => bytes[at + i] === b);
62
+ /** Text: no NUL byte in the sampled head and the sample decodes as UTF-8. */
63
+ export function looksLikeText(head) {
64
+ if (head.includes(0))
65
+ return false;
66
+ try {
67
+ // A cut multi-byte character at the end of the sample is not a decoding failure.
68
+ new TextDecoder("utf-8", { fatal: true }).decode(head.subarray(0, Math.max(0, head.length - 3)));
69
+ return true;
70
+ }
71
+ catch {
72
+ return false;
73
+ }
74
+ }
75
+ function matches(magic, head) {
76
+ switch (magic) {
77
+ case "text":
78
+ return looksLikeText(head);
79
+ case "delimited":
80
+ // Text in any of the encodings the ingestion reads: UTF-8, windows-1252 (no NUL bytes) or
81
+ // UTF-16 with a BOM.
82
+ return (looksLikeText(head) ||
83
+ startsWith(head, [0xff, 0xfe]) ||
84
+ startsWith(head, [0xfe, 0xff]) ||
85
+ !head.includes(0));
86
+ case "pdf":
87
+ return startsWith(head, [0x25, 0x50, 0x44, 0x46, 0x2d]);
88
+ case "png":
89
+ return startsWith(head, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
90
+ case "jpeg":
91
+ return startsWith(head, [0xff, 0xd8, 0xff]);
92
+ case "gif":
93
+ return startsWith(head, [0x47, 0x49, 0x46, 0x38]);
94
+ case "webp":
95
+ return (startsWith(head, [0x52, 0x49, 0x46, 0x46]) && startsWith(head, [0x57, 0x45, 0x42, 0x50], 8));
96
+ case "zip":
97
+ return (startsWith(head, [0x50, 0x4b, 0x03, 0x04]) || startsWith(head, [0x50, 0x4b, 0x05, 0x06]));
98
+ }
99
+ }
100
+ /**
101
+ * The type of a file from its name and its first bytes (at least 4 KiB is a good sample). An
102
+ * unknown extension, or bytes that contradict the extension, yield `file` (download only).
103
+ * An empty file keeps the type of its extension.
104
+ */
105
+ export function classifyArtifact(fileName, head) {
106
+ const rule = RULES[extensionOf(fileName)];
107
+ if (!rule)
108
+ return DOWNLOAD_ONLY;
109
+ if (head.length > 0 && !matches(rule.magic, head))
110
+ return DOWNLOAD_ONLY;
111
+ return { kind: rule.kind, mimeType: rule.mimeType };
112
+ }
113
+ /** Whether a rich client may preview a file of this name, type and size. */
114
+ export function isPreviewable(fileName, type, bytes) {
115
+ if (type.kind === "file" || type.kind === "archive")
116
+ return false;
117
+ const rule = RULES[extensionOf(fileName)];
118
+ return !!rule?.previewMax && rule.mimeType === type.mimeType && bytes <= rule.previewMax;
119
+ }
120
+ /** English labels of each kind (the web localizes its own; text surfaces use these). */
121
+ export const KIND_LABELS = {
122
+ dashboard: "Dashboard",
123
+ document: "Document",
124
+ spreadsheet: "Spreadsheet",
125
+ image: "Image",
126
+ data: "Data",
127
+ code: "Text",
128
+ archive: "Archive",
129
+ file: "File",
130
+ };
131
+ /**
132
+ * Content types of the files of an artifact served by the isolated viewer (spec §14.2): a
133
+ * multi-file dashboard needs its scripts, styles and fonts with their real types (under
134
+ * `nosniff` a script served as text never runs). Only that sandboxed route uses this table;
135
+ * every other route serves the registry type above.
136
+ */
137
+ const VIEWER_TYPES = {
138
+ html: `text/html${UTF8}`,
139
+ htm: `text/html${UTF8}`,
140
+ css: `text/css${UTF8}`,
141
+ js: `text/javascript${UTF8}`,
142
+ mjs: `text/javascript${UTF8}`,
143
+ json: `application/json${UTF8}`,
144
+ geojson: `application/json${UTF8}`,
145
+ csv: `text/csv${UTF8}`,
146
+ tsv: `text/tab-separated-values${UTF8}`,
147
+ txt: `text/plain${UTF8}`,
148
+ md: `text/markdown${UTF8}`,
149
+ svg: "image/svg+xml",
150
+ png: "image/png",
151
+ jpg: "image/jpeg",
152
+ jpeg: "image/jpeg",
153
+ gif: "image/gif",
154
+ webp: "image/webp",
155
+ ico: "image/x-icon",
156
+ woff: "font/woff",
157
+ woff2: "font/woff2",
158
+ ttf: "font/ttf",
159
+ otf: "font/otf",
160
+ pdf: "application/pdf",
161
+ mp4: "video/mp4",
162
+ webm: "video/webm",
163
+ mp3: "audio/mpeg",
164
+ wav: "audio/wav",
165
+ };
166
+ /** The type the sandboxed viewer serves for one file (`application/octet-stream` when unknown). */
167
+ export const viewerContentType = (fileName) => VIEWER_TYPES[extensionOf(fileName)] ?? "application/octet-stream";
168
+ /**
169
+ * The registry type of one file inside an artifact (for the authenticated `files/*` route):
170
+ * the extension and the leading bytes decide, exactly like a published file.
171
+ */
172
+ export function fileType(fileName, head) {
173
+ const type = classifyArtifact(fileName, head);
174
+ // HTML never renders on the app origin; download-only kinds never render inline.
175
+ const inline = type.kind !== "file" && type.kind !== "archive" && type.kind !== "dashboard";
176
+ return { ...type, inline };
177
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The `ToolContext.artifacts` of one tool call: binds the artifact store to the calling session
3
+ * (and its root), run and call, and announces every publication (`artifact_published`).
4
+ */
5
+ import type { CoreArtifactPublisher, PublishedArtifactInfo } from "../core/contracts.ts";
6
+ import type { ArtifactOwner, ArtifactStore } from "./store.ts";
7
+ export declare function createArtifactPublisher(store: ArtifactStore, owner: ArtifactOwner, announce: (published: PublishedArtifactInfo) => void): CoreArtifactPublisher;
@@ -0,0 +1,29 @@
1
+ export function createArtifactPublisher(store, owner, announce) {
2
+ const done = (published, executionId) => {
3
+ const info = { ...published, ...(executionId ? { executionId } : {}) };
4
+ announce(info);
5
+ return info;
6
+ };
7
+ return {
8
+ async publish(input) {
9
+ return done(await store.publish(input, owner)).artifact;
10
+ },
11
+ async publishText(input) {
12
+ return done(await store.publishText(input, owner)).artifact;
13
+ },
14
+ async publishTextDetailed(input) {
15
+ return done(await store.publishText(input, owner));
16
+ },
17
+ async publishOutputs(staging, options) {
18
+ const published = await store.publishOutputs(staging, {
19
+ ...owner,
20
+ executionId: options.executionId,
21
+ ...(options.partial ? { partial: true } : {}),
22
+ ...(options.provenance
23
+ ? { provenance: { ...owner.provenance, ...options.provenance } }
24
+ : {}),
25
+ }, options.title ? { title: options.title } : {});
26
+ return published.map((p) => done(p, options.executionId));
27
+ },
28
+ };
29
+ }
@@ -0,0 +1,119 @@
1
+ import type { ArtifactKind, ArtifactPublishInput, ArtifactRef, SqlDatabase } from "@alisio/sdk";
2
+ export interface ArtifactLimits {
3
+ maxFiles: number;
4
+ maxFileBytes: number;
5
+ /** Total bytes of one publication (one execution). */
6
+ maxOutputBytes: number;
7
+ }
8
+ export declare const DEFAULT_ARTIFACT_LIMITS: ArtifactLimits;
9
+ /** Who publishes: the session (and its root), the call that produced the files, provenance. */
10
+ export interface ArtifactOwner {
11
+ sessionId: string;
12
+ rootSessionId: string;
13
+ workspace: string;
14
+ runId?: string;
15
+ callId?: string;
16
+ executionId?: string;
17
+ partial?: boolean;
18
+ /** Extra public provenance (runtime, script hash, inputs, model, provider). No paths. */
19
+ provenance?: Record<string, unknown>;
20
+ }
21
+ export interface PublishedArtifact {
22
+ artifact: ArtifactRef;
23
+ /** Absolute path of the file, or of the entry of a multi-file artifact. */
24
+ path: string;
25
+ /** Non-fatal notes (e.g. a dashboard reference to a missing file). */
26
+ warnings: string[];
27
+ }
28
+ export interface ArtifactFile {
29
+ path: string;
30
+ bytes: number;
31
+ sha256: string;
32
+ }
33
+ export interface ArtifactRecord extends ArtifactRef {
34
+ entry?: string;
35
+ executionId?: string;
36
+ runId?: string;
37
+ callId?: string;
38
+ provenance: Record<string, unknown>;
39
+ /** Folder relative to the store root. */
40
+ relDir: string;
41
+ }
42
+ /** A rejected publication: the message is user-readable and names the offending path. */
43
+ export declare class ArtifactRejected extends Error {
44
+ }
45
+ /** `title` → `[a-z0-9-]`, at most 48 characters (`artifact` when nothing remains). */
46
+ export declare function slugify(title: string): string;
47
+ /** The first bytes of a file (the sample `classifyArtifact` needs). */
48
+ export declare function readHead(path: string): Promise<Uint8Array>;
49
+ /** The public part of a record (what the SDK `ArtifactRef` carries). */
50
+ export declare const toRef: (record: ArtifactRecord) => ArtifactRef;
51
+ export declare class ArtifactStore {
52
+ private options;
53
+ readonly limits: ArtifactLimits;
54
+ private readonly now;
55
+ constructor(options: {
56
+ /** State root (`stateHome()` or the folder of `--db`); artifacts live under `artifacts/`. */
57
+ root: string;
58
+ db: SqlDatabase;
59
+ limits?: Partial<ArtifactLimits>;
60
+ now?: () => number;
61
+ });
62
+ get root(): string;
63
+ /** Session folder of an owner (artifacts of child sessions live with their root). */
64
+ private sessionDir;
65
+ /**
66
+ * Publishes the outputs a script left in `staging`: the entries of `staging/outputs.json`, or
67
+ * else every top-level file (and every top-level folder; with `index.html` a multi-file
68
+ * dashboard, otherwise one ZIP archive). Everything or nothing is published.
69
+ */
70
+ publishOutputs(staging: string, owner: ArtifactOwner, defaults?: {
71
+ title?: string;
72
+ }): Promise<PublishedArtifact[]>;
73
+ /** Publishes one caller-owned file or directory. */
74
+ publish(input: ArtifactPublishInput, owner: ArtifactOwner): Promise<PublishedArtifact>;
75
+ /** Publishes a single text file the caller holds in memory. */
76
+ publishText(input: {
77
+ fileName: string;
78
+ title?: string;
79
+ text: string;
80
+ }, owner: ArtifactOwner): Promise<PublishedArtifact>;
81
+ private scan;
82
+ private publishAll;
83
+ private build;
84
+ /** Artifacts of a root session, newest first. */
85
+ list(rootSessionId: string, options?: {
86
+ kind?: ArtifactKind;
87
+ limit?: number;
88
+ before?: number;
89
+ /** Also `deleted` and `expired` rows (the folder is gone, the row remains). */
90
+ includeDeleted?: boolean;
91
+ /** Also `expired` rows (retention), but not `deleted` ones. */
92
+ includeExpired?: boolean;
93
+ }): ArtifactRecord[];
94
+ get(id: string): ArtifactRecord | undefined;
95
+ /** Absolute folder holding `manifest.json` and `files/`. */
96
+ folder(record: ArtifactRecord): string;
97
+ /** Absolute path of the file (or the entry of a multi-file artifact). */
98
+ localPath(record: ArtifactRecord): string;
99
+ /** Files of an artifact from its manifest, with absolute paths (inside `files/`). */
100
+ files(record: ArtifactRecord): Promise<Array<ArtifactFile & {
101
+ abs: string;
102
+ }>>;
103
+ /**
104
+ * One file of a ready artifact by its manifest path (`files/` only, never `manifest.json`):
105
+ * the path must be listed in the manifest and its real path must stay inside `files/`.
106
+ */
107
+ resolveFile(record: ArtifactRecord, path: string): Promise<(ArtifactFile & {
108
+ abs: string;
109
+ }) | undefined>;
110
+ /**
111
+ * Retention: marks a `ready` artifact `expired` and removes its folder; the row stays so cards
112
+ * and listings keep showing it as `Expired`. False when it is not `ready`.
113
+ */
114
+ markExpired(id: string): Promise<boolean>;
115
+ /** Ready artifacts created before `cutoff` (epoch ms), oldest first (for the retention sweep). */
116
+ readyBefore(cutoff: number): ArtifactRecord[];
117
+ /** Marks an artifact deleted and removes its folder (the row stays for references). */
118
+ delete(id: string): Promise<boolean>;
119
+ }