@hasna/hooks 0.12.9 → 0.12.14

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.
Files changed (58) hide show
  1. package/README.md +69 -6
  2. package/bin/hooks/stop-review.js +1235 -0
  3. package/bin/hooks-mcp.js +298 -85
  4. package/bin/index.js +3309 -1086
  5. package/bin/native-readiness-entry.js +5 -1
  6. package/bin/native-safety-entry.js +27 -25
  7. package/bin/native-safety-worker.cjs +27 -25
  8. package/bin/serve.js +1362 -70
  9. package/dist/db/remote-storage.d.ts +7 -1
  10. package/dist/index.d.ts +4 -1
  11. package/dist/index.js +1665 -257
  12. package/dist/lib/codex-safety-check.d.ts +1 -1
  13. package/dist/lib/hosted-registry.d.ts +70 -0
  14. package/dist/lib/legacy-registry-artifact.d.ts +23 -0
  15. package/dist/lib/manifest.d.ts +7 -0
  16. package/dist/lib/native-safety.d.ts +1 -0
  17. package/dist/lib/native-target.d.ts +7 -0
  18. package/dist/lib/opencode-stop-plugin.d.ts +55 -0
  19. package/dist/lib/registry-artifact.d.ts +36 -0
  20. package/dist/lib/registry.d.ts +4 -0
  21. package/dist/lib/stop-review-context.d.ts +12 -0
  22. package/dist/lib/store.d.ts +4 -0
  23. package/dist/lib/sumi-stop-plugin.d.ts +129 -0
  24. package/dist/lib/sync.d.ts +10 -0
  25. package/dist/lib/transport.d.ts +1 -1
  26. package/dist/native-readiness.d.ts +1 -1
  27. package/dist/native-readiness.js +5 -1
  28. package/dist/openapi.d.ts +160 -16
  29. package/dist/opencode-stop-plugin.js +384 -0
  30. package/dist/registry-auth.d.ts +5 -0
  31. package/dist/registry-http.d.ts +4 -0
  32. package/dist/sdk/generated.d.ts +32 -12
  33. package/dist/sdk/index.d.ts +28 -5
  34. package/dist/sdk/index.js +49 -24
  35. package/dist/sdk/registry-client.d.ts +1 -1
  36. package/dist/serve.d.ts +4 -4
  37. package/dist/storage.js +33 -2
  38. package/dist/sumi-stop-plugin.js +380 -0
  39. package/hooks/hook-scanoutput/src/hook.ts +33 -3
  40. package/hooks/hook-stop-review/README.md +109 -0
  41. package/hooks/hook-stop-review/manifest.json +10 -0
  42. package/hooks/hook-stop-review/package.json +11 -0
  43. package/hooks/hook-stop-review/src/hook.ts +59 -0
  44. package/hooks/hook-stop-review/src/index.ts +3 -0
  45. package/hooks/hook-stop-review/src/jev.ts +121 -0
  46. package/hooks/hook-stop-review/src/native.ts +246 -0
  47. package/hooks/hook-stop-review/src/policy.ts +145 -0
  48. package/hooks/hook-stop-review/src/runtime.ts +309 -0
  49. package/hooks/hook-stop-review/src/types.ts +121 -0
  50. package/hooks/hook-trash-guard/src/hook.ts +96 -0
  51. package/hooks/hook-workspace-repos-guard/src/hook.ts +231 -3
  52. package/hooks/local-executors.ts +841 -0
  53. package/package.json +22 -4
  54. package/scripts/build-bundled-hooks.ts +40 -0
  55. package/scripts/validate-bundled-hooks.ts +78 -0
  56. package/scripts/validate-opencode-stop-plugin.ts +42 -0
  57. package/scripts/validate-package.ts +9 -0
  58. package/scripts/validate-sumi-stop-plugin.ts +47 -0
@@ -2,7 +2,7 @@ import { type NativeSafetyName } from "./native-safety.js";
2
2
  import { verifyNativeSafetyCommand } from "../native-safety.js";
