@agent-assembly/sdk 0.0.1-beta.3 → 0.0.1-beta.5

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.
Files changed (75) hide show
  1. package/README.md +36 -23
  2. package/dist/cjs/core/gateway-resolver.js +73 -3
  3. package/dist/cjs/core/init-assembly.js +155 -33
  4. package/dist/cjs/core/redact.js +63 -0
  5. package/dist/cjs/gateway/client.js +63 -1
  6. package/dist/cjs/gateway/index.js +2 -1
  7. package/dist/cjs/hooks/ai-sdk.js +46 -10
  8. package/dist/cjs/hooks/langchain.js +12 -3
  9. package/dist/cjs/hooks/mastra.js +10 -6
  10. package/dist/cjs/hooks/openai-agents.js +1 -3
  11. package/dist/cjs/index.js +9 -1
  12. package/dist/cjs/native/client.js +94 -25
  13. package/dist/cjs/op-control.js +159 -17
  14. package/dist/cjs/runtime.js +73 -7
  15. package/dist/cjs/wrappers/with-assembly.js +89 -32
  16. package/dist/esm/core/gateway-resolver.js +72 -3
  17. package/dist/esm/core/gateway-resolver.js.map +1 -1
  18. package/dist/esm/core/init-assembly.js +154 -32
  19. package/dist/esm/core/init-assembly.js.map +1 -1
  20. package/dist/esm/core/redact.js +59 -0
  21. package/dist/esm/core/redact.js.map +1 -0
  22. package/dist/esm/gateway/client.js +62 -1
  23. package/dist/esm/gateway/client.js.map +1 -1
  24. package/dist/esm/gateway/index.js +1 -1
  25. package/dist/esm/gateway/index.js.map +1 -1
  26. package/dist/esm/hooks/ai-sdk.js +46 -10
  27. package/dist/esm/hooks/ai-sdk.js.map +1 -1
  28. package/dist/esm/hooks/langchain.js +12 -3
  29. package/dist/esm/hooks/langchain.js.map +1 -1
  30. package/dist/esm/hooks/mastra.js +10 -6
  31. package/dist/esm/hooks/mastra.js.map +1 -1
  32. package/dist/esm/hooks/openai-agents.js +1 -3
  33. package/dist/esm/hooks/openai-agents.js.map +1 -1
  34. package/dist/esm/index.js +6 -0
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/native/client.js +91 -24
  37. package/dist/esm/native/client.js.map +1 -1
  38. package/dist/esm/op-control.js +124 -17
  39. package/dist/esm/op-control.js.map +1 -1
  40. package/dist/esm/runtime.js +72 -7
  41. package/dist/esm/runtime.js.map +1 -1
  42. package/dist/esm/wrappers/with-assembly.js +89 -32
  43. package/dist/esm/wrappers/with-assembly.js.map +1 -1
  44. package/dist/types/core/gateway-resolver.d.ts +18 -1
  45. package/dist/types/core/gateway-resolver.d.ts.map +1 -1
  46. package/dist/types/core/init-assembly.d.ts +2 -1
  47. package/dist/types/core/init-assembly.d.ts.map +1 -1
  48. package/dist/types/core/redact.d.ts +28 -0
  49. package/dist/types/core/redact.d.ts.map +1 -0
  50. package/dist/types/gateway/client.d.ts +17 -0
  51. package/dist/types/gateway/client.d.ts.map +1 -1
  52. package/dist/types/gateway/index.d.ts +1 -1
  53. package/dist/types/gateway/index.d.ts.map +1 -1
  54. package/dist/types/hooks/ai-sdk.d.ts +13 -0
  55. package/dist/types/hooks/ai-sdk.d.ts.map +1 -1
  56. package/dist/types/hooks/langchain.d.ts +11 -0
  57. package/dist/types/hooks/langchain.d.ts.map +1 -1
  58. package/dist/types/hooks/mastra.d.ts.map +1 -1
  59. package/dist/types/hooks/openai-agents.d.ts.map +1 -1
  60. package/dist/types/index.d.ts +4 -1
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/native/client.d.ts +44 -0
  63. package/dist/types/native/client.d.ts.map +1 -1
  64. package/dist/types/op-control.d.ts +71 -7
  65. package/dist/types/op-control.d.ts.map +1 -1
  66. package/dist/types/runtime.d.ts +27 -5
  67. package/dist/types/runtime.d.ts.map +1 -1
  68. package/dist/types/types/assembly-config.d.ts +6 -0
  69. package/dist/types/types/assembly-config.d.ts.map +1 -1
  70. package/dist/types/wrappers/index.d.ts +1 -1
  71. package/dist/types/wrappers/index.d.ts.map +1 -1
  72. package/dist/types/wrappers/with-assembly.d.ts +25 -0
  73. package/dist/types/wrappers/with-assembly.d.ts.map +1 -1
  74. package/native/aa-ffi-node/index.d.ts +82 -1
  75. package/package.json +18 -5
@@ -1 +1 @@
1
- {"version":3,"file":"op-control.d.ts","sourceRoot":"","sources":["../../src/op-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAE1B,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAIjB,MAAM,6BAA6B,CAAC;AAUrC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,CACf,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAC3B,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,eAAe,CAAC;CACvC;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAqC;IACzD,OAAO,CAAC,IAAI,CAAuD;IACnE,OAAO,CAAC,KAAK,CAAQ;IAErB,OAAO;IAKP,wEAAwE;WAC1D,OAAO,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,0BAA0B,GAC/B,mBAAmB;IAiBtB;;OAEG;IACI,KAAK,IAAI,IAAI;IAOpB,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,IAAI;IAS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11
  export declare const BINARY_NAME = "aasm";
12
12
  export declare const DEFAULT_PORT = 7878;
13
13
  export declare const DEFAULT_RUNTIME_HOST = "127.0.0.1";
14
+ /**
15
+ * Opt-in gate for spawning the `aasm` sidecar. Auto-start runs a binary
16
+ * discovered from `$PATH` / the filesystem, so it is a privileged side effect
17
+ * that must be explicitly enabled rather than triggered silently by every
18
+ * `initAssembly()` call. Set to `1`/`true`/`yes` to permit auto-start.
19
+ */
20
+ export declare const ENV_AUTO_START = "AA_AUTO_START";
14
21
  export declare const USER_LOCAL_BIN: string;
15
22
  export declare const DOCKER_BASE_BIN = "/usr/local/bin";
16
23
  export declare const RUNTIME_LOG_FILENAME = ".aasm-runtime.log";
@@ -32,6 +39,14 @@ export declare function findAasmBinary(): string | null;
32
39
  * unreachable) resolves to `false` and is treated as no sidecar.
33
40
  */
34
41
  export declare function isRunning(port?: number, host?: string): Promise<boolean>;
42
+ /**
43
+ * Throw `Error` unless `binaryPath` is safe to spawn: it must be absolute and
44
+ * either resolve inside an allow-listed install dir (see
45
+ * {@link allowedInstallDirs}) or be the npm-bundled runtime binary. This is the
46
+ * integrity gate for the auto-start subprocess — without it the SDK would
47
+ * execute whatever `aasm` happened to be first on `$PATH`.
48
+ */
49
+ export declare function assertSafeBinaryPath(binaryPath: string): void;
35
50
  /**
36
51
  * Spawn `aasm serve --port <port>` as a detached background subprocess.
37
52
  *
@@ -49,11 +64,18 @@ export declare function startRuntime(binaryPath: string, port?: number, logDir?:
49
64
  * 2. Resolve the binary via {@link findAasmBinary}.
50
65
  * 3. Spawn the sidecar via {@link startRuntime}.
51
66
  *
52
- * `agentId` is accepted to keep the ticket-specified signature stable;
53
- * actual register-and-connect is performed by the existing gateway-aware
54
- * `@agent-assembly/sdk` `initAssembly` once the sidecar is reachable.
67
+ * `_agentId` is accepted to keep the ticket-specified signature stable but is
68
+ * intentionally not consumed at this lifecycle layer; actual register-and-connect
69
+ * is performed by the existing gateway-aware `@agent-assembly/sdk` `initAssembly`
70
+ * once the sidecar is reachable.
71
+ *
72
+ * Auto-start is **opt-in**: when the sidecar is not already running, this
73
+ * throws unless `AA_AUTO_START` is enabled. When it does spawn, the resolved
74
+ * binary path is logged and integrity-checked via {@link assertSafeBinaryPath}.
55
75
  *
56
- * Throws `Error` with {@link INSTALL_HINT} when no binary is found.
76
+ * Throws `Error` with {@link INSTALL_HINT} when no binary is found, and a
77
+ * descriptive `Error` when auto-start is not opted in or the resolved binary
78
+ * fails the integrity check.
57
79
  */
58
- export declare function initAssembly(agentId?: string, port?: number): Promise<void>;
80
+ export declare function initAssembly(_agentId?: string, port?: number): Promise<void>;
59
81
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAQ9D,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,eAAO,MAAM,cAAc,EAAE,MAAyC,CAAC;AACvE,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,oBAAoB,sBAAsB,CAAC;AAExD,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,EAAE,MAA0C,CAAC;AAE5E,eAAO,MAAM,YAAY,EAAE,MAKf,CAAC;AAsBb;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAa9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,GAAE,MAAqB,EAC3B,IAAI,GAAE,MAA6B,GAClC,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,MAAqB,EAC3B,MAAM,GAAE,MAAc,GACrB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C,IAAI,CAAC,CAgBf"}
@@ -25,6 +25,12 @@ export interface AssemblyConfig {
25
25
  */
26
26
  apiKey?: string;
27
27
  agentId?: string;
28
+ /**
29
+ * Human-readable agent name recorded by the gateway at registration
30
+ * (AAASM-3400). Descriptive metadata only; when omitted it falls back to
31
+ * ``agentId``.
32
+ */
33
+ name?: string;
28
34
  mode?: AssemblyMode;
29
35
  gatewayClient?: GatewayClient;
30
36
  langchain?: LangChainAdapterConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"assembly-config.d.ts","sourceRoot":"","sources":["../../../src/types/assembly-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC"}
1
+ {"version":3,"file":"assembly-config.d.ts","sourceRoot":"","sources":["../../../src/types/assembly-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC"}
@@ -1,3 +1,3 @@
1
1
  export { withAssembly } from "./with-assembly.js";
2
- export type { WithAssemblyOptions } from "./with-assembly.js";
2
+ export type { OpControl, WithAssemblyOptions } from "./with-assembly.js";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wrappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wrappers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,9 +1,34 @@
1
1
  import type { GatewayClient } from "../gateway/client.js";
2
2
  import type { ToolMap } from "../types/tool-map.js";
3
+ /**
4
+ * Narrow seam onto the live op-control consumer (AAASM-3491).
5
+ *
6
+ * The wrapper only needs to *wait until an op is runnable* — a pause blocks
7
+ * here cooperatively, a terminate rejects with {@link OpTerminatedError}.
8
+ * Depending on this strip rather than the concrete `OpControlSubscriber` keeps
9
+ * the wrapper decoupled from the gRPC transport and lets tests drive it without
10
+ * a live stream; the real `OpControlSubscriber` satisfies it structurally. This
11
+ * mirrors the Python companion's `build_governance_interceptor(op_control=...)`
12
+ * seam.
13
+ */
14
+ export interface OpControl {
15
+ waitForOp(opId: string, opts?: {
16
+ timeoutMs?: number;
17
+ }): Promise<void>;
18
+ }
3
19
  export interface WithAssemblyOptions {
4
20
  gatewayClient: GatewayClient;
5
21
  agentId?: string;
6
22
  approvalTimeoutMs?: number;
23
+ /**
24
+ * Live op-control consumer. When supplied, the gateway kill switch
25
+ * (AAASM-3491) is honored *in this tool path*: before the pre-exec gateway
26
+ * check, a terminated op fast-fails the call and a paused op blocks
27
+ * cooperatively until the gateway resumes it. Optional — without it the tool
28
+ * path behaves exactly as before (gateway check + approval only), and op
29
+ * control reaches the agent solely via the native runtime's own stream.
30
+ */
31
+ opControl?: OpControl;
7
32
  }
8
33
  export declare function withAssembly<TTool, TTools extends ToolMap<TTool>>(tools: TTools, options: WithAssemblyOptions): TTools;
9
34
  //# sourceMappingURL=with-assembly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"with-assembly.d.ts","sourceRoot":"","sources":["../../../src/wrappers/with-assembly.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AA+GD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,SAAS,OAAO,CAAC,KAAK,CAAC,EAC/D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAKR"}
1
+ {"version":3,"file":"with-assembly.d.ts","sourceRoot":"","sources":["../../../src/wrappers/with-assembly.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAsKD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,SAAS,OAAO,CAAC,KAAK,CAAC,EAC/D,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAKR"}
@@ -15,8 +15,15 @@ export declare class ClientHandle {
15
15
  * Socket resolution, the background IPC thread, and the wire codec are all
16
16
  * delegated to `aa-sdk-client`; this shim only validates the argument and
17
17
  * wraps the resulting client.
18
+ *
19
+ * `agentId` is the agent identity the background thread signs the runtime
20
+ * session handshake with (AAASM-3587). `sdkVersion` is the user-facing npm
21
+ * package version (`@agent-assembly/sdk`) the JS layer forwards so it — not the
22
+ * shared `aa-sdk-client` crate version — is what gets signed into the handshake
23
+ * proof (AAASM-3683); `undefined` falls back to the crate version (no
24
+ * regression vs AAASM-3666).
18
25
  */
19
- export declare function connect(socketPath: string): Promise<ClientHandle>
26
+ export declare function connect(socketPath: string, agentId?: string | undefined | null, sdkVersion?: string | undefined | null): Promise<ClientHandle>
20
27
 
21
28
  /**
22
29
  * Shut down the session and join the background IPC thread.
@@ -27,6 +34,80 @@ export declare function connect(socketPath: string): Promise<ClientHandle>
27
34
  */
28
35
  export declare function disconnect(handle: ClientHandle): Promise<void>
29
36
 
37
+ /**
38
+ * A policy verdict returned to JS.
39
+ *
40
+ * `decision` is one of `"allow"`, `"deny"`, `"pending"`, `"redact"`; `reason`
41
+ * is the human-readable explanation from the policy engine (or the fail-open
42
+ * note when the runtime did not answer).
43
+ */
44
+ export interface PolicyDecision {
45
+ decision: string
46
+ reason: string
47
+ }
48
+
49
+ /**
50
+ * Query the runtime for a policy decision on an action.
51
+ *
52
+ * The JS query object is translated into a `CheckActionRequest` (agent id,
53
+ * action type, and — for tool calls — tool name / source / args) and handed
54
+ * to [`AssemblyClient::query_policy`], which blocks its calling thread for up
55
+ * to 5s waiting on the runtime's `CheckActionResponse`. That blocking call is
56
+ * run on a `spawn_blocking` task — exactly like [`disconnect`] — so the napi
57
+ * async runtime stays free and the **Node event loop is never blocked** while
58
+ * a slow runtime is answering.
59
+ *
60
+ * **Fail-open:** the SDK is advisory, not a security boundary. When the
61
+ * runtime does not return a decision — it is too slow or the connection
62
+ * closed ([`SdkClientError::QueryFailed`]), or it was never reachable so the
63
+ * IPC channel is closed / the session is shut down — this returns a non-deny
64
+ * `"allow"` so a missing or degraded runtime never blocks the agent (the
65
+ * proxy / eBPF layers remain authoritative). Only a genuine local fault
66
+ * (a poisoned lock) surfaces as a typed error.
67
+ */
68
+ export declare function queryPolicy(handle: ClientHandle, query: any): Promise<PolicyDecision>
69
+
70
+ /**
71
+ * Register this agent with the governance gateway and store the issued
72
+ * credential token on the session.
73
+ *
74
+ * This is the **only** direct SDK→gateway gRPC call (per ADR 0004);
75
+ * `CheckAction` still flows through `aa-runtime`. The token the gateway issues
76
+ * is stored inside the shared [`AssemblyClient`] and then attached to every
77
+ * subsequent [`query_policy`] request so the gateway's
78
+ * `validate_credential_token` does not deny a registered agent.
79
+ *
80
+ * Delegates to [`AssemblyClient::register`], an async tonic call, so this napi
81
+ * function is itself `async` and awaits it without blocking the Node event
82
+ * loop. Returns the assigned policy id reported by the gateway. A failed
83
+ * registration — gateway unreachable, identity rejected — surfaces as a typed
84
+ * error so the caller can decide whether to proceed unregistered.
85
+ */
86
+ export declare function register(handle: ClientHandle, options: RegisterOptions): Promise<string>
87
+
88
+ /**
89
+ * Parameters for [`register`].
90
+ *
91
+ * `agentId` is the agent identity the gateway registers (derived into a
92
+ * `did:key` + Ed25519 public key by the shared client). `name` and `framework`
93
+ * are descriptive metadata the gateway records. `gatewayEndpoint` overrides the
94
+ * gateway gRPC endpoint (default resolved from `AA_GATEWAY_ENDPOINT` or
95
+ * `http://127.0.0.1:50051`).
96
+ *
97
+ * `teamId` and `parentAgentId` carry the agent's lineage/team scoping to the
98
+ * gateway on register (AAASM-3415): `teamId` drives team-budget attribution
99
+ * and `parentAgentId` the topology graph. Both are optional — omit for a
100
+ * team-unscoped / root agent.
101
+ */
102
+ export interface RegisterOptions {
103
+ agentId: string
104
+ name: string
105
+ framework: string
106
+ gatewayEndpoint?: string
107
+ teamId?: string
108
+ parentAgentId?: string
109
+ }
110
+
30
111
  /**
31
112
  * Ship a captured event to the runtime.
32
113
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-assembly/sdk",
3
- "version": "0.0.1-beta.3",
3
+ "version": "0.0.1-beta.5",
4
4
  "description": "TypeScript SDK for Agent Assembly",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -30,12 +30,24 @@
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@langchain/core": ">=0.3.0",
33
+ "@langchain/langgraph": ">=1.0.0",
34
+ "ai": ">=5.0.0",
35
+ "@mastra/core": ">=0.20.0",
33
36
  "@openai/agents": ">=0.1.0"
34
37
  },
35
38
  "peerDependenciesMeta": {
36
39
  "@langchain/core": {
37
40
  "optional": true
38
41
  },
42
+ "@langchain/langgraph": {
43
+ "optional": true
44
+ },
45
+ "ai": {
46
+ "optional": true
47
+ },
48
+ "@mastra/core": {
49
+ "optional": true
50
+ },
39
51
  "@openai/agents": {
40
52
  "optional": true
41
53
  }
@@ -46,6 +58,7 @@
46
58
  "@types/js-yaml": "^4.0.9",
47
59
  "@types/node": "^25.9.1",
48
60
  "@vitest/coverage-v8": "^3.2.6",
61
+ "ai": "^6.0.0",
49
62
  "blocked-at": "^1.2.0",
50
63
  "eslint": "^10.4.1",
51
64
  "grpc-tools": "^1.13.1",
@@ -64,10 +77,10 @@
64
77
  "nodejs"
65
78
  ],
66
79
  "optionalDependencies": {
67
- "@agent-assembly/runtime-darwin-arm64": "0.0.1-beta.3",
68
- "@agent-assembly/runtime-darwin-x64": "0.0.1-beta.3",
69
- "@agent-assembly/runtime-linux-arm64": "0.0.1-beta.3",
70
- "@agent-assembly/runtime-linux-x64": "0.0.1-beta.3"
80
+ "@agent-assembly/runtime-darwin-arm64": "0.0.1-beta.5",
81
+ "@agent-assembly/runtime-darwin-x64": "0.0.1-beta.5",
82
+ "@agent-assembly/runtime-linux-arm64": "0.0.1-beta.5",
83
+ "@agent-assembly/runtime-linux-x64": "0.0.1-beta.5"
71
84
  },
72
85
  "files": [
73
86
  "dist/",