@contractspec/lib.surface-runtime 0.2.3 → 0.3.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 (153) hide show
  1. package/dist/adapters/ai-sdk-stub.js +1 -6
  2. package/dist/adapters/blocknote-stub.js +3 -8
  3. package/dist/adapters/dnd-kit-adapter.js +6 -11
  4. package/dist/adapters/dnd-kit-stub.js +1 -6
  5. package/dist/adapters/floating-ui-stub.js +4 -9
  6. package/dist/adapters/index.js +7 -176
  7. package/dist/adapters/interfaces.js +0 -1
  8. package/dist/adapters/motion-stub.js +2 -7
  9. package/dist/adapters/resizable-panels-stub.js +7 -12
  10. package/dist/browser/adapters/ai-sdk-stub.js +1 -5
  11. package/dist/browser/adapters/blocknote-stub.js +3 -7
  12. package/dist/browser/adapters/dnd-kit-adapter.js +6 -10
  13. package/dist/browser/adapters/dnd-kit-stub.js +1 -5
  14. package/dist/browser/adapters/floating-ui-stub.js +4 -8
  15. package/dist/browser/adapters/index.js +7 -175
  16. package/dist/browser/adapters/motion-stub.js +2 -6
  17. package/dist/browser/adapters/resizable-panels-stub.js +5 -9
  18. package/dist/browser/evals/golden-harness.js +4 -825
  19. package/dist/browser/examples/pm-workbench.bundle.js +2 -316
  20. package/dist/browser/i18n/catalogs/en.js +1 -5
  21. package/dist/browser/i18n/catalogs/es.js +1 -5
  22. package/dist/browser/i18n/catalogs/fr.js +1 -5
  23. package/dist/browser/i18n/catalogs/index.js +3 -133
  24. package/dist/browser/i18n/index.js +3 -168
  25. package/dist/browser/i18n/keys.js +1 -5
  26. package/dist/browser/i18n/messages.js +6 -137
  27. package/dist/browser/index.js +4 -2466
  28. package/dist/browser/react/BundleProvider.js +12 -19
  29. package/dist/browser/react/BundleRenderer.js +19 -662
  30. package/dist/browser/react/OverlayConflictResolver.js +12 -180
  31. package/dist/browser/react/PatchProposalCard.js +9 -177
  32. package/dist/browser/react/RegionRenderer.js +14 -60
  33. package/dist/browser/react/SlotRenderer.js +15 -58
  34. package/dist/browser/react/WidgetPalette.js +6 -10
  35. package/dist/browser/react/index.js +14 -790
  36. package/dist/browser/runtime/apply-surface-patch.js +3 -208
  37. package/dist/browser/runtime/audit-events.js +8 -19
  38. package/dist/browser/runtime/build-context.js +2 -6
  39. package/dist/browser/runtime/extension-registry.js +3 -9
  40. package/dist/browser/runtime/field-renderer-registry.js +5 -11
  41. package/dist/browser/runtime/index.js +54 -1487
  42. package/dist/browser/runtime/overlay-alignment.js +8 -19
  43. package/dist/browser/runtime/overlay-signer.js +2 -7
  44. package/dist/browser/runtime/override-store.js +3 -9
  45. package/dist/browser/runtime/planner-prompt.js +2 -6
  46. package/dist/browser/runtime/planner-tools.js +3 -9
  47. package/dist/browser/runtime/policy-eval.js +3 -135
  48. package/dist/browser/runtime/preference-adapter.js +2 -62
  49. package/dist/browser/runtime/resolve-bundle.js +10 -447
  50. package/dist/browser/runtime/resolve-preferences.js +3 -7
  51. package/dist/browser/runtime/rollback.js +2 -325
  52. package/dist/browser/runtime/widget-registry.js +1 -5
  53. package/dist/browser/spec/define-module-bundle.js +2 -67
  54. package/dist/browser/spec/index.js +9 -317
  55. package/dist/browser/spec/validate-bundle.js +3 -8
  56. package/dist/browser/spec/validate-surface-patch.js +5 -11
  57. package/dist/browser/telemetry/index.js +4 -16
  58. package/dist/browser/telemetry/surface-metrics.js +7 -16
  59. package/dist/evals/golden-context.js +0 -1
  60. package/dist/evals/golden-harness.js +4 -826
  61. package/dist/examples/pm-workbench.bundle.js +2 -317
  62. package/dist/i18n/catalogs/en.js +1 -6
  63. package/dist/i18n/catalogs/es.js +1 -6
  64. package/dist/i18n/catalogs/fr.js +1 -6
  65. package/dist/i18n/catalogs/index.js +3 -134
  66. package/dist/i18n/index.js +3 -169
  67. package/dist/i18n/keys.js +1 -6
  68. package/dist/i18n/messages.js +6 -138
  69. package/dist/index.js +4 -2467
  70. package/dist/node/adapters/ai-sdk-stub.js +1 -5
  71. package/dist/node/adapters/blocknote-stub.js +3 -7
  72. package/dist/node/adapters/dnd-kit-adapter.js +6 -10
  73. package/dist/node/adapters/dnd-kit-stub.js +1 -5
  74. package/dist/node/adapters/floating-ui-stub.js +4 -8
  75. package/dist/node/adapters/index.js +7 -175
  76. package/dist/node/adapters/motion-stub.js +2 -6
  77. package/dist/node/adapters/resizable-panels-stub.js +5 -9
  78. package/dist/node/evals/golden-harness.js +4 -825
  79. package/dist/node/examples/pm-workbench.bundle.js +2 -316
  80. package/dist/node/i18n/catalogs/en.js +1 -5
  81. package/dist/node/i18n/catalogs/es.js +1 -5
  82. package/dist/node/i18n/catalogs/fr.js +1 -5
  83. package/dist/node/i18n/catalogs/index.js +3 -133
  84. package/dist/node/i18n/index.js +3 -168
  85. package/dist/node/i18n/keys.js +1 -5
  86. package/dist/node/i18n/messages.js +6 -137
  87. package/dist/node/index.js +4 -2466
  88. package/dist/node/react/BundleProvider.js +12 -19
  89. package/dist/node/react/BundleRenderer.js +19 -662
  90. package/dist/node/react/OverlayConflictResolver.js +12 -180
  91. package/dist/node/react/PatchProposalCard.js +9 -177
  92. package/dist/node/react/RegionRenderer.js +14 -60
  93. package/dist/node/react/SlotRenderer.js +15 -58
  94. package/dist/node/react/WidgetPalette.js +6 -10
  95. package/dist/node/react/index.js +14 -790
  96. package/dist/node/runtime/apply-surface-patch.js +3 -208
  97. package/dist/node/runtime/audit-events.js +8 -19
  98. package/dist/node/runtime/build-context.js +2 -6
  99. package/dist/node/runtime/extension-registry.js +3 -9
  100. package/dist/node/runtime/field-renderer-registry.js +5 -11
  101. package/dist/node/runtime/index.js +54 -1487
  102. package/dist/node/runtime/overlay-alignment.js +8 -19
  103. package/dist/node/runtime/overlay-signer.js +2 -7
  104. package/dist/node/runtime/override-store.js +3 -9
  105. package/dist/node/runtime/planner-prompt.js +2 -6
  106. package/dist/node/runtime/planner-tools.js +3 -9
  107. package/dist/node/runtime/policy-eval.js +3 -135
  108. package/dist/node/runtime/preference-adapter.js +2 -62
  109. package/dist/node/runtime/resolve-bundle.js +10 -447
  110. package/dist/node/runtime/resolve-preferences.js +3 -7
  111. package/dist/node/runtime/rollback.js +2 -325
  112. package/dist/node/runtime/widget-registry.js +1 -5
  113. package/dist/node/spec/define-module-bundle.js +2 -67
  114. package/dist/node/spec/index.js +9 -317
  115. package/dist/node/spec/validate-bundle.js +3 -8
  116. package/dist/node/spec/validate-surface-patch.js +5 -11
  117. package/dist/node/telemetry/index.js +4 -16
  118. package/dist/node/telemetry/surface-metrics.js +7 -16
  119. package/dist/react/BundleProvider.js +12 -20
  120. package/dist/react/BundleRenderer.d.ts +3 -1
  121. package/dist/react/BundleRenderer.js +19 -663
  122. package/dist/react/OverlayConflictResolver.js +12 -181
  123. package/dist/react/PatchProposalCard.js +9 -178
  124. package/dist/react/RegionRenderer.js +14 -61
  125. package/dist/react/SlotRenderer.js +15 -59
  126. package/dist/react/WidgetPalette.js +6 -11
  127. package/dist/react/index.js +14 -791
  128. package/dist/runtime/apply-surface-patch.js +3 -209
  129. package/dist/runtime/audit-events.js +8 -20
  130. package/dist/runtime/build-context.js +2 -7
  131. package/dist/runtime/extension-registry.js +3 -10
  132. package/dist/runtime/field-renderer-registry.js +9 -16
  133. package/dist/runtime/index.js +54 -1488
  134. package/dist/runtime/overlay-alignment.js +8 -20
  135. package/dist/runtime/overlay-signer.js +2 -8
  136. package/dist/runtime/override-store.js +3 -10
  137. package/dist/runtime/planner-prompt.js +11 -9
  138. package/dist/runtime/planner-tools.js +4 -11
  139. package/dist/runtime/policy-eval.js +3 -136
  140. package/dist/runtime/preference-adapter.js +2 -63
  141. package/dist/runtime/resolve-bundle.js +10 -448
  142. package/dist/runtime/resolve-preferences.js +3 -8
  143. package/dist/runtime/rollback.js +2 -326
  144. package/dist/runtime/widget-registry.js +1 -6
  145. package/dist/spec/define-module-bundle.js +2 -68
  146. package/dist/spec/index.js +9 -318
  147. package/dist/spec/types.js +0 -1
  148. package/dist/spec/validate-bundle.js +3 -9
  149. package/dist/spec/validate-surface-patch.js +5 -12
  150. package/dist/spec/verification-snapshot-types.js +0 -1
  151. package/dist/telemetry/index.js +4 -17
  152. package/dist/telemetry/surface-metrics.js +7 -17
  153. package/package.json +7 -7
