ace-wake 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a679048243d6647fbd557f720145e244bd42198dfbbe3e6f290a7ac96e9cf2a6
4
- data.tar.gz: 20ee3a591b2f8324fefe4927b3c5b3f820799d8769f2df6d357bc65f4c9dac76
3
+ metadata.gz: 90d56b134bd020956dbdf73c1b52f3a6988bd2bce06dbf1b0bf8a52c9d5b089c
4
+ data.tar.gz: 0a7357f6d16c6c05d19fb58c473225473dea6aeff312fb4d77f7a2a4b3fc73a6
5
5
  SHA512:
6
- metadata.gz: 3988a72f9d1a5b4c6a687e265615e3036edfa08da782cdab5b5f3b20c84326751ffa18746d07def2fc90a90a86fe68d5cc31831df2442285f4e0e8849e440dc8
7
- data.tar.gz: bba20957de9af875a32835e5ca1c500e924a0178282b19a6778e5af03f1789aa9863ceb3a542784a40bdeb7b90bb83a298b52fcd794c5a57b64a4a927927f15a
6
+ metadata.gz: 45d4bc561feefe1142559eb996b7c5338082eb52993cb180d4fab926003b1c73e8cce58f4d309732939d2e42186256c6c581f425e4f8cf185a8d56ed97bf8185
7
+ data.tar.gz: e3ee0958695b688f938bd3c8e778edb8fd11fc992b4bdb747483b2f6c7d70f053f1ed1f09eda8edb23dbd3e0ed1ee09c9195547529b290b0257388e5f78e8fbd
data/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-11-12
11
+
12
+ ### Changed
13
+
14
+ - Initialize configured eyes and compose report processing with healthy observation and exact revision acknowledgements.
15
+ - Show the pending wake-budget resume deadline in eyes status.
16
+
17
+ ### Fixed
18
+
19
+ - Describe the eyes deadline timestamp as absolute epoch milliseconds in the agent tool schema, preventing durations from being mistaken for future deadlines.
20
+
21
+
10
22
  ## [0.3.0] - 2026-11-10
11
23
 
12
24
  ### Added
@@ -56,7 +56,17 @@ export async function observeHitl(cwd, config) {
56
56
  return result;
57
57
  }
58
58
 
59
- export function registerEyes(pi, { observe = observeHitl, now = Date.now,
59
+ export async function processReports(cwd, config, signal) {
60
+ const { stdout } = await execute("ace-overseer", ["process-reports", "--json",
61
+ "--owner", config.recipient, "--scope", config.scope],
62
+ { cwd, signal, maxBuffer: 8 * 1024 * 1024, encoding: "utf8" });
63
+ const result = JSON.parse(stdout);
64
+ if (!Array.isArray(result?.outcomes) || result.dry_run !== false)
65
+ throw new Error("Invalid report-processing receipt");
66
+ return result;
67
+ }
68
+
69
+ export function registerEyes(pi, { observe = observeHitl, processReports: processReportOwner = processReports, env = process.env, now = Date.now,
60
70
  schedule = (fn, ms) => setInterval(fn, ms), cancel = clearInterval, processIdentity = eyesProcessIdentity } = {}) {
61
71
  let eyes, timer, attempt, observedSources, observedAt, bindingGeneration = 0, compacting = false, running = false, arming = false;
62
72
  const clearEvidence = () => { observedSources = undefined; observedAt = undefined; };
@@ -69,7 +79,7 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
69
79
  timer?.unref?.();
70
80
  }
71
81
  }
72
- const bind = (ctx) => {
82
+ const bind = async (ctx) => {
73
83
  const generation = ++bindingGeneration;
74
84
  stopTimer(); eyes?.dispose(); attempt = undefined; clearEvidence(); compacting = false; running = false;
75
85
  const entries = ctx.sessionManager.getBranch();
@@ -93,7 +103,7 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
93
103
  } });
94
104
  },
