@orion-agents/orion-code 0.2.2 → 0.3.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 (217) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +89 -14
  3. package/README.zh-CN.md +77 -14
  4. package/bin/orion +15 -4
  5. package/dist/cli.js +51 -172
  6. package/dist/cli.js.map +1 -1
  7. package/dist/commands/model-command-handlers.d.ts +2 -2
  8. package/dist/commands/model-command-handlers.d.ts.map +1 -1
  9. package/dist/commands/model-command-handlers.js +113 -32
  10. package/dist/commands/model-command-handlers.js.map +1 -1
  11. package/dist/commands/session-command-handlers.d.ts.map +1 -1
  12. package/dist/commands/session-command-handlers.js +106 -15
  13. package/dist/commands/session-command-handlers.js.map +1 -1
  14. package/dist/commands/types.d.ts +13 -3
  15. package/dist/commands/types.d.ts.map +1 -1
  16. package/dist/commands/types.js +1 -1
  17. package/dist/commands/types.js.map +1 -1
  18. package/dist/core/tool-artifacts.d.ts +2 -0
  19. package/dist/core/tool-artifacts.d.ts.map +1 -1
  20. package/dist/core/tool-artifacts.js +27 -1
  21. package/dist/core/tool-artifacts.js.map +1 -1
  22. package/dist/index.d.ts +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/runtime/agent-loop.d.ts.map +1 -1
  25. package/dist/runtime/agent-loop.js +3 -3
  26. package/dist/runtime/agent-loop.js.map +1 -1
  27. package/dist/runtime/agent-runtime-controller.d.ts +32 -1
  28. package/dist/runtime/agent-runtime-controller.d.ts.map +1 -1
  29. package/dist/runtime/agent-runtime-controller.js +241 -27
  30. package/dist/runtime/agent-runtime-controller.js.map +1 -1
  31. package/dist/runtime/agent-runtime-protocol.d.ts +4 -0
  32. package/dist/runtime/agent-runtime-protocol.d.ts.map +1 -1
  33. package/dist/runtime/agent-runtime-protocol.js.map +1 -1
  34. package/dist/runtime/agent-runtime-runner.d.ts +2 -1
  35. package/dist/runtime/agent-runtime-runner.d.ts.map +1 -1
  36. package/dist/runtime/durable-tool-receipt-reader.d.ts +32 -0
  37. package/dist/runtime/durable-tool-receipt-reader.d.ts.map +1 -0
  38. package/dist/runtime/durable-tool-receipt-reader.js +130 -0
  39. package/dist/runtime/durable-tool-receipt-reader.js.map +1 -0
  40. package/dist/runtime/legacy-thread-materializer.d.ts +31 -0
  41. package/dist/runtime/legacy-thread-materializer.d.ts.map +1 -1
  42. package/dist/runtime/legacy-thread-materializer.js +71 -17
  43. package/dist/runtime/legacy-thread-materializer.js.map +1 -1
  44. package/dist/runtime/orion-runtime-v1.d.ts +2 -0
  45. package/dist/runtime/orion-runtime-v1.d.ts.map +1 -1
  46. package/dist/runtime/orion-runtime-v1.js +7 -1
  47. package/dist/runtime/orion-runtime-v1.js.map +1 -1
  48. package/dist/runtime/orion-session-runner.d.ts +7 -2
  49. package/dist/runtime/orion-session-runner.d.ts.map +1 -1
  50. package/dist/runtime/orion-session-runner.js +16 -6
  51. package/dist/runtime/orion-session-runner.js.map +1 -1
  52. package/dist/runtime/product-bootstrap.d.ts +22 -0
  53. package/dist/runtime/product-bootstrap.d.ts.map +1 -0
  54. package/dist/runtime/product-bootstrap.js +374 -0
  55. package/dist/runtime/product-bootstrap.js.map +1 -0
  56. package/dist/runtime/product-orion-runtime.d.ts +2 -1
  57. package/dist/runtime/product-orion-runtime.d.ts.map +1 -1
  58. package/dist/runtime/product-orion-runtime.js +83 -13
  59. package/dist/runtime/product-orion-runtime.js.map +1 -1
  60. package/dist/runtime/protocol/runtime-protocol-v1.d.ts +1 -1
  61. package/dist/runtime/protocol/runtime-protocol-v1.js +1 -1
  62. package/dist/runtime/protocol/runtime-protocol-v1.js.map +1 -1
  63. package/dist/runtime/release-receipts.d.ts +66 -3
  64. package/dist/runtime/release-receipts.d.ts.map +1 -1
  65. package/dist/runtime/release-receipts.js +340 -7
  66. package/dist/runtime/release-receipts.js.map +1 -1
  67. package/dist/runtime/step-snapshot.d.ts.map +1 -1
  68. package/dist/runtime/step-snapshot.js +22 -2
  69. package/dist/runtime/step-snapshot.js.map +1 -1
  70. package/dist/runtime/subagents/runtime-integration.d.ts +1 -1
  71. package/dist/runtime/subagents/runtime-integration.d.ts.map +1 -1
  72. package/dist/runtime/subagents/runtime-integration.js +5 -2
  73. package/dist/runtime/subagents/runtime-integration.js.map +1 -1
  74. package/dist/runtime/thread-event-store.d.ts +80 -0
  75. package/dist/runtime/thread-event-store.d.ts.map +1 -1
  76. package/dist/runtime/thread-event-store.js +456 -22
  77. package/dist/runtime/thread-event-store.js.map +1 -1
  78. package/dist/runtime/thread-projection.d.ts +10 -0
  79. package/dist/runtime/thread-projection.d.ts.map +1 -1
  80. package/dist/runtime/thread-projection.js +40 -0
  81. package/dist/runtime/thread-projection.js.map +1 -1
  82. package/dist/runtime/thread-runtime.d.ts +3 -1
  83. package/dist/runtime/thread-runtime.d.ts.map +1 -1
  84. package/dist/runtime/thread-runtime.js +6 -0
  85. package/dist/runtime/thread-runtime.js.map +1 -1
  86. package/dist/runtime/thread-session-index.d.ts +84 -0
  87. package/dist/runtime/thread-session-index.d.ts.map +1 -0
  88. package/dist/runtime/thread-session-index.js +503 -0
  89. package/dist/runtime/thread-session-index.js.map +1 -0
  90. package/dist/runtime/thread-session-view.d.ts +70 -9
  91. package/dist/runtime/thread-session-view.d.ts.map +1 -1
  92. package/dist/runtime/thread-session-view.js +200 -82
  93. package/dist/runtime/thread-session-view.js.map +1 -1
  94. package/dist/runtime/thread-ui-adapter.d.ts +2 -0
  95. package/dist/runtime/thread-ui-adapter.d.ts.map +1 -1
  96. package/dist/runtime/thread-ui-adapter.js +86 -4
  97. package/dist/runtime/thread-ui-adapter.js.map +1 -1
  98. package/dist/runtime/tool-detail-repository.d.ts.map +1 -1
  99. package/dist/runtime/tool-detail-repository.js +23 -19
  100. package/dist/runtime/tool-detail-repository.js.map +1 -1
  101. package/dist/runtime/tool-receipt-validator.d.ts +21 -0
  102. package/dist/runtime/tool-receipt-validator.d.ts.map +1 -0
  103. package/dist/runtime/tool-receipt-validator.js +157 -0
  104. package/dist/runtime/tool-receipt-validator.js.map +1 -0
  105. package/dist/runtime/ui-events.d.ts +35 -0
  106. package/dist/runtime/ui-events.d.ts.map +1 -1
  107. package/dist/runtime/ui-events.js +1 -0
  108. package/dist/runtime/ui-events.js.map +1 -1
  109. package/dist/runtime/ui-view-model.d.ts +2 -0
  110. package/dist/runtime/ui-view-model.d.ts.map +1 -1
  111. package/dist/runtime/ui-view-model.js +7 -3
  112. package/dist/runtime/ui-view-model.js.map +1 -1
  113. package/dist/services/global-config.d.ts +25 -0
  114. package/dist/services/global-config.d.ts.map +1 -1
  115. package/dist/services/global-config.js +373 -5
  116. package/dist/services/global-config.js.map +1 -1
  117. package/dist/services/redaction.d.ts +4 -0
  118. package/dist/services/redaction.d.ts.map +1 -1
  119. package/dist/services/redaction.js +63 -0
  120. package/dist/services/redaction.js.map +1 -1
  121. package/dist/services/session-index.d.ts +16 -0
  122. package/dist/services/session-index.d.ts.map +1 -1
  123. package/dist/services/session-index.js +45 -36
  124. package/dist/services/session-index.js.map +1 -1
  125. package/dist/services/session-storage.d.ts +59 -0
  126. package/dist/services/session-storage.d.ts.map +1 -1
  127. package/dist/services/session-storage.js +306 -107
  128. package/dist/services/session-storage.js.map +1 -1
  129. package/dist/services/settings-coordinator.d.ts +174 -0
  130. package/dist/services/settings-coordinator.d.ts.map +1 -0
  131. package/dist/services/settings-coordinator.js +605 -0
  132. package/dist/services/settings-coordinator.js.map +1 -0
  133. package/dist/services/settings-document-repository.d.ts +138 -0
  134. package/dist/services/settings-document-repository.d.ts.map +1 -0
  135. package/dist/services/settings-document-repository.js +551 -0
  136. package/dist/services/settings-document-repository.js.map +1 -0
  137. package/dist/services/workspace-registry.d.ts +42 -0
  138. package/dist/services/workspace-registry.d.ts.map +1 -0
  139. package/dist/services/workspace-registry.js +222 -0
  140. package/dist/services/workspace-registry.js.map +1 -0
  141. package/dist/terminal-ui/launch.d.ts.map +1 -1
  142. package/dist/terminal-ui/launch.js +5 -0
  143. package/dist/terminal-ui/launch.js.map +1 -1
  144. package/dist/tui-ui/state.d.ts.map +1 -1
  145. package/dist/tui-ui/state.js +5 -0
  146. package/dist/tui-ui/state.js.map +1 -1
  147. package/dist/web/errors.d.ts +6 -0
  148. package/dist/web/errors.d.ts.map +1 -0
  149. package/dist/web/errors.js +13 -0
  150. package/dist/web/errors.js.map +1 -0
  151. package/dist/web/event-hub.d.ts +43 -0
  152. package/dist/web/event-hub.d.ts.map +1 -0
  153. package/dist/web/event-hub.js +323 -0
  154. package/dist/web/event-hub.js.map +1 -0
  155. package/dist/web/file-read-service.d.ts +55 -0
  156. package/dist/web/file-read-service.d.ts.map +1 -0
  157. package/dist/web/file-read-service.js +399 -0
  158. package/dist/web/file-read-service.js.map +1 -0
  159. package/dist/web/git-read-model-service.d.ts +77 -0
  160. package/dist/web/git-read-model-service.d.ts.map +1 -0
  161. package/dist/web/git-read-model-service.js +631 -0
  162. package/dist/web/git-read-model-service.js.map +1 -0
  163. package/dist/web/index.d.ts +6 -0
  164. package/dist/web/index.d.ts.map +1 -0
  165. package/dist/web/index.js +28 -0
  166. package/dist/web/index.js.map +1 -0
  167. package/dist/web/launch.d.ts +9 -0
  168. package/dist/web/launch.d.ts.map +1 -0
  169. package/dist/web/launch.js +64 -0
  170. package/dist/web/launch.js.map +1 -0
  171. package/dist/web/protocol.d.ts +408 -0
  172. package/dist/web/protocol.d.ts.map +1 -0
  173. package/dist/web/protocol.js +369 -0
  174. package/dist/web/protocol.js.map +1 -0
  175. package/dist/web/review-service.d.ts +38 -0
  176. package/dist/web/review-service.d.ts.map +1 -0
  177. package/dist/web/review-service.js +74 -0
  178. package/dist/web/review-service.js.map +1 -0
  179. package/dist/web/server.d.ts +20 -0
  180. package/dist/web/server.d.ts.map +1 -0
  181. package/dist/web/server.js +744 -0
  182. package/dist/web/server.js.map +1 -0
  183. package/dist/web/terminal-manager.d.ts +155 -0
  184. package/dist/web/terminal-manager.d.ts.map +1 -0
  185. package/dist/web/terminal-manager.js +728 -0
  186. package/dist/web/terminal-manager.js.map +1 -0
  187. package/dist/web/terminal-server.d.ts +8 -0
  188. package/dist/web/terminal-server.d.ts.map +1 -0
  189. package/dist/web/terminal-server.js +275 -0
  190. package/dist/web/terminal-server.js.map +1 -0
  191. package/dist/web/workbench-controller.d.ts +99 -0
  192. package/dist/web/workbench-controller.d.ts.map +1 -0
  193. package/dist/web/workbench-controller.js +1267 -0
  194. package/dist/web/workbench-controller.js.map +1 -0
  195. package/dist/web-client/assets/DiffViewer-DpKoD07C.js +5 -0
  196. package/dist/web-client/assets/FilesPanel-BkoLmgjR.js +2 -0
  197. package/dist/web-client/assets/GitPanel-D20StcdG.js +1 -0
  198. package/dist/web-client/assets/ReviewPanel-3MVWbMQV.js +1 -0
  199. package/dist/web-client/assets/TerminalPanel-BLQ592Fb.js +21 -0
  200. package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +1 -0
  201. package/dist/web-client/assets/index-BkIDl_xk.js +16 -0
  202. package/dist/web-client/assets/index-DXMpnWE8.css +1 -0
  203. package/dist/web-client/index.html +16 -0
  204. package/docs/architecture/v0.3.0-web-api.yaml +1340 -0
  205. package/docs/architecture/v0.3.1-web-api.yaml +2290 -0
  206. package/docs/migration/v0.2.2-to-v0.3.0-settings.md +114 -0
  207. package/docs/migration/v0.2.2-to-v0.3.0.md +55 -0
  208. package/docs/migration/v0.3.0-to-v0.3.1.md +88 -0
  209. package/docs/orion.example.json +9 -2
  210. package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +57 -0
  211. package/docs/plan/v0.3.0-settings-integration-plan.md +740 -0
  212. package/docs/plan/v0.3.0-web-workbench-plan.md +376 -0
  213. package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +848 -0
  214. package/docs/readme.md +22 -1
  215. package/docs/test/v0.3.1-web-workbench-e2e-plan.md +140 -0
  216. package/npm-shrinkwrap.json +1229 -45
  217. package/package.json +47 -11
