maka-agent 0.2.0-dev.8.20260830 → 0.2.0-dev.9.20260831

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 (63) hide show
  1. package/dist/cli-core.js +11 -0
  2. package/dist/runtime-host-cli.js +44 -0
  3. package/dist/runtime-host-installed-update-activator.js +70 -33
  4. package/dist/runtime-host-installed-update-coordinator.js +11 -96
  5. package/dist/runtime-host-lifecycle-transaction.js +2 -0
  6. package/dist/runtime-host-local-handoff.js +169 -38
  7. package/dist/runtime-host-local-source-retirement.js +103 -0
  8. package/dist/runtime-host-local-target-activation.js +141 -0
  9. package/dist/runtime-host-peer-management-command.js +10 -4
  10. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  11. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  12. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  13. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  14. package/node_modules/@maka/core/dist/artifacts.js +23 -15
  15. package/node_modules/@maka/core/dist/durable-tool-result-projection.js +124 -0
  16. package/node_modules/@maka/core/dist/llm-connections.js +20 -0
  17. package/node_modules/@maka/core/dist/runtime-event.js +28 -3
  18. package/node_modules/@maka/core/dist/session-name.js +0 -1
  19. package/node_modules/@maka/core/package.json +1 -0
  20. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +95 -19
  21. package/node_modules/@maka/runtime/dist/conversation-copy.js +67 -0
  22. package/node_modules/@maka/runtime/dist/durable-tool-result-projection.js +390 -0
  23. package/node_modules/@maka/runtime/dist/model-history.js +12 -39
  24. package/node_modules/@maka/runtime/dist/recovery-resolver.js +18 -14
  25. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +20 -11
  26. package/node_modules/@maka/runtime/dist/session-manager.js +0 -170
  27. package/node_modules/@maka/runtime/dist/tool-runtime.js +118 -71
  28. package/node_modules/@maka/runtime/package.json +1 -0
  29. package/node_modules/@maka/runtime-host/dist/candidate-entry.js +6 -1
  30. package/node_modules/@maka/runtime-host/dist/candidate-launch-owner-guard.js +13 -0
  31. package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +4 -1
  32. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +27 -1
  33. package/node_modules/@maka/runtime-host/dist/client/index.js +1 -1
  34. package/node_modules/@maka/runtime-host/dist/client/launcher.js +8 -2
  35. package/node_modules/@maka/runtime-host/dist/client/peer-client.js +11 -1
  36. package/node_modules/@maka/runtime-host/dist/peer-mesh/index.js +1 -1
  37. package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +394 -113
  38. package/node_modules/@maka/runtime-host/dist/peer-mesh/store.js +90 -21
  39. package/node_modules/@maka/runtime-host/dist/protocol/index.js +8 -1
  40. package/node_modules/@maka/runtime-host/dist/protocol/oauth.js +60 -7
  41. package/node_modules/@maka/runtime-host/dist/protocol/usage-pricing.js +4 -0
  42. package/node_modules/@maka/runtime-host/dist/server/artifact-coordinator.js +2 -4
  43. package/node_modules/@maka/runtime-host/dist/server/candidate.js +3 -0
  44. package/node_modules/@maka/runtime-host/dist/server/client-capability-recovery.js +10 -7
  45. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +5 -1
  46. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +9 -1
  47. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +10 -0
  48. package/node_modules/@maka/runtime-host/dist/server/oauth-coordinator.js +91 -42
  49. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +10 -1
  50. package/node_modules/@maka/runtime-host/dist/server/usage-pricing-coordinator.js +45 -5
  51. package/node_modules/@maka/storage/dist/artifact-attachments.js +62 -11
  52. package/node_modules/@maka/storage/dist/artifact-store.js +11 -0
  53. package/node_modules/@maka/storage/dist/artifact-stores.js +4 -1
  54. package/node_modules/@maka/storage/dist/quiescent-session-snapshot.js +1154 -0
  55. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +36 -0
  56. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +213 -46
  57. package/node_modules/@maka/storage/dist/runtime-policy/document-io.js +1 -1
  58. package/node_modules/@maka/storage/dist/runtime-policy/oauth-login-receipt-document.js +186 -0
  59. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +120 -1
  60. package/node_modules/@maka/storage/dist/runtime-policy-stores.js +2 -1
  61. package/node_modules/@maka/storage/dist/session-bundle-ustar.js +12 -0
  62. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +5 -0
  63. package/package.json +1 -1
