@opengeni/contracts 0.40.0 → 0.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/atlassian.d.ts +278 -0
  2. package/dist/atlassian.js +55 -0
  3. package/dist/atlassian.js.map +1 -0
  4. package/dist/chunk-52SGB2QO.js +688 -0
  5. package/dist/chunk-52SGB2QO.js.map +1 -0
  6. package/dist/{chunk-7JZMI22I.js → chunk-5UDNP7AO.js} +34 -2
  7. package/dist/chunk-5UDNP7AO.js.map +1 -0
  8. package/dist/chunk-BVGIYW7D.js +11 -0
  9. package/dist/chunk-BVGIYW7D.js.map +1 -0
  10. package/dist/chunk-CADSX6UN.js +1145 -0
  11. package/dist/chunk-CADSX6UN.js.map +1 -0
  12. package/dist/chunk-D2HKF2EF.js +1460 -0
  13. package/dist/chunk-D2HKF2EF.js.map +1 -0
  14. package/dist/chunk-FJBG5E4O.js +194 -0
  15. package/dist/chunk-FJBG5E4O.js.map +1 -0
  16. package/dist/chunk-H5BVCZKF.js +382 -0
  17. package/dist/chunk-H5BVCZKF.js.map +1 -0
  18. package/dist/chunk-LSB7GRLG.js +779 -0
  19. package/dist/chunk-LSB7GRLG.js.map +1 -0
  20. package/dist/chunk-MYBZRDTY.js +340 -0
  21. package/dist/chunk-MYBZRDTY.js.map +1 -0
  22. package/dist/chunk-RIY7GYQS.js +1204 -0
  23. package/dist/chunk-RIY7GYQS.js.map +1 -0
  24. package/dist/chunk-TZ6YEYN4.js +386 -0
  25. package/dist/chunk-TZ6YEYN4.js.map +1 -0
  26. package/dist/chunk-VA22KRHS.js +15177 -0
  27. package/dist/chunk-VA22KRHS.js.map +1 -0
  28. package/dist/chunk-Y3MLSLB4.js +392 -0
  29. package/dist/chunk-Y3MLSLB4.js.map +1 -0
  30. package/dist/chunk-YRKRZ6OF.js +134 -0
  31. package/dist/chunk-YRKRZ6OF.js.map +1 -0
  32. package/dist/company-profile.d.ts +629 -0
  33. package/dist/document-artifact-commands.d.ts +282 -0
  34. package/dist/document-artifact-commands.js +54 -0
  35. package/dist/document-artifact-commands.js.map +1 -0
  36. package/dist/document-artifact-query.d.ts +2 -0
  37. package/dist/document-artifact-query.js +54 -0
  38. package/dist/document-artifact-query.js.map +1 -0
  39. package/dist/editable-artifact-binary.d.ts +56 -0
  40. package/dist/editable-artifact-causal-frontier.d.ts +12 -0
  41. package/dist/editable-artifact-causal-frontier.js +18 -0
  42. package/dist/editable-artifact-causal-frontier.js.map +1 -0
  43. package/dist/editable-artifact-codec-registry.d.ts +48 -0
  44. package/dist/editable-artifact-codec-registry.js +20 -0
  45. package/dist/editable-artifact-codec-registry.js.map +1 -0
  46. package/dist/editable-artifact-committed-transaction.d.ts +35 -0
  47. package/dist/editable-artifact-committed-transaction.js +19 -0
  48. package/dist/editable-artifact-committed-transaction.js.map +1 -0
  49. package/dist/editable-artifact-live.d.ts +276 -0
  50. package/dist/editable-artifact-live.js +907 -0
  51. package/dist/editable-artifact-live.js.map +1 -0
  52. package/dist/editable-artifact-serialized-commit.d.ts +53 -0
  53. package/dist/editable-artifact-serialized-commit.js +26 -0
  54. package/dist/editable-artifact-serialized-commit.js.map +1 -0
  55. package/dist/editable-artifact-versions.d.ts +6 -0
  56. package/dist/editable-artifact-versions.js +11 -0
  57. package/dist/editable-artifact-versions.js.map +1 -0
  58. package/dist/editable-artifacts.d.ts +46 -0
  59. package/dist/editable-artifacts.js +236 -0
  60. package/dist/editable-artifacts.js.map +1 -0
  61. package/dist/event-preview.d.ts +1 -1
  62. package/dist/google-drive.d.ts +114 -2
  63. package/dist/google-drive.js +70 -14
  64. package/dist/google-drive.js.map +1 -1
  65. package/dist/image-generation.d.ts +70 -0
  66. package/dist/index.d.ts +4460 -155
  67. package/dist/index.js +1127 -30
  68. package/dist/interaction.d.ts +6895 -0
  69. package/dist/memory-slack-delivery.d.ts +397 -0
  70. package/dist/presentation-artifact-commands.d.ts +349 -0
  71. package/dist/presentation-artifact-commands.js +66 -0
  72. package/dist/presentation-artifact-commands.js.map +1 -0
  73. package/dist/presentation-artifact-query.d.ts +2 -0
  74. package/dist/presentation-artifact-query.js +66 -0
  75. package/dist/presentation-artifact-query.js.map +1 -0
  76. package/dist/retained-output.d.ts +24 -0
  77. package/dist/sandbox-snapshots.d.ts +9 -0
  78. package/dist/scoped-knowledge.d.ts +14 -13
  79. package/dist/slack-bot-scopes.d.ts +4 -0
  80. package/dist/slack-bot-scopes.js +3 -1
  81. package/dist/spreadsheet-artifact-commands.d.ts +101 -0
  82. package/dist/spreadsheet-artifact-commands.js +27 -0
  83. package/dist/spreadsheet-artifact-commands.js.map +1 -0
  84. package/dist/spreadsheet-artifact-date.d.ts +4 -0
  85. package/dist/spreadsheet-artifact-query.d.ts +120 -0
  86. package/dist/spreadsheet-artifact-query.js +48 -0
  87. package/dist/spreadsheet-artifact-query.js.map +1 -0
  88. package/dist/tool-catalog.d.ts +576 -0
  89. package/dist/video-generation.d.ts +532 -0
  90. package/dist/video-generation.js +51 -0
  91. package/dist/video-generation.js.map +1 -0
  92. package/dist/workspace-learning-policy.d.ts +208 -0
  93. package/package.json +61 -1
  94. package/src/atlassian.ts +160 -0
  95. package/src/company-profile.ts +306 -0
  96. package/src/document-artifact-commands.ts +1709 -0
  97. package/src/document-artifact-query.ts +2 -0
  98. package/src/editable-artifact-binary.ts +396 -0
  99. package/src/editable-artifact-causal-frontier.ts +154 -0
  100. package/src/editable-artifact-codec-registry.ts +261 -0
  101. package/src/editable-artifact-committed-transaction.ts +478 -0
  102. package/src/editable-artifact-live.ts +1379 -0
  103. package/src/editable-artifact-serialized-commit.ts +494 -0
  104. package/src/editable-artifact-versions.ts +8 -0
  105. package/src/editable-artifacts.ts +473 -0
  106. package/src/google-drive.ts +68 -15
  107. package/src/image-generation.ts +106 -0
  108. package/src/index.ts +2326 -325
  109. package/src/interaction.ts +2292 -0
  110. package/src/memory-slack-delivery.ts +183 -0
  111. package/src/presentation-artifact-commands.ts +2035 -0
  112. package/src/presentation-artifact-query.ts +2 -0
  113. package/src/retained-output.ts +149 -2
  114. package/src/sandbox-snapshots.ts +28 -1
  115. package/src/scoped-knowledge.ts +18 -4
  116. package/src/slack-bot-scopes.ts +34 -1
  117. package/src/spreadsheet-artifact-commands.ts +999 -0
  118. package/src/spreadsheet-artifact-date.ts +21 -0
  119. package/src/spreadsheet-artifact-query.ts +1411 -0
  120. package/src/tool-catalog.ts +334 -0
  121. package/src/video-generation.ts +394 -0
  122. package/src/workspace-learning-policy.ts +233 -0
  123. package/dist/chunk-5HR2GPSC.js +0 -11031
  124. package/dist/chunk-5HR2GPSC.js.map +0 -1
  125. package/dist/chunk-7JZMI22I.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/editable-artifacts.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\nexport * from \"./spreadsheet-artifact-commands\";\nexport * from \"./spreadsheet-artifact-query\";\nexport * from \"./editable-artifact-causal-frontier\";\nexport * from \"./document-artifact-commands\";\nexport * from \"./presentation-artifact-commands\";\nexport * from \"./editable-artifact-codec-registry\";\n\nexport const EDITABLE_ARTIFACT_INTENT_VERSION = 1 as const;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_BYTES = 5 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_COMMAND_MAX_BYTES = 4 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES = 512;\n/** Largest durable snapshot every supported browser/WASM client can open. */\nexport const EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS = 1_024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS = 10_000;\n\nconst MAGIC = new TextEncoder().encode(\"OGATX001\");\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: true });\nconst STABLE_ID = /^[0-9a-f]{32}$/u;\nconst REPLICA_ID = /^[0-9a-f]{16}$/u;\nconst CLIENT_TRANSACTION_ID = /^[A-Za-z0-9._:-]{1,200}$/u;\nconst REQUEST_HASH = /^sha256:[0-9a-f]{64}$/u;\n\nexport type EditableArtifactCausalEntry = Readonly<{\n replicaId: string;\n counter: number;\n}>;\n\n/**\n * Exact client-authored mutation identity. Scope and actor authority are\n * deliberately absent: the server derives them and binds them in the\n * idempotency lookup tuple instead of trusting client bytes.\n */\nexport type EditableArtifactMutationIntent = Readonly<{\n envelopeVersion: typeof EDITABLE_ARTIFACT_INTENT_VERSION;\n protocolVersion: number;\n modelSchemaVersion: number;\n commandProtocolVersion: number;\n artifactId: string;\n clientTransactionId: string;\n replicaId: string;\n replicaCounter: number;\n previousLocalTransactionId: string | null;\n observedHeadSequence: number;\n causalBase: readonly EditableArtifactCausalEntry[];\n selectiveUndoOperationIds: readonly string[];\n commandBytes: Uint8Array;\n}>;\n\nexport function encodeEditableArtifactMutationIntent(\n input: EditableArtifactMutationIntent,\n): Uint8Array {\n // The writer owns the emitted bytes, so a second eager copy of a potentially\n // multi-megabyte command block would add no safety.\n const intent = normalizeIntent(input, false);\n const writer = new BinaryWriter(EDITABLE_ARTIFACT_INTENT_MAX_BYTES);\n writer.bytes(MAGIC);\n writer.u16(intent.envelopeVersion);\n writer.u16(intent.protocolVersion);\n writer.u16(intent.modelSchemaVersion);\n writer.u16(intent.commandProtocolVersion);\n writer.string(intent.artifactId);\n writer.string(intent.clientTransactionId);\n writer.string(intent.replicaId);\n writer.u64(intent.replicaCounter);\n writer.u8(intent.previousLocalTransactionId === null ? 0 : 1);\n if (intent.previousLocalTransactionId !== null) {\n writer.string(intent.previousLocalTransactionId);\n }\n writer.u64(intent.observedHeadSequence);\n writer.u16(intent.causalBase.length);\n for (const entry of intent.causalBase) {\n writer.string(entry.replicaId);\n writer.u64(entry.counter);\n }\n writer.u16(intent.selectiveUndoOperationIds.length);\n for (const operationId of intent.selectiveUndoOperationIds) writer.string(operationId);\n writer.byteBlock(intent.commandBytes);\n return writer.finish();\n}\n\nexport function decodeEditableArtifactMutationIntent(\n bytes: Uint8Array,\n): EditableArtifactMutationIntent {\n return parseEditableArtifactMutationIntent(bytes, true);\n}\n\nfunction parseEditableArtifactMutationIntent(\n bytes: Uint8Array,\n copyCommandBytes: boolean,\n): EditableArtifactMutationIntent {\n if (!(bytes instanceof Uint8Array)) throw new TypeError(\"intent bytes must be a Uint8Array\");\n if (bytes.byteLength > EDITABLE_ARTIFACT_INTENT_MAX_BYTES) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n const reader = new BinaryReader(bytes);\n const magic = reader.bytes(MAGIC.byteLength);\n if (!equalBytes(magic, MAGIC)) throw new TypeError(\"invalid editable artifact intent magic\");\n const envelopeVersion = reader.u16();\n if (envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(`unsupported editable artifact intent version: ${envelopeVersion}`);\n }\n const protocolVersion = reader.u16();\n const modelSchemaVersion = reader.u16();\n const commandProtocolVersion = reader.u16();\n const artifactId = reader.string();\n const clientTransactionId = reader.string();\n const replicaId = reader.string();\n const replicaCounter = reader.u64();\n const predecessorFlag = reader.u8();\n if (predecessorFlag > 1) throw new TypeError(\"invalid predecessor presence flag\");\n const previousLocalTransactionId = predecessorFlag === 1 ? reader.string() : null;\n const observedHeadSequence = reader.u64();\n const causalCount = reader.u16();\n if (causalCount > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalBase: EditableArtifactCausalEntry[] = [];\n let previousReplicaId = \"\";\n for (let index = 0; index < causalCount; index += 1) {\n const causalReplicaId = reader.string();\n if (causalReplicaId <= previousReplicaId) {\n throw new TypeError(\"causal base replica ids must be unique and canonically sorted\");\n }\n previousReplicaId = causalReplicaId;\n causalBase.push(Object.freeze({ replicaId: causalReplicaId, counter: reader.u64() }));\n }\n const undoCount = reader.u16();\n if (undoCount > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const selectiveUndoOperationIds: string[] = [];\n let previousOperationId = \"\";\n for (let index = 0; index < undoCount; index += 1) {\n const operationId = reader.string();\n if (operationId <= previousOperationId) {\n throw new TypeError(\"undo operation ids must be unique and canonically sorted\");\n }\n previousOperationId = operationId;\n selectiveUndoOperationIds.push(operationId);\n }\n const commandBytes = reader.byteBlock(EDITABLE_ARTIFACT_COMMAND_MAX_BYTES);\n reader.done();\n return normalizeIntent(\n {\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase,\n selectiveUndoOperationIds,\n commandBytes,\n },\n copyCommandBytes,\n );\n}\n\nexport function hashEditableArtifactMutationIntentBytes(bytes: Uint8Array): string {\n // Decode first so noncanonical or malformed bytes can never acquire a valid\n // application-level request hash merely because SHA-256 accepts any bytes.\n parseEditableArtifactMutationIntent(bytes, false);\n return `sha256:${bytesToHex(sha256(bytes))}`;\n}\n\nexport function hashEditableArtifactMutationIntent(intent: EditableArtifactMutationIntent): {\n bytes: Uint8Array;\n requestHash: string;\n} {\n const bytes = encodeEditableArtifactMutationIntent(intent);\n return { bytes, requestHash: `sha256:${bytesToHex(sha256(bytes))}` };\n}\n\nexport function assertEditableArtifactRequestHash(value: string): string {\n if (!REQUEST_HASH.test(value)) {\n throw new TypeError(\"editable artifact request hash must be canonical sha256 text\");\n }\n return value;\n}\n\nfunction normalizeIntent(\n input: EditableArtifactMutationIntent,\n copyCommandBytes = true,\n): EditableArtifactMutationIntent {\n if (!isPlainRecord(input)) throw new TypeError(\"editable artifact intent must be a plain record\");\n if (input.envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(\"editable artifact intent envelope version must be 1\");\n }\n const protocolVersion = positiveU16(input.protocolVersion, \"protocolVersion\");\n const modelSchemaVersion = positiveU16(input.modelSchemaVersion, \"modelSchemaVersion\");\n const commandProtocolVersion = positiveU16(\n input.commandProtocolVersion,\n \"commandProtocolVersion\",\n );\n const artifactId = stableId(input.artifactId, \"artifactId\");\n const clientTransactionId = portableTransactionId(\n input.clientTransactionId,\n \"clientTransactionId\",\n );\n const replicaId = replicaIdentity(input.replicaId, \"replicaId\");\n const replicaCounter = positiveSafeInteger(input.replicaCounter, \"replicaCounter\");\n const previousLocalTransactionId =\n input.previousLocalTransactionId === null\n ? null\n : portableTransactionId(input.previousLocalTransactionId, \"previousLocalTransactionId\");\n const observedHeadSequence = nonnegativeSafeInteger(\n input.observedHeadSequence,\n \"observedHeadSequence\",\n );\n if (!Array.isArray(input.causalBase)) throw new TypeError(\"causalBase must be an array\");\n if (input.causalBase.length > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalByReplica = new Map<string, number>();\n for (const entry of input.causalBase) {\n if (!isPlainRecord(entry)) throw new TypeError(\"causal entries must be plain records\");\n const causalReplicaId = replicaIdentity(entry.replicaId, \"causal replicaId\");\n if (causalByReplica.has(causalReplicaId)) throw new TypeError(\"duplicate causal replicaId\");\n causalByReplica.set(\n causalReplicaId,\n positiveSafeInteger(entry.counter, `causal counter for ${causalReplicaId}`),\n );\n }\n const causalBase = [...causalByReplica]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([causalReplicaId, counter]) => Object.freeze({ replicaId: causalReplicaId, counter }));\n if (!Array.isArray(input.selectiveUndoOperationIds)) {\n throw new TypeError(\"selectiveUndoOperationIds must be an array\");\n }\n if (input.selectiveUndoOperationIds.length > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const undoSet = new Set<string>();\n for (const value of input.selectiveUndoOperationIds) {\n const operationId = stableId(value, \"selective undo operation id\");\n if (undoSet.has(operationId)) throw new TypeError(\"duplicate selective undo operation id\");\n undoSet.add(operationId);\n }\n const selectiveUndoOperationIds = [...undoSet].sort(compareCodeUnits);\n if (!(input.commandBytes instanceof Uint8Array)) {\n throw new TypeError(\"commandBytes must be a Uint8Array\");\n }\n if (input.commandBytes.byteLength < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (input.commandBytes.byteLength > EDITABLE_ARTIFACT_COMMAND_MAX_BYTES) {\n throw new RangeError(\"commandBytes exceeds its byte limit\");\n }\n return Object.freeze({\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase: Object.freeze(causalBase),\n selectiveUndoOperationIds: Object.freeze(selectiveUndoOperationIds),\n commandBytes: copyCommandBytes ? input.commandBytes.slice() : input.commandBytes,\n });\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nfunction stableId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !STABLE_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero fixed-width lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction replicaIdentity(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !REPLICA_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero 64-bit lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction portableTransactionId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !CLIENT_TRANSACTION_ID.test(value)) {\n throw new TypeError(`${label} must contain 1-200 portable identifier characters`);\n }\n return value;\n}\n\nfunction positiveU16(value: unknown, label: string): number {\n if (!Number.isInteger(value) || (value as number) < 1 || (value as number) > 0xffff) {\n throw new TypeError(`${label} must be a positive 16-bit integer`);\n }\n return value as number;\n}\n\nfunction positiveSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 1) {\n throw new TypeError(`${label} must be a positive safe integer`);\n }\n return value as number;\n}\n\nfunction nonnegativeSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 0) {\n throw new TypeError(`${label} must be a nonnegative safe integer`);\n }\n return value as number;\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction equalBytes(left: Uint8Array, right: Uint8Array): boolean {\n return (\n left.byteLength === right.byteLength && left.every((value, index) => value === right[index])\n );\n}\n\nclass BinaryWriter {\n private buffer = new Uint8Array(1_024);\n private length = 0;\n\n constructor(private readonly maximum: number) {}\n\n u8(value: number): void {\n this.ensure(1);\n this.buffer[this.length++] = value;\n }\n\n u16(value: number): void {\n this.ensure(2);\n this.buffer[this.length++] = value & 0xff;\n this.buffer[this.length++] = (value >>> 8) & 0xff;\n }\n\n u32(value: number): void {\n this.ensure(4);\n for (let offset = 0; offset < 4; offset += 1) {\n this.buffer[this.length++] = Math.floor(value / 2 ** (offset * 8)) & 0xff;\n }\n }\n\n u64(value: number): void {\n if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(\"u64 must be safe\");\n this.ensure(8);\n let remaining = BigInt(value);\n for (let offset = 0; offset < 8; offset += 1) {\n this.buffer[this.length++] = Number(remaining & 0xffn);\n remaining >>= 8n;\n }\n }\n\n string(value: string): void {\n const bytes = textEncoder.encode(value);\n if (bytes.byteLength > 0xffff) throw new RangeError(\"intent string exceeds 65535 bytes\");\n this.u16(bytes.byteLength);\n this.bytes(bytes);\n }\n\n byteBlock(value: Uint8Array): void {\n this.u32(value.byteLength);\n this.bytes(value);\n }\n\n bytes(value: Uint8Array): void {\n this.ensure(value.byteLength);\n this.buffer.set(value, this.length);\n this.length += value.byteLength;\n }\n\n finish(): Uint8Array {\n return this.buffer.slice(0, this.length);\n }\n\n private ensure(additional: number): void {\n const needed = this.length + additional;\n if (!Number.isSafeInteger(needed) || needed > this.maximum) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n if (needed <= this.buffer.byteLength) return;\n let size = this.buffer.byteLength;\n while (size < needed) size = Math.min(this.maximum, size * 2);\n const next = new Uint8Array(size);\n next.set(this.buffer.subarray(0, this.length));\n this.buffer = next;\n }\n}\n\nclass BinaryReader {\n private offset = 0;\n\n constructor(private readonly input: Uint8Array) {}\n\n u8(): number {\n this.require(1);\n return this.input[this.offset++]!;\n }\n\n u16(): number {\n this.require(2);\n const value = this.input[this.offset]! | (this.input[this.offset + 1]! << 8);\n this.offset += 2;\n return value;\n }\n\n u32(): number {\n this.require(4);\n const value =\n this.input[this.offset]! +\n this.input[this.offset + 1]! * 2 ** 8 +\n this.input[this.offset + 2]! * 2 ** 16 +\n this.input[this.offset + 3]! * 2 ** 24;\n this.offset += 4;\n return value;\n }\n\n u64(): number {\n this.require(8);\n let value = 0n;\n for (let offset = 0; offset < 8; offset += 1) {\n value |= BigInt(this.input[this.offset + offset]!) << BigInt(offset * 8);\n }\n this.offset += 8;\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new RangeError(\"u64 exceeds safe integer\");\n return Number(value);\n }\n\n string(): string {\n return textDecoder.decode(this.bytes(this.u16()));\n }\n\n byteBlock(maximum: number): Uint8Array {\n const length = this.u32();\n if (length < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (length > maximum) throw new RangeError(\"commandBytes exceeds its byte limit\");\n return this.bytes(length);\n }\n\n bytes(length: number): Uint8Array {\n this.require(length);\n const output = this.input.subarray(this.offset, this.offset + length);\n this.offset += length;\n return output;\n }\n\n done(): void {\n if (this.offset !== this.input.byteLength) {\n throw new TypeError(\"editable artifact intent contains trailing bytes\");\n }\n }\n\n private require(length: number): void {\n if (\n !Number.isSafeInteger(length) ||\n length < 0 ||\n this.offset + length > this.input.byteLength\n ) {\n throw new TypeError(\"truncated editable artifact intent\");\n }\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,kBAAkB;AASpB,IAAM,mCAAmC;AACzC,IAAM,qCAAqC,IAAI,OAAO;AACtD,IAAM,sCAAsC,IAAI,OAAO;AACvD,IAAM,6CAA6C;AAEnD,IAAM,+CAA+C,KAAK,OAAO;AACjE,IAAM,6CAA6C;AACnD,IAAM,4CAA4C;AAEzD,IAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,UAAU;AACjD,IAAM,cAAc,IAAI,YAAY;AACpC,IAAM,cAAc,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AAC5D,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,wBAAwB;AAC9B,IAAM,eAAe;AA4Bd,SAAS,qCACd,OACY;AAGZ,QAAM,SAAS,gBAAgB,OAAO,KAAK;AAC3C,QAAM,SAAS,IAAI,aAAa,kCAAkC;AAClE,SAAO,MAAM,KAAK;AAClB,SAAO,IAAI,OAAO,eAAe;AACjC,SAAO,IAAI,OAAO,eAAe;AACjC,SAAO,IAAI,OAAO,kBAAkB;AACpC,SAAO,IAAI,OAAO,sBAAsB;AACxC,SAAO,OAAO,OAAO,UAAU;AAC/B,SAAO,OAAO,OAAO,mBAAmB;AACxC,SAAO,OAAO,OAAO,SAAS;AAC9B,SAAO,IAAI,OAAO,cAAc;AAChC,SAAO,GAAG,OAAO,+BAA+B,OAAO,IAAI,CAAC;AAC5D,MAAI,OAAO,+BAA+B,MAAM;AAC9C,WAAO,OAAO,OAAO,0BAA0B;AAAA,EACjD;AACA,SAAO,IAAI,OAAO,oBAAoB;AACtC,SAAO,IAAI,OAAO,WAAW,MAAM;AACnC,aAAW,SAAS,OAAO,YAAY;AACrC,WAAO,OAAO,MAAM,SAAS;AAC7B,WAAO,IAAI,MAAM,OAAO;AAAA,EAC1B;AACA,SAAO,IAAI,OAAO,0BAA0B,MAAM;A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