openplanr 2.6.0 → 2.6.2

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 (50) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/CONTRIBUTING.md +2 -31
  3. package/dist/dashboard/.vite/manifest.json +1 -1
  4. package/dist/dashboard/assets/{index-BaARCc1f.js → index-AeydhSKa.js} +2 -2
  5. package/dist/dashboard/assets/{index-BaARCc1f.js.map → index-AeydhSKa.js.map} +1 -1
  6. package/dist/dashboard/dashboard-manifest.json +8 -8
  7. package/dist/dashboard/index.html +1 -1
  8. package/dist/services/codex-plugin-service.d.ts +2 -2
  9. package/dist/services/codex-plugin-service.d.ts.map +1 -1
  10. package/dist/services/codex-plugin-service.js +7 -7
  11. package/dist/services/codex-plugin-service.js.map +1 -1
  12. package/dist/services/diagram-artifact-service.d.ts +20 -0
  13. package/dist/services/diagram-artifact-service.d.ts.map +1 -1
  14. package/dist/services/diagram-artifact-service.js +10 -0
  15. package/dist/services/diagram-artifact-service.js.map +1 -1
  16. package/lib/host-packages/adapter-registry.json +5 -5
  17. package/lib/host-packages/capability-map.json +1 -1
  18. package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
  19. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
  20. package/lib/host-packages/claude/openplanr/.openplanr-content.json +10 -10
  21. package/lib/host-packages/claude/openplanr/skills/design/scripts/design.mjs +66 -1
  22. package/lib/host-packages/claude/openplanr/skills/design/scripts/runtime/packages/protocol/package.json +5 -1
  23. package/lib/host-packages/claude/openplanr/skills/design-loop/scripts/design.mjs +66 -1
  24. package/lib/host-packages/claude/openplanr/skills/design-loop/scripts/runtime/packages/protocol/package.json +5 -1
  25. package/lib/host-packages/claude/openplanr/skills/design-review/scripts/design.mjs +66 -1
  26. package/lib/host-packages/claude/openplanr/skills/design-review/scripts/runtime/packages/protocol/package.json +5 -1
  27. package/lib/host-packages/claude/openplanr/skills/plan/scripts/design.mjs +66 -1
  28. package/lib/host-packages/claude/openplanr/skills/plan/scripts/runtime/packages/protocol/package.json +5 -1
  29. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +10 -10
  30. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  31. package/lib/host-packages/cursor/openplanr/rules/planr-design/scripts/design.mjs +66 -1
  32. package/lib/host-packages/cursor/openplanr/rules/planr-design/scripts/runtime/packages/protocol/package.json +5 -1
  33. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/scripts/design.mjs +66 -1
  34. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/scripts/runtime/packages/protocol/package.json +5 -1
  35. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/scripts/design.mjs +66 -1
  36. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/scripts/runtime/packages/protocol/package.json +5 -1
  37. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/design.mjs +66 -1
  38. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/runtime/packages/protocol/package.json +5 -1
  39. package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
  40. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
  41. package/lib/host-packages/openai/openplanr/.openplanr-content.json +10 -10
  42. package/lib/host-packages/openai/openplanr/skills/design/scripts/design.mjs +66 -1
  43. package/lib/host-packages/openai/openplanr/skills/design/scripts/runtime/packages/protocol/package.json +5 -1
  44. package/lib/host-packages/openai/openplanr/skills/design-loop/scripts/design.mjs +66 -1
  45. package/lib/host-packages/openai/openplanr/skills/design-loop/scripts/runtime/packages/protocol/package.json +5 -1
  46. package/lib/host-packages/openai/openplanr/skills/design-review/scripts/design.mjs +66 -1
  47. package/lib/host-packages/openai/openplanr/skills/design-review/scripts/runtime/packages/protocol/package.json +5 -1
  48. package/lib/host-packages/openai/openplanr/skills/plan/scripts/design.mjs +66 -1
  49. package/lib/host-packages/openai/openplanr/skills/plan/scripts/runtime/packages/protocol/package.json +5 -1
  50. package/package.json +2 -2
