@ory/vercel-ai 0.13.9 → 1.0.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/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Ory Agent Security for the [Vercel AI SDK](https://ai-sdk.dev).
4
4
 
5
- Wraps your tools so every call is authorized against Ory Permissions, traced, and tied to
6
- the user → agent identity — built on [`@ory/argus`](../core).
5
+ Wraps your tools so every call is authorized against Ory Permissions, audited, and tied to
6
+ the user → agent identity — built on [`@ory/argus`](https://www.npmjs.com/package/@ory/argus).
7
7
 
8
8
  ```bash
9
9
  npm install @ory/vercel-ai
@@ -22,9 +22,9 @@ const result = await generateText({
22
22
 
23
23
  The Vercel AI SDK has no global before-tool hook — enforcement lives at the tool boundary, so
24
24
  `withOry` wraps each tool's `execute`. On the first call it runs the Ory session gates; on
25
- each call it authorizes the tool and records spans. In **enforce** mode
26
- (`ORY_PERMISSION_MODE=enforce`) a denied tool throws, surfacing to the model as a tool error;
27
- in **observe** mode (default) the tool runs and a `permission.observe_deny` span is recorded.
25
+ each call it authorizes the tool and records activity. In **enforce** mode a denied
26
+ tool throws, surfacing to the model as a tool error;
27
+ in **observe** mode (default) the tool runs and a `permission.observe_deny` activity event is recorded.
28
28
  Tools without an `execute` (provider-defined) pass through untouched.
29
29
 
30
30
  Derive the permission subject from per-call context with `subjectFromOptions`. A non-empty
@@ -38,4 +38,3 @@ withOry(tools, { subjectFromOptions: (o) => o?.experimental_context?.userId });
38
38
 
39
39
  This package depends only on `@ory/argus` — not the `ai` package; tools are duck-typed so any
40
40
  `ai` version works. Credentials come from the shared `~/.config/ory-agent-plugins/config.json`.
41
- See [docs/sdk-integrations.md](../../docs/sdk-integrations.md).
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * The Vercel AI SDK has no global before-tool hook — enforcement lives at the tool
5
5
  * boundary. {@link withOry} wraps each tool's `execute` so every call is authorized against
6
- * Ory Permissions, traced, and (on first call) preceded by the Ory session gates. A denied
6
+ * Ory Permissions, recorded as activity, and (on first call) preceded by the Ory session gates. A denied
7
7
  * tool in enforce mode throws, surfacing to the model as a tool error; in observe mode the
8
- * tool runs and a `permission.observe_deny` span is recorded.
8
+ * tool runs and a `permission.observe_deny` activity event is recorded.
9
9
  *
10
10
  * This package depends only on `@ory/argus` — the Vercel `ai` package is not a dependency;
11
11
  * tools are duck-typed so any `ai` version works.
package/dist/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * The Vercel AI SDK has no global before-tool hook — enforcement lives at the tool
6
6
  * boundary. {@link withOry} wraps each tool's `execute` so every call is authorized against
7
- * Ory Permissions, traced, and (on first call) preceded by the Ory session gates. A denied
7
+ * Ory Permissions, recorded as activity, and (on first call) preceded by the Ory session gates. A denied
8
8
  * tool in enforce mode throws, surfacing to the model as a tool error; in observe mode the
9
- * tool runs and a `permission.observe_deny` span is recorded.
9
+ * tool runs and a `permission.observe_deny` activity event is recorded.
10
10
  *
11
11
  * This package depends only on `@ory/argus` — the Vercel `ai` package is not a dependency;
12
12
  * tools are duck-typed so any `ai` version works.
@@ -26,23 +26,10 @@ const HARNESS = "vercel-ai";
26
26
  function withOry(tools, options = {}) {
27
27
  const client = options.client ?? argus_1.OryAgentClient.fromEnv(HARNESS);
28
28
  const canBlock = options.canBlock ?? true;
29
- let sessionPromise;
30
- // Cache the in-flight promise (not a boolean) so concurrent first calls all
31
- // await the same session start instead of racing past a still-running gate.
32
- // Fail-open: a rejection is logged, never rethrown, and clears the cache so
33
- // a later call can retry.
34
- const ensureSession = () => {
35
- sessionPromise ??= (0, argus_1.sessionStart)(client, {
36
- harness: HARNESS,
37
- projectUrl: options.projectUrl,
38
- }).then(() => undefined, (err) => {
39
- sessionPromise = undefined;
40
- client.logger.warn("session_start.failed", {
41
- message: err instanceof Error ? err.message : String(err),
42
- });
43
- });
44
- return sessionPromise;
45
- };
29
+ const ensureSession = (0, argus_1.createSessionStarter)(client, {
30
+ harness: HARNESS,
31
+ projectUrl: options.projectUrl,
32
+ });
46
33
  const wrapped = {};
47
34
  for (const [name, tool] of Object.entries(tools)) {
48
35
  if (!tool || typeof tool.execute !== "function") {
@@ -69,9 +56,15 @@ function withOry(tools, options = {}) {
69
56
  namespace: result.namespace,
70
57
  });
71
58
  }
72
- const output = await originalExecute(input, callOptions);
73
- (0, argus_1.complete)(client, { toolName: name, output });
74
- return output;
59
+ try {
60
+ const output = await originalExecute(input, callOptions);
61
+ (0, argus_1.complete)(client, { toolName: name, input, output });
62
+ return output;
63
+ }
64
+ catch (error) {
65
+ (0, argus_1.fail)(client, { toolName: name, input, error });
66
+ throw error;
67
+ }
75
68
  },
76
69
  };
77
70
  }
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@ory/vercel-ai",
3
- "version": "0.13.9",
4
- "description": "Ory Agent Security for the Vercel AI SDK — per-tool authorization, tracing, and identity propagation by wrapping tool execute(). Built on @ory/argus.",
3
+ "version": "1.0.0",
4
+ "description": "Ory Agent Security for the Vercel AI SDK — per-tool authorization, activity auditing, and identity propagation by wrapping tool execute(). Built on @ory/argus.",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public",
8
8
  "registry": "https://registry.npmjs.org/",
9
9
  "provenance": true
10
10
  },
11
+ "reova": {
12
+ "enabled": true,
13
+ "endpoint": "https://telemetry.reo.dev/data"
14
+ },
11
15
  "main": "dist/index.js",
12
16
  "types": "dist/index.d.ts",
13
17
  "exports": {
@@ -30,8 +34,8 @@
30
34
  "permissions"
31
35
  ],
32
36
  "dependencies": {
33
- "reo-census": "^1.2.8",
34
- "@ory/argus": "0.13.9"
37
+ "reova": "^0.7.0",
38
+ "@ory/argus": "1.0.0"
35
39
  },
36
40
  "devDependencies": {
37
41
  "typescript": "^6.0.2",