@openplanr/protocol 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +9 -0
  2. package/package.json +17 -1
  3. package/registries/commands.json +11 -11
  4. package/registries/skills.json +86 -8
  5. package/registry/v1.17.0/commands.json +88 -0
  6. package/schemas/v1.16.0/artifact-envelope.schema.json +408 -0
  7. package/schemas/v1.16.0/design-review-bundle.schema.json +590 -0
  8. package/schemas/v1.17.0/artifact-paste-v2.schema.json +52 -0
  9. package/schemas/v1.17.0/artifact-room-append-v3.schema.json +159 -0
  10. package/schemas/v1.17.0/artifact-room-create-v3.schema.json +111 -0
  11. package/schemas/v1.17.0/artifact-room-descriptor-v3.schema.json +92 -0
  12. package/schemas/v1.17.0/artifact-room-event-v3.schema.json +130 -0
  13. package/schemas/v1.17.0/artifact-room-management-v3.schema.json +47 -0
  14. package/schemas/v1.17.0/artifact-room-read-page-v3.schema.json +308 -0
  15. package/schemas/v1.17.0/company-resource-manifest.schema.json +128 -0
  16. package/schemas/v1.17.0/company-resource-upload-prepare.schema.json +164 -0
  17. package/schemas/v1.17.0/company-resource-upload-receipt.schema.json +63 -0
  18. package/schemas/v1.17.0/company-resource-upload-status.schema.json +123 -0
  19. package/schemas/v1.17.0/diagram-authoring-bundle.schema.json +1117 -0
  20. package/schemas/v1.17.0/diagram-edit-transaction.schema.json +3295 -0
  21. package/schemas/v1.17.0/diagram-presentation.schema.json +37 -0
  22. package/schemas/v1.17.0/diagram-review-bundle.schema.json +2439 -0
  23. package/schemas/v1.17.0/encrypted-resource-manifest.schema.json +131 -0
  24. package/schemas/v1.17.0/encrypted-upload-commit.schema.json +38 -0
  25. package/schemas/v1.17.0/encrypted-upload-prepare.schema.json +234 -0
  26. package/schemas/v1.17.0/encrypted-upload-receipt.schema.json +54 -0
  27. package/schemas/v1.17.0/encrypted-upload-status.schema.json +129 -0
  28. package/schemas/v1.17.0/encrypted-workspace-event-v2.schema.json +79 -0
  29. package/schemas/v1.17.0/encrypted-workspace-v2.schema.json +91 -0
  30. package/schemas/v1.17.0/enterprise-agent-handoff.schema.json +985 -0
  31. package/schemas/v1.17.0/enterprise-artifact-revision.schema.json +115 -0
  32. package/schemas/v1.17.0/enterprise-change-proposal.schema.json +379 -0
  33. package/schemas/v1.17.0/enterprise-evidence-reference.schema.json +159 -0
  34. package/schemas/v1.17.0/enterprise-review-thread.schema.json +298 -0
  35. package/schemas/v1.17.0/enterprise-sync-state.schema.json +189 -0
  36. package/schemas/v1.17.0/preview-bridge-message.schema.json +197 -0
  37. package/schemas/v1.17.0/resource-catalog.schema.json +145 -0
  38. package/schemas/v1.17.0/sharing-crypto-aad.schema.json +36 -0
  39. package/schemas/v1.17.0/workspace-management-v2.schema.json +45 -0
  40. package/schemas/v1.17.0/workspace-rotation-v2.schema.json +61 -0
  41. package/src/bounded-json-data.d.mts +2 -0
  42. package/src/bounded-json-data.mjs +56 -0
  43. package/src/browser-contracts.d.mts +14 -1
  44. package/src/browser-contracts.mjs +16 -0
  45. package/src/canonical-json.mjs +17 -16
  46. package/src/contracts.d.mts +1 -1
  47. package/src/contracts.mjs +90 -2
  48. package/src/diagram-authoring-contracts.d.mts +12 -0
  49. package/src/diagram-authoring-contracts.mjs +174 -1
  50. package/src/enterprise-contract-validation.d.mts +44 -0
  51. package/src/enterprise-contract-validation.mjs +279 -0
  52. package/src/enterprise-contracts.mjs +25 -231
  53. package/src/enterprise-resource-contracts.d.mts +72 -0
  54. package/src/enterprise-resource-contracts.mjs +202 -0
  55. package/src/generated/artifact-envelope-metadata.mjs +769 -0
  56. package/src/generated/canonical-registries.mjs +97 -19
  57. package/src/index.d.mts +21 -0
  58. package/src/index.mjs +23 -0
  59. package/src/large-object-contracts.d.mts +107 -0
  60. package/src/large-object-contracts.mjs +473 -0
  61. package/src/large-object-limits.d.mts +16 -0
  62. package/src/large-object-limits.mjs +17 -0
  63. package/src/registries.mjs +1 -0
  64. package/src/review-experience-contracts.d.mts +1 -0
  65. package/src/review-experience-contracts.mjs +25 -4
  66. package/src/sharing-security-contracts.d.mts +63 -0
  67. package/src/sharing-security-contracts.mjs +403 -0
  68. package/src/studio-presentation-contracts.d.mts +92 -0
  69. package/src/studio-presentation-contracts.mjs +287 -0