@@ -14910,6 +14910,7 @@ function createArtifactReviewServer({
14910
14910
  throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Artifact review instance id is invalid.");
14911
14911
  }
14912
14912
  const sessions = /* @__PURE__ */ new Map();
14913
+ const ownerSessions = /* @__PURE__ */ new Map();
14913
14914
  let port = null;
14914
14915
  let closePromise = null;
14915
14916
  let pendingRegistrations = 0;
@@ -14917,7 +14918,7 @@ function createArtifactReviewServer({
14917
14918
  let draining = false;
14918
14919
  let emptyTimer = null;
14919
14920
  const stageRuntime = () => readFileSync11(STAGE_RUNTIME_PATH, "utf8");
14920
- const idle = () => sessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
+ const idle = () => sessions.size === 0 && ownerSessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
14922
  const scheduleEmpty = () => {
14922
14923
  if (emptyTimer || draining || typeof onEmpty !== "function") return;
14923
14924
  emptyTimer = setTimeout(async () => {
@@ -15042,6 +15043,41 @@ function createArtifactReviewServer({
15042
15043
  notFound(res, { head });
15043
15044
  return;
15044
15045
  }
15046
+ if (segments[0] === "o") {
15047
+ const owner = safeSessionId(segments[1]) && ownerSessions.get(segments[1]);
15048
+ if (draining || !sessionMatches(owner, segments[2])) {
15049
+ notFound(res, { head });
15050
+ return;
15051
+ }
15052
+ const request2 = Promise.resolve().then(() => owner.handleRequest({
15053
+ req,
15054
+ segments: segments.slice(3),
15055
+ head,
15056
+ origin: `http://${LOOPBACK_HOST}:${port}`,
15057
+ recoveryScope: owner.recoveryScope
15058
+ }));
15059
+ owner.pending.add(request2);
15060
+ let response;
15061
+ try {
15062
+ response = await request2;
15063
+ } finally {
15064
+ owner.pending.delete(request2);
15065
+ }
15066
+ if (!response) {
15067
+ notFound(res, { head });
15068
+ return;
15069
+ }
15070
+ send(res, response.status, JSON.stringify(response.body), {
15071
+ // Rejections may precede body consumption (for example Content-Length
15072
+ // above the limit). Do not reuse a socket containing unread body bytes.
15073
+ ...response.status >= 400 ? { connection: "close" } : {},
15074
+ "content-type": "application/json; charset=utf-8",
15075
+ "cross-origin-resource-policy": "same-origin",
15076
+ "content-security-policy": "default-src 'none'; frame-ancestors 'none'",
15077
+ "x-frame-options": "DENY"
15078
+ }, { head });
15079
+ return;
15080
+ }
15045
15081
  if (segments.length < 3 || segments[0] !== "r" || !safeSessionId(segments[1])) {
15046
15082
  notFound(res, { head });
15047
15083
  return;
@@ -15200,6 +15236,32 @@ function createArtifactReviewServer({
15200
15236
  controlToken,
15201
15237
  instanceId,
15202
15238
  sessionCount: () => sessions.size,
15239
+ /** Trusted local authority only; this operation has no HTTP control route. */
15240
+ registerOwnerSession({ handleRequest } = {}) {
15241
+ if (draining || closePromise || typeof handleRequest !== "function") {
15242
+ throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Local owner session cannot be registered.");
15243
+ }
15244
+ const id4 = mintCapabilityToken({ bytes: SESSION_ID_BYTES });
15245
+ const owner = {
15246
+ id: id4,
15247
+ capability: mintCapabilityToken({ bytes: SESSION_TOKEN_BYTES }),
15248
+ recoveryScope: `diagram-owner_${id4}`,
15249
+ handleRequest,
15250
+ pending: /* @__PURE__ */ new Set()
15251
+ };
15252
+ ownerSessions.set(id4, owner);
15253
+ return Object.freeze({
15254
+ sessionId: id4,
15255
+ capability: owner.capability,
15256
+ recoveryScope: owner.recoveryScope,
15257
+ path: `/o/${id4}/${owner.capability}/`,
15258
+ async close() {
15259
+ ownerSessions.delete(id4);
15260
+ await Promise.allSettled([...owner.pending]);
15261
+ if (idle()) scheduleEmpty();
15262
+ }
15263
+ });
15264
+ },
15203
15265
  isIdle: idle,
15204
15266
  accepting: () => !draining && !closePromise,
15205
15267
  beginCloseIfIdle() {
@@ -15224,6 +15286,9 @@ function createArtifactReviewServer({
15224
15286
  emptyTimer = null;
15225
15287
  closePromise = (async () => {
15226
15288
  sessions.clear();
15289
+ const pendingOwners = [...ownerSessions.values()].flatMap((owner) => [...owner.pending]);
15290
+ ownerSessions.clear();
15291
+ await Promise.allSettled(pendingOwners);
15227
15292
  await closeHttpServer(server);
15228
15293
  })();
15229
15294
  return closePromise;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplanr/protocol",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Canonical OpenPlanr schemas, registries, typed errors, and portable contract validation",
6
6
  "license": "MIT",
@@ -83,6 +83,10 @@
83
83
  "./enterprise-contracts": {
84
84
  "types": "./src/enterprise-contracts.d.mts",
85
85
  "import": "./src/enterprise-contracts.mjs"
86
+ },
87
+ "./diagram-authoring-contracts": {
88
+ "types": "./src/diagram-authoring-contracts.d.mts",
89
+ "import": "./src/diagram-authoring-contracts.mjs"
86
90
  }
87
91
  },
88
92
  "files": [
@@ -14910,6 +14910,7 @@ function createArtifactReviewServer({
14910
14910
  throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Artifact review instance id is invalid.");
14911
14911
  }
14912
14912
  const sessions = /* @__PURE__ */ new Map();
14913
+ const ownerSessions = /* @__PURE__ */ new Map();
14913
14914
  let port = null;
14914
14915
  let closePromise = null;
14915
14916
  let pendingRegistrations = 0;
@@ -14917,7 +14918,7 @@ function createArtifactReviewServer({
14917
14918
  let draining = false;
14918
14919
  let emptyTimer = null;
14919
14920
  const stageRuntime = () => readFileSync11(STAGE_RUNTIME_PATH, "utf8");
14920
- const idle = () => sessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
+ const idle = () => sessions.size === 0 && ownerSessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
14922
  const scheduleEmpty = () => {
14922
14923
  if (emptyTimer || draining || typeof onEmpty !== "function") return;
14923
14924
  emptyTimer = setTimeout(async () => {
@@ -15042,6 +15043,41 @@ function createArtifactReviewServer({
15042
15043
  notFound(res, { head });
15043
15044
  return;
15044
15045
  }
15046
+ if (segments[0] === "o") {
15047
+ const owner = safeSessionId(segments[1]) && ownerSessions.get(segments[1]);
15048
+ if (draining || !sessionMatches(owner, segments[2])) {
15049
+ notFound(res, { head });
15050
+ return;
15051
+ }
15052
+ const request2 = Promise.resolve().then(() => owner.handleRequest({
15053
+ req,
15054
+ segments: segments.slice(3),
15055
+ head,
15056
+ origin: `http://${LOOPBACK_HOST}:${port}`,
15057
+ recoveryScope: owner.recoveryScope
15058
+ }));
15059
+ owner.pending.add(request2);
15060
+ let response;
15061
+ try {
15062
+ response = await request2;
15063
+ } finally {
15064
+ owner.pending.delete(request2);
15065
+ }
15066
+ if (!response) {
15067
+ notFound(res, { head });
15068
+ return;
15069
+ }
15070
+ send(res, response.status, JSON.stringify(response.body), {
15071
+ // Rejections may precede body consumption (for example Content-Length
15072
+ // above the limit). Do not reuse a socket containing unread body bytes.
15073
+ ...response.status >= 400 ? { connection: "close" } : {},
15074
+ "content-type": "application/json; charset=utf-8",
15075
+ "cross-origin-resource-policy": "same-origin",
15076
+ "content-security-policy": "default-src 'none'; frame-ancestors 'none'",
15077
+ "x-frame-options": "DENY"
15078
+ }, { head });
15079
+ return;
15080
+ }
15045
15081
  if (segments.length < 3 || segments[0] !== "r" || !safeSessionId(segments[1])) {
15046
15082
  notFound(res, { head });
15047
15083
  return;
@@ -15200,6 +15236,32 @@ function createArtifactReviewServer({
15200
15236
  controlToken,
15201
15237
  instanceId,
15202
15238
  sessionCount: () => sessions.size,
15239
+ /** Trusted local authority only; this operation has no HTTP control route. */
15240
+ registerOwnerSession({ handleRequest } = {}) {
15241
+ if (draining || closePromise || typeof handleRequest !== "function") {
15242
+ throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Local owner session cannot be registered.");
15243
+ }
15244
+ const id4 = mintCapabilityToken({ bytes: SESSION_ID_BYTES });
15245
+ const owner = {
15246
+ id: id4,
15247
+ capability: mintCapabilityToken({ bytes: SESSION_TOKEN_BYTES }),
15248
+ recoveryScope: `diagram-owner_${id4}`,
15249
+ handleRequest,
15250
+ pending: /* @__PURE__ */ new Set()
15251
+ };
15252
+ ownerSessions.set(id4, owner);
15253
+ return Object.freeze({
15254
+ sessionId: id4,
15255
+ capability: owner.capability,
15256
+ recoveryScope: owner.recoveryScope,
15257
+ path: `/o/${id4}/${owner.capability}/`,
15258
+ async close() {
15259
+ ownerSessions.delete(id4);
15260
+ await Promise.allSettled([...owner.pending]);
15261
+ if (idle()) scheduleEmpty();
15262
+ }
15263
+ });
15264
+ },
15203
15265
  isIdle: idle,
15204
15266
  accepting: () => !draining && !closePromise,
15205
15267
  beginCloseIfIdle() {
@@ -15224,6 +15286,9 @@ function createArtifactReviewServer({
15224
15286
  emptyTimer = null;
15225
15287
  closePromise = (async () => {
15226
15288
  sessions.clear();
15289
+ const pendingOwners = [...ownerSessions.values()].flatMap((owner) => [...owner.pending]);
15290
+ ownerSessions.clear();
15291
+ await Promise.allSettled(pendingOwners);
15227
15292
  await closeHttpServer(server);
15228
15293
  })();
15229
15294
  return closePromise;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplanr/protocol",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Canonical OpenPlanr schemas, registries, typed errors, and portable contract validation",
6
6
  "license": "MIT",
@@ -83,6 +83,10 @@
83
83
  "./enterprise-contracts": {
84
84
  "types": "./src/enterprise-contracts.d.mts",
85
85
  "import": "./src/enterprise-contracts.mjs"
86
+ },
87
+ "./diagram-authoring-contracts": {
88
+ "types": "./src/diagram-authoring-contracts.d.mts",
89
+ "import": "./src/diagram-authoring-contracts.mjs"
86
90
  }
87
91
  },
88
92
  "files": [
@@ -4,14 +4,14 @@
4
4
  "name": "AsemDevs"
5
5
  },
6
6
  "metadata": {
7
- "version": "2.6.0",
7
+ "version": "2.6.2",
8
8
  "description": "Generated local OpenPlanr package."
9
9
  },
10
10
  "plugins": [
11
11
  {
12
12
  "name": "planr",
13
13
  "source": "./openplanr",
14
- "version": "2.6.0",
14
+ "version": "2.6.2",
15
15
  "description": "Host-native OpenPlanr skills for OpenAI coding agents.",
16
16
  "strict": true
17
17
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "planr",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "description": "Host-native OpenPlanr planning, delivery, review, design, and operating skills.",
5
5
  "author": {
6
6
  "name": "AsemDevs"
@@ -8,7 +8,7 @@
8
8
  "files": [
9
9
  {
10
10
  "path": ".codex-plugin/plugin.json",
11
- "digest": "sha256:86914866190aef3f24b1ec71289d84363ad4d20d9d08266bc526e1971542c4b7"
11
+ "digest": "sha256:848eeaeef1f239d5938a57121755a287736ed9361df9c697ebf1999b9f1a374c"
12
12
  },
13
13
  {
14
14
  "path": "skills/artifact/agents/openai.yaml",
@@ -328,7 +328,7 @@
328
328
  },
329
329
  {
330
330
  "path": "skills/design-loop/scripts/design.mjs",
331
- "digest": "sha256:3fec9a1d47bc41c0caf4909a2c4b9d00205da630c015a46f6921caf2a4d7a2d2"
331
+ "digest": "sha256:e368470cc9863cd20f5d5815c1d1df30a0f8432cbc09160f5b445fdb5420d4be"
332
332
  },
333
333
  {
334
334
  "path": "skills/design-loop/scripts/runtime/notices/entities.txt",
@@ -376,7 +376,7 @@
376
376
  },
377
377
  {
378
378
  "path": "skills/design-loop/scripts/runtime/packages/protocol/package.json",
379
- "digest": "sha256:005fd84b459d0673203781da7693ffb28b379ef73096213fd6df5c2606617730"
379
+ "digest": "sha256:6e51f9d61b978532cd129f442a4e88f9f3900e58a7239427ec264c34a1337ac3"
380
380
  },
381
381
  {
382
382
  "path": "skills/design-loop/scripts/runtime/packages/protocol/registry/artifact-theme.json",
@@ -520,7 +520,7 @@
520
520
  },
521
521
  {
522
522
  "path": "skills/design-review/scripts/design.mjs",
523
- "digest": "sha256:3fec9a1d47bc41c0caf4909a2c4b9d00205da630c015a46f6921caf2a4d7a2d2"
523
+ "digest": "sha256:e368470cc9863cd20f5d5815c1d1df30a0f8432cbc09160f5b445fdb5420d4be"
524
524
  },
525
525
  {
526
526
  "path": "skills/design-review/scripts/runtime/notices/entities.txt",
@@ -568,7 +568,7 @@
568
568
  },
569
569
  {
570
570
  "path": "skills/design-review/scripts/runtime/packages/protocol/package.json",
571
- "digest": "sha256:005fd84b459d0673203781da7693ffb28b379ef73096213fd6df5c2606617730"
571
+ "digest": "sha256:6e51f9d61b978532cd129f442a4e88f9f3900e58a7239427ec264c34a1337ac3"
572
572
  },
573
573
  {
574
574
  "path": "skills/design-review/scripts/runtime/packages/protocol/registry/artifact-theme.json",
@@ -712,7 +712,7 @@
712
712
  },
713
713
  {
714
714
  "path": "skills/design/scripts/design.mjs",
715
- "digest": "sha256:3fec9a1d47bc41c0caf4909a2c4b9d00205da630c015a46f6921caf2a4d7a2d2"
715
+ "digest": "sha256:e368470cc9863cd20f5d5815c1d1df30a0f8432cbc09160f5b445fdb5420d4be"
716
716
  },
717
717
  {
718
718
  "path": "skills/design/scripts/runtime/notices/entities.txt",
@@ -760,7 +760,7 @@
760
760
  },
761
761
  {
762
762
  "path": "skills/design/scripts/runtime/packages/protocol/package.json",
763
- "digest": "sha256:005fd84b459d0673203781da7693ffb28b379ef73096213fd6df5c2606617730"
763
+ "digest": "sha256:6e51f9d61b978532cd129f442a4e88f9f3900e58a7239427ec264c34a1337ac3"
764
764
  },
765
765
  {
766
766
  "path": "skills/design/scripts/runtime/packages/protocol/registry/artifact-theme.json",
@@ -992,7 +992,7 @@
992
992
  },
993
993
  {
994
994
  "path": "skills/plan/scripts/design.mjs",
995
- "digest": "sha256:3fec9a1d47bc41c0caf4909a2c4b9d00205da630c015a46f6921caf2a4d7a2d2"
995
+ "digest": "sha256:e368470cc9863cd20f5d5815c1d1df30a0f8432cbc09160f5b445fdb5420d4be"
996
996
  },
997
997
  {
998
998
  "path": "skills/plan/scripts/planning-ids.mjs",
@@ -1044,7 +1044,7 @@
1044
1044
  },
1045
1045
  {
1046
1046
  "path": "skills/plan/scripts/runtime/packages/protocol/package.json",
1047
- "digest": "sha256:005fd84b459d0673203781da7693ffb28b379ef73096213fd6df5c2606617730"
1047
+ "digest": "sha256:6e51f9d61b978532cd129f442a4e88f9f3900e58a7239427ec264c34a1337ac3"
1048
1048
  },
1049
1049
  {
1050
1050
  "path": "skills/plan/scripts/runtime/packages/protocol/registry/artifact-theme.json",
@@ -1259,5 +1259,5 @@
1259
1259
  "digest": "sha256:53698324b62f43b672ce8fe1654c526c96fb202e313442f09c6fc1e72268677e"
1260
1260
  }
1261
1261
  ],
1262
- "contentDigest": "sha256:43d99dd0fba75e793114c9a0d31f741cfd7e9e96ce00c63eb3b44ef41314c0fe"
1262
+ "contentDigest": "sha256:6cf50c5f87816e7e85e6c3a622c784199abfa4f4371d9bbef9f22b3b72bfd98b"
1263
1263
  }
@@ -14910,6 +14910,7 @@ function createArtifactReviewServer({
14910
14910
  throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Artifact review instance id is invalid.");
14911
14911
  }
14912
14912
  const sessions = /* @__PURE__ */ new Map();
14913
+ const ownerSessions = /* @__PURE__ */ new Map();
14913
14914
  let port = null;
14914
14915
  let closePromise = null;
14915
14916
  let pendingRegistrations = 0;
@@ -14917,7 +14918,7 @@ function createArtifactReviewServer({
14917
14918
  let draining = false;
14918
14919
  let emptyTimer = null;
14919
14920
  const stageRuntime = () => readFileSync11(STAGE_RUNTIME_PATH, "utf8");
14920
- const idle = () => sessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
+ const idle = () => sessions.size === 0 && ownerSessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
14922
  const scheduleEmpty = () => {
14922
14923
  if (emptyTimer || draining || typeof onEmpty !== "function") return;
14923
14924
  emptyTimer = setTimeout(async () => {
@@ -15042,6 +15043,41 @@ function createArtifactReviewServer({
15042
15043
  notFound(res, { head });
15043
15044
  return;
15044
15045
  }
15046
+ if (segments[0] === "o") {
15047
+ const owner = safeSessionId(segments[1]) && ownerSessions.get(segments[1]);
15048
+ if (draining || !sessionMatches(owner, segments[2])) {
15049
+ notFound(res, { head });
15050
+ return;
15051
+ }
15052
+ const request2 = Promise.resolve().then(() => owner.handleRequest({
15053
+ req,
15054
+ segments: segments.slice(3),
15055
+ head,
15056
+ origin: `http://${LOOPBACK_HOST}:${port}`,
15057
+ recoveryScope: owner.recoveryScope
15058
+ }));
15059
+ owner.pending.add(request2);
15060
+ let response;
15061
+ try {
15062
+ response = await request2;
15063
+ } finally {
15064
+ owner.pending.delete(request2);
15065
+ }
15066
+ if (!response) {
15067
+ notFound(res, { head });
15068
+ return;
15069
+ }
15070
+ send(res, response.status, JSON.stringify(response.body), {
15071
+ // Rejections may precede body consumption (for example Content-Length
15072
+ // above the limit). Do not reuse a socket containing unread body bytes.
15073
+ ...response.status >= 400 ? { connection: "close" } : {},
15074
+ "content-type": "application/json; charset=utf-8",
15075
+ "cross-origin-resource-policy": "same-origin",
15076
+ "content-security-policy": "default-src 'none'; frame-ancestors 'none'",
15077
+ "x-frame-options": "DENY"
15078
+ }, { head });
15079
+ return;
15080
+ }
15045
15081
  if (segments.length < 3 || segments[0] !== "r" || !safeSessionId(segments[1])) {
15046
15082
  notFound(res, { head });
15047
15083
  return;
@@ -15200,6 +15236,32 @@ function createArtifactReviewServer({
15200
15236
  controlToken,
15201
15237
  instanceId,
15202
15238
  sessionCount: () => sessions.size,
15239
+ /** Trusted local authority only; this operation has no HTTP control route. */
15240
+ registerOwnerSession({ handleRequest } = {}) {
15241
+ if (draining || closePromise || typeof handleRequest !== "function") {
15242
+ throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Local owner session cannot be registered.");
15243
+ }
15244
+ const id4 = mintCapabilityToken({ bytes: SESSION_ID_BYTES });
15245
+ const owner = {
15246
+ id: id4,
15247
+ capability: mintCapabilityToken({ bytes: SESSION_TOKEN_BYTES }),
15248
+ recoveryScope: `diagram-owner_${id4}`,
15249
+ handleRequest,
15250
+ pending: /* @__PURE__ */ new Set()
15251
+ };
15252
+ ownerSessions.set(id4, owner);
15253
+ return Object.freeze({
15254
+ sessionId: id4,
15255
+ capability: owner.capability,
15256
+ recoveryScope: owner.recoveryScope,
15257
+ path: `/o/${id4}/${owner.capability}/`,
15258
+ async close() {
15259
+ ownerSessions.delete(id4);
15260
+ await Promise.allSettled([...owner.pending]);
15261
+ if (idle()) scheduleEmpty();
15262
+ }
15263
+ });
15264
+ },
15203
15265
  isIdle: idle,
15204
15266
  accepting: () => !draining && !closePromise,
15205
15267
  beginCloseIfIdle() {
@@ -15224,6 +15286,9 @@ function createArtifactReviewServer({
15224
15286
  emptyTimer = null;
15225
15287
  closePromise = (async () => {
15226
15288
  sessions.clear();
15289
+ const pendingOwners = [...ownerSessions.values()].flatMap((owner) => [...owner.pending]);
15290
+ ownerSessions.clear();
15291
+ await Promise.allSettled(pendingOwners);
15227
15292
  await closeHttpServer(server);
15228
15293
  })();
15229
15294
  return closePromise;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplanr/protocol",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Canonical OpenPlanr schemas, registries, typed errors, and portable contract validation",
6
6
  "license": "MIT",
@@ -83,6 +83,10 @@
83
83
  "./enterprise-contracts": {
84
84
  "types": "./src/enterprise-contracts.d.mts",
85
85
  "import": "./src/enterprise-contracts.mjs"
86
+ },
87
+ "./diagram-authoring-contracts": {
88
+ "types": "./src/diagram-authoring-contracts.d.mts",
89
+ "import": "./src/diagram-authoring-contracts.mjs"
86
90
  }
87
91
  },
88
92
  "files": [
@@ -14910,6 +14910,7 @@ function createArtifactReviewServer({
14910
14910
  throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Artifact review instance id is invalid.");
14911
14911
  }
14912
14912
  const sessions = /* @__PURE__ */ new Map();
14913
+ const ownerSessions = /* @__PURE__ */ new Map();
14913
14914
  let port = null;
14914
14915
  let closePromise = null;
14915
14916
  let pendingRegistrations = 0;
@@ -14917,7 +14918,7 @@ function createArtifactReviewServer({
14917
14918
  let draining = false;
14918
14919
  let emptyTimer = null;
14919
14920
  const stageRuntime = () => readFileSync11(STAGE_RUNTIME_PATH, "utf8");
14920
- const idle = () => sessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
+ const idle = () => sessions.size === 0 && ownerSessions.size === 0 && pendingRegistrations === 0 && activeRequests === 0;
14921
14922
  const scheduleEmpty = () => {
14922
14923
  if (emptyTimer || draining || typeof onEmpty !== "function") return;
14923
14924
  emptyTimer = setTimeout(async () => {
@@ -15042,6 +15043,41 @@ function createArtifactReviewServer({
15042
15043
  notFound(res, { head });
15043
15044
  return;
15044
15045
  }
15046
+ if (segments[0] === "o") {
15047
+ const owner = safeSessionId(segments[1]) && ownerSessions.get(segments[1]);
15048
+ if (draining || !sessionMatches(owner, segments[2])) {
15049
+ notFound(res, { head });
15050
+ return;
15051
+ }
15052
+ const request2 = Promise.resolve().then(() => owner.handleRequest({
15053
+ req,
15054
+ segments: segments.slice(3),
15055
+ head,
15056
+ origin: `http://${LOOPBACK_HOST}:${port}`,
15057
+ recoveryScope: owner.recoveryScope
15058
+ }));
15059
+ owner.pending.add(request2);
15060
+ let response;
15061
+ try {
15062
+ response = await request2;
15063
+ } finally {
15064
+ owner.pending.delete(request2);
15065
+ }
15066
+ if (!response) {
15067
+ notFound(res, { head });
15068
+ return;
15069
+ }
15070
+ send(res, response.status, JSON.stringify(response.body), {
15071
+ // Rejections may precede body consumption (for example Content-Length
15072
+ // above the limit). Do not reuse a socket containing unread body bytes.
15073
+ ...response.status >= 400 ? { connection: "close" } : {},
15074
+ "content-type": "application/json; charset=utf-8",
15075
+ "cross-origin-resource-policy": "same-origin",
15076
+ "content-security-policy": "default-src 'none'; frame-ancestors 'none'",
15077
+ "x-frame-options": "DENY"
15078
+ }, { head });
15079
+ return;
15080
+ }
15045
15081
  if (segments.length < 3 || segments[0] !== "r" || !safeSessionId(segments[1])) {
15046
15082
  notFound(res, { head });
15047
15083
  return;
@@ -15200,6 +15236,32 @@ function createArtifactReviewServer({
15200
15236
  controlToken,
15201
15237
  instanceId,
15202
15238
  sessionCount: () => sessions.size,
15239
+ /** Trusted local authority only; this operation has no HTTP control route. */
15240
+ registerOwnerSession({ handleRequest } = {}) {
15241
+ if (draining || closePromise || typeof handleRequest !== "function") {
15242
+ throw artifactError(ARTIFACT_ERROR_CODES.LOOPBACK_STATE, "Local owner session cannot be registered.");
15243
+ }
15244
+ const id4 = mintCapabilityToken({ bytes: SESSION_ID_BYTES });
15245
+ const owner = {
15246
+ id: id4,
15247
+ capability: mintCapabilityToken({ bytes: SESSION_TOKEN_BYTES }),
15248
+ recoveryScope: `diagram-owner_${id4}`,
15249
+ handleRequest,
15250
+ pending: /* @__PURE__ */ new Set()
15251
+ };
15252
+ ownerSessions.set(id4, owner);
15253
+ return Object.freeze({
15254
+ sessionId: id4,
15255
+ capability: owner.capability,
15256
+ recoveryScope: owner.recoveryScope,
15257
+ path: `/o/${id4}/${owner.capability}/`,
15258
+ async close() {
15259
+ ownerSessions.delete(id4);
15260
+ await Promise.allSettled([...owner.pending]);
15261
+ if (idle()) scheduleEmpty();
15262
+ }
15263
+ });
15264
+ },
15203
15265
  isIdle: idle,
15204
15266
  accepting: () => !draining && !closePromise,
15205
15267
  beginCloseIfIdle() {
@@ -15224,6 +15286,9 @@ function createArtifactReviewServer({
15224
15286
  emptyTimer = null;
15225
15287
  closePromise = (async () => {
15226
15288
  sessions.clear();
15289
+ const pendingOwners = [...ownerSessions.values()].flatMap((owner) => [...owner.pending]);
15290
+ ownerSessions.clear();
15291
+ await Promise.allSettled(pendingOwners);
15227
15292
  await closeHttpServer(server);
15228
15293
  })();
15229
15294
  return closePromise;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openplanr/protocol",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Canonical OpenPlanr schemas, registries, typed errors, and portable contract validation",
6
6
  "license": "MIT",
@@ -83,6 +83,10 @@
83
83
  "./enterprise-contracts": {
84
84
  "types": "./src/enterprise-contracts.d.mts",
85
85
  "import": "./src/enterprise-contracts.mjs"
86
+ },
87
+ "./diagram-authoring-contracts": {
88
+ "types": "./src/diagram-authoring-contracts.d.mts",
89
+ "import": "./src/diagram-authoring-contracts.mjs"
86
90
  }
87
91
  },
88
92
  "files": [