Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts
29 changes: 29 additions & 0 deletions packages/astrid-sdk/src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,35 @@ export namespace hook {
data?: string;
}

/**
* Payload of `hook.v1.event.<hook_name>` envelopes published by the
* hook bridge during fan-out to subscriber capsules.
*
* Subscribers wishing to influence the outcome (merge strategies
* `ToolCallBefore` / `LastNonNull`) reply on the per-request
* scoped topic `hook.v1.response.<hook_name>.<correlation_id>`.
* When `correlation_id` is absent, the dispatch is fire-and-forget
* (merge semantics `None`) and no reply topic exists.
*/
export interface HookEventRequest {
/**
* Semantic hook name (e.g. `before_tool_call`, `session_start`,
* `on_compaction_started`). Matches the mapping table in
* `astrid-capsule-hook-bridge`.
*/
hook: string;
/**
* Original lifecycle event payload, serialized as JSON. Opaque
* to the bus — subscribers parse based on the hook name.
*/
payload: string;
/**
* Per-request correlation id for scoped replies. `none` for
* fire-and-forget hooks.
*/
correlation_id?: string;
}

}

/** Types generated from the `llm` WIT interface. */
Expand Down
21 changes: 21 additions & 0 deletions packages/astrid-sdk/wit-contracts/astrid-contracts.wit
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,27 @@ interface hook {
/// Merged data from interceptor responses (opaque JSON).
data: option<string>,
}

/// Payload of `hook.v1.event.<hook_name>` envelopes published by the
/// hook bridge during fan-out to subscriber capsules.
///
/// Subscribers wishing to influence the outcome (merge strategies
/// `ToolCallBefore` / `LastNonNull`) reply on the per-request
/// scoped topic `hook.v1.response.<hook_name>.<correlation_id>`.
/// When `correlation_id` is absent, the dispatch is fire-and-forget
/// (merge semantics `None`) and no reply topic exists.
record hook-event-request {
/// Semantic hook name (e.g. `before_tool_call`, `session_start`,
/// `on_compaction_started`). Matches the mapping table in
/// `astrid-capsule-hook-bridge`.
hook: string,
/// Original lifecycle event payload, serialized as JSON. Opaque
/// to the bus — subscribers parse based on the hook name.
payload: string,
/// Per-request correlation id for scoped replies. `none` for
/// fire-and-forget hooks.
correlation-id: option<string>,
}
Comment on lines +315 to +326

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The TypeScript contracts file packages/astrid-sdk/src/contracts.ts is checked into the repository but has not been regenerated to include the new hook-event-request types. Please run the generation script (e.g., node packages/astrid-sdk/scripts/generate-contracts.mjs) and commit the updated contracts.ts file to ensure the TS SDK remains in sync with the WIT contracts.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The WIT carried the new hook-event-request record but src/contracts.ts was never regenerated on this branch (the prior commit only bumped the WIT and the contracts submodule, not the generated TS). Regenerated via the package prebuild step (node scripts/generate-contracts.mjs) and committed — the diff is purely additive, adding the HookEventRequest interface (type count 99 → 100), and tsc -b is clean. The generator is deterministic (walks the WIT AST in source order, no sorting/timestamps/randomness), so the same WIT always yields identical output.

}

// ── llm ──────────────────────────────────────────────────────────
Expand Down
Loading