@pulsarinteractive/geniustasker 0.1.0-beta.17 → 0.1.0-beta.19
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.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/docs/CHATGPT.md +7 -0
- package/docs/CLI.md +32 -1
- package/docs/DOCUMENTATION_SYNC.md +8 -0
- package/docs/INTEGRATIONS.md +8 -4
- package/docs/MEMORY.md +90 -8
- package/docs/PLANNING.md +2 -1
- package/docs/STORAGE.md +32 -0
- package/docs/WORKFLOWS.md +8 -0
- package/examples/codex.toml +1 -1
- package/examples/mcp.json +1 -1
- package/mcp.json +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/remote/tool-catalog.json +1014 -11
- package/remote/workflows.json +208 -5
- package/skills/geniustasker/SKILL.md +16 -0
- package/skills/geniustasker-documentation/SKILL.md +5 -0
- package/skills/geniustasker-media/SKILL.md +10 -1
- package/skills/geniustasker-memory/SKILL.md +38 -5
- package/skills/geniustasker-planning/SKILL.md +12 -0
- package/src/archive.d.mts +1 -0
- package/src/archive.mjs +96 -0
- package/src/attachment-upload.mjs +203 -0
- package/src/cli.mjs +109 -0
- package/src/client.mjs +6 -0
- package/src/command-catalog.mjs +35 -14
- package/src/command-input-schemas.mjs +102 -0
- package/src/documentation-sync.mjs +23 -2
- package/src/mcp.mjs +83 -3
- package/src/memory-editorial.d.mts +5 -0
- package/src/memory-editorial.mjs +216 -0
- package/src/memory-history.mjs +45 -0
- package/src/memory-read-pages.d.mts +4 -0
- package/src/memory-read-pages.mjs +221 -0
- package/src/ticket-storage.mjs +67 -0
- package/src/transport.mjs +21 -3
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { constants } from 'node:fs';
|
|
2
|
+
import { open } from 'node:fs/promises';
|
|
3
|
+
import { basename, join, resolve } from 'node:path';
|
|
4
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
5
|
+
import * as z from 'zod/v4';
|
|
6
|
+
import { CredentialStore } from './store.mjs';
|
|
7
|
+
import { AgentError, fail } from './errors.mjs';
|
|
8
|
+
import { operationIdSchema } from './commands.mjs';
|
|
9
|
+
|
|
10
|
+
const partBytes = 8 * 1024 * 1024,
|
|
11
|
+
directBytes = 15_000_000;
|
|
12
|
+
export const ticketUploadInput = z
|
|
13
|
+
.object({
|
|
14
|
+
scope: z.string().regex(/^project:[A-Za-z0-9_-]{1,128}$/),
|
|
15
|
+
taskId: z.string().regex(/^[A-Za-z0-9_-]{1,128}$/),
|
|
16
|
+
attachmentId: z.string().uuid(),
|
|
17
|
+
epoch: z.string().min(1).max(128),
|
|
18
|
+
replaceRevision: z
|
|
19
|
+
.string()
|
|
20
|
+
.regex(/^[1-9][0-9]{0,31}$/)
|
|
21
|
+
.optional(),
|
|
22
|
+
file: z.string().min(1).max(4096),
|
|
23
|
+
contentType: z.string().min(1).max(128),
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
const binding = (s) => [s.origin, s.connection_id, s.profile_id, s.session_id];
|
|
27
|
+
const digest = (b) => createHash('sha256').update(b).digest('hex');
|
|
28
|
+
const route = (op) => '/api/agents/v1/attachment-uploads/' + op;
|
|
29
|
+
function storeFor(client, id) {
|
|
30
|
+
if (!operationIdSchema.safeParse(id).success) {
|
|
31
|
+
fail('invalid_arguments', 'Use a prepared upload ID.');
|
|
32
|
+
}
|
|
33
|
+
return new CredentialStore({
|
|
34
|
+
directory: join(client.store.directory, 'attachments', client.store.context),
|
|
35
|
+
context: id,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function withFile(file, run) {
|
|
39
|
+
let handle;
|
|
40
|
+
try {
|
|
41
|
+
handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
42
|
+
const stat = await handle.stat();
|
|
43
|
+
if (!stat.isFile() || stat.size < 1 || stat.size > 200_000_000) {
|
|
44
|
+
fail('invalid_arguments', 'Choose one regular ticket attachment of at most 200 MB.');
|
|
45
|
+
}
|
|
46
|
+
return await run(handle, stat.size);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof AgentError) {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
if (['ENOENT', 'ELOOP', 'EACCES', 'EISDIR'].includes(error.code)) {
|
|
52
|
+
fail('invalid_arguments', 'The selected local attachment is unavailable.');
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
} finally {
|
|
56
|
+
await handle?.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function readPart(handle, position, length) {
|
|
60
|
+
const data = Buffer.alloc(length);
|
|
61
|
+
let read = 0;
|
|
62
|
+
while (read < length) {
|
|
63
|
+
const { bytesRead } = await handle.read(data, read, length - read, position + read);
|
|
64
|
+
if (!bytesRead) {
|
|
65
|
+
fail('file_changed', 'The source file changed. Prepare the new file explicitly.');
|
|
66
|
+
}
|
|
67
|
+
read += bytesRead;
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
export async function prepareTicketUpload(client, raw) {
|
|
72
|
+
const validation = ticketUploadInput.safeParse(raw);
|
|
73
|
+
if (!validation.success) {
|
|
74
|
+
fail('invalid_arguments', 'Specify the project, task and attachment and a regular local file.');
|
|
75
|
+
}
|
|
76
|
+
const { file, scope, taskId, attachmentId, epoch, replaceRevision, contentType } =
|
|
77
|
+
validation.data;
|
|
78
|
+
const session = await client.authorizedSession(),
|
|
79
|
+
path = resolve(file),
|
|
80
|
+
id = randomUUID(),
|
|
81
|
+
fileName = basename(path);
|
|
82
|
+
if (fileName.length > 200) {
|
|
83
|
+
fail('invalid_arguments', 'Choose a filename of at most 200 characters.');
|
|
84
|
+
}
|
|
85
|
+
return withFile(path, async (handle, size) => {
|
|
86
|
+
const hash = createHash('sha256'),
|
|
87
|
+
hashes = [];
|
|
88
|
+
for (let at = 0; at < size; at += partBytes) {
|
|
89
|
+
const part = await readPart(handle, at, Math.min(partBytes, size - at));
|
|
90
|
+
hash.update(part);
|
|
91
|
+
hashes.push(digest(part));
|
|
92
|
+
}
|
|
93
|
+
const input = {
|
|
94
|
+
id,
|
|
95
|
+
issuedAt: Date.now(),
|
|
96
|
+
scope,
|
|
97
|
+
taskId,
|
|
98
|
+
attachmentId,
|
|
99
|
+
expectedEpoch: epoch,
|
|
100
|
+
...(replaceRevision ? { replaceRevision } : {}),
|
|
101
|
+
size,
|
|
102
|
+
sha256: hash.digest('hex'),
|
|
103
|
+
fileName,
|
|
104
|
+
contentType,
|
|
105
|
+
kind: 'project',
|
|
106
|
+
purpose: 'ticketAttachment',
|
|
107
|
+
};
|
|
108
|
+
const store = storeFor(client, id);
|
|
109
|
+
await store.locked(() => store.write({ binding: binding(session), input, hashes, path }));
|
|
110
|
+
return { operationId: id, fileName, size, scope, taskId, attachmentId, prepared: true };
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export async function uploadTicketAttachment(client, id) {
|
|
114
|
+
const store = storeFor(client, id);
|
|
115
|
+
return store.locked(async () => {
|
|
116
|
+
const saved = await store.read(),
|
|
117
|
+
session = await client.authorizedSession();
|
|
118
|
+
if (
|
|
119
|
+
saved?.input?.id !== id ||
|
|
120
|
+
JSON.stringify(saved.binding) !== JSON.stringify(binding(session))
|
|
121
|
+
) {
|
|
122
|
+
fail('media_context_changed', 'Resume in the original authorized context.');
|
|
123
|
+
}
|
|
124
|
+
const input = saved.input,
|
|
125
|
+
token = session.access_token;
|
|
126
|
+
const request = (op, options = {}) =>
|
|
127
|
+
client.transport.request(route(op), { ...options, token });
|
|
128
|
+
const opened = await request('sessions', { method: 'POST', json: input });
|
|
129
|
+
if (
|
|
130
|
+
opened?.id !== id ||
|
|
131
|
+
opened.size !== input.size ||
|
|
132
|
+
!/^[-_a-zA-Z0-9]{1,128}$/.test(opened.ownerId) ||
|
|
133
|
+
typeof opened.published !== 'boolean'
|
|
134
|
+
) {
|
|
135
|
+
fail('invalid_response', 'The session does not match this upload.');
|
|
136
|
+
}
|
|
137
|
+
const query = {
|
|
138
|
+
scope: input.scope,
|
|
139
|
+
taskId: input.taskId,
|
|
140
|
+
attachmentId: input.attachmentId,
|
|
141
|
+
ownerId: opened.ownerId,
|
|
142
|
+
id,
|
|
143
|
+
...(input.replaceRevision ? { replaceRevision: input.replaceRevision } : {}),
|
|
144
|
+
};
|
|
145
|
+
const receipt = {
|
|
146
|
+
scope: input.scope,
|
|
147
|
+
taskId: input.taskId,
|
|
148
|
+
attachmentId: input.attachmentId,
|
|
149
|
+
assetId: id,
|
|
150
|
+
published: true,
|
|
151
|
+
};
|
|
152
|
+
if (opened.published) {
|
|
153
|
+
return receipt;
|
|
154
|
+
}
|
|
155
|
+
await withFile(saved.path, async (handle, size) => {
|
|
156
|
+
if (size !== input.size) {
|
|
157
|
+
fail('file_changed', 'Prepare the changed source file again.');
|
|
158
|
+
}
|
|
159
|
+
if (size <= directBytes) {
|
|
160
|
+
const bytes = await readPart(handle, 0, size);
|
|
161
|
+
if (digest(bytes) !== input.sha256) {
|
|
162
|
+
fail('file_changed', 'Prepare the changed source file again.');
|
|
163
|
+
}
|
|
164
|
+
await request('content', { method: 'PUT', query, bytes });
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const state = await request('parts', { query });
|
|
168
|
+
if (
|
|
169
|
+
state?.partSize !== partBytes ||
|
|
170
|
+
!Array.isArray(state.parts) ||
|
|
171
|
+
state.parts.some((v) => !Number.isInteger(v) || v < 1 || v > saved.hashes.length) ||
|
|
172
|
+
new Set(state.parts).size !== state.parts.length ||
|
|
173
|
+
typeof state.complete !== 'boolean'
|
|
174
|
+
) {
|
|
175
|
+
fail('invalid_response', 'The upload part index is invalid.');
|
|
176
|
+
}
|
|
177
|
+
if (state.complete) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
for (let n = 1; n <= saved.hashes.length; n++) {
|
|
181
|
+
if (state.parts.includes(n)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const at = (n - 1) * partBytes,
|
|
185
|
+
bytes = await readPart(handle, at, Math.min(partBytes, size - at)),
|
|
186
|
+
partSha256 = digest(bytes);
|
|
187
|
+
if (partSha256 !== saved.hashes[n - 1]) {
|
|
188
|
+
fail('file_changed', 'Prepare the changed source file again.');
|
|
189
|
+
}
|
|
190
|
+
await request('parts/' + n, { method: 'PUT', query, bytes, partSha256 });
|
|
191
|
+
}
|
|
192
|
+
const completed = await request('complete', { method: 'POST', query });
|
|
193
|
+
if (!completed?.complete) {
|
|
194
|
+
fail('media_not_published', 'The transfer has not completed. Resume the same upload.');
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const published = await request('publish', { method: 'POST', query });
|
|
198
|
+
if (!published?.published || published.id !== id || published.ownerId !== opened.ownerId) {
|
|
199
|
+
fail('media_not_published', 'Resume the same upload and verify its publication.');
|
|
200
|
+
}
|
|
201
|
+
return receipt;
|
|
202
|
+
});
|
|
203
|
+
}
|
package/src/cli.mjs
CHANGED
|
@@ -12,6 +12,16 @@ import {
|
|
|
12
12
|
uploadFeedbackImage,
|
|
13
13
|
downloadFeedbackImage,
|
|
14
14
|
} from './feedback-media-transfer.mjs';
|
|
15
|
+
import { prepareTicketUpload, uploadTicketAttachment } from './attachment-upload.mjs';
|
|
16
|
+
import { ticketStorageTools, ticketStorageRequest } from './ticket-storage.mjs';
|
|
17
|
+
import { readArchive } from './archive.mjs';
|
|
18
|
+
import {
|
|
19
|
+
readProjectDocumentation,
|
|
20
|
+
reviewProjectMemory,
|
|
21
|
+
previewMemoryTemplate,
|
|
22
|
+
} from './memory-editorial.mjs';
|
|
23
|
+
import { memoryHistoryRequest } from './memory-history.mjs';
|
|
24
|
+
import { readMemoryPages } from './memory-read-pages.mjs';
|
|
15
25
|
import { workflow, workflowTopics } from './workflows.mjs';
|
|
16
26
|
import { readFile } from 'node:fs/promises';
|
|
17
27
|
import {
|
|
@@ -181,6 +191,57 @@ export const commands = {
|
|
|
181
191
|
summary: 'Read one folder and descendant versions; unchanged validators avoid page bodies.',
|
|
182
192
|
options: ['scope', 'parent', 'after', 'epoch', 'checkpoint', 'if-none-match'],
|
|
183
193
|
},
|
|
194
|
+
...Object.fromEntries(
|
|
195
|
+
[...ticketStorageTools].map(([command, { tool }]) => [
|
|
196
|
+
command,
|
|
197
|
+
{ summary: tool.description, options: ['file'] },
|
|
198
|
+
]),
|
|
199
|
+
),
|
|
200
|
+
'attachment prepare-upload': {
|
|
201
|
+
summary: 'Prepare a local original and bind it to one ticket and attachment.',
|
|
202
|
+
options: ['file'],
|
|
203
|
+
},
|
|
204
|
+
'attachment upload': {
|
|
205
|
+
summary: 'Resume the prepared private upload and return its published asset ID.',
|
|
206
|
+
options: ['operation'],
|
|
207
|
+
},
|
|
208
|
+
'archive query': {
|
|
209
|
+
summary: 'Search one project archive with bounded filters from a JSON file.',
|
|
210
|
+
options: ['file'],
|
|
211
|
+
},
|
|
212
|
+
'archive detail': {
|
|
213
|
+
summary: 'Read one archived task with historical access.',
|
|
214
|
+
options: ['scope', 'id'],
|
|
215
|
+
},
|
|
216
|
+
'archive comments': {
|
|
217
|
+
summary: 'Read one page of comments for the selected archived task.',
|
|
218
|
+
options: ['scope', 'id', 'after'],
|
|
219
|
+
},
|
|
220
|
+
'memory review': {
|
|
221
|
+
summary: 'Evaluate verified evidence against the live documentation policy. Reads only.',
|
|
222
|
+
options: ['file'],
|
|
223
|
+
},
|
|
224
|
+
'memory template': {
|
|
225
|
+
summary: 'List optional pages in a family or preview one selected page.',
|
|
226
|
+
options: ['family', 'page', 'language'],
|
|
227
|
+
},
|
|
228
|
+
'memory history': {
|
|
229
|
+
summary: 'Read a page of retained revision metadata for an authorized note.',
|
|
230
|
+
options: ['scope', 'page', 'before-revision'],
|
|
231
|
+
},
|
|
232
|
+
'memory diff': {
|
|
233
|
+
summary: 'Compare changed fields and block excerpts between retained revisions.',
|
|
234
|
+
options: ['scope', 'page', 'from', 'to'],
|
|
235
|
+
},
|
|
236
|
+
'memory restore': {
|
|
237
|
+
summary: 'Restore a confirmed note revision using an immutable JSON request.',
|
|
238
|
+
options: ['file'],
|
|
239
|
+
},
|
|
240
|
+
'memory read-pages': {
|
|
241
|
+
summary:
|
|
242
|
+
'Read one bounded batch of selected page outlines or blocks. The JSON file contains scope, pages and optional snapshot.',
|
|
243
|
+
options: ['file'],
|
|
244
|
+
},
|
|
184
245
|
'memory markdown': {
|
|
185
246
|
summary: 'Fetch one portable Markdown document with stable media IDs and source metadata.',
|
|
186
247
|
options: ['scope', 'page', 'revision', 'epoch', 'checkpoint'],
|
|
@@ -198,6 +259,10 @@ export const commands = {
|
|
|
198
259
|
'Resolve a Memory page or block with current permissions; unavailable links preserve nodes.',
|
|
199
260
|
options: ['scope', 'page', 'block'],
|
|
200
261
|
},
|
|
262
|
+
'projects documentation': {
|
|
263
|
+
summary: 'Read the current editorial policy and its authorized target.',
|
|
264
|
+
options: ['scope'],
|
|
265
|
+
},
|
|
201
266
|
'projects list': {
|
|
202
267
|
summary: 'Read a bounded project page; follow nextAfter even for an empty page.',
|
|
203
268
|
options: ['after'],
|
|
@@ -597,6 +662,50 @@ export async function main(
|
|
|
597
662
|
checkpoint: options.checkpoint,
|
|
598
663
|
ifNoneMatch: options['if-none-match'],
|
|
599
664
|
});
|
|
665
|
+
} else if (command === 'attachment prepare-upload') {
|
|
666
|
+
data = await prepareTicketUpload(client, await readCommandFile(options.file));
|
|
667
|
+
} else if (command === 'attachment upload') {
|
|
668
|
+
data = await uploadTicketAttachment(client, options.operation);
|
|
669
|
+
} else if (ticketStorageTools.has(command)) {
|
|
670
|
+
data = await ticketStorageRequest(client, command, await readCommandFile(options.file));
|
|
671
|
+
} else if (command.startsWith('archive ')) {
|
|
672
|
+
const operation = command.split(' ')[1];
|
|
673
|
+
const input =
|
|
674
|
+
operation === 'query'
|
|
675
|
+
? await readCommandFile(options.file)
|
|
676
|
+
: {
|
|
677
|
+
scope: options.scope,
|
|
678
|
+
id: options.id,
|
|
679
|
+
...(options.after ? { after: options.after } : {}),
|
|
680
|
+
};
|
|
681
|
+
data = await readArchive(client, operation, input);
|
|
682
|
+
} else if (command === 'projects documentation') {
|
|
683
|
+
data = await readProjectDocumentation(client, { scope: options.scope });
|
|
684
|
+
} else if (command === 'memory review') {
|
|
685
|
+
data = await reviewProjectMemory(client, await readCommandFile(options.file));
|
|
686
|
+
} else if (command === 'memory template') {
|
|
687
|
+
data = previewMemoryTemplate({
|
|
688
|
+
family: options.family,
|
|
689
|
+
language: options.language,
|
|
690
|
+
...(options.page ? { page: options.page } : {}),
|
|
691
|
+
});
|
|
692
|
+
} else if (command === 'memory history') {
|
|
693
|
+
data = await memoryHistoryRequest(client, 'history', {
|
|
694
|
+
scope: options.scope,
|
|
695
|
+
pageId: options.page,
|
|
696
|
+
...(options['before-revision'] ? { beforeRevision: options['before-revision'] } : {}),
|
|
697
|
+
});
|
|
698
|
+
} else if (command === 'memory diff') {
|
|
699
|
+
data = await memoryHistoryRequest(client, 'diff', {
|
|
700
|
+
scope: options.scope,
|
|
701
|
+
pageId: options.page,
|
|
702
|
+
fromRevision: options.from,
|
|
703
|
+
...(options.to ? { toRevision: options.to } : {}),
|
|
704
|
+
});
|
|
705
|
+
} else if (command === 'memory restore') {
|
|
706
|
+
data = await memoryHistoryRequest(client, 'restore', await readCommandFile(options.file));
|
|
707
|
+
} else if (command === 'memory read-pages') {
|
|
708
|
+
data = await readMemoryPages(client, await readCommandFile(options.file));
|
|
600
709
|
} else if (command === 'memory markdown') {
|
|
601
710
|
data = await readMemoryMarkdown(client, {
|
|
602
711
|
scope: options.scope,
|
package/src/client.mjs
CHANGED
|
@@ -180,6 +180,9 @@ export class AgentClient {
|
|
|
180
180
|
'me',
|
|
181
181
|
'capabilities',
|
|
182
182
|
'projects',
|
|
183
|
+
'project/documentation',
|
|
184
|
+
'tasks/archive/detail',
|
|
185
|
+
'tasks/archive/comments',
|
|
183
186
|
'memories',
|
|
184
187
|
'resources',
|
|
185
188
|
'profiles',
|
|
@@ -189,6 +192,9 @@ export class AgentClient {
|
|
|
189
192
|
'reference',
|
|
190
193
|
'memory/tree',
|
|
191
194
|
'memory/markdown',
|
|
195
|
+
'memory/sections',
|
|
196
|
+
'memory/history',
|
|
197
|
+
'memory/diff',
|
|
192
198
|
].includes(resource)
|
|
193
199
|
) {
|
|
194
200
|
fail('invalid_arguments', 'Unknown delegated resource.');
|
package/src/command-catalog.mjs
CHANGED
|
@@ -238,12 +238,6 @@ export default {
|
|
|
238
238
|
"module": "Memory/$",
|
|
239
239
|
"permission": "memory:write"
|
|
240
240
|
},
|
|
241
|
-
"memory.delete": {
|
|
242
|
-
"delete": true,
|
|
243
|
-
"fields": [],
|
|
244
|
-
"module": "Memory/$",
|
|
245
|
-
"permission": "memory:write"
|
|
246
|
-
},
|
|
247
241
|
"memory.edge.create": {
|
|
248
242
|
"create": true,
|
|
249
243
|
"fields": [
|
|
@@ -325,6 +319,7 @@ export default {
|
|
|
325
319
|
"memory.page.create": {
|
|
326
320
|
"create": true,
|
|
327
321
|
"fields": [
|
|
322
|
+
"changeReason",
|
|
328
323
|
"visibility",
|
|
329
324
|
"readRoles",
|
|
330
325
|
"title",
|
|
@@ -347,13 +342,24 @@ export default {
|
|
|
347
342
|
"permission": "memory:write"
|
|
348
343
|
},
|
|
349
344
|
"memory.page.delete": {
|
|
350
|
-
"
|
|
351
|
-
"fields": [
|
|
345
|
+
"action": "retireMemoryPage",
|
|
346
|
+
"fields": [
|
|
347
|
+
"changeReason"
|
|
348
|
+
],
|
|
349
|
+
"module": "Memory/MemoryPage",
|
|
350
|
+
"permission": "memory:write"
|
|
351
|
+
},
|
|
352
|
+
"memory.page.restore": {
|
|
353
|
+
"action": "restoreMemoryVersion",
|
|
354
|
+
"fields": [
|
|
355
|
+
"revision"
|
|
356
|
+
],
|
|
352
357
|
"module": "Memory/MemoryPage",
|
|
353
358
|
"permission": "memory:write"
|
|
354
359
|
},
|
|
355
360
|
"memory.page.update": {
|
|
356
361
|
"fields": [
|
|
362
|
+
"changeReason",
|
|
357
363
|
"visibility",
|
|
358
364
|
"readRoles",
|
|
359
365
|
"title",
|
|
@@ -482,6 +488,15 @@ export default {
|
|
|
482
488
|
"permission": "metrics:write",
|
|
483
489
|
"personalModule": "LocalUser/LocalUserMetricObservation"
|
|
484
490
|
},
|
|
491
|
+
"project.configureDocumentation": {
|
|
492
|
+
"action": "configureDocumentation",
|
|
493
|
+
"fields": [
|
|
494
|
+
"documentation"
|
|
495
|
+
],
|
|
496
|
+
"inputSchema": "GeniusTasker.Contracts.AgentDocumentationSettings",
|
|
497
|
+
"module": "Project/$",
|
|
498
|
+
"permission": "projects:write"
|
|
499
|
+
},
|
|
485
500
|
"project.configureInstructions": {
|
|
486
501
|
"action": "configureAgentInstructions",
|
|
487
502
|
"fields": [
|
|
@@ -502,12 +517,6 @@ export default {
|
|
|
502
517
|
"module": "Project/$",
|
|
503
518
|
"permission": "projects:write"
|
|
504
519
|
},
|
|
505
|
-
"project.delete": {
|
|
506
|
-
"delete": true,
|
|
507
|
-
"fields": [],
|
|
508
|
-
"module": "Project/$",
|
|
509
|
-
"permission": "projects:write"
|
|
510
|
-
},
|
|
511
520
|
"project.features": {
|
|
512
521
|
"action": "features",
|
|
513
522
|
"fields": [
|
|
@@ -858,6 +867,12 @@ export default {
|
|
|
858
867
|
"module": "Project/ProjectTask",
|
|
859
868
|
"permission": "tasks:write"
|
|
860
869
|
},
|
|
870
|
+
"task.delete": {
|
|
871
|
+
"delete": true,
|
|
872
|
+
"fields": [],
|
|
873
|
+
"module": "Project/ProjectTask",
|
|
874
|
+
"permission": "tasks:delete"
|
|
875
|
+
},
|
|
861
876
|
"task.lock": {
|
|
862
877
|
"action": "lockTask",
|
|
863
878
|
"fields": [
|
|
@@ -990,6 +1005,12 @@ export default {
|
|
|
990
1005
|
},
|
|
991
1006
|
"grants": {
|
|
992
1007
|
"permissions": [
|
|
1008
|
+
"tasks:delete",
|
|
1009
|
+
"storage:read",
|
|
1010
|
+
"attachments:add",
|
|
1011
|
+
"attachments:replace",
|
|
1012
|
+
"attachments:remove",
|
|
1013
|
+
"history:read",
|
|
993
1014
|
"projects:read",
|
|
994
1015
|
"projects:write",
|
|
995
1016
|
"tasks:read",
|
|
@@ -794,6 +794,108 @@ export default {
|
|
|
794
794
|
},
|
|
795
795
|
"additionalProperties": false
|
|
796
796
|
},
|
|
797
|
+
"project.configureDocumentation": {
|
|
798
|
+
"type": "object",
|
|
799
|
+
"required": [
|
|
800
|
+
"documentation"
|
|
801
|
+
],
|
|
802
|
+
"properties": {
|
|
803
|
+
"documentation": {
|
|
804
|
+
"type": "object",
|
|
805
|
+
"required": [
|
|
806
|
+
"autoDomains",
|
|
807
|
+
"folderId",
|
|
808
|
+
"guidance",
|
|
809
|
+
"language",
|
|
810
|
+
"memoryId",
|
|
811
|
+
"stylePageId",
|
|
812
|
+
"suggestionState"
|
|
813
|
+
],
|
|
814
|
+
"properties": {
|
|
815
|
+
"autoDomains": {
|
|
816
|
+
"type": "array",
|
|
817
|
+
"maxItems": 24,
|
|
818
|
+
"uniqueItems": true,
|
|
819
|
+
"items": {
|
|
820
|
+
"type": "string"
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
"folderId": {
|
|
824
|
+
"anyOf": [
|
|
825
|
+
{
|
|
826
|
+
"type": "string",
|
|
827
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"type": "null"
|
|
831
|
+
}
|
|
832
|
+
]
|
|
833
|
+
},
|
|
834
|
+
"guidance": {
|
|
835
|
+
"type": "string",
|
|
836
|
+
"maxLength": 4000
|
|
837
|
+
},
|
|
838
|
+
"language": {
|
|
839
|
+
"anyOf": [
|
|
840
|
+
{
|
|
841
|
+
"type": "string",
|
|
842
|
+
"maxLength": 64
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"type": "null"
|
|
846
|
+
}
|
|
847
|
+
]
|
|
848
|
+
},
|
|
849
|
+
"memoryId": {
|
|
850
|
+
"anyOf": [
|
|
851
|
+
{
|
|
852
|
+
"type": "string",
|
|
853
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
"type": "null"
|
|
857
|
+
}
|
|
858
|
+
]
|
|
859
|
+
},
|
|
860
|
+
"stylePageId": {
|
|
861
|
+
"anyOf": [
|
|
862
|
+
{
|
|
863
|
+
"type": "string",
|
|
864
|
+
"pattern": "^[a-zA-Z0-9_-]{1,128}$"
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
"type": "null"
|
|
868
|
+
}
|
|
869
|
+
]
|
|
870
|
+
},
|
|
871
|
+
"suggestionState": {
|
|
872
|
+
"oneOf": [
|
|
873
|
+
{
|
|
874
|
+
"type": "string",
|
|
875
|
+
"enum": [
|
|
876
|
+
"ask"
|
|
877
|
+
]
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
"type": "string",
|
|
881
|
+
"enum": [
|
|
882
|
+
"later"
|
|
883
|
+
]
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
"type": "string",
|
|
887
|
+
"enum": [
|
|
888
|
+
"dismissed"
|
|
889
|
+
]
|
|
890
|
+
}
|
|
891
|
+
]
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
"additionalProperties": false
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
"additionalProperties": false
|
|
898
|
+
},
|
|
797
899
|
"project.configureInstructions": {
|
|
798
900
|
"type": "object",
|
|
799
901
|
"required": [
|
|
@@ -3,7 +3,7 @@ import { posix } from 'node:path';
|
|
|
3
3
|
import { DocumentationStore, DocumentationDownloads, digest } from './documentation-store.mjs';
|
|
4
4
|
import { readMemoryTree, readMemoryMarkdown } from './documentation.mjs';
|
|
5
5
|
import { exportGraph } from './documentation-graph.mjs';
|
|
6
|
-
import { fail } from './errors.mjs';
|
|
6
|
+
import { AgentError, fail } from './errors.mjs';
|
|
7
7
|
|
|
8
8
|
const id = z.string().regex(/^[a-zA-Z0-9_-]{1,128}$/);
|
|
9
9
|
const sourceSchema = z
|
|
@@ -257,7 +257,8 @@ async function localAsset(client, store, source, tree, assetId, previous, downlo
|
|
|
257
257
|
export async function syncDocumentation(client, input) {
|
|
258
258
|
const options = parse(documentationSyncSchema, input);
|
|
259
259
|
const store = new DocumentationStore(options.directory, options);
|
|
260
|
-
|
|
260
|
+
let progress;
|
|
261
|
+
const sync = store.run(async () => {
|
|
261
262
|
const identity = await client.get('me'),
|
|
262
263
|
capabilities = await client.get('capabilities');
|
|
263
264
|
if (!capabilities.documentationSync) {
|
|
@@ -289,6 +290,7 @@ export async function syncDocumentation(client, input) {
|
|
|
289
290
|
fences = [],
|
|
290
291
|
stats = { pagesFetched: 0, pagesReused: 0, pagesResumed: 0, unavailable: [] };
|
|
291
292
|
for (const source of configuration.sources) {
|
|
293
|
+
progress = { scope: source.scope, phase: 'inventory', preparedPages: 0, selectedPages: null };
|
|
292
294
|
let previous = before?.sources.find((state) => state.scope === source.scope);
|
|
293
295
|
if (previous?.parentId !== (source.parentId ?? null)) {
|
|
294
296
|
previous = null;
|
|
@@ -315,6 +317,8 @@ export async function syncDocumentation(client, input) {
|
|
|
315
317
|
}
|
|
316
318
|
const pages = await collectPages(client, source, tree, previous),
|
|
317
319
|
paths = documentPaths(source, pages);
|
|
320
|
+
progress.selectedPages = Object.keys(pages).length;
|
|
321
|
+
progress.phase = 'pages';
|
|
318
322
|
await downloads.prepare(source.scope, pages, tree);
|
|
319
323
|
const state = {
|
|
320
324
|
scope: source.scope,
|
|
@@ -404,7 +408,9 @@ export async function syncDocumentation(client, input) {
|
|
|
404
408
|
assetIds: document.assetIds,
|
|
405
409
|
};
|
|
406
410
|
}
|
|
411
|
+
progress.preparedPages++;
|
|
407
412
|
}
|
|
413
|
+
progress.phase = 'resources';
|
|
408
414
|
await exportGraph(client, store, source, tree, previous, state, assets, downloads);
|
|
409
415
|
for (const asset of assets) {
|
|
410
416
|
await ensureAsset(asset);
|
|
@@ -439,6 +445,15 @@ export async function syncDocumentation(client, input) {
|
|
|
439
445
|
// Every participating scope must still match before publishing the new
|
|
440
446
|
// snapshot. An HTTP/ACL/network failure is never interpreted as an empty tree.
|
|
441
447
|
for (const { source, tree } of fences) {
|
|
448
|
+
const pages = Object.keys(
|
|
449
|
+
states.find((state) => state.scope === source.scope).documents,
|
|
450
|
+
).length;
|
|
451
|
+
progress = {
|
|
452
|
+
scope: source.scope,
|
|
453
|
+
phase: 'verification',
|
|
454
|
+
preparedPages: pages,
|
|
455
|
+
selectedPages: pages,
|
|
456
|
+
};
|
|
442
457
|
try {
|
|
443
458
|
const finalTree = await readMemoryTree(client, {
|
|
444
459
|
scope: source.scope,
|
|
@@ -489,6 +504,12 @@ export async function syncDocumentation(client, input) {
|
|
|
489
504
|
...stats,
|
|
490
505
|
};
|
|
491
506
|
});
|
|
507
|
+
return sync.catch((error) => {
|
|
508
|
+
if (progress && error instanceof AgentError && error.status === 429) {
|
|
509
|
+
error.details.progress = progress;
|
|
510
|
+
}
|
|
511
|
+
throw error;
|
|
512
|
+
});
|
|
492
513
|
}
|
|
493
514
|
|
|
494
515
|
export async function documentationStatus(input) {
|