@atlasauth/pca-llamaindex 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Atlas Authorization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # @atlasauth/pca-llamaindex
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ LlamaIndex.TS adapter for Proof-Carrying Authority (PCA). `withPCA` wraps a `FunctionTool` so every call first builds a signed PCActn (failing fast if the agent's own grant does not permit it), hands you the proof to forward to the resource server, and then runs the original tool.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i @atlasauth/pca-llamaindex @atlasauth/pca
9
+ npm i llamaindex # optional peer dependency (^0.8 || ^0.9 || ^0.10)
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import { agent, generateKeyPair } from '@atlasauth/pca';
16
+ import { withPCA } from '@atlasauth/pca-llamaindex';
17
+
18
+ const pcaAgent = agent({
19
+ principal: generateKeyPair(),
20
+ goal: 'process refunds',
21
+ permissions: { stripe: ['refund'] },
22
+ limits: { refund: '$500/day' },
23
+ aud: 'ins_acme',
24
+ });
25
+
26
+ const guardedRefund = withPCA(
27
+ pcaAgent,
28
+ {
29
+ verb: 'stripe.refund',
30
+ resource: (args) => `charge:${args.charge}`,
31
+ onProof: (pca, args) => {
32
+ // forward pca.headers (PCA-Action) to the resource server with your request
33
+ },
34
+ },
35
+ refundTool, // your LlamaIndex FunctionTool
36
+ );
37
+ ```
38
+
39
+ The wrapped tool has the same shape (`metadata` and other fields preserved; only `call` is wrapped), so it drops into your agent's `tools` array. If the agent's local dry-run denies the action, the call throws `PcaDenied` before the tool runs (disable with `failFast: false`).
40
+
41
+ ## API
42
+
43
+ - `withPCA(agent, spec, tool)` - spec is `{ verb, resource, aud?, failFast?, onProof? }`.
44
+ - Re-exports `bridgeToolCall`, `pcaHeaders`, and the `PcaCall` type from `@atlasauth/pca`.
45
+
46
+ ## Status
47
+
48
+ This package does not authorize anything. It attaches a proof-carrying action; the resource server's verifier (see `@atlasauth/pca`) decides. The `llamaindex` package is matched structurally and never imported. PCA cryptography has not been independently audited.
49
+
50
+ ## License
51
+
52
+ MIT - see LICENSE
@@ -0,0 +1,45 @@
1
+ /**
2
+ * LlamaIndex.TS adapter for Proof-Carrying Authority.
3
+ *
4
+ * Wrap a LlamaIndex FunctionTool so every call first builds a PCActn (via the core `guard`) — fast-failing
5
+ * on the agent's local dry-run and handing the proof to your `onProof` so it can forward it to the resource
6
+ * server — then runs the original tool. Drop-in: the wrapped tool has the SAME shape, so it slots straight
7
+ * into the `tools` array you hand to a LlamaIndex agent.
8
+ *
9
+ * Structurally compatible with the `llamaindex` package (declare `llamaindex` as a peer dependency). We touch
10
+ * only `call` and preserve `metadata` and every other field, so this works across minor versions without
11
+ * importing the SDK's runtime.
12
+ *
13
+ * HONEST: this does not authorize — it attaches a proof-carrying action; the resource server's verifier
14
+ * decides. A bypassed wrapper just means the action lacks a valid PCActn and fails server-side.
15
+ */
16
+ import { type Agent, type PcaCall, bridgeToolCall, pcaHeaders } from '@atlasauth/pca';
17
+ /**
18
+ * Minimal structural shape of a LlamaIndex FunctionTool. `call` is a METHOD (not an arrow property) on
19
+ * purpose: method signatures are bivariant, so a tool with concrete argument types assigns cleanly to the
20
+ * general `LlamaIndexTool` when collected in a `tools` array — no `any`, no casts.
21
+ */
22
+ export interface LlamaIndexTool<ARGS = Record<string, unknown>, RESULT = unknown> {
23
+ metadata: {
24
+ name: string;
25
+ description?: string;
26
+ parameters?: unknown;
27
+ };
28
+ call(input: ARGS): Promise<RESULT> | RESULT;
29
+ [k: string]: unknown;
30
+ }
31
+ export interface GuardToolSpec<ARGS> {
32
+ /** Catalog verb this tool maps to (e.g. `stripe.refund`). */
33
+ verb: string;
34
+ /** Resource for the call: fixed, or derived from the tool args. */
35
+ resource: string | ((args: ARGS) => string);
36
+ /** Audience (resource-server / instance id); falls back to the agent's default. */
37
+ aud?: string;
38
+ /** Fast-fail on the local dry-run before executing (default true). */
39
+ failFast?: boolean;
40
+ /** Receive the PCActn so `call` can forward it (e.g. as request headers) to the resource server. */
41
+ onProof?: (pca: PcaCall, args: ARGS) => void;
42
+ }
43
+ /** Wrap a LlamaIndex FunctionTool so each call emits + attaches a PCActn before the original `call` runs. */
44
+ export declare function withPCA<ARGS extends Record<string, unknown>, RESULT>(agent: Agent, spec: GuardToolSpec<ARGS>, tool: LlamaIndexTool<ARGS, RESULT>): LlamaIndexTool<ARGS, RESULT>;
45
+ export { bridgeToolCall, pcaHeaders, type PcaCall };
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * LlamaIndex.TS adapter for Proof-Carrying Authority.
4
+ *
5
+ * Wrap a LlamaIndex FunctionTool so every call first builds a PCActn (via the core `guard`) — fast-failing
6
+ * on the agent's local dry-run and handing the proof to your `onProof` so it can forward it to the resource
7
+ * server — then runs the original tool. Drop-in: the wrapped tool has the SAME shape, so it slots straight
8
+ * into the `tools` array you hand to a LlamaIndex agent.
9
+ *
10
+ * Structurally compatible with the `llamaindex` package (declare `llamaindex` as a peer dependency). We touch
11
+ * only `call` and preserve `metadata` and every other field, so this works across minor versions without
12
+ * importing the SDK's runtime.
13
+ *
14
+ * HONEST: this does not authorize — it attaches a proof-carrying action; the resource server's verifier
15
+ * decides. A bypassed wrapper just means the action lacks a valid PCActn and fails server-side.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.pcaHeaders = exports.bridgeToolCall = void 0;
19
+ exports.withPCA = withPCA;
20
+ const pca_1 = require("@atlasauth/pca");
21
+ Object.defineProperty(exports, "bridgeToolCall", { enumerable: true, get: function () { return pca_1.bridgeToolCall; } });
22
+ Object.defineProperty(exports, "pcaHeaders", { enumerable: true, get: function () { return pca_1.pcaHeaders; } });
23
+ /** Wrap a LlamaIndex FunctionTool so each call emits + attaches a PCActn before the original `call` runs. */
24
+ function withPCA(agent, spec, tool) {
25
+ const run = (0, pca_1.guard)(agent, {
26
+ verb: spec.verb,
27
+ resource: spec.resource,
28
+ ...(spec.aud !== undefined ? { aud: spec.aud } : {}),
29
+ ...(spec.failFast !== undefined ? { failFast: spec.failFast } : {}),
30
+ }, async (args, pca) => {
31
+ spec.onProof?.(pca, args);
32
+ return (await tool.call(args));
33
+ });
34
+ return { ...tool, call: (input) => run(input) };
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA6BH,0BAmBC;AA9CD,wCAA6F;AAgDpF,+FAhD0B,oBAAc,OAgD1B;AAAE,2FAhDiC,gBAAU,OAgDjC;AAtBnC,6GAA6G;AAC7G,SAAgB,OAAO,CACrB,KAAY,EACZ,IAAyB,EACzB,IAAkC;IAElC,MAAM,GAAG,GAAG,IAAA,WAAK,EACf,KAAK,EACL;QACE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,EACD,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAClB,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAW,CAAC;IAC3C,CAAC,CACF,CAAC;IACF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,KAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;AACxD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@atlasauth/pca-llamaindex",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "LlamaIndex.TS adapter for Proof-Carrying Authority: wrap a FunctionTool so each call emits a PCActn before it runs.",
5
+ "keywords": [
6
+ "llamaindex",
7
+ "tool calling",
8
+ "agent authorization",
9
+ "proof-carrying authority",
10
+ "pca",
11
+ "ai agents"
12
+ ],
13
+ "license": "MIT",
14
+ "homepage": "https://github.com/Atlas-Authorization/pca#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/Atlas-Authorization/pca/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Atlas-Authorization/pca.git",
21
+ "directory": "packages/pca-llamaindex"
22
+ },
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "dependencies": {
33
+ "@atlasauth/pca": "0.2.0"
34
+ },
35
+ "peerDependencies": {
36
+ "llamaindex": "^0.8 || ^0.9 || ^0.10"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "llamaindex": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "devDependencies": {
44
+ "typescript": "^5.6.3",
45
+ "vitest": "^2.1.4"
46
+ },
47
+ "files": [
48
+ "dist",
49
+ "README.md",
50
+ "LICENSE"
51
+ ],
52
+ "engines": {
53
+ "node": ">=20"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "scripts": {
59
+ "build": "tsc -p tsconfig.build.json",
60
+ "typecheck": "tsc -p tsconfig.json --noEmit",
61
+ "test": "vitest run"
62
+ }
6
63
  }