@atlasauth/pca-llamaindex 0.0.0-stage → 0.1.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 +29 -2
- package/dist/index.d.ts +45 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -3
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @atlasauth/pca-llamaindex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
LlamaIndex.TS adapter for Proof-Carrying Authority — wrap a `FunctionTool` so every call emits a
|
|
4
|
+
PCActn (and hands you the proof) before the tool runs.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm i @atlasauth/pca-llamaindex
|
|
10
|
+
# peer dependency, install alongside:
|
|
11
|
+
npm i llamaindex
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { withPCA } from '@atlasauth/pca-llamaindex';
|
|
18
|
+
|
|
19
|
+
const guardedRefund = withPCA(
|
|
20
|
+
agent,
|
|
21
|
+
{ verb: 'stripe.refund', resource: (args) => `charge:${args.charge}`, onProof: (pca) => attach(pca.headers) },
|
|
22
|
+
refundTool, // your LlamaIndex FunctionTool
|
|
23
|
+
);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The wrapped tool has the same shape, so it drops into your agent's tool list. `agent` comes from
|
|
27
|
+
`@atlasauth/pca`'s facade. This attaches a proof-carrying action; it doesn't authorize — the resource
|
|
28
|
+
server's verifier decides. `llamaindex` is an optional peer dependency and is never imported.
|
|
29
|
+
|
|
30
|
+
Part of Proof-Carrying Authority — see [`@atlasauth/pca`](../pca).
|
package/dist/index.d.ts
ADDED
|
@@ -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,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-llamaindex",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LlamaIndex.TS adapter for Proof-Carrying Authority: wrap a FunctionTool so each call emits a PCActn before it runs.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@atlasauth/pca": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"llamaindex": "^0.8 || ^0.9 || ^0.10"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"llamaindex": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typescript": "^5.6.3",
|
|
27
|
+
"vitest": "^2.1.4"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.build.json",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
}
|
|
6
41
|
}
|