3
3
  /** Exact `codex --version` outputs whose app-server protocol was measured
4
4
  * against the real native binary. Anything else refuses as native_unsupported. */
5
- export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0"];
5
+ export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0"];
6
6
  export type CodexSafetyCode = "native_unavailable" | "native_unsafe_executable" | "native_executable_required" | "native_unsupported" | "native_failed" | "native_discovery_failed" | "hooks_disabled" | "guard_missing" | "guard_ambiguous" | "guard_definition_invalid" | "guard_disabled" | "guard_untrusted" | "guard_changed" | "guard_failed";
7
7
  export declare class CodexSafetyError extends Error {
8
8
  readonly code: CodexSafetyCode;
@@ -0,0 +1,70 @@
1
+ import { type RegistryArtifact, type RegistrySelection, type RegistryPin } from "./registry-artifact.js";
2
+ import type { PgAdapterAsync } from "../db/remote-storage.js";
3
+ export declare const REGISTRY_MIGRATIONS: readonly ["CREATE TABLE IF NOT EXISTS hooks_registry_versions (name TEXT NOT NULL, version TEXT NOT NULL, bundle_sha256 TEXT NOT NULL, script_sha256 TEXT NOT NULL, artifact_json TEXT NOT NULL, artifact_format TEXT NOT NULL DEFAULT 'portable-v1' CHECK(artifact_format IN ('portable-v1','legacy-raw-v1')), catalog_json TEXT, catalog_sha256 TEXT, published_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), PRIMARY KEY(name, version))", "CREATE TABLE IF NOT EXISTS hooks_registry_selections (profile TEXT NOT NULL, revision INTEGER NOT NULL CHECK(revision > 0), selection_json TEXT NOT NULL, selection_sha256 TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), PRIMARY KEY(profile, revision))", "CREATE TABLE IF NOT EXISTS hooks_registry_legacy_imports (export_sha256 TEXT PRIMARY KEY, manifest_json TEXT NOT NULL, catalog_json TEXT NOT NULL, lock_json TEXT NOT NULL, version_json TEXT NOT NULL, artifact_count INTEGER NOT NULL CHECK(artifact_count > 0), imported_at TIMESTAMPTZ NOT NULL DEFAULT NOW())"];
4
+ export interface RegistryVersion {
5
+ name: string;
6
+ version: string;
7
+ bundle_sha256: string;
8
+ script_sha256: string;
9
+ artifact_json: string;
10
+ artifact_format?: "portable-v1" | "legacy-raw-v1";
11
+ catalog_json?: string | null;
12
+ catalog_sha256?: string | null;
13
+ }
14
+ export interface RegistryStore {
15
+ ready?(): Promise<void>;
16
+ versions(): Promise<RegistryVersion[]>;
17
+ version(name: string, version: string): Promise<RegistryVersion | null>;
18
+ insertVersion(row: RegistryVersion): Promise<boolean>;
19
+ selection(profile: string): Promise<RegistrySelection | null>;
20
+ insertSelection(selection: RegistrySelection, expectedRevision: number): Promise<boolean>;
21
+ }
22
+ export declare class PgRegistryStore implements RegistryStore {
23
+ private readonly db;
24
+ constructor(db: PgAdapterAsync);
25
+ ready(): Promise<void>;
26
+ versions(): Promise<RegistryVersion[]>;
27
+ version(name: string, version: string): Promise<RegistryVersion | null>;
28
+ insertVersion(row: RegistryVersion): Promise<boolean>;
29
+ selection(profile: string): Promise<RegistrySelection | null>;
30
+ insertSelection(selection: RegistrySelection, expectedRevision: number): Promise<boolean>;
31
+ }
32
+ export declare class HostedRegistry {
33
+ private readonly store;
34
+ constructor(store: RegistryStore);
35
+ ready(): Promise<void>;
36
+ publish(value: unknown): Promise<{
37
+ ok: true;
38
+ idempotent: boolean;
39
+ hook: RegistryPin & {
40
+ name: string;
41
+ };
42
+ }>;
43
+ artifact(name: string, version: string): Promise<{
44
+ artifact: RegistryArtifact;
45
+ row: RegistryVersion;
46
+ }>;
47
+ /** Byte-preserving reads are deliberately separate from the portable selection path. */
48
+ artifactWire(name: string, version: string): Promise<{
49
+ body: string;
50
+ row: RegistryVersion;
51
+ format: "portable-v1" | "legacy-raw-v1";
52
+ portable: boolean;
53
+ }>;
54
+ catalog(): Promise<{
55
+ hooks: {
56
+ name: string;
57
+ version: string;
58
+ sha256: string;
59
+ bundle_sha256: string;
60
+ source: string;
61
+ format: string;
62
+ portable: boolean;
63
+ versions: string[];
64
+ description?: string;
65
+ events?: string[];
66
+ }[];
67
+ }>;
68
+ selection(profile: string): Promise<RegistrySelection>;
69
+ select(profile: string, value: unknown): Promise<RegistrySelection>;
70
+ }
@@ -0,0 +1,23 @@
1
+ import type { RegistryVersion } from "./hosted-registry.js";
2
+ export interface LegacyCatalogRow {
3
+ name: string;
4
+ version: string;
5
+ sha256: string;
6
+ versions: string[];
7
+ source: string;
8
+ description?: string;
9
+ events?: string[];
10
+ [key: string]: unknown;
11
+ }
12
+ export declare function validateLegacyArtifact(wire: string, name: string, version: string, expectedScript: string): {
13
+ manifest: Record<string, unknown>;
14
+ script: string;
15
+ };
16
+ export declare function validateLegacyCatalog(value: unknown): LegacyCatalogRow;
17
+ export declare function readLegacyRegistryRow(row: RegistryVersion): {
18
+ artifact: {
19
+ manifest: Record<string, unknown>;
20
+ script: string;
21
+ };
22
+ catalog: LegacyCatalogRow;
23
+ };
@@ -17,6 +17,8 @@ export declare const manifestSchema: z.ZodObject<{
17
17
  */
18
18
  script_kind: z.ZodOptional<z.ZodEnum<["inline", "file"]>>;
19
19
  args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ /** Request trusted native target dispatch as --harness, never from stdin. */
21
+ nativeTargetDispatch: z.ZodOptional<z.ZodBoolean>;
20
22
  timeout_ms: z.ZodOptional<z.ZodNumber>;
21
23
  /**
22
24
  * Per-hook environment passed to the hook child (reviewer efcad315).
@@ -36,6 +38,7 @@ export declare const manifestSchema: z.ZodObject<{
36
38
  description?: string | undefined;
37
39
  script_kind?: "inline" | "file" | undefined;
38
40
  args?: string[] | undefined;
41
+ nativeTargetDispatch?: boolean | undefined;
39
42
  timeout_ms?: number | undefined;
40
43
  }, {
41
44
  version: string;
@@ -46,6 +49,7 @@ export declare const manifestSchema: z.ZodObject<{
46
49
  description?: string | undefined;
47
50
  script_kind?: "inline" | "file" | undefined;
48
51
  args?: string[] | undefined;
52
+ nativeTargetDispatch?: boolean | undefined;
49
53
  timeout_ms?: number | undefined;
50
54
  }>;
51
55
  export type HookManifest = z.infer<typeof manifestSchema>;
@@ -94,6 +98,9 @@ export declare function resolveScript(manifest: HookManifest, manifestDir: strin
94
98
  path: string;
95
99
  content: string;
96
100
  };
101
+ export declare class HookIdentityError extends Error {
102
+ constructor();
103
+ }
97
104
  export declare function customHookDir(name: string): string;
98
105
  export declare function readCustomManifest(name: string): ParsedManifest | undefined;
99
106
  export declare function listCustomHooks(): ParsedManifest[];
@@ -12,6 +12,7 @@ export declare function isNativeSafetyName(name: string): name is NativeSafetyNa
12
12
  export declare function buildNativeSafetyCommand(binding: NativeSafetyBinding): string;
13
13
  export declare function nativeSafetyRegistration(command: string): NativeSafetyName | undefined;
14
14
  export declare function nativeSafetyCommandBinding(command: string): NativeSafetyBinding | undefined;
15
+ export declare function pinEligibleFile(file: string, maximum: number, executable?: boolean): string;
15
16
  /** Whether a saved supervisor command's pinned runtime and worker still verify
16
17
  * on disk. `undefined` means the command is not a native-safety binding at all.
17
18
  * Read-only: it never registers, rewrites or executes anything. */
@@ -0,0 +1,7 @@
1
+ /** Trusted invocation metadata, supplied by a native registration or plugin, never hook stdin. */
2
+ export declare const HOOK_RUN_TARGETS: readonly ["claude", "codex", "gemini", "codewith", "sumi", "opencode"];
3
+ export type HookRunTarget = typeof HOOK_RUN_TARGETS[number];
4
+ export declare function isHookRunTarget(value: unknown): value is HookRunTarget;
5
+ /** Existing hooks keep their arguments verbatim. Opted-in hooks require explicit native dispatch. */
6
+ export declare function nativeTargetArgs(dispatch: boolean | undefined, target: unknown, args?: readonly string[]): string[];
7
+ export declare function nativeTargetCommandSuffix(dispatch: boolean | undefined, target: unknown): string;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Transport-only native OpenCode plugin. A patched OpenCode host owns all
3
+ * session state and the final guarded admission; this plugin pipes the host's
4
+ * envelope to the pinned Hooks CLI and returns its recommendation, which the
5
+ * host validates again before admitting anything.
6
+ *
7
+ * OpenCode loads the default export from its config:
8
+ * "plugin": [["file:///<retained Hooks runtime>/dist/opencode-stop-plugin.js", {
9
+ * "schema": "hasna.hooks.opencode-stop-plugin.v1",
10
+ * "hooksCommand": "...", "hooksCommandSha256": "...",
11
+ * "runtimeCommand": "...", "runtimeCommandSha256": "..." }]]
12
+ * `hooks install stop-review --target opencode` writes that entry.
13
+ *
14
+ * Stock OpenCode advertises no stop-review capability, so registration fails
15
+ * closed there and no review or continuation ever happens.
16
+ */
17
+ import { type SumiStopPluginDependencies, type SumiStopPluginOptions } from "./sumi-stop-plugin.js";
18
+ export declare const OPENCODE_STOP_PLUGIN_ID: "hasna-hooks-stop-review";
19
+ /** Marks the installer-owned plugin entry in an OpenCode config. */
20
+ export declare const OPENCODE_STOP_PLUGIN_SCHEMA: "hasna.hooks.opencode-stop-plugin.v1";
21
+ export declare const OPENCODE_STOP_HOOK: "experimental.session.stop";
22
+ export interface OpenCodeStopReviewCapability {
23
+ readonly schema: "hooks.stop-review.v1";
24
+ readonly admission: "parent_final_cas";
25
+ readonly harness: "opencode";
26
+ readonly hook: typeof OPENCODE_STOP_HOOK;
27
+ readonly maxContinuations: 1;
28
+ }
29
+ export interface OpenCodeStopPluginOptions extends SumiStopPluginOptions {
30
+ schema?: typeof OPENCODE_STOP_PLUGIN_SCHEMA;
31
+ plugin?: string;
32
+ pluginSha256?: string;
33
+ }
34
+ export type OpenCodeStopPluginDependencies = SumiStopPluginDependencies;
35
+ export interface OpenCodeStopReviewHooks {
36
+ [OPENCODE_STOP_HOOK]: (envelope: unknown, output: {
37
+ recommendation?: unknown;
38
+ }) => Promise<void>;
39
+ }
40
+ /** The read-only `PluginInput.experimental_stop_review` a guarded host passes. */
41
+ export declare function isOpenCodeStopReviewCapability(v: unknown): v is OpenCodeStopReviewCapability;
42
+ export declare function createOpenCodeStopReviewPlugin(options: OpenCodeStopPluginOptions, dependencies?: OpenCodeStopPluginDependencies): {
43
+ id: "hasna-hooks-stop-review";
44
+ server(input: {
45
+ experimental_stop_review?: unknown;
46
+ } | undefined): Promise<OpenCodeStopReviewHooks>;
47
+ };
48
+ /** OpenCode plugin module: the host passes the config entry's options as the second argument. */
49
+ declare const _default: {
50
+ id: "hasna-hooks-stop-review";
51
+ server: (input: {
52
+ experimental_stop_review?: unknown;
53
+ } | undefined, options?: Record<string, unknown>) => Promise<OpenCodeStopReviewHooks>;
54
+ };
55
+ export default _default;
@@ -0,0 +1,36 @@
1
+ export interface RegistryArtifact {
2
+ manifest: {
3
+ name: string;
4
+ version: string;
5
+ events: string[];
6
+ script: string;
7
+ script_kind: "file";
8
+ description?: string;
9
+ args?: string[];
10
+ timeout_ms?: number;
11
+ nativeTargetDispatch?: boolean;
12
+ };
13
+ script: string;
14
+ }
15
+ export interface RegistryPin {
16
+ version: string;
17
+ sha256: string;
18
+ bundle_sha256: string;
19
+ source: string;
20
+ }
21
+ export interface RegistrySelection {
22
+ profile: string;
23
+ revision: number;
24
+ hooks: Record<string, RegistryPin>;
25
+ }
26
+ export declare class RegistryError extends Error {
27
+ readonly status: number;
28
+ readonly code: string;
29
+ constructor(status: number, code: string);
30
+ }
31
+ export declare const REGISTRY_NAME: RegExp;
32
+ export declare const REGISTRY_MAX_BYTES: number;
33
+ export declare function canonicalJson(value: unknown): string;
34
+ export declare function registryDigest(value: unknown): string;
35
+ export declare function scriptDigest(script: string): string;
36
+ export declare function validateRegistryArtifact(value: unknown): RegistryArtifact;
@@ -4,6 +4,10 @@
4
4
  export type HookEvent = "PreToolUse" | "PostToolUse" | "Stop" | "Notification" | "SessionStart" | "SessionEnd" | "UserPromptSubmit" | "SubagentStart";
5
5
  export declare const HOOK_EVENTS: HookEvent[];
6
6
  export interface HookMeta {
7
+ /** Package-relative, build-owned execution bundle; missing output fails closed. */
8
+ bundledEntry?: string;
9
+ /** Requires the owning runner to pass the installer-selected native target. */
10
+ nativeTargetDispatch?: boolean;
7
11
  name: string;
8
12
  displayName: string;
9
13
  description: string;
@@ -0,0 +1,12 @@
1
+ /** Non-secret resolver intent shared by both native transports and hook children.
2
+ * No credential resolution, filesystem access, network or provider dependency.
3
+ */
4
+ type Environment = Readonly<Record<string, string | undefined>>;
5
+ export declare const HOOK_CLIENT_CONFIG_PROJECTIONS: ReadonlyArray<readonly [string, string]>;
6
+ /** Reserved carrier names are emitted only by this module, never copied raw. */
7
+ export declare function isStopReviewContextCarrier(name: string): boolean;
8
+ export declare function projectStopReviewClientContext(source: Environment, extra?: Environment): Record<string, string>;
9
+ export declare function stopReviewClientContextRefused(source: Environment): boolean;
10
+ /** Rehydrate only selected non-secret context for the trusted owning consumer. */
11
+ export declare function restoreStopReviewClientContext(source: Environment): Record<string, string>;
12
+ export {};
@@ -18,6 +18,8 @@ export interface HookRecord {
18
18
  last_verified_at: string | null;
19
19
  }
20
20
  export interface LockEntry {
21
+ bundle_sha256?: string;
22
+ manifest_sha256?: string;
21
23
  version: string;
22
24
  sha256: string;
23
25
  source: string;
@@ -59,6 +61,8 @@ export declare function readLock(): LockFile;
59
61
  export declare function writeLock(lock: LockFile): string;
60
62
  export declare function setPinnedHook(name: string, entry: LockEntry): string;
61
63
  export declare function getPinnedHook(name: string): LockEntry | undefined;
64
+ /** Durable provenance precedes any remote execution bytes; TOFU cannot clear it. */
65
+ export declare function markRegistryManaged(name: string): void;
62
66
  export declare function removePinnedHook(name: string): boolean;
63
67
  /**
64
68
  * Pin a hook at install time — the ACTUAL installed version and sha, so the
@@ -0,0 +1,129 @@
1
+ export interface SumiStopReviewEnvelope {
2
+ schema: "hooks.stop-review.v1";
3
+ sessionId: string;
4
+ turnId: string;
5
+ inputRevision: string;
6
+ capturedAt: string;
7
+ lastUserPrompt: string;
8
+ lastAssistantMessage: string;
9
+ goal?: {
10
+ id: string;
11
+ objective: string;
12
+ status: "active" | "complete" | "paused" | "cancelled" | "blocked" | "budget_limited" | "usage_limited" | "unknown";
13
+ } | null;
14
+ goalAvailability?: "known" | "unavailable";
15
+ runtime: {
16
+ stopReason: "end_turn" | "user_stop" | "cancelled" | "error" | "approval_wait" | "budget_limit" | "usage_limit" | "unknown";
17
+ userRequestedStop: boolean;
18
+ terminal: boolean;
19
+ paused: boolean;
20
+ budgetExhausted: boolean;
21
+ usageLimited: boolean;
22
+ awaitingApproval: boolean;
23
+ nativeContinuationAllowed: boolean;
24
+ stopHookActive: boolean;
25
+ continuationCount: number;
26
+ };
27
+ }
28
+ export type SumiStopClassification = "complete" | "actionable_remaining" | "blocked_permission" | "blocked_external" | "blocked_environment" | "needs_user_input" | "uncertain";
29
+ export interface SumiStopReviewResult {
30
+ schema: "hooks.stop-review-result.v1";
31
+ action: "allow_stop" | "continue" | "unavailable";
32
+ reason: string;
33
+ sessionId: string;
34
+ turnId: string;
35
+ inputRevision: string;
36
+ classification?: SumiStopClassification;
37
+ assessment?: {
38
+ classification: SumiStopClassification;
39
+ confidence: number;
40
+ probabilities: Record<SumiStopClassification, number>;
41
+ actionableProbability: number;
42
+ boundaryProbability: number;
43
+ model: string;
44
+ inputTokens: number;
45
+ outputTokens: number;
46
+ };
47
+ instruction?: {
48
+ sourceId: string;
49
+ version: number;
50
+ digest: string;
51
+ };
52
+ continuationPrompt?: string;
53
+ httpStatus?: number;
54
+ admission: {
55
+ mode: "parent_final_cas";
56
+ harness: "sumi";
57
+ settlement: "complete" | "blocked" | "none";
58
+ };
59
+ }
60
+ /** Native harnesses whose parent performs the final guarded admission. */
61
+ export type ParentStopReviewHarness = "sumi" | "opencode";
62
+ /** The same certificate with the admitting harness named. */
63
+ export type ParentStopReviewResult = Omit<SumiStopReviewResult, "admission"> & {
64
+ admission: {
65
+ mode: "parent_final_cas";
66
+ harness: ParentStopReviewHarness;
67
+ settlement: "complete" | "blocked" | "none";
68
+ };
69
+ };
70
+ export interface SumiStopReviewEvent {
71
+ envelope: SumiStopReviewEnvelope;
72
+ result?: SumiStopReviewResult;
73
+ }
74
+ export interface SumiStopPluginContext {
75
+ session: {
76
+ stopReview?: unknown;
77
+ hook(name: "stop", callback: (event: SumiStopReviewEvent) => Promise<void>): unknown;
78
+ };
79
+ }
80
+ export interface SumiStopPluginOptions {
81
+ /** Installer-resolved retained CLI bundle, never a PATH name or mutable symlink. */
82
+ hooksCommand: string;
83
+ /** CLI and interpreter pins are separate from the package/plugin artifact pin. */
84
+ hooksCommandSha256: string;
85
+ runtimeCommand: string;
86
+ runtimeCommandSha256: string;
87
+ timeoutMs?: number;
88
+ }
89
+ export interface SumiStopReviewCommand {
90
+ command: string;
91
+ args: string[];
92
+ input: string;
93
+ env: Record<string, string>;
94
+ timeoutMs: number;
95
+ maxOutputBytes: number;
96
+ }
97
+ export interface SumiStopReviewCommandResult {
98
+ ok: boolean;
99
+ stdout?: string;
100
+ }
101
+ export type SumiStopReviewRunner = (command: SumiStopReviewCommand) => Promise<SumiStopReviewCommandResult>;
102
+ /** Dependency injection supports hermetic transport tests without model requests. */
103
+ export interface SumiStopPluginDependencies {
104
+ run?: SumiStopReviewRunner;
105
+ environment?: () => Readonly<Record<string, string | undefined>>;
106
+ }
107
+ /** Reject unknown fields so no extra event context is disclosed to a child. */
108
+ export declare function isSumiStopReviewEnvelope(v: unknown): v is SumiStopReviewEnvelope;
109
+ /** Validate the complete transport certificate; only Sumi may act on it. */
110
+ export declare function isSumiStopReviewResult(v: unknown, envelope: SumiStopReviewEnvelope): v is SumiStopReviewResult;
111
+ /** The same certificate for any parent-guarded native harness; only the named harness may act on it. */
112
+ export declare function isParentStopReviewResult(v: unknown, envelope: SumiStopReviewEnvelope, harness: ParentStopReviewHarness): boolean;
113
+ /** Readback pin check, including non-writable owner-controlled path components. */
114
+ export declare function verifySumiStopReviewCommand(command: string, expected: string): boolean;
115
+ /** Bounded pipes; only the fresh direct child is ever signaled, never a group. */
116
+ export declare const runSumiStopReviewCommand: SumiStopReviewRunner;
117
+ /**
118
+ * One recommendation from the pinned Hooks CLI for a parent-guarded harness.
119
+ * Never throws: every refusal is an `unavailable` result bound to the envelope,
120
+ * and no native diagnostics, prompt bytes, paths or secrets leave this call.
121
+ * The caller validated the envelope and owns any further native admission.
122
+ */
123
+ export declare function requestParentStopReview(envelope: SumiStopReviewEnvelope, harness: ParentStopReviewHarness, pins: Required<SumiStopPluginOptions>, dependencies?: SumiStopPluginDependencies): Promise<ParentStopReviewResult>;
124
+ /** Validate installer-resolved pins once for every parent-guarded transport. */
125
+ export declare function parentStopReviewPins(options: SumiStopPluginOptions, harness: ParentStopReviewHarness, maxTimeoutMs?: number): Required<SumiStopPluginOptions>;
126
+ export declare function createSumiStopReviewPlugin(options: SumiStopPluginOptions, dependencies?: SumiStopPluginDependencies): {
127
+ id: "local.hasna-hooks-stop-review";
128
+ setup(ctx: SumiStopPluginContext): Promise<void>;
129
+ };
@@ -12,6 +12,8 @@ import { parseManifest } from "./manifest.js";
12
12
  type Env = Record<string, string | undefined>;
13
13
  export interface HooksSyncOptions {
14
14
  dryRun?: boolean;
15
+ selectionProfile?: string;
16
+ expectedRevision?: number;
15
17
  /** Injectable environment (tests). Defaults to `process.env`. */
16
18
  env?: Env;
17
19
  /** Injectable credential-chain inputs (tests: fake `security` runner). */
@@ -27,6 +29,10 @@ export interface SyncPlan {
27
29
  apiUrl: string | null;
28
30
  dryRun: boolean;
29
31
  diff: SyncDiff;
32
+ selection?: {
33
+ profile: string;
34
+ revision: number;
35
+ };
30
36
  }
31
37
  export interface ArtifactResponse {
32
38
  manifest: {
@@ -38,13 +44,17 @@ export interface ArtifactResponse {
38
44
  script_kind?: "inline" | "file";
39
45
  args?: string[];
40
46
  timeout_ms?: number;
47
+ nativeTargetDispatch?: boolean;
41
48
  };
42
49
  script: string;
43
50
  }
44
51
  interface RemoteLock {
52
+ profile?: string;
53
+ revision?: number;
45
54
  hooks: Record<string, {
46
55
  version: string;
47
56
  sha256: string;
57
+ bundle_sha256?: string;
48
58
  source: string;
49
59
  versions?: string[];
50
60
  }>;
@@ -5,7 +5,7 @@ export type HooksTransportMode = "remote" | "local";
5
5
  export interface HooksRemoteAuthority {
6
6
  /**
7
7
  * Registry origin WITHOUT the `/v1` suffix the resolver appends — the sync
8
- * client composes `/api/v1/...` routes on top of it.
8
+ * client composes `/v1/...` routes on top of it.
9
9
  */
10
10
  origin: string;
11
11
  /** Literal credential, or empty for a vault reference. Requests use resolveHooksRequestAuthority(). */
@@ -20,7 +20,7 @@ export interface TrashReadinessBinding {
20
20
  plan: Pin;
21
21
  timeoutMs: number;
22
22
  }
23
- export type ReadinessCode = "ready" | "binding_missing" | "binding_invalid" | "unsafe_path" | "file_changed" | "package_mismatch" | "plan_invalid" | "deadline_exceeded" | "execution_failed" | "output_invalid" | "unsupported_platform" | "station_detection_failed" | "station_mismatch" | "retention_mismatch" | "hosted_unavailable" | "authentication_refused" | "station_setup_required" | "invalid_status" | "managed_instructions_refused" | "removal_instruction_missing" | "native_config_changed" | "instructions_changed" | "guard_refused" | "owner_refused" | "check_failed" | "input_invalid";
23
+ export type ReadinessCode = "ready" | "binding_missing" | "binding_invalid" | "unsafe_path" | "file_changed" | "package_mismatch" | "plan_invalid" | "deadline_exceeded" | "execution_failed" | "output_invalid" | "unsupported_platform" | "station_detection_failed" | "station_mismatch" | "retention_mismatch" | "hosted_unavailable" | "authentication_refused" | "station_setup_required" | "invalid_status" | "managed_instructions_refused" | "removal_instruction_missing" | "native_config_changed" | "instructions_changed" | "guard_refused" | "owner_refused" | "check_failed" | "input_invalid" | "native_executable_changed" | "runtime_changed" | "installed_cli_changed" | "plan_changed";
24
24
  export interface TrashReadinessResult {
25
25
  schema: "hasna.hooks.trash-readiness-result/v1";
26
26
  provider: ReadinessProvider;
@@ -228,7 +228,11 @@ var safeFailureCodes = new Set([
228
228
  "instructions_changed",
229
229
  "native_config_changed",
230
230
  "guard_refused",
231
- "owner_refused"
231
+ "owner_refused",
232
+ "native_executable_changed",
233
+ "runtime_changed",
234
+ "installed_cli_changed",
235
+ "plan_changed"
232
236
  ]);
233
237
  async function runTrashReadiness(provider, d = {}) {
234
238
  const started = performance.now();