@pulsarinteractive/geniustasker 0.1.0-beta.16 → 0.1.0-beta.18

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/src/cli.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { withFeedbackDiscovery } from './presentation.mjs';
1
2
  import {
2
3
  readFeedbackCapabilities,
3
4
  readFeedbackPage,
@@ -11,6 +12,14 @@ import {
11
12
  uploadFeedbackImage,
12
13
  downloadFeedbackImage,
13
14
  } from './feedback-media-transfer.mjs';
15
+ import { readArchive } from './archive.mjs';
16
+ import {
17
+ readProjectDocumentation,
18
+ reviewProjectMemory,
19
+ previewMemoryTemplate,
20
+ } from './memory-editorial.mjs';
21
+ import { memoryHistoryRequest } from './memory-history.mjs';
22
+ import { readMemoryPages } from './memory-read-pages.mjs';
14
23
  import { workflow, workflowTopics } from './workflows.mjs';
15
24
  import { readFile } from 'node:fs/promises';
16
25
  import {
@@ -180,6 +189,43 @@ export const commands = {
180
189
  summary: 'Read one folder and descendant versions; unchanged validators avoid page bodies.',
181
190
  options: ['scope', 'parent', 'after', 'epoch', 'checkpoint', 'if-none-match'],
182
191
  },
192
+ 'archive query': {
193
+ summary: 'Search one project archive with bounded filters from a JSON file.',
194
+ options: ['file'],
195
+ },
196
+ 'archive detail': {
197
+ summary: 'Read one archived task with historical access.',
198
+ options: ['scope', 'id'],
199
+ },
200
+ 'archive comments': {
201
+ summary: 'Read one page of comments for the selected archived task.',
202
+ options: ['scope', 'id', 'after'],
203
+ },
204
+ 'memory review': {
205
+ summary: 'Evaluate verified evidence against the live documentation policy. Reads only.',
206
+ options: ['file'],
207
+ },
208
+ 'memory template': {
209
+ summary: 'List optional pages in a family or preview one selected page.',
210
+ options: ['family', 'page', 'language'],
211
+ },
212
+ 'memory history': {
213
+ summary: 'Read a page of retained revision metadata for an authorized note.',
214
+ options: ['scope', 'page', 'before-revision'],
215
+ },
216
+ 'memory diff': {
217
+ summary: 'Compare changed fields and block excerpts between retained revisions.',
218
+ options: ['scope', 'page', 'from', 'to'],
219
+ },
220
+ 'memory restore': {
221
+ summary: 'Restore a confirmed note revision using an immutable JSON request.',
222
+ options: ['file'],
223
+ },
224
+ 'memory read-pages': {
225
+ summary:
226
+ 'Read one bounded batch of selected page outlines or blocks. The JSON file contains scope, pages and optional snapshot.',
227
+ options: ['file'],
228
+ },
183
229
  'memory markdown': {
184
230
  summary: 'Fetch one portable Markdown document with stable media IDs and source metadata.',
185
231
  options: ['scope', 'page', 'revision', 'epoch', 'checkpoint'],
@@ -197,6 +243,10 @@ export const commands = {
197
243
  'Resolve a Memory page or block with current permissions; unavailable links preserve nodes.',
198
244
  options: ['scope', 'page', 'block'],
199
245
  },
246
+ 'projects documentation': {
247
+ summary: 'Read the current editorial policy and its authorized target.',
248
+ options: ['scope'],
249
+ },
200
250
  'projects list': {
201
251
  summary: 'Read a bounded project page; follow nextAfter even for an empty page.',
202
252
  options: ['after'],
@@ -543,7 +593,7 @@ export async function main(
543
593
  } else if (command === 'whoami' || command === 'auth status') {
544
594
  data = await client.get('me');
545
595
  } else if (command === 'capabilities') {
546
- data = await client.get('capabilities');
596
+ data = withFeedbackDiscovery(await client.get('capabilities'));
547
597
  } else if (command === 'projects list' || command === 'memories list') {
548
598
  data = await client.get(command === 'projects list' ? 'projects' : 'memories', {
549
599
  after: options.after,
@@ -596,6 +646,44 @@ export async function main(
596
646
  checkpoint: options.checkpoint,
597
647
  ifNoneMatch: options['if-none-match'],
598
648
  });
649
+ } else if (command.startsWith('archive ')) {
650
+ const operation = command.split(' ')[1];
651
+ const input =
652
+ operation === 'query'
653
+ ? await readCommandFile(options.file)
654
+ : {
655
+ scope: options.scope,
656
+ id: options.id,
657
+ ...(options.after ? { after: options.after } : {}),
658
+ };
659
+ data = await readArchive(client, operation, input);
660
+ } else if (command === 'projects documentation') {
661
+ data = await readProjectDocumentation(client, { scope: options.scope });
662
+ } else if (command === 'memory review') {
663
+ data = await reviewProjectMemory(client, await readCommandFile(options.file));
664
+ } else if (command === 'memory template') {
665
+ data = previewMemoryTemplate({
666
+ family: options.family,
667
+ language: options.language,
668
+ ...(options.page ? { page: options.page } : {}),
669
+ });
670
+ } else if (command === 'memory history') {
671
+ data = await memoryHistoryRequest(client, 'history', {
672
+ scope: options.scope,
673
+ pageId: options.page,
674
+ ...(options['before-revision'] ? { beforeRevision: options['before-revision'] } : {}),
675
+ });
676
+ } else if (command === 'memory diff') {
677
+ data = await memoryHistoryRequest(client, 'diff', {
678
+ scope: options.scope,
679
+ pageId: options.page,
680
+ fromRevision: options.from,
681
+ ...(options.to ? { toRevision: options.to } : {}),
682
+ });
683
+ } else if (command === 'memory restore') {
684
+ data = await memoryHistoryRequest(client, 'restore', await readCommandFile(options.file));
685
+ } else if (command === 'memory read-pages') {
686
+ data = await readMemoryPages(client, await readCommandFile(options.file));
599
687
  } else if (command === 'memory markdown') {
600
688
  data = await readMemoryMarkdown(client, {
601
689
  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.');
@@ -36,7 +36,8 @@ export default {
36
36
  "create": true,
37
37
  "fields": [
38
38
  "task",
39
- "title"
39
+ "title",
40
+ "sectionId"
40
41
  ],
41
42
  "inputSchema": "GeniusTasker.Checklists.Create",
42
43
  "module": "Project/ProjectTaskChecklistItem",
@@ -324,6 +325,7 @@ export default {
324
325
  "memory.page.create": {
325
326
  "create": true,
326
327
  "fields": [
328
+ "changeReason",
327
329
  "visibility",
328
330
  "readRoles",
329
331
  "title",
@@ -351,8 +353,17 @@ export default {
351
353
  "module": "Memory/MemoryPage",
352
354
  "permission": "memory:write"
353
355
  },
356
+ "memory.page.restore": {
357
+ "action": "restoreMemoryVersion",
358
+ "fields": [
359
+ "revision"
360
+ ],
361
+ "module": "Memory/MemoryPage",
362
+ "permission": "memory:write"
363
+ },
354
364
  "memory.page.update": {
355
365
  "fields": [
366
+ "changeReason",
356
367
  "visibility",
357
368
  "readRoles",
358
369
  "title",
@@ -481,6 +492,15 @@ export default {
481
492
  "permission": "metrics:write",
482
493
  "personalModule": "LocalUser/LocalUserMetricObservation"
483
494
  },
495
+ "project.configureDocumentation": {
496
+ "action": "configureDocumentation",
497
+ "fields": [
498
+ "documentation"
499
+ ],
500
+ "inputSchema": "GeniusTasker.Contracts.AgentDocumentationSettings",
501
+ "module": "Project/$",
502
+ "permission": "projects:write"
503
+ },
484
504
  "project.configureInstructions": {
485
505
  "action": "configureAgentInstructions",
486
506
  "fields": [
@@ -838,6 +858,7 @@ export default {
838
858
  "description",
839
859
  "importance",
840
860
  "importanceReason",
861
+ "completionDelivery",
841
862
  "type",
842
863
  "owner",
843
864
  "status",
@@ -911,6 +932,7 @@ export default {
911
932
  "description",
912
933
  "importance",
913
934
  "importanceReason",
935
+ "completionDelivery",
914
936
  "type",
915
937
  "owner",
916
938
  "status",
@@ -987,6 +1009,7 @@ export default {
987
1009
  },
988
1010
  "grants": {
989
1011
  "permissions": [
1012
+ "history:read",
990
1013
  "projects:read",
991
1014
  "projects:write",
992
1015
  "tasks:read",
@@ -16,6 +16,17 @@ export default {
16
16
  "type": "string",
17
17
  "minLength": 1,
18
18
  "maxLength": 240
19
+ },
20
+ "sectionId": {
21
+ "anyOf": [
22
+ {
23
+ "type": "string",
24
+ "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
25
+ },
26
+ {
27
+ "type": "null"
28
+ }
29
+ ]
19
30
  }
20
31
  },
21
32
  "additionalProperties": false
@@ -783,6 +794,108 @@ export default {
783
794
  },
784
795
  "additionalProperties": false
785
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
+ },
786
899
  "project.configureInstructions": {
787
900
  "type": "object",
788
901
  "required": [
@@ -913,8 +1026,31 @@ export default {
913
1026
  "request"
914
1027
  ]
915
1028
  },
1029
+ "reason": {
1030
+ "anyOf": [
1031
+ {
1032
+ "type": "string",
1033
+ "maxLength": 240
1034
+ },
1035
+ {
1036
+ "type": "null"
1037
+ }
1038
+ ]
1039
+ },
916
1040
  "recap": {
917
1041
  "type": "boolean"
1042
+ },
1043
+ "score": {
1044
+ "anyOf": [
1045
+ {
1046
+ "type": "integer",
1047
+ "minimum": 0,
1048
+ "maximum": 100
1049
+ },
1050
+ {
1051
+ "type": "null"
1052
+ }
1053
+ ]
918
1054
  }
919
1055
  },
920
1056
  "additionalProperties": false
@@ -1166,6 +1302,17 @@ export default {
1166
1302
  "createChecklistItem"
1167
1303
  ]
1168
1304
  },
1305
+ "sectionId": {
1306
+ "anyOf": [
1307
+ {
1308
+ "type": "string",
1309
+ "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
1310
+ },
1311
+ {
1312
+ "type": "null"
1313
+ }
1314
+ ]
1315
+ },
1169
1316
  "task": {
1170
1317
  "type": "string",
1171
1318
  "minLength": 1,
@@ -1551,6 +1698,59 @@ export default {
1551
1698
  }
1552
1699
  ]
1553
1700
  },
1701
+ "completionDelivery": {
1702
+ "type": "object",
1703
+ "required": [
1704
+ "animation",
1705
+ "push",
1706
+ "recap"
1707
+ ],
1708
+ "properties": {
1709
+ "animation": {
1710
+ "type": "string",
1711
+ "enum": [
1712
+ "inherit",
1713
+ "silent",
1714
+ "request"
1715
+ ]
1716
+ },
1717
+ "push": {
1718
+ "type": "string",
1719
+ "enum": [
1720
+ "inherit",
1721
+ "silent",
1722
+ "request"
1723
+ ]
1724
+ },
1725
+ "reason": {
1726
+ "anyOf": [
1727
+ {
1728
+ "type": "string",
1729
+ "maxLength": 240
1730
+ },
1731
+ {
1732
+ "type": "null"
1733
+ }
1734
+ ]
1735
+ },
1736
+ "recap": {
1737
+ "type": "boolean"
1738
+ },
1739
+ "score": {
1740
+ "anyOf": [
1741
+ {
1742
+ "type": "integer",
1743
+ "minimum": 0,
1744
+ "maximum": 100
1745
+ },
1746
+ {
1747
+ "type": "null"
1748
+ }
1749
+ ]
1750
+ }
1751
+ },
1752
+ "additionalProperties": false
1753
+ },
1554
1754
  "type": {
1555
1755
  "anyOf": [
1556
1756
  {
@@ -1795,6 +1995,59 @@ export default {
1795
1995
  }
1796
1996
  ]
1797
1997
  },
1998
+ "completionDelivery": {
1999
+ "type": "object",
2000
+ "required": [
2001
+ "animation",
2002
+ "push",
2003
+ "recap"
2004
+ ],
2005
+ "properties": {
2006
+ "animation": {
2007
+ "type": "string",
2008
+ "enum": [
2009
+ "inherit",
2010
+ "silent",
2011
+ "request"
2012
+ ]
2013
+ },
2014
+ "push": {
2015
+ "type": "string",
2016
+ "enum": [
2017
+ "inherit",
2018
+ "silent",
2019
+ "request"
2020
+ ]
2021
+ },
2022
+ "reason": {
2023
+ "anyOf": [
2024
+ {
2025
+ "type": "string",
2026
+ "maxLength": 240
2027
+ },
2028
+ {
2029
+ "type": "null"
2030
+ }
2031
+ ]
2032
+ },
2033
+ "recap": {
2034
+ "type": "boolean"
2035
+ },
2036
+ "score": {
2037
+ "anyOf": [
2038
+ {
2039
+ "type": "integer",
2040
+ "minimum": 0,
2041
+ "maximum": 100
2042
+ },
2043
+ {
2044
+ "type": "null"
2045
+ }
2046
+ ]
2047
+ }
2048
+ },
2049
+ "additionalProperties": false
2050
+ },
1798
2051
  "type": {
1799
2052
  "anyOf": [
1800
2053
  {
package/src/commands.mjs CHANGED
@@ -302,7 +302,17 @@ export class CommandJournal {
302
302
  const value = checked(feedbackDraftSchema, draft);
303
303
  const identity = binding(await this.client.session());
304
304
  if (!value.expectedEpoch) {
305
- value.expectedEpoch = (await readFeedbackCapabilities(this.client)).epoch;
305
+ const capabilities = await readFeedbackCapabilities(this.client);
306
+ if (!capabilities.canReportBug) {
307
+ fail('agent_permission_denied', 'Feedback needs a personal feedback:write grant.');
308
+ }
309
+ if (value.type === 'FeatureRequest' && !capabilities.canRequestFeature) {
310
+ fail(
311
+ 'feedback_premium_required',
312
+ 'This account can report bugs. Feature requests require a paid plan.',
313
+ );
314
+ }
315
+ value.expectedEpoch = capabilities.epoch;
306
316
  }
307
317
  if (canonical(binding(await this.client.session())) !== canonical(identity)) {
308
318
  fail('operation_identity_mismatch', 'The connection changed while preparing feedback.');
@@ -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
- return store.run(async () => {
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) {