@@ -267,7 +267,10 @@ export async function connectOrSpawnRuntimeHostWithDependencies(input, dependenc
267
267
  ...(input.onExit === undefined ? {} : { onExit: input.onExit }),
268
268
  ...(input.inheritableAuthorityLeaseFd === undefined
269
269
  ? {}
270
- : { inheritableAuthorityLeaseFd: input.inheritableAuthorityLeaseFd }),
270
+ : {
271
+ inheritableAuthorityLeaseFd: input.inheritableAuthorityLeaseFd,
272
+ launchOwnerClientInstanceId: clientInstanceId,
273
+ }),
271
274
  ...(input.closeOnLauncherExit === undefined
272
275
  ? {}
273
276
  : { closeOnLauncherExit: input.closeOnLauncherExit }),
@@ -130,9 +130,13 @@ export async function connectRemoteRuntimeHostProfile(input, overrides = {}) {
130
130
  ...(input.handshakeTimeoutMs === undefined
131
131
  ? {}
132
132
  : { handshakeTimeoutMs: input.handshakeTimeoutMs }),
133
+ ...(input.onConnectionPhase === undefined
134
+ ? {}
135
+ : { onConnectionPhase: input.onConnectionPhase }),
133
136
  });
134
137
  }
135
138
  else {
139
+ notifyConnectionPhase(input.onConnectionPhase, 'connecting');
136
140
  const activation = transport.kind === 'ssh' && transport.activation
137
141
  ? await (overrides.activateSshOperator ?? activateRuntimeHostSshOperator)({
138
142
  destination: transport.destination,
@@ -195,6 +199,7 @@ export async function connectRemoteRuntimeHostProfile(input, overrides = {}) {
195
199
  }
196
200
  try {
197
201
  input.signal?.throwIfAborted();
202
+ notifyConnectionPhase(input.onConnectionPhase, 'waiting_for_ready');
198
203
  await (overrides.waitForReady ?? waitForRuntimeHostReady)(connection, input.readyTimeoutMs ?? 45_000, input.signal);
199
204
  return connection;
200
205
  }
@@ -216,7 +221,7 @@ export async function connectPeerRuntimeHost(input) {
216
221
  routeHints: input.transport.routeHints,
217
222
  coordinationRelays: input.transport.coordinationRelays,
218
223
  directDeadlineMs: Math.min(input.connectTimeoutMs ?? 40_000, 120_000),
219
- }, input.signal);
224
+ }, input.signal, input.onConnectionPhase);
220
225
  const abort = () => stream.abort();
221
226
  input.signal?.addEventListener('abort', abort, { once: true });
222
227
  if (input.signal?.aborted)
