gcf-harness-aif-ext 0.9.6 → 0.9.7

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.
@@ -115,7 +115,7 @@ function limitIn(text, whole = true) {
115
115
  * @returns {{lines: string[], cost?: Cost, session_id?: string, limit?: {resets: string | null},
116
116
  * context?: number, turn?: string, model?: string, windows?: Record<string, number>,
117
117
  * compacted?: boolean, implement?: boolean, writes?: {id: string, file: string}[],
118
- * failed?: string[]}}
118
+ * failed?: string[], quota?: Record<string, unknown>}}
119
119
  */
120
120
  export function activity(line, now = new Date()) {
121
121
  let e;
@@ -145,9 +145,18 @@ export function activity(line, now = new Date()) {
145
145
 
146
146
  if (e.type === 'result') return ended(e, at);
147
147
 
148
- return { lines: [] };
148
+ return quotaOf(e);
149
149
  }
150
150
 
151
+ /**
152
+ * The account's usage-limit state as the stream gives it, raw: kept to learn its fields before
153
+ * the board shows the quota (Board-PRD decision 17). Any other event gives nothing.
154
+ */
155
+ const quotaOf = (e) =>
156
+ e.type === 'rate_limit_event' && e.rate_limit_info
157
+ ? { lines: [], quota: e.rate_limit_info }
158
+ : { lines: [] };
159
+
151
160
  /**
152
161
  * A system event: the init names the session and its model; a compaction is a line, the
153
162
  * agent's context summarized; the rest (hooks, thinking) give nothing.
package/commands/run.js CHANGED
@@ -319,6 +319,15 @@ function handoffWatch(handoff, dir, write, stop) {
319
319
  };
320
320
  }
321
321
 
322
+ /** The last usage-limit state a session's stream gave, with its time; a failed write loses it. */
323
+ function keepQuota(file, info) {
324
+ try {
325
+ writeFileSync(file, `${JSON.stringify({ at: new Date().toISOString(), info })}\n`);
326
+ } catch {
327
+ // A probe, not a record: the run goes on without it.
328
+ }
329
+ }
330
+
322
331
  /**
323
332
  * One agent session on `prompt` in `dir`; resolves with its exit code, or `timeout` when it ran
324
333
  * past `timeoutMs`: a hung session would hold the item's run lock, and every move on it, for
@@ -334,7 +343,7 @@ function handoffWatch(handoff, dir, write, stop) {
334
343
  * session_id?: string, limit?: {resets: string | null}, gone: boolean, handoff: boolean,
335
344
  * handedOver: boolean, model?: string, window?: number, result?: string}>}
336
345
  */
337
- function startAgent(agent, prompt, dir, { fd, timeoutMs, id, onSpawn, env = {}, handoff }) {
346
+ function startAgent(agent, prompt, dir, { fd, timeoutMs, id, onSpawn, env = {}, handoff, quota }) {
338
347
  return new Promise((resolve) => {
339
348
  const command = `${agent} "${prompt}"`;
340
349
  // A line before the agent's first: the log's time says the session is alive from its start.
@@ -360,6 +369,7 @@ function startAgent(agent, prompt, dir, { fd, timeoutMs, id, onSpawn, env = {},
360
369
  });
361
370
  const flushOut = byLine(child.stdout, (line) => {
362
371
  const a = activity(line);
372
+ if (a.quota && quota) keepQuota(quota, a.quota);
363
373
  absorb(seen, a, dir);
364
374
  write(a.lines);
365
375
  if (open) watch.see(a, seen.model);
@@ -736,7 +746,15 @@ async function agentSession(s, agent, prompt) {
736
746
  const flags = launch?.flags(r.dir);
737
747
  const handoff = launch?.handoff && { ...launch.handoff, plan: launch.planOf?.(r.id) };
738
748
  const left = Math.max(deadline - Date.now(), 1000);
739
- const opts = { fd, timeoutMs: left, id: r.id, onSpawn: s.onSpawn, env: launch?.env, handoff };
749
+ const opts = {
750
+ fd,
751
+ timeoutMs: left,
752
+ id: r.id,
753
+ onSpawn: s.onSpawn,
754
+ env: launch?.env,
755
+ handoff,
756
+ quota: path.join(s.logs, 'quota.json'),
757
+ };
740
758
  const ran = await startAgent(flags ? `${agent} ${flags}` : agent, prompt, r.dir, opts);
741
759
  await rm(flag, { force: true });
742
760
  // Between two sessions the lock names none: a stop then marks the item, not the run.
@@ -928,6 +946,7 @@ async function askLessons(s, ran, base = 0) {
928
946
  onSpawn: s.onSpawn,
929
947
  env: launch?.env,
930
948
  handoff: null,
949
+ quota: null,
931
950
  });
932
951
  writeFileSync(s.lock, `${process.pid}\n${r.id}\n`);
933
952
  // A turn cut by the limit, a timeout, a stop or an error has no answer: its text is not one.
package/extension.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
3
3
  "name": "gcf-harness-aif-ext",
4
- "version": "0.9.6",
4
+ "version": "0.9.7",
5
5
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
6
6
  "skills": [
7
7
  "skills/gcf-run",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-harness-aif-ext",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,7 +28,7 @@
28
28
  "prepack": "node -e \"const p=require('./package.json'),e=require('./extension.json');if(p.version!==e.version)throw new Error('version mismatch: package.json '+p.version+' vs extension.json '+e.version)\""
29
29
  },
30
30
  "peerDependencies": {
31
- "gcf-aif-ext": "^0.7.14"
31
+ "gcf-aif-ext": "^0.7.14 || ^0.8.0"
32
32
  },
33
33
  "files": [
34
34
  "extension.json",