@@ -0,0 +1,145 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openplanr.dev/schemas/v1.17.0/resource-catalog.schema.json",
4
+ "x-openplanr-contract": {
5
+ "id": "resource-catalog",
6
+ "version": "1.17.0"
7
+ },
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "schemaVersion": {
12
+ "const": "1.0.0"
13
+ },
14
+ "kind": {
15
+ "const": "openplanr-resource-catalog"
16
+ },
17
+ "bundle": {
18
+ "type": "object"
19
+ },
20
+ "uniqueHtmlBytes": {
21
+ "type": "integer",
22
+ "minimum": 0,
23
+ "maximum": 104857600
24
+ },
25
+ "totalDecodedBytes": {
26
+ "type": "integer",
27
+ "minimum": 1,
28
+ "maximum": 134217728
29
+ },
30
+ "resources": {
31
+ "type": "array",
32
+ "minItems": 1,
33
+ "maxItems": 1024,
34
+ "items": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "properties": {
38
+ "id": {
39
+ "type": "string",
40
+ "pattern": "^r[0-9]{1,4}$"
41
+ },
42
+ "type": {
43
+ "enum": [
44
+ "html-segments",
45
+ "shared-block",
46
+ "asset"
47
+ ]
48
+ },
49
+ "offset": {
50
+ "type": "integer",
51
+ "minimum": 0,
52
+ "maximum": 134217728
53
+ },
54
+ "encodedBytes": {
55
+ "type": "integer",
56
+ "minimum": 1,
57
+ "maximum": 134217728
58
+ },
59
+ "decodedBytes": {
60
+ "type": "integer",
61
+ "minimum": 1,
62
+ "maximum": 134217728
63
+ },
64
+ "codec": {
65
+ "enum": [
66
+ "identity",
67
+ "deflate-raw"
68
+ ]
69
+ },
70
+ "sha256": {
71
+ "type": "string",
72
+ "pattern": "^[a-f0-9]{64}$"
73
+ }
74
+ },
75
+ "required": [
76
+ "id",
77
+ "type",
78
+ "offset",
79
+ "encodedBytes",
80
+ "decodedBytes",
81
+ "codec",
82
+ "sha256"
83
+ ]
84
+ }
85
+ },
86
+ "sources": {
87
+ "type": "array",
88
+ "minItems": 1,
89
+ "maxItems": 256,
90
+ "items": {
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "properties": {
94
+ "id": {
95
+ "type": "string",
96
+ "minLength": 1,
97
+ "maxLength": 128
98
+ },
99
+ "resourceId": {
100
+ "type": "string",
101
+ "pattern": "^r[0-9]{1,4}$"
102
+ },
103
+ "htmlBytes": {
104
+ "type": "integer",
105
+ "minimum": 1,
106
+ "maximum": 104857600
107
+ },
108
+ "sha256": {
109
+ "type": "string",
110
+ "pattern": "^[a-f0-9]{64}$"
111
+ }
112
+ },
113
+ "required": [
114
+ "id",
115
+ "resourceId",
116
+ "htmlBytes",
117
+ "sha256"
118
+ ]
119
+ }
120
+ },
121
+ "viewSources": {
122
+ "type": "object",
123
+ "maxProperties": 4096,
124
+ "additionalProperties": {
125
+ "type": "string",
126
+ "minLength": 1,
127
+ "maxLength": 128
128
+ }
129
+ },
130
+ "reviewOf": {
131
+ "type": "string",
132
+ "pattern": "^[a-f0-9]{64}$"
133
+ }
134
+ },
135
+ "required": [
136
+ "schemaVersion",
137
+ "kind",
138
+ "bundle",
139
+ "uniqueHtmlBytes",
140
+ "totalDecodedBytes",
141
+ "resources",
142
+ "sources",
143
+ "viewSources"
144
+ ]
145
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openplanr.dev/schemas/v1.17.0/sharing-crypto-aad.schema.json",
4
+ "x-openplanr-contract": {
5
+ "id": "sharing-crypto-aad",
6
+ "version": "1.17.0"
7
+ },
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "version": {
12
+ "const": "2.0.0"
13
+ },
14
+ "purpose": {
15
+ "enum": [
16
+ "artifact-paste",
17
+ "room-envelope",
18
+ "room-event"
19
+ ]
20
+ },
21
+ "objectId": {
22
+ "type": "string",
23
+ "pattern": "^[A-Za-z0-9_-]{16,128}$"
24
+ },
25
+ "recordId": {
26
+ "type": "string",
27
+ "pattern": "^[A-Za-z0-9._:-]{1,128}$"
28
+ }
29
+ },
30
+ "required": [
31
+ "version",
32
+ "purpose",
33
+ "objectId",
34
+ "recordId"
35
+ ]
36
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openplanr.dev/schemas/v1.17.0/workspace-management-v2.schema.json",
4
+ "x-openplanr-contract": {
5
+ "id": "workspace-management-v2",
6
+ "version": "1.17.0"
7
+ },
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "operationId": {
12
+ "type": "string",
13
+ "pattern": "^[A-Za-z0-9_-]{22,64}$"
14
+ },
15
+ "expectedVersion": {
16
+ "type": "integer",
17
+ "minimum": 1,
18
+ "maximum": 9007199254740991
19
+ },
20
+ "epoch": {
21
+ "type": "integer",
22
+ "minimum": 1,
23
+ "maximum": 9007199254740991
24
+ },
25
+ "action": {
26
+ "enum": [
27
+ "pause",
28
+ "resume",
29
+ "revoke",
30
+ "delete"
31
+ ]
32
+ },
33
+ "signature": {
34
+ "type": "string",
35
+ "pattern": "^[A-Za-z0-9_-]{86}$"
36
+ }
37
+ },
38
+ "required": [
39
+ "operationId",
40
+ "expectedVersion",
41
+ "epoch",
42
+ "action",
43
+ "signature"
44
+ ]
45
+ }
@@ -0,0 +1,61 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://openplanr.dev/schemas/v1.17.0/workspace-rotation-v2.schema.json",
4
+ "x-openplanr-contract": {
5
+ "id": "workspace-rotation-v2",
6
+ "version": "1.17.0"
7
+ },
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "operationId": {
12
+ "type": "string",
13
+ "pattern": "^[A-Za-z0-9_-]{22,64}$"
14
+ },
15
+ "expectedVersion": {
16
+ "type": "integer",
17
+ "minimum": 1,
18
+ "maximum": 9007199254740991
19
+ },
20
+ "epoch": {
21
+ "type": "integer",
22
+ "minimum": 2,
23
+ "maximum": 9007199254740991
24
+ },
25
+ "reviewerAuthHash": {
26
+ "type": "string",
27
+ "pattern": "^[a-f0-9]{64}$"
28
+ },
29
+ "keyring": {
30
+ "type": "object",
31
+ "additionalProperties": false,
32
+ "properties": {
33
+ "iv": {
34
+ "type": "string",
35
+ "pattern": "^[A-Za-z0-9_-]{16}$"
36
+ },
37
+ "ciphertext": {
38
+ "type": "string",
39
+ "pattern": "^[A-Za-z0-9_-]+$",
40
+ "maxLength": 65536
41
+ }
42
+ },
43
+ "required": [
44
+ "iv",
45
+ "ciphertext"
46
+ ]
47
+ },
48
+ "signature": {
49
+ "type": "string",
50
+ "pattern": "^[A-Za-z0-9_-]{86}$"
51
+ }
52
+ },
53
+ "required": [
54
+ "operationId",
55
+ "expectedVersion",
56
+ "epoch",
57
+ "reviewerAuthHash",
58
+ "keyring",
59
+ "signature"
60
+ ]
61
+ }
@@ -0,0 +1,2 @@
1
+ /** Inspect finite, acyclic JSON data with resource limits before reading schema fields. */
2
+ export declare function assertLargeObjectData<T>(value: T): T;
@@ -0,0 +1,56 @@
1
+ import { assertPlainData } from './canonical-json.mjs';
2
+
3
+ /** Bound hostile input before any resource schema reader or contract field access.
4
+ * @type {typeof import('./bounded-json-data.d.mts').assertLargeObjectData}
5
+ */
6
+ export function assertLargeObjectData(value) {
7
+ const pending = [[value, 0]],
8
+ visited = new Set();
9
+ let nodes = 0;
10
+ for (let next = pending.pop(); next; next = pending.pop()) {
11
+ const [item, depth, exit] = next;
12
+ if (exit) {
13
+ visited.delete(item);
14
+ continue;
15
+ }
16
+ if (++nodes > 250000 || depth > 40)
17
+ throw new RangeError('Large object complexity exceeds its limit.');
18
+ if (item && typeof item === 'object') {
19
+ if (visited.has(item)) throw new TypeError('Large objects require acyclic plain data.');
20
+ visited.add(item);
21
+ pending.push([item, depth, true]);
22
+ const array = Array.isArray(item);
23
+ const prototype = Object.getPrototypeOf(item);
24
+ if (
25
+ array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null
26
+ )
27
+ throw new TypeError('Large objects require plain data.');
28
+ const descriptors = Object.getOwnPropertyDescriptors(item);
29
+ const keys = Reflect.ownKeys(descriptors);
30
+ const length = array ? descriptors.length.value : null;
31
+ if (array && keys.length !== length + 1)
32
+ throw new TypeError('Large objects require dense JSON arrays.');
33
+ for (const key of keys) {
34
+ if (typeof key !== 'string' || ['__proto__', 'constructor', 'prototype'].includes(key))
35
+ throw new TypeError('Large objects cannot contain unsafe or symbolic keys.');
36
+ const descriptor = descriptors[key];
37
+ if (!('value' in descriptor))
38
+ throw new TypeError('Large objects cannot contain accessors.');
39
+ if (!(array && key === 'length') && !descriptor.enumerable)
40
+ throw new TypeError('Large objects require enumerable JSON fields.');
41
+ if (
42
+ array &&
43
+ key !== 'length' &&
44
+ (!Number.isSafeInteger(Number(key)) ||
45
+ Number(key) < 0 ||
46
+ Number(key) >= length ||
47
+ String(Number(key)) !== key)
48
+ )
49
+ throw new TypeError('Large objects require numeric JSON array indices.');
50
+ pending.push([descriptor.value, depth + 1]);
51
+ }
52
+ }
53
+ }
54
+ assertPlainData(value, 'Large object data');
55
+ return value;
56
+ }
@@ -6,7 +6,16 @@ export declare const PROTOCOL_V111_CONTRACTS: Readonly<Record<string, string>>;
6
6
  export declare function protocolAssetUrl(
7
7
  kind: string,
8
8
  options?: {
9
- protocolVersion?: '1.5.0' | '1.6.0' | '1.7.0' | '1.8.0' | '1.11.0' | '1.13.0' | '1.15.0';
9
+ protocolVersion?:
10
+ | '1.5.0'
11
+ | '1.6.0'
12
+ | '1.7.0'
13
+ | '1.8.0'
14
+ | '1.11.0'
15
+ | '1.13.0'
16
+ | '1.15.0'
17
+ | '1.16.0'
18
+ | '1.17.0';
10
19
  },
11
20
  ): URL;
