maka-agent 0.2.0-dev.25.20260908 → 0.2.0-dev.27.20260910

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 (110) hide show
  1. package/dist/cli-core.js +21 -0
  2. package/dist/mcp-capability-provider.js +4 -1
  3. package/dist/pi-tui-mcp-status.js +2 -2
  4. package/dist/pi-tui-pickers.js +19 -29
  5. package/dist/runtime-host-cli.js +43 -3
  6. package/dist/runtime-host-handoff-surface.js +10 -8
  7. package/dist/runtime-host-lifecycle-transaction.js +28 -3
  8. package/dist/runtime-host-local-source-retirement.js +1 -1
  9. package/dist/runtime-host-setup-command.js +29 -6
  10. package/dist/runtime-host-update-command.js +49 -5
  11. package/dist/session-export-command.js +72 -0
  12. package/dist/tui-autocomplete-layout.js +3 -1
  13. package/dist/tui-copy-catalog.js +6 -3
  14. package/dist/tui-editor-render.js +36 -0
  15. package/dist/tui-mcp-control.js +41 -6
  16. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  17. package/node_modules/@maka/core/dist/runtime-event.js +3 -0
  18. package/node_modules/@maka/core/dist/session.js +29 -4
  19. package/node_modules/@maka/core/dist/usage-stats/types.js +2 -0
  20. package/node_modules/@maka/core/dist/workhub-action-result.js +68 -0
  21. package/node_modules/@maka/core/dist/workhub-routing.js +126 -0
  22. package/node_modules/@maka/core/package.json +3 -3
  23. package/node_modules/@maka/eval/dist/toolchain-verification.js +1 -1
  24. package/node_modules/@maka/mcp/dist/form-elicitation.js +213 -0
  25. package/node_modules/@maka/mcp/dist/index.js +337 -71
  26. package/node_modules/@maka/runtime/dist/agent-run.js +10 -1
  27. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +7 -3
  28. package/node_modules/@maka/runtime/dist/builtin-tools.js +21 -2
  29. package/node_modules/@maka/runtime/dist/goal-continuation.js +5 -1
  30. package/node_modules/@maka/runtime/dist/plugin-agent-service.js +131 -0
  31. package/node_modules/@maka/runtime/dist/plugin-approval-service.js +33 -0
  32. package/node_modules/@maka/runtime/dist/plugin-attachment-service.js +53 -0
  33. package/node_modules/@maka/runtime/dist/plugin-command-service.js +100 -0
  34. package/node_modules/@maka/runtime/dist/plugin-data-services.js +332 -0
  35. package/node_modules/@maka/runtime/dist/plugin-fs-service.js +62 -0
  36. package/node_modules/@maka/runtime/dist/plugin-goal-service.js +61 -0
  37. package/node_modules/@maka/runtime/dist/plugin-invocation-signal.js +24 -0
  38. package/node_modules/@maka/runtime/dist/plugin-llm-service.js +85 -0
  39. package/node_modules/@maka/runtime/dist/plugin-lsp-service.js +94 -0
  40. package/node_modules/@maka/runtime/dist/plugin-scope-registry.js +91 -0
  41. package/node_modules/@maka/runtime/dist/plugin-session-query-service.js +71 -0
  42. package/node_modules/@maka/runtime/dist/plugin-shell-env-service.js +87 -0
  43. package/node_modules/@maka/runtime/dist/plugin-shell-service.js +74 -0
  44. package/node_modules/@maka/runtime/dist/plugin-skill-service.js +93 -0
  45. package/node_modules/@maka/runtime/dist/plugin-system-prompt-service.js +346 -0
  46. package/node_modules/@maka/runtime/dist/plugin-tool-service.js +18 -52
  47. package/node_modules/@maka/runtime/dist/plugin-user-question-service.js +43 -0
  48. package/node_modules/@maka/runtime/dist/plugin-web-service.js +69 -0
  49. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +20 -1
  50. package/node_modules/@maka/runtime/dist/runtime-kernel.js +120 -13
  51. package/node_modules/@maka/runtime/dist/session-export.js +177 -0
  52. package/node_modules/@maka/runtime/dist/session-manager.js +20 -36
  53. package/node_modules/@maka/runtime/package.json +18 -0
  54. package/node_modules/@maka/runtime-host/dist/client/connection.js +30 -5
  55. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +83 -18
  56. package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +46 -12
  57. package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +4 -2
  58. package/node_modules/@maka/runtime-host/dist/client/peer-client.js +18 -1
  59. package/node_modules/@maka/runtime-host/dist/operator/setup-frame.js +31 -21
  60. package/node_modules/@maka/runtime-host/dist/protocol/index.js +13 -1
  61. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +3 -2
  62. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +30 -5
  63. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +1 -0
  64. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +90 -188
  65. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +4 -0
  66. package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +2 -1
  67. package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +62 -4
  68. package/node_modules/@maka/runtime-host/dist/server/connection-session.js +28 -8
  69. package/node_modules/@maka/runtime-host/dist/server/daily-review-coordinator.js +112 -56
  70. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +497 -27
  71. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +74 -0
  72. package/node_modules/@maka/runtime-host/dist/server/failure-diagnostic.js +24 -0
  73. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +7 -3
  74. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +3 -3
  75. package/node_modules/@maka/runtime-host/dist/server/host-session-availability.js +5 -2
  76. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +4 -3
  77. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +64 -4
  78. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +83 -17
  79. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +25 -4
  80. package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +2 -7
  81. package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +234 -0
  82. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
  83. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +12 -0
  84. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +289 -96
  85. package/node_modules/@maka/runtime-host/dist/server/runtime-resource-coordinator.js +11 -8
  86. package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +31 -21
  87. package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +1 -1
  88. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +20 -8
  89. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +15 -104
  90. package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +3 -0
  91. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +85 -117
  92. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +201 -136
  93. package/node_modules/@maka/storage/dist/agent-run-store.js +60 -3
  94. package/node_modules/@maka/storage/dist/artifact-store.js +40 -3
  95. package/node_modules/@maka/storage/dist/atomic-file-write.js +74 -0
  96. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +13 -6
  97. package/node_modules/@maka/storage/dist/credential-store.js +12 -63
  98. package/node_modules/@maka/storage/dist/execution-stores.js +5 -2
  99. package/node_modules/@maka/storage/dist/mcp-config-store.js +10 -25
  100. package/node_modules/@maka/storage/dist/session-bundle-policy.js +333 -30
  101. package/node_modules/@maka/storage/dist/session-store.js +16 -4
  102. package/node_modules/@maka/storage/dist/settings-store.js +8 -4
  103. package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +11 -0
  104. package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +12 -1
  105. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +79 -8
  106. package/node_modules/@maka/storage/dist/stable-storage.js +14 -1
  107. package/node_modules/@maka/storage/package.json +2 -0
  108. package/package.json +1 -1
  109. package/node_modules/@maka/core/dist/workhub-creation-intent.js +0 -990
  110. package/node_modules/@maka/core/dist/workhub-session-resolver.js +0 -50
