@tangle-network/agent-provider-tangle 1.1.7 → 1.1.8
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/dist/tangle-contract-safety.d.ts +3 -0
- package/dist/tangle-contract-safety.js +22 -6
- package/dist/tangle-workspace-branching.js +8 -844
- package/dist/tangle-workspace-markers.d.ts +27 -0
- package/dist/tangle-workspace-markers.js +277 -0
- package/dist/tangle-workspace-recovery.d.ts +68 -0
- package/dist/tangle-workspace-recovery.js +530 -0
- package/package.json +5 -1
|
@@ -21,3 +21,6 @@ export declare function validateExactProcessCreateInput(input: CreateAgentExactP
|
|
|
21
21
|
export declare function awaitWithSignal<T>(operation: Promise<T> | T | undefined, signal?: AbortSignal): Promise<T>;
|
|
22
22
|
/** Await an operation and clean its result if abort wins before it resolves. */
|
|
23
23
|
export declare function awaitWithSignalAndCleanup<T>(operation: () => Promise<T> | T, signal: AbortSignal | undefined, cleanup: (value: T) => Promise<void> | void): Promise<T>;
|
|
24
|
+
export declare function cloneJson<T>(value: T): T;
|
|
25
|
+
export declare function safeIdentifier(value: unknown): string | undefined;
|
|
26
|
+
export declare function safeString(value: unknown): string | undefined;
|
|
@@ -11,13 +11,10 @@ export const MAX_JSON_DEPTH = 16;
|
|
|
11
11
|
export const MAX_JSON_NODES = 8_192;
|
|
12
12
|
const IMMUTABLE_TANGLE_IMAGE = /^(?:sha256:[a-f0-9]{64}|\S+@sha256:[a-f0-9]{64})$/i;
|
|
13
13
|
export function boundedIdentifier(value, label) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value.length > MAX_IDENTIFIER_LENGTH ||
|
|
17
|
-
value.trim() !== value) {
|
|
14
|
+
const identifier = safeIdentifier(value);
|
|
15
|
+
if (identifier === undefined)
|
|
18
16
|
throw new Error(`${label} is invalid`);
|
|
19
|
-
|
|
20
|
-
return value;
|
|
17
|
+
return identifier;
|
|
21
18
|
}
|
|
22
19
|
export function boundedString(value, label) {
|
|
23
20
|
if (typeof value !== "string" || value.length > MAX_STRING_LENGTH) {
|
|
@@ -269,3 +266,22 @@ export async function awaitWithSignalAndCleanup(operation, signal, cleanup) {
|
|
|
269
266
|
signal.removeEventListener("abort", listener);
|
|
270
267
|
}
|
|
271
268
|
}
|
|
269
|
+
export function cloneJson(value) {
|
|
270
|
+
assertBoundedJson(value);
|
|
271
|
+
return structuredClone(value);
|
|
272
|
+
}
|
|
273
|
+
export function safeIdentifier(value) {
|
|
274
|
+
if (typeof value !== "string" ||
|
|
275
|
+
value.length === 0 ||
|
|
276
|
+
value.length > MAX_IDENTIFIER_LENGTH ||
|
|
277
|
+
value.trim() !== value)
|
|
278
|
+
return undefined;
|
|
279
|
+
return value;
|
|
280
|
+
}
|
|
281
|
+
export function safeString(value) {
|
|
282
|
+
if (typeof value !== "string" ||
|
|
283
|
+
value.length === 0 ||
|
|
284
|
+
value.length > MAX_STRING_LENGTH)
|
|
285
|
+
return undefined;
|
|
286
|
+
return value;
|
|
287
|
+
}
|