@ory/antigravity 0.10.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.
package/dist/hook.js ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Google Antigravity hook entry point.
5
+ *
6
+ * Antigravity invokes this script as a subprocess for each hook event.
7
+ * Input: JSON on stdin.
8
+ * Output: JSON on stdout.
9
+ *
10
+ * FAIL-CLOSED CONTRACT (the reason this differs from every other plugin):
11
+ * on a `PreToolUse` event, Antigravity blocks the tool unless the hook
12
+ * returns `{"allow_tool": true}`. A crash, a timeout, malformed output, or
13
+ * a non-zero exit are all treated as "block". To preserve this repo's
14
+ * fail-open guarantee, EVERY error path here emits `{"allow_tool": true}`
15
+ * and exits 0 — a transient Ory/network failure must never wedge the
16
+ * user's tools. Emitting `allow_tool` on non-tool events is harmless
17
+ * (the harness ignores it), so the safe default works for all events.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const argus_1 = require("@ory/argus");
21
+ const handlers_js_1 = require("./handlers.js");
22
+ /** The fail-open response: explicitly allow, so a crash never blocks. */
23
+ const FAIL_OPEN = { allow_tool: true };
24
+ /**
25
+ * Read all of stdin as a string. Uses event listeners (not `for await`)
26
+ * with an idle timer so we don't hang if the parent never sends EOF.
27
+ */
28
+ function readStdin() {
29
+ return new Promise((resolve, reject) => {
30
+ const chunks = [];
31
+ let resolved = false;
32
+ let idleTimer;
33
+ function done() {
34
+ if (!resolved) {
35
+ resolved = true;
36
+ resolve(Buffer.concat(chunks).toString("utf-8"));
37
+ }
38
+ }
39
+ process.stdin.on("data", (chunk) => {
40
+ chunks.push(chunk);
41
+ clearTimeout(idleTimer);
42
+ idleTimer = setTimeout(done, 100);
43
+ });
44
+ process.stdin.on("end", done);
45
+ process.stdin.on("error", (err) => {
46
+ if (!resolved) {
47
+ resolved = true;
48
+ reject(err);
49
+ }
50
+ });
51
+ });
52
+ }
53
+ async function main() {
54
+ const client = argus_1.OryAgentClient.fromEnv("antigravity");
55
+ const raw = await readStdin();
56
+ let input;
57
+ try {
58
+ input = JSON.parse(raw);
59
+ }
60
+ catch {
61
+ client.logger.error("hook.stdin.parse_failed", { raw: raw.slice(0, 200) });
62
+ // Can't tell the event; allow to avoid wedging a PreToolUse call.
63
+ process.stdout.write(JSON.stringify(FAIL_OPEN));
64
+ await client.tracer.shutdown();
65
+ process.exit(0);
66
+ }
67
+ let output;
68
+ try {
69
+ output = await (0, handlers_js_1.handleHookEvent)(input, client);
70
+ }
71
+ catch (err) {
72
+ client.logger.error("hook.handler.error", {
73
+ event: input.hook_event_name,
74
+ message: err instanceof Error ? err.message : String(err),
75
+ });
76
+ output = FAIL_OPEN;
77
+ }
78
+ process.stdout.write(JSON.stringify(output));
79
+ await client.tracer.shutdown();
80
+ process.exit(0);
81
+ }
82
+ main().catch((err) => {
83
+ // Last-resort guard: allow rather than block, then exit cleanly.
84
+ process.stderr.write(`[ory-agent] fatal: ${err}\n`);
85
+ process.stdout.write(JSON.stringify(FAIL_OPEN));
86
+ process.exit(0);
87
+ });
@@ -0,0 +1,4 @@
1
+ export { handleHookEvent } from "./handlers.js";
2
+ export type { HandleHookEventDeps } from "./handlers.js";
3
+ export type { AntigravityHookInput, AntigravityHookOutput } from "./types.js";
4
+ export { installAntigravityOryAssets, uninstallAntigravityOryAssets, } from "./cli/assets.js";
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uninstallAntigravityOryAssets = exports.installAntigravityOryAssets = exports.handleHookEvent = void 0;
4
+ var handlers_js_1 = require("./handlers.js");
5
+ Object.defineProperty(exports, "handleHookEvent", { enumerable: true, get: function () { return handlers_js_1.handleHookEvent; } });
6
+ var assets_js_1 = require("./cli/assets.js");
7
+ Object.defineProperty(exports, "installAntigravityOryAssets", { enumerable: true, get: function () { return assets_js_1.installAntigravityOryAssets; } });
8
+ Object.defineProperty(exports, "uninstallAntigravityOryAssets", { enumerable: true, get: function () { return assets_js_1.uninstallAntigravityOryAssets; } });
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Google Antigravity (`agy` CLI / IDE) hook contract.
3
+ *
4
+ * Verified against `agy 1.0.13`: hooks run as subprocesses, receive a
5
+ * JSON payload on stdin, and emit a JSON response on stdout. The payload
6
+ * uses Claude-Code-style snake_case field names (`tool_name`,
7
+ * `tool_input`, `session_id`, `transcript_path`, `hook_event_name`).
8
+ *
9
+ * IMPORTANT — Antigravity hooks FAIL CLOSED. On a `PreToolUse` event, a
10
+ * hook that crashes, times out, or omits `allow_tool` BLOCKS the tool
11
+ * call. This is the inverse of every other harness in this repo, so the
12
+ * hook entry point must always emit `{ "allow_tool": true }` (and exit 0)
13
+ * on any allow/error path. See `hook.ts`.
14
+ */
15
+ /** Hook event names emitted by Antigravity. */
16
+ export type AntigravityHookEvent = "SessionStart" | "SessionEnd" | "PreToolUse" | "PostToolUse" | "PreInvocation" | "PostInvocation" | "Stop" | "Notification" | string;
17
+ /**
18
+ * Hook event payload delivered on stdin. Field availability depends on
19
+ * `hook_event_name`; everything past the first two is optional.
20
+ */
21
+ export interface AntigravityHookInput {
22
+ hook_event_name: AntigravityHookEvent;
23
+ session_id: string;
24
+ /** Path to the conversation transcript for this session. */
25
+ transcript_path?: string;
26
+ /** Workspace roots for the session. */
27
+ workspace_paths?: string[];
28
+ /** Current working directory, when provided. */
29
+ cwd?: string;
30
+ /** Tool the agent is about to run (or just ran). */
31
+ tool_name?: string;
32
+ /** Arguments passed to the tool. */
33
+ tool_input?: Record<string, unknown>;
34
+ /** Tool result, on PostToolUse. */
35
+ tool_response?: Record<string, unknown>;
36
+ /** Tool error payload, when a tool failed. */
37
+ tool_error?: unknown;
38
+ model?: string;
39
+ /** SessionStart source: startup | resume | ... */
40
+ source?: string;
41
+ /** Termination reason. */
42
+ reason?: string;
43
+ /** Free-form notification / permission-prompt message. */
44
+ message?: string;
45
+ [key: string]: unknown;
46
+ }
47
+ /**
48
+ * Hook response written to stdout.
49
+ *
50
+ * On `PreToolUse`, `allow_tool` is authoritative:
51
+ * - `allow_tool: true` → the tool runs.
52
+ * - `allow_tool: false` → the tool is blocked; `deny_reason` is shown.
53
+ * - omitted / invalid → Antigravity FAILS CLOSED and blocks the tool.
54
+ *
55
+ * For non-tool events, an empty object (or no output) is fine.
56
+ */
57
+ export interface AntigravityHookOutput {
58
+ /** PreToolUse gate decision. Always set it explicitly on PreToolUse. */
59
+ allow_tool?: boolean;
60
+ /** Human-readable reason shown when `allow_tool` is false. */
61
+ deny_reason?: string;
62
+ /** Optional audit/log message surfaced by the harness. */
63
+ system_message?: string;
64
+ }
package/dist/types.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Google Antigravity (`agy` CLI / IDE) hook contract.
4
+ *
5
+ * Verified against `agy 1.0.13`: hooks run as subprocesses, receive a
6
+ * JSON payload on stdin, and emit a JSON response on stdout. The payload
7
+ * uses Claude-Code-style snake_case field names (`tool_name`,
8
+ * `tool_input`, `session_id`, `transcript_path`, `hook_event_name`).
9
+ *
10
+ * IMPORTANT — Antigravity hooks FAIL CLOSED. On a `PreToolUse` event, a
11
+ * hook that crashes, times out, or omits `allow_tool` BLOCKS the tool
12
+ * call. This is the inverse of every other harness in this repo, so the
13
+ * hook entry point must always emit `{ "allow_tool": true }` (and exit 0)
14
+ * on any allow/error path. See `hook.ts`.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@ory/antigravity",
3
+ "version": "0.10.0",
4
+ "description": "Ory plugin for Google Antigravity: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/ory/ory-agent-plugins/tree/main/packages/antigravity",
7
+ "bugs": {
8
+ "url": "https://github.com/ory/ory-agent-plugins/issues"
9
+ },
10
+ "keywords": [
11
+ "ory",
12
+ "antigravity",
13
+ "google-antigravity",
14
+ "agy",
15
+ "gemini",
16
+ "hooks",
17
+ "plugin",
18
+ "identity",
19
+ "identity-management",
20
+ "iam",
21
+ "authentication",
22
+ "authorization",
23
+ "access-control",
24
+ "permissions",
25
+ "rbac",
26
+ "zanzibar",
27
+ "oauth",
28
+ "oauth2",
29
+ "openid-connect",
30
+ "oidc",
31
+ "session",
32
+ "mfa",
33
+ "sso",
34
+ "audit",
35
+ "audit-log",
36
+ "compliance",
37
+ "agent",
38
+ "ai-agent",
39
+ "agent-security",
40
+ "guardrails",
41
+ "llm",
42
+ "mcp",
43
+ "mcp-server",
44
+ "tracing",
45
+ "distributed-tracing",
46
+ "observability",
47
+ "kratos",
48
+ "keto",
49
+ "hydra"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "registry": "https://registry.npmjs.org/",
54
+ "provenance": true
55
+ },
56
+ "main": "dist/index.js",
57
+ "types": "dist/index.d.ts",
58
+ "exports": {
59
+ ".": {
60
+ "types": "./dist/index.d.ts",
61
+ "default": "./dist/index.js"
62
+ }
63
+ },
64
+ "bin": {
65
+ "ory-antigravity": "dist/cli/main.js",
66
+ "ory-antigravity-hook": "dist/hook.js",
67
+ "ory-antigravity-setup": "dist/cli/setup.js"
68
+ },
69
+ "files": [
70
+ "dist",
71
+ "!dist/dev",
72
+ "!dist/**/*.tsbuildinfo"
73
+ ],
74
+ "dependencies": {
75
+ "@ory/argus": "0.10.0"
76
+ },
77
+ "devDependencies": {
78
+ "typescript": "^6.0.2",
79
+ "vitest": "4.1.4"
80
+ },
81
+ "engines": {
82
+ "node": ">=22"
83
+ },
84
+ "scripts": {
85
+ "build": "tsc",
86
+ "clean": "rm -rf dist *.tsbuildinfo",
87
+ "test": "vitest run",
88
+ "test:watch": "vitest",
89
+ "typecheck": "tsc --noEmit",
90
+ "dev": "node dist/dev/launcher.js"
91
+ }
92
+ }