@@ -1,7 +1,5 @@
1
- // @bun
2
- // src/runtime/overlay-alignment.ts
3
1
  import { applyOverlayModifications } from "@contractspec/lib.overlay-engine/merger";
4
- function toOverlayScopeContext(ctx) {
2
+ export function toOverlayScopeContext(ctx) {
5
3
  return {
6
4
  tenantId: ctx.tenantId,
7
5
  userId: ctx.actorId,
@@ -9,7 +7,7 @@ function toOverlayScopeContext(ctx) {
9
7
  tags: ctx.featureFlags
10
8
  };
11
9
  }
12
- function toOverlayTargetRef(_ctx, target) {
10
+ export function toOverlayTargetRef(_ctx, target) {
13
11
  return {
14
12
  presentation: target.surfaceId ?? target.routeId,
15
13
  bundleKey: target.bundleKey,
@@ -18,7 +16,7 @@ function toOverlayTargetRef(_ctx, target) {
18
16
  entityType: target.entityType
19
17
  };
20
18
  }
21
- function toOverlayAppliesTo(ctx, target, scope) {
19
+ export function toOverlayAppliesTo(ctx, target, scope) {
22
20
  const scopeCtx = toOverlayScopeContext(ctx);
23
21
  return {
24
22
  ...scopeCtx,
@@ -27,7 +25,7 @@ function toOverlayAppliesTo(ctx, target, scope) {
27
25
  ...scope === "workspace" && ctx.workspaceId ? { tags: [...scopeCtx.tags ?? [], `workspace:${ctx.workspaceId}`] } : {}
28
26
  };
29
27
  }
30
- function toOverlayRenderableField(field) {
28
+ export function toOverlayRenderableField(field) {
31
29
  return {
32
30
  key: field.fieldId,
33
31
  label: field.title,
@@ -36,7 +34,7 @@ function toOverlayRenderableField(field) {
36
34
  order: 0
37
35
  };
38
36
  }
39
- function fromOverlayRenderableField(overlay) {
37
+ export function fromOverlayRenderableField(overlay) {
40
38
  return {
41
39
  fieldId: overlay.key,
42
40
  title: overlay.label ?? overlay.key,
@@ -44,12 +42,12 @@ function fromOverlayRenderableField(overlay) {
44
42
  required: overlay.required ?? false
45
43
  };
46
44
  }
47
- function toOverlayRenderable(fields) {
45
+ export function toOverlayRenderable(fields) {
48
46
  return {
49
47
  fields: fields.map(toOverlayRenderableField)
50
48
  };
51
49
  }
52
- function mergeOverlayResultIntoFields(fields, merged) {
50
+ export function mergeOverlayResultIntoFields(fields, merged) {
53
51
  const fieldMap = new Map(fields.map((f) => [f.fieldId, { ...f }]));
54
52
  const result = [];
55
53
  for (const overlay of merged.fields) {
@@ -65,20 +63,10 @@ function mergeOverlayResultIntoFields(fields, merged) {
65
63
  }
66
64
  return result;
67
65
  }
68
- function applyEntityFieldOverlays(fields, overlays, options) {
66
+ export function applyEntityFieldOverlays(fields, overlays, options) {
69
67
  if (!overlays.length)
70
68
  return fields;
71
69
  const target = toOverlayRenderable(fields);
72
70
  const merged = applyOverlayModifications(target, overlays, options);
73
71
  return mergeOverlayResultIntoFields(fields, merged);
74
72
  }
75
- export {
76
- toOverlayTargetRef,
77
- toOverlayScopeContext,
78
- toOverlayRenderableField,
79
- toOverlayRenderable,
80
- toOverlayAppliesTo,
81
- mergeOverlayResultIntoFields,
82
- fromOverlayRenderableField,
83
- applyEntityFieldOverlays
84
- };
@@ -1,16 +1,10 @@
1
- // @bun
2
- // src/runtime/overlay-signer.ts
3
1
  import {
4
2
  signOverlay,
5
3
  verifyOverlaySignature
6
4
  } from "@contractspec/lib.overlay-engine/signer";
7
- function signWorkspaceOverlay(spec, privateKey, options) {
5
+ export function signWorkspaceOverlay(spec, privateKey, options) {
8
6
  return signOverlay(spec, privateKey, options);
9
7
  }
10
- function verifyWorkspaceOverlay(overlay) {
8
+ export function verifyWorkspaceOverlay(overlay) {
11
9
  return verifyOverlaySignature(overlay);
12
10
  }
13
- export {
14
- verifyWorkspaceOverlay,
15
- signWorkspaceOverlay
16
- };
@@ -1,9 +1,7 @@
1
- // @bun
2
- // src/runtime/override-store.ts
3
- function buildOverrideTargetKey(bundleKey, surfaceId, routeId) {
1
+ export function buildOverrideTargetKey(bundleKey, surfaceId, routeId) {
4
2
  return routeId ? `${bundleKey}:${routeId}:${surfaceId}` : `${bundleKey}:${surfaceId}`;
5
3
  }
6
- function createOverrideStoreWithApprovalGate(store, options) {
4
+ export function createOverrideStoreWithApprovalGate(store, options) {
7
5
  const { requireApprovalForWorkspacePatches = false, requestApproval } = options;
8
6
  return {
9
7
  list: store.list.bind(store),
@@ -19,7 +17,7 @@ function createOverrideStoreWithApprovalGate(store, options) {
19
17
  remove: store.remove.bind(store)
20
18
  };
21
19
  }
22
- function createInMemoryOverrideStore() {
20
+ export function createInMemoryOverrideStore() {
23
21
  const overrides = new Map;
24
22
  function nextId() {
25
23
  return `ov_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
@@ -46,8 +44,3 @@ function createInMemoryOverrideStore() {
46
44
  }
47
45
  };
48
46
  }
49
- export {
50
- createOverrideStoreWithApprovalGate,
51
- createInMemoryOverrideStore,
52
- buildOverrideTargetKey
53
- };
@@ -1,6 +1,4 @@
1
- // @bun
2
- // src/runtime/planner-prompt.ts
3
- var SAFETY_INSTRUCTIONS = `
1
+ const SAFETY_INSTRUCTIONS = `
4
2
  ## Safety instructions (mandatory)
5
3
  - Do NOT emit JSX, HTML, or raw markup.
6
4
  - Do NOT invent node kinds; use only the allowed kinds listed above.
@@ -8,7 +6,7 @@ var SAFETY_INSTRUCTIONS = `
8
6
  - Prefer fewer high-confidence patches over many speculative ones.
9
7
  - Explain why a patch helps the user.
10
8
  `;
11
- function compilePlannerPrompt(input) {
9
+ export function compilePlannerPrompt(input) {
12
10
  const {
13
11
  bundleMeta,
14
12
  surfaceId,
@@ -47,7 +45,7 @@ function compilePlannerPrompt(input) {
47
45
  parts.push("");
48
46
  }
49
47
  parts.push("## Current preference profile");
50
- parts.push(`guidance=${preferences.guidance}, density=${preferences.density}, ` + `dataDepth=${preferences.dataDepth}, control=${preferences.control}, ` + `media=${preferences.media}, pace=${preferences.pace}, narrative=${preferences.narrative}`);
48
+ parts.push(`guidance=${preferences.guidance}, density=${preferences.density}, dataDepth=${preferences.dataDepth}, control=${preferences.control}, media=${preferences.media}, pace=${preferences.pace}, narrative=${preferences.narrative}`);
51
49
  parts.push("");
52
50
  if (planSummary) {
53
51
  parts.push("## Current plan summary");
@@ -59,10 +57,14 @@ function compilePlannerPrompt(input) {
59
57
  parts.push(`${entity.type}: ${entity.id}`);
60
58
  parts.push("");
61
59
  }
62
- parts.push(SAFETY_INSTRUCTIONS.trim());
60
+ parts.push(`
61
+ ## Safety instructions (mandatory)
62
+ - Do NOT emit JSX, HTML, or raw markup.
63
+ - Do NOT invent node kinds; use only the allowed kinds listed above.
64
+ - Do NOT call undeclared tools.
65
+ - Prefer fewer high-confidence patches over many speculative ones.
66
+ - Explain why a patch helps the user.
67
+ `.trim());
63
68
  return parts.join(`
64
69
  `);
65
70
  }
66
- export {
67
- compilePlannerPrompt
68
- };
@@ -1,6 +1,4 @@
1
- // @bun
2
- // src/runtime/planner-tools.ts
3
- var PROPOSE_PATCH_TOOL_SCHEMA = {
1
+ export const PROPOSE_PATCH_TOOL_SCHEMA = {
4
2
  type: "object",
5
3
  properties: {
6
4
  proposalId: { type: "string", description: "Unique proposal identifier" },
@@ -56,14 +54,14 @@ var PROPOSE_PATCH_TOOL_SCHEMA = {
56
54
  },
57
55
  required: ["proposalId", "ops"]
58
56
  };
59
- var proposePatchToolConfig = {
57
+ export const proposePatchToolConfig = {
60
58
  name: "propose-patch",
61
- description: "Propose surface patches (layout changes, node insertions, etc.) for user approval. " + "Only use allowed ops, slots, and node kinds from the planner context.",
59
+ description: "Propose surface patches (layout changes, node insertions, etc.) for user approval. Only use allowed ops, slots, and node kinds from the planner context.",
62
60
  schema: PROPOSE_PATCH_TOOL_SCHEMA,
63
61
  automationSafe: false,
64
62
  requiresApproval: true
65
63
  };
66
- function buildSurfacePatchProposal(proposalId, ops) {
64
+ export function buildSurfacePatchProposal(proposalId, ops) {
67
65
  return {
68
66
  proposalId,
69
67
  source: "assistant",
@@ -71,8 +69,3 @@ function buildSurfacePatchProposal(proposalId, ops) {
71
69
  approvalState: "proposed"
72
70
  };
73
71
  }
74
- export {
75
- proposePatchToolConfig,
76
- buildSurfacePatchProposal,
77
- PROPOSE_PATCH_TOOL_SCHEMA
78
- };
@@ -1,140 +1,11 @@
1
- // @bun
2
- // src/runtime/audit-events.ts
3
- function generateEventId() {
4
- return `evt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
5
- }
6
- function emitPatchProposed(audit, args) {
7
- audit.emit({
8
- eventId: generateEventId(),
9
- at: new Date().toISOString(),
10
- actorId: args.actorId,
11
- source: args.proposal.source === "assistant" ? "assistant" : "user",
12
- bundleKey: args.bundleKey,
13
- surfaceId: args.surfaceId,
14
- eventType: "patch.proposed",
15
- payload: {
16
- proposalId: args.proposal.proposalId,
17
- source: args.proposal.source,
18
- opsCount: args.proposal.ops.length
19
- }
20
- });
21
- }
22
- function emitPatchApproved(audit, args) {
23
- audit.emit({
24
- eventId: generateEventId(),
25
- at: new Date().toISOString(),
26
- actorId: args.actorId,
27
- source: "user",
28
- bundleKey: args.bundleKey,
29
- surfaceId: args.surfaceId,
30
- eventType: "patch.approved",
31
- payload: {
32
- proposalId: args.proposalId,
33
- source: args.source,
34
- opsCount: args.opsCount,
35
- reason: args.reason
36
- }
37
- });
38
- }
39
- function emitPatchRejected(audit, args) {
40
- audit.emit({
41
- eventId: generateEventId(),
42
- at: new Date().toISOString(),
43
- actorId: args.actorId,
44
- source: "user",
45
- bundleKey: args.bundleKey,
46
- surfaceId: args.surfaceId,
47
- eventType: "patch.rejected",
48
- payload: {
49
- proposalId: args.proposalId,
50
- source: args.source,
51
- opsCount: args.opsCount,
52
- reason: args.reason
53
- }
54
- });
55
- }
56
- function emitOverlaySaved(audit, args) {
57
- audit.emit({
58
- eventId: generateEventId(),
59
- at: new Date().toISOString(),
60
- actorId: args.actorId,
61
- source: "user",
62
- bundleKey: args.bundleKey,
63
- eventType: "overlay.saved",
64
- payload: {
65
- overlayId: args.overlayId,
66
- scope: args.scope,
67
- opsCount: args.opsCount
68
- }
69
- });
70
- }
71
- function emitOverlayApplied(audit, args) {
72
- audit.emit({
73
- eventId: generateEventId(),
74
- at: new Date().toISOString(),
75
- source: "system",
76
- bundleKey: args.bundleKey,
77
- surfaceId: args.surfaceId,
78
- eventType: "overlay.applied",
79
- payload: {
80
- overlayId: args.overlayId,
81
- opsCount: args.opsCount
82
- }
83
- });
84
- }
85
- function emitOverlayFailed(audit, args) {
86
- audit.emit({
87
- eventId: generateEventId(),
88
- at: new Date().toISOString(),
89
- source: "system",
90
- bundleKey: args.bundleKey,
91
- surfaceId: args.surfaceId,
92
- eventType: "overlay.failed",
93
- payload: {
94
- overlayId: args.overlayId,
95
- error: args.error
96
- }
97
- });
98
- }
99
- function emitPolicyDenied(audit, args) {
100
- audit.emit({
101
- eventId: generateEventId(),
102
- at: new Date().toISOString(),
103
- actorId: args.actorId,
104
- source: "policy",
105
- bundleKey: args.bundleKey,
106
- surfaceId: args.surfaceId,
107
- eventType: "policy.denied",
108
- payload: {
109
- targetId: args.targetId,
110
- reason: args.reason
111
- }
112
- });
113
- }
114
- function emitPolicyRedacted(audit, args) {
115
- audit.emit({
116
- eventId: generateEventId(),
117
- at: new Date().toISOString(),
118
- actorId: args.actorId,
119
- source: "policy",
120
- bundleKey: args.bundleKey,
121
- surfaceId: args.surfaceId,
122
- eventType: "policy.redacted",
123
- payload: {
124
- targetId: args.targetId,
125
- redactions: args.redactions
126
- }
127
- });
128
- }
129
-
130
- // src/runtime/policy-eval.ts
131
- function evaluatePatchProposalPolicy(ops, ctx, policy) {
1
+ import { emitPolicyDenied } from "./audit-events";
2
+ export function evaluatePatchProposalPolicy(ops, ctx, policy) {
132
3
  const evaluate = policy?.evaluatePatchProposal;
133
4
  if (!evaluate)
134
5
  return "allow";
135
6
  return evaluate(ops, ctx);
136
7
  }
137
- function evaluateAndEmitPatchPolicy(ops, ctx, args) {
8
+ export function evaluateAndEmitPatchPolicy(ops, ctx, args) {
138
9
  const effect = evaluatePatchProposalPolicy(ops, ctx, args.policy);
139
10
  if (effect === "deny") {
140
11
  if (args.audit) {
@@ -150,7 +21,3 @@ function evaluateAndEmitPatchPolicy(ops, ctx, args) {
150
21
  }
151
22
  return true;
152
23
  }
153
- export {
154
- evaluatePatchProposalPolicy,
155
- evaluateAndEmitPatchPolicy
156
- };
@@ -1,68 +1,7 @@
1
- // @bun
2
- // src/runtime/resolve-preferences.ts
3
- var DIMENSION_KEYS = [
4
- "guidance",
5
- "density",
6
- "dataDepth",
7
- "control",
8
- "media",
9
- "pace",
10
- "narrative"
11
- ];
12
- var SCOPE_ORDER = [
13
- "user",
14
- "workspace-user",
15
- "bundle",
16
- "surface",
17
- "entity",
18
- "session"
19
- ];
20
- function mergeByScope(layers, ctx) {
21
- const merged = { ...ctx.preferences };
22
- const sourceByDimension = {};
23
- for (const scope of SCOPE_ORDER) {
24
- const layer = layers[scope];
25
- if (!layer)
26
- continue;
27
- for (const dim of DIMENSION_KEYS) {
28
- const val = layer[dim];
29
- if (val !== undefined) {
30
- merged[dim] = val;
31
- sourceByDimension[dim] = scope;
32
- }
33
- }
34
- }
35
- for (const dim of DIMENSION_KEYS) {
36
- if (sourceByDimension[dim] === undefined) {
37
- sourceByDimension[dim] = "session";
38
- }
39
- }
40
- return { canonical: merged, sourceByDimension };
41
- }
42
- function resolveConstraints(_canonical, _ctx) {
43
- return { constrained: {}, notes: [] };
44
- }
45
- function resolvePreferenceProfile(ctx) {
46
- const layers = {
47
- session: ctx.preferences
48
- };
49
- const { canonical, sourceByDimension } = mergeByScope(layers, ctx);
50
- const { constrained, notes } = resolveConstraints(canonical, ctx);
51
- return {
52
- canonical,
53
- sourceByDimension,
54
- constrained,
55
- notes
56
- };
57
- }
58
-
59
- // src/runtime/preference-adapter.ts
60
- var defaultPreferenceAdapter = {
1
+ import { resolvePreferenceProfile } from "./resolve-preferences";
2
+ export const defaultPreferenceAdapter = {
61
3
  async resolve(ctx) {
62
4
  return resolvePreferenceProfile(ctx);
63
5
  },
64
6
  async savePreferencePatch(_args) {}
65
7
  };
66
- export {
67
- defaultPreferenceAdapter
68
- };