@@ -730,10 +730,12 @@ export class SqliteSessionMetadataStore {
730
730
  throw new SessionNotFoundError(sessionId);
731
731
  return record;
732
732
  }
733
- async readCatalogRecord(sessionId) {
733
+ async readCatalogRecord(sessionId, roleScope = 'ordinary') {
734
734
  this.assertOpen();
735
735
  assertSafeSessionId(sessionId);
736
- const role = sqliteOrdinarySessionRolePredicate();
736
+ const role = roleScope === 'recoverable'
737
+ ? sqliteRecoverableSessionRolePredicate()
738
+ : sqliteOrdinarySessionRolePredicate();
737
739
  const row = this.db
738
740
  .prepare(`
739
741
  SELECT
@@ -1206,7 +1208,11 @@ export class SqliteSessionMetadataStore {
1206
1208
  assignment.id !== `wha_${suffix}` ||
1207
1209
  assignment.targetMessageId !== `whm_${suffix}` ||
1208
1210
  assignment.delegationId !== `whd_${suffix}` ||
1209
- !messageContentsEqual(admission.content, normalizeMessageContent({ text: assignment.userText })) ||
1211
+ !workHubAssignmentAttachmentsMatchTarget(assignment) ||
1212
+ !messageContentsEqual(admission.content, normalizeMessageContent({
1213
+ text: assignment.delegationText ?? assignment.userText,
1214
+ ...(assignment.targetAttachments ? { attachments: assignment.targetAttachments } : {}),
1215
+ })) ||
1210
1216
  admission.submittedContentDigest !== messageContentDigest(admission.content) ||
1211
1217
  admission.submittedPlacement !== 'current_turn' ||
1212
1218
  admission.placement !== 'current_turn' ||
@@ -1793,7 +1799,7 @@ export class SqliteSessionMetadataStore {
1793
1799
  }
1794
1800
  });
1795
1801
  }
1796
- async reorderMessageAdmissions(sessionId, messageIds) {
1802
+ async reorderMessageAdmissions(sessionId, messageIds, disposition = 'followup') {
1797
1803
  this.assertOpen();
1798
1804
  assertSafeSessionId(sessionId);
1799
1805
  const unique = [...new Set(messageIds)];
@@ -1807,13 +1813,13 @@ export class SqliteSessionMetadataStore {
1807
1813
  .prepare(`
1808
1814
  SELECT message_id
1809
1815
  FROM message_admissions
1810
- WHERE session_id = ? AND disposition = 'followup'
1816
+ WHERE session_id = ? AND disposition = ?
1811
1817
  ORDER BY queue_order, sequence
1812
1818
  `)
1813
- .all(sessionId);
1819
+ .all(sessionId, disposition);
1814
1820
  const current = rows.map((row) => row.message_id);
1815
1821
  const currentIds = new Set(current);
1816
- if (current.length !== unique.length ||
1822
+ if ((disposition === 'followup' && current.length !== unique.length) ||
1817
1823
  unique.some((messageId) => !currentIds.has(messageId))) {
1818
1824
  throw new SessionMetadataConflictError('Message admission reorder identity conflict');
1819
1825
  }
@@ -1822,9 +1828,55 @@ export class SqliteSessionMetadataStore {
1822
1828
  SET queue_order = ?
1823
1829
  WHERE session_id = ? AND message_id = ?
1824
1830
  `);
1825
- unique.forEach((messageId, index) => update.run(index, sessionId, messageId));
1831
+ // Older steering may already be in flight. Keep those entries in their
1832
+ // slots so recovery never interleaves them with a newly reordered batch.
1833
+ const selected = new Set(unique);
1834
+ let next = 0;
1835
+ current.forEach((messageId, index) => {
1836
+ const orderedId = selected.has(messageId) ? unique[next++] : messageId;
1837
+ update.run(index, sessionId, orderedId);
1838
+ });
1839
+ });
1840
+ }
1841
+ async readCoordinationTranscriptIndexState() {
1842
+ this.assertOpen();
1843
+ return this.db
1844
+ .prepare(`SELECT (SELECT MAX(sequence) FROM coordination_transcript_index) AS highWater,
1845
+ (SELECT MAX(source_sequence) FROM coordination_transcript_index WHERE source = 'legacy') AS legacy,
1846
+ (SELECT MAX(source_sequence) FROM coordination_transcript_index WHERE source = 'runtime') AS runtime`)
1847
+ .get();
1848
+ }
1849
+ async appendCoordinationTranscriptIndex(records) {
1850
+ this.assertOpen();
1851
+ if (records.length > 64)
1852
+ throw new Error('Coordination transcript index batch exceeds limit');
1853
+ this.transaction(() => {
1854
+ let sequence = this.db
1855
+ .prepare('SELECT MAX(sequence) AS value FROM coordination_transcript_index')
1856
+ .get().value ?? -1;
1857
+ const insert = this.db.prepare(`INSERT INTO coordination_transcript_index
1858
+ (sequence, source, source_sequence) VALUES (?, ?, ?)
1859
+ ON CONFLICT(source, source_sequence) DO NOTHING`);
1860
+ for (const record of records) {
1861
+ if (!Number.isSafeInteger(record.sourceSequence) || record.sourceSequence < 0)
1862
+ throw new Error('Invalid Coordination source sequence');
1863
+ const result = insert.run(sequence + 1, record.source, record.sourceSequence);
1864
+ if (result.changes)
1865
+ sequence++;
1866
+ }
1826
1867
  });
1827
1868
  }
