agentfootprint 9.20.0 → 9.21.0
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/AGENTS.md +1 -1
- package/CLAUDE.md +1 -1
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/artifacts/capability.js +131 -0
- package/dist/artifacts/capability.js.map +1 -0
- package/dist/artifacts/fileArtifacts.js +230 -0
- package/dist/artifacts/fileArtifacts.js.map +1 -0
- package/dist/artifacts/inMemoryArtifacts.js +165 -0
- package/dist/artifacts/inMemoryArtifacts.js.map +1 -0
- package/dist/artifacts/index.js +33 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/artifacts/minting.js +79 -0
- package/dist/artifacts/minting.js.map +1 -0
- package/dist/artifacts/naming.js +64 -0
- package/dist/artifacts/naming.js.map +1 -0
- package/dist/artifacts/payload.js +113 -0
- package/dist/artifacts/payload.js.map +1 -0
- package/dist/artifacts/retention.js +121 -0
- package/dist/artifacts/retention.js.map +1 -0
- package/dist/artifacts/sqliteArtifacts.js +338 -0
- package/dist/artifacts/sqliteArtifacts.js.map +1 -0
- package/dist/artifacts/types.js +96 -0
- package/dist/artifacts/types.js.map +1 -0
- package/dist/core/Agent.js +20 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +88 -0
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/artifacts/capability.d.ts +86 -0
- package/dist/esm/artifacts/capability.js +126 -0
- package/dist/esm/artifacts/capability.js.map +1 -0
- package/dist/esm/artifacts/fileArtifacts.d.ts +58 -0
- package/dist/esm/artifacts/fileArtifacts.js +225 -0
- package/dist/esm/artifacts/fileArtifacts.js.map +1 -0
- package/dist/esm/artifacts/inMemoryArtifacts.d.ts +54 -0
- package/dist/esm/artifacts/inMemoryArtifacts.js +161 -0
- package/dist/esm/artifacts/inMemoryArtifacts.js.map +1 -0
- package/dist/esm/artifacts/index.d.ts +16 -0
- package/dist/esm/artifacts/index.js +16 -0
- package/dist/esm/artifacts/index.js.map +1 -0
- package/dist/esm/artifacts/minting.d.ts +29 -0
- package/dist/esm/artifacts/minting.js +75 -0
- package/dist/esm/artifacts/minting.js.map +1 -0
- package/dist/esm/artifacts/naming.d.ts +36 -0
- package/dist/esm/artifacts/naming.js +59 -0
- package/dist/esm/artifacts/naming.js.map +1 -0
- package/dist/esm/artifacts/payload.d.ts +43 -0
- package/dist/esm/artifacts/payload.js +105 -0
- package/dist/esm/artifacts/payload.js.map +1 -0
- package/dist/esm/artifacts/retention.d.ts +72 -0
- package/dist/esm/artifacts/retention.js +115 -0
- package/dist/esm/artifacts/retention.js.map +1 -0
- package/dist/esm/artifacts/sqliteArtifacts.d.ts +90 -0
- package/dist/esm/artifacts/sqliteArtifacts.js +333 -0
- package/dist/esm/artifacts/sqliteArtifacts.js.map +1 -0
- package/dist/esm/artifacts/types.d.ts +220 -0
- package/dist/esm/artifacts/types.js +90 -0
- package/dist/esm/artifacts/types.js.map +1 -0
- package/dist/esm/core/Agent.d.ts +3 -0
- package/dist/esm/core/Agent.js +20 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +10 -0
- package/dist/esm/core/agent/stages/toolCalls.js +88 -0
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +17 -0
- package/dist/esm/core/tools.d.ts +15 -0
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/events/dispatcher.d.ts +1 -1
- package/dist/esm/events/dispatcher.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +57 -0
- package/dist/esm/events/registry.d.ts +11 -1
- package/dist/esm/events/registry.js +10 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/mcp/mcpServe.js +7 -0
- package/dist/esm/lib/mcp/mcpServe.js.map +1 -1
- package/dist/esm/lib/trace-toolpack/traceToolpack.js +4 -0
- package/dist/esm/lib/trace-toolpack/traceToolpack.js.map +1 -1
- package/dist/esm/recorders/core/ArtifactsRecorder.d.ts +22 -0
- package/dist/esm/recorders/core/ArtifactsRecorder.js +27 -0
- package/dist/esm/recorders/core/ArtifactsRecorder.js.map +1 -0
- package/dist/events/dispatcher.js.map +1 -1
- package/dist/events/registry.js +10 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/mcp/mcpServe.js +7 -0
- package/dist/lib/mcp/mcpServe.js.map +1 -1
- package/dist/lib/trace-toolpack/traceToolpack.js +4 -0
- package/dist/lib/trace-toolpack/traceToolpack.js.map +1 -1
- package/dist/recorders/core/ArtifactsRecorder.js +31 -0
- package/dist/recorders/core/ArtifactsRecorder.js.map +1 -0
- package/dist/types/artifacts/capability.d.ts +87 -0
- package/dist/types/artifacts/capability.d.ts.map +1 -0
- package/dist/types/artifacts/fileArtifacts.d.ts +59 -0
- package/dist/types/artifacts/fileArtifacts.d.ts.map +1 -0
- package/dist/types/artifacts/inMemoryArtifacts.d.ts +55 -0
- package/dist/types/artifacts/inMemoryArtifacts.d.ts.map +1 -0
- package/dist/types/artifacts/index.d.ts +17 -0
- package/dist/types/artifacts/index.d.ts.map +1 -0
- package/dist/types/artifacts/minting.d.ts +30 -0
- package/dist/types/artifacts/minting.d.ts.map +1 -0
- package/dist/types/artifacts/naming.d.ts +37 -0
- package/dist/types/artifacts/naming.d.ts.map +1 -0
- package/dist/types/artifacts/payload.d.ts +44 -0
- package/dist/types/artifacts/payload.d.ts.map +1 -0
- package/dist/types/artifacts/retention.d.ts +73 -0
- package/dist/types/artifacts/retention.d.ts.map +1 -0
- package/dist/types/artifacts/sqliteArtifacts.d.ts +91 -0
- package/dist/types/artifacts/sqliteArtifacts.d.ts.map +1 -0
- package/dist/types/artifacts/types.d.ts +221 -0
- package/dist/types/artifacts/types.d.ts.map +1 -0
- package/dist/types/core/Agent.d.ts +3 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +10 -0
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +17 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/tools.d.ts +15 -0
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/events/dispatcher.d.ts +1 -1
- package/dist/types/events/dispatcher.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +57 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +11 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/mcp/mcpServe.d.ts.map +1 -1
- package/dist/types/lib/trace-toolpack/traceToolpack.d.ts.map +1 -1
- package/dist/types/recorders/core/ArtifactsRecorder.d.ts +23 -0
- package/dist/types/recorders/core/ArtifactsRecorder.d.ts.map +1 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -475,7 +475,7 @@ Resilience decorators live on the `agentfootprint/resilience` subpath
|
|
|
475
475
|
(not the main barrel). Each preserves the `LLMProvider` interface and
|
|
476
476
|
stacks freely.
|
|
477
477
|
|
|
478
|
-
### Observability —
|
|
478
|
+
### Observability — 89 typed events across 21 domains
|
|
479
479
|
|
|
480
480
|
```typescript
|
|
481
481
|
agent.on('agentfootprint.context.injected', (e) =>
|
package/CLAUDE.md
CHANGED
|
@@ -60,7 +60,7 @@ Traps: `src/observability/` holds the finder IMPLEMENTATIONS (canonical home; `d
|
|
|
60
60
|
- **Embedder fingerprint** (8.9.0) → `Embedder.id` (optional; every shipped embedder sets one, and NONE include dims — the store appends `@<dims>` itself, so an id carrying its own size double-stamps) + `indexDocuments` defaulting `embedderId` to it + `SqliteVectorStore.reconcileFingerprint` (the only comparison site). Rule: dimensions ALWAYS decide, model ids decide only when BOTH sides named themselves — refusing on an absent name would block the majority of callers who never pass `embedderId`.
|
|
61
61
|
- **Retrieval record** (8.8.0) → FOUR stages write one object in sequence: `loadRelevant` (candidates+scores+threshold verdicts) → `pickByBudget` (re-marks admitted→over-budget/over-max-entries) → `formatDefault` (`promptFragment` + `promptPosition`) → the read mount's outputMapper lifts it to root as `retrievalEvidence_<id>`. `memoryRecallInjections` then splits ONE recall into one ActiveInjection PER CHUNK — guarded by a byte-equality check (`fragments.join('\n\n') === systemContent`) that falls back to the single injection rather than change the prompt. `rank` (score order) and `promptPosition` (picker order) are DIFFERENT and both load-bearing: joining fragments in rank order reproduces the right bytes in a sequence the model never saw.
|
|
62
62
|
- **AgentState** → all 8 stages/ files, both builders' mappers, memory-wire STRING-TYPED keys ('runIdentity'/'turnNumber'/… buildAgentChart.ts:177-180 — not refactor-safe), finalizeResult's `reliabilityFail*`/`policyHalt*` reads (rename silently kills the typed errors).
|
|
63
|
-
- **events/** →
|
|
63
|
+
- **events/** → 89 typed events across 21 domains (counts anti-drift-tested against this file — update BOTH when adding events): ALL_EVENT_TYPES exhaustiveness tests, DomainWildcard hand-list, ~42 importers (recorders, strategies, stream, commentary).
|
|
64
64
|
- **adapters/types.ts LLMMessage/LLMRequest** → 62 importers: tool_use round-trip (toolCalls.ts:115-135), wire assembly (callLLM.ts:150-160), providers, cache strategies, security/extractSequence, reliability loop.
|
|
65
65
|
- **Cache** → strategy registration is a MODULE SIDE EFFECT (src/index.ts:15-17); an entry point skipping that import silently falls back to NoOp. Resolved once per Agent at construction (Agent.ts:347).
|
|
66
66
|
- **Injection engine eval semantics** → Evaluate stage cursor keystone (buildInjectionEngineSubflow.ts:214-222), Route stage MIRRORS slot filters (keep in sync with buildSystemPromptSlot), read_skill gate (toolCalls.ts:747). The gate's allowed set is TWO kinds of id (8.4.0): a HOP (`deps.allowedSkillIds` = `graph.reachableSkills(cursor)` — activates AND moves the cursor) ∪ an OPEN skill (`deps.openSkillIds` = `Agent.openSkillIds()`, Agent.ts:1052 — a registered skill whose trigger is `llm-activated` AND that the graph declares no incoming edge to; activates, never moves the cursor). Both clauses are load-bearing: the trigger test is "read_skill can really activate this", the edge test keeps a bare model edge `.route(a,m)` from-gated. **8.5.0** extends the SAME trigger test three ways: a decision `tree()` returns `[]` from `reachableSkills` (leaves compile to `rule` triggers, so a pick could only be accepted then dropped — the gate refuses with a tree-specific message, `deps.skillGraphIsTree`, derived in AgentBuilder from `graph.nodes.some(kind==='predicate')`); `surfaceMode:'tool-only'` is refused at agent build for any skill whose trigger is not `llm-activated` (skillBodyDelivery.ts — the read_skill tool result is the only channel that mode has, and the graph never calls read_skill); and `read_skill`'s DESCRIPTION is rebuilt per iteration from `reachableSkills(cursor) ∪ open` (Agent.readSkillOfferFor → buildToolsSlot's `readSkillFor`). **The read_skill ENUM must stay the full catalog** — `toolArgValidation` defaults to `'enforce'` and runs at toolCalls.ts:570, BEFORE the gate at :765, and sets `error = true` which the gate skips; narrowing the enum silently retires the teaching refusal, `skill.rejected`, routeRecorder's rejection hops and the rejected-cap governor.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* artifacts/capability — `ctx.artifacts`, the scope-bound door a tool gets.
|
|
4
|
+
*
|
|
5
|
+
* Shaped exactly like `ctx.credentials`:
|
|
6
|
+
* • ALWAYS present — with no store attached every method is a teaching
|
|
7
|
+
* refusal naming how to attach one, so a tool can never silently
|
|
8
|
+
* optional-chain past a store that is not there;
|
|
9
|
+
* • fail-closed — the refusal throws; `ctx.hasArtifacts` is the fact to
|
|
10
|
+
* branch on for an intentional degraded mode;
|
|
11
|
+
* • scope composed by the FRAMEWORK from the run's identity/session — the
|
|
12
|
+
* capability closes over it, so a tool cannot name, widen or replace the
|
|
13
|
+
* scope it resolves under. The five verbs here take no scope argument on
|
|
14
|
+
* purpose: that argument was already answered by whoever built the
|
|
15
|
+
* context.
|
|
16
|
+
*
|
|
17
|
+
* Every hop lands on the record AS IT HAPPENS: this module reports facts to a
|
|
18
|
+
* neutral sink (a plain callback), and the tool-dispatch layer adapts that
|
|
19
|
+
* sink onto the typed event channel. Neutral so this folder never imports the
|
|
20
|
+
* event system or the agent — core wires artifacts, never the reverse.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.unconfiguredArtifacts = exports.bindArtifacts = void 0;
|
|
24
|
+
const types_js_1 = require("./types.js");
|
|
25
|
+
/**
|
|
26
|
+
* Bind a store to one run's scope — the framework's move, made where the
|
|
27
|
+
* scope is known and a tool cannot reach.
|
|
28
|
+
*/
|
|
29
|
+
function bindArtifacts(store, scope, options = {}) {
|
|
30
|
+
const { origin, onEvent } = options;
|
|
31
|
+
const report = (fact) => {
|
|
32
|
+
onEvent?.(fact);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
async put(input) {
|
|
36
|
+
try {
|
|
37
|
+
// `origin` is the framework's field: whatever a caller managed to put
|
|
38
|
+
// there is discarded in favor of the run's own facts.
|
|
39
|
+
const result = await store.put(scope, {
|
|
40
|
+
...input,
|
|
41
|
+
...(origin !== undefined ? { origin } : {}),
|
|
42
|
+
});
|
|
43
|
+
for (const swept of result.swept)
|
|
44
|
+
report({ type: 'expired', swept });
|
|
45
|
+
report({ type: 'minted', meta: result.meta });
|
|
46
|
+
return result.meta;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err instanceof types_js_1.UnknownParentRefError) {
|
|
50
|
+
report({ type: 'refused', op: 'put', reason: 'unknown-parent', detail: err.message });
|
|
51
|
+
}
|
|
52
|
+
else if (err instanceof types_js_1.InvalidArtifactError) {
|
|
53
|
+
report({ type: 'refused', op: 'put', reason: 'invalid-input', detail: err.message });
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
async head(ref) {
|
|
59
|
+
const meta = await store.head(scope, ref);
|
|
60
|
+
if (meta === null) {
|
|
61
|
+
report({ type: 'refused', op: 'head', reason: 'missing-or-expired', ref });
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
report({ type: 'resolved', ref: meta.ref, via: 'head', kind: meta.kind, bytes: meta.bytes });
|
|
65
|
+
return meta;
|
|
66
|
+
},
|
|
67
|
+
async get(ref) {
|
|
68
|
+
let record;
|
|
69
|
+
try {
|
|
70
|
+
record = await store.get(scope, ref);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (err instanceof types_js_1.ArtifactIntegrityError) {
|
|
74
|
+
report({
|
|
75
|
+
type: 'refused',
|
|
76
|
+
op: 'get',
|
|
77
|
+
reason: 'digest-mismatch',
|
|
78
|
+
ref,
|
|
79
|
+
detail: err.message,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
throw err;
|
|
83
|
+
}
|
|
84
|
+
if (record === null) {
|
|
85
|
+
report({ type: 'refused', op: 'get', reason: 'missing-or-expired', ref });
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
report({
|
|
89
|
+
type: 'resolved',
|
|
90
|
+
ref: record.meta.ref,
|
|
91
|
+
via: 'get',
|
|
92
|
+
kind: record.meta.kind,
|
|
93
|
+
bytes: record.meta.bytes,
|
|
94
|
+
});
|
|
95
|
+
return record;
|
|
96
|
+
},
|
|
97
|
+
delete(ref) {
|
|
98
|
+
return store.delete(scope, ref);
|
|
99
|
+
},
|
|
100
|
+
list(options) {
|
|
101
|
+
return store.list(scope, options);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.bindArtifacts = bindArtifacts;
|
|
106
|
+
/**
|
|
107
|
+
* The fail-closed capability used when NO store is attached. Every verb
|
|
108
|
+
* throws the same teaching refusal — loud, named, and on the record — so
|
|
109
|
+
* `ctx.artifacts` is never `undefined` and a missing store can never read as
|
|
110
|
+
* an empty one. Branch on `ctx.hasArtifacts` for an intentional no-store
|
|
111
|
+
* mode. (The `unconfiguredCredentialProvider` law, verb for verb.)
|
|
112
|
+
*/
|
|
113
|
+
function unconfiguredArtifacts(onEvent) {
|
|
114
|
+
const refuse = (op, ref) => {
|
|
115
|
+
onEvent?.({ type: 'refused', op, reason: 'no-store', ...(ref !== undefined && { ref }) });
|
|
116
|
+
return Promise.reject(new Error(`No artifact store is attached, but this tool called ctx.artifacts.${op}(...). ` +
|
|
117
|
+
`Pass \`artifacts\` to Agent.create({ ..., artifacts }) — inMemoryArtifacts() for ` +
|
|
118
|
+
`an in-process store, fileArtifacts({ directory }) or sqliteArtifacts({ file }) for ` +
|
|
119
|
+
`one that survives a restart. A tool that intentionally supports running without a ` +
|
|
120
|
+
`store should branch on \`ctx.hasArtifacts\` instead of catching this.`));
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
put: () => refuse('put'),
|
|
124
|
+
head: (ref) => refuse('head', ref),
|
|
125
|
+
get: (ref) => refuse('get', ref),
|
|
126
|
+
delete: (ref) => refuse('delete', ref),
|
|
127
|
+
list: () => refuse('list'),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
exports.unconfiguredArtifacts = unconfiguredArtifacts;
|
|
131
|
+
//# sourceMappingURL=capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.js","sourceRoot":"","sources":["../../src/artifacts/capability.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,yCAcoB;AAkEpB;;;GAGG;AACH,SAAgB,aAAa,CAC3B,KAAoB,EACpB,KAAoB,EACpB,UAAgC,EAAE;IAElC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACpC,MAAM,MAAM,GAAG,CAAC,IAAuB,EAAQ,EAAE;QAC/C,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,KAA2B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fileArtifacts — the claim-check store in a directory.
|
|
4
|
+
*
|
|
5
|
+
* One machine, one directory, nothing to install: each artifact is one JSON
|
|
6
|
+
* envelope at `<dir>/<tenant>/<principal>/<conversation>/<ref>.json`, so an
|
|
7
|
+
* incident can be inspected with `ls` and `cat` — a store you cannot read
|
|
8
|
+
* with the tools already on the box is a store you debug by guessing.
|
|
9
|
+
*
|
|
10
|
+
* ── Scope-partitioned paths, structurally traversal-proof ──────────────────
|
|
11
|
+
* The path is built from two kinds of segment and both are closed:
|
|
12
|
+
* • the ref — MINTED (`art_` + base62), and `isArtifactRef` is asserted
|
|
13
|
+
* before any ref touches a path anyway, because "cannot happen" is a
|
|
14
|
+
* claim, not a defence;
|
|
15
|
+
* • the scope tuple — caller strings, so each segment is percent-encoded
|
|
16
|
+
* before it becomes a directory name: `..`, `/` and `\` arrive as data
|
|
17
|
+
* and land as literals, never as navigation.
|
|
18
|
+
*
|
|
19
|
+
* ── What this adapter does NOT know ────────────────────────────────────────
|
|
20
|
+
* A directory cannot cheaply know which artifact was READ last, so budget
|
|
21
|
+
* evictions here are oldest-first (by mint time) rather than the in-memory
|
|
22
|
+
* adapter's least-recently-used — stated here so nobody discovers it as a
|
|
23
|
+
* surprise under pressure. TTL expiry behaves identically everywhere.
|
|
24
|
+
*
|
|
25
|
+
* Node-only (`node:fs` via lazy require, the sqliteSessions law) — importing
|
|
26
|
+
* the barrel costs a browser bundle nothing; constructing one where there is
|
|
27
|
+
* no filesystem refuses by name.
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.fileArtifacts = exports.UnreadableArtifactFileError = void 0;
|
|
31
|
+
const lazyRequire_js_1 = require("../lib/lazyRequire.js");
|
|
32
|
+
const minting_js_1 = require("./minting.js");
|
|
33
|
+
const naming_js_1 = require("./naming.js");
|
|
34
|
+
const payload_js_1 = require("./payload.js");
|
|
35
|
+
const retention_js_1 = require("./retention.js");
|
|
36
|
+
const types_js_1 = require("./types.js");
|
|
37
|
+
/** What one artifact file holds. `format` is bumped only for a change an
|
|
38
|
+
* older reader could not survive; a newer number is refused, never half-read. */
|
|
39
|
+
const FILE_FORMAT = 1;
|
|
40
|
+
/**
|
|
41
|
+
* Raised when an artifact file EXISTS but this runtime cannot read it — a
|
|
42
|
+
* different fact from "no artifact", and only one of them is safe to answer
|
|
43
|
+
* with `null`. (The sqliteSessions law, per file.)
|
|
44
|
+
*/
|
|
45
|
+
class UnreadableArtifactFileError extends Error {
|
|
46
|
+
code = 'ERR_UNREADABLE_ARTIFACT_FILE';
|
|
47
|
+
file;
|
|
48
|
+
constructor(file, detail) {
|
|
49
|
+
super(`[artifacts] the artifact file at '${file}' cannot be read: ${detail} ` +
|
|
50
|
+
`An unreadable artifact and a missing one are different facts — this refuses rather ` +
|
|
51
|
+
`than reporting "no data" over bytes that exist. Move the file aside to release the ref.`);
|
|
52
|
+
this.name = 'UnreadableArtifactFileError';
|
|
53
|
+
this.file = file;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.UnreadableArtifactFileError = UnreadableArtifactFileError;
|
|
57
|
+
/**
|
|
58
|
+
* A directory-backed artifact store — durable across restarts, legible to a
|
|
59
|
+
* human, one file per artifact.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const store = fileArtifacts({ directory: './artifacts' });
|
|
63
|
+
* const agent = Agent.create({ provider, artifacts: store });
|
|
64
|
+
*/
|
|
65
|
+
function fileArtifacts(options) {
|
|
66
|
+
const { directory, retention } = options;
|
|
67
|
+
if (typeof directory !== 'string' || directory.trim() === '') {
|
|
68
|
+
throw new TypeError(`[artifacts] fileArtifacts({ directory: ${JSON.stringify(directory)} }) names no ` +
|
|
69
|
+
`directory. Give it a path — it will be created if it does not exist.`);
|
|
70
|
+
}
|
|
71
|
+
(0, retention_js_1.assertRetention)('fileArtifacts', retention);
|
|
72
|
+
const now = options._now ?? Date.now;
|
|
73
|
+
const fs = (0, lazyRequire_js_1.lazyRequire)('node:fs');
|
|
74
|
+
const path = (0, lazyRequire_js_1.lazyRequire)('node:path');
|
|
75
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
76
|
+
/**
|
|
77
|
+
* One RAW tuple field → one directory name. Encoded from the FIELD, never
|
|
78
|
+
* from the joined namespace (a tenant containing '/' must not become two
|
|
79
|
+
* path segments), and with dots encoded too — `encodeURIComponent` leaves
|
|
80
|
+
* `.` alone, so a tenant of literally `'..'` would otherwise survive as a
|
|
81
|
+
* real parent-directory hop. After this, `..`, `/` and `\` are inert
|
|
82
|
+
* directory NAMES (`%2E%2E`, `%2F`, `%5C`). Empty fields collapse to `_`,
|
|
83
|
+
* mirroring `identityNamespace`'s stable layout.
|
|
84
|
+
*/
|
|
85
|
+
const segment = (raw) => encodeURIComponent(raw === undefined || raw === '' ? '_' : raw).replace(/\./g, '%2E');
|
|
86
|
+
const scopeDir = (scope) => path.join(directory, segment(scope.tenant), segment(scope.principal), segment(scope.conversationId));
|
|
87
|
+
const fileFor = (scope, ref) => path.join(scopeDir(scope), `${ref}.json`);
|
|
88
|
+
const readEnvelope = (file) => {
|
|
89
|
+
let raw;
|
|
90
|
+
try {
|
|
91
|
+
raw = fs.readFileSync(file, 'utf8');
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return undefined; // never written (or already swept) — the null case.
|
|
95
|
+
}
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = JSON.parse(raw);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
throw new UnreadableArtifactFileError(file, 'it is not JSON.');
|
|
102
|
+
}
|
|
103
|
+
const candidate = parsed;
|
|
104
|
+
if (candidate === null ||
|
|
105
|
+
typeof candidate !== 'object' ||
|
|
106
|
+
typeof candidate.format !== 'number' ||
|
|
107
|
+
candidate.meta === undefined ||
|
|
108
|
+
candidate.payload === undefined) {
|
|
109
|
+
throw new UnreadableArtifactFileError(file, 'it is not an artifact envelope.');
|
|
110
|
+
}
|
|
111
|
+
if (candidate.format > FILE_FORMAT) {
|
|
112
|
+
throw new UnreadableArtifactFileError(file, `it was written with format ${candidate.format} and this runtime reads format ` +
|
|
113
|
+
`${FILE_FORMAT}; roll agentfootprint forward rather than half-read it.`);
|
|
114
|
+
}
|
|
115
|
+
return candidate;
|
|
116
|
+
};
|
|
117
|
+
/** Read a LIVE envelope; sweep the file when the calendar says it is gone. */
|
|
118
|
+
const liveEnvelope = (scope, ref) => {
|
|
119
|
+
if (!(0, naming_js_1.isArtifactRef)(ref))
|
|
120
|
+
return undefined;
|
|
121
|
+
const file = fileFor(scope, ref);
|
|
122
|
+
const envelope = readEnvelope(file);
|
|
123
|
+
if (envelope === undefined)
|
|
124
|
+
return undefined;
|
|
125
|
+
if (envelope.meta.expiresAt !== undefined && envelope.meta.expiresAt <= now()) {
|
|
126
|
+
fs.rmSync(file, { force: true });
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return envelope;
|
|
130
|
+
};
|
|
131
|
+
/** Every live meta in a scope (expired files swept as they are found). */
|
|
132
|
+
const scopeMetas = (scope) => {
|
|
133
|
+
const dir = scopeDir(scope);
|
|
134
|
+
let names;
|
|
135
|
+
try {
|
|
136
|
+
names = fs.readdirSync(dir);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return []; // scope never wrote anything.
|
|
140
|
+
}
|
|
141
|
+
const at = now();
|
|
142
|
+
const metas = [];
|
|
143
|
+
for (const name of names) {
|
|
144
|
+
if (!name.endsWith('.json'))
|
|
145
|
+
continue;
|
|
146
|
+
const ref = name.slice(0, -'.json'.length);
|
|
147
|
+
if (!(0, naming_js_1.isArtifactRef)(ref))
|
|
148
|
+
continue; // not ours; leave foreign files alone.
|
|
149
|
+
const envelope = readEnvelope(path.join(dir, name));
|
|
150
|
+
if (envelope === undefined)
|
|
151
|
+
continue;
|
|
152
|
+
if (envelope.meta.expiresAt !== undefined && envelope.meta.expiresAt <= at) {
|
|
153
|
+
fs.rmSync(path.join(dir, name), { force: true });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
metas.push(envelope.meta);
|
|
157
|
+
}
|
|
158
|
+
return metas;
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
async put(scope, input) {
|
|
162
|
+
const at = now();
|
|
163
|
+
const { meta } = await (0, minting_js_1.prepareArtifact)(input, (parent) => liveEnvelope(scope, parent) !== undefined, retention, at);
|
|
164
|
+
const rows = scopeMetas(scope).map((held) => ({
|
|
165
|
+
ref: held.ref,
|
|
166
|
+
kind: held.kind,
|
|
167
|
+
bytes: held.bytes,
|
|
168
|
+
...(held.expiresAt !== undefined && { expiresAt: held.expiresAt }),
|
|
169
|
+
// A directory has no cheap read-recency; oldest-first is the stated law.
|
|
170
|
+
lastAccessedAt: held.createdAt,
|
|
171
|
+
}));
|
|
172
|
+
const plan = (0, retention_js_1.planRetention)(rows, meta.bytes, retention, at);
|
|
173
|
+
if (plan.refusal !== undefined)
|
|
174
|
+
throw new types_js_1.InvalidArtifactError(plan.refusal);
|
|
175
|
+
for (const swept of plan.swept)
|
|
176
|
+
fs.rmSync(fileFor(scope, swept.ref), { force: true });
|
|
177
|
+
const envelope = {
|
|
178
|
+
format: FILE_FORMAT,
|
|
179
|
+
meta,
|
|
180
|
+
payload: (0, payload_js_1.encodeArtifactData)(input.data),
|
|
181
|
+
};
|
|
182
|
+
fs.mkdirSync(scopeDir(scope), { recursive: true });
|
|
183
|
+
fs.writeFileSync(fileFor(scope, meta.ref), JSON.stringify(envelope));
|
|
184
|
+
return { meta, swept: plan.swept };
|
|
185
|
+
},
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
187
|
+
async head(scope, ref) {
|
|
188
|
+
return liveEnvelope(scope, ref)?.meta ?? null;
|
|
189
|
+
},
|
|
190
|
+
async get(scope, ref) {
|
|
191
|
+
const envelope = liveEnvelope(scope, ref);
|
|
192
|
+
if (envelope === undefined)
|
|
193
|
+
return null;
|
|
194
|
+
const data = (0, payload_js_1.decodeArtifactData)(envelope.payload);
|
|
195
|
+
if (envelope.meta.digest !== undefined) {
|
|
196
|
+
const actual = await (0, payload_js_1.computeArtifactDigest)(data);
|
|
197
|
+
if (actual !== envelope.meta.digest) {
|
|
198
|
+
throw new types_js_1.ArtifactIntegrityError(envelope.meta.ref, envelope.meta.digest, actual);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { meta: envelope.meta, data };
|
|
202
|
+
},
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
204
|
+
async delete(scope, ref) {
|
|
205
|
+
if (!(0, naming_js_1.isArtifactRef)(ref))
|
|
206
|
+
return;
|
|
207
|
+
fs.rmSync(fileFor(scope, ref), { force: true });
|
|
208
|
+
},
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
210
|
+
async list(scope, listOptions) {
|
|
211
|
+
const all = scopeMetas(scope).sort((a, b) => b.createdAt - a.createdAt || (a.ref < b.ref ? -1 : 1));
|
|
212
|
+
const offset = decodeCursor(listOptions?.cursor);
|
|
213
|
+
const limit = Math.max(1, Math.floor(listOptions?.limit ?? 50));
|
|
214
|
+
const page = all.slice(offset, offset + limit);
|
|
215
|
+
const nextOffset = offset + page.length;
|
|
216
|
+
return {
|
|
217
|
+
artifacts: page,
|
|
218
|
+
...(nextOffset < all.length && { cursor: String(nextOffset) }),
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
exports.fileArtifacts = fileArtifacts;
|
|
224
|
+
function decodeCursor(cursor) {
|
|
225
|
+
if (cursor === undefined)
|
|
226
|
+
return 0;
|
|
227
|
+
const parsed = Number(cursor);
|
|
228
|
+
return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : 0;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=fileArtifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileArtifacts.js","sourceRoot":"","sources":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local development, and single-process agents whose artifacts may
|
|
6
|
+
* die with the process. Exactly as durable as the process — which is the
|
|
7
|
+
* point of the port: swap the one argument for `fileArtifacts` or
|
|
8
|
+
* `sqliteArtifacts` and nothing else changes.
|
|
9
|
+
*
|
|
10
|
+
* ── Bounded, and counting its drops (the innerRunRecords laws) ─────────────
|
|
11
|
+
* A retained payload is retained memory, and an agent minting a dataset per
|
|
12
|
+
* turn for a week would otherwise pin every one of them — the failure would
|
|
13
|
+
* look like a leak rather than like a feature. So this adapter is ALWAYS
|
|
14
|
+
* bounded: it has a default byte budget and row budget per scope, an explicit
|
|
15
|
+
* retention only replaces those dials, and there is deliberately no spelling
|
|
16
|
+
* for "unbounded" here — a memory store without a ceiling is a leak wearing
|
|
17
|
+
* configuration. When the budget forces an eviction the least-recently-USED
|
|
18
|
+
* artifact leaves first (reading refreshes recency, so the dataset a chart is
|
|
19
|
+
* actively rendered from is not the next casualty), every eviction is
|
|
20
|
+
* reported by the `put` that caused it, and `dropped` COUNTS them — "we kept
|
|
21
|
+
* the last 200 of 340" is an answer a debugging session can act on; a
|
|
22
|
+
* silently missing ref is not.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.inMemoryArtifacts = exports.DEFAULT_IN_MEMORY_ARTIFACT_RETENTION = void 0;
|
|
26
|
+
const index_js_1 = require("../memory/identity/index.js");
|
|
27
|
+
const minting_js_1 = require("./minting.js");
|
|
28
|
+
const naming_js_1 = require("./naming.js");
|
|
29
|
+
const payload_js_1 = require("./payload.js");
|
|
30
|
+
const retention_js_1 = require("./retention.js");
|
|
31
|
+
const types_js_1 = require("./types.js");
|
|
32
|
+
/** The always-on bounds. Override dials via `retention`; there is no "off". */
|
|
33
|
+
exports.DEFAULT_IN_MEMORY_ARTIFACT_RETENTION = {
|
|
34
|
+
/** 32 MiB per scope — a working set, not an archive. */
|
|
35
|
+
maxBytesPerScope: 32 * 1024 * 1024,
|
|
36
|
+
/** 256 artifacts per scope. */
|
|
37
|
+
maxCountPerScope: 256,
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* A bounded, drop-counting, per-scope-isolated artifact store in process
|
|
41
|
+
* memory.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const store = inMemoryArtifacts({ retention: { ttlMs: 15 * 60_000 } });
|
|
45
|
+
* const agent = Agent.create({ provider, artifacts: store });
|
|
46
|
+
*/
|
|
47
|
+
function inMemoryArtifacts(options = {}) {
|
|
48
|
+
(0, retention_js_1.assertRetention)('inMemoryArtifacts', options.retention);
|
|
49
|
+
const retention = {
|
|
50
|
+
...exports.DEFAULT_IN_MEMORY_ARTIFACT_RETENTION,
|
|
51
|
+
...options.retention,
|
|
52
|
+
};
|
|
53
|
+
const now = options._now ?? Date.now;
|
|
54
|
+
/** namespace → (ref → row). Insertion order is NOT recency; rows carry it. */
|
|
55
|
+
const scopes = new Map();
|
|
56
|
+
let dropped = 0;
|
|
57
|
+
const shelf = (scope) => {
|
|
58
|
+
const ns = (0, index_js_1.identityNamespace)(scope);
|
|
59
|
+
let held = scopes.get(ns);
|
|
60
|
+
if (held === undefined) {
|
|
61
|
+
held = new Map();
|
|
62
|
+
scopes.set(ns, held);
|
|
63
|
+
}
|
|
64
|
+
return held;
|
|
65
|
+
};
|
|
66
|
+
/** Resolve a live row, sweeping it when the calendar says it is gone. */
|
|
67
|
+
const liveRow = (scope, ref) => {
|
|
68
|
+
if (!(0, naming_js_1.isArtifactRef)(ref))
|
|
69
|
+
return undefined;
|
|
70
|
+
const held = shelf(scope);
|
|
71
|
+
const row = held.get(ref);
|
|
72
|
+
if (row === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
if (row.meta.expiresAt !== undefined && row.meta.expiresAt <= now()) {
|
|
75
|
+
held.delete(ref);
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
return row;
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
get dropped() {
|
|
82
|
+
return dropped;
|
|
83
|
+
},
|
|
84
|
+
retention,
|
|
85
|
+
async put(scope, input) {
|
|
86
|
+
const held = shelf(scope);
|
|
87
|
+
const at = now();
|
|
88
|
+
const { meta } = await (0, minting_js_1.prepareArtifact)(input, (parent) => liveRow(scope, parent) !== undefined, retention, at);
|
|
89
|
+
const rows = [...held.values()].map((row) => ({
|
|
90
|
+
ref: row.meta.ref,
|
|
91
|
+
kind: row.meta.kind,
|
|
92
|
+
bytes: row.meta.bytes,
|
|
93
|
+
...(row.meta.expiresAt !== undefined && { expiresAt: row.meta.expiresAt }),
|
|
94
|
+
lastAccessedAt: row.lastAccessedAt,
|
|
95
|
+
}));
|
|
96
|
+
const plan = (0, retention_js_1.planRetention)(rows, meta.bytes, retention, at);
|
|
97
|
+
if (plan.refusal !== undefined)
|
|
98
|
+
throw new types_js_1.InvalidArtifactError(plan.refusal);
|
|
99
|
+
for (const swept of plan.swept) {
|
|
100
|
+
held.delete(swept.ref);
|
|
101
|
+
if (swept.reason !== 'ttl')
|
|
102
|
+
dropped++;
|
|
103
|
+
}
|
|
104
|
+
held.set(meta.ref, { meta, payload: (0, payload_js_1.encodeArtifactData)(input.data), lastAccessedAt: at });
|
|
105
|
+
return { meta, swept: plan.swept };
|
|
106
|
+
},
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
108
|
+
async head(scope, ref) {
|
|
109
|
+
const row = liveRow(scope, ref);
|
|
110
|
+
if (row === undefined)
|
|
111
|
+
return null;
|
|
112
|
+
row.lastAccessedAt = now();
|
|
113
|
+
return row.meta;
|
|
114
|
+
},
|
|
115
|
+
async get(scope, ref) {
|
|
116
|
+
const row = liveRow(scope, ref);
|
|
117
|
+
if (row === undefined)
|
|
118
|
+
return null;
|
|
119
|
+
row.lastAccessedAt = now();
|
|
120
|
+
const data = (0, payload_js_1.decodeArtifactData)(row.payload);
|
|
121
|
+
if (row.meta.digest !== undefined) {
|
|
122
|
+
const actual = await (0, payload_js_1.computeArtifactDigest)(data);
|
|
123
|
+
if (actual !== row.meta.digest) {
|
|
124
|
+
throw new types_js_1.ArtifactIntegrityError(row.meta.ref, row.meta.digest, actual);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { meta: row.meta, data };
|
|
128
|
+
},
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
130
|
+
async delete(scope, ref) {
|
|
131
|
+
if (!(0, naming_js_1.isArtifactRef)(ref))
|
|
132
|
+
return;
|
|
133
|
+
shelf(scope).delete(ref);
|
|
134
|
+
},
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
136
|
+
async list(scope, listOptions) {
|
|
137
|
+
const at = now();
|
|
138
|
+
const held = shelf(scope);
|
|
139
|
+
// Sweep-on-access: an expired row is "no data" everywhere, lists included.
|
|
140
|
+
for (const [ref, row] of held) {
|
|
141
|
+
if (row.meta.expiresAt !== undefined && row.meta.expiresAt <= at)
|
|
142
|
+
held.delete(ref);
|
|
143
|
+
}
|
|
144
|
+
const all = [...held.values()]
|
|
145
|
+
.map((row) => row.meta)
|
|
146
|
+
.sort((a, b) => b.createdAt - a.createdAt || (a.ref < b.ref ? -1 : 1));
|
|
147
|
+
const offset = decodeCursor(listOptions?.cursor);
|
|
148
|
+
const limit = Math.max(1, Math.floor(listOptions?.limit ?? 50));
|
|
149
|
+
const page = all.slice(offset, offset + limit);
|
|
150
|
+
const nextOffset = offset + page.length;
|
|
151
|
+
return {
|
|
152
|
+
artifacts: page,
|
|
153
|
+
...(nextOffset < all.length && { cursor: String(nextOffset) }),
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
exports.inMemoryArtifacts = inMemoryArtifacts;
|
|
159
|
+
function decodeCursor(cursor) {
|
|
160
|
+
if (cursor === undefined)
|
|
161
|
+
return 0;
|
|
162
|
+
const parsed = Number(cursor);
|
|
163
|
+
return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : 0;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=inMemoryArtifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inMemoryArtifacts.js","sourceRoot":"","sources":["../../src/artifacts/inMemoryArtifacts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,0DAAgE;AAChE,6CAA+C;AAC/C,2CAA4C;AAC5C,6CAKsB;AACtB,iDAKwB;AACxB,yCAWoB;AAEpB,+EAA+E;AAClE,QAAA,oCAAoC,GAE7C;IACF,wDAAwD;IACxD,gBAAgB,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAClC,+BAA+B;IAC/B,gBAAgB,EAAE,GAAG;CACtB,CAAC;AAkCF;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,UAAoC,EAAE;IACtE,IAAA,8BAAe,EAAC,mBAAmB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,SAAS,GAAsB;QACnC,GAAG,4CAAoC;QACvC,GAAG,OAAO,CAAC,SAAS;KACrB,CAAC;IACF,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC;IACrC,8EAA8E;IAC9E,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4C,CAAC;IACnE,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,CAAC,KAAoB,EAAoC,EAAE;QACvE,MAAM,EAAE,GAAG,IAAA,4BAAiB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAI,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;I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AAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* artifacts — barrel.
|
|
4
|
+
*
|
|
5
|
+
* The claim-check store: shapes + the five-verb port (`types`), the ref
|
|
6
|
+
* grammar (`naming`), the payload laws (`payload`), the eviction law
|
|
7
|
+
* (`retention`), the shared put pipeline (`minting`), three adapters, and
|
|
8
|
+
* the `ctx.artifacts` capability (`capability`). See README.md in this
|
|
9
|
+
* folder for the one-job map and the import direction.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.unconfiguredArtifacts = exports.bindArtifacts = exports.UnreadableArtifactStoreError = exports.sqliteArtifacts = exports.UnreadableArtifactFileError = exports.fileArtifacts = exports.DEFAULT_IN_MEMORY_ARTIFACT_RETENTION = exports.inMemoryArtifacts = exports.mintArtifactRef = exports.isArtifactRef = exports.ARTIFACT_REF_PREFIX = exports.UnknownParentRefError = exports.InvalidArtifactError = exports.ArtifactIntegrityError = void 0;
|
|
13
|
+
var types_js_1 = require("./types.js");
|
|
14
|
+
Object.defineProperty(exports, "ArtifactIntegrityError", { enumerable: true, get: function () { return types_js_1.ArtifactIntegrityError; } });
|
|
15
|
+
Object.defineProperty(exports, "InvalidArtifactError", { enumerable: true, get: function () { return types_js_1.InvalidArtifactError; } });
|
|
16
|
+
Object.defineProperty(exports, "UnknownParentRefError", { enumerable: true, get: function () { return types_js_1.UnknownParentRefError; } });
|
|
17
|
+
var naming_js_1 = require("./naming.js");
|
|
18
|
+
Object.defineProperty(exports, "ARTIFACT_REF_PREFIX", { enumerable: true, get: function () { return naming_js_1.ARTIFACT_REF_PREFIX; } });
|
|
19
|
+
Object.defineProperty(exports, "isArtifactRef", { enumerable: true, get: function () { return naming_js_1.isArtifactRef; } });
|
|
20
|
+
Object.defineProperty(exports, "mintArtifactRef", { enumerable: true, get: function () { return naming_js_1.mintArtifactRef; } });
|
|
21
|
+
var inMemoryArtifacts_js_1 = require("./inMemoryArtifacts.js");
|
|
22
|
+
Object.defineProperty(exports, "inMemoryArtifacts", { enumerable: true, get: function () { return inMemoryArtifacts_js_1.inMemoryArtifacts; } });
|
|
23
|
+
Object.defineProperty(exports, "DEFAULT_IN_MEMORY_ARTIFACT_RETENTION", { enumerable: true, get: function () { return inMemoryArtifacts_js_1.DEFAULT_IN_MEMORY_ARTIFACT_RETENTION; } });
|
|
24
|
+
var fileArtifacts_js_1 = require("./fileArtifacts.js");
|
|
25
|
+
Object.defineProperty(exports, "fileArtifacts", { enumerable: true, get: function () { return fileArtifacts_js_1.fileArtifacts; } });
|
|
26
|
+
Object.defineProperty(exports, "UnreadableArtifactFileError", { enumerable: true, get: function () { return fileArtifacts_js_1.UnreadableArtifactFileError; } });
|
|
27
|
+
var sqliteArtifacts_js_1 = require("./sqliteArtifacts.js");
|
|
28
|
+
Object.defineProperty(exports, "sqliteArtifacts", { enumerable: true, get: function () { return sqliteArtifacts_js_1.sqliteArtifacts; } });
|
|
29
|
+
Object.defineProperty(exports, "UnreadableArtifactStoreError", { enumerable: true, get: function () { return sqliteArtifacts_js_1.UnreadableArtifactStoreError; } });
|
|
30
|
+
var capability_js_1 = require("./capability.js");
|
|
31
|
+
Object.defineProperty(exports, "bindArtifacts", { enumerable: true, get: function () { return capability_js_1.bindArtifacts; } });
|
|
32
|
+
Object.defineProperty(exports, "unconfiguredArtifacts", { enumerable: true, get: function () { return capability_js_1.unconfiguredArtifacts; } });
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/artifacts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,uCAgBoB;AAflB,kHAAA,sBAAsB,OAAA;AACtB,gHAAA,oBAAoB,OAAA;AACpB,iHAAA,qBAAqB,OAAA;AAcvB,yCAAkF;AAAzE,gHAAA,mBAAmB,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,4GAAA,eAAe,OAAA;AAE5D,+DAKgC;AAJ9B,yHAAA,iBAAiB,OAAA;AACjB,4IAAA,oCAAoC,OAAA;AAItC,uDAI4B;AAH1B,iHAAA,aAAa,OAAA;AACb,+HAAA,2BAA2B,OAAA;AAG7B,2DAK8B;AAJ5B,qHAAA,eAAe,OAAA;AACf,kIAAA,4BAA4B,OAAA;AAI9B,iDAUyB;AATvB,8GAAA,aAAa,OAAA;AACb,sHAAA,qBAAqB,OAAA"}
|