stitchkit 0.103.8 → 0.103.10
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/CHANGELOG.md +21 -0
- package/dist/agent-runtime/sandbox-process.d.ts +2 -2
- package/dist/agent-runtime/sandbox-process.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
- package/dist/durability/contract.d.ts +3 -2
- package/dist/durability/contract.d.ts.map +1 -1
- package/dist/durability/effect.d.ts.map +1 -1
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/json.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/harness.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +29 -81
- package/dist/entrypoints/agent-runtime.js +2 -2
- package/dist/entrypoints/application/diagnostic-journal.js +2 -1
- package/dist/entrypoints/cli.js +1 -1
- package/dist/entrypoints/files.d.ts +2 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +14 -6
- package/dist/entrypoints/primitives.js +77 -57
- package/dist/entrypoints/process.d.ts +5 -0
- package/dist/entrypoints/process.d.ts.map +1 -0
- package/dist/entrypoints/process.js +20 -0
- package/dist/entrypoints/tools.js +12 -3
- package/dist/files/boundary.d.ts +19 -1
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +5 -1
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/read.d.ts +13 -0
- package/dist/files/read.d.ts.map +1 -0
- package/dist/index-12m2v2a9.js +98 -0
- package/dist/index-6m6a9ty4.js +285 -0
- package/dist/index-8a9ksm91.js +95 -0
- package/dist/{index-90ppdx3q.js → index-9jb61j5a.js} +1 -1
- package/dist/{index-5vyd0fkb.js → index-ary5s7k0.js} +40 -61
- package/dist/index-c1jmtxa0.js +74 -0
- package/dist/index-ga597cvy.js +184 -0
- package/dist/index-mbnnw3f2.js +25 -0
- package/dist/index-nybn2err.js +213 -0
- package/dist/{index-v4a2fjtk.js → index-sybedc8b.js} +124 -55
- package/dist/internal/abort-race.d.ts +3 -0
- package/dist/internal/abort-race.d.ts.map +1 -0
- package/dist/internal/atomic-file.d.ts +20 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/atomic-publication.d.ts +19 -0
- package/dist/internal/atomic-publication.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +2 -1
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/json-data.d.ts +8 -0
- package/dist/internal/json-data.d.ts.map +1 -0
- package/dist/internal/process-instance.d.ts +46 -9
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +4 -3
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/primitives/canonical-json.d.ts +11 -0
- package/dist/primitives/canonical-json.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts +13 -0
- package/dist/process/command-owner.d.ts.map +1 -0
- package/dist/process/command.d.ts +3 -0
- package/dist/process/command.d.ts.map +1 -0
- package/dist/process/contract.d.ts +45 -0
- package/dist/process/contract.d.ts.map +1 -0
- package/dist/process/group.d.ts +6 -0
- package/dist/process/group.d.ts.map +1 -0
- package/dist/process/leader-settlement.d.ts +4 -0
- package/dist/process/leader-settlement.d.ts.map +1 -0
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -1
- package/llms/files.txt +9 -1
- package/llms/primitives.txt +31 -1
- package/llms/process.txt +242 -0
- package/llms/stitchkit.txt +1 -0
- package/llms/tools.txt +18 -0
- package/llms-full.txt +292 -2
- package/llms.txt +6 -4
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/package.json +5 -1
- package/dist/index-7kxw1awn.js +0 -328
- package/dist/index-aan6hqb9.js +0 -65
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,27 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.103.10] - 2026-10-01
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `stitchkit/process`: `onLeaderSettled` observes launcher exit before inherited-pipe drain and settles resource scopes once on terminal failure; callbacks have bounded cancellation and preserve initial causes. Public process identity observation/probing preserves unavailable evidence and its cause from the existing Linux/Darwin owner.
|
|
23
|
+
- `stitchkit/files`: `ownerlessGraceMs: null` explicitly refuses age-based reclaim of unknown locks and guards; exact requested lock permissions survive restrictive umask, and failed descriptor setup cannot remove a replacement inode.
|
|
24
|
+
- Document and qualify neutral library bundling from public imports and published declarations with Zod as its only runtime peer; full-kernel install remains a build-time choice.
|
|
25
|
+
|
|
26
|
+
## [0.103.9] - 2026-10-01
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- `stitchkit/files`: atomic create without replacement, explicit file/directory durability, publication-aware errors and opt-in strict descriptor reads with observed metadata.
|
|
31
|
+
- `stitchkit/primitives`: bounded production `canonicalJson` preserving historical UTF-16 sorted bytes. Public surface ceiling grows by two names for the serializer and inferred options; files grows by the publication error and metadata type.
|
|
32
|
+
- `stitchkit/process`: evolving POSIX Node/Bun one-shot command leaf with binary sinks, bounded capture, explicit environment policy and cancellation independent of the agent runtime (four public names; ADR 0224).
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- Effect reconciliation releases caller waits on cancellation and ignores late results, including independently cancelled coalesced observers; document the external execution lease required across processes. Historical sticky uncertain remains unchanged; automatic absence-based retries require recipient authority.
|
|
37
|
+
- Managed reads preserve the primary error when descriptor cleanup also fails. Native command and reconciliation deadlines refuse timer overflow instead of silently firing after 1 ms.
|
|
38
|
+
|
|
18
39
|
## [0.103.8] - 2026-10-01
|
|
19
40
|
|
|
20
41
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
import { type SandboxProcess, type SandboxRunOptions } from './sandbox-contract.js';
|
|
3
|
-
/**
|
|
3
|
+
/** Sandbox admission and mandatory caps adapt the shared native command owner. */
|
|
4
4
|
export declare function spawnSandboxProcess(executable: string, args: string[], limits: {
|
|
5
5
|
timeoutMs: number;
|
|
6
6
|
maxOutputBytes: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-process.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sandbox-process.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAGzE,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,GAAE,iBAAsB,EAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,GACxD,cAAc,CA8ChB"}
|
|
@@ -133,6 +133,11 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
133
133
|
parts: ({
|
|
134
134
|
type: "text";
|
|
135
135
|
text: string;
|
|
136
|
+
} | {
|
|
137
|
+
type: "file";
|
|
138
|
+
mediaType: string;
|
|
139
|
+
reference: string;
|
|
140
|
+
filename?: string | undefined;
|
|
136
141
|
} | {
|
|
137
142
|
type: "reasoning";
|
|
138
143
|
text: string;
|
|
@@ -141,11 +146,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
141
146
|
provider: string;
|
|
142
147
|
data: Record<string, import("zod").JSONType>;
|
|
143
148
|
} | undefined;
|
|
144
|
-
} | {
|
|
145
|
-
type: "file";
|
|
146
|
-
mediaType: string;
|
|
147
|
-
reference: string;
|
|
148
|
-
filename?: string | undefined;
|
|
149
149
|
} | {
|
|
150
150
|
type: "source";
|
|
151
151
|
sourceId: string;
|
|
@@ -313,6 +313,11 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
313
313
|
parts: ({
|
|
314
314
|
type: "text";
|
|
315
315
|
text: string;
|
|
316
|
+
} | {
|
|
317
|
+
type: "file";
|
|
318
|
+
mediaType: string;
|
|
319
|
+
reference: string;
|
|
320
|
+
filename?: string | undefined;
|
|
316
321
|
} | {
|
|
317
322
|
type: "reasoning";
|
|
318
323
|
text: string;
|
|
@@ -321,11 +326,6 @@ export declare function fencingPhase(store: AgentRuntimeStore, conversationId: s
|
|
|
321
326
|
provider: string;
|
|
322
327
|
data: Record<string, import("zod").JSONType>;
|
|
323
328
|
} | undefined;
|
|
324
|
-
} | {
|
|
325
|
-
type: "file";
|
|
326
|
-
mediaType: string;
|
|
327
|
-
reference: string;
|
|
328
|
-
filename?: string | undefined;
|
|
329
329
|
} | {
|
|
330
330
|
type: "source";
|
|
331
331
|
sourceId: string;
|
|
@@ -119,8 +119,9 @@ export type EffectOutcome<P> = {
|
|
|
119
119
|
export interface EffectHandlers<P> {
|
|
120
120
|
/**
|
|
121
121
|
* Perform the effect, once, and return what the recipient named it — a
|
|
122
|
-
* message id, a turn id. Called at most once per name
|
|
123
|
-
*
|
|
122
|
+
* message id, a turn id. Called at most once per name while a caller-owned exclusive execution lease
|
|
123
|
+
* fences this conversation/run. Sharing a ledger alone is not an atomic claim;
|
|
124
|
+
* standalone callers must provide that lease across processes/port objects.
|
|
124
125
|
*/
|
|
125
126
|
run(): P | Promise<P>;
|
|
126
127
|
/**
|
|
@@ -1 +1 @@
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qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,QAAQ,EAAE,MAAM,EAG3B;CACF;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,MAAM,EACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB;IANtB,YACW,UAAU,EAAE,MAAM,EAClB,MAAM,EACX,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,EACpB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAI9B;CACF;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGzD;CACF;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,IAAI,EAAE,MAAM,EAGvB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/durability/effect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../src/durability/effect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAGrB,KAAK,oBAAoB,EAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,oBAAoB,EAA+B,MAAM,UAAU,CAAC;AAMlF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC7C;AAED,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAuFhD,wBAAsB,aAAa,CAAC,CAAC,SAAS,KAAK,EACjD,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,gBAAgB,GAAG,SAAS,GACpC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA0B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/durability/engine.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/durability/engine.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAGhC,MAAM,YAAY,CAAC;AAepB,YAAY,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAmBpB;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,CA+LrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/durability/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/durability/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB,qCAS7B,CAAC"}
|
|
@@ -5,7 +5,7 @@ import"../../index-8kzct1d6.js";
|
|
|
5
5
|
import {
|
|
6
6
|
composeAgentPrompt2,
|
|
7
7
|
createAgentRuntime2
|
|
8
|
-
} from "../../index-
|
|
8
|
+
} from "../../index-9jb61j5a.js";
|
|
9
9
|
import"../../index-h97tqqp1.js";
|
|
10
10
|
import"../../index-mnkk1ffz.js";
|
|
11
11
|
import"../../index-n53mswt3.js";
|
|
@@ -15,7 +15,7 @@ import"../../index-9pw0a51a.js";
|
|
|
15
15
|
import"../../index-ct75c3at.js";
|
|
16
16
|
import"../../index-x87j7csh.js";
|
|
17
17
|
import"../../index-m2xqkv55.js";
|
|
18
|
-
import"../../index-
|
|
18
|
+
import"../../index-ary5s7k0.js";
|
|
19
19
|
import"../../index-nggfa2yn.js";
|
|
20
20
|
import"../../index-r5hsgkz5.js";
|
|
21
21
|
import"../../index-n5yqxd3d.js";
|
|
@@ -10,6 +10,10 @@ import"../../index-b2bz0kdm.js";
|
|
|
10
10
|
import {
|
|
11
11
|
createAgentCodingTools2
|
|
12
12
|
} from "../../index-a4ajxwmb.js";
|
|
13
|
+
import {
|
|
14
|
+
NativeCommandError2,
|
|
15
|
+
startNativeCommand
|
|
16
|
+
} from "../../index-6m6a9ty4.js";
|
|
13
17
|
import"../../index-tgzhq07n.js";
|
|
14
18
|
|
|
15
19
|
// src/agent-runtime/sandbox-bubblewrap.ts
|
|
@@ -503,95 +507,39 @@ function createSandboxCodingAdapter(input) {
|
|
|
503
507
|
}
|
|
504
508
|
|
|
505
509
|
// src/agent-runtime/sandbox-process.ts
|
|
506
|
-
import { spawn } from "node:child_process";
|
|
507
510
|
function spawnSandboxProcess(executable, args, limits, options = {}, onSpawn) {
|
|
508
|
-
|
|
509
|
-
|
|
511
|
+
const command = startNativeCommand({
|
|
512
|
+
executable,
|
|
513
|
+
args,
|
|
514
|
+
timeoutMs: limits.timeoutMs,
|
|
515
|
+
maxOutputBytes: limits.maxOutputBytes,
|
|
516
|
+
signal: options.signal,
|
|
517
|
+
capture: true,
|
|
518
|
+
envPolicy: "declared-only",
|
|
510
519
|
env: {},
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
} catch (error) {
|
|
526
|
-
if (!(error instanceof Error && ("code" in error) && error.code === "ESRCH"))
|
|
527
|
-
failure ??= error;
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
const abort = () => {
|
|
531
|
-
failure ??= options.signal?.reason ?? new Error("Sandbox command aborted");
|
|
532
|
-
kill();
|
|
533
|
-
};
|
|
534
|
-
const timer = setTimeout(() => {
|
|
535
|
-
failure ??= new SandboxError("SANDBOX_LIMIT", "Sandbox command deadline exceeded");
|
|
536
|
-
kill();
|
|
537
|
-
}, limits.timeoutMs);
|
|
538
|
-
timer.unref();
|
|
539
|
-
const result = new Promise((resolve, reject) => {
|
|
540
|
-
const collect = (target) => (chunk) => {
|
|
541
|
-
bytes += chunk.byteLength;
|
|
542
|
-
if (bytes > limits.maxOutputBytes) {
|
|
543
|
-
failure ??= new SandboxError("SANDBOX_LIMIT", "Sandbox output limit exceeded");
|
|
544
|
-
kill();
|
|
545
|
-
} else
|
|
546
|
-
target.push(chunk);
|
|
547
|
-
};
|
|
548
|
-
child.stdout.on("data", collect(stdout));
|
|
549
|
-
child.stderr.on("data", collect(stderr));
|
|
550
|
-
child.on("error", (error) => {
|
|
551
|
-
failure ??= new SandboxError("SANDBOX_UNAVAILABLE", "Sandbox process could not start", { cause: error });
|
|
552
|
-
});
|
|
553
|
-
child.stdin.on("error", (error) => {
|
|
554
|
-
if (!(("code" in error) && error.code === "EPIPE")) {
|
|
555
|
-
failure ??= error;
|
|
556
|
-
kill();
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
child.on("close", (code) => {
|
|
560
|
-
finished = true;
|
|
561
|
-
clearTimeout(timer);
|
|
562
|
-
options.signal?.removeEventListener("abort", abort);
|
|
563
|
-
if (failure !== undefined)
|
|
564
|
-
reject(failure);
|
|
565
|
-
else
|
|
566
|
-
resolve({
|
|
567
|
-
exitCode: code ?? 137,
|
|
568
|
-
stdout: Buffer.concat(stdout),
|
|
569
|
-
stderr: Buffer.concat(stderr)
|
|
570
|
-
});
|
|
571
|
-
});
|
|
520
|
+
killGraceMs: 0,
|
|
521
|
+
...options.stdin !== undefined ? {
|
|
522
|
+
stdin: typeof options.stdin === "string" ? new TextEncoder().encode(options.stdin) : options.stdin,
|
|
523
|
+
maxStdinBytes: Math.max(1, typeof options.stdin === "string" ? Buffer.byteLength(options.stdin) : options.stdin.byteLength)
|
|
524
|
+
} : {}
|
|
525
|
+
}, onSpawn);
|
|
526
|
+
const result = command.result.then((result) => ({
|
|
527
|
+
exitCode: result.exitCode ?? 137,
|
|
528
|
+
stdout: result.stdout,
|
|
529
|
+
stderr: result.stderr
|
|
530
|
+
})).catch((error) => {
|
|
531
|
+
if (error instanceof NativeCommandError2)
|
|
532
|
+
throw new SandboxError(error.code === "COMMAND_LIMIT" ? "SANDBOX_LIMIT" : "SANDBOX_UNAVAILABLE", error.message, { cause: error });
|
|
533
|
+
throw error;
|
|
572
534
|
});
|
|
573
535
|
result.catch(() => {
|
|
574
536
|
return;
|
|
575
537
|
});
|
|
576
|
-
|
|
577
|
-
if (options.signal?.aborted)
|
|
578
|
-
abort();
|
|
579
|
-
child.stdin.end(options.stdin);
|
|
580
|
-
return {
|
|
581
|
-
result,
|
|
582
|
-
async stop() {
|
|
583
|
-
kill();
|
|
584
|
-
await result.then(() => {
|
|
585
|
-
return;
|
|
586
|
-
}, () => {
|
|
587
|
-
return;
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
};
|
|
538
|
+
return { result, stop: command.stop };
|
|
591
539
|
}
|
|
592
540
|
|
|
593
541
|
// src/agent-runtime/sandbox-process-owner.ts
|
|
594
|
-
import { spawn
|
|
542
|
+
import { spawn } from "node:child_process";
|
|
595
543
|
function sandboxProcessOwner(assertActive, maximum) {
|
|
596
544
|
const children = new Map;
|
|
597
545
|
const admit = () => {
|
|
@@ -616,7 +564,7 @@ function sandboxProcessOwner(assertActive, maximum) {
|
|
|
616
564
|
},
|
|
617
565
|
spawn(input) {
|
|
618
566
|
admit();
|
|
619
|
-
const child =
|
|
567
|
+
const child = spawn(input.executable, [...input.args], {
|
|
620
568
|
cwd: input.cwd,
|
|
621
569
|
env: input.environment,
|
|
622
570
|
detached: true,
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
agentGoalStateSlot2,
|
|
111
111
|
agentTodoStateSlot2,
|
|
112
112
|
createAgentRuntime2
|
|
113
|
-
} from "../index-
|
|
113
|
+
} from "../index-9jb61j5a.js";
|
|
114
114
|
import {
|
|
115
115
|
AgentConversationSummarySchema2,
|
|
116
116
|
AgentConversationPageSchema2,
|
|
@@ -175,7 +175,7 @@ import {
|
|
|
175
175
|
StepAbortedError2,
|
|
176
176
|
ParkRecordDecodeError2,
|
|
177
177
|
ParkAbortedError2
|
|
178
|
-
} from "../index-
|
|
178
|
+
} from "../index-ary5s7k0.js";
|
|
179
179
|
import {
|
|
180
180
|
AgentSandboxRestrictionSchema2,
|
|
181
181
|
AgentSandboxGradeSchema2,
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
createBoundedChannel2
|
|
16
16
|
} from "../../index-w0eqdhyd.js";
|
|
17
|
+
import"../../index-nybn2err.js";
|
|
17
18
|
import {
|
|
18
19
|
attemptExclusiveLock
|
|
19
|
-
} from "../../index-
|
|
20
|
+
} from "../../index-ga597cvy.js";
|
|
20
21
|
import {
|
|
21
22
|
isRecord
|
|
22
23
|
} from "../../index-9jfdm5tg.js";
|
package/dist/entrypoints/cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { type ManagedFilePath, ManagedFilePathSchema, type ManagedFileRef, ManagedFileRefSchema, } from '../contract/file-ref.js';
|
|
2
|
+
export type { FileObservation } from '../files/boundary.js';
|
|
2
3
|
export { createManagedFileBoundary, type ManagedFileBoundary, type ManagedFileBoundaryConfig, ManagedFileError, type ManagedFileErrorCode, type ManagedFileInspection, type ManagedFileInspectionInput, type ManagedFileInspector, type ManagedFileReadOptions, type ManagedFileSource, type ManagedFileWriteOptions, } from '../files/boundary.js';
|
|
3
4
|
export { CHUNK_SPOOL_ERROR_CODES, type ChunkSpool, type ChunkSpoolAssembly, type ChunkSpoolConfig, type ChunkSpoolErrorCode, type ChunkSpoolKey, type ChunkSpoolOpen, type ChunkSpoolPart, createChunkSpool, isChunkSpoolErrorCode, } from '../files/chunk-spool.js';
|
|
4
5
|
export { type WriteFileAtomicOptions, writeFileAtomic, writeFileAtomicSync, } from '../internal/atomic-file.js';
|
|
6
|
+
export { AtomicFilePublicationError } from '../internal/atomic-publication.js';
|
|
5
7
|
export { type ExclusiveLock, ExclusiveLockError, type ExclusiveLockOptions, type ExclusiveLockOwner, withExclusiveLock, } from '../internal/with-exclusive-lock.js';
|
|
6
8
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/entrypoints/files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,EACf,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/entrypoints/files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,cAAc,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,KAAK,sBAAsB,EAC3B,eAAe,EACf,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EACL,KAAK,aAAa,EAClB,kBAAkB,EAClB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC"}
|
|
@@ -5,17 +5,21 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
ManagedFileError2,
|
|
7
7
|
createManagedFileBoundary2
|
|
8
|
-
} from "../index-
|
|
8
|
+
} from "../index-sybedc8b.js";
|
|
9
9
|
import {
|
|
10
10
|
AppError2
|
|
11
11
|
} from "../index-n53mswt3.js";
|
|
12
|
+
import"../index-nybn2err.js";
|
|
12
13
|
import {
|
|
13
14
|
attemptExclusiveLock
|
|
14
|
-
} from "../index-
|
|
15
|
+
} from "../index-ga597cvy.js";
|
|
15
16
|
import {
|
|
16
17
|
writeFileAtomic2,
|
|
17
18
|
writeFileAtomicSync2
|
|
18
|
-
} from "../index-
|
|
19
|
+
} from "../index-12m2v2a9.js";
|
|
20
|
+
import {
|
|
21
|
+
AtomicFilePublicationError2
|
|
22
|
+
} from "../index-8a9ksm91.js";
|
|
19
23
|
// src/files/chunk-spool.ts
|
|
20
24
|
import { createHash, randomBytes } from "node:crypto";
|
|
21
25
|
import {
|
|
@@ -297,7 +301,10 @@ function pause(ms, signal) {
|
|
|
297
301
|
async function withExclusiveLock(path, run, options = {}) {
|
|
298
302
|
const label = options.label ?? path;
|
|
299
303
|
const timeoutMs = nonNegative("timeoutMs", options.timeoutMs, DEFAULT_TIMEOUT_MS);
|
|
300
|
-
const ownerlessGraceMs = nonNegative("ownerlessGraceMs", options.ownerlessGraceMs, DEFAULT_OWNERLESS_GRACE_MS);
|
|
304
|
+
const ownerlessGraceMs = options.ownerlessGraceMs === null ? null : nonNegative("ownerlessGraceMs", options.ownerlessGraceMs, DEFAULT_OWNERLESS_GRACE_MS);
|
|
305
|
+
const mode = options.mode ?? 384;
|
|
306
|
+
if (!Number.isInteger(mode) || mode < 0 || mode > 511)
|
|
307
|
+
throw new RangeError("[stitchkit] withExclusiveLock: mode must be permission bits from 0000 to 0777");
|
|
301
308
|
const { signal } = options;
|
|
302
309
|
const deadline = performance.now() + timeoutMs;
|
|
303
310
|
let delay = FIRST_RETRY_MS;
|
|
@@ -306,7 +313,7 @@ async function withExclusiveLock(path, run, options = {}) {
|
|
|
306
313
|
throw new ExclusiveLockError("LOCK_ABORTED", label, null, `[stitchkit] waiting for the lock on "${label}" was cancelled`, { cause: signal.reason });
|
|
307
314
|
}
|
|
308
315
|
const attempt = await attemptExclusiveLock(path, {
|
|
309
|
-
mode
|
|
316
|
+
mode,
|
|
310
317
|
reclaim: true,
|
|
311
318
|
ownerlessGraceMs,
|
|
312
319
|
...options.machineIdentity !== undefined && {
|
|
@@ -330,13 +337,14 @@ async function withExclusiveLock(path, run, options = {}) {
|
|
|
330
337
|
const remaining = deadline - performance.now();
|
|
331
338
|
if (remaining <= 0) {
|
|
332
339
|
const holder = attempt.diagnosis?.owner ?? null;
|
|
333
|
-
throw new ExclusiveLockError("LOCK_TIMEOUT", label, holder, `[stitchkit] the lock on "${label}" is held by ${describeHolder(holder)}${describeEvidence(attempt.diagnosis)}; gave up after ${timeoutMs} ms`, { cause: attempt.error });
|
|
340
|
+
throw new ExclusiveLockError("LOCK_TIMEOUT", label, holder, `[stitchkit] the lock on "${label}" is held by ${describeHolder(holder)}${describeEvidence(attempt.diagnosis)}; gave up after ${timeoutMs} ms`, { cause: attempt.diagnosis?.cause ?? attempt.error });
|
|
334
341
|
}
|
|
335
342
|
await pause(Math.min(delay * (0.5 + Math.random() / 2), remaining), signal);
|
|
336
343
|
delay = Math.min(delay * 2, MAX_RETRY_MS);
|
|
337
344
|
}
|
|
338
345
|
}
|
|
339
346
|
export {
|
|
347
|
+
AtomicFilePublicationError2 as AtomicFilePublicationError,
|
|
340
348
|
CHUNK_SPOOL_ERROR_CODES,
|
|
341
349
|
ExclusiveLockError,
|
|
342
350
|
ManagedFileError2 as ManagedFileError,
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ManagedFileRefSchema2
|
|
3
3
|
} from "../index-xqhede6x.js";
|
|
4
|
+
import {
|
|
5
|
+
isJsonData
|
|
6
|
+
} from "../index-c1jmtxa0.js";
|
|
7
|
+
import {
|
|
8
|
+
serializeCanonicalJson
|
|
9
|
+
} from "../index-zsvzhjtk.js";
|
|
4
10
|
|
|
5
11
|
// src/primitives/audit.ts
|
|
6
12
|
import { z as z2 } from "zod";
|
|
@@ -76,14 +82,27 @@ function createAuditRecord(input) {
|
|
|
76
82
|
payload: { operation: input.operation, change }
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
|
-
// src/primitives/
|
|
85
|
+
// src/primitives/canonical-json.ts
|
|
80
86
|
import { z as z3 } from "zod";
|
|
87
|
+
var CanonicalJsonOptionsSchema = z3.strictObject({
|
|
88
|
+
maxDepth: z3.number().int().min(0).max(100).default(100),
|
|
89
|
+
maxNodes: z3.number().int().positive().default(1e5),
|
|
90
|
+
maxBytes: z3.number().int().positive().default(1024 * 1024)
|
|
91
|
+
});
|
|
92
|
+
function canonicalJson(value, options = {}) {
|
|
93
|
+
const limits = CanonicalJsonOptionsSchema.parse(options);
|
|
94
|
+
if (!isJsonData(value, { ...limits, omitObjectUndefined: true }))
|
|
95
|
+
throw new TypeError("Expected bounded plain JSON: dense arrays, finite numbers, no -0, cycles or accessors");
|
|
96
|
+
return serializeCanonicalJson(value);
|
|
97
|
+
}
|
|
98
|
+
// src/primitives/deadline.ts
|
|
99
|
+
import { z as z4 } from "zod";
|
|
81
100
|
var DAY_MS = 86400000;
|
|
82
|
-
var DeadlineResultSchema =
|
|
83
|
-
dueAt:
|
|
84
|
-
remainingDays:
|
|
85
|
-
overdueDays:
|
|
86
|
-
category:
|
|
101
|
+
var DeadlineResultSchema = z4.object({
|
|
102
|
+
dueAt: z4.iso.datetime({ offset: true }),
|
|
103
|
+
remainingDays: z4.number().int(),
|
|
104
|
+
overdueDays: z4.number().int().nonnegative(),
|
|
105
|
+
category: z4.string().min(1)
|
|
87
106
|
});
|
|
88
107
|
function partsInZone(value, timeZone) {
|
|
89
108
|
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
@@ -163,26 +182,26 @@ function defineDeadlinePolicy(config) {
|
|
|
163
182
|
});
|
|
164
183
|
}
|
|
165
184
|
// src/primitives/delivery.ts
|
|
166
|
-
import { z as
|
|
167
|
-
var DomainEventDestinationSchema =
|
|
168
|
-
id:
|
|
169
|
-
transport:
|
|
170
|
-
address:
|
|
185
|
+
import { z as z5 } from "zod";
|
|
186
|
+
var DomainEventDestinationSchema = z5.object({
|
|
187
|
+
id: z5.string().min(1),
|
|
188
|
+
transport: z5.string().min(1),
|
|
189
|
+
address: z5.string().min(1)
|
|
171
190
|
});
|
|
172
|
-
var DomainEventDeliveryOutcomeSchema =
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
outcome:
|
|
176
|
-
code:
|
|
177
|
-
retryAt:
|
|
191
|
+
var DomainEventDeliveryOutcomeSchema = z5.discriminatedUnion("outcome", [
|
|
192
|
+
z5.object({ outcome: z5.literal("delivered"), receipt: z5.string().min(1).optional() }),
|
|
193
|
+
z5.object({
|
|
194
|
+
outcome: z5.literal("retryable"),
|
|
195
|
+
code: z5.string().min(1),
|
|
196
|
+
retryAt: z5.iso.datetime({ offset: true })
|
|
178
197
|
}),
|
|
179
|
-
|
|
180
|
-
|
|
198
|
+
z5.object({ outcome: z5.literal("terminal"), code: z5.string().min(1) }),
|
|
199
|
+
z5.object({ outcome: z5.literal("unknown"), code: z5.string().min(1) })
|
|
181
200
|
]);
|
|
182
|
-
var DomainEventDeliveryClaimSchema =
|
|
201
|
+
var DomainEventDeliveryClaimSchema = z5.object({
|
|
183
202
|
event: DomainEventSchema,
|
|
184
203
|
destination: DomainEventDestinationSchema,
|
|
185
|
-
attempt:
|
|
204
|
+
attempt: z5.number().int().positive()
|
|
186
205
|
});
|
|
187
206
|
function defineDomainEventDelivery(config) {
|
|
188
207
|
const maxClaims = config.maxClaimsPerDispatch ?? 100;
|
|
@@ -244,17 +263,17 @@ function defineDomainEventDelivery(config) {
|
|
|
244
263
|
});
|
|
245
264
|
}
|
|
246
265
|
// src/primitives/export-operation.ts
|
|
247
|
-
import { z as
|
|
266
|
+
import { z as z6 } from "zod";
|
|
248
267
|
function createExportResultSchema(operationId) {
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
state:
|
|
268
|
+
return z6.discriminatedUnion("state", [
|
|
269
|
+
z6.object({
|
|
270
|
+
state: z6.literal("ready"),
|
|
252
271
|
file: ManagedFileRefSchema2.extend({
|
|
253
|
-
mediaType:
|
|
254
|
-
name:
|
|
272
|
+
mediaType: z6.string().min(1),
|
|
273
|
+
name: z6.string().min(1)
|
|
255
274
|
})
|
|
256
275
|
}),
|
|
257
|
-
|
|
276
|
+
z6.object({ state: z6.literal("pending"), operationId })
|
|
258
277
|
]);
|
|
259
278
|
}
|
|
260
279
|
function defineExportOperation(config) {
|
|
@@ -288,20 +307,20 @@ function defineExportOperation(config) {
|
|
|
288
307
|
});
|
|
289
308
|
}
|
|
290
309
|
// src/primitives/lifecycle.ts
|
|
291
|
-
import { z as
|
|
310
|
+
import { z as z7 } from "zod";
|
|
292
311
|
var lifecycleStateBrand = Symbol("stitchkit.lifecycle.state");
|
|
293
|
-
var LifecycleTransitionEventSchema =
|
|
294
|
-
id:
|
|
295
|
-
type:
|
|
296
|
-
occurredAt:
|
|
297
|
-
actor:
|
|
298
|
-
subject:
|
|
299
|
-
payload:
|
|
300
|
-
lifecycle:
|
|
301
|
-
transition:
|
|
302
|
-
from:
|
|
303
|
-
to:
|
|
304
|
-
data:
|
|
312
|
+
var LifecycleTransitionEventSchema = z7.object({
|
|
313
|
+
id: z7.string().min(1),
|
|
314
|
+
type: z7.literal("lifecycle.transitioned"),
|
|
315
|
+
occurredAt: z7.iso.datetime({ offset: true }),
|
|
316
|
+
actor: z7.object({ id: z7.string().min(1), role: z7.string().min(1) }),
|
|
317
|
+
subject: z7.object({ type: z7.string().min(1), id: z7.string().min(1) }),
|
|
318
|
+
payload: z7.object({
|
|
319
|
+
lifecycle: z7.string().min(1),
|
|
320
|
+
transition: z7.string().min(1),
|
|
321
|
+
from: z7.string().min(1),
|
|
322
|
+
to: z7.string().min(1),
|
|
323
|
+
data: z7.unknown()
|
|
305
324
|
})
|
|
306
325
|
});
|
|
307
326
|
function stateMatches(expected, actual) {
|
|
@@ -433,12 +452,12 @@ function scanOwnerFilterRisks(sources, ownerKeys = ["ownerId"]) {
|
|
|
433
452
|
return risks;
|
|
434
453
|
}
|
|
435
454
|
// src/primitives/money.ts
|
|
436
|
-
import { z as
|
|
437
|
-
var IntegerStringSchema =
|
|
455
|
+
import { z as z8 } from "zod";
|
|
456
|
+
var IntegerStringSchema = z8.string().regex(/^-?(?:0|[1-9]\d*)$/);
|
|
438
457
|
function createMoneySchema(currency) {
|
|
439
|
-
return
|
|
458
|
+
return z8.object({
|
|
440
459
|
minor: IntegerStringSchema,
|
|
441
|
-
currency:
|
|
460
|
+
currency: z8.literal(currency)
|
|
442
461
|
});
|
|
443
462
|
}
|
|
444
463
|
function parseMinor(value) {
|
|
@@ -577,7 +596,7 @@ function definePermissionMatrix(config) {
|
|
|
577
596
|
});
|
|
578
597
|
}
|
|
579
598
|
// src/primitives/quantity.ts
|
|
580
|
-
import { z as
|
|
599
|
+
import { z as z9 } from "zod";
|
|
581
600
|
|
|
582
601
|
// src/primitives/decimal.ts
|
|
583
602
|
var DECIMAL_PATTERN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;
|
|
@@ -631,7 +650,7 @@ function multiplyDecimalRatio(value, numerator, denominator) {
|
|
|
631
650
|
}
|
|
632
651
|
|
|
633
652
|
// src/primitives/quantity.ts
|
|
634
|
-
var DecimalStringSchema =
|
|
653
|
+
var DecimalStringSchema = z9.string().refine((value) => {
|
|
635
654
|
try {
|
|
636
655
|
return formatDecimal(parseDecimal(value)) === value;
|
|
637
656
|
} catch {
|
|
@@ -639,7 +658,7 @@ var DecimalStringSchema = z8.string().refine((value) => {
|
|
|
639
658
|
}
|
|
640
659
|
}, "expected a canonical decimal string");
|
|
641
660
|
function createQuantitySchema(unit) {
|
|
642
|
-
return
|
|
661
|
+
return z9.object({ value: DecimalStringSchema, unit: z9.literal(unit) });
|
|
643
662
|
}
|
|
644
663
|
function quantity(value, unit) {
|
|
645
664
|
return Object.freeze({ value: formatDecimal(parseDecimal(value)), unit });
|
|
@@ -653,16 +672,16 @@ function addQuantity(left, right) {
|
|
|
653
672
|
}
|
|
654
673
|
return quantity(formatDecimal(addDecimal(parseDecimal(left.value), parseDecimal(right.value))), left.unit);
|
|
655
674
|
}
|
|
656
|
-
var QuantityProjectionSchema =
|
|
657
|
-
|
|
658
|
-
kind:
|
|
659
|
-
quantity:
|
|
675
|
+
var QuantityProjectionSchema = z9.discriminatedUnion("kind", [
|
|
676
|
+
z9.object({
|
|
677
|
+
kind: z9.literal("recorded"),
|
|
678
|
+
quantity: z9.object({ value: DecimalStringSchema, unit: z9.string().min(1) })
|
|
660
679
|
}),
|
|
661
|
-
|
|
662
|
-
kind:
|
|
663
|
-
quantity:
|
|
664
|
-
source:
|
|
665
|
-
conversionId:
|
|
680
|
+
z9.object({
|
|
681
|
+
kind: z9.literal("derived"),
|
|
682
|
+
quantity: z9.object({ value: DecimalStringSchema, unit: z9.string().min(1) }),
|
|
683
|
+
source: z9.object({ value: DecimalStringSchema, unit: z9.string().min(1) }),
|
|
684
|
+
conversionId: z9.string().min(1)
|
|
666
685
|
})
|
|
667
686
|
]);
|
|
668
687
|
function defineUnitSystem(config) {
|
|
@@ -727,6 +746,7 @@ export {
|
|
|
727
746
|
addQuantity,
|
|
728
747
|
assertAuditDeclared,
|
|
729
748
|
audit,
|
|
749
|
+
canonicalJson,
|
|
730
750
|
createAuditRecord,
|
|
731
751
|
createDomainEventSchema,
|
|
732
752
|
createExportResultSchema,
|