95
105
  status: (state) => {
96
- ctx.ui?.setStatus?.("ace-eyes", `eyes ${state.retired ? "retired" : state.breaker?.reason || (state.observationUnavailable ? "observation-unavailable" : state.enabled ? "observing" : "off")} pending:${state.pending}`);
106
+ ctx.ui?.setStatus?.("ace-eyes", `eyes ${state.retired ? "retired" : state.breaker?.reason || (state.observationUnavailable ? "observation-unavailable" : state.wakeLimitedUntil && state.pending ? `wake-limited until ${new Date(state.wakeLimitedUntil).toISOString()}` : state.enabled ? "observing" : "off")} pending:${state.pending}`);
97
107
  if (state.breaker || state.retired) stopTimer();
98
108
  },
99
109
  observe: (config) => observe(ctx.cwd, config),
@@ -120,8 +130,8 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
120
130
  deliver: async (batch) => {
121
131
  if (!ctx.model) return false;
122
132
  const text = `[ace-eyes] Pending task/assignment/HITL/deadline revisions: ${JSON.stringify(batch)}. ` +
123
- "Read ace-overseer observe and the original state owners; adopt reports through ace-overseer process-reports and existing task/assignment gates. " +
124
- "Reconcile uncertain effects; never repeat external actions on wake alone. After handling each exact revision, " +
133
+ "Read the original state owners. For reports use ace_eyes action process-reports; it accepts, continues and acknowledges exact completed revisions. " +
134
+ "Reconcile uncertain effects; never repeat external actions on wake alone. For other event types, after handling each exact revision, " +
125
135
  "acknowledge with the ace_eyes tool (action ack, key, revision). Settlement alone is not acknowledgement.";
126
136
  const previous = attempt;
127
137
  attempt = { text, accepted: false };
@@ -132,8 +142,17 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
132
142
  if (submitted === false) attempt = previous;
133
143
  return submitted !== false;
134
144
  } });
145
+ const configPath = env.ACE_OVERSEER_EYES_CONFIG;
146
+ if (configPath) {
147
+ const expected = path.join(ownerCwd, ".ace-local/overseer/eyes.json");
148
+ if (path.resolve(configPath) !== expected) throw new Error("Eyes config does not belong to this coordinator root");
149
+ eyes.start(JSON.parse(fs.readFileSync(configPath, "utf8")));
150
+ }
135
151
  arm();
136
- if (eyes.s.enabled) void eyes.tick();
152
+ if (eyes.s.enabled && configPath) {
153
+ arming = true;
154
+ try { await eyes.tick(); } finally { arming = false; }
155
+ } else if (eyes.s.enabled) void eyes.tick();
137
156
  };
138
157
  pi.on("session_start", async (_event, ctx) => bind(ctx));
139
158
  pi.on("session_tree", async (_event, ctx) => bind(ctx));
@@ -157,17 +176,19 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
157
176
  if (message?.role === "assistant" && message.stopReason === "error") eyes?.quota(message.errorMessage);
158
177
  });
