@cef-ai/vault-sdk 4.3.0 → 5.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 +35 -19
- package/dist/agreements/payload.d.ts +15 -1
- package/dist/agreements/payload.d.ts.map +1 -1
- package/dist/agreements/payload.js +13 -1
- package/dist/agreements/payload.js.map +1 -1
- package/dist/agreements/sign.d.ts +16 -3
- package/dist/agreements/sign.d.ts.map +1 -1
- package/dist/agreements/sign.js +16 -1
- package/dist/agreements/sign.js.map +1 -1
- package/dist/client.d.ts +54 -52
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +95 -98
- package/dist/client.js.map +1 -1
- package/dist/core/connect-scopes.d.ts +18 -0
- package/dist/core/connect-scopes.d.ts.map +1 -0
- package/dist/core/connect-scopes.js +72 -0
- package/dist/core/connect-scopes.js.map +1 -0
- package/dist/core/endpoints.d.ts +22 -1
- package/dist/core/endpoints.d.ts.map +1 -1
- package/dist/core/endpoints.js +24 -3
- package/dist/core/endpoints.js.map +1 -1
- package/dist/core/errors.d.ts +13 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +14 -2
- package/dist/core/errors.js.map +1 -1
- package/dist/core/types.d.ts +70 -3
- package/dist/core/types.d.ts.map +1 -1
- package/dist/fluent/agent-connection.d.ts +16 -1
- package/dist/fluent/agent-connection.d.ts.map +1 -1
- package/dist/fluent/agent-connection.js +20 -0
- package/dist/fluent/agent-connection.js.map +1 -1
- package/dist/fluent/service.d.ts +34 -0
- package/dist/fluent/service.d.ts.map +1 -0
- package/dist/fluent/service.js +41 -0
- package/dist/fluent/service.js.map +1 -0
- package/dist/fluent/vault.d.ts +59 -10
- package/dist/fluent/vault.d.ts.map +1 -1
- package/dist/fluent/vault.js +62 -8
- package/dist/fluent/vault.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/internal/agents.d.ts +54 -7
- package/dist/internal/agents.d.ts.map +1 -1
- package/dist/internal/agents.js +110 -8
- package/dist/internal/agents.js.map +1 -1
- package/dist/internal/cubbies.d.ts +33 -0
- package/dist/internal/cubbies.d.ts.map +1 -1
- package/dist/internal/cubbies.js +39 -0
- package/dist/internal/cubbies.js.map +1 -1
- package/dist/internal/memory.d.ts +85 -5
- package/dist/internal/memory.d.ts.map +1 -1
- package/dist/internal/memory.js +58 -8
- package/dist/internal/memory.js.map +1 -1
- package/dist/internal/vaults.d.ts +8 -5
- package/dist/internal/vaults.d.ts.map +1 -1
- package/dist/internal/vaults.js +0 -10
- package/dist/internal/vaults.js.map +1 -1
- package/package.json +2 -2
- package/dist/internal/gateway-info.d.ts +0 -16
- package/dist/internal/gateway-info.d.ts.map +0 -1
- package/dist/internal/gateway-info.js +0 -34
- package/dist/internal/gateway-info.js.map +0 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,YAAY,EACZ,gBAAgB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qB,CAAC;AAKvH,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,YAAY,EACV,IAAI,EACJ,SAAS,EACT,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { VaultSDK } from "./client.js";
|
|
|
5
5
|
export { OnboardingRequiredError, OnboardingTimeoutError, } from "./internal/onboarding.js";
|
|
6
6
|
export { Vault } from "./fluent/vault.js";
|
|
7
7
|
export { ScopeHandle } from "./fluent/scope.js";
|
|
8
|
+
export { ServiceHandle } from "./fluent/service.js";
|
|
8
9
|
export { AgentConnectionHandle } from "./fluent/agent-connection.js";
|
|
9
10
|
export { JobHandle } from "./fluent/job.js";
|
|
10
11
|
export { CubbyHandle } from "./fluent/cubby.js";
|
|
@@ -20,15 +21,11 @@ export { VaultRequestError, VaultNotImplementedError, VaultSignerRequiredError,
|
|
|
20
21
|
// `SignedGrant.role`/`.scopes` instead and end up with a signature it checked
|
|
21
22
|
// and did not act on.
|
|
22
23
|
export { GRANT_ISSUED_AT_HEADER, GRANT_SCHEMA, GRANT_SCHEMA_V2, GRANT_SIGNATURE_HEADER, GrantVerificationError, NO_GRANT_EXPIRY, NO_PRIVACY_CEILING, PRIVACY_CEILINGS, canonicalGrantBytes, canonicalGrantBytesWithCeiling, canonicalPubkeyHex, decodeGrantDoc, grantExpiry, isValidPrivacyCeiling, privacyCeiling, vaultIdFor, verifyGrant, verifyGrantSig, verifySignedRoster, } from "./core/grant-doc.js";
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
// through the SDK instance). Re-exported here via the leaf `delegate-grants`
|
|
30
|
-
// subpath — never the `@cef-ai/account` root barrel — to keep vault-sdk
|
|
31
|
-
// chain-free (ADR-033).
|
|
24
|
+
// Vault-api's delegate identity (`VaultInfo` / `DelegateInfo`) stays exported
|
|
25
|
+
// for the frontend. The `registerDelegate`/`revokeDelegate` re-exports (and
|
|
26
|
+
// the `vault.delegate.{pubkey,grant,revoke}` namespace they backed) were
|
|
27
|
+
// removed with the gateway's `/auth/delegates` API: vault write delegation is
|
|
28
|
+
// now a durable on-chain NonTransfer proxy grant
|
|
29
|
+
// (`@cef-ai/account`'s `ensureVaultDelegate`).
|
|
32
30
|
export { VaultInfo } from "./internal/vault-info.js";
|
|
33
|
-
export { registerDelegate, revokeDelegate, GatewayDelegateError, } from "@cef-ai/account/delegate-grants";
|
|
34
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,wEAAwE;AACxE,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,E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O,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQhD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAe9D,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,0EAA0E;AAC1E,wEAAwE;AACxE,8EAA8E;AAC9E,sBAAsB;AACtB,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,8BAA8B,EAC9B,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,WAAW,EACX,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AA4C7B,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,iDAAiD;AACjD,+CAA+C;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VaultHttpClient } from "../core/http.js";
|
|
2
|
-
import type { AgentConnection, AgentConnectionStatus, ConnectAgentRequest } from "../core/types.js";
|
|
2
|
+
import type { AgentConnection, AgentConnectionStatus, ConnectAgentRequest, ConnectionCeiling } from "../core/types.js";
|
|
3
3
|
export interface ListAgentsOptions {
|
|
4
4
|
status?: AgentConnectionStatus;
|
|
5
5
|
}
|
|
@@ -7,17 +7,64 @@ export declare class Agents {
|
|
|
7
7
|
private readonly http;
|
|
8
8
|
constructor(http: VaultHttpClient);
|
|
9
9
|
/**
|
|
10
|
-
* Low-level surface — POSTs a `ConnectAgentRequest` (`{ agentId, scope
|
|
11
|
-
* settings?, agreementSignature? }`) with a pre-signed
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* Low-level surface — POSTs a `ConnectAgentRequest` (`{ agentId, scope?,
|
|
11
|
+
* scopes?, settings?, agreementSignature? }`) with a pre-signed
|
|
12
|
+
* `agreementSignature`. Pass `scopes` for a set of vault scopes, or the
|
|
13
|
+
* singular `scope` for callers that predate the set — exactly one of the
|
|
14
|
+
* two is required (`ScopeSelector`); whichever is supplied is sent through
|
|
15
|
+
* untouched, never derived from the other. `version`/`manifestCid` are not
|
|
16
|
+
* sent; the vault-api resolves the manifest from the DDC registry. For the
|
|
17
|
+
* high-level flow that signs the GAR agreement on your behalf, use
|
|
18
|
+
* `vault.agents.connect({ agentId, scope, settings })` from
|
|
19
|
+
* `@cef-ai/vault-sdk` (requires `garEndpoint` + `wallet` on the SDK config).
|
|
20
|
+
*
|
|
21
|
+
* `ceiling` (optional) is the connection's spend ceiling, written
|
|
22
|
+
* atomically with the connection row. Set it here to avoid a window where
|
|
23
|
+
* the connection exists with no ceiling; use {@link setCeiling} to change it
|
|
24
|
+
* later. It is validated exactly as `setCeiling` validates (see there) and a
|
|
25
|
+
* violation rejects with `VaultRequestError(status 0, "BAD_REQUEST")` before
|
|
26
|
+
* any request is made. When present it is sent as `{ gpuUnits, a2aTokens }`
|
|
27
|
+
* with both axes explicit (absent axis = `0` = no ceiling on that axis);
|
|
28
|
+
* when `undefined` the `ceiling` key is omitted from the body. The resolved
|
|
29
|
+
* connection's `ceiling` reports what the server stored (absent when
|
|
30
|
+
* neither axis is set).
|
|
16
31
|
*/
|
|
17
32
|
connect(v: string, req: ConnectAgentRequest): Promise<AgentConnection>;
|
|
18
33
|
list(v: string, opts?: ListAgentsOptions): Promise<AgentConnection[]>;
|
|
19
34
|
get(v: string, a: string): Promise<AgentConnection>;
|
|
20
35
|
update(v: string, a: string, settings: Record<string, unknown>): Promise<AgentConnection>;
|
|
36
|
+
/**
|
|
37
|
+
* Set (replace) the connection's spend ceiling —
|
|
38
|
+
* `PUT /vaults/:v/agents/:a/ceiling`, wallet-signed like {@link update}.
|
|
39
|
+
*
|
|
40
|
+
* Both axes are always sent; an absent axis is sent as `0` (= no ceiling on
|
|
41
|
+
* that axis), so `setCeiling(v, a, {})` clears both. This is a full replace,
|
|
42
|
+
* not a merge: omitting `a2aTokens` clears an existing token ceiling.
|
|
43
|
+
*
|
|
44
|
+
* Validated before sending: only the keys `gpuUnits` and `a2aTokens` are
|
|
45
|
+
* allowed (any other own key is refused, even with an `undefined` value,
|
|
46
|
+
* mirroring vault-api's unknown-field refusal); each axis must be a finite
|
|
47
|
+
* number >= 0; `a2aTokens` must be an integer <= `Number.MAX_SAFE_INTEGER`.
|
|
48
|
+
* A violation throws {@link VaultRequestError} with `status` 0 and `code`
|
|
49
|
+
* "BAD_REQUEST" (the same code vault-api uses), and no request is made; the
|
|
50
|
+
* returned promise rejects. `status` 0 is also what a network failure
|
|
51
|
+
* carries — distinguish a validation refusal by `code === "BAD_REQUEST"`.
|
|
52
|
+
*
|
|
53
|
+
* Resolves to the updated {@link AgentConnection}; its `ceiling` is absent
|
|
54
|
+
* when both axes are 0.
|
|
55
|
+
*/
|
|
56
|
+
setCeiling(v: string, a: string, ceiling: ConnectionCeiling): Promise<AgentConnection>;
|
|
21
57
|
disconnect(v: string, a: string): Promise<void>;
|
|
22
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Client-side mirror of vault-api's ceiling validation. Returns the wire body
|
|
61
|
+
* (`{ gpuUnits, a2aTokens }`, both axes explicit). Throws
|
|
62
|
+
* `VaultRequestError(status 0, "BAD_REQUEST")` on a violation. Shared by
|
|
63
|
+
* `setCeiling`, `connect` and the fluent `vault.agents.connect` (which calls it
|
|
64
|
+
* before the GAR agreement is signed, so a bad ceiling costs no ceremony).
|
|
65
|
+
*/
|
|
66
|
+
export declare function validateCeiling(c: ConnectionCeiling): {
|
|
67
|
+
gpuUnits: number;
|
|
68
|
+
a2aTokens: number;
|
|
69
|
+
};
|
|
23
70
|
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/internal/agents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/internal/agents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIvH,MAAM,WAAW,iBAAiB;IAAG,MAAM,CAAC,EAAE,qBAAqB,CAAA;CAAE;AAErE,qBAAa,MAAM;IACL,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,eAAe;IAElD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBtE,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,iBAAsB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAK/E,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAGnD,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAGzF;;;;;;;;;;;;;;;;;;;OAmBG;IACG,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC;IAK5F,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhD;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,iBAAiB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAiC7F"}
|
package/dist/internal/agents.js
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
import { endpoints } from "../core/endpoints.js";
|
|
2
|
+
import { resolveConnectScopes } from "../core/connect-scopes.js";
|
|
3
|
+
import { VaultRequestError } from "../core/errors.js";
|
|
2
4
|
export class Agents {
|
|
3
5
|
http;
|
|
4
6
|
constructor(http) {
|
|
5
7
|
this.http = http;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
|
-
* Low-level surface — POSTs a `ConnectAgentRequest` (`{ agentId, scope
|
|
9
|
-
* settings?, agreementSignature? }`) with a pre-signed
|
|
10
|
-
* `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Low-level surface — POSTs a `ConnectAgentRequest` (`{ agentId, scope?,
|
|
11
|
+
* scopes?, settings?, agreementSignature? }`) with a pre-signed
|
|
12
|
+
* `agreementSignature`. Pass `scopes` for a set of vault scopes, or the
|
|
13
|
+
* singular `scope` for callers that predate the set — exactly one of the
|
|
14
|
+
* two is required (`ScopeSelector`); whichever is supplied is sent through
|
|
15
|
+
* untouched, never derived from the other. `version`/`manifestCid` are not
|
|
16
|
+
* sent; the vault-api resolves the manifest from the DDC registry. For the
|
|
17
|
+
* high-level flow that signs the GAR agreement on your behalf, use
|
|
18
|
+
* `vault.agents.connect({ agentId, scope, settings })` from
|
|
19
|
+
* `@cef-ai/vault-sdk` (requires `garEndpoint` + `wallet` on the SDK config).
|
|
20
|
+
*
|
|
21
|
+
* `ceiling` (optional) is the connection's spend ceiling, written
|
|
22
|
+
* atomically with the connection row. Set it here to avoid a window where
|
|
23
|
+
* the connection exists with no ceiling; use {@link setCeiling} to change it
|
|
24
|
+
* later. It is validated exactly as `setCeiling` validates (see there) and a
|
|
25
|
+
* violation rejects with `VaultRequestError(status 0, "BAD_REQUEST")` before
|
|
26
|
+
* any request is made. When present it is sent as `{ gpuUnits, a2aTokens }`
|
|
27
|
+
* with both axes explicit (absent axis = `0` = no ceiling on that axis);
|
|
28
|
+
* when `undefined` the `ceiling` key is omitted from the body. The resolved
|
|
29
|
+
* connection's `ceiling` reports what the server stored (absent when
|
|
30
|
+
* neither axis is set).
|
|
14
31
|
*/
|
|
15
|
-
connect(v, req) {
|
|
16
|
-
|
|
32
|
+
async connect(v, req) {
|
|
33
|
+
// The ceiling is validated (and normalised to the two-axis wire body)
|
|
34
|
+
// before the request goes out — the same `validateCeiling` setCeiling
|
|
35
|
+
// uses. Absent → the key stays off the body entirely.
|
|
36
|
+
const { ceiling, ...rest } = req;
|
|
37
|
+
const body = ceiling === undefined ? { ...rest } : { ...rest, ceiling: validateCeiling(ceiling) };
|
|
38
|
+
// Validates the scope selector without rewriting it — `req` is still
|
|
39
|
+
// forwarded exactly as given below; see resolveConnectScopes for why
|
|
40
|
+
// this check is needed even though `ConnectAgentRequest` is typed to
|
|
41
|
+
// forbid both-or-neither already. `connect` is `async` (rather than
|
|
42
|
+
// just returning the `http.send` promise) specifically so this
|
|
43
|
+
// validation failure is a rejected promise like every other error from
|
|
44
|
+
// this method, not a synchronous throw a caller's `await`/`.catch`
|
|
45
|
+
// wouldn't expect.
|
|
46
|
+
resolveConnectScopes(req, "Agents.connect");
|
|
47
|
+
return this.http.send("POST", endpoints.agents(v), { body });
|
|
17
48
|
}
|
|
18
49
|
async list(v, opts = {}) {
|
|
19
50
|
const res = await this.http.send("GET", endpoints.agents(v), { query: { status: opts.status } });
|
|
@@ -25,8 +56,79 @@ export class Agents {
|
|
|
25
56
|
update(v, a, settings) {
|
|
26
57
|
return this.http.send("PATCH", endpoints.agent(v, a), { body: { settings } });
|
|
27
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Set (replace) the connection's spend ceiling —
|
|
61
|
+
* `PUT /vaults/:v/agents/:a/ceiling`, wallet-signed like {@link update}.
|
|
62
|
+
*
|
|
63
|
+
* Both axes are always sent; an absent axis is sent as `0` (= no ceiling on
|
|
64
|
+
* that axis), so `setCeiling(v, a, {})` clears both. This is a full replace,
|
|
65
|
+
* not a merge: omitting `a2aTokens` clears an existing token ceiling.
|
|
66
|
+
*
|
|
67
|
+
* Validated before sending: only the keys `gpuUnits` and `a2aTokens` are
|
|
68
|
+
* allowed (any other own key is refused, even with an `undefined` value,
|
|
69
|
+
* mirroring vault-api's unknown-field refusal); each axis must be a finite
|
|
70
|
+
* number >= 0; `a2aTokens` must be an integer <= `Number.MAX_SAFE_INTEGER`.
|
|
71
|
+
* A violation throws {@link VaultRequestError} with `status` 0 and `code`
|
|
72
|
+
* "BAD_REQUEST" (the same code vault-api uses), and no request is made; the
|
|
73
|
+
* returned promise rejects. `status` 0 is also what a network failure
|
|
74
|
+
* carries — distinguish a validation refusal by `code === "BAD_REQUEST"`.
|
|
75
|
+
*
|
|
76
|
+
* Resolves to the updated {@link AgentConnection}; its `ceiling` is absent
|
|
77
|
+
* when both axes are 0.
|
|
78
|
+
*/
|
|
79
|
+
async setCeiling(v, a, ceiling) {
|
|
80
|
+
// `async` so a validation failure is a rejected promise, not a sync throw.
|
|
81
|
+
const body = validateCeiling(ceiling);
|
|
82
|
+
return this.http.send("PUT", endpoints.agentCeiling(v, a), { body: { ...body } });
|
|
83
|
+
}
|
|
28
84
|
disconnect(v, a) {
|
|
29
85
|
return this.http.send("DELETE", endpoints.agent(v, a), { body: {} });
|
|
30
86
|
}
|
|
31
87
|
}
|
|
88
|
+
function invalidCeiling(msg) {
|
|
89
|
+
return new VaultRequestError(`invalid ceiling: ${msg}`, 0, "BAD_REQUEST");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Client-side mirror of vault-api's ceiling validation. Returns the wire body
|
|
93
|
+
* (`{ gpuUnits, a2aTokens }`, both axes explicit). Throws
|
|
94
|
+
* `VaultRequestError(status 0, "BAD_REQUEST")` on a violation. Shared by
|
|
95
|
+
* `setCeiling`, `connect` and the fluent `vault.agents.connect` (which calls it
|
|
96
|
+
* before the GAR agreement is signed, so a bad ceiling costs no ceremony).
|
|
97
|
+
*/
|
|
98
|
+
export function validateCeiling(c) {
|
|
99
|
+
if (c === null || typeof c !== "object" || Array.isArray(c)) {
|
|
100
|
+
throw invalidCeiling("expected an object { gpuUnits?, a2aTokens? }");
|
|
101
|
+
}
|
|
102
|
+
// Mirror vault-api's DisallowUnknownFields: a misspelled key (`a2a_tokens`)
|
|
103
|
+
// would otherwise be dropped and its axis sent as 0 — silently clearing a
|
|
104
|
+
// ceiling in force. Checked before the axes are read. A key present with an
|
|
105
|
+
// `undefined` value is refused too: the key itself is the mistake.
|
|
106
|
+
for (const k of Object.keys(c)) {
|
|
107
|
+
if (k !== "gpuUnits" && k !== "a2aTokens") {
|
|
108
|
+
throw invalidCeiling(`unknown field ${JSON.stringify(k)} (expected { gpuUnits?, a2aTokens? })`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const axis = (name) => {
|
|
112
|
+
const v = c[name];
|
|
113
|
+
if (v === undefined)
|
|
114
|
+
return 0;
|
|
115
|
+
if (typeof v !== "number" || !Number.isFinite(v)) {
|
|
116
|
+
throw invalidCeiling(`${name} must be a finite number (got ${String(v)})`);
|
|
117
|
+
}
|
|
118
|
+
if (v < 0)
|
|
119
|
+
throw invalidCeiling(`${name} must be >= 0 (got ${v})`);
|
|
120
|
+
return v;
|
|
121
|
+
};
|
|
122
|
+
const gpuUnits = axis("gpuUnits");
|
|
123
|
+
const a2aTokens = axis("a2aTokens");
|
|
124
|
+
if (!Number.isInteger(a2aTokens)) {
|
|
125
|
+
throw invalidCeiling(`a2aTokens must be an integer (got ${a2aTokens})`);
|
|
126
|
+
}
|
|
127
|
+
// Above 2^53 the number no longer round-trips exactly through JSON (and
|
|
128
|
+
// above 2^63 the server fails to decode it into int64 at all).
|
|
129
|
+
if (a2aTokens > Number.MAX_SAFE_INTEGER) {
|
|
130
|
+
throw invalidCeiling(`a2aTokens must be <= Number.MAX_SAFE_INTEGER (got ${a2aTokens})`);
|
|
131
|
+
}
|
|
132
|
+
return { gpuUnits, a2aTokens };
|
|
133
|
+
}
|
|
32
134
|
//# sourceMappingURL=agents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/internal/agents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/internal/agents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,OAAO,MAAM;IACY;IAA7B,YAA6B,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAG,CAAC;IAEtD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,OAAO,CAAC,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MAAM,cAAc,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,IAA8B,EAAU,EAAE;QACtD,MAAM,CAAC,GAAY,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,MAAM,cAAc,CAAC,GAAG,IAAI,iCAAiC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC7E,CAAC;QACD,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,cAAc,CAAC,GAAG,IAAI,sBAAsB,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,MAAM,cAAc,CAAC,qCAAqC,SAAS,GAAG,CAAC,CAAC;IAC1E,CAAC;IACD,wEAAwE;IACxE,+DAA+D;IAC/D,IAAI,SAAS,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QACxC,MAAM,cAAc,CAAC,qDAAqD,SAAS,GAAG,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -11,5 +11,38 @@ export declare class Cubbies {
|
|
|
11
11
|
* for normal write flows.
|
|
12
12
|
*/
|
|
13
13
|
exec(v: string, s: string, a: string, alias: string, sql: string, params?: unknown[]): Promise<CubbyExecResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Read a cubby the AGENT SERVICE owns, rather than one of its agents.
|
|
16
|
+
*
|
|
17
|
+
* One database per service, so what a coordinator writes its specialists can
|
|
18
|
+
* read without a copy. `as` is the service's public key — the half of an
|
|
19
|
+
* agent id before the colon.
|
|
20
|
+
*/
|
|
21
|
+
serviceQuery<Row = unknown[]>(v: string, as: string, alias: string, sql: string, params?: unknown[]): Promise<CubbyQueryResponse<Row>>;
|
|
22
|
+
/** The write half of {@link serviceQuery}; needs a member-level grant. */
|
|
23
|
+
serviceExec(v: string, as: string, alias: string, sql: string, params?: unknown[]): Promise<CubbyExecResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Every cubby this service holds in (vault, scope).
|
|
26
|
+
*
|
|
27
|
+
* There is nothing else to ask: a service cubby has no declaration — an alias
|
|
28
|
+
* passing the shape rule is legal and the first write creates the file — so
|
|
29
|
+
* the registry IS the list.
|
|
30
|
+
*/
|
|
31
|
+
serviceList(v: string, as: string): Promise<ServiceCubby[]>;
|
|
32
|
+
/** Create one with its schema. Member level, like exec. */
|
|
33
|
+
serviceProvision(v: string, as: string, alias: string, migrations: CubbyMigration[]): Promise<void>;
|
|
34
|
+
/** Remove one, and its file. Member level, like exec. */
|
|
35
|
+
serviceDelete(v: string, as: string, alias: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** One migration, as the platform applies them. */
|
|
38
|
+
export interface CubbyMigration {
|
|
39
|
+
version: number;
|
|
40
|
+
up: string;
|
|
41
|
+
}
|
|
42
|
+
/** What the registry knows about one cubby of a service. */
|
|
43
|
+
export interface ServiceCubby {
|
|
44
|
+
alias: string;
|
|
45
|
+
sizeBytes: number;
|
|
46
|
+
schemaVersion: number;
|
|
14
47
|
}
|
|
15
48
|
//# sourceMappingURL=cubbies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cubbies.d.ts","sourceRoot":"","sources":["../../src/internal/cubbies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,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;CACvB"}
|
package/dist/internal/cubbies.js
CHANGED
|
@@ -16,5 +16,44 @@ export class Cubbies {
|
|
|
16
16
|
exec(v, s, a, alias, sql, params = []) {
|
|
17
17
|
return this.http.send("POST", endpoints.cubbyExec(v, s, a, alias), { body: { sql, params } });
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Read a cubby the AGENT SERVICE owns, rather than one of its agents.
|
|
21
|
+
*
|
|
22
|
+
* One database per service, so what a coordinator writes its specialists can
|
|
23
|
+
* read without a copy. `as` is the service's public key — the half of an
|
|
24
|
+
* agent id before the colon.
|
|
25
|
+
*/
|
|
26
|
+
serviceQuery(v, as, alias, sql, params = []) {
|
|
27
|
+
return this.http.send("POST", endpoints.serviceCubbyQuery(v, as, alias), {
|
|
28
|
+
body: { sql, params },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** The write half of {@link serviceQuery}; needs a member-level grant. */
|
|
32
|
+
serviceExec(v, as, alias, sql, params = []) {
|
|
33
|
+
return this.http.send("POST", endpoints.serviceCubbyExec(v, as, alias), {
|
|
34
|
+
body: { sql, params },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Every cubby this service holds in (vault, scope).
|
|
39
|
+
*
|
|
40
|
+
* There is nothing else to ask: a service cubby has no declaration — an alias
|
|
41
|
+
* passing the shape rule is legal and the first write creates the file — so
|
|
42
|
+
* the registry IS the list.
|
|
43
|
+
*/
|
|
44
|
+
async serviceList(v, as) {
|
|
45
|
+
const body = await this.http.send("GET", endpoints.serviceCubbies(v, as));
|
|
46
|
+
return body?.data ?? [];
|
|
47
|
+
}
|
|
48
|
+
/** Create one with its schema. Member level, like exec. */
|
|
49
|
+
serviceProvision(v, as, alias, migrations) {
|
|
50
|
+
return this.http.send("POST", endpoints.serviceCubbyProvision(v, as, alias), {
|
|
51
|
+
body: { migrations },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** Remove one, and its file. Member level, like exec. */
|
|
55
|
+
serviceDelete(v, as, alias) {
|
|
56
|
+
return this.http.send("DELETE", endpoints.serviceCubby(v, as, alias));
|
|
57
|
+
}
|
|
19
58
|
}
|
|
20
59
|
//# sourceMappingURL=cubbies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cubbies.js","sourceRoot":"","sources":["../../src/internal/cubbies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,OAAO,OAAO;IACW;IAA7B,YAA6B,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAG,CAAC;IAEtD,KAAK,CACH,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,GAAW,EAAE,SAAoB,EAAE;QAEnF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACjG,CAAC;IAED;;;;;OAKG;IACH,IAAI,CACF,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,GAAW,EAAE,SAAoB,EAAE;QAEnF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"cubbies.js","sourceRoot":"","sources":["../../src/internal/cubbies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,OAAO,OAAO;IACW;IAA7B,YAA6B,IAAqB;QAArB,SAAI,GAA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SACtB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAC,CAAS,EAAE,EAAU;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAC/B,KAAK,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CACvC,CAAC;QACF,OAAO,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED,2DAA2D;IAC3D,gBAAgB,CACd,CAAS,EAAE,EAAU,EAAE,KAAa,EAAE,UAA4B;QAElE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,qBAAqB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE;YAC3E,IAAI,EAAE,EAAE,UAAU,EAAE;SACrB,CAAC,CAAC;IACL,CAAC;IAED,yDAAyD;IACzD,aAAa,CAAC,CAAS,EAAE,EAAU,EAAE,KAAa;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -12,13 +12,43 @@ import type { VaultHttpClient } from "../core/http.js";
|
|
|
12
12
|
export interface MemoryRows {
|
|
13
13
|
columns: string[];
|
|
14
14
|
rows: unknown[][];
|
|
15
|
+
/**
|
|
16
|
+
* The paged read tools (`record_search`, `record_list`) mint an opaque
|
|
17
|
+
* keyset cursor when a full page was returned and more rows exist; pass it
|
|
18
|
+
* back as the matching tool's `cursor` request param to fetch the next
|
|
19
|
+
* page. ABSENT on the last page (and on every unpaged tool) — the server
|
|
20
|
+
* marks it `omitempty`, so its absence means "no more rows". The one
|
|
21
|
+
* additive sibling key on an otherwise untouched `{ columns, rows }`
|
|
22
|
+
* envelope: the cursor rides beside the columns, never inside them.
|
|
23
|
+
*/
|
|
24
|
+
cursor?: string;
|
|
15
25
|
}
|
|
16
26
|
/**
|
|
17
27
|
* The memory bank's READ surface for browser clients (the memory-route UI).
|
|
18
|
-
* One route,
|
|
19
|
-
* the Go json-tag body keys (`match`, `limit`, `id`
|
|
28
|
+
* One route, five tools: `POST /api/v1/vaults/:vaultId/memory/:tool` with
|
|
29
|
+
* the Go json-tag body keys (`match`, `limit`, `id`, `type`, `privacy`,
|
|
30
|
+
* `scope`, `cursor`, `edge_type`, `direction`, `domain` — all `omitempty`, so
|
|
20
31
|
* undefined fields are omitted from the body entirely).
|
|
21
32
|
*
|
|
33
|
+
* `scope` narrows within the caller's grants (an ungranted scope yields an
|
|
34
|
+
* empty result, never an error); `cursor` pages the read tools (see
|
|
35
|
+
* `MemoryRows.cursor`). `domain` (on `search`, `list`, `countByType` — the
|
|
36
|
+
* three reads the server applies it to) narrows by the record's SUBJECT tag:
|
|
37
|
+
* `domain` is the record's subject tag (e.g. sales), NOT the vault scope —
|
|
38
|
+
* narrowing by it is not an access control; the UI labels it Topic. Two
|
|
39
|
+
* axes: `scope` is access, `domain` is subject.
|
|
40
|
+
*
|
|
41
|
+
* `record_neighbours` filters by `edge_type` and `direction`
|
|
42
|
+
* (`in`|`out`|`both`, relative to the anchor record — `out` is
|
|
43
|
+
* anchor → far; absent means `both`). The SDK sends the direction as-given:
|
|
44
|
+
* enum validation is the server's job, the TS type is the only client-side
|
|
45
|
+
* constraint.
|
|
46
|
+
*
|
|
47
|
+
* `record_search`'s projection is seven positional columns — `id, type,
|
|
48
|
+
* title, scope, privacy, rank, snippet` (the FTS5 `snippet` is appended
|
|
49
|
+
* after the six historical columns, aliased because the columns array goes
|
|
50
|
+
* out verbatim and the UI reads it by name).
|
|
51
|
+
*
|
|
22
52
|
* Writes are agent-side (`ctx.memory` in `@cef-ai/agent-sdk`) per the spec —
|
|
23
53
|
* this class exposes no write methods on purpose.
|
|
24
54
|
*/
|
|
@@ -26,17 +56,67 @@ export declare class Memory {
|
|
|
26
56
|
private readonly http;
|
|
27
57
|
private readonly vaultId;
|
|
28
58
|
constructor(http: VaultHttpClient, vaultId: string);
|
|
29
|
-
/** Full-text search
|
|
59
|
+
/** Full-text search, optionally narrowed to a type, privacy class, and/or scope. */
|
|
30
60
|
search(match: string, opts?: {
|
|
31
61
|
limit?: number;
|
|
62
|
+
type?: string;
|
|
63
|
+
privacy?: string;
|
|
64
|
+
scope?: string;
|
|
65
|
+
cursor?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The record's subject tag (e.g. `sales`, `hiring`, `engineering`) —
|
|
68
|
+
* wire `domain`, sent only when set. Narrows WITHIN the caller's
|
|
69
|
+
* grants; an absent domain adds no predicate.
|
|
70
|
+
*
|
|
71
|
+
* `domain` is the record's subject tag (e.g. sales), NOT the vault
|
|
72
|
+
* scope — narrowing by it is not an access control; the UI labels it
|
|
73
|
+
* Topic. (The product UI's "Domain" is the vault SCOPE, the access
|
|
74
|
+
* axis — that is `scope` here.)
|
|
75
|
+
*/
|
|
76
|
+
domain?: string;
|
|
77
|
+
}): Promise<MemoryRows>;
|
|
78
|
+
/** Browse records newest-first, gated by the caller's grants and ceiling. */
|
|
79
|
+
list(type?: string, opts?: {
|
|
80
|
+
limit?: number;
|
|
81
|
+
scope?: string;
|
|
82
|
+
cursor?: string;
|
|
83
|
+
/**
|
|
84
|
+
* The record's subject tag (e.g. `sales`, `hiring`, `engineering`) —
|
|
85
|
+
* wire `domain`, sent only when set. Narrows WITHIN the caller's
|
|
86
|
+
* grants; an absent domain adds no predicate.
|
|
87
|
+
*
|
|
88
|
+
* `domain` is the record's subject tag (e.g. sales), NOT the vault
|
|
89
|
+
* scope — narrowing by it is not an access control; the UI labels it
|
|
90
|
+
* Topic. (The product UI's "Domain" is the vault SCOPE, the access
|
|
91
|
+
* axis — that is `scope` here.)
|
|
92
|
+
*/
|
|
93
|
+
domain?: string;
|
|
32
94
|
}): Promise<MemoryRows>;
|
|
33
95
|
/** Fetch a single record by id. */
|
|
34
96
|
get(id: string): Promise<MemoryRows>;
|
|
35
97
|
/** Records connected to the given one by a relation. */
|
|
36
98
|
neighbours(id: string, opts?: {
|
|
37
99
|
limit?: number;
|
|
100
|
+
edgeType?: string;
|
|
101
|
+
direction?: "in" | "out" | "both";
|
|
102
|
+
}): Promise<MemoryRows>;
|
|
103
|
+
/**
|
|
104
|
+
* Row counts grouped by record type, optionally narrowed to one scope
|
|
105
|
+
* and/or one subject `domain`.
|
|
106
|
+
*/
|
|
107
|
+
countByType(opts?: {
|
|
108
|
+
scope?: string;
|
|
109
|
+
/**
|
|
110
|
+
* The record's subject tag (e.g. `sales`, `hiring`, `engineering`) —
|
|
111
|
+
* wire `domain`, sent only when set. Narrows WITHIN the caller's
|
|
112
|
+
* grants; an absent domain adds no predicate.
|
|
113
|
+
*
|
|
114
|
+
* `domain` is the record's subject tag (e.g. sales), NOT the vault
|
|
115
|
+
* scope — narrowing by it is not an access control; the UI labels it
|
|
116
|
+
* Topic. (The product UI's "Domain" is the vault SCOPE, the access
|
|
117
|
+
* axis — that is `scope` here.)
|
|
118
|
+
*/
|
|
119
|
+
domain?: string;
|
|
38
120
|
}): Promise<MemoryRows>;
|
|
39
|
-
/** Row counts grouped by record type. */
|
|
40
|
-
countByType(): Promise<MemoryRows>;
|
|
41
121
|
}
|
|
42
122
|
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/internal/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/internal/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM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E,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;KAC9B,GACL,OAAO,CAAC,UAAU,CAAC;IAetB;;;OAGG;IACH,WAAW,CACT,IAAI,GAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf;;;;;;;;;WASG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,GACL,OAAO,CAAC,UAAU,CAAC;CAOvB"}
|
package/dist/internal/memory.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { endpoints } from "../core/endpoints.js";
|
|
2
2
|
/**
|
|
3
3
|
* The memory bank's READ surface for browser clients (the memory-route UI).
|
|
4
|
-
* One route,
|
|
5
|
-
* the Go json-tag body keys (`match`, `limit`, `id`
|
|
4
|
+
* One route, five tools: `POST /api/v1/vaults/:vaultId/memory/:tool` with
|
|
5
|
+
* the Go json-tag body keys (`match`, `limit`, `id`, `type`, `privacy`,
|
|
6
|
+
* `scope`, `cursor`, `edge_type`, `direction`, `domain` — all `omitempty`, so
|
|
6
7
|
* undefined fields are omitted from the body entirely).
|
|
7
8
|
*
|
|
9
|
+
* `scope` narrows within the caller's grants (an ungranted scope yields an
|
|
10
|
+
* empty result, never an error); `cursor` pages the read tools (see
|
|
11
|
+
* `MemoryRows.cursor`). `domain` (on `search`, `list`, `countByType` — the
|
|
12
|
+
* three reads the server applies it to) narrows by the record's SUBJECT tag:
|
|
13
|
+
* `domain` is the record's subject tag (e.g. sales), NOT the vault scope —
|
|
14
|
+
* narrowing by it is not an access control; the UI labels it Topic. Two
|
|
15
|
+
* axes: `scope` is access, `domain` is subject.
|
|
16
|
+
*
|
|
17
|
+
* `record_neighbours` filters by `edge_type` and `direction`
|
|
18
|
+
* (`in`|`out`|`both`, relative to the anchor record — `out` is
|
|
19
|
+
* anchor → far; absent means `both`). The SDK sends the direction as-given:
|
|
20
|
+
* enum validation is the server's job, the TS type is the only client-side
|
|
21
|
+
* constraint.
|
|
22
|
+
*
|
|
23
|
+
* `record_search`'s projection is seven positional columns — `id, type,
|
|
24
|
+
* title, scope, privacy, rank, snippet` (the FTS5 `snippet` is appended
|
|
25
|
+
* after the six historical columns, aliased because the columns array goes
|
|
26
|
+
* out verbatim and the UI reads it by name).
|
|
27
|
+
*
|
|
8
28
|
* Writes are agent-side (`ctx.memory` in `@cef-ai/agent-sdk`) per the spec —
|
|
9
29
|
* this class exposes no write methods on purpose.
|
|
10
30
|
*/
|
|
@@ -15,10 +35,30 @@ export class Memory {
|
|
|
15
35
|
this.http = http;
|
|
16
36
|
this.vaultId = vaultId;
|
|
17
37
|
}
|
|
18
|
-
/** Full-text search
|
|
38
|
+
/** Full-text search, optionally narrowed to a type, privacy class, and/or scope. */
|
|
19
39
|
search(match, opts = {}) {
|
|
20
40
|
return this.http.send("POST", endpoints.memoryTool(this.vaultId, "record_search"), {
|
|
21
|
-
body: {
|
|
41
|
+
body: {
|
|
42
|
+
match,
|
|
43
|
+
limit: opts.limit,
|
|
44
|
+
type: opts.type,
|
|
45
|
+
privacy: opts.privacy,
|
|
46
|
+
scope: opts.scope,
|
|
47
|
+
cursor: opts.cursor,
|
|
48
|
+
domain: opts.domain,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Browse records newest-first, gated by the caller's grants and ceiling. */
|
|
53
|
+
list(type, opts = {}) {
|
|
54
|
+
return this.http.send("POST", endpoints.memoryTool(this.vaultId, "record_list"), {
|
|
55
|
+
body: {
|
|
56
|
+
type,
|
|
57
|
+
limit: opts.limit,
|
|
58
|
+
scope: opts.scope,
|
|
59
|
+
cursor: opts.cursor,
|
|
60
|
+
domain: opts.domain,
|
|
61
|
+
},
|
|
22
62
|
});
|
|
23
63
|
}
|
|
24
64
|
/** Fetch a single record by id. */
|
|
@@ -29,11 +69,21 @@ export class Memory {
|
|
|
29
69
|
}
|
|
30
70
|
/** Records connected to the given one by a relation. */
|
|
31
71
|
neighbours(id, opts = {}) {
|
|
32
|
-
return this.http.send("POST", endpoints.memoryTool(this.vaultId, "record_neighbours"), {
|
|
72
|
+
return this.http.send("POST", endpoints.memoryTool(this.vaultId, "record_neighbours"), {
|
|
73
|
+
body: {
|
|
74
|
+
id,
|
|
75
|
+
limit: opts.limit,
|
|
76
|
+
edge_type: opts.edgeType,
|
|
77
|
+
direction: opts.direction,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
33
80
|
}
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Row counts grouped by record type, optionally narrowed to one scope
|
|
83
|
+
* and/or one subject `domain`.
|
|
84
|
+
*/
|
|
85
|
+
countByType(opts = {}) {
|
|
86
|
+
return this.http.send("POST", endpoints.memoryTool(this.vaultId, "record_count_by_type"), { body: { scope: opts.scope, domain: opts.domain } });
|
|
37
87
|
}
|
|
38
88
|
}
|
|
39
89
|
//# sourceMappingURL=memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/internal/memory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/internal/memory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AA2BjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,MAAM;IAEE;IACA;IAFnB,YACmB,IAAqB,EACrB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAiB;QACrB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ,oFAAoF;IACpF,MAAM,CACJ,KAAa,EACb,OAiBI,EAAE;QAEN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE;YACjF,IAAI,EAAE;gBACJ,KAAK;gBACL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