@@ -0,0 +1,605 @@
1
+ "use strict";
2
+ /** Product-level coordinator for durable Settings reads and mutations. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SettingsCoordinatorV1 = exports.SettingsCoordinatorError = void 0;
5
+ const crypto_1 = require("crypto");
6
+ const child_process_1 = require("child_process");
7
+ const settings_document_repository_1 = require("./settings-document-repository");
8
+ const MAX_IDEMPOTENCY_ENTRIES = 256;
9
+ class SettingsCoordinatorError extends Error {
10
+ constructor(status, code, message = code) {
11
+ super(message);
12
+ this.status = status;
13
+ this.code = code;
14
+ this.name = 'SettingsCoordinatorError';
15
+ }
16
+ }
17
+ exports.SettingsCoordinatorError = SettingsCoordinatorError;
18
+ function isRecord(value) {
19
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
20
+ }
21
+ function deepFreeze(value) {
22
+ if (value && typeof value === 'object' && !Object.isFrozen(value)) {
23
+ for (const child of Object.values(value))
24
+ deepFreeze(child);
25
+ Object.freeze(value);
26
+ }
27
+ return value;
28
+ }
29
+ function cloneFrozen(value) {
30
+ return deepFreeze(JSON.parse(JSON.stringify(value)));
31
+ }
32
+ function getRecord(parent, key) {
33
+ const value = parent[key];
34
+ return isRecord(value) ? value : {};
35
+ }
36
+ function getString(parent, key) {
37
+ const value = parent[key];
38
+ return typeof value === 'string' ? value : undefined;
39
+ }
40
+ function fieldBlockedReason(state, runtimeBusy) {
41
+ if (state === 'invalid')
42
+ return 'invalid_document';
43
+ if (state === 'read-only' || state === 'unavailable')
44
+ return 'read_only';
45
+ if (runtimeBusy)
46
+ return 'runtime_busy';
47
+ return undefined;
48
+ }
49
+ function controlledState(snapshot, workspace) {
50
+ const document = snapshot.document;
51
+ const appearance = getRecord(getRecord(document, 'web'), 'appearance');
52
+ const project = getRecord(getRecord(document, 'projects'), workspace);
53
+ return Object.freeze({
54
+ ...(getString(appearance, 'theme')
55
+ ? { theme: getString(appearance, 'theme') }
56
+ : {}),
57
+ ...(getString(appearance, 'motion')
58
+ ? { motion: getString(appearance, 'motion') }
59
+ : {}),
60
+ ...(getString(document, 'defaultModel')
61
+ ? { defaultModel: getString(document, 'defaultModel') }
62
+ : {}),
63
+ ...(getString(project, 'defaultEffort')
64
+ ? { projectEffort: getString(project, 'defaultEffort') }
65
+ : {}),
66
+ ...(getString(document, 'defaultEffort')
67
+ ? { globalEffort: getString(document, 'defaultEffort') }
68
+ : {}),
69
+ ...(getString(document, 'toolConfirmation')
70
+ ? {
71
+ toolConfirmation: getString(document, 'toolConfirmation'),
72
+ }
73
+ : {}),
74
+ });
75
+ }
76
+ function controlledDiff(before, after) {
77
+ const operations = [];
78
+ if (before.theme !== after.theme) {
79
+ operations.push(after.theme
80
+ ? { op: 'set', key: 'appearance.theme', value: after.theme }
81
+ : { op: 'unset', key: 'appearance.theme' });
82
+ }
83
+ if (before.motion !== after.motion) {
84
+ operations.push(after.motion
85
+ ? { op: 'set', key: 'appearance.motion', value: after.motion }
86
+ : { op: 'unset', key: 'appearance.motion' });
87
+ }
88
+ if (before.defaultModel !== after.defaultModel) {
89
+ operations.push(after.defaultModel
90
+ ? { op: 'set', key: 'defaults.model', value: after.defaultModel }
91
+ : { op: 'unset', key: 'defaults.model' });
92
+ }
93
+ if (before.projectEffort !== after.projectEffort) {
94
+ operations.push(after.projectEffort
95
+ ? { op: 'set', key: 'defaults.effort', value: after.projectEffort }
96
+ : { op: 'unset', key: 'defaults.effort' });
97
+ }
98
+ if (before.globalEffort !== after.globalEffort) {
99
+ operations.push(after.globalEffort
100
+ ? { op: 'set', key: 'defaults.globalEffort', value: after.globalEffort }
101
+ : { op: 'unset', key: 'defaults.globalEffort' });
102
+ }
103
+ if (before.toolConfirmation !== after.toolConfirmation) {
104
+ operations.push(after.toolConfirmation
105
+ ? {
106
+ op: 'set',
107
+ key: 'permissions.toolConfirmation',
108
+ value: after.toolConfirmation,
109
+ }
110
+ : { op: 'unset', key: 'permissions.toolConfirmation' });
111
+ }
112
+ return Object.freeze(operations.map(operation => Object.freeze(operation)));
113
+ }
114
+ function isRuntimeSensitive(operations) {
115
+ return operations.some(operation => operation.key === 'defaults.effort' ||
116
+ operation.key === 'defaults.globalEffort' ||
117
+ operation.key === 'permissions.toolConfirmation');
118
+ }
119
+ function mapRepositoryError(error) {
120
+ if (error instanceof SettingsCoordinatorError)
121
+ return error;
122
+ if (error instanceof settings_document_repository_1.SettingsDocumentRepositoryError) {
123
+ const status = error.code === 'settings_invalid_operation'
124
+ ? 400
125
+ : error.code === 'settings_revision_conflict'
126
+ ? 409
127
+ : error.code === 'settings_rejected'
128
+ ? 422
129
+ : 503;
130
+ return new SettingsCoordinatorError(status, error.code, error.message);
131
+ }
132
+ return new SettingsCoordinatorError(422, 'settings_rejected', 'The settings update failed.');
133
+ }
134
+ function defaultDocumentOpener(documentPath) {
135
+ return new Promise((resolve, reject) => {
136
+ const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
137
+ const args = process.platform === 'win32' ? ['/c', 'start', '', documentPath] : [documentPath];
138
+ const child = (0, child_process_1.spawn)(command, args, { detached: true, stdio: 'ignore' });
139
+ child.once('error', reject);
140
+ child.once('spawn', () => {
141
+ child.unref();
142
+ resolve();
143
+ });
144
+ });
145
+ }
146
+ /**
147
+ * Single in-process write coordinator. Cross-process correctness remains in
148
+ * SettingsDocumentRepository's lock-protected reread and CAS.
149
+ */
150
+ class SettingsCoordinatorV1 {
151
+ constructor(options) {
152
+ this.queue = Promise.resolve();
153
+ this.idempotency = new Map();
154
+ this.recoveryRequired = false;
155
+ this.externalRecoveryRequired = false;
156
+ this.externalSyncPending = false;
157
+ this.externalSyncScheduled = false;
158
+ this.closed = false;
159
+ this.workspace = options.workspace;
160
+ this.repository =
161
+ options.repository ?? settings_document_repository_1.SettingsDocumentRepository.create(options.repositoryOptions);
162
+ this.onInvalidated = options.onInvalidated;
163
+ this.configuredModels = options.models ? cloneFrozen(options.models) : undefined;
164
+ this.configuredCredentials = options.credentials ? cloneFrozen(options.credentials) : undefined;
165
+ this.internalDefaultModel = options.internalDefaultModel ?? 'gpt-4o';
166
+ this.modelDefaultEffort = options.modelDefaultEffort ?? 'auto';
167
+ this.internalToolConfirmation = options.internalToolConfirmation ?? 'allow';
168
+ this.readOnly = options.readOnly ?? false;
169
+ this.documentOpener = options.documentOpener ?? defaultDocumentOpener;
170
+ this.runtimeIdle = options.runtimeIdle;
171
+ this.runtimePrepare = options.runtimePrepare;
172
+ this.runtimeApply = options.runtimeApply;
173
+ // Establish last-good before installing the watcher, then close the
174
+ // read-before-watch race inside repository.watch().
175
+ this.lastAppliedSnapshot = this.repository.read();
176
+ this.stopWatching = this.repository.watch(event => this.forwardExternalInvalidation(event));
177
+ }
178
+ static create(options) {
179
+ return new SettingsCoordinatorV1(options);
180
+ }
181
+ assertOpen() {
182
+ if (this.closed) {
183
+ throw new SettingsCoordinatorError(503, 'settings_document_unavailable', 'The settings coordinator is closed.');
184
+ }
185
+ }
186
+ forwardExternalInvalidation(event) {
187
+ this.emitInvalidation(event);
188
+ if (event.state === 'invalid') {
189
+ this.externalSyncPending = false;
190
+ this.externalRecoveryRequired = false;
191
+ return;
192
+ }
193
+ this.externalSyncPending = true;
194
+ this.scheduleExternalSynchronization();
195
+ }
196
+ scheduleExternalSynchronization() {
197
+ if (this.closed || this.recoveryRequired || this.externalSyncScheduled)
198
+ return;
199
+ this.externalSyncScheduled = true;
200
+ void this.enqueue(async () => {
201
+ this.externalSyncScheduled = false;
202
+ await this.synchronizeExternalChangesInQueue(false);
203
+ }).catch(() => undefined);
204
+ }
205
+ emitInvalidation(event) {
206
+ try {
207
+ this.onInvalidated?.(Object.freeze({ ...event }));
208
+ }
209
+ catch {
210
+ // Invalidation is advisory; observers cannot poison durable state.
211
+ }
212
+ }
213
+ enqueue(operation) {
214
+ const result = this.queue.then(operation, operation);
215
+ this.queue = result.then(() => undefined, () => undefined);
216
+ return result;
217
+ }
218
+ deriveModels(document) {
219
+ if (this.configuredModels)
220
+ return this.configuredModels;
221
+ const models = document.models;
222
+ if (!Array.isArray(models))
223
+ return Object.freeze([]);
224
+ return Object.freeze(models.flatMap(model => {
225
+ if (!isRecord(model) || typeof model.id !== 'string')
226
+ return [];
227
+ return [
228
+ Object.freeze({
229
+ id: model.id,
230
+ label: typeof model.displayName === 'string' ? model.displayName : model.id,
231
+ ...(typeof model.provider === 'string' ? { provider: model.provider } : {}),
232
+ }),
233
+ ];
234
+ }));
235
+ }
236
+ deriveCredentials(document) {
237
+ if (this.configuredCredentials)
238
+ return this.configuredCredentials;
239
+ const providers = document.providers;
240
+ if (!Array.isArray(providers))
241
+ return Object.freeze([]);
242
+ const result = [];
243
+ for (const provider of providers) {
244
+ if (!isRecord(provider) || typeof provider.id !== 'string')
245
+ continue;
246
+ const apiKey = typeof provider.apiKey === 'string' ? provider.apiKey : '';
247
+ if (apiKey.startsWith('$')) {
248
+ const environmentName = apiKey.slice(1);
249
+ result.push(Object.freeze({
250
+ providerId: provider.id,
251
+ state: environmentName && process.env[environmentName] ? 'ready' : 'missing',
252
+ source: 'environment',
253
+ writable: false,
254
+ }));
255
+ }
256
+ else {
257
+ result.push(Object.freeze({
258
+ providerId: provider.id,
259
+ state: apiKey ? 'ready' : 'missing',
260
+ source: apiKey ? 'legacy' : 'none',
261
+ writable: false,
262
+ }));
263
+ }
264
+ }
265
+ return Object.freeze(result);
266
+ }
267
+ buildView(snapshot, input = {}) {
268
+ const document = snapshot.document;
269
+ const web = getRecord(document, 'web');
270
+ const appearance = getRecord(web, 'appearance');
271
+ const projects = getRecord(document, 'projects');
272
+ const project = getRecord(projects, this.workspace);
273
+ const explicitTheme = getString(appearance, 'theme');
274
+ const explicitMotion = getString(appearance, 'motion');
275
+ const explicitModel = getString(document, 'defaultModel');
276
+ const projectEffort = getString(project, 'defaultEffort');
277
+ const globalEffort = getString(document, 'defaultEffort');
278
+ const explicitToolConfirmation = getString(document, 'toolConfirmation');
279
+ const runtimeBusy = input.runtime?.busy === true;
280
+ const recoveryRequired = this.recoveryRequired || this.externalRecoveryRequired;
281
+ const storageWritable = !this.readOnly && !recoveryRequired && this.repository.isWritable(snapshot);
282
+ const state = recoveryRequired
283
+ ? 'unavailable'
284
+ : snapshot.state === 'invalid'
285
+ ? 'invalid'
286
+ : snapshot.state === 'unavailable'
287
+ ? 'unavailable'
288
+ : storageWritable
289
+ ? 'ready'
290
+ : 'read-only';
291
+ const generalBlocked = fieldBlockedReason(state, false);
292
+ const runtimeBlocked = fieldBlockedReason(state, runtimeBusy);
293
+ const effortInherited = globalEffort ?? this.modelDefaultEffort;
294
+ const effortSource = projectEffort
295
+ ? 'project'
296
+ : globalEffort
297
+ ? 'global'
298
+ : 'model';
299
+ const currentSession = input.currentSession
300
+ ? Object.freeze({ ...input.currentSession })
301
+ : undefined;
302
+ const diagnostic = recoveryRequired
303
+ ? Object.freeze({
304
+ code: 'settings_recovery_required',
305
+ message: 'Settings recovery is required before additional updates.',
306
+ })
307
+ : snapshot.diagnostic;
308
+ return deepFreeze({
309
+ schemaVersion: 1,
310
+ revision: snapshot.revision,
311
+ state,
312
+ writable: storageWritable,
313
+ hasDocument: snapshot.hasDocument,
314
+ workspace: this.workspace,
315
+ sections: {
316
+ appearance: {
317
+ theme: {
318
+ effectiveValue: explicitTheme ?? 'system',
319
+ ...(explicitTheme
320
+ ? { explicitValue: explicitTheme }
321
+ : { inheritedValue: 'system' }),
322
+ source: explicitTheme ? 'global' : 'internal',
323
+ scope: 'global',
324
+ applies: 'live',
325
+ overridden: false,
326
+ writable: storageWritable,
327
+ ...(generalBlocked ? { blockedReason: generalBlocked } : {}),
328
+ },
329
+ motion: {
330
+ effectiveValue: explicitMotion ?? 'system',
331
+ ...(explicitMotion
332
+ ? { explicitValue: explicitMotion }
333
+ : { inheritedValue: 'system' }),
334
+ source: explicitMotion ? 'global' : 'internal',
335
+ scope: 'global',
336
+ applies: 'live',
337
+ overridden: false,
338
+ writable: storageWritable,
339
+ ...(generalBlocked ? { blockedReason: generalBlocked } : {}),
340
+ },
341
+ },
342
+ defaults: {
343
+ model: {
344
+ effectiveValue: explicitModel ?? this.internalDefaultModel,
345
+ ...(explicitModel
346
+ ? { explicitValue: explicitModel }
347
+ : { inheritedValue: this.internalDefaultModel }),
348
+ source: explicitModel ? 'global' : 'internal',
349
+ scope: 'global',
350
+ applies: 'new-session',
351
+ overridden: Boolean(currentSession &&
352
+ currentSession.model !== (explicitModel ?? this.internalDefaultModel)),
353
+ writable: storageWritable,
354
+ ...(generalBlocked ? { blockedReason: generalBlocked } : {}),
355
+ },
356
+ effort: {
357
+ effectiveValue: projectEffort ?? effortInherited,
358
+ ...(projectEffort
359
+ ? { explicitValue: projectEffort, inheritedValue: effortInherited }
360
+ : { inheritedValue: effortInherited }),
361
+ source: effortSource,
362
+ scope: 'project',
363
+ applies: 'next-logical-request',
364
+ overridden: currentSession?.overridesProjectEffort ?? false,
365
+ writable: storageWritable && !runtimeBusy,
366
+ ...(runtimeBlocked ? { blockedReason: runtimeBlocked } : {}),
367
+ },
368
+ },
369
+ permissions: {
370
+ toolConfirmation: {
371
+ effectiveValue: explicitToolConfirmation ?? this.internalToolConfirmation,
372
+ ...(explicitToolConfirmation
373
+ ? { explicitValue: explicitToolConfirmation }
374
+ : { inheritedValue: this.internalToolConfirmation }),
375
+ source: explicitToolConfirmation ? 'global' : 'internal',
376
+ scope: 'global',
377
+ applies: 'next-logical-request',
378
+ overridden: false,
379
+ writable: storageWritable && !runtimeBusy,
380
+ ...(runtimeBlocked ? { blockedReason: runtimeBlocked } : {}),
381
+ },
382
+ },
383
+ },
384
+ models: this.deriveModels(document),
385
+ credentials: this.deriveCredentials(document),
386
+ ...(currentSession ? { currentSession } : {}),
387
+ ...(diagnostic ? { diagnostic } : {}),
388
+ });
389
+ }
390
+ describe(input = {}) {
391
+ this.assertOpen();
392
+ return this.buildView(this.repository.read(), input);
393
+ }
394
+ hasPendingExternalChanges() {
395
+ return this.externalSyncPending;
396
+ }
397
+ /**
398
+ * Reconcile the latest valid external bytes into Runtime state. Callers
399
+ * should await this before starting a logical request or transition.
400
+ */
401
+ synchronizeExternalChanges(input = {}) {
402
+ this.assertOpen();
403
+ return this.enqueue(async () => {
404
+ await this.synchronizeExternalChangesInQueue(true);
405
+ return this.describe(input);
406
+ });
407
+ }
408
+ async synchronizeExternalChangesInQueue(throwOnBlocked) {
409
+ if (this.recoveryRequired) {
410
+ if (throwOnBlocked) {
411
+ throw new SettingsCoordinatorError(503, 'settings_recovery_required', 'Settings recovery is required before synchronizing external changes.');
412
+ }
413
+ return;
414
+ }
415
+ const latest = this.repository.read();
416
+ if (latest.state !== 'ready') {
417
+ this.externalSyncPending = false;
418
+ return;
419
+ }
420
+ if (latest.revision === this.lastAppliedSnapshot.revision) {
421
+ this.externalSyncPending = false;
422
+ this.externalRecoveryRequired = false;
423
+ return;
424
+ }
425
+ this.externalSyncPending = true;
426
+ const operations = controlledDiff(controlledState(this.lastAppliedSnapshot, this.workspace), controlledState(latest, this.workspace));
427
+ if (operations.length === 0) {
428
+ this.lastAppliedSnapshot = latest;
429
+ this.externalSyncPending = false;
430
+ this.externalRecoveryRequired = false;
431
+ return;
432
+ }
433
+ if (isRuntimeSensitive(operations) && this.runtimeIdle && !(await this.runtimeIdle())) {
434
+ this.externalSyncPending = true;
435
+ if (throwOnBlocked) {
436
+ throw new SettingsCoordinatorError(409, 'runtime_busy', 'The runtime is busy.');
437
+ }
438
+ return;
439
+ }
440
+ const before = this.buildView(this.lastAppliedSnapshot);
441
+ const document = this.buildView(latest);
442
+ try {
443
+ await this.runtimePrepare?.({ before, operations });
444
+ await this.runtimeApply?.({ before, document, operations });
445
+ }
446
+ catch {
447
+ this.externalSyncPending = false;
448
+ this.externalRecoveryRequired = true;
449
+ this.emitInvalidation({
450
+ revision: latest.revision,
451
+ reason: 'external-edit',
452
+ state: 'invalid',
453
+ });
454
+ if (throwOnBlocked) {
455
+ throw new SettingsCoordinatorError(503, 'settings_recovery_required', 'The external settings document could not be applied to the runtime.');
456
+ }
457
+ return;
458
+ }
459
+ this.lastAppliedSnapshot = latest;
460
+ this.externalSyncPending = false;
461
+ this.externalRecoveryRequired = false;
462
+ }
463
+ requestDigest(input) {
464
+ return (0, crypto_1.createHash)('sha256')
465
+ .update(JSON.stringify({
466
+ expectedRevision: input.expectedRevision,
467
+ operations: input.operations,
468
+ }))
469
+ .digest('hex');
470
+ }
471
+ update(input) {
472
+ this.assertOpen();
473
+ if (input.requestId) {
474
+ const digest = this.requestDigest(input);
475
+ const existing = this.idempotency.get(input.requestId);
476
+ if (existing) {
477
+ if (existing.digest !== digest) {
478
+ return Promise.reject(new SettingsCoordinatorError(409, 'request_id_conflict', 'The request id was already used for a different settings update.'));
479
+ }
480
+ return existing.result;
481
+ }
482
+ const result = this.enqueue(() => this.performUpdate(input));
483
+ const entry = { digest, result, settled: false };
484
+ this.idempotency.set(input.requestId, entry);
485
+ result.then(() => {
486
+ entry.settled = true;
487
+ this.trimIdempotencyCache();
488
+ }, () => {
489
+ if (this.idempotency.get(input.requestId)?.result === result) {
490
+ this.idempotency.delete(input.requestId);
491
+ }
492
+ });
493
+ return result;
494
+ }
495
+ return this.enqueue(() => this.performUpdate(input));
496
+ }
497
+ trimIdempotencyCache() {
498
+ while (this.idempotency.size > MAX_IDEMPOTENCY_ENTRIES) {
499
+ const settled = [...this.idempotency].find(([, entry]) => entry.settled);
500
+ if (!settled)
501
+ return;
502
+ this.idempotency.delete(settled[0]);
503
+ }
504
+ }
505
+ async performUpdate(input) {
506
+ try {
507
+ (0, settings_document_repository_1.validateSettingsOperationsV1)(input.operations);
508
+ const selectedModel = input.operations.find(operation => operation.op === 'set' && operation.key === 'defaults.model');
509
+ if (selectedModel?.op === 'set' &&
510
+ this.configuredModels &&
511
+ !this.configuredModels.some(model => model.id === selectedModel.value)) {
512
+ throw new SettingsCoordinatorError(422, 'settings_rejected', 'The selected default model is unavailable.');
513
+ }
514
+ if (this.recoveryRequired) {
515
+ throw new SettingsCoordinatorError(503, 'settings_recovery_required', 'Settings recovery is required before additional updates.');
516
+ }
517
+ await this.synchronizeExternalChangesInQueue(true);
518
+ if (this.readOnly) {
519
+ throw new SettingsCoordinatorError(403, 'settings_write_forbidden', 'Settings updates are disabled for this host.');
520
+ }
521
+ const before = this.describe(input);
522
+ const runtimeSensitive = isRuntimeSensitive(input.operations);
523
+ if (runtimeSensitive &&
524
+ (input.runtime?.busy || (this.runtimeIdle && !(await this.runtimeIdle())))) {
525
+ throw new SettingsCoordinatorError(409, 'runtime_busy', 'The runtime is busy.');
526
+ }
527
+ const prepare = input.runtimePrepare ?? this.runtimePrepare;
528
+ await prepare?.({ before, operations: input.operations });
529
+ const persisted = this.repository.persist(this.workspace, input.expectedRevision, input.operations);
530
+ const document = this.buildView(persisted.snapshot, input);
531
+ try {
532
+ const apply = input.runtimeApply ?? this.runtimeApply;
533
+ await apply?.({ before, document, operations: input.operations });
534
+ }
535
+ catch {
536
+ try {
537
+ const restored = this.repository.rollback(persisted.rollbackToken);
538
+ this.emitInvalidation({
539
+ revision: restored.revision,
540
+ reason: 'local-write',
541
+ state: 'ready',
542
+ });
543
+ }
544
+ catch {
545
+ this.recoveryRequired = true;
546
+ throw new SettingsCoordinatorError(503, 'settings_recovery_required', 'The durable settings write could not be reconciled with the runtime.');
547
+ }
548
+ throw new SettingsCoordinatorError(422, 'settings_rejected', 'The runtime rejected the settings update; the document was restored.');
549
+ }
550
+ this.lastAppliedSnapshot = persisted.snapshot;
551
+ const result = deepFreeze({
552
+ revision: persisted.revision,
553
+ appliedKeys: [...persisted.appliedKeys],
554
+ document,
555
+ });
556
+ this.emitInvalidation({
557
+ revision: result.revision,
558
+ reason: 'local-write',
559
+ state: 'ready',
560
+ });
561
+ return result;
562
+ }
563
+ catch (error) {
564
+ throw mapRepositoryError(error);
565
+ }
566
+ }
567
+ openDocument() {
568
+ this.assertOpen();
569
+ return this.enqueue(async () => {
570
+ try {
571
+ const current = this.repository.read();
572
+ if (this.readOnly && !current.hasDocument) {
573
+ throw new SettingsCoordinatorError(403, 'settings_write_forbidden', 'Creating the settings document is disabled for this host.');
574
+ }
575
+ const ensured = this.repository.ensureDocument();
576
+ if (ensured.created) {
577
+ this.emitInvalidation({
578
+ revision: ensured.snapshot.revision,
579
+ reason: 'local-write',
580
+ state: 'ready',
581
+ });
582
+ }
583
+ try {
584
+ await this.documentOpener(this.repository.documentPath);
585
+ }
586
+ catch {
587
+ throw new SettingsCoordinatorError(503, 'settings_document_unavailable', 'The settings document could not be opened.');
588
+ }
589
+ }
590
+ catch (error) {
591
+ throw mapRepositoryError(error);
592
+ }
593
+ });
594
+ }
595
+ close() {
596
+ if (this.closed)
597
+ return;
598
+ this.closed = true;
599
+ this.stopWatching();
600
+ this.repository.close();
601
+ this.idempotency.clear();
602
+ }
603
+ }
604
+ exports.SettingsCoordinatorV1 = SettingsCoordinatorV1;
605
+ //# sourceMappingURL=settings-coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-coordinator.js","sourceRoot":"","sources":["../../src/services/settings-coordinator.ts"],"names":[],"mappings":";AAAA,0EAA0E;;;AAE1E,mCAAoC;AACpC,iDAAsC;AAGtC,iFASwC;AAgJxC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAa,wBAAyB,SAAQ,KAAK;IACjD,YACW,MAAc,EACd,IAAY,EACrB,OAAO,GAAG,IAAI;QAEd,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AATD,4DASC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAAI,KAAQ;IAC7B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC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