@atolis-hq/wake 0.3.65 → 0.3.66

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,5 +1,5 @@
1
1
  import { ControlStreamKind, ScheduleService, createIntakePipeline, createRunnerPipeline, createWorkCancellationPolicy, } from '../control-plane/index.js';
2
- import { RunRepository } from '../execution/index.js';
2
+ import { RunRepository, createRuntimeMemoryProfile, } from '../execution/index.js';
3
3
  import { AgentRunPublicationReactor, ArtifactRegistrationReactor, DeliveryOutcomeReactor, DeliveryService, IntegrationStreamKind, PollService, ProviderRegistry, fakeProviderDefinition, } from '../integrations/index.js';
4
4
  import { EventActorKind, } from '../kernel/index.js';
5
5
  import { compileWorkflowSelectors, createPullRequestTransitionEvidence, createResourceTransitionReactor, createWatchReactor, selectWorkflow, workflowName, } from '../orchestration/index.js';
@@ -18,6 +18,13 @@ function serializeRunRegisteredOnce(runner) {
18
18
  return runner;
19
19
  }
20
20
  export async function composeIntegrationRuntime(input) {
21
+ const memoryProfile = process.env.WAKE_MEMORY_PROFILE === 'runner'
22
+ ? createRuntimeMemoryProfile({
23
+ write: (line) => process.stderr.write(line),
24
+ now: () => input.clock.now().toISOString(),
25
+ memoryUsage: () => process.memoryUsage(),
26
+ })
27
+ : undefined;
21
28
  const registry = new ProviderRegistry();
22
29
  registry.register(fakeProviderDefinition);
23
30
  for (const definition of input.providerDefinitions)
@@ -121,24 +128,28 @@ export async function composeIntegrationRuntime(input) {
121
128
  // Tick needs a backing-off host; see bootstrap/surface-cli-applications.ts.
122
129
  const intakePipeline = createIntakePipeline({
123
130
  isPaused: input.isPaused,
124
- catchUpProjections,
131
+ catchUpProjections: () => observeMemory(memoryProfile, 'intake.projections', catchUpProjections),
125
132
  poll: async (signal) => {
126
- let appended = 0;
127
- for (const provider of providers)
128
- appended += await new PollService(input.journal, provider).pollOnce(signal);
129
- return appended;
133
+ return observeMemory(memoryProfile, 'intake.poll', async () => {
134
+ let appended = 0;
135
+ for (const provider of providers)
136
+ appended += await new PollService(input.journal, provider).pollOnce(signal);
137
+ return appended;
138
+ });
130
139
  },
131
140
  translateInbound: async () => {
132
- let translated = 0;
133
- for (const provider of providers)
134
- translated += await provider.inbound.runOnce();
135
- return translated;
141
+ return observeMemory(memoryProfile, 'intake.translate', async () => {
142
+ let translated = 0;
143
+ for (const provider of providers)
144
+ translated += await provider.inbound.runOnce();
145
+ return translated;
146
+ });
136
147
  },
137
148
  });
138
149
  const runnerPipeline = createRunnerPipeline({
139
150
  isPaused: input.isPaused,
140
- catchUpProjections,
141
- runSchedules: async () => {
151
+ catchUpProjections: () => observeMemory(memoryProfile, 'runner.projections', catchUpProjections),
152
+ runSchedules: () => observeMemory(memoryProfile, 'runner.schedules', async () => {
142
153
  for (const schedule of input.config.controlPlane.schedules)
143
154
  await schedules.run(schedule, {
144
155
  commandId: input.ids.next('command'),
@@ -146,8 +157,8 @@ export async function composeIntegrationRuntime(input) {
146
157
  occurredAt: input.clock.now().toISOString(),
147
158
  actor: { kind: EventActorKind.System, id: ControlStreamKind.Global },
148
159
  });
149
- },
150
- react: async () => {
160
+ }),
161
+ react: () => observeMemory(memoryProfile, 'runner.react', async () => {
151
162
  await watch.runOnce();
152
163
  await watch.reconcileOnce();
153
164
  await resourceTransitions.runOnce();
@@ -155,14 +166,14 @@ export async function composeIntegrationRuntime(input) {
155
166
  await outcomes.runOnce();
156
167
  for (const provider of providers)
157
168
  await provider.maintenance?.runOnce();
158
- },
159
- advance: input.advanceOnce,
160
- publishAgentRuns: async () => {
169
+ }),
170
+ advance: (options) => observeMemory(memoryProfile, 'runner.advance', () => input.advanceOnce(options)),
171
+ publishAgentRuns: () => observeMemory(memoryProfile, 'runner.publish-agent-runs', async () => {
161
172
  await agentRunPublications.runOnce();
162
- },
163
- deliver: async (signal) => {
173
+ }),
174
+ deliver: (signal) => observeMemory(memoryProfile, 'runner.deliver', async () => {
164
175
  await delivery.deliverNext(signal);
165
- },
176
+ }),
166
177
  });
167
178
  return {
168
179
  projectionRunner,
@@ -173,6 +184,15 @@ export async function composeIntegrationRuntime(input) {
173
184
  runnerPipeline,
174
185
  };
175
186
  }
187
+ async function observeMemory(profile, phase, operation) {
188
+ profile?.sample(`${phase}.before`);
189
+ try {
190
+ return await operation();
191
+ }
192
+ finally {
193
+ profile?.sample(`${phase}.settled`);
194
+ }
195
+ }
176
196
  // Configuration is the only routing authority: adapters ask, they never propose.
177
197
  function createWorkflowRouter(orchestration) {
178
198
  const selectors = compileWorkflowSelectors(orchestration.workflowSelectors);
@@ -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 = "gcf37d8a";
111
+ export const wakeVersion = "gcfcc531";
@@ -1,3 +1,21 @@
1
+ export function createRuntimeMemoryProfile(options) {
2
+ return {
3
+ sample: (phase) => {
4
+ const memory = options.memoryUsage();
5
+ options.write(`${JSON.stringify({
6
+ type: 'wake.runtime-memory',
7
+ phase,
8
+ at: options.now(),
9
+ pid: process.pid,
10
+ rss: memory.rss,
11
+ heapTotal: memory.heapTotal,
12
+ heapUsed: memory.heapUsed,
13
+ external: memory.external,
14
+ arrayBuffers: memory.arrayBuffers,
15
+ })}\n`);
16
+ },
17
+ };
18
+ }
1
19
  export function createRunnerMemoryProfileDecorator(options) {
2
20
  return (runner, name) => ({
3
21
  ...(runner.supportsSessionResume === undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.3.65",
3
+ "version": "0.3.66",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {