stitchkit 0.136.4 → 0.136.6
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 +14 -0
- package/dist/agent-runtime/providers/openrouter-spend.d.ts +4 -2
- package/dist/agent-runtime/providers/openrouter-spend.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +5 -5
- package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
- package/dist/entrypoints/agent-executor/claude.js +7 -7
- package/dist/entrypoints/agent-executor/codex.js +9 -9
- package/dist/entrypoints/agent-executor/testing.js +9 -9
- package/dist/entrypoints/agent-executor.js +5 -5
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
- package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
- package/dist/entrypoints/agent-runtime/testing.js +4 -4
- package/dist/entrypoints/agent-runtime.js +4 -4
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +7 -7
- package/dist/entrypoints/cli/publish.d.ts +14 -6
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +685 -30
- package/dist/entrypoints/cli.js +7 -124
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.d.ts +1 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +9 -9
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/service-host/macos.js +7 -7
- package/dist/entrypoints/service-host/work.js +6 -6
- package/dist/entrypoints/service-host.js +9 -9
- package/dist/entrypoints/spend.js +85 -15
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/tools.js +1 -1
- package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
- package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
- package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
- package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
- package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
- package/dist/index-2rs7ze0q.js +376 -0
- package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
- package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
- package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
- package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
- package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
- package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
- package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
- package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
- package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
- package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
- package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
- package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
- package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
- package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
- package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
- package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
- package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
- package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
- package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
- package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
- package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
- package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
- package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
- package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
- package/dist/internal/atomic-file-owner.d.ts +91 -0
- package/dist/internal/atomic-file-owner.d.ts.map +1 -0
- package/dist/internal/atomic-file.d.ts +29 -7
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +6 -2
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/spend/receipt-merge.d.ts +8 -4
- package/dist/spend/receipt-merge.d.ts.map +1 -1
- package/dist/spend/reconcile.d.ts +15 -2
- package/dist/spend/reconcile.d.ts.map +1 -1
- package/dist/spend/schemas.d.ts +1 -0
- package/dist/spend/schemas.d.ts.map +1 -1
- package/dist/tools/cli/distribution-config.d.ts +56 -0
- package/dist/tools/cli/distribution-config.d.ts.map +1 -0
- package/dist/tools/cli/distribution-routes.d.ts +20 -0
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
- package/dist/tools/cli/publication-source.d.ts +77 -0
- package/dist/tools/cli/publication-source.d.ts.map +1 -0
- package/llms/agent-runtime-openrouter.txt +1 -1
- package/llms/cli-publish.txt +15 -3
- package/llms/cli.2.txt +84 -63
- package/llms/cli.3.txt +67 -1
- package/llms/cli.txt +1 -1
- package/llms/files.txt +1 -1
- package/llms/process.txt +24 -4
- package/llms/spend.txt +11 -5
- package/llms/stitchkit.txt +1 -1
- package/llms-full.txt +136 -15
- package/llms.txt +7 -7
- package/package.json +1 -1
- package/dist/index-pp97q86a.js +0 -221
- package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ExclusiveLockError2,
|
|
3
3
|
withExclusiveLock2
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-zhngww7q.js";
|
|
5
5
|
import {
|
|
6
6
|
writeFileAtomicSync2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-2rs7ze0q.js";
|
|
8
8
|
import {
|
|
9
9
|
fetchGuarded,
|
|
10
10
|
PrivateAddressRefusal,
|
|
@@ -24,6 +24,125 @@ import {
|
|
|
24
24
|
raceAbort
|
|
25
25
|
} from "./index-rptj3qnc.js";
|
|
26
26
|
|
|
27
|
+
// src/tools/cli/installer.ts
|
|
28
|
+
function shellQuote(value) {
|
|
29
|
+
return `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
30
|
+
}
|
|
31
|
+
function renderCliInstaller2(config) {
|
|
32
|
+
const binary = config.binaryName ?? config.manifest.name;
|
|
33
|
+
const installDir = config.installDir ?? "$HOME/.local/bin";
|
|
34
|
+
const assets = config.asset ? [config.asset] : config.manifest.assets;
|
|
35
|
+
if (assets.length === 0) {
|
|
36
|
+
throw new Error("[stitchkit] a build manifest with no assets installs nothing");
|
|
37
|
+
}
|
|
38
|
+
const selection = assets.length === 1 && assets[0] !== undefined ? singleTarget(assets[0]) : unameDispatch(assets);
|
|
39
|
+
return `#!/bin/sh
|
|
40
|
+
# ${binary} ${config.manifest.version} (${config.manifest.commit})
|
|
41
|
+
# Generated from the build manifest — it parses no JSON and needs no jq.
|
|
42
|
+
set -eu
|
|
43
|
+
|
|
44
|
+
binary=${shellQuote(binary)}
|
|
45
|
+
dir="\${INSTALL_DIR:-${installDir}}"
|
|
46
|
+
|
|
47
|
+
${selection}
|
|
48
|
+
|
|
49
|
+
fetch() {
|
|
50
|
+
if command -v curl >/dev/null 2>&1; then
|
|
51
|
+
curl -fsSL "$1" -o "$2"
|
|
52
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
53
|
+
wget -q "$1" -O "$2"
|
|
54
|
+
else
|
|
55
|
+
echo "need curl or wget" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
digest() {
|
|
61
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
62
|
+
sha256sum "$1" | cut -d' ' -f1
|
|
63
|
+
elif command -v shasum >/dev/null 2>&1; then
|
|
64
|
+
shasum -a 256 "$1" | cut -d' ' -f1
|
|
65
|
+
elif command -v openssl >/dev/null 2>&1; then
|
|
66
|
+
openssl dgst -sha256 "$1" | awk '{print $NF}'
|
|
67
|
+
else
|
|
68
|
+
echo "need sha256sum, shasum or openssl" >&2
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
tmp="$(mktemp -d)"
|
|
74
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
75
|
+
|
|
76
|
+
fetch "$url" "$tmp/download"
|
|
77
|
+
if [ "$compression" = "gzip" ]; then
|
|
78
|
+
gzip -dc "$tmp/download" > "$tmp/binary"
|
|
79
|
+
else
|
|
80
|
+
mv "$tmp/download" "$tmp/binary"
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
actual="$(digest "$tmp/binary")"
|
|
84
|
+
if [ "$actual" != "$sha256" ]; then
|
|
85
|
+
echo "checksum mismatch: expected $sha256, got $actual" >&2
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
actual_size="$(wc -c < "$tmp/binary" | tr -d ' ')"
|
|
90
|
+
if [ "$actual_size" != "$size" ]; then
|
|
91
|
+
echo "size mismatch: expected $size bytes, got $actual_size" >&2
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
mkdir -p "$dir"
|
|
96
|
+
chmod 755 "$tmp/binary"
|
|
97
|
+
# A rename, never a write over the file in place: anything else can leave a
|
|
98
|
+
# half-written executable where a working one used to be.
|
|
99
|
+
mv "$tmp/binary" "$dir/$binary"
|
|
100
|
+
|
|
101
|
+
echo "installed $binary ${config.manifest.version} to $dir/$binary"
|
|
102
|
+
case ":$PATH:" in
|
|
103
|
+
*":$dir:"*) ;;
|
|
104
|
+
*) echo "note: $dir is not on your PATH" >&2 ;;
|
|
105
|
+
esac
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
function singleTarget(asset) {
|
|
109
|
+
return [
|
|
110
|
+
`url=${shellQuote(asset.url)}`,
|
|
111
|
+
`sha256=${shellQuote(asset.sha256)}`,
|
|
112
|
+
`size=${shellQuote(String(asset.size))}`,
|
|
113
|
+
`compression=${shellQuote(asset.compression)}`
|
|
114
|
+
].join(`
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
function unameDispatch(assets) {
|
|
118
|
+
const cases = assets.map((asset) => ` ${asset.platform}/${asset.arch})
|
|
119
|
+
url=${shellQuote(asset.url)}
|
|
120
|
+
sha256=${shellQuote(asset.sha256)}
|
|
121
|
+
size=${shellQuote(String(asset.size))}
|
|
122
|
+
compression=${shellQuote(asset.compression)}
|
|
123
|
+
;;`).join(`
|
|
124
|
+
`);
|
|
125
|
+
const published = assets.map((asset) => `${asset.platform}/${asset.arch}`).join(", ");
|
|
126
|
+
return `case "$(uname -s)" in
|
|
127
|
+
Darwin) platform=darwin ;;
|
|
128
|
+
Linux) platform=linux ;;
|
|
129
|
+
*) platform="$(uname -s)" ;;
|
|
130
|
+
esac
|
|
131
|
+
case "$(uname -m)" in
|
|
132
|
+
x86_64|amd64) arch=x64 ;;
|
|
133
|
+
aarch64|arm64) arch=arm64 ;;
|
|
134
|
+
*) arch="$(uname -m)" ;;
|
|
135
|
+
esac
|
|
136
|
+
|
|
137
|
+
case "$platform/$arch" in
|
|
138
|
+
${cases}
|
|
139
|
+
*)
|
|
140
|
+
echo "no published build for $platform/$arch — published: ${published}" >&2
|
|
141
|
+
exit 1
|
|
142
|
+
;;
|
|
143
|
+
esac`;
|
|
144
|
+
}
|
|
145
|
+
|
|
27
146
|
// src/tools/cli/manifest.ts
|
|
28
147
|
import { z as z2 } from "zod";
|
|
29
148
|
|
|
@@ -648,4 +767,4 @@ function rollbackCliUpdate2(config) {
|
|
|
648
767
|
return { path: target, bytes: bytes.length, sha256 };
|
|
649
768
|
}
|
|
650
769
|
|
|
651
|
-
export { CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
770
|
+
export { renderCliInstaller2, CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withExclusiveLock2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-zhngww7q.js";
|
|
4
4
|
import {
|
|
5
5
|
writeAtomicFileData
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-2rs7ze0q.js";
|
|
7
7
|
import {
|
|
8
8
|
publishAtomicFile
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gyfsh29t.js";
|
|
10
10
|
import {
|
|
11
11
|
readBoundedFile
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-150b1qyw.js";
|
|
13
13
|
import {
|
|
14
14
|
errnoOf
|
|
15
15
|
} from "./index-jj9228tt.js";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
reclaimable,
|
|
10
10
|
LockRecordError,
|
|
11
11
|
readLockRecord
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-2qnqvq11.js";
|
|
13
13
|
import {
|
|
14
14
|
AtomicFilePublicationError2,
|
|
15
15
|
publishAtomicFile
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-gyfsh29t.js";
|
|
17
17
|
import {
|
|
18
18
|
errnoOf
|
|
19
19
|
} from "./index-jj9228tt.js";
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "./index-02kdtrcd.js";
|
|
10
10
|
import {
|
|
11
11
|
streamNativeCommand2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-1h0dtfz3.js";
|
|
13
13
|
import {
|
|
14
14
|
runNativeCommand2
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-afaq0nc4.js";
|
|
16
16
|
import {
|
|
17
17
|
jsonDataRefusal
|
|
18
18
|
} from "./index-m6w6jtda.js";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POSIX ownership policy, validation and descriptor application for atomic file writes.
|
|
3
|
+
*
|
|
4
|
+
* Ownership is either left to the kernel (`'none'`), preserved from an existing regular file at
|
|
5
|
+
* `target` via `lstat` (`'preserve'`), or set explicitly (`{ uid, gid }`). Before calling `fchown`,
|
|
6
|
+
* the descriptor's actual `(uid, gid)` is read with `fstat(fd)` — never guessed from
|
|
7
|
+
* `process.getuid()`/`process.getgid()`, which disagree with the inode in setgid or BSD directories.
|
|
8
|
+
*/
|
|
9
|
+
/** Explicit POSIX numeric user and group IDs (`0`..`4294967294`) applied to an atomically written file. */
|
|
10
|
+
export interface WriteFileAtomicOwner {
|
|
11
|
+
/** Numeric POSIX user ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(uid_t)-1` no-op). */
|
|
12
|
+
readonly uid: number;
|
|
13
|
+
/** Numeric POSIX group ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(gid_t)-1` no-op). */
|
|
14
|
+
readonly gid: number;
|
|
15
|
+
}
|
|
16
|
+
/** Normalized ownership policy resolved once up front from `WriteFileAtomicOptions`. */
|
|
17
|
+
export type AtomicOwnerPolicy = {
|
|
18
|
+
readonly kind: 'none';
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'preserve';
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'explicit';
|
|
23
|
+
readonly owner: WriteFileAtomicOwner;
|
|
24
|
+
};
|
|
25
|
+
/** Minimal `lstat` view needed to inspect an existing target's file kind and ownership. */
|
|
26
|
+
export interface TargetLstatView {
|
|
27
|
+
isFile(): boolean;
|
|
28
|
+
uid: number;
|
|
29
|
+
gid: number;
|
|
30
|
+
}
|
|
31
|
+
/** Minimal `fstat(fd)` view needed to compare a staged descriptor's real `(uid, gid)`. */
|
|
32
|
+
export interface DescriptorOwnerView {
|
|
33
|
+
uid: number;
|
|
34
|
+
gid: number;
|
|
35
|
+
}
|
|
36
|
+
/** Maximum valid POSIX `uid`/`gid` for `fchown`; `0xffff_ffff` is the `(uid_t)-1` no-op sentinel. */
|
|
37
|
+
export declare const MAX_POSIX_OWNER_ID = 4294967294;
|
|
38
|
+
/** Exclusive create flags for staging files: refuses existing files and symbolic links. */
|
|
39
|
+
export declare function stagingOpenFlags(): number;
|
|
40
|
+
/** Validate `options.mode` eagerly before opening any staging file or narrowing bits. */
|
|
41
|
+
export declare function assertWriteMode(mode: unknown, defaultMode: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Validate and snapshot the ownership policy once up front. Option types and combinations throw
|
|
44
|
+
* `TypeError` before the Windows platform refusal so malformed inputs fail uniformly everywhere.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveAtomicOwnerPolicy(options: {
|
|
47
|
+
readonly replace?: boolean;
|
|
48
|
+
readonly owner?: unknown;
|
|
49
|
+
}, platform?: string): AtomicOwnerPolicy;
|
|
50
|
+
/**
|
|
51
|
+
* When ownership will be adjusted before publication, strip group/other bits at `open` time so
|
|
52
|
+
* the staging file is never readable by the process's prior group before `fchown` and `fchmod`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function initialCreateMode(mode: number, policy: AtomicOwnerPolicy): number;
|
|
55
|
+
/** Resolve the target `(uid, gid)` asynchronously; missing or non-regular targets yield `undefined`. */
|
|
56
|
+
export declare function resolveDesiredOwner(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => Promise<TargetLstatView>): Promise<WriteFileAtomicOwner | undefined>;
|
|
57
|
+
/** Synchronous counterpart of {@link resolveDesiredOwner}. */
|
|
58
|
+
export declare function resolveDesiredOwnerSync(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => TargetLstatView): WriteFileAtomicOwner | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Apply `desired` to an open staged descriptor after inspecting its real `fstat(fd)`. Skips
|
|
61
|
+
* `fchown` when the inode already matches, and refuses unchangeable sentinel IDs instead of
|
|
62
|
+
* letting POSIX `fchown` silently ignore `(uid_t)-1`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyAtomicFileOwner(file: {
|
|
65
|
+
stat(): Promise<DescriptorOwnerView>;
|
|
66
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
67
|
+
}, desired: WriteFileAtomicOwner | undefined): Promise<void>;
|
|
68
|
+
/** Synchronous counterpart of {@link applyAtomicFileOwner}. */
|
|
69
|
+
export declare function applyAtomicFileOwnerSync(file: {
|
|
70
|
+
stat(): DescriptorOwnerView;
|
|
71
|
+
chown(uid: number, gid: number): void;
|
|
72
|
+
}, desired: WriteFileAtomicOwner | undefined): void;
|
|
73
|
+
/** Normalized write options resolved once up front for both async and sync atomic writes. */
|
|
74
|
+
export interface ResolvedAtomicWriteOptions {
|
|
75
|
+
readonly mode: number;
|
|
76
|
+
readonly replace: boolean;
|
|
77
|
+
readonly idempotent: boolean;
|
|
78
|
+
readonly durability: 'none' | 'file' | 'directory';
|
|
79
|
+
readonly ownerPolicy: AtomicOwnerPolicy;
|
|
80
|
+
}
|
|
81
|
+
/** Validate and snapshot every atomic-write option once up front before touching the filesystem. */
|
|
82
|
+
export declare function resolveAtomicWriteOptions(options: {
|
|
83
|
+
readonly mode?: unknown;
|
|
84
|
+
readonly replace?: boolean;
|
|
85
|
+
readonly idempotent?: boolean;
|
|
86
|
+
readonly durability?: 'none' | 'file' | 'directory';
|
|
87
|
+
readonly owner?: unknown;
|
|
88
|
+
}, defaultMode: number, platform?: string): ResolvedAtomicWriteOptions;
|
|
89
|
+
/** Check whether an existing target's `(uid, gid)` satisfies an explicit `owner` for `idempotent: true`. */
|
|
90
|
+
export declare function ownerMatches(actualUid: number | undefined, actualGid: number | undefined, policy: AtomicOwnerPolicy): boolean;
|
|
91
|
+
//# sourceMappingURL=atomic-file-owner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-file-owner.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file-owner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,2GAA2G;AAC3G,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uGAAuG;IACvG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAExE,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,MAAM,IAAI,OAAO,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qGAAqG;AACrG,eAAO,MAAM,kBAAkB,aAAc,CAAC;AAG9C,2FAA2F;AAC3F,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AAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC5E,OAAO,EAAE,oBAAoB,GAAG,SAAS,GACxC,IAAI,CAIN;AAED,6FAA6F;AAC7F,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IACnD,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;CACzC;AAED,oGAAoG;AACpG,wBAAgB,yBAAyB,CACvC,OAAO,EAAE;IACP,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,EACD,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,MAAyB,GAClC,0BAA0B,CAU5B;AAED,4GAA4G;AAC5G,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAGT"}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* synchronous `rename` on a loaded machine was measured holding a consumer's
|
|
21
21
|
* main thread for ~15 s — every timer and request of a daemon stood still.
|
|
22
22
|
*/
|
|
23
|
+
import { type DescriptorOwnerView, type TargetLstatView, type WriteFileAtomicOwner } from './atomic-file-owner.js';
|
|
23
24
|
import { type AtomicPublishOptions } from './atomic-publication.js';
|
|
24
25
|
/** Options of {@link writeFileAtomic} and {@link writeFileAtomicSync}. */
|
|
25
26
|
export interface WriteFileAtomicOptions {
|
|
@@ -35,8 +36,9 @@ export interface WriteFileAtomicOptions {
|
|
|
35
36
|
/**
|
|
36
37
|
* Only valid with `replace: false` (throws `TypeError` otherwise). When `true`
|
|
37
38
|
* and `target` already exists, succeed without replacing it if the existing
|
|
38
|
-
* regular file (not a symlink, FIFO, or directory) already has identical bytes
|
|
39
|
-
*
|
|
39
|
+
* regular file (not a symlink, FIFO, or directory) already has identical bytes,
|
|
40
|
+
* matching permission bits (`mode`, on POSIX), and matching `(uid, gid)` when an
|
|
41
|
+
* explicit `owner` is requested.
|
|
40
42
|
*/
|
|
41
43
|
idempotent?: boolean;
|
|
42
44
|
/**
|
|
@@ -44,12 +46,22 @@ export interface WriteFileAtomicOptions {
|
|
|
44
46
|
* also fsyncs the parent after it; `'none'` does neither.
|
|
45
47
|
*/
|
|
46
48
|
durability?: 'none' | 'file' | 'directory';
|
|
49
|
+
/**
|
|
50
|
+
* POSIX file ownership applied via `fchown` before `fchmod`, `fsync` and
|
|
51
|
+
* publication: `'preserve'` copies `(uid, gid)` from an existing regular file
|
|
52
|
+
* at `target` via `lstat` (requires `replace !== false`; missing or non-regular
|
|
53
|
+
* targets keep the kernel default), and `{ uid, gid }` sets an explicit owner.
|
|
54
|
+
* Compared against the staged descriptor's real `fstat(fd)`; unsupported on Windows.
|
|
55
|
+
*/
|
|
56
|
+
owner?: 'preserve' | WriteFileAtomicOwner;
|
|
47
57
|
}
|
|
48
58
|
/** The staged file as a writer sees it; a `FileHandle` satisfies it. */
|
|
49
59
|
export interface StagedFile {
|
|
50
60
|
write(bytes: Uint8Array, offset: number, length: number): Promise<{
|
|
51
61
|
bytesWritten: number;
|
|
52
62
|
}>;
|
|
63
|
+
stat(): Promise<DescriptorOwnerView>;
|
|
64
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
53
65
|
chmod(mode: number): Promise<void>;
|
|
54
66
|
sync(): Promise<void>;
|
|
55
67
|
close(): Promise<void>;
|
|
@@ -70,14 +82,18 @@ export declare function writeAllBytes(file: StagedFile, bytes: Uint8Array): Prom
|
|
|
70
82
|
*/
|
|
71
83
|
export declare function writeFileAtomic(target: string, data: Uint8Array | string, options?: WriteFileAtomicOptions): Promise<void>;
|
|
72
84
|
interface AtomicFileWriteIO {
|
|
73
|
-
open(path: string, flags:
|
|
85
|
+
open(path: string, flags: number, mode: number): Promise<StagedFile>;
|
|
74
86
|
unlink(path: string): Promise<void>;
|
|
75
87
|
publish(staged: string, target: string, options: AtomicPublishOptions): Promise<void>;
|
|
88
|
+
lstat?(path: string): Promise<TargetLstatView>;
|
|
76
89
|
readExisting?(target: string, maxBytes: number): Promise<{
|
|
77
90
|
bytes: Uint8Array;
|
|
78
91
|
mode: number | undefined;
|
|
92
|
+
uid?: number | undefined;
|
|
93
|
+
gid?: number | undefined;
|
|
79
94
|
}>;
|
|
80
95
|
syncDir?(dir: string): Promise<void>;
|
|
96
|
+
platform?: string;
|
|
81
97
|
}
|
|
82
98
|
/** How the staged bytes of one atomic write are produced and vetted. */
|
|
83
99
|
export interface AtomicFileStage<T> {
|
|
@@ -90,9 +106,9 @@ export interface AtomicFileStage<T> {
|
|
|
90
106
|
}
|
|
91
107
|
/**
|
|
92
108
|
* The one staging sequence behind every asynchronous atomic write: exclusive
|
|
93
|
-
* create
|
|
94
|
-
* staging file on any failure. Also the internal
|
|
95
|
-
* publication-order and precommit fault controls.
|
|
109
|
+
* create with `O_NOFOLLOW`, fill, optional `fstat`/`fchown`, `fchmod`, `fsync`,
|
|
110
|
+
* publication, and removal of the staging file on any failure. Also the internal
|
|
111
|
+
* syscall seam for publication-order and precommit fault controls.
|
|
96
112
|
*/
|
|
97
113
|
export declare function writeAtomicFileStaged<T>(target: string, stage: AtomicFileStage<T>, options: WriteFileAtomicOptions, io?: AtomicFileWriteIO): Promise<T>;
|
|
98
114
|
/** {@link writeAtomicFileStaged} for bytes already in memory. */
|
|
@@ -100,19 +116,25 @@ export declare function writeAtomicFileData(target: string, data: Uint8Array | s
|
|
|
100
116
|
/** The staged file of the synchronous form. */
|
|
101
117
|
interface StagedFileSync {
|
|
102
118
|
write(bytes: Uint8Array, offset: number, length: number): number;
|
|
119
|
+
stat(): DescriptorOwnerView;
|
|
120
|
+
chown(uid: number, gid: number): void;
|
|
103
121
|
chmod(mode: number): void;
|
|
104
122
|
sync(): void;
|
|
105
123
|
close(): void;
|
|
106
124
|
}
|
|
107
125
|
interface AtomicFileWriteSyncIO {
|
|
108
|
-
open(path: string, flags:
|
|
126
|
+
open(path: string, flags: number, mode: number): StagedFileSync;
|
|
109
127
|
unlink(path: string): void;
|
|
110
128
|
publish(staged: string, target: string, options: AtomicPublishOptions): void;
|
|
129
|
+
lstat?(path: string): TargetLstatView;
|
|
111
130
|
readExisting?(target: string, maxBytes: number): {
|
|
112
131
|
bytes: Uint8Array;
|
|
113
132
|
mode: number;
|
|
133
|
+
uid?: number | undefined;
|
|
134
|
+
gid?: number | undefined;
|
|
114
135
|
};
|
|
115
136
|
syncDir?(dir: string): void;
|
|
137
|
+
platform?: string;
|
|
116
138
|
}
|
|
117
139
|
/**
|
|
118
140
|
* The synchronous form of {@link writeFileAtomic}, with the same guarantees in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAeH,OAAO,EAGL,KAAK,mBAAmB,EAQxB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,oBAAoB,EAK1B,MAAM,sBAAsB,CAAC;AAM9B,0EAA0E;AAC1E,MAAM,WAA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AM,EACd,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,GAAE,qBAAkC,GACrC,IAAI,CA0CN;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,GAAE,sBAA2B,GACnC,IAAI,CAEN"}
|
|
@@ -36,6 +36,8 @@ export interface BoundedFileRead {
|
|
|
36
36
|
bytes: Uint8Array;
|
|
37
37
|
observation: FileObservation;
|
|
38
38
|
mode: number | undefined;
|
|
39
|
+
uid?: number | undefined;
|
|
40
|
+
gid?: number | undefined;
|
|
39
41
|
/** Exact nanosecond post-read stat when the open descriptor supports `{ bigint: true }`. */
|
|
40
42
|
after?: NanosecondFileStats;
|
|
41
43
|
}
|
|
@@ -51,13 +53,15 @@ export interface BoundedFileReadSyncOptions extends FileOpenOptions {
|
|
|
51
53
|
/**
|
|
52
54
|
* Synchronous counterpart of {@link readBoundedFile}: opens with `O_RDONLY | O_NONBLOCK`
|
|
53
55
|
* (plus `O_NOFOLLOW` when `rejectSymlinks` is true), validates `fstat` regular file and
|
|
54
|
-
* link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode
|
|
55
|
-
* the nanosecond `fstat` taken after the read (`after`) for an exact identity.
|
|
56
|
+
* link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode, uid,
|
|
57
|
+
* gid and the nanosecond `fstat` taken after the read (`after`) for an exact identity.
|
|
56
58
|
*/
|
|
57
59
|
export declare function readBoundedFileSync(target: string, maxBytes: number, options?: BoundedFileReadSyncOptions, openFd?: (path: string, flags: number) => number, snapshot?: BoundedFileSnapshotSyncHooks): {
|
|
58
60
|
bytes: Uint8Array;
|
|
59
61
|
observation: FileObservation;
|
|
60
62
|
mode: number;
|
|
63
|
+
uid: number;
|
|
64
|
+
gid: number;
|
|
61
65
|
after: BigIntStats;
|
|
62
66
|
};
|
|
63
67
|
export declare function readHandle(handle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounded-file-read.d.ts","sourceRoot":"","sources":["../../src/internal/bounded-file-read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EAYlC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc;IAElB,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe;IARxC,YACW,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,EAClB,OAAO,EAAE,MAAM,EACN,WAAW,CAAC,EAAE,eAAe,YAAA,EACtC,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,CAC3E,SAAQ,eAAe;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iGAAiG;IACjG,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,aAAa,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAA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E,UAAU,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,WAAW,CAAC;CACpB,CAuFA;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1F,EACD,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
|
|
@@ -4,10 +4,14 @@ import { type SpendReceipt } from './schemas.js';
|
|
|
4
4
|
* out-of-order delivery converge: a field the higher-ranked receipt knows wins, a
|
|
5
5
|
* field it does not know keeps the other's value, a closed outcome never returns
|
|
6
6
|
* to `pending`, and a provider-reported cost is never erased by a later guess.
|
|
7
|
-
* Equal ranks: the receipt with the later `at` wins, whatever order they arrive in
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Equal ranks: the receipt with the later `at` wins, whatever order they arrive in
|
|
8
|
+
* (and a factual cost breaks an exact-timestamp tie). A non-factual rank-3
|
|
9
|
+
* reconciler receipt never overwrites or leaves behind a reconciler `failureCode` /
|
|
10
|
+
* `failureMessage` alongside a factual (`reported` or `free`) cost, while transport
|
|
11
|
+
* failure codes from ranks 1–2 stay intact. An `orphaned` close (a sweep found
|
|
12
|
+
* nothing) never replaces a real one. Fields are ranked by receipt, not each: it
|
|
13
|
+
* assumes one transport-side receipt per attempt (the gateway writes exactly one),
|
|
14
|
+
* followed by reconciler receipts.
|
|
11
15
|
*/
|
|
12
16
|
export declare function mergeSpendReceipt(previous: SpendReceipt | undefined, next: SpendReceipt): SpendReceipt;
|
|
13
17
|
//# sourceMappingURL=receipt-merge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receipt-merge.d.ts","sourceRoot":"","sources":["../../src/spend/receipt-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"receipt-merge.d.ts","sourceRoot":"","sources":["../../src/spend/receipt-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAElB,MAAM,WAAW,CAAC;AAqCnB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,IAAI,EAAE,YAAY,GACjB,YAAY,CA2Cd"}
|
|
@@ -11,8 +11,16 @@ export interface ReconcilePendingSpendOptions {
|
|
|
11
11
|
/** By gateway name; a pending attempt of a gateway without one is left as it is. */
|
|
12
12
|
reconcilers: Readonly<Record<string, SpendReconciler>>;
|
|
13
13
|
limit?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Once a pending attempt has waited at least this many milliseconds since its
|
|
16
|
+
* latest receipt (`record.receipt.at`, or `record.attempt.startedAt` when no
|
|
17
|
+
* receipt exists) and its reconciler still returns `undefined`, settle it as
|
|
18
|
+
* `costStatus: 'unknown'` with `failureCode: 'price-never-reported'` instead
|
|
19
|
+
* of leaving it `pending` forever.
|
|
20
|
+
*/
|
|
21
|
+
maxPendingAgeMs?: number;
|
|
14
22
|
now?: () => Date;
|
|
15
|
-
/** A reconciler that threw or returned invalid facts: the attempt stays pending, and here is why (for `reconcileError`). */
|
|
23
|
+
/** A reconciler that threw or returned invalid facts, an invalid record timestamp, or a receipt-merge failure: the attempt stays pending, and here is why (for `reconcileError`). */
|
|
16
24
|
onError?: (failure: {
|
|
17
25
|
record: SpendRecord;
|
|
18
26
|
error: unknown;
|
|
@@ -28,7 +36,12 @@ export interface SpendReconcileResult {
|
|
|
28
36
|
/**
|
|
29
37
|
* One pass over the attempts whose cost is still `pending`: each reconciler's
|
|
30
38
|
* answer is settled as a rank-3 receipt, merged so it only ever adds what the
|
|
31
|
-
* provider now knows.
|
|
39
|
+
* provider now knows. When `maxPendingAgeMs` is set and a reconciler still
|
|
40
|
+
* returns `undefined` once at least that many milliseconds have passed since
|
|
41
|
+
* `record.receipt.at` (or `record.attempt.startedAt` when no receipt exists),
|
|
42
|
+
* the attempt is settled as `costStatus: 'unknown'` with
|
|
43
|
+
* `failureCode: 'price-never-reported'`. A reconciler that throws or returns
|
|
44
|
+
* invalid facts, an invalid record timestamp, or a receipt-merge failure is
|
|
32
45
|
* counted and its attempt stays pending for the next pass.
|
|
33
46
|
*/
|
|
34
47
|
export declare function reconcilePendingSpend(options: ReconcilePendingSpendOptions): Promise<SpendReconcileResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/spend/reconcile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reconcile.d.ts","sourceRoot":"","sources":["../../src/spend/reconcile.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAEjB,MAAM,WAAW,CAAC;AAEnB;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,CAAC;AAE9C,6EAA6E;AAC7E,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,gBAAgB,CAAC;IACxB,oFAAoF;IACpF,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,qLAAqL;IACrL,OA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