@agimon-ai/doompi-extension-contracts 0.0.1-alpha.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/backgroundWork.cjs +2 -0
  4. package/dist/backgroundWork.cjs.map +1 -0
  5. package/dist/backgroundWork.d.cts +73 -0
  6. package/dist/backgroundWork.d.cts.map +1 -0
  7. package/dist/backgroundWork.d.mts +73 -0
  8. package/dist/backgroundWork.d.mts.map +1 -0
  9. package/dist/backgroundWork.mjs +2 -0
  10. package/dist/backgroundWork.mjs.map +1 -0
  11. package/dist/childProcess.cjs +2 -0
  12. package/dist/childProcess.cjs.map +1 -0
  13. package/dist/childProcess.d.cts +20 -0
  14. package/dist/childProcess.d.cts.map +1 -0
  15. package/dist/childProcess.d.mts +20 -0
  16. package/dist/childProcess.d.mts.map +1 -0
  17. package/dist/childProcess.mjs +2 -0
  18. package/dist/childProcess.mjs.map +1 -0
  19. package/dist/config.cjs +2 -0
  20. package/dist/config.cjs.map +1 -0
  21. package/dist/config.d.cts +517 -0
  22. package/dist/config.d.cts.map +1 -0
  23. package/dist/config.d.mts +517 -0
  24. package/dist/config.d.mts.map +1 -0
  25. package/dist/config.mjs +2 -0
  26. package/dist/config.mjs.map +1 -0
  27. package/dist/delegation.cjs +2 -0
  28. package/dist/delegation.cjs.map +1 -0
  29. package/dist/delegation.d.cts +114 -0
  30. package/dist/delegation.d.cts.map +1 -0
  31. package/dist/delegation.d.mts +114 -0
  32. package/dist/delegation.d.mts.map +1 -0
  33. package/dist/delegation.mjs +2 -0
  34. package/dist/delegation.mjs.map +1 -0
  35. package/dist/fablePlan.cjs +2 -0
  36. package/dist/fablePlan.cjs.map +1 -0
  37. package/dist/fablePlan.d.cts +143 -0
  38. package/dist/fablePlan.d.cts.map +1 -0
  39. package/dist/fablePlan.d.mts +143 -0
  40. package/dist/fablePlan.d.mts.map +1 -0
  41. package/dist/fablePlan.mjs +2 -0
  42. package/dist/fablePlan.mjs.map +1 -0
  43. package/dist/footer.cjs +2 -0
  44. package/dist/footer.cjs.map +1 -0
  45. package/dist/footer.d.cts +141 -0
  46. package/dist/footer.d.cts.map +1 -0
  47. package/dist/footer.d.mts +141 -0
  48. package/dist/footer.d.mts.map +1 -0
  49. package/dist/footer.mjs +2 -0
  50. package/dist/footer.mjs.map +1 -0
  51. package/dist/index.cjs +1 -0
  52. package/dist/index.d.cts +2 -0
  53. package/dist/index.d.mts +2 -0
  54. package/dist/index.mjs +1 -0
  55. package/dist/leader.cjs +2 -0
  56. package/dist/leader.cjs.map +1 -0
  57. package/dist/leader.d.cts +171 -0
  58. package/dist/leader.d.cts.map +1 -0
  59. package/dist/leader.d.mts +171 -0
  60. package/dist/leader.d.mts.map +1 -0
  61. package/dist/leader.mjs +2 -0
  62. package/dist/leader.mjs.map +1 -0
  63. package/dist/mcpStatus.cjs +2 -0
  64. package/dist/mcpStatus.cjs.map +1 -0
  65. package/dist/mcpStatus.d.cts +79 -0
  66. package/dist/mcpStatus.d.cts.map +1 -0
  67. package/dist/mcpStatus.d.mts +79 -0
  68. package/dist/mcpStatus.d.mts.map +1 -0
  69. package/dist/mcpStatus.mjs +2 -0
  70. package/dist/mcpStatus.mjs.map +1 -0
  71. package/dist/mode.cjs +2 -0
  72. package/dist/mode.cjs.map +1 -0
  73. package/dist/mode.d.cts +132 -0
  74. package/dist/mode.d.cts.map +1 -0
  75. package/dist/mode.d.mts +132 -0
  76. package/dist/mode.d.mts.map +1 -0
  77. package/dist/mode.mjs +2 -0
  78. package/dist/mode.mjs.map +1 -0
  79. package/dist/protocol.cjs +2 -0
  80. package/dist/protocol.cjs.map +1 -0
  81. package/dist/protocol.d.cts +83 -0
  82. package/dist/protocol.d.cts.map +1 -0
  83. package/dist/protocol.d.mts +83 -0
  84. package/dist/protocol.d.mts.map +1 -0
  85. package/dist/protocol.mjs +2 -0
  86. package/dist/protocol.mjs.map +1 -0
  87. package/dist/runnerPty.cjs +2 -0
  88. package/dist/runnerPty.cjs.map +1 -0
  89. package/dist/runnerPty.d.cts +39 -0
  90. package/dist/runnerPty.d.cts.map +1 -0
  91. package/dist/runnerPty.d.mts +39 -0
  92. package/dist/runnerPty.d.mts.map +1 -0
  93. package/dist/runnerPty.mjs +2 -0
  94. package/dist/runnerPty.mjs.map +1 -0
  95. package/dist/skills.cjs +2 -0
  96. package/dist/skills.cjs.map +1 -0
  97. package/dist/skills.d.cts +51 -0
  98. package/dist/skills.d.cts.map +1 -0
  99. package/dist/skills.d.mts +51 -0
  100. package/dist/skills.d.mts.map +1 -0
  101. package/dist/skills.mjs +2 -0
  102. package/dist/skills.mjs.map +1 -0
  103. package/dist/subagentPolicy.cjs +2 -0
  104. package/dist/subagentPolicy.cjs.map +1 -0
  105. package/dist/subagentPolicy.d.cts +47 -0
  106. package/dist/subagentPolicy.d.cts.map +1 -0
  107. package/dist/subagentPolicy.d.mts +47 -0
  108. package/dist/subagentPolicy.d.mts.map +1 -0
  109. package/dist/subagentPolicy.mjs +2 -0
  110. package/dist/subagentPolicy.mjs.map +1 -0
  111. package/dist/subagentTool.cjs +2 -0
  112. package/dist/subagentTool.cjs.map +1 -0
  113. package/dist/subagentTool.d.cts +78 -0
  114. package/dist/subagentTool.d.cts.map +1 -0
  115. package/dist/subagentTool.d.mts +78 -0
  116. package/dist/subagentTool.d.mts.map +1 -0
  117. package/dist/subagentTool.mjs +2 -0
  118. package/dist/subagentTool.mjs.map +1 -0
  119. package/dist/workflow.cjs +2 -0
  120. package/dist/workflow.cjs.map +1 -0
  121. package/dist/workflow.d.cts +15 -0
  122. package/dist/workflow.d.cts.map +1 -0
  123. package/dist/workflow.d.mts +15 -0
  124. package/dist/workflow.d.mts.map +1 -0
  125. package/dist/workflow.mjs +2 -0
  126. package/dist/workflow.mjs.map +1 -0
  127. package/package.json +121 -0
