@dinoxx/dinox-cli 2.17.0 → 2.18.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 (73) hide show
  1. package/dist/cli.js +2 -0
  2. package/dist/commands/editor/index.d.ts +4 -0
  3. package/dist/commands/editor/index.js +155 -0
  4. package/dist/commands/notes/contentPatch.d.ts +23 -0
  5. package/dist/commands/notes/contentPatch.js +37 -0
  6. package/dist/commands/schema/renderSkills.js +1 -0
  7. package/dist/commands/schema/spec.js +2 -0
  8. package/dist/daemon/server.d.ts +2 -1
  9. package/dist/daemon/server.js +22 -2
  10. package/dist/dsh-plugin/cordis.patch.yml +3 -0
  11. package/dist/dsh-plugin/lib/client.js +2145 -0
  12. package/dist/dsh-plugin/lib/index.js +369 -0
  13. package/dist/dsh-plugin/package.json +32 -0
  14. package/dist/dsh-plugin/runtime.json +5 -0
  15. package/dist/editor/anchor.d.ts +46 -0
  16. package/dist/editor/anchor.js +129 -0
  17. package/dist/editor/blockIds.d.ts +21 -0
  18. package/dist/editor/blockIds.js +51 -0
  19. package/dist/editor/blocks.d.ts +47 -0
  20. package/dist/editor/blocks.js +236 -0
  21. package/dist/editor/compat.d.ts +32 -0
  22. package/dist/editor/compat.js +392 -0
  23. package/dist/editor/daemon.d.ts +10 -0
  24. package/dist/editor/daemon.js +56 -0
  25. package/dist/editor/document.d.ts +74 -0
  26. package/dist/editor/document.js +88 -0
  27. package/dist/editor/i18n.d.ts +23 -0
  28. package/dist/editor/i18n.js +61 -0
  29. package/dist/editor/install.d.ts +72 -0
  30. package/dist/editor/install.js +239 -0
  31. package/dist/editor/mcp.d.ts +22 -0
  32. package/dist/editor/mcp.js +222 -0
  33. package/dist/editor/meta.d.ts +70 -0
  34. package/dist/editor/meta.js +163 -0
  35. package/dist/editor/paths.d.ts +2 -0
  36. package/dist/editor/paths.js +13 -0
  37. package/dist/editor/persistence.d.ts +4 -0
  38. package/dist/editor/persistence.js +35 -0
  39. package/dist/editor/saveGuard.d.ts +9 -0
  40. package/dist/editor/saveGuard.js +38 -0
  41. package/dist/editor/schema.d.ts +14 -0
  42. package/dist/editor/schema.js +38 -0
  43. package/dist/editor/service.d.ts +326 -0
  44. package/dist/editor/service.js +1007 -0
  45. package/dist/editor-ui/mcp-app.html +765 -0
  46. package/dist/gateway/adapters/acp.d.ts +8 -0
  47. package/dist/gateway/adapters/acp.js +38 -2
  48. package/dist/gateway/agentTaskHost.d.ts +9 -3
  49. package/dist/gateway/agentTaskHost.js +45 -25
  50. package/dist/gateway/config.js +2 -2
  51. package/dist/gateway/deviceHost.d.ts +1 -1
  52. package/dist/gateway/deviceHost.js +8 -4
  53. package/dist/gateway/mcpCommandTools.d.ts +1 -1
  54. package/dist/gateway/mcpCommandTools.js +2 -2
  55. package/dist/gateway/processTree.d.ts +15 -0
  56. package/dist/gateway/processTree.js +60 -0
  57. package/dist/gateway/protocol.js +2 -1
  58. package/dist/gateway/service.d.ts +1 -1
  59. package/dist/gateway/service.js +2 -1
  60. package/dist/gateway/taskJournal.d.ts +14 -0
  61. package/dist/gateway/taskJournal.js +47 -0
  62. package/dist/gateway/threadStore.d.ts +7 -1
  63. package/dist/gateway/threadStore.js +14 -3
  64. package/dist/gateway/types.d.ts +7 -3
  65. package/dist/gateway/types.js +3 -1
  66. package/dist/integrations/dsh/host.d.ts +53 -0
  67. package/dist/integrations/dsh/host.js +237 -0
  68. package/dist/integrations/dsh/mcpClient.d.ts +66 -0
  69. package/dist/integrations/dsh/mcpClient.js +192 -0
  70. package/dist/utils/errorCodes.d.ts +28 -0
  71. package/dist/utils/errorCodes.js +7 -0
  72. package/dist/vendor/electron/shared/remote-device-agent.d.ts +2 -0
  73. package/package.json +9 -2