1869
+ async readCoordinationTranscriptIndex(request) {
1870
+ this.assertOpen();
1871
+ if (!Number.isSafeInteger(request.limit) || request.limit < 1 || request.limit > 64)
1872
+ throw new Error('Invalid Coordination transcript index limit');
1873
+ const older = request.direction === 'older';
1874
+ return this.db
1875
+ .prepare(`SELECT sequence, source, source_sequence AS sourceSequence
1876
+ FROM coordination_transcript_index WHERE sequence <= ? AND sequence ${older ? '<=' : '>='} ?
1877
+ ORDER BY sequence ${older ? 'DESC' : 'ASC'} LIMIT ?`)
1878
+ .all(request.throughSequence, request.position, request.limit);
1879
+ }
1828
1880
  async readMessages(sessionId) {
1829
1881
  return this.readMessagesWith(sessionId, decodeStoredMessage);
1830
1882
  }
@@ -4566,6 +4618,21 @@ function isWorkHubActionOperation(value) {
4566
4618
  value === 'replace' ||
4567
4619
  value === 'stop');
4568
4620
  }
4621
+ function workHubAssignmentAttachmentsMatchTarget(assignment) {
4622
+ const source = assignment.attachments ?? [];
4623
+ const target = assignment.targetAttachments ?? [];
4624
+ return (source.length === target.length &&
4625
+ source.every((attachment, index) => {
4626
+ const copied = target[index];
4627
+ const { ref: sourceRef, ...sourceMetadata } = attachment;
4628
+ const { ref: targetRef, ...targetMetadata } = copied;
4629
+ return (sourceRef.kind === 'session_file' &&
4630
+ sourceRef.sessionId === WORKHUB_COORDINATION_SESSION_ID &&
4631
+ targetRef.kind === 'session_file' &&
4632
+ targetRef.sessionId === assignment.targetSessionId &&
4633
+ isDeepStrictEqual(sourceMetadata, targetMetadata));
4634
+ }));
4635
+ }
4569
4636
  function sameWorkHubAssignmentRequest(existing, requested) {
4570
4637
  return isDeepStrictEqual({
4571
4638
  actionId: existing.actionId,
@@ -4574,6 +4641,8 @@ function sameWorkHubAssignmentRequest(existing, requested) {
4574
4641
  targetSessionId: existing.targetSessionId,
4575
4642
  disposition: existing.disposition,
4576
4643
  userText: existing.userText,
4644
+ delegationText: existing.delegationText,
4645
+ attachments: existing.attachments,
4577
4646
  create: existing.create,
4578
4647
  replacesActionId: existing.replacesActionId,
4579
4648
  replacesDelegationId: existing.replacesDelegationId,
@@ -4584,6 +4653,8 @@ function sameWorkHubAssignmentRequest(existing, requested) {
4584
4653
  targetSessionId: requested.targetSessionId,
4585
4654
  disposition: requested.disposition,
4586
4655
  userText: requested.userText,
4656
+ delegationText: requested.delegationText,
4657
+ attachments: requested.attachments,
4587
4658
  create: requested.create,
4588
4659
  replacesActionId: requested.replacesActionId,
4589
4660
  replacesDelegationId: requested.replacesDelegationId,
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { constants } from 'node:fs';
20
- import { lstat, open } from 'node:fs/promises';
20
+ import { chmod, lstat, mkdir, open } from 'node:fs/promises';
21
21
  import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
22
22
  const openStableFile = open;
23
23
  const lstatStableFile = lstat;
@@ -74,6 +74,19 @@ export async function syncFile(path) {
74
74
  await handle.close();
75
75
  }
76
76
  }
77
+ /**
78
+ * Create (or harden) an owner-only directory: recursive mkdir plus a
79
+ * fail-closed chmod, since mkdir's mode only applies on creation. Callers that
80
+ * store secrets use this before creating their file or update lock.
81
+ */
82
+ export async function hardenDirectory(dir, mode = 0o700) {
83
+ await mkdir(dir, { recursive: true, mode });
84
+ if (process.platform === 'win32') {
85
+ await chmod(dir, mode).catch(() => { });
86
+ return;
87
+ }
88
+ await chmod(dir, mode);
89
+ }
77
90
  export async function syncDirectoryChain(path, root, beforeSync) {
78
91
  const boundary = resolve(root);
79
92
  let current = resolve(path);
@@ -43,6 +43,8 @@
43
43
  "./scheduled-task-store": "./dist/scheduled-task-store.js",
44
44
  "./quiescent-session-snapshot": "./dist/quiescent-session-snapshot.js",
45
45
  "./production-session-snapshot": "./dist/production-session-snapshot.js",
46
+ "./session-bundle-contract": "./dist/session-bundle-contract.js",
47
+ "./session-bundle-file-service": "./dist/session-bundle-file-service.js",
46
48
  "./session-bundle-policy": "./dist/session-bundle-policy.js",
47
49
  "./session-copy-cleanup": "./dist/session-copy-cleanup.js",
48
50
  "./session-todo-authority": "./dist/session-todo-authority.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maka-agent",
3
- "version": "0.2.0-dev.25.20260908",
3
+ "version": "0.2.0-dev.27.20260910",
4
4
  "description": "Apache Maka (Incubating) developer snapshot; not an Apache release.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",