@@ -0,0 +1,517 @@
1
+ import { EventBusLike, NotificationDefinition, ProtocolRuntime } from "./protocol.mjs";
2
+ import { Static, Type } from "typebox";
3
+ //#region src/config.d.ts
4
+ /** Matches the leader contract's source rule: package names, addressable and spoof-checkable. */
5
+ declare const ConfigSourceSchema: Type.TString;
6
+ /**
7
+ * How ready a value is to be used, as opposed to whether it is merely set.
8
+ * `blocked` covers a choice that needs something else first, such as a model
9
+ * whose engine is not installed.
10
+ */
11
+ declare const ConfigStatusSchema: Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>;
12
+ type ConfigStatus = Static<typeof ConfigStatusSchema>;
13
+ declare const ConfigFieldKindSchema: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
14
+ type ConfigFieldKind = Static<typeof ConfigFieldKindSchema>;
15
+ /**
16
+ * A key the renderer offers on the focused field, sent back verbatim as an
17
+ * action. Owners use this for confirmations, so the pending question survives a
18
+ * panel that is closed and reopened.
19
+ */
20
+ declare const ConfigActionSchema: Type.TObject<{
21
+ key: Type.TString;
22
+ label: Type.TString;
23
+ action: Type.TString;
24
+ }>;
25
+ type ConfigAction = Static<typeof ConfigActionSchema>;
26
+ declare const ConfigChoiceSchema: Type.TObject<{
27
+ id: Type.TString;
28
+ label: Type.TString;
29
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
30
+ detail: Type.TOptional<Type.TString>;
31
+ /** Groups entries under a heading the cursor skips over. */
32
+ group: Type.TOptional<Type.TString>;
33
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
34
+ statusText: Type.TOptional<Type.TString>;
35
+ /**
36
+ * What enter does on this entry. Carrying it per-entry is what lets one list
37
+ * hold both an installed model that only needs selecting and an absent one
38
+ * that needs fetching, without the renderer knowing the difference.
39
+ */
40
+ action: Type.TOptional<Type.TString>;
41
+ }>;
42
+ type ConfigChoice = Static<typeof ConfigChoiceSchema>;
43
+ /**
44
+ * One line of a multi-step operation.
45
+ *
46
+ * Published as a list rather than a single "current step" string so the panel can
47
+ * show what already ran alongside what is left. During an install that is the
48
+ * difference between "something is happening" and knowing a package manager
49
+ * already finished and a download is now underway.
50
+ */
51
+ declare const ConfigStepSchema: Type.TObject<{
52
+ label: Type.TString;
53
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
54
+ detail: Type.TOptional<Type.TString>;
55
+ }>;
56
+ type ConfigStep = Static<typeof ConfigStepSchema>;
57
+ declare const ConfigProgressSchema: Type.TObject<{
58
+ label: Type.TString;
59
+ /** 0 to 1. Omitted when the work has no measurable total. */
60
+ ratio: Type.TOptional<Type.TNumber>;
61
+ }>;
62
+ type ConfigProgress = Static<typeof ConfigProgressSchema>;
63
+ declare const ConfigFieldSchema: Type.TObject<{
64
+ id: Type.TString;
65
+ label: Type.TString;
66
+ kind: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
67
+ /** Absent means unset; the renderer shows `placeholder` instead. */
68
+ value: Type.TOptional<Type.TString>;
69
+ placeholder: Type.TOptional<Type.TString>;
70
+ /** One line of help for the focused field. */
71
+ detail: Type.TOptional<Type.TString>;
72
+ /** The config key this writes, shown under the focused field so the file stays legible. */
73
+ keyPath: Type.TOptional<Type.TString>;
74
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
75
+ /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
76
+ statusText: Type.TOptional<Type.TString>;
77
+ choices: Type.TOptional<Type.TArray<Type.TObject<{
78
+ id: Type.TString;
79
+ label: Type.TString;
80
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
81
+ detail: Type.TOptional<Type.TString>;
82
+ /** Groups entries under a heading the cursor skips over. */
83
+ group: Type.TOptional<Type.TString>;
84
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
85
+ statusText: Type.TOptional<Type.TString>;
86
+ /**
87
+ * What enter does on this entry. Carrying it per-entry is what lets one list
88
+ * hold both an installed model that only needs selecting and an absent one
89
+ * that needs fetching, without the renderer knowing the difference.
90
+ */
91
+ action: Type.TOptional<Type.TString>;
92
+ }>>>;
93
+ actions: Type.TOptional<Type.TArray<Type.TObject<{
94
+ key: Type.TString;
95
+ label: Type.TString;
96
+ action: Type.TString;
97
+ }>>>;
98
+ /** Work is running; the renderer dims the field and offers abort. */
99
+ busy: Type.TOptional<Type.TBoolean>;
100
+ progress: Type.TOptional<Type.TObject<{
101
+ label: Type.TString;
102
+ /** 0 to 1. Omitted when the work has no measurable total. */
103
+ ratio: Type.TOptional<Type.TNumber>;
104
+ }>>;
105
+ steps: Type.TOptional<Type.TArray<Type.TObject<{
106
+ label: Type.TString;
107
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
108
+ detail: Type.TOptional<Type.TString>;
109
+ }>>>;
110
+ /**
111
+ * The tail of a running command's terminal output.
112
+ *
113
+ * A tail rather than the whole scrollback: the field is a few rows of a
114
+ * shared pane, and what matters is the question a package manager just
115
+ * asked, not what it printed a minute ago.
116
+ */
117
+ output: Type.TOptional<Type.TArray<Type.TString>>;
118
+ /**
119
+ * The command is waiting on the user. The renderer offers a line to type
120
+ * into, which comes back as an owner-defined action carrying the text.
121
+ */
122
+ awaitingInput: Type.TOptional<Type.TBoolean>;
123
+ }>;
124
+ type ConfigField = Static<typeof ConfigFieldSchema>;
125
+ declare const ConfigSectionSchema: Type.TObject<{
126
+ id: Type.TString;
127
+ title: Type.TString;
128
+ detail: Type.TOptional<Type.TString>;
129
+ order: Type.TInteger;
130
+ /** Section-wide state: readiness, or why a write failed. */
131
+ notice: Type.TOptional<Type.TString>;
132
+ noticeLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"info">, Type.TLiteral<"error">]>>;
133
+ fields: Type.TArray<Type.TObject<{
134
+ id: Type.TString;
135
+ label: Type.TString;
136
+ kind: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
137
+ /** Absent means unset; the renderer shows `placeholder` instead. */
138
+ value: Type.TOptional<Type.TString>;
139
+ placeholder: Type.TOptional<Type.TString>;
140
+ /** One line of help for the focused field. */
141
+ detail: Type.TOptional<Type.TString>;
142
+ /** The config key this writes, shown under the focused field so the file stays legible. */
143
+ keyPath: Type.TOptional<Type.TString>;
144
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
145
+ /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
146
+ statusText: Type.TOptional<Type.TString>;
147
+ choices: Type.TOptional<Type.TArray<Type.TObject<{
148
+ id: Type.TString;
149
+ label: Type.TString;
150
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
151
+ detail: Type.TOptional<Type.TString>;
152
+ /** Groups entries under a heading the cursor skips over. */
153
+ group: Type.TOptional<Type.TString>;
154
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
155
+ statusText: Type.TOptional<Type.TString>;
156
+ /**
157
+ * What enter does on this entry. Carrying it per-entry is what lets one list
158
+ * hold both an installed model that only needs selecting and an absent one
159
+ * that needs fetching, without the renderer knowing the difference.
160
+ */
161
+ action: Type.TOptional<Type.TString>;
162
+ }>>>;
163
+ actions: Type.TOptional<Type.TArray<Type.TObject<{
164
+ key: Type.TString;
165
+ label: Type.TString;
166
+ action: Type.TString;
167
+ }>>>;
168
+ /** Work is running; the renderer dims the field and offers abort. */
169
+ busy: Type.TOptional<Type.TBoolean>;
170
+ progress: Type.TOptional<Type.TObject<{
171
+ label: Type.TString;
172
+ /** 0 to 1. Omitted when the work has no measurable total. */
173
+ ratio: Type.TOptional<Type.TNumber>;
174
+ }>>;
175
+ steps: Type.TOptional<Type.TArray<Type.TObject<{
176
+ label: Type.TString;
177
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
178
+ detail: Type.TOptional<Type.TString>;
179
+ }>>>;
180
+ /**
181
+ * The tail of a running command's terminal output.
182
+ *
183
+ * A tail rather than the whole scrollback: the field is a few rows of a
184
+ * shared pane, and what matters is the question a package manager just
185
+ * asked, not what it printed a minute ago.
186
+ */
187
+ output: Type.TOptional<Type.TArray<Type.TString>>;
188
+ /**
189
+ * The command is waiting on the user. The renderer offers a line to type
190
+ * into, which comes back as an owner-defined action carrying the text.
191
+ */
192
+ awaitingInput: Type.TOptional<Type.TBoolean>;
193
+ }>>;
194
+ }>;
195
+ type ConfigSection = Static<typeof ConfigSectionSchema>;
196
+ declare const ConfigSourceRefSchema: Type.TObject<{
197
+ source: Type.TString;
198
+ generation: Type.TString;
199
+ }>;
200
+ declare const ConfigSnapshotSchema: Type.TObject<{
201
+ sections: Type.TArray<Type.TObject<{
202
+ id: Type.TString;
203
+ title: Type.TString;
204
+ detail: Type.TOptional<Type.TString>;
205
+ order: Type.TInteger;
206
+ /** Section-wide state: readiness, or why a write failed. */
207
+ notice: Type.TOptional<Type.TString>;
208
+ noticeLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"info">, Type.TLiteral<"error">]>>;
209
+ fields: Type.TArray<Type.TObject<{
210
+ id: Type.TString;
211
+ label: Type.TString;
212
+ kind: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
213
+ /** Absent means unset; the renderer shows `placeholder` instead. */
214
+ value: Type.TOptional<Type.TString>;
215
+ placeholder: Type.TOptional<Type.TString>;
216
+ /** One line of help for the focused field. */
217
+ detail: Type.TOptional<Type.TString>;
218
+ /** The config key this writes, shown under the focused field so the file stays legible. */
219
+ keyPath: Type.TOptional<Type.TString>;
220
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
221
+ /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
222
+ statusText: Type.TOptional<Type.TString>;
223
+ choices: Type.TOptional<Type.TArray<Type.TObject<{
224
+ id: Type.TString;
225
+ label: Type.TString;
226
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
227
+ detail: Type.TOptional<Type.TString>;
228
+ /** Groups entries under a heading the cursor skips over. */
229
+ group: Type.TOptional<Type.TString>;
230
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
231
+ statusText: Type.TOptional<Type.TString>;
232
+ /**
233
+ * What enter does on this entry. Carrying it per-entry is what lets one list
234
+ * hold both an installed model that only needs selecting and an absent one
235
+ * that needs fetching, without the renderer knowing the difference.
236
+ */
237
+ action: Type.TOptional<Type.TString>;
238
+ }>>>;
239
+ actions: Type.TOptional<Type.TArray<Type.TObject<{
240
+ key: Type.TString;
241
+ label: Type.TString;
242
+ action: Type.TString;
243
+ }>>>;
244
+ /** Work is running; the renderer dims the field and offers abort. */
245
+ busy: Type.TOptional<Type.TBoolean>;
246
+ progress: Type.TOptional<Type.TObject<{
247
+ label: Type.TString;
248
+ /** 0 to 1. Omitted when the work has no measurable total. */
249
+ ratio: Type.TOptional<Type.TNumber>;
250
+ }>>;
251
+ steps: Type.TOptional<Type.TArray<Type.TObject<{
252
+ label: Type.TString;
253
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
254
+ detail: Type.TOptional<Type.TString>;
255
+ }>>>;
256
+ /**
257
+ * The tail of a running command's terminal output.
258
+ *
259
+ * A tail rather than the whole scrollback: the field is a few rows of a
260
+ * shared pane, and what matters is the question a package manager just
261
+ * asked, not what it printed a minute ago.
262
+ */
263
+ output: Type.TOptional<Type.TArray<Type.TString>>;
264
+ /**
265
+ * The command is waiting on the user. The renderer offers a line to type
266
+ * into, which comes back as an owner-defined action carrying the text.
267
+ */
268
+ awaitingInput: Type.TOptional<Type.TBoolean>;
269
+ }>>;
270
+ }>>;
271
+ source: Type.TString;
272
+ generation: Type.TString;
273
+ }>;
274
+ type ConfigSnapshot = Static<typeof ConfigSnapshotSchema>;
275
+ type ConfigSourceRef = Static<typeof ConfigSourceRefSchema>;
276
+ declare const ConfigDiscovery: NotificationDefinition<Type.TObject<{}>>;
277
+ declare const ConfigRegistration: NotificationDefinition<Type.TObject<{
278
+ sections: Type.TArray<Type.TObject<{
279
+ id: Type.TString;
280
+ title: Type.TString;
281
+ detail: Type.TOptional<Type.TString>;
282
+ order: Type.TInteger;
283
+ /** Section-wide state: readiness, or why a write failed. */
284
+ notice: Type.TOptional<Type.TString>;
285
+ noticeLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"info">, Type.TLiteral<"error">]>>;
286
+ fields: Type.TArray<Type.TObject<{
287
+ id: Type.TString;
288
+ label: Type.TString;
289
+ kind: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
290
+ /** Absent means unset; the renderer shows `placeholder` instead. */
291
+ value: Type.TOptional<Type.TString>;
292
+ placeholder: Type.TOptional<Type.TString>;
293
+ /** One line of help for the focused field. */
294
+ detail: Type.TOptional<Type.TString>;
295
+ /** The config key this writes, shown under the focused field so the file stays legible. */
296
+ keyPath: Type.TOptional<Type.TString>;
297
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
298
+ /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
299
+ statusText: Type.TOptional<Type.TString>;
300
+ choices: Type.TOptional<Type.TArray<Type.TObject<{
301
+ id: Type.TString;
302
+ label: Type.TString;
303
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
304
+ detail: Type.TOptional<Type.TString>;
305
+ /** Groups entries under a heading the cursor skips over. */
306
+ group: Type.TOptional<Type.TString>;
307
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
308
+ statusText: Type.TOptional<Type.TString>;
309
+ /**
310
+ * What enter does on this entry. Carrying it per-entry is what lets one list
311
+ * hold both an installed model that only needs selecting and an absent one
312
+ * that needs fetching, without the renderer knowing the difference.
313
+ */
314
+ action: Type.TOptional<Type.TString>;
315
+ }>>>;
316
+ actions: Type.TOptional<Type.TArray<Type.TObject<{
317
+ key: Type.TString;
318
+ label: Type.TString;
319
+ action: Type.TString;
320
+ }>>>;
321
+ /** Work is running; the renderer dims the field and offers abort. */
322
+ busy: Type.TOptional<Type.TBoolean>;
323
+ progress: Type.TOptional<Type.TObject<{
324
+ label: Type.TString;
325
+ /** 0 to 1. Omitted when the work has no measurable total. */
326
+ ratio: Type.TOptional<Type.TNumber>;
327
+ }>>;
328
+ steps: Type.TOptional<Type.TArray<Type.TObject<{
329
+ label: Type.TString;
330
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
331
+ detail: Type.TOptional<Type.TString>;
332
+ }>>>;
333
+ /**
334
+ * The tail of a running command's terminal output.
335
+ *
336
+ * A tail rather than the whole scrollback: the field is a few rows of a
337
+ * shared pane, and what matters is the question a package manager just
338
+ * asked, not what it printed a minute ago.
339
+ */
340
+ output: Type.TOptional<Type.TArray<Type.TString>>;
341
+ /**
342
+ * The command is waiting on the user. The renderer offers a line to type
343
+ * into, which comes back as an owner-defined action carrying the text.
344
+ */
345
+ awaitingInput: Type.TOptional<Type.TBoolean>;
346
+ }>>;
347
+ }>>;
348
+ source: Type.TString;
349
+ generation: Type.TString;
350
+ }>>;
351
+ /** Also the reply channel: every invoked action is answered by one of these. */
352
+ declare const ConfigChanged: NotificationDefinition<Type.TObject<{
353
+ sections: Type.TArray<Type.TObject<{
354
+ id: Type.TString;
355
+ title: Type.TString;
356
+ detail: Type.TOptional<Type.TString>;
357
+ order: Type.TInteger;
358
+ /** Section-wide state: readiness, or why a write failed. */
359
+ notice: Type.TOptional<Type.TString>;
360
+ noticeLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"info">, Type.TLiteral<"error">]>>;
361
+ fields: Type.TArray<Type.TObject<{
362
+ id: Type.TString;
363
+ label: Type.TString;
364
+ kind: Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"enum">, Type.TLiteral<"choice">, Type.TLiteral<"info">]>;
365
+ /** Absent means unset; the renderer shows `placeholder` instead. */
366
+ value: Type.TOptional<Type.TString>;
367
+ placeholder: Type.TOptional<Type.TString>;
368
+ /** One line of help for the focused field. */
369
+ detail: Type.TOptional<Type.TString>;
370
+ /** The config key this writes, shown under the focused field so the file stays legible. */
371
+ keyPath: Type.TOptional<Type.TString>;
372
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
373
+ /** Doubles as the error line: a rejected edit comes back as the old value plus this. */
374
+ statusText: Type.TOptional<Type.TString>;
375
+ choices: Type.TOptional<Type.TArray<Type.TObject<{
376
+ id: Type.TString;
377
+ label: Type.TString;
378
+ /** Right-aligned by the renderer. Sizes, ids, anything narrow. */
379
+ detail: Type.TOptional<Type.TString>;
380
+ /** Groups entries under a heading the cursor skips over. */
381
+ group: Type.TOptional<Type.TString>;
382
+ status: Type.TOptional<Type.TUnion<[Type.TLiteral<"ready">, Type.TLiteral<"available">, Type.TLiteral<"blocked">]>>;
383
+ statusText: Type.TOptional<Type.TString>;
384
+ /**
385
+ * What enter does on this entry. Carrying it per-entry is what lets one list
386
+ * hold both an installed model that only needs selecting and an absent one
387
+ * that needs fetching, without the renderer knowing the difference.
388
+ */
389
+ action: Type.TOptional<Type.TString>;
390
+ }>>>;
391
+ actions: Type.TOptional<Type.TArray<Type.TObject<{
392
+ key: Type.TString;
393
+ label: Type.TString;
394
+ action: Type.TString;
395
+ }>>>;
396
+ /** Work is running; the renderer dims the field and offers abort. */
397
+ busy: Type.TOptional<Type.TBoolean>;
398
+ progress: Type.TOptional<Type.TObject<{
399
+ label: Type.TString;
400
+ /** 0 to 1. Omitted when the work has no measurable total. */
401
+ ratio: Type.TOptional<Type.TNumber>;
402
+ }>>;
403
+ steps: Type.TOptional<Type.TArray<Type.TObject<{
404
+ label: Type.TString;
405
+ state: Type.TUnion<[Type.TLiteral<"pending">, Type.TLiteral<"satisfied">, Type.TLiteral<"running">, Type.TLiteral<"done">, Type.TLiteral<"failed">]>;
406
+ detail: Type.TOptional<Type.TString>;
407
+ }>>>;
408
+ /**
409
+ * The tail of a running command's terminal output.
410
+ *
411
+ * A tail rather than the whole scrollback: the field is a few rows of a
412
+ * shared pane, and what matters is the question a package manager just
413
+ * asked, not what it printed a minute ago.
414
+ */
415
+ output: Type.TOptional<Type.TArray<Type.TString>>;
416
+ /**
417
+ * The command is waiting on the user. The renderer offers a line to type
418
+ * into, which comes back as an owner-defined action carrying the text.
419
+ */
420
+ awaitingInput: Type.TOptional<Type.TBoolean>;
421
+ }>>;
422
+ }>>;
423
+ source: Type.TString;
424
+ generation: Type.TString;
425
+ }>>;
426
+ declare const ConfigUnregistration: NotificationDefinition<Type.TObject<{
427
+ source: Type.TString;
428
+ generation: Type.TString;
429
+ }>>;
430
+ /**
431
+ * A keystroke handed back to the field's owner.
432
+ *
433
+ * A notification rather than a request/reply because every owner listens on one
434
+ * channel: with request/reply each `provide` would answer, and a non-addressed
435
+ * owner's reply would race the real one. Owners answer with `ConfigChanged`
436
+ * instead, on success and on failure alike, which is also what carries progress
437
+ * while long work runs.
438
+ *
439
+ * `set` and `clear` are the two the renderer originates on its own. Everything
440
+ * else is an owner-defined name the renderer read off a choice or an action and
441
+ * hands back verbatim.
442
+ */
443
+ declare const ConfigInvoked: NotificationDefinition<Type.TObject<{
444
+ /** The addressed owner. Checked against the envelope source by the receiver. */
445
+ source: Type.TString;
446
+ sectionId: Type.TString;
447
+ fieldId: Type.TString;
448
+ action: Type.TString;
449
+ /** The typed text for `set`, or the chosen entry's id for a choice action. */
450
+ value: Type.TOptional<Type.TString>;
451
+ }>>;
452
+ declare const CONFIG_ACTION: {
453
+ readonly set: "set";
454
+ readonly clear: "clear";
455
+ };
456
+ interface ConfigProvider {
457
+ source: string;
458
+ listSections(): readonly ConfigSection[];
459
+ }
460
+ interface ConfigProviderHandle {
461
+ update(): void;
462
+ dispose(): void;
463
+ }
464
+ declare function registerConfigProvider(runtime: ProtocolRuntime, provider: ConfigProvider): ConfigProviderHandle;
465
+ interface DoomExtensionContext {
466
+ sessionManager: {
467
+ getSessionId(): string;
468
+ };
469
+ }
470
+ interface DoomExtensionHost {
471
+ events: EventBusLike;
472
+ on(event: string, handler: (event: unknown, context: DoomExtensionContext) => void): void;
473
+ }
474
+ interface DoomConfigSectionView extends ConfigSection {
475
+ source: string;
476
+ }
477
+ interface DoomConfigInvocation {
478
+ source: string;
479
+ sectionId: string;
480
+ fieldId: string;
481
+ action: string;
482
+ value?: string;
483
+ }
484
+ declare class DoomConfigRegistry {
485
+ private readonly sources;
486
+ private readonly listeners;
487
+ private runtime;
488
+ bind(runtime: ProtocolRuntime): () => void;
489
+ getSections(): DoomConfigSectionView[];
490
+ invoke(invocation: DoomConfigInvocation): void;
491
+ subscribe(listener: () => void): () => void;
492
+ reset(): void;
493
+ private register;
494
+ private update;
495
+ private unregister;
496
+ private notify;
497
+ }
498
+ interface DoomConfigActionInput {
499
+ ctx: DoomExtensionContext;
500
+ sectionId: string;
501
+ fieldId: string;
502
+ value?: string;
503
+ }
504
+ interface DoomConfigContributionOptions {
505
+ source: string;
506
+ listSections: () => readonly ConfigSection[];
507
+ handlers: Readonly<Record<string, (input: DoomConfigActionInput) => void | Promise<void>>>;
508
+ onError: (error: unknown, actionName: string, ctx: DoomExtensionContext) => void;
509
+ }
510
+ interface DoomConfigContributionHandle {
511
+ update(): void;
512
+ dispose(): void;
513
+ }
514
+ declare function registerDoomConfigContribution(pi: DoomExtensionHost, options: DoomConfigContributionOptions): DoomConfigContributionHandle;
515
+ //#endregion
516
+ export { CONFIG_ACTION, ConfigAction, ConfigActionSchema, ConfigChanged, ConfigChoice, ConfigChoiceSchema, ConfigDiscovery, ConfigField, ConfigFieldKind, ConfigFieldKindSchema, ConfigFieldSchema, ConfigInvoked, ConfigProgress, ConfigProgressSchema, ConfigProvider, ConfigProviderHandle, ConfigRegistration, ConfigSection, ConfigSectionSchema, ConfigSnapshot, ConfigSourceRef, ConfigSourceSchema, ConfigStatus, ConfigStatusSchema, ConfigStep, ConfigStepSchema, ConfigUnregistration, DoomConfigActionInput, DoomConfigContributionHandle, DoomConfigContributionOptions, DoomConfigInvocation, DoomConfigRegistry, DoomConfigSectionView, DoomExtensionContext, DoomExtensionHost, registerConfigProvider, registerDoomConfigContribution };
517
+ //# sourceMappingURL=config.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;cAuBa,oBAAkB,KAAA;;;;;;cAalB,oBAAkB,KAAA,QAAA,KAAA,mBAAA,KAAA,uBAAA,KAAA;KAKnB,eAAe,cAAc;cAE5B,uBAAqB,KAAA,QAAA,KAAA,kBAAA,KAAA,kBAAA,KAAA,oBAAA,KAAA;KAUtB,kBAAkB,cAAc;;;;;;cAO/B,oBAAkB,KAAA;;;;;KAQnB,eAAe,cAAc;cAE5B,oBAAkB,KAAA;;;;;;;;;;;;;;;;KAmBnB,eAAe,cAAc;;;;;;;;;cAU5B,kBAAgB,KAAA;;;;;KAejB,aAAa,cAAc;cAE1B,sBAAoB,KAAA;;;;;KAQrB,iBAAiB,cAAc;cAE9B,mBAAiB,KAAA;;;;;;;;;;;;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;iBAGc,+BACd,IAAI,mBACJ,SAAS,gCACR"}
@@ -0,0 +1,2 @@
1
+ import{createProtocolRuntime as e,defineNotification as t}from"./protocol.mjs";import{Type as n}from"typebox";const r=n.String({minLength:1,maxLength:128,pattern:`^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$`}),i=n.String({minLength:1,maxLength:128,pattern:`^[a-z0-9][a-z0-9._:-]*$`}),a=n.Union([n.Literal(`ready`),n.Literal(`available`),n.Literal(`blocked`)]),o=n.Union([n.Literal(`text`),n.Literal(`enum`),n.Literal(`choice`),n.Literal(`info`)]),s=n.Object({key:n.String({minLength:1,maxLength:1}),label:n.String({minLength:1,maxLength:24}),action:i},{additionalProperties:!1}),c=n.Object({id:n.String({minLength:1,maxLength:256}),label:n.String({minLength:1,maxLength:96}),detail:n.Optional(n.String({minLength:1,maxLength:96})),group:n.Optional(n.String({minLength:1,maxLength:48})),status:n.Optional(a),statusText:n.Optional(n.String({minLength:1,maxLength:96})),action:n.Optional(i)},{additionalProperties:!1}),l=n.Object({label:n.String({minLength:1,maxLength:96}),state:n.Union([n.Literal(`pending`),n.Literal(`satisfied`),n.Literal(`running`),n.Literal(`done`),n.Literal(`failed`)]),detail:n.Optional(n.String({minLength:1,maxLength:160}))},{additionalProperties:!1}),u=n.Object({label:n.String({minLength:1,maxLength:96}),ratio:n.Optional(n.Number({minimum:0,maximum:1}))},{additionalProperties:!1}),d=n.Object({id:i,label:n.String({minLength:1,maxLength:48}),kind:o,value:n.Optional(n.String({minLength:1,maxLength:4096})),placeholder:n.Optional(n.String({minLength:1,maxLength:96})),detail:n.Optional(n.String({minLength:1,maxLength:240})),keyPath:n.Optional(n.String({minLength:1,maxLength:128})),status:n.Optional(a),statusText:n.Optional(n.String({minLength:1,maxLength:240})),choices:n.Optional(n.Array(c,{maxItems:128})),actions:n.Optional(n.Array(s,{maxItems:4})),busy:n.Optional(n.Boolean()),progress:n.Optional(u),steps:n.Optional(n.Array(l,{maxItems:24})),output:n.Optional(n.Array(n.String({maxLength:512}),{maxItems:64})),awaitingInput:n.Optional(n.Boolean())},{additionalProperties:!1}),f=n.Object({id:i,title:n.String({minLength:1,maxLength:32}),detail:n.Optional(n.String({minLength:1,maxLength:96})),order:n.Integer({minimum:0,maximum:1e3}),notice:n.Optional(n.String({minLength:1,maxLength:240})),noticeLevel:n.Optional(n.Union([n.Literal(`info`),n.Literal(`error`)])),fields:n.Array(d,{maxItems:64})},{additionalProperties:!1}),p=n.Object({source:r,generation:n.String({minLength:1})},{additionalProperties:!1}),m=n.Object({...p.properties,sections:n.Array(f,{maxItems:32})},{additionalProperties:!1}),h=t({channel:`doom:ui:config:v1:discover`,kind:`config.discover`,payload:n.Object({},{additionalProperties:!1})}),g=t({channel:`doom:ui:config:v1:register`,kind:`config.register`,payload:m}),_=t({channel:`doom:ui:config:v1:changed`,kind:`config.changed`,payload:m}),v=t({channel:`doom:ui:config:v1:unregister`,kind:`config.unregister`,payload:p}),y=t({channel:`doom:ui:config:v1:invoked`,kind:`config.invoked`,payload:n.Object({source:r,sectionId:i,fieldId:i,action:i,value:n.Optional(n.String({minLength:1,maxLength:4096}))},{additionalProperties:!1})}),b={set:`set`,clear:`clear`};function x(e,t){let n=`${t.source}:${crypto.randomUUID()}`,r=!1,i=()=>({source:t.source,generation:n,sections:t.listSections().map(e=>({...e,fields:[...e.fields]}))}),a=()=>{r||e.notify(g,i())},o=e.onNotification(h,a);return a(),{update(){r||e.notify(_,i())},dispose(){r||(r=!0,o(),e.notify(v,{source:t.source,generation:n}))}}}var S=class{sources=new Map;listeners=new Set;runtime;bind(e){this.runtime=e;let t=[e.onNotification(g,(e,t)=>{t.source===e.source&&this.register(e)}),e.onNotification(_,(e,t)=>{t.source===e.source&&this.update(e)}),e.onNotification(v,(e,t)=>{t.source===e.source&&this.unregister(e)})];e.notify(h,{});let n=!1;return()=>{if(!n){n=!0;for(let e of t)e();this.runtime===e&&(this.runtime=void 0)}}}getSections(){return[...this.sources.entries()].flatMap(([e,t])=>t.sections.map(t=>({source:e,...t}))).toSorted((e,t)=>e.order-t.order||e.source.localeCompare(t.source)||e.id.localeCompare(t.id))}invoke(e){this.runtime?.notify(y,{source:e.source,sectionId:e.sectionId,fieldId:e.fieldId,action:e.action,...e.value===void 0?{}:{value:e.value}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}reset(){this.sources.size!==0&&(this.sources.clear(),this.notify())}register(e){this.sources.set(e.source,{generation:e.generation,sections:C(e.sections)}),this.notify()}update(e){this.sources.get(e.source)?.generation===e.generation&&(this.sources.set(e.source,{generation:e.generation,sections:C(e.sections)}),this.notify())}unregister(e){this.sources.get(e.source)?.generation===e.generation&&(this.sources.delete(e.source),this.notify())}notify(){for(let e of this.listeners)e()}};function C(e){return e.map(e=>({...e,fields:e.fields.map(e=>({...e}))}))}function w(t,n){let r,i,a,o=0,s=!1,c=()=>{r?.dispose(),r=void 0,i?.(),i=void 0},l=()=>{if(!(!r||!a))try{r.update()}catch(e){n.onError(e,`update`,a)}};return t.on(`session_start`,(u,d)=>{if(s)return;c(),a=d;let f=++o,p=e({bus:t.events,source:n.source,sessionId:d.sessionManager.getSessionId()}),m=()=>{try{return n.listSections()}catch(e){return n.onError(e,`listSections`,d),[]}};try{r=x(p,{source:n.source,listSections:m})}catch(e){n.onError(e,`register`,d),r=void 0}i=p.onNotification(y,async(e,t)=>{if(s||o!==f||t.source!==`@agimon-ai/doompi-ui`||e.source!==n.source)return;let r=n.handlers[e.action];if(r){try{await r({ctx:d,sectionId:e.sectionId,fieldId:e.fieldId,...e.value===void 0?{}:{value:e.value}})}catch(t){n.onError(t,e.action,d)}l()}})}),t.on(`session_shutdown`,()=>{++o,c()}),{update(){s||l()},dispose(){s||(s=!0,++o,c(),a=void 0)}}}export{b as CONFIG_ACTION,s as ConfigActionSchema,_ as ConfigChanged,c as ConfigChoiceSchema,h as ConfigDiscovery,o as ConfigFieldKindSchema,d as ConfigFieldSchema,y as ConfigInvoked,u as ConfigProgressSchema,g as ConfigRegistration,f as ConfigSectionSchema,r as ConfigSourceSchema,a as ConfigStatusSchema,l as ConfigStepSchema,v as ConfigUnregistration,S as DoomConfigRegistry,x as registerConfigProvider,w as registerDoomConfigContribution};
2
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration surfaces, contributed by every extension that owns settings.\n *\n * Doom settings live in one YAML file but are owned by many extensions, and for\n * a long time the only way to change any of them was to edit that file by hand.\n * The one exception, an editor-command prompt, asked for a value with no way to\n * see what a valid one looked like.\n *\n * So configuration is published rather than centralised: an extension describes\n * its own fields, one renderer draws them all, and the extension still performs\n * every write. Nothing here knows what a voice model or an editor command is.\n *\n * Deliberately the same shape as the mode and footer contracts next door, since\n * the problem is the same one: several extensions sharing one surface. The one\n * addition is `ConfigInvoked`, the renderer's way of handing a keystroke back to\n * whichever extension owns the field, because unlike a status strip this surface\n * is written to as well as read.\n */\n\nimport { type Static, Type } from 'typebox';\nimport { createProtocolRuntime, defineNotification, type EventBusLike, type ProtocolRuntime } from './protocol.ts';\n\n/** Matches the leader contract's source rule: package names, addressable and spoof-checkable. */\nexport const ConfigSourceSchema = Type.String({\n minLength: 1,\n maxLength: 128,\n pattern: '^[A-Za-z0-9@][A-Za-z0-9@/._:-]*$',\n});\n\nconst ConfigIdSchema = Type.String({ minLength: 1, maxLength: 128, pattern: '^[a-z0-9][a-z0-9._:-]*$' });\n\n/**\n * How ready a value is to be used, as opposed to whether it is merely set.\n * `blocked` covers a choice that needs something else first, such as a model\n * whose engine is not installed.\n */\nexport const ConfigStatusSchema = Type.Union([\n Type.Literal('ready'),\n Type.Literal('available'),\n Type.Literal('blocked'),\n]);\nexport type ConfigStatus = Static<typeof ConfigStatusSchema>;\n\nexport const ConfigFieldKindSchema = Type.Union([\n /** Free text, edited in place. */\n Type.Literal('text'),\n /** A short closed set, cycled in place. */\n Type.Literal('enum'),\n /** A long set worth its own screen, with per-entry status and actions. */\n Type.Literal('choice'),\n /** Read-only. Resolution results, derived values, preflight checks. */\n Type.Literal('info'),\n]);\nexport type ConfigFieldKind = Static<typeof ConfigFieldKindSchema>;\n\n/**\n * A key the renderer offers on the focused field, sent back verbatim as an\n * action. Owners use this for confirmations, so the pending question survives a\n * panel that is closed and reopened.\n */\nexport const ConfigActionSchema = Type.Object(\n {\n key: Type.String({ minLength: 1, maxLength: 1 }),\n label: Type.String({ minLength: 1, maxLength: 24 }),\n action: ConfigIdSchema,\n },\n { additionalProperties: false },\n);\nexport type ConfigAction = Static<typeof ConfigActionSchema>;\n\nexport const ConfigChoiceSchema = Type.Object(\n {\n id: Type.String({ minLength: 1, maxLength: 256 }),\n label: Type.String({ minLength: 1, maxLength: 96 }),\n /** Right-aligned by the renderer. Sizes, ids, anything narrow. */\n detail: Type.Optional(Type.String({ minLength: 1, maxLength: 96 })),\n /** Groups entries under a heading the cursor skips over. */\n group: Type.Optional(Type.String({ minLength: 1, maxLength: 48 })),\n status: Type.Optional(ConfigStatusSchema),\n statusText: Type.Optional(Type.String({ minLength: 1, maxLength: 96 })),\n /**\n * What enter does on this entry. Carrying it per-entry is what lets one list\n * hold both an installed model that only needs selecting and an absent one\n * that needs fetching, without the renderer knowing the difference.\n */\n action: Type.Optional(ConfigIdSchema),\n },\n { additionalProperties: false },\n);\nexport type ConfigChoice = Static<typeof ConfigChoiceSchema>;\n\n/**\n * One line of a multi-step operation.\n *\n * Published as a list rather than a single \"current step\" string so the panel can\n * show what already ran alongside what is left. During an install that is the\n * difference between \"something is happening\" and knowing a package manager\n * already finished and a download is now underway.\n */\nexport const ConfigStepSchema = Type.Object(\n {\n label: Type.String({ minLength: 1, maxLength: 96 }),\n state: Type.Union([\n Type.Literal('pending'),\n /** Already true of this machine, so nothing will run for it. */\n Type.Literal('satisfied'),\n Type.Literal('running'),\n Type.Literal('done'),\n Type.Literal('failed'),\n ]),\n detail: Type.Optional(Type.String({ minLength: 1, maxLength: 160 })),\n },\n { additionalProperties: false },\n);\nexport type ConfigStep = Static<typeof ConfigStepSchema>;\n\nexport const ConfigProgressSchema = Type.Object(\n {\n label: Type.String({ minLength: 1, maxLength: 96 }),\n /** 0 to 1. Omitted when the work has no measurable total. */\n ratio: Type.Optional(Type.Number({ minimum: 0, maximum: 1 })),\n },\n { additionalProperties: false },\n);\nexport type ConfigProgress = Static<typeof ConfigProgressSchema>;\n\nexport const ConfigFieldSchema = Type.Object(\n {\n id: ConfigIdSchema,\n label: Type.String({ minLength: 1, maxLength: 48 }),\n kind: ConfigFieldKindSchema,\n /** Absent means unset; the renderer shows `placeholder` instead. */\n value: Type.Optional(Type.String({ minLength: 1, maxLength: 4096 })),\n placeholder: Type.Optional(Type.String({ minLength: 1, maxLength: 96 })),\n /** One line of help for the focused field. */\n detail: Type.Optional(Type.String({ minLength: 1, maxLength: 240 })),\n /** The config key this writes, shown under the focused field so the file stays legible. */\n keyPath: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),\n status: Type.Optional(ConfigStatusSchema),\n /** Doubles as the error line: a rejected edit comes back as the old value plus this. */\n statusText: Type.Optional(Type.String({ minLength: 1, maxLength: 240 })),\n choices: Type.Optional(Type.Array(ConfigChoiceSchema, { maxItems: 128 })),\n actions: Type.Optional(Type.Array(ConfigActionSchema, { maxItems: 4 })),\n /** Work is running; the renderer dims the field and offers abort. */\n busy: Type.Optional(Type.Boolean()),\n progress: Type.Optional(ConfigProgressSchema),\n steps: Type.Optional(Type.Array(ConfigStepSchema, { maxItems: 24 })),\n /**\n * The tail of a running command's terminal output.\n *\n * A tail rather than the whole scrollback: the field is a few rows of a\n * shared pane, and what matters is the question a package manager just\n * asked, not what it printed a minute ago.\n */\n output: Type.Optional(Type.Array(Type.String({ maxLength: 512 }), { maxItems: 64 })),\n /**\n * The command is waiting on the user. The renderer offers a line to type\n * into, which comes back as an owner-defined action carrying the text.\n */\n awaitingInput: Type.Optional(Type.Boolean()),\n },\n { additionalProperties: false },\n);\nexport type ConfigField = Static<typeof ConfigFieldSchema>;\n\nexport const ConfigSectionSchema = Type.Object(\n {\n id: ConfigIdSchema,\n title: Type.String({ minLength: 1, maxLength: 32 }),\n detail: Type.Optional(Type.String({ minLength: 1, maxLength: 96 })),\n order: Type.Integer({ minimum: 0, maximum: 1000 }),\n /** Section-wide state: readiness, or why a write failed. */\n notice: Type.Optional(Type.String({ minLength: 1, maxLength: 240 })),\n noticeLevel: Type.Optional(Type.Union([Type.Literal('info'), Type.Literal('error')])),\n fields: Type.Array(ConfigFieldSchema, { maxItems: 64 }),\n },\n { additionalProperties: false },\n);\nexport type ConfigSection = Static<typeof ConfigSectionSchema>;\n\nconst ConfigSourceRefSchema = Type.Object(\n { source: ConfigSourceSchema, generation: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\n\nconst ConfigSnapshotSchema = Type.Object(\n { ...ConfigSourceRefSchema.properties, sections: Type.Array(ConfigSectionSchema, { maxItems: 32 }) },\n { additionalProperties: false },\n);\nexport type ConfigSnapshot = Static<typeof ConfigSnapshotSchema>;\nexport type ConfigSourceRef = Static<typeof ConfigSourceRefSchema>;\n\nexport const ConfigDiscovery = defineNotification({\n channel: 'doom:ui:config:v1:discover',\n kind: 'config.discover',\n payload: Type.Object({}, { additionalProperties: false }),\n});\n\nexport const ConfigRegistration = defineNotification({\n channel: 'doom:ui:config:v1:register',\n kind: 'config.register',\n payload: ConfigSnapshotSchema,\n});\n\n/** Also the reply channel: every invoked action is answered by one of these. */\nexport const ConfigChanged = defineNotification({\n channel: 'doom:ui:config:v1:changed',\n kind: 'config.changed',\n payload: ConfigSnapshotSchema,\n});\n\nexport const ConfigUnregistration = defineNotification({\n channel: 'doom:ui:config:v1:unregister',\n kind: 'config.unregister',\n payload: ConfigSourceRefSchema,\n});\n\n/**\n * A keystroke handed back to the field's owner.\n *\n * A notification rather than a request/reply because every owner listens on one\n * channel: with request/reply each `provide` would answer, and a non-addressed\n * owner's reply would race the real one. Owners answer with `ConfigChanged`\n * instead, on success and on failure alike, which is also what carries progress\n * while long work runs.\n *\n * `set` and `clear` are the two the renderer originates on its own. Everything\n * else is an owner-defined name the renderer read off a choice or an action and\n * hands back verbatim.\n */\nexport const ConfigInvoked = defineNotification({\n channel: 'doom:ui:config:v1:invoked',\n kind: 'config.invoked',\n payload: Type.Object(\n {\n /** The addressed owner. Checked against the envelope source by the receiver. */\n source: ConfigSourceSchema,\n sectionId: ConfigIdSchema,\n fieldId: ConfigIdSchema,\n action: ConfigIdSchema,\n /** The typed text for `set`, or the chosen entry's id for a choice action. */\n value: Type.Optional(Type.String({ minLength: 1, maxLength: 4096 })),\n },\n { additionalProperties: false },\n ),\n});\n\nexport const CONFIG_ACTION = {\n set: 'set',\n clear: 'clear',\n} as const;\n\nexport interface ConfigProvider {\n source: string;\n listSections(): readonly ConfigSection[];\n}\n\nexport interface ConfigProviderHandle {\n update(): void;\n dispose(): void;\n}\n\nexport function registerConfigProvider(runtime: ProtocolRuntime, provider: ConfigProvider): ConfigProviderHandle {\n const generation = `${provider.source}:${crypto.randomUUID()}`;\n let disposed = false;\n const snapshot = (): ConfigSnapshot => ({\n source: provider.source,\n generation,\n sections: provider.listSections().map((section) => ({ ...section, fields: [...section.fields] })),\n });\n // A renderer that loads after a provider would otherwise never learn about it,\n // and neither side controls the order extensions load in.\n const announce = (): void => {\n if (!disposed) runtime.notify(ConfigRegistration, snapshot());\n };\n const disposeDiscovery = runtime.onNotification(ConfigDiscovery, announce);\n announce();\n\n return {\n update() {\n if (!disposed) runtime.notify(ConfigChanged, snapshot());\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n disposeDiscovery();\n runtime.notify(ConfigUnregistration, { source: provider.source, generation });\n },\n };\n}\n\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\nconst DOOM_UI_SOURCE = '@agimon-ai/doompi-ui';\n\nexport interface DoomExtensionContext {\n sessionManager: { getSessionId(): string };\n}\n\nexport interface DoomExtensionHost {\n events: EventBusLike;\n on(event: string, handler: (event: unknown, context: DoomExtensionContext) => void): void;\n}\n\nexport interface DoomConfigSectionView extends ConfigSection {\n source: string;\n}\n\nexport interface DoomConfigInvocation {\n source: string;\n sectionId: string;\n fieldId: string;\n action: string;\n value?: string;\n}\n\ninterface ActiveConfigSource {\n generation: string;\n sections: ConfigSection[];\n}\n\nexport class DoomConfigRegistry {\n private readonly sources = new Map<string, ActiveConfigSource>();\n private readonly listeners = new Set<() => void>();\n private runtime: ProtocolRuntime | undefined;\n\n bind(runtime: ProtocolRuntime): () => void {\n this.runtime = runtime;\n const disposers = [\n runtime.onNotification(ConfigRegistration, (snapshot, identity) => {\n if (identity.source !== snapshot.source) return;\n this.register(snapshot);\n }),\n runtime.onNotification(ConfigChanged, (snapshot, identity) => {\n if (identity.source !== snapshot.source) return;\n this.update(snapshot);\n }),\n runtime.onNotification(ConfigUnregistration, (source, identity) => {\n if (identity.source !== source.source) return;\n this.unregister(source);\n }),\n ];\n runtime.notify(ConfigDiscovery, {});\n let disposed = false;\n return () => {\n if (disposed) return;\n disposed = true;\n for (const dispose of disposers) dispose();\n if (this.runtime === runtime) this.runtime = undefined;\n };\n }\n\n getSections(): DoomConfigSectionView[] {\n return [...this.sources.entries()]\n .flatMap(([source, snapshot]) => snapshot.sections.map((section) => ({ source, ...section })))\n .toSorted(\n (left, right) =>\n left.order - right.order || left.source.localeCompare(right.source) || left.id.localeCompare(right.id),\n );\n }\n\n invoke(invocation: DoomConfigInvocation): void {\n this.runtime?.notify(ConfigInvoked, {\n source: invocation.source,\n sectionId: invocation.sectionId,\n fieldId: invocation.fieldId,\n action: invocation.action,\n ...(invocation.value === undefined ? {} : { value: invocation.value }),\n });\n }\n\n subscribe(listener: () => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n reset(): void {\n if (this.sources.size === 0) return;\n this.sources.clear();\n this.notify();\n }\n\n private register(snapshot: ConfigSnapshot): void {\n this.sources.set(snapshot.source, { generation: snapshot.generation, sections: copySections(snapshot.sections) });\n this.notify();\n }\n\n private update(snapshot: ConfigSnapshot): void {\n if (this.sources.get(snapshot.source)?.generation !== snapshot.generation) return;\n this.sources.set(snapshot.source, { generation: snapshot.generation, sections: copySections(snapshot.sections) });\n this.notify();\n }\n\n private unregister(source: ConfigSourceRef): void {\n if (this.sources.get(source.source)?.generation !== source.generation) return;\n this.sources.delete(source.source);\n this.notify();\n }\n\n private notify(): void {\n for (const listener of this.listeners) listener();\n }\n}\n\nfunction copySections(sections: readonly ConfigSection[]): ConfigSection[] {\n return sections.map((section) => ({ ...section, fields: section.fields.map((field) => ({ ...field })) }));\n}\n\nexport interface DoomConfigActionInput {\n ctx: DoomExtensionContext;\n sectionId: string;\n fieldId: string;\n value?: string;\n}\n\nexport interface DoomConfigContributionOptions {\n source: string;\n listSections: () => readonly ConfigSection[];\n handlers: Readonly<Record<string, (input: DoomConfigActionInput) => void | Promise<void>>>;\n onError: (error: unknown, actionName: string, ctx: DoomExtensionContext) => void;\n}\n\nexport interface DoomConfigContributionHandle {\n update(): void;\n dispose(): void;\n}\n\nexport function registerDoomConfigContribution(\n pi: DoomExtensionHost,\n options: DoomConfigContributionOptions,\n): DoomConfigContributionHandle {\n let provider: ConfigProviderHandle | undefined;\n let disposeNotification: (() => void) | undefined;\n let activeContext: DoomExtensionContext | undefined;\n let generation = 0;\n let stopped = false;\n\n const teardown = (): void => {\n provider?.dispose();\n provider = undefined;\n disposeNotification?.();\n disposeNotification = undefined;\n };\n const publish = (): void => {\n if (!provider || !activeContext) return;\n try {\n provider.update();\n } catch (error) {\n options.onError(error, 'update', activeContext);\n }\n };\n\n pi.on(SESSION_START_EVENT, (_event, ctx) => {\n if (stopped) return;\n teardown();\n activeContext = ctx;\n const activeGeneration = ++generation;\n const runtime = createProtocolRuntime({\n bus: pi.events,\n source: options.source,\n sessionId: ctx.sessionManager.getSessionId(),\n });\n const safeListSections = (): readonly ConfigSection[] => {\n try {\n return options.listSections();\n } catch (error) {\n options.onError(error, 'listSections', ctx);\n return [];\n }\n };\n try {\n provider = registerConfigProvider(runtime, { source: options.source, listSections: safeListSections });\n } catch (error) {\n options.onError(error, 'register', ctx);\n provider = undefined;\n }\n disposeNotification = runtime.onNotification(ConfigInvoked, async (payload, identity) => {\n if (stopped || generation !== activeGeneration) return;\n if (identity.source !== DOOM_UI_SOURCE || payload.source !== options.source) return;\n const handler = options.handlers[payload.action];\n if (!handler) return;\n try {\n await handler({\n ctx,\n sectionId: payload.sectionId,\n fieldId: payload.fieldId,\n ...(payload.value === undefined ? {} : { value: payload.value }),\n });\n } catch (error) {\n options.onError(error, payload.action, ctx);\n }\n publish();\n });\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, () => {\n ++generation;\n teardown();\n });\n\n return {\n update() {\n if (!stopped) publish();\n },\n dispose() {\n if (stopped) return;\n stopped = true;\n ++generation;\n teardown();\n activeContext = undefined;\n },\n };\n}\n"],"mappings":"8GAuBA,MAAa,EAAqB,EAAK,OAAO,CAC5C,UAAW,EACX,UAAW,IACX,QAAS,kCACX,CAAC,EAEK,EAAiB,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,IAAK,QAAS,yBAA0B,CAAC,EAO1F,EAAqB,EAAK,MAAM,CAC3C,EAAK,QAAQ,OAAO,EACpB,EAAK,QAAQ,WAAW,EACxB,EAAK,QAAQ,SAAS,CACxB,CAAC,EAGY,EAAwB,EAAK,MAAM,CAE9C,EAAK,QAAQ,MAAM,EAEnB,EAAK,QAAQ,MAAM,EAEnB,EAAK,QAAQ,QAAQ,EAErB,EAAK,QAAQ,MAAM,CACrB,CAAC,EAQY,EAAqB,EAAK,OACrC,CACE,IAAK,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,CAAE,CAAC,EAC/C,MAAO,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,EAAG,CAAC,EAClD,OAAQ,CACV,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAAqB,EAAK,OACrC,CACE,GAAI,EAAK,OAAO,CAAE,UAAW,EAAG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GAClB,CACF,CACF"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./protocol.cjs"),t=require("./subagentTool.cjs");let n=require("typebox");const r=n.Type.Object({requestId:n.Type.String({minLength:1}),taskId:n.Type.Union([n.Type.String(),n.Type.Number()]),agent:n.Type.String({minLength:1}),inlineAgent:n.Type.Optional(t.InlineAgentSchema),prompt:n.Type.String({minLength:1}),cwd:n.Type.String({minLength:1}),model:n.Type.Optional(n.Type.String({minLength:1})),context:n.Type.Optional(n.Type.Union([n.Type.Literal(`fresh`),n.Type.Literal(`fork`)])),timeoutMs:n.Type.Optional(n.Type.Integer({minimum:1})),artifacts:n.Type.Optional(n.Type.Boolean()),runMode:n.Type.Optional(n.Type.Union([n.Type.Literal(`foreground`),n.Type.Literal(`detached`)])),teamTask:n.Type.Optional(n.Type.Object({id:n.Type.String({minLength:1}),subject:n.Type.String({minLength:1})},{additionalProperties:!1}))},{additionalProperties:!1}),i=n.Type.Object({requestId:n.Type.String({minLength:1})},{additionalProperties:!1}),a=n.Type.Object({requestId:n.Type.String({minLength:1}),runId:n.Type.String({minLength:1})},{additionalProperties:!1}),o=n.Type.Object({requestId:n.Type.String({minLength:1}),runId:n.Type.String({minLength:1}),status:n.Type.Optional(n.Type.String({minLength:1})),currentTool:n.Type.Optional(n.Type.String({minLength:1})),toolCount:n.Type.Optional(n.Type.Integer({minimum:0})),durationMs:n.Type.Optional(n.Type.Integer({minimum:0})),tokens:n.Type.Optional(n.Type.Integer({minimum:0}))},{additionalProperties:!1}),s=n.Type.Union([n.Type.Literal(`completed`),n.Type.Literal(`failed`),n.Type.Literal(`timed_out`),n.Type.Literal(`cancelled`),n.Type.Literal(`interrupted`),n.Type.Literal(`turn_budget_exhausted`),n.Type.Literal(`tool_budget_exhausted`),n.Type.Literal(`acceptance_failed`),n.Type.Literal(`invalid_request`),n.Type.Literal(`unavailable_context`)]),c=n.Type.Object({requestId:n.Type.String({minLength:1}),runId:n.Type.String({minLength:1}),status:s,output:n.Type.Optional(n.Type.String()),error:n.Type.Optional(n.Type.String()),outputPath:n.Type.Optional(n.Type.String({minLength:1})),sessionFile:n.Type.Optional(n.Type.String({minLength:1})),durationMs:n.Type.Optional(n.Type.Integer({minimum:0})),toolCount:n.Type.Optional(n.Type.Integer({minimum:0}))},{additionalProperties:!1}),l=n.Type.Object({requestId:n.Type.String({minLength:1}),reason:n.Type.Optional(n.Type.String({minLength:1}))},{additionalProperties:!1}),u=e.defineNotification({channel:`doom:team:delegation:v1:requested`,kind:`delegation.requested`,payload:r}),d=e.defineNotification({channel:`doom:team:delegation:v1:accepted`,kind:`delegation.accepted`,payload:i}),f=e.defineNotification({channel:`doom:team:delegation:v1:started`,kind:`delegation.started`,payload:a}),p=e.defineNotification({channel:`doom:team:delegation:v1:updated`,kind:`delegation.updated`,payload:o}),m=e.defineNotification({channel:`doom:team:delegation:v1:finished`,kind:`delegation.finished`,payload:c}),h=e.defineNotification({channel:`doom:team:delegation:v1:cancelled`,kind:`delegation.cancelled`,payload:l});exports.DelegationAccepted=d,exports.DelegationAcceptedSchema=i,exports.DelegationCancelSchema=l,exports.DelegationCancelled=h,exports.DelegationFinished=m,exports.DelegationRequestSchema=r,exports.DelegationRequested=u,exports.DelegationResultSchema=c,exports.DelegationStarted=f,exports.DelegationStartedSchema=a,exports.DelegationStatusSchema=s,exports.DelegationUpdateSchema=o,exports.DelegationUpdated=p;
2
+ //# sourceMappingURL=delegation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.cjs","names":["Type","InlineAgentSchema","defineNotification"],"sources":["../src/delegation.ts"],"sourcesContent":["import { type Static, Type } from 'typebox';\nimport { defineNotification } from './protocol.ts';\nimport { InlineAgentSchema } from './subagentTool.ts';\n\nexport const DelegationRequestSchema = Type.Object(\n {\n requestId: Type.String({ minLength: 1 }),\n taskId: Type.Union([Type.String(), Type.Number()]),\n agent: Type.String({ minLength: 1 }),\n inlineAgent: Type.Optional(InlineAgentSchema),\n prompt: Type.String({ minLength: 1 }),\n cwd: Type.String({ minLength: 1 }),\n model: Type.Optional(Type.String({ minLength: 1 })),\n context: Type.Optional(Type.Union([Type.Literal('fresh'), Type.Literal('fork')])),\n timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),\n artifacts: Type.Optional(Type.Boolean()),\n runMode: Type.Optional(Type.Union([Type.Literal('foreground'), Type.Literal('detached')])),\n teamTask: Type.Optional(\n Type.Object(\n { id: Type.String({ minLength: 1 }), subject: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n ),\n ),\n },\n { additionalProperties: false },\n);\nexport type DelegationRequest = Static<typeof DelegationRequestSchema>;\n\nexport const DelegationAcceptedSchema = Type.Object(\n { requestId: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\nexport type DelegationAccepted = Static<typeof DelegationAcceptedSchema>;\n\nexport const DelegationStartedSchema = Type.Object(\n { requestId: Type.String({ minLength: 1 }), runId: Type.String({ minLength: 1 }) },\n { additionalProperties: false },\n);\nexport type DelegationStarted = Static<typeof DelegationStartedSchema>;\n\nexport const DelegationUpdateSchema = Type.Object(\n {\n requestId: Type.String({ minLength: 1 }),\n runId: Type.String({ minLength: 1 }),\n status: Type.Optional(Type.String({ minLength: 1 })),\n currentTool: Type.Optional(Type.String({ minLength: 1 })),\n toolCount: Type.Optional(Type.Integer({ minimum: 0 })),\n durationMs: Type.Optional(Type.Integer({ minimum: 0 })),\n tokens: Type.Optional(Type.Integer({ minimum: 0 })),\n },\n { additionalProperties: false },\n);\nexport type DelegationUpdate = Static<typeof DelegationUpdateSchema>;\n\nexport const DelegationStatusSchema = Type.Union([\n Type.Literal('completed'),\n Type.Literal('failed'),\n Type.Literal('timed_out'),\n Type.Literal('cancelled'),\n Type.Literal('interrupted'),\n Type.Literal('turn_budget_exhausted'),\n Type.Literal('tool_budget_exhausted'),\n Type.Literal('acceptance_failed'),\n Type.Literal('invalid_request'),\n Type.Literal('unavailable_context'),\n]);\nexport type DelegationStatus = Static<typeof DelegationStatusSchema>;\n\nexport const DelegationResultSchema = Type.Object(\n {\n requestId: Type.String({ minLength: 1 }),\n runId: Type.String({ minLength: 1 }),\n status: DelegationStatusSchema,\n output: Type.Optional(Type.String()),\n error: Type.Optional(Type.String()),\n outputPath: Type.Optional(Type.String({ minLength: 1 })),\n sessionFile: Type.Optional(Type.String({ minLength: 1 })),\n durationMs: Type.Optional(Type.Integer({ minimum: 0 })),\n toolCount: Type.Optional(Type.Integer({ minimum: 0 })),\n },\n { additionalProperties: false },\n);\nexport type DelegationResult = Static<typeof DelegationResultSchema>;\n\nexport const DelegationCancelSchema = Type.Object(\n { requestId: Type.String({ minLength: 1 }), reason: Type.Optional(Type.String({ minLength: 1 })) },\n { additionalProperties: false },\n);\nexport type DelegationCancel = Static<typeof DelegationCancelSchema>;\n\nexport const DelegationRequested = defineNotification({\n channel: 'doom:team:delegation:v1:requested',\n kind: 'delegation.requested',\n payload: DelegationRequestSchema,\n});\n\nexport const DelegationAccepted = defineNotification({\n channel: 'doom:team:delegation:v1:accepted',\n kind: 'delegation.accepted',\n payload: DelegationAcceptedSchema,\n});\n\nexport const DelegationStarted = defineNotification({\n channel: 'doom:team:delegation:v1:started',\n kind: 'delegation.started',\n payload: DelegationStartedSchema,\n});\n\nexport const DelegationUpdated = defineNotification({\n channel: 'doom:team:delegation:v1:updated',\n kind: 'delegation.updated',\n payload: DelegationUpdateSchema,\n});\n\nexport const DelegationFinished = defineNotification({\n channel: 'doom:team:delegation:v1:finished',\n kind: 'delegation.finished',\n payload: DelegationResultSchema,\n});\n\nexport const DelegationCancelled = defineNotification({\n channel: 'doom:team:delegation:v1:cancelled',\n kind: 'delegation.cancelled',\n payload: DelegationCancelSchema,\n});\n"],"mappings":"8JAIA,MAAa,EAA0BA,EAAAA,KAAK,OAC1C,CACE,UAAWA,EAAAA,KAAK,OAAO,CAAE,UAAW,CAAE,CAAC,EACvC,OAAQA,EAAAA,KAAK,MAAM,CAACA,EAAAA,KAAK,OAAO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