@@ -224,11 +229,13 @@ export async function connectPeerRuntimeHost(input) {
224
229
  let transferred = false;
225
230
  try {
226
231
  input.signal?.throwIfAborted();
232
+ notifyConnectionPhase(input.onConnectionPhase, 'authenticating');
227
233
  await writeRuntimeHostPeerAuthentication(stream, input.credential);
228
234
  const authentication = await readRuntimeHostPeerAuthenticationResult(stream, input.handshakeTimeoutMs);
229
235
  if (!authentication.accepted) {
230
236
  throw new RuntimeHostPermanentReconnectError(`Runtime Host profile ${input.profileId} rejected its access credential`);
231
237
  }
238
+ notifyConnectionPhase(input.onConnectionPhase, 'handshaking');
232
239
  const result = await connectRuntimeHostMessageTransport({
233
240
  transport: new FramedByteStreamTransport(new RuntimeHostPeerByteStream(stream, authentication.remainder)),
234
241
  expectedRootId: input.expectedRootId,
@@ -260,6 +267,14 @@ export async function connectPeerRuntimeHost(input) {
260
267
  stream.abort();
261
268
  }
262
269
  }
270
+ function notifyConnectionPhase(observer, phase) {
271
+ try {
272
+ observer?.(phase);
273
+ }
274
+ catch {
275
+ // Connection progress is diagnostic state and cannot control the connection.
276
+ }
277
+ }
263
278
  function requireRuntimeHostPeerClient(peerClient) {
264
279
  if (peerClient)
265
280
  return peerClient;
@@ -362,6 +377,9 @@ class FileRuntimeHostProfileCatalog {
362
377
  if (!profile) {
363
378
  throw new RuntimeHostPermanentReconnectError(`Unknown Runtime Host profile: ${id}`);
364
379
  }
380
+ if (profile.kind === 'remote' && profile.access === 'session_guest') {
381
+ throw new RuntimeHostPermanentReconnectError('Session Guest access is retained only as a shared Session mount');
382
+ }
365
383
  if (profile.kind === 'environment')
366
384
  return { profile };
367
385
  const credential = await this.credentials.get(profile);
@@ -378,6 +396,7 @@ class FileRuntimeHostProfileCatalog {
378
396
  }
379
397
  #save(value, suppliedCredential, requireNew) {
380
398
  const profile = decodePersistedRuntimeHostProfile(value);
399
+ assertOwnerProfile(profile);
381
400
  return this.#exclusive(async () => {
382
401
  const current = await this.#readSnapshot();
383
402
  const previousProfile = current.profiles.find((candidate) => candidate.id === profile.id);
@@ -463,6 +482,8 @@ class FileRuntimeHostProfileCatalog {
463
482
  }
464
483
  const expectedProfile = decodeRemoteRuntimeHostProfile(target.profile);
465
484
  const profile = decodeRemoteRuntimeHostProfile(value);
485
+ assertOwnerProfile(expectedProfile);
486
+ assertOwnerProfile(profile);
466
487
  if (profile.id !== expectedProfile.id ||
467
488
  !sameRemoteRuntimeHostProfileTarget(profile, expectedProfile) ||
468
489
  runtimeHostProfileAccess(profile) !== runtimeHostProfileAccess(expectedProfile)) {
@@ -530,6 +551,11 @@ export function decodePersistedRuntimeHostProfile(value) {
530
551
  ? decodeEnvironmentRuntimeHostProfile(value)
531
552
  : decodeRemoteRuntimeHostProfile(value);
532
553
  }
554
+ function assertOwnerProfile(profile) {
555
+ if (profile.kind === 'remote' && profile.access === 'session_guest') {
556
+ throw new Error('Session Guest access is retained only as a shared Session mount');
557
+ }
558
+ }
533
559
  export function decodeEnvironmentRuntimeHostProfile(value) {
534
560
  const record = requireExactRecord(value, 'WSL Runtime Host environment profile', [
535
561
  'id',
@@ -31,7 +31,7 @@ export { RuntimeHostStartupError, runtimeHostStartupError, } from './startup-err
31
31
  export { connectRuntimeHostWslEnvironment, listRuntimeHostWslDistributions, normalizeRuntimeHostWslDistribution, normalizeRuntimeHostWslOperatorPath, resolveSystemRuntimeHostWslExecutable, } from './wsl-environment.js';
32
32
  export { RuntimeHostCatalogReadError, readRuntimeHostConnectionCatalog, readRuntimeHostInvocableSkills, readRuntimeHostProjectDetails, readRuntimeHostResources, readRuntimeHostProjects, readRuntimeHostSessions, readRuntimeHostSkillCatalog, } from './catalog-reader.js';
33
33
  export { connectOrSpawnRuntimeHost, } from './connect-or-spawn.js';
34
- export { waitForRuntimeHostReady } from './wait-for-ready.js';
34
+ export { abortable, waitForRuntimeHostReady } from './wait-for-ready.js';
35
35
  export { createRuntimeHostCandidateLaunchBarrier, } from './candidate-launch-barrier.js';
36
36
  export { runHostedExecution } from './hosted-execution.js';
37
37
  export { readRuntimeHostAgentGraphEpochs, } from './agent-graph-reader.js';
@@ -21,7 +21,7 @@ import { randomUUID } from 'node:crypto';
21
21
  import { dirname, isAbsolute } from 'node:path';
22
22
  import { fileURLToPath } from 'node:url';
23
23
  import { candidateStartupFailureForExitCode, } from '../candidate-startup-failure.js';
24
- import { RUNTIME_HOST_LAUNCH_OWNER_GUARD_ENV, RUNTIME_HOST_LAUNCH_OWNER_LEASE_FD_ENV, runtimeHostLaunchOwnerReleaseMessage, } from '../candidate-launch-owner-guard.js';
24
+ import { RUNTIME_HOST_LAUNCH_OWNER_GUARD_ENV, RUNTIME_HOST_LAUNCH_OWNER_CLIENT_ID_ENV, RUNTIME_HOST_LAUNCH_OWNER_LEASE_FD_ENV, runtimeHostLaunchOwnerReleaseMessage, } from '../candidate-launch-owner-guard.js';
25
25
  import { RUNTIME_HOST_STDERR_PIPE_ENV } from '../process-diagnostics.js';
26
26
  const CANDIDATE_STDERR_MAX_BYTES = 4 * 1024;
27
27
  export function launchDetachedRuntimeHostCandidate(input) {
@@ -39,6 +39,9 @@ export function launchDetachedRuntimeHostCandidate(input) {
39
39
  export function launchOwnedRuntimeHostCandidate(input) {
40
40
  const startupAttemptId = randomUUID();
41
41
  const guarded = input.inheritableAuthorityLeaseFd !== undefined || input.closeOnLauncherExit === true;
42
+ if (input.inheritableAuthorityLeaseFd !== undefined && !input.launchOwnerClientInstanceId) {
43
+ throw new Error('A launch-owner-supervised Candidate requires its Client identity');
44
+ }
42
45
  const child = spawnCandidate(input, false, startupAttemptId, guarded);
43
46
  const exited = observeCandidateExit(child);
44
47
  notifyCandidateExit(child, exited, input.onExit);
@@ -113,7 +116,10 @@ function spawnCandidate(input, detached, startupAttemptId, guarded) {
113
116
  ...(guarded ? { [RUNTIME_HOST_LAUNCH_OWNER_GUARD_ENV]: '1' } : {}),
114
117
  ...(childLeaseFd === undefined
115
118
  ? {}
116
- : { [RUNTIME_HOST_LAUNCH_OWNER_LEASE_FD_ENV]: String(childLeaseFd) }),
119
+ : {
120
+ [RUNTIME_HOST_LAUNCH_OWNER_LEASE_FD_ENV]: String(childLeaseFd),
121
+ [RUNTIME_HOST_LAUNCH_OWNER_CLIENT_ID_ENV]: input.launchOwnerClientInstanceId,
122
+ }),
117
123
  },
118
124
  });
119
125
  const stderr = child.stderr;
@@ -92,8 +92,10 @@ class RuntimeHostPeerClientImpl {
92
92
  throw normalizePeerError(error);
93
93
  });
94
94
  }
95
- async connect(input, signal) {
95
+ async connect(input, signal, onPhase) {
96
+ notifyPhase(onPhase, 'discovering');
96
97
  await this.#prepareRoutes(input, signal);
98
+ notifyPhase(onPhase, 'connecting');
97
99
  return this.#connect(input, signal, 'application');
98
100
  }
99
101
  async #prepareRoutes(input, signal) {
@@ -333,6 +335,14 @@ class RuntimeHostPeerClientImpl {
333
335
  return requestId;
334
336
  }
335
337
  }
338
+ function notifyPhase(observer, phase) {
339
+ try {
340
+ observer?.(phase);
341
+ }
342
+ catch {
343
+ // Connection progress is diagnostic state and cannot control the connection.
344
+ }
345
+ }
336
346
  function waitForPeerConnectTurn(previous, signal) {
337
347
  if (!signal)
338
348
  return previous;
@@ -19,4 +19,4 @@
19
19
  export { decodePeerMeshInvitation } from '../protocol/peer-mesh.js';
20
20
  export { openPeerMeshNode, } from './node.js';
21
21
  export { openRuntimeHostPeerMeshOwner, } from './owner.js';
22
- export { hasActivePeerMeshMembership } from './store.js';
22
+ export { hasPeerMeshIdentityObligations, PeerMeshPostCommitError } from './store.js';