159
178
  pi.registerTool?.({
160
- name: "ace_eyes", label: "Eyes observation", description: "Start standing observation with an existing config file, read pending semantic events or acknowledge an exact handled revision. Does not accept reports, authorize effects, start actors or reset quota. Use existing report/assignment owners first. Deadlines require an operation identity and revision; cancel when no longer active.",
179
+ name: "ace_eyes", label: "Eyes observation", description: "Start standing observation with an existing config file, read pending semantic events or acknowledge an exact handled revision. Action process-reports invokes the existing report owner and acknowledges only its completed exact revisions. Other events require explicit ack. Does not reset quota. Deadlines require an operation identity and revision; cancel when no longer active.",
161
180
  parameters: { type: "object", properties: {
162
- action: { type: "string", enum: ["start", "status", "ack", "deadline", "cancel"] },
181
+ action: { type: "string", enum: ["start", "status", "process-reports", "ack", "deadline", "cancel"] },
163
182
  configPath: { type: "string" },
164
- key: { type: "string" }, revision: { type: "string" }, at: { type: "integer" }
183
+ key: { type: "string" }, revision: { type: "string" },
184
+ at: { type: "integer", description: "Absolute Unix epoch timestamp in milliseconds, NOT a duration. For five minutes from now use the current epoch milliseconds plus 300000; a past timestamp is immediately due." }
165
185
  }, required: ["action"], additionalProperties: false },
166
186
  execute: async (_id, args, _signal, _onUpdate, ctx) => {
167
187
  if (!eyes) {
168
188
  if (!ctx) throw new Error("Eyes session not initialized");
169
- bind(ctx);
189
+ await bind(ctx);
170
190
  }
191
+ let processing;
171
192
  if (args.action === "start") {
172
193
  if (!ctx || typeof args.configPath !== "string" || !args.configPath.trim()) {
173
194
  throw new Error("Eyes start requires configPath and the current session context");
@@ -181,20 +202,42 @@ export function registerEyes(pi, { observe = observeHitl, now = Date.now,
181
202
  try { await current.tick(); } finally { if (current === eyes && generation === bindingGeneration) arming = false; }
182
203
  if (current !== eyes || generation !== bindingGeneration) throw new Error("Eyes session changed during start");
183
204
  }
205
+ else if (args.action === "process-reports") {
206
+ if (!ctx || !eyes.s.enabled) throw new Error("Report processing requires active eyes in this session");
207
+ const sources = observedSources && Object.values(observedSources);
208
+ const config = eyes.s.config;
209
+ const interval = config.intervalSeconds * 1000;
210
+ const cadence = Math.ceil(3600000 / (config.maxObservationsPerHour * interval)) * interval;
211
+ if (eyes.s.breaker || eyes.s.observationUnavailable || !sources?.length ||
212
+ sources.some(source => source.status !== "ok") || observedAt === undefined ||
213
+ now() - observedAt > cadence + config.timeoutMs)
214
+ throw new Error("Report processing blocked: required observation is unavailable, degraded or stale");
215
+ const current = eyes, generation = bindingGeneration;
216
+ processing = await processReportOwner(ctx.cwd, current.s.config, _signal);
217
+ if (current !== eyes || generation !== bindingGeneration)
218
+ throw new Error("Eyes session changed during report processing; retained receipts require reconciliation");
219
+ if (!Array.isArray(processing?.outcomes) || processing.dry_run !== false)
220
+ throw new Error("Invalid report-processing receipt");
221
+ for (const receipt of processing.outcomes) {
222
+ if (receipt.acknowledge !== true || receipt.accepted !== true || receipt.cleanup !== "complete") continue;
223
+ if (current.s.pending[receipt.key]?.revision === receipt.revision || current.sent.get(receipt.key) === receipt.revision)
224
+ current.ack(receipt.key, receipt.revision);
225
+ }
226
+ }
184
227
  else if (args.action === "ack") eyes.ack(args.key, args.revision);
185
228
  else if (args.action === "deadline") eyes.deadline(args.key, args.at, args.revision);
186
229
  else if (args.action === "cancel") eyes.cancelDeadline(args.key);
187
230
  else if (args.action !== "status") throw new Error("Unknown eyes action");
188
231
  // Do not send a second wake from inside the running model turn. The next
189
232
  // observation delivers remaining coalesced revisions through the same owner.
190
- const details = { ...eyes.summary(), sources: observedSources, pending: eyes.s.pending, deadlines: eyes.s.deadlines };
233
+ const details = { ...eyes.summary(), ...(processing ? { processing } : {}), sources: observedSources, pending: eyes.s.pending, deadlines: eyes.s.deadlines };
191
234
  return { content: [{ type: "text", text: JSON.stringify(details) }], details };
192
235
  }
193
236
  });
194
237
  pi.registerCommand("eyes", { description: "Event-driven HITL observation: start CONFIG | status | ack KEY REV | deadline NAME REVISION EPOCH_MS | cancel NAME | resume quota-verified | retire",
195
238
  handler: async (args, ctx) => {
196
239
  try {
197
- if (!eyes) bind(ctx);
240
+ if (!eyes) await bind(ctx);
198
241
  const [command, a, b, ...rest] = args.trim().split(/\s+/);
199
242
  if (rest.length && command !== "deadline") throw new Error("Too many arguments");
200
243
  switch (command) {
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ace
4
4
  module Wake
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ace-wake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Czyz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-11-10 00:00:00.000000000 Z
10
+ date: 2026-11-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ace-runtime