@@ -0,0 +1,326 @@
1
+ import type { JSONContent } from '@tiptap/core';
2
+ import { type Message } from './i18n.js';
3
+ import type { EditorNote, EditorSearchHit, EditorStore } from './document.js';
4
+ import { type EditorMeta } from './meta.js';
5
+ /**
6
+ * Shared state of every co-editing session, owned by the daemon so all hosts
7
+ * (Codex, dsh, ...) and every reload of a host see the same note, suggestions
8
+ * and activity. The editor UI owns the live document and its base revision;
9
+ * this service mirrors what the model needs, writes saves through the
10
+ * daemon's database and announces changes made elsewhere.
11
+ */
12
+ export type SuggestionStatus = 'pending' | 'accepted' | 'rejected';
13
+ export type Suggestion = {
14
+ id: string;
15
+ /** comment: advice pinned to a span of text, shown as a highlight with a bubble; the text is not changed. */
16
+ kind: SuggestionKind;
17
+ /** The block the suggestion targets (replace) or follows (insert), when the model named one. */
18
+ block?: string;
19
+ /** Text offset of the anchor when it was made; the UI resolves repeated text to the nearest occurrence. */
20
+ at?: number;
21
+ /** replace: the text to change, as the model wrote it. */
22
+ find?: string;
23
+ replace?: string;
24
+ /** insert: the text the new blocks follow, or `<end>`. */
25
+ after?: string;
26
+ markdown?: string;
27
+ /** comment: the advice itself. */
28
+ comment?: string;
29
+ reason: string;
30
+ /** The exact plain-text string that matched, used by the UI to place the suggestion. */
31
+ anchor: string;
32
+ status: SuggestionStatus;
33
+ createdAt: string;
34
+ };
35
+ export type SuggestionKind = 'replace' | 'insert' | 'comment';
36
+ export type ActivityActor = 'ai' | 'user' | 'system';
37
+ export type ActivityKind = 'open' | 'read' | 'suggest' | 'accept' | 'reject' | 'save' | 'remote' | 'error';
38
+ export type Activity = {
39
+ at: string;
40
+ actor: ActivityActor;
41
+ kind: ActivityKind;
42
+ /** In the source language (Traditional Chinese); `message` words it for each UI's language. */
43
+ text: string;
44
+ message?: Message;
45
+ /** Text ranges the activity was about (e.g. the blocks the AI just read); absent means the whole note. */
46
+ focus?: Array<[number, number]>;
47
+ };
48
+ export type Selection = {
49
+ text: string;
50
+ start: number;
51
+ end: number;
52
+ };
53
+ export type UploadState = {
54
+ hash: string;
55
+ state: 'pending' | 'uploaded' | 'failed';
56
+ };
57
+ export type RemoteChange = {
58
+ seq: number;
59
+ note: EditorNote;
60
+ };
61
+ export type OpenPayload = EditorNote & {
62
+ openSeq: number;
63
+ session: string;
64
+ meta: EditorMeta | null;
65
+ };
66
+ /** One block of the open note: a textblock with a stable id. */
67
+ /** `id` is what the model reads and targets: the short form of the block's note id (`nodeId`), or a session id for a block without one. */
68
+ export type Block = {
69
+ id: string;
70
+ md: string;
71
+ text: string;
72
+ start: number;
73
+ end: number;
74
+ nodeId?: string;
75
+ };
76
+ type LogEntry = {
77
+ v: number;
78
+ op: 'added' | 'changed' | 'removed' | 'accepted' | 'rejected';
79
+ id: string | null;
80
+ by: 'user' | 'remote';
81
+ suggestion?: string;
82
+ };
83
+ export type ReadChange = {
84
+ id: string;
85
+ op: 'added' | 'changed' | 'removed';
86
+ by: 'user' | 'remote';
87
+ md?: string;
88
+ after?: string | null;
89
+ };
90
+ export type ReadResult = {
91
+ noteId: string;
92
+ title: string;
93
+ version: number;
94
+ dirty: boolean;
95
+ blockCount: number;
96
+ mode: 'full' | 'outline' | 'changes' | 'blocks';
97
+ blocks?: Array<{
98
+ id: string;
99
+ md: string;
100
+ clipped?: true;
101
+ }>;
102
+ changes?: ReadChange[];
103
+ resolved?: Array<{
104
+ suggestion: string;
105
+ block: string | null;
106
+ accepted: boolean;
107
+ }>;
108
+ selection: {
109
+ blocks: string[];
110
+ text: string;
111
+ } | null;
112
+ pending: Array<{
113
+ id: string;
114
+ kind: SuggestionKind;
115
+ block: string | null;
116
+ summary: string;
117
+ }>;
118
+ notice?: string;
119
+ };
120
+ type Session = {
121
+ key: string;
122
+ noteId: string | null;
123
+ title: string;
124
+ /** Last content hash this service loaded, saved or announced. */
125
+ knownHash: string | null;
126
+ knownVersion: number | null;
127
+ doc: JSONContent | null;
128
+ /** Derived from `doc` by `ensureBlocks`. */
129
+ plainText: string;
130
+ blocks: Block[];
131
+ blocksDoc: JSONContent | null;
132
+ blockSeq: number;
133
+ /** Note block id → the id the model knows it by; kept for the session so a block never changes id under the model. */
134
+ aliases: Map<string, string>;
135
+ /** Bumped whenever the blocks change or a suggestion is settled; the model reads changes since one. */
136
+ version: number;
137
+ /** Oldest version `read({ since })` can still answer from the log. */
138
+ floor: number;
139
+ changeLog: LogEntry[];
140
+ /** The UI's last mirrored revision; incremental mirror patches must build on it. */
141
+ mirrorRev: string | null;
142
+ /** Title, tags, boxes and properties as last read; `metaSeq` bumps whenever they change. */
143
+ meta: EditorMeta | null;
144
+ metaSeq: number;
145
+ selection: Selection;
146
+ dirty: boolean;
147
+ suggestions: Suggestion[];
148
+ activity: Activity[];
149
+ openSeq: number;
150
+ /** Highest openSeq a mounted UI has displayed. */
151
+ ackSeq: number;
152
+ rev: number;
153
+ upload: UploadState | null;
154
+ remote: RemoteChange | null;
155
+ updatedAt: number;
156
+ saving: Promise<unknown> | null;
157
+ };
158
+ export type PersistedSession = Pick<Session, 'key' | 'noteId' | 'title' | 'knownHash' | 'knownVersion' | 'openSeq' | 'suggestions' | 'activity' | 'updatedAt'> & Partial<Pick<Session, 'version' | 'blockSeq'>>;
159
+ export type EditorPersistence = {
160
+ load(): Promise<PersistedSession[]>;
161
+ save(sessions: PersistedSession[]): Promise<void>;
162
+ };
163
+ export type EditorServiceOptions = {
164
+ store: EditorStore;
165
+ persistence?: EditorPersistence;
166
+ now?: () => number;
167
+ /** Subscribes to note changes; returns an unsubscribe function. */
168
+ watchNotes?: (onChange: () => void) => () => void;
169
+ log?: (message: string, details?: Record<string, unknown>) => void;
170
+ };
171
+ /** A whole-block replacement keeps the block's type, so a repeated `## ` or `- [ ] ` is dropped. */
172
+ export declare function withoutLinePrefix(blockMd: string, replace: string): string;
173
+ export declare class EditorService {
174
+ private readonly options;
175
+ private readonly sessions;
176
+ private readonly waiters;
177
+ private readonly openWaiters;
178
+ private opensRev;
179
+ private remoteSeq;
180
+ private persistTimer;
181
+ private remoteTimer;
182
+ private unwatch;
183
+ private closed;
184
+ private readonly now;
185
+ constructor(options: EditorServiceOptions);
186
+ restore(): Promise<void>;
187
+ open(key: string, input: {
188
+ noteId?: unknown;
189
+ query?: unknown;
190
+ }): Promise<OpenPayload & {
191
+ otherHits: EditorSearchHit[];
192
+ }>;
193
+ /**
194
+ * What the model reads. Without arguments: the whole note as blocks (an
195
+ * outline around the user's cursor when it is long). With `since`: only
196
+ * what changed after that version, including the user's verdicts on
197
+ * suggestions. With `blocks`: exactly those blocks. With `focus`: the
198
+ * blocks under the user's cursor or selection and their neighbours, so an
199
+ * edit at the cursor costs a few blocks, not the whole note.
200
+ */
201
+ read(key: string, input?: Record<string, unknown>): Promise<ReadResult>;
202
+ /** Legacy name of `read` without arguments. */
203
+ state(key: string): Promise<ReadResult>;
204
+ /**
205
+ * One or more suggestions, all or none: every edit is validated against the
206
+ * note first, and any failure rejects the whole batch with a reason per edit.
207
+ */
208
+ suggest(key: string, input: Record<string, unknown>): Promise<{
209
+ version: number;
210
+ suggestions: Array<{
211
+ id: string;
212
+ kind: SuggestionKind;
213
+ block: string | null;
214
+ }>;
215
+ }>;
216
+ private prepare;
217
+ private locate;
218
+ private blockIndex;
219
+ search(input: {
220
+ query?: unknown;
221
+ limit?: unknown;
222
+ }): Promise<EditorSearchHit[]>;
223
+ /**
224
+ * Mirrors the UI and long-polls for changes. A call that carries no updates
225
+ * and names the current `rev` waits up to `waitMs` for anything to change.
226
+ */
227
+ sync(key: string, input: Record<string, unknown>, signal?: AbortSignal): Promise<{
228
+ openRequest?: OpenPayload | undefined;
229
+ rev: number;
230
+ openSeq: number;
231
+ noteId: string | null;
232
+ title: string;
233
+ suggestions: Suggestion[];
234
+ activity: Activity[];
235
+ upload: UploadState | null;
236
+ remote: RemoteChange | null;
237
+ mirrorRev: string | null;
238
+ meta: EditorMeta | null;
239
+ metaSeq: number;
240
+ }>;
241
+ save(key: string, input: Record<string, unknown>): Promise<{
242
+ status: "saved" | "unchanged";
243
+ hash: string;
244
+ version: number | null;
245
+ updatedAt: string | null;
246
+ } | {
247
+ status: "conflict";
248
+ current: {
249
+ hash: string;
250
+ version: number | null;
251
+ updatedAt: string | null;
252
+ };
253
+ }>;
254
+ resolve(key: string, input: Record<string, unknown>): {
255
+ ok: boolean;
256
+ };
257
+ /** Tags, card boxes and property definitions the header can pick from. */
258
+ catalog(): Promise<import("./meta.js").EditorCatalog>;
259
+ /** Writes the title, tags, boxes, starred or property values of the open note. */
260
+ updateMeta(key: string, input: Record<string, unknown>): Promise<{
261
+ changed: string[];
262
+ meta: EditorMeta;
263
+ metaSeq: number;
264
+ }>;
265
+ note(key: string, input: Record<string, unknown>): {
266
+ ok: boolean;
267
+ };
268
+ /** Sessions whose latest open has not reached a UI; hosts use this to reveal the editor. */
269
+ watchOpens(input: Record<string, unknown>, signal?: AbortSignal): Promise<{
270
+ cursor: number;
271
+ opens: {
272
+ session: string;
273
+ openSeq: number;
274
+ noteId: string | null;
275
+ title: string;
276
+ }[];
277
+ }>;
278
+ close(): Promise<void>;
279
+ /** Re-reads open notes and announces content changed outside this service. */
280
+ checkRemote(): Promise<void>;
281
+ private blank;
282
+ private session;
283
+ private requireOpen;
284
+ private payload;
285
+ private view;
286
+ /** A session restored after a daemon restart has no document until something needs it. */
287
+ private hydrate;
288
+ /**
289
+ * Takes a document from outside the mirror. `by: null` starts a fresh
290
+ * history (a newly opened or restored note); otherwise the difference is
291
+ * logged as that actor's change.
292
+ */
293
+ private adopt;
294
+ /** Brings the blocks up to date with the document, logging what changed. */
295
+ private ensureBlocks;
296
+ /**
297
+ * Which block is which. A block with a note id is that block, whatever
298
+ * happened to its text: it keeps the id the model knows it by. Only blocks
299
+ * without one (older notes, or a block that just got its id in this edit)
300
+ * are paired by position and similarity with the blocks that had none.
301
+ */
302
+ private identify;
303
+ private log;
304
+ private changesSince;
305
+ private blockAt;
306
+ private selectionBlocks;
307
+ private recordRead;
308
+ /**
309
+ * Mirror updates from the UI: a whole document, or a splice of top-level
310
+ * nodes on top of the revision the daemon has. A splice on any other base is
311
+ * ignored; the view's `mirrorRev` then tells the UI to resend in full.
312
+ */
313
+ private applyMirror;
314
+ private trackUpload;
315
+ private record;
316
+ private loadMeta;
317
+ private setMeta;
318
+ private changed;
319
+ private waitersOf;
320
+ private wake;
321
+ private waitFor;
322
+ private updateWatch;
323
+ private schedulePersist;
324
+ private persistNow;
325
+ }
326
+ export {};