@aidenhq/sdk 0.5.1 → 0.5.3

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.
@@ -70,11 +70,16 @@ export async function flushEvents(store, post, onRefused) {
70
70
  const held = store.load();
71
71
  if (!held.length)
72
72
  return { sent: 0, left: 0 };
73
- const r = await sendEvents(post, held);
74
- const gone = new Set([...r.sent, ...r.refused.map((x) => x.id)]);
73
+ // One event per id a pass (a live one and its replay share an id, and the kernel answers by id): the other goes next pass.
74
+ const key = (e) => `${e.id}\0${String(e.replay ?? "")}`;
75
+ const seen = new Set(), batch = held.filter((e) => !seen.has(e.id) && Boolean(seen.add(e.id)));
76
+ const r = await sendEvents(post, batch);
77
+ // Exactly the events this pass sent are removed; one stored meanwhile, or held back above, stays.
78
+ const ids = new Set([...r.sent, ...r.refused.map((x) => x.id)]);
79
+ const gone = new Set(batch.filter((e) => ids.has(e.id)).map(key));
75
80
  let left = held.length;
76
81
  if (gone.size) {
77
- const rest = store.load().filter((e) => !gone.has(e.id));
82
+ const rest = store.load().filter((e) => !gone.has(key(e)));
78
83
  store.save(rest);
79
84
  left = rest.length;
80
85
  }
@@ -78,6 +78,11 @@ export interface ExecuteRequest {
78
78
  identifier?: string;
79
79
  /** The record's tier as the kernel set it (0 ran unreviewed): an executor rechecks what a Tier 0 rested on. */
80
80
  tier?: 0 | 1 | 2;
81
+ /** How it was decided: `approve` only on the AI reviewer's approval (`code` `fail_open` when the review didn't finish), `owner`, or `none` (Tier 0). */
82
+ review?: {
83
+ decision: "approve" | "owner" | "none";
84
+ code: string | null;
85
+ };
81
86
  }
82
87
  export interface Executor {
83
88
  plan(req: PlanRequest): Promise<PlanResult>;
@@ -1,6 +1,6 @@
1
1
  // executor@1, the module side (spec §3.3.2): the kernel calls a module's write kinds here, with the module's own service key.
2
2
  // POST <path>/plan { kind, args, requester, task, evidence?, revalidate? } → { args, targets?, facts?, raise?, card?, satisfied? }
3
- // POST <path>/execute { id, kind, args, digest, idempotency_key, task } → { accepted: true } at once; the outcome follows to the
3
+ // POST <path>/execute { id, kind, args, digest, idempotency_key, task, tier, review } → { accepted: true } at once; the outcome follows to the
4
4
  // kernel's POST /v1/writes/:id/outcome. Once per id: a repeat is accepted and runs nothing.
5
5
  // POST <path>/status { id, idempotency_key } → { state: running | done | failed | unknown, text?, objects? }
6
6
  // The kernel calls execute only for an approved, claimed and revalidated record; plan never changes anything.
@@ -8,13 +8,10 @@ export function errorKind(code) {
8
8
  return code;
9
9
  return VENDOR_CODES[code];
10
10
  }
11
+ // The ChatGPT Codex backend's (modules/models-chatgpt): the plan's Codex limit, and a plan without Codex.
11
12
  const VENDOR_CODES = {
12
- subscription_sharing_usage_limit_exceeded: "quota",
13
- subscription_sharing_user_not_eligible: "ineligible",
14
- subscription_sharing_unsupported_capability: "unsupported",
15
- subscription_sharing_usage_unavailable: "unavailable",
16
- subscription_sharing_user_unavailable: "unavailable",
17
- subscription_sharing_invalid_user: "auth",
13
+ usage_limit_reached: "quota",
14
+ usage_not_included: "ineligible",
18
15
  };
19
16
  export class ModelError extends Error {
20
17
  kind;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidenhq/sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "The shared code of AidenHQ modules: contract types, engine IO, the caller check and fence, write executors, the reviewer side, the judges' models and call, the source writer and the vendor MCP pass-through.",
5
5
  "license": "MIT",
6
6
  "repository": {