12
21
  export declare const PROTOCOL_V113_CONTRACTS: Readonly<Record<string, string>>;
@@ -17,3 +26,7 @@ export declare function validateDiagramReviewArtifact(
17
26
  value: unknown,
18
27
  options?: { protocolVersion?: string },
19
28
  ): Array<{ path: string; rule: string; detail: string }>;
29
+
30
+ export declare const PROTOCOL_V116_CONTRACTS: Readonly<Record<string, string>>;
31
+
32
+ export declare const PROTOCOL_V117_CONTRACTS: Readonly<Record<string, string>>;
@@ -1,4 +1,5 @@
1
1
  // @ts-check
2
+
2
3
  import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
3
4
  import { DIAGRAM_AUTHORING_CONTRACT_FILES } from './diagram-authoring-contracts.mjs';
4
5
  import {
@@ -7,6 +8,7 @@ import {
7
8
  assertDiagramWorkspaceContract,
8
9
  DIAGRAM_REVIEW_SCHEMAS,
9
10
  } from './diagram-review-contracts.mjs';
11
+ import { LARGE_OBJECT_SCHEMAS } from './large-object-contracts.mjs';
10
12
  import {
11
13
  PROTOCOL_V16_CONTRACT_FILES,
12
14
  PROTOCOL_V17_CONTRACT_FILES,
@@ -73,6 +75,18 @@ export function validateDiagramReviewArtifact(kind, value, { protocolVersion = '
73
75
  }
74
76
  }
75
77
 
78
+ /** @type {typeof import('./browser-contracts.d.mts').PROTOCOL_V116_CONTRACTS} */
79
+ export const PROTOCOL_V116_CONTRACTS = Object.freeze({
80
+ 'artifact-envelope': 'artifact-envelope.schema.json',
81
+ 'design-review-bundle': 'design-review-bundle.schema.json',
82
+ });
83
+
84
+ export const PROTOCOL_V117_CONTRACTS = Object.freeze(
85
+ Object.fromEntries(
86
+ Object.keys(LARGE_OBJECT_SCHEMAS).map((kind) => [kind, `${kind}.schema.json`]),
87
+ ),
88
+ );
89
+
76
90
  const PROTOCOL_CONTRACTS_BY_VERSION = Object.freeze({
77
91
  '1.5.0': PROTOCOL_V15_CONTRACTS,
78
92
  '1.6.0': PROTOCOL_V16_CONTRACTS,
@@ -81,6 +95,8 @@ const PROTOCOL_CONTRACTS_BY_VERSION = Object.freeze({
81
95
  '1.11.0': PROTOCOL_V111_CONTRACTS,
82
96
  '1.13.0': PROTOCOL_V113_CONTRACTS,
83
97
  '1.15.0': PROTOCOL_V115_CONTRACTS,
98
+ '1.16.0': PROTOCOL_V116_CONTRACTS,
99
+ '1.17.0': PROTOCOL_V117_CONTRACTS,
84
100
  });
85
101
 
86
102
  /**
@@ -65,7 +65,7 @@ export function canonicalizeJson(value) {
65
65
  return serialize(value, '$', new Set());
66
66
  }
67
67
 
68
- const SHA256_K = /* @__PURE__ */ new Uint32Array([
68
+ const SHA256_K = /* @__PURE__ */ new Int32Array([
69
69
  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
70
70
  0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
71
71
  0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
@@ -108,7 +108,8 @@ export function sha256Hex(value) {
108
108
  let h5 = 0x9b05688c;
109
109
  let h6 = 0x1f83d9ab;
110
110
  let h7 = 0x5be0cd19;
111
- const words = new Uint32Array(64);
111
+ // Signed words retain the same modulo-2^32 bits without promoting each round to unsigned doubles.
112
+ const words = new Int32Array(64);
112
113
 
113
114
  for (let offset = 0; offset < bytes.length; offset += 64) {
114
115
  for (let index = 0; index < 16; index += 1) words[index] = view.getUint32(offset + index * 4);
@@ -117,7 +118,7 @@ export function sha256Hex(value) {
117
118
  rotr(words[index - 15], 7) ^ rotr(words[index - 15], 18) ^ (words[index - 15] >>> 3);
118
119
  const s1 =
119
120
  rotr(words[index - 2], 17) ^ rotr(words[index - 2], 19) ^ (words[index - 2] >>> 10);
120
- words[index] = (words[index - 16] + s0 + words[index - 7] + s1) >>> 0;
121
+ words[index] = (words[index - 16] + s0 + words[index - 7] + s1) | 0;
121
122
  }
122
123
  let a = h0;
123
124
  let b = h1;
@@ -130,30 +131,30 @@ export function sha256Hex(value) {
130
131
  for (let index = 0; index < 64; index += 1) {
131
132
  const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
132
133
  const choice = (e & f) ^ (~e & g);
133
- const temp1 = (h + s1 + choice + SHA256_K[index] + words[index]) >>> 0;
134
+ const temp1 = (h + s1 + choice + SHA256_K[index] + words[index]) | 0;
134
135
  const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
135
136
  const majority = (a & b) ^ (a & c) ^ (b & c);
136
- const temp2 = (s0 + majority) >>> 0;
137
+ const temp2 = (s0 + majority) | 0;
137
138
  h = g;
138
139
  g = f;
139
140
  f = e;
140
- e = (d + temp1) >>> 0;
141
+ e = (d + temp1) | 0;
141
142
  d = c;
142
143
  c = b;
143
144
  b = a;
144
- a = (temp1 + temp2) >>> 0;
145
+ a = (temp1 + temp2) | 0;
145
146
  }
146
- h0 = (h0 + a) >>> 0;
147
- h1 = (h1 + b) >>> 0;
148
- h2 = (h2 + c) >>> 0;
149
- h3 = (h3 + d) >>> 0;
150
- h4 = (h4 + e) >>> 0;
151
- h5 = (h5 + f) >>> 0;
152
- h6 = (h6 + g) >>> 0;
153
- h7 = (h7 + h) >>> 0;
147
+ h0 = (h0 + a) | 0;
148
+ h1 = (h1 + b) | 0;
149
+ h2 = (h2 + c) | 0;
150
+ h3 = (h3 + d) | 0;
151
+ h4 = (h4 + e) | 0;
152
+ h5 = (h5 + f) | 0;
153
+ h6 = (h6 + g) | 0;
154
+ h7 = (h7 + h) | 0;
154
155
  }
155
156
  return [h0, h1, h2, h3, h4, h5, h6, h7]
156
- .map((part) => part.toString(16).padStart(8, '0'))
157
+ .map((part) => (part >>> 0).toString(16).padStart(8, '0'))
157
158
  .join('');
158
159
  }
159
160
 
@@ -63,7 +63,7 @@ export declare function resolveOperateExperienceSchemaV2(
63
63
  kind: string,
64
64
  options?: { protocolVersion?: string },
65
65
  ): ResolvedProtocolSchema;
66
- /** Includes closed diagram review kinds at exact Protocol 1.15.0. */
66
+ /** Includes semantic validation for exact diagram readers and additive Protocol 1.17 contracts. */
67
67
  export declare function validateProtocolArtifact(
68
68
  kind: string,
69
69
  value: unknown,
package/src/contracts.mjs CHANGED
@@ -15,6 +15,7 @@ import { PROTOCOL_V115_CONTRACTS, validateDiagramReviewArtifact } from './browse
15
15
  import { deepFreeze } from './canonical-json.mjs';
16
16
  import { DESIGN_HANDOFF_CONTRACT_FILES } from './design-handoff-contracts.mjs';
17
17
  import {
18
+ assertDiagramData,
18
19
  DIAGRAM_AUTHORING_CONTRACT_FILES,
19
20
  validateDiagramAuthoringArtifact,
20
21
  } from './diagram-authoring-contracts.mjs';
@@ -22,11 +23,26 @@ import { ENTERPRISE_SCHEMAS } from './enterprise-contracts.mjs';
22
23
  import { PipelineError } from './errors.mjs';
23
24
  import { OPERATE_CONTRACT_CATALOG_V2 } from './generated/contract-catalog-v2.mjs';
24
25
  import { validateJson } from './json-schema.mjs';
26
+ import {
27
+ assertLargeObjectContract,
28
+ assertLargeObjectData,
29
+ LARGE_OBJECT_SCHEMAS,
30
+ } from './large-object-contracts.mjs';
31
+ import {
32
+ assertSharingSecurityContract,
33
+ SHARING_SECURITY_SCHEMAS,
34
+ } from './sharing-security-contracts.mjs';
25
35
  import {
26
36
  PROTOCOL_V16_CONTRACT_FILES,
27
37
  PROTOCOL_V17_CONTRACT_FILES,
28
38
  PROTOCOL_V18_CONTRACT_FILES,
29
39
  } from './skill-source-contracts.mjs';
40
+ import {
41
+ assertDiagramPresentation,
42
+ assertDiagramReviewBundleV11,
43
+ assertVersionedDiagramAuthoringBundle,
44
+ assertVersionedDiagramEditTransaction,
45
+ } from './studio-presentation-contracts.mjs';
30
46
 
31
47
  const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
32
48
 
@@ -37,10 +53,21 @@ const v17Schema = (kind) => `schemas/v1.7.0/${PROTOCOL_V17_CONTRACT_FILES[kind]}
37
53
  const v18Schema = (kind) => `schemas/v1.8.0/${PROTOCOL_V18_CONTRACT_FILES[kind]}`;
38
54
 
39
55
  const foundationPaths = {
56
+ ...Object.fromEntries(
57
+ Object.keys(LARGE_OBJECT_SCHEMAS).map((name) => [
58
+ name,
59
+ { '1.17.0': `schemas/v1.17.0/${name}.schema.json` },
60
+ ]),
61
+ ),
40
62
  ...Object.fromEntries(
41
63
  Object.keys(ENTERPRISE_SCHEMAS).map((name) => [
42
64
  name,
43
- { '1.12.0': `schemas/v1.12.0/${name}.schema.json` },
65
+ {
66
+ ...(Object.hasOwn(LARGE_OBJECT_SCHEMAS, name)
67
+ ? { '1.17.0': `schemas/v1.17.0/${name}.schema.json` }
68
+ : {}),
69
+ '1.12.0': `schemas/v1.12.0/${name}.schema.json`,
70
+ },
44
71
  ]),
45
72
  ),
46
73
  'design-document': { '1.9.0': 'schemas/v1.9.0/design-document.schema.json' },
@@ -51,6 +78,7 @@ const foundationPaths = {
51
78
  'design-review-bundle': {
52
79
  '1.9.0': 'schemas/v1.9.0/design-review-bundle.schema.json',
53
80
  '1.10.0': 'schemas/v1.10.0/design-review-bundle.schema.json',
81
+ '1.16.0': 'schemas/v1.16.0/design-review-bundle.schema.json',
54
82
  },
55
83
  'design-review-context': { '1.10.0': 'schemas/v1.10.0/design-review-context.schema.json' },
56
84
  'design-review-handoff': { '1.10.0': 'schemas/v1.10.0/design-review-handoff.schema.json' },
@@ -111,7 +139,10 @@ const foundationPaths = {
111
139
  '1.3.0': 'schemas/v1.3.0/release-compatibility-claim.schema.json',
112
140
  },
113
141
  'release-ledger-receipt': { '1.3.0': 'schemas/v1.3.0/release-ledger-receipt.schema.json' },
114
- 'artifact-envelope': { '1.1.0': 'schemas/v1.1.0/artifact-envelope.schema.json' },
142
+ 'artifact-envelope': {
143
+ '1.1.0': 'schemas/v1.1.0/artifact-envelope.schema.json',
144
+ '1.16.0': 'schemas/v1.16.0/artifact-envelope.schema.json',
145
+ },
115
146
  'artifact-review': { '1.1.0': 'schemas/v1.1.0/artifact-review.schema.json' },
116
147
  'artifact-paste': { '1.1.0': 'schemas/v1.1.0/artifact-paste.schema.json' },
117
148
  'artifact-room-event': { '1.1.0': 'schemas/v1.1.0/artifact-room-event.schema.json' },
@@ -1198,6 +1229,10 @@ function guidedQuestionnaireCompatibilityErrors(value) {
1198
1229
 
1199
1230
  /** @type {typeof import('./contracts.d.mts').validateProtocolArtifact} */
1200
1231
  export function validateProtocolArtifact(kind, value, { protocolVersion } = {}) {
1232
+ const studioKind = Object.hasOwn(LARGE_OBJECT_SCHEMAS, kind);
1233
+ if (studioKind && protocolVersion === '1.17.0') {
1234
+ return validateStudioArtifact(kind, value, sharedProtocolSchema(kind, protocolVersion));
1235
+ }
1201
1236
  if (Object.hasOwn(PROTOCOL_V115_CONTRACTS, kind)) {
1202
1237
  // Review transport envelopes do not carry a Protocol version. Do not read
1203
1238
  // arbitrary input properties while selecting the dedicated safety preflight.
@@ -1222,13 +1257,66 @@ export function validateProtocolArtifact(kind, value, { protocolVersion } = {})
1222
1257
  if (descriptor && !Object.hasOwn(descriptor, 'value'))
1223
1258
  return validateDiagramAuthoringArtifact(kind, value);
1224
1259
  versionInput = { protocolVersion: descriptor?.value };
1260
+ } else if (studioKind && !protocolVersion) {
1261
+ // New resource envelopes may be hostile objects. Version inference must use
1262
+ // descriptors too; the bounded additive reader owns the safety diagnostic.
1263
+ let descriptor;
1264
+ try {
1265
+ descriptor =
1266
+ value !== null && typeof value === 'object'
1267
+ ? Object.getOwnPropertyDescriptor(value, 'protocolVersion')
1268
+ : undefined;
1269
+ } catch {
1270
+ return invalidStudioData();
1271
+ }
1272
+ if (descriptor && !Object.hasOwn(descriptor, 'value')) return invalidStudioData();
1273
+ versionInput = { protocolVersion: descriptor?.value };
1225
1274
  }
1226
1275
  const version = inferredVersion(kind, versionInput, protocolVersion);
1276
+ if (studioKind && version === '1.17.0') {
1277
+ return validateStudioArtifact(kind, value, sharedProtocolSchema(kind, version));
1278
+ }
1227
1279
  if (version === '1.13.0' && authoringKind) {
1228
1280
  return validateDiagramAuthoringArtifact(kind, value);
1229
1281
  }
1230
1282
  return validateGenericArtifact(kind, value, sharedProtocolSchema(kind, version));
1231
1283
  }
1284
+ function invalidStudioData() {
1285
+ return [
1286
+ { path: '$', rule: 'studio-protocol-contract', detail: 'Expected bounded inert JSON data.' },
1287
+ ];
1288
+ }
1289
+ function validateStudioArtifact(kind, value, resolved) {
1290
+ try {
1291
+ if (
1292
+ [
1293
+ 'diagram-authoring-bundle',
1294
+ 'diagram-edit-transaction',
1295
+ 'diagram-review-bundle',
1296
+ 'diagram-presentation',
1297
+ ].includes(kind)
1298
+ )
1299
+ assertDiagramData(value);
1300
+ else assertLargeObjectData(value);
1301
+ const errors = validateResolvedArtifact(value, resolved);
1302
+ if (errors.length) return errors;
1303
+ if (Object.hasOwn(SHARING_SECURITY_SCHEMAS, kind)) assertSharingSecurityContract(value, kind);
1304
+ else if (kind === 'diagram-authoring-bundle') assertVersionedDiagramAuthoringBundle(value);
1305
+ else if (kind === 'diagram-edit-transaction') assertVersionedDiagramEditTransaction(value);
1306
+ else if (kind === 'diagram-review-bundle') assertDiagramReviewBundleV11(value);
1307
+ else if (kind === 'diagram-presentation') assertDiagramPresentation(value);
1308
+ else assertLargeObjectContract(value, kind);
1309
+ return [];
1310
+ } catch (error) {
1311
+ return [
1312
+ {
1313
+ path: '$',
1314
+ rule: 'studio-protocol-contract',
1315
+ detail: error instanceof Error ? error.message : 'Invalid Studio contract data.',
1316
+ },
1317
+ ];
1318
+ }
1319
+ }
1232
1320
  function validateGenericArtifact(kind, value, resolved) {
1233
1321
  const errors = validateResolvedArtifact(value, resolved);
1234
1322
  if (kind === 'guided-questionnaire' && resolved.protocolVersion === '1.2.0')
@@ -454,3 +454,15 @@ export declare function summarizeDiagramAuthoringContent(bundle: DiagramAuthorin
454
454
  hasVisibleContent: boolean;
455
455
  };
456
456
  export declare function inspectLegacyDiagramDocument(value: unknown): DiagramLegacyInspection;
457
+
458
+ /** Internal: detached and recursively frozen inert data, without a semantic validity claim. */
459
+ export declare function copyImmutableDiagramData<T>(value: T, previous?: T | null): T;
460
+ /** Inspect inert authoring data with the existing aggregate limits, without copying it. */
461
+ export declare function assertDiagramData<T>(value: T): T;
462
+
463
+ /** Internal: seals an inert draft into an immutable copy without claiming semantic validity. */
464
+ export declare function sealImmutableDiagramData<T>(value: T, previous?: T | null): T;
465
+
466
+ export function immutableDiagramDataUsage(
467
+ value: unknown,
468
+ ): { values: number; text: number; height: number } | null;