@atolis-hq/wake 0.3.64 → 0.3.65

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.
@@ -1,6 +1,6 @@
1
1
  import { createPullRequestService } from '../activities/index.js';
2
2
  import { ControlStreamKind, DispatchPolicy, createAdvanceOnce, createControlPlaneService, createRunnerControlService, ineligibleRunners, } from '../control-plane/index.js';
3
- import { ExecutionCancellationReason, ExternalExecutionState, GitWorkspaceProvider, RecoveryService, TranscriptStore, createExecutionService, } from '../execution/index.js';
3
+ import { ExecutionCancellationReason, ExternalExecutionState, GitWorkspaceProvider, RecoveryService, TranscriptStore, createExecutionService, createRunnerMemoryProfileDecorator, } from '../execution/index.js';
4
4
  import { createGitHubAgentContextReader, gitHubProviderDefinition, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
5
5
  import { SystemClock, UlidIdGenerator, } from '../kernel/index.js';
6
6
  import { compileWorkflow, createOrchestrationService } from '../orchestration/index.js';
@@ -59,10 +59,22 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
59
59
  const transcriptStore = config.transcripts.enabled
60
60
  ? (options.transcriptStore ?? new TranscriptStore(paths.transcriptsRoot))
61
61
  : undefined;
62
+ const profileDecorator = process.env.WAKE_MEMORY_PROFILE === 'runner'
63
+ ? createRunnerMemoryProfileDecorator({
64
+ write: (line) => process.stderr.write(line),
65
+ now: () => clock.now().toISOString(),
66
+ memoryUsage: () => process.memoryUsage(),
67
+ })
68
+ : undefined;
69
+ const decorateRunner = profileDecorator === undefined
70
+ ? options.decorateRunner
71
+ : options.decorateRunner === undefined
72
+ ? profileDecorator
73
+ : (runner, name) => profileDecorator(options.decorateRunner(runner, name), name);
62
74
  const execution = createExecutionService(journal, activities, config.execution, {
63
75
  clock,
64
76
  ids,
65
- runners: createRunnerRegistry(config.execution, fakeScenarios, options.decorateRunner),
77
+ runners: createRunnerRegistry(config.execution, fakeScenarios, decorateRunner),
66
78
  reportRunnerQuota: createRunnerQuotaReporter(journal, clock, ids),
67
79
  ...(transcriptStore !== undefined
68
80
  ? {
@@ -179,6 +179,7 @@ function sandboxDockerOptions(root, overrides) {
179
179
  containerHomeMountPath: root.config.host.sandbox.containerHomeMountPath,
180
180
  extraMounts: root.config.host.sandbox.extraMounts,
181
181
  startEnabled: root.config.host.sandbox.start.enabled,
182
+ ...(process.env.WAKE_MEMORY_PROFILE === 'runner' ? { memoryProfile: 'runner' } : {}),
182
183
  inspect: createDockerInspection(root.paths.wakeRoot),
183
184
  resolveBuildVersion: () => resolveSandboxBuildVersion(root),
184
185
  };
@@ -108,4 +108,4 @@ export function resolveWakeVersion(options = {}) {
108
108
  return `g${headHash.slice(0, 7)}`;
109
109
  return '0.1.0-dev';
110
110
  }
111
- export const wakeVersion = "gfe73f33";
111
+ export const wakeVersion = "gcf37d8a";
@@ -26,6 +26,7 @@ export * from './infrastructure/runners/cursor.js';
26
26
  export * from './infrastructure/runners/fake.js';
27
27
  export * from './infrastructure/runners/fake-scenarios.js';
28
28
  export * from './infrastructure/runners/registry.js';
29
+ export * from './infrastructure/runner-memory-profile.js';
29
30
  export * from './infrastructure/transcripts.js';
30
31
  export * from './infrastructure/transcript-store.js';
31
32
  export * from './infrastructure/workspace/fake-workspace.js';
@@ -0,0 +1,34 @@
1
+ export function createRunnerMemoryProfileDecorator(options) {
2
+ return (runner, name) => ({
3
+ ...(runner.supportsSessionResume === undefined
4
+ ? {}
5
+ : { supportsSessionResume: runner.supportsSessionResume }),
6
+ start: async (request, signal) => {
7
+ writeSample(options, 'runner.start.before', name, request.runId);
8
+ const execution = await runner.start(request, signal);
9
+ writeSample(options, 'runner.start.returned', name, request.runId);
10
+ return {
11
+ ...execution,
12
+ result: execution.result.finally(() => {
13
+ writeSample(options, 'runner.result.settled', name, request.runId);
14
+ }),
15
+ };
16
+ },
17
+ });
18
+ }
19
+ function writeSample(options, phase, runner, runId) {
20
+ const memory = options.memoryUsage();
21
+ options.write(`${JSON.stringify({
22
+ type: 'wake.runner-memory',
23
+ phase,
24
+ at: options.now(),
25
+ pid: process.pid,
26
+ runner,
27
+ runId,
28
+ rss: memory.rss,
29
+ heapTotal: memory.heapTotal,
30
+ heapUsed: memory.heapUsed,
31
+ external: memory.external,
32
+ arrayBuffers: memory.arrayBuffers,
33
+ })}\n`);
34
+ }
@@ -197,6 +197,9 @@ async function createContainer(docker, options) {
197
197
  `WAKE_HOME_INIT_DIRS=${homeInitDirectories.join('\n')}`,
198
198
  ]),
199
199
  ...(options.startEnabled === true ? ['-e', 'WAKE_START_ENABLED=true'] : []),
200
+ ...(options.memoryProfile === undefined
201
+ ? []
202
+ : ['-e', `WAKE_MEMORY_PROFILE=${options.memoryProfile}`]),
200
203
  options.image,
201
204
  ]);
202
205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.3.64",
3
+ "version": "0.3.65",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {