@agent-assembly/sdk 0.0.1-alpha.3
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 +176 -0
- package/README.md +182 -0
- package/dist/cjs/adapters/adapter-registry.js +2 -0
- package/dist/cjs/adapters/adapter.js +2 -0
- package/dist/cjs/adapters/index.js +2 -0
- package/dist/cjs/adapters/langchain/assembly-callback-handler.js +93 -0
- package/dist/cjs/adapters/langchain/index.js +8 -0
- package/dist/cjs/adapters/langchain/wrap-tool-with-assembly.js +55 -0
- package/dist/cjs/audit/encode.js +176 -0
- package/dist/cjs/audit/index.js +8 -0
- package/dist/cjs/core/gateway-resolver.js +254 -0
- package/dist/cjs/core/index.js +9 -0
- package/dist/cjs/core/init-assembly.js +224 -0
- package/dist/cjs/errors/configuration-error.js +17 -0
- package/dist/cjs/errors/gateway-error.js +17 -0
- package/dist/cjs/errors/index.js +11 -0
- package/dist/cjs/errors/op-terminated-error.js +20 -0
- package/dist/cjs/errors/policy-violation-error.js +10 -0
- package/dist/cjs/gateway/client.js +15 -0
- package/dist/cjs/gateway/index.js +5 -0
- package/dist/cjs/hooks/adapter-registry.js +7 -0
- package/dist/cjs/hooks/ai-sdk-detection.js +14 -0
- package/dist/cjs/hooks/ai-sdk.js +164 -0
- package/dist/cjs/hooks/langchain.js +9 -0
- package/dist/cjs/hooks/langgraph-detection.js +14 -0
- package/dist/cjs/hooks/langgraph.js +107 -0
- package/dist/cjs/hooks/mastra-detection.js +14 -0
- package/dist/cjs/hooks/mastra.js +120 -0
- package/dist/cjs/hooks/openai-agents-detection.js +14 -0
- package/dist/cjs/hooks/openai-agents.js +189 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/lineage/agent-context-store.js +20 -0
- package/dist/cjs/lineage/index.js +7 -0
- package/dist/cjs/native/client.js +160 -0
- package/dist/cjs/op-control.js +150 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/proto/generated/common.js +365 -0
- package/dist/cjs/proto/generated/policy.js +1418 -0
- package/dist/cjs/runtime.js +144 -0
- package/dist/cjs/types/assembly-config.js +2 -0
- package/dist/cjs/types/assembly-context.js +2 -0
- package/dist/cjs/types/assembly-mode.js +2 -0
- package/dist/cjs/types/audit.js +5 -0
- package/dist/cjs/types/enforcement-mode.js +9 -0
- package/dist/cjs/types/gateway-governance.js +2 -0
- package/dist/cjs/types/index.js +5 -0
- package/dist/cjs/types/langchain-adapter.js +2 -0
- package/dist/cjs/types/openai-agents-adapter.js +2 -0
- package/dist/cjs/types/policy.js +2 -0
- package/dist/cjs/types/tool-map.js +2 -0
- package/dist/cjs/types/vercel-ai-adapter.js +2 -0
- package/dist/cjs/wrappers/index.js +5 -0
- package/dist/cjs/wrappers/with-assembly.js +82 -0
- package/dist/esm/adapters/adapter-registry.js +2 -0
- package/dist/esm/adapters/adapter-registry.js.map +1 -0
- package/dist/esm/adapters/adapter.js +2 -0
- package/dist/esm/adapters/adapter.js.map +1 -0
- package/dist/esm/adapters/index.js +2 -0
- package/dist/esm/adapters/index.js.map +1 -0
- package/dist/esm/adapters/langchain/assembly-callback-handler.js +90 -0
- package/dist/esm/adapters/langchain/assembly-callback-handler.js.map +1 -0
- package/dist/esm/adapters/langchain/index.js +3 -0
- package/dist/esm/adapters/langchain/index.js.map +1 -0
- package/dist/esm/adapters/langchain/wrap-tool-with-assembly.js +52 -0
- package/dist/esm/adapters/langchain/wrap-tool-with-assembly.js.map +1 -0
- package/dist/esm/audit/encode.js +171 -0
- package/dist/esm/audit/encode.js.map +1 -0
- package/dist/esm/audit/index.js +2 -0
- package/dist/esm/audit/index.js.map +1 -0
- package/dist/esm/core/gateway-resolver.js +213 -0
- package/dist/esm/core/gateway-resolver.js.map +1 -0
- package/dist/esm/core/index.js +2 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/init-assembly.js +218 -0
- package/dist/esm/core/init-assembly.js.map +1 -0
- package/dist/esm/errors/configuration-error.js +14 -0
- package/dist/esm/errors/configuration-error.js.map +1 -0
- package/dist/esm/errors/gateway-error.js +14 -0
- package/dist/esm/errors/gateway-error.js.map +1 -0
- package/dist/esm/errors/index.js +5 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/errors/op-terminated-error.js +17 -0
- package/dist/esm/errors/op-terminated-error.js.map +1 -0
- package/dist/esm/errors/policy-violation-error.js +7 -0
- package/dist/esm/errors/policy-violation-error.js.map +1 -0
- package/dist/esm/gateway/client.js +13 -0
- package/dist/esm/gateway/client.js.map +1 -0
- package/dist/esm/gateway/index.js +2 -0
- package/dist/esm/gateway/index.js.map +1 -0
- package/dist/esm/hooks/adapter-registry.js +5 -0
- package/dist/esm/hooks/adapter-registry.js.map +1 -0
- package/dist/esm/hooks/ai-sdk-detection.js +12 -0
- package/dist/esm/hooks/ai-sdk-detection.js.map +1 -0
- package/dist/esm/hooks/ai-sdk.js +123 -0
- package/dist/esm/hooks/ai-sdk.js.map +1 -0
- package/dist/esm/hooks/langchain.js +7 -0
- package/dist/esm/hooks/langchain.js.map +1 -0
- package/dist/esm/hooks/langgraph-detection.js +12 -0
- package/dist/esm/hooks/langgraph-detection.js.map +1 -0
- package/dist/esm/hooks/langgraph.js +69 -0
- package/dist/esm/hooks/langgraph.js.map +1 -0
- package/dist/esm/hooks/mastra-detection.js +12 -0
- package/dist/esm/hooks/mastra-detection.js.map +1 -0
- package/dist/esm/hooks/mastra.js +83 -0
- package/dist/esm/hooks/mastra.js.map +1 -0
- package/dist/esm/hooks/openai-agents-detection.js +12 -0
- package/dist/esm/hooks/openai-agents-detection.js.map +1 -0
- package/dist/esm/hooks/openai-agents.js +145 -0
- package/dist/esm/hooks/openai-agents.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lineage/agent-context-store.js +16 -0
- package/dist/esm/lineage/agent-context-store.js.map +1 -0
- package/dist/esm/lineage/index.js +2 -0
- package/dist/esm/lineage/index.js.map +1 -0
- package/dist/esm/native/client.js +150 -0
- package/dist/esm/native/client.js.map +1 -0
- package/dist/esm/op-control.js +147 -0
- package/dist/esm/op-control.js.map +1 -0
- package/dist/esm/proto/generated/common.js +357 -0
- package/dist/esm/proto/generated/common.js.map +1 -0
- package/dist/esm/proto/generated/policy.js +1414 -0
- package/dist/esm/proto/generated/policy.js.map +1 -0
- package/dist/esm/runtime.js +138 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/types/assembly-config.js +2 -0
- package/dist/esm/types/assembly-config.js.map +1 -0
- package/dist/esm/types/assembly-context.js +2 -0
- package/dist/esm/types/assembly-context.js.map +1 -0
- package/dist/esm/types/assembly-mode.js +2 -0
- package/dist/esm/types/assembly-mode.js.map +1 -0
- package/dist/esm/types/audit.js +5 -0
- package/dist/esm/types/audit.js.map +1 -0
- package/dist/esm/types/enforcement-mode.js +7 -0
- package/dist/esm/types/enforcement-mode.js.map +1 -0
- package/dist/esm/types/gateway-governance.js +2 -0
- package/dist/esm/types/gateway-governance.js.map +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/langchain-adapter.js +2 -0
- package/dist/esm/types/langchain-adapter.js.map +1 -0
- package/dist/esm/types/openai-agents-adapter.js +2 -0
- package/dist/esm/types/openai-agents-adapter.js.map +1 -0
- package/dist/esm/types/policy.js +2 -0
- package/dist/esm/types/policy.js.map +1 -0
- package/dist/esm/types/tool-map.js +2 -0
- package/dist/esm/types/tool-map.js.map +1 -0
- package/dist/esm/types/vercel-ai-adapter.js +2 -0
- package/dist/esm/types/vercel-ai-adapter.js.map +1 -0
- package/dist/esm/wrappers/index.js +2 -0
- package/dist/esm/wrappers/index.js.map +1 -0
- package/dist/esm/wrappers/with-assembly.js +80 -0
- package/dist/esm/wrappers/with-assembly.js.map +1 -0
- package/dist/types/adapters/adapter-registry.d.ts +7 -0
- package/dist/types/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/types/adapters/adapter.d.ts +6 -0
- package/dist/types/adapters/adapter.d.ts.map +1 -0
- package/dist/types/adapters/index.d.ts +3 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/langchain/assembly-callback-handler.d.ts +21 -0
- package/dist/types/adapters/langchain/assembly-callback-handler.d.ts.map +1 -0
- package/dist/types/adapters/langchain/index.d.ts +4 -0
- package/dist/types/adapters/langchain/index.d.ts.map +1 -0
- package/dist/types/adapters/langchain/wrap-tool-with-assembly.d.ts +9 -0
- package/dist/types/adapters/langchain/wrap-tool-with-assembly.d.ts.map +1 -0
- package/dist/types/audit/encode.d.ts +77 -0
- package/dist/types/audit/encode.d.ts.map +1 -0
- package/dist/types/audit/index.d.ts +3 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/core/gateway-resolver.d.ts +92 -0
- package/dist/types/core/gateway-resolver.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/init-assembly.d.ts +10 -0
- package/dist/types/core/init-assembly.d.ts.map +1 -0
- package/dist/types/errors/configuration-error.d.ts +11 -0
- package/dist/types/errors/configuration-error.d.ts.map +1 -0
- package/dist/types/errors/gateway-error.d.ts +11 -0
- package/dist/types/errors/gateway-error.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +5 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/errors/op-terminated-error.d.ts +13 -0
- package/dist/types/errors/op-terminated-error.d.ts.map +1 -0
- package/dist/types/errors/policy-violation-error.d.ts +4 -0
- package/dist/types/errors/policy-violation-error.d.ts.map +1 -0
- package/dist/types/gateway/client.d.ts +14 -0
- package/dist/types/gateway/client.d.ts.map +1 -0
- package/dist/types/gateway/index.d.ts +3 -0
- package/dist/types/gateway/index.d.ts.map +1 -0
- package/dist/types/hooks/adapter-registry.d.ts +3 -0
- package/dist/types/hooks/adapter-registry.d.ts.map +1 -0
- package/dist/types/hooks/ai-sdk-detection.d.ts +2 -0
- package/dist/types/hooks/ai-sdk-detection.d.ts.map +1 -0
- package/dist/types/hooks/ai-sdk.d.ts +36 -0
- package/dist/types/hooks/ai-sdk.d.ts.map +1 -0
- package/dist/types/hooks/langchain.d.ts +3 -0
- package/dist/types/hooks/langchain.d.ts.map +1 -0
- package/dist/types/hooks/langgraph-detection.d.ts +2 -0
- package/dist/types/hooks/langgraph-detection.d.ts.map +1 -0
- package/dist/types/hooks/langgraph.d.ts +26 -0
- package/dist/types/hooks/langgraph.d.ts.map +1 -0
- package/dist/types/hooks/mastra-detection.d.ts +2 -0
- package/dist/types/hooks/mastra-detection.d.ts.map +1 -0
- package/dist/types/hooks/mastra.d.ts +29 -0
- package/dist/types/hooks/mastra.d.ts.map +1 -0
- package/dist/types/hooks/openai-agents-detection.d.ts +2 -0
- package/dist/types/hooks/openai-agents-detection.d.ts.map +1 -0
- package/dist/types/hooks/openai-agents.d.ts +42 -0
- package/dist/types/hooks/openai-agents.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lineage/agent-context-store.d.ts +12 -0
- package/dist/types/lineage/agent-context-store.d.ts.map +1 -0
- package/dist/types/lineage/index.d.ts +2 -0
- package/dist/types/lineage/index.d.ts.map +1 -0
- package/dist/types/native/client.d.ts +26 -0
- package/dist/types/native/client.d.ts.map +1 -0
- package/dist/types/op-control.d.ts +85 -0
- package/dist/types/op-control.d.ts.map +1 -0
- package/dist/types/proto/generated/common.d.ts +90 -0
- package/dist/types/proto/generated/common.d.ts.map +1 -0
- package/dist/types/proto/generated/policy.d.ts +298 -0
- package/dist/types/proto/generated/policy.d.ts.map +1 -0
- package/dist/types/runtime.d.ts +59 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/types/assembly-config.d.ts +47 -0
- package/dist/types/types/assembly-config.d.ts.map +1 -0
- package/dist/types/types/assembly-context.d.ts +12 -0
- package/dist/types/types/assembly-context.d.ts.map +1 -0
- package/dist/types/types/assembly-mode.d.ts +2 -0
- package/dist/types/types/assembly-mode.d.ts.map +1 -0
- package/dist/types/types/audit.d.ts +76 -0
- package/dist/types/types/audit.d.ts.map +1 -0
- package/dist/types/types/enforcement-mode.d.ts +20 -0
- package/dist/types/types/enforcement-mode.d.ts.map +1 -0
- package/dist/types/types/gateway-governance.d.ts +31 -0
- package/dist/types/types/gateway-governance.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +12 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/langchain-adapter.d.ts +25 -0
- package/dist/types/types/langchain-adapter.d.ts.map +1 -0
- package/dist/types/types/openai-agents-adapter.d.ts +17 -0
- package/dist/types/types/openai-agents-adapter.d.ts.map +1 -0
- package/dist/types/types/policy.d.ts +10 -0
- package/dist/types/types/policy.d.ts.map +1 -0
- package/dist/types/types/tool-map.d.ts +2 -0
- package/dist/types/types/tool-map.d.ts.map +1 -0
- package/dist/types/types/vercel-ai-adapter.d.ts +12 -0
- package/dist/types/types/vercel-ai-adapter.d.ts.map +1 -0
- package/dist/types/wrappers/index.d.ts +3 -0
- package/dist/types/wrappers/index.d.ts.map +1 -0
- package/dist/types/wrappers/with-assembly.d.ts +9 -0
- package/dist/types/wrappers/with-assembly.d.ts.map +1 -0
- package/native/aa-ffi-node/index.cjs +20 -0
- package/native/aa-ffi-node/index.d.ts +23 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# @agent-assembly/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@agent-assembly/sdk)
|
|
4
|
+
[](https://github.com/AI-agent-assembly/node-sdk/actions/workflows/test-matrix.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://sonarcloud.io/summary/new_code?id=AI-agent-assembly_node-sdk)
|
|
7
|
+
[](https://codecov.io/gh/AI-agent-assembly/node-sdk)
|
|
8
|
+
|
|
9
|
+
TypeScript/Node.js SDK for Agent Assembly, licensed under Apache 2.0.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
Before installing or contributing, ensure your environment has:
|
|
14
|
+
|
|
15
|
+
- **Node.js** ≥ 18.18.0 (LTS). The active LTS lines (18, 20, 22, 24) are exercised in CI.
|
|
16
|
+
- **pnpm** ≥ 10. The repository enforces pnpm via `engines` and ships a `pnpm-lock.yaml`.
|
|
17
|
+
- **Rust toolchain** (only required when rebuilding the native `aa-ffi-node` binding from
|
|
18
|
+
source — most consumers receive a prebuilt platform binary via `optionalDependencies`).
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @agent-assembly/sdk
|
|
24
|
+
# or
|
|
25
|
+
npm install @agent-assembly/sdk
|
|
26
|
+
# or
|
|
27
|
+
yarn add @agent-assembly/sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The SDK ships dual ESM/CJS entries and selects a prebuilt native binding for your platform
|
|
31
|
+
during `postinstall`. No additional build step is required for typical consumers.
|
|
32
|
+
|
|
33
|
+
## Quickstart
|
|
34
|
+
|
|
35
|
+
### ESM (`import`)
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { initAssembly, withAssembly } from "@agent-assembly/sdk";
|
|
39
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
40
|
+
|
|
41
|
+
const ctx = await initAssembly({ gatewayUrl: "http://localhost:8080", agentId: "demo" });
|
|
42
|
+
const governedTools = withAssembly(myTools, { context: ctx });
|
|
43
|
+
const model = new ChatOpenAI({ model: "gpt-4o-mini" }).bindTools(governedTools);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### CJS (`require`)
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const { initAssembly, withAssembly } = require("@agent-assembly/sdk");
|
|
50
|
+
const { ChatOpenAI } = require("@langchain/openai");
|
|
51
|
+
|
|
52
|
+
const ctx = await initAssembly({ gatewayUrl: "http://localhost:8080", agentId: "demo" });
|
|
53
|
+
const governedTools = withAssembly(myTools, { context: ctx });
|
|
54
|
+
const model = new ChatOpenAI({ model: "gpt-4o-mini" }).bindTools(governedTools);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Both entrypoints resolve to the same governance pipeline; the package's `exports` field
|
|
58
|
+
selects ESM or CJS automatically based on how the consumer imports it.
|
|
59
|
+
|
|
60
|
+
`initAssembly()` registers the LangChain callback handler and the AdapterRegistry, so any
|
|
61
|
+
tool wrapped by `withAssembly()` is checked against gateway policy before invocation.
|
|
62
|
+
|
|
63
|
+
## Supported Node.js versions
|
|
64
|
+
|
|
65
|
+
The SDK is tested against every active Node.js LTS line on every supported operating
|
|
66
|
+
system. The matrix is enforced by `.github/workflows/test-matrix.yml`:
|
|
67
|
+
|
|
68
|
+
| Node.js | Linux (ubuntu-latest) | macOS (macos-latest) | Windows (windows-latest) |
|
|
69
|
+
| ------- | --------------------- | -------------------- | ------------------------ |
|
|
70
|
+
| 18 | ✅ | ✅ | ✅ |
|
|
71
|
+
| 20 | ✅ | ✅ | ✅ |
|
|
72
|
+
| 22 | ✅ | ✅ | ✅ |
|
|
73
|
+
| 24 | ✅ | ✅ | ✅ |
|
|
74
|
+
|
|
75
|
+
Older Node.js lines (≤ 16) are unsupported because the napi-rs ABI used by the native
|
|
76
|
+
binding requires Node 18.18 or newer.
|
|
77
|
+
|
|
78
|
+
## Goal
|
|
79
|
+
|
|
80
|
+
Provide a thin wrapper around the Agent Assembly Rust runtime through:
|
|
81
|
+
|
|
82
|
+
- gRPC sidecar client (default)
|
|
83
|
+
- native in-process binding (napi-rs)
|
|
84
|
+
|
|
85
|
+
The primary entrypoint is `initAssembly()`, which prepares runtime governance and
|
|
86
|
+
registers framework hooks for supported tool ecosystems.
|
|
87
|
+
|
|
88
|
+
## Public Entrypoints
|
|
89
|
+
|
|
90
|
+
- `initAssembly(config)`
|
|
91
|
+
- `withAssembly(tools, options)`
|
|
92
|
+
|
|
93
|
+
## Policy Matching Constraint
|
|
94
|
+
|
|
95
|
+
Vercel AI SDK tools do not expose a `.name` field. Governance policies must match
|
|
96
|
+
by tool description content (or tool map key in wrapper context), not by strict
|
|
97
|
+
framework-level tool name.
|
|
98
|
+
|
|
99
|
+
## LangChain Blocking Model
|
|
100
|
+
|
|
101
|
+
LangChain callback `handleToolStart` cannot preempt execution by return value, so
|
|
102
|
+
this SDK applies a two-layer model:
|
|
103
|
+
|
|
104
|
+
- callback layer (`AssemblyCallbackHandler`) tracks deferred denials and redacts at `handleToolEnd`
|
|
105
|
+
- wrapper layer (`wrapToolWithAssembly`) enforces true pre-execution deny/pending checks
|
|
106
|
+
|
|
107
|
+
`initAssembly()` auto-registers the callback handler and auto-wraps configured
|
|
108
|
+
LangChain tools.
|
|
109
|
+
|
|
110
|
+
## Current Architecture Layout
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
src/
|
|
114
|
+
index.ts
|
|
115
|
+
core/
|
|
116
|
+
init-assembly.ts
|
|
117
|
+
adapters/
|
|
118
|
+
adapter.ts
|
|
119
|
+
adapter-registry.ts
|
|
120
|
+
langchain/
|
|
121
|
+
assembly-callback-handler.ts
|
|
122
|
+
wrap-tool-with-assembly.ts
|
|
123
|
+
gateway/
|
|
124
|
+
client.ts
|
|
125
|
+
wrappers/
|
|
126
|
+
with-assembly.ts
|
|
127
|
+
errors/
|
|
128
|
+
policy-violation-error.ts
|
|
129
|
+
types/
|
|
130
|
+
assembly-mode.ts
|
|
131
|
+
assembly-config.ts
|
|
132
|
+
assembly-context.ts
|
|
133
|
+
gateway-governance.ts
|
|
134
|
+
langchain-adapter.ts
|
|
135
|
+
tool-map.ts
|
|
136
|
+
tests/
|
|
137
|
+
architecture/
|
|
138
|
+
.github/workflows/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Native napi-rs Binding (AAASM-60)
|
|
142
|
+
|
|
143
|
+
The `aa-ffi-node` Rust crate is located at `native/aa-ffi-node`.
|
|
144
|
+
|
|
145
|
+
Build commands:
|
|
146
|
+
|
|
147
|
+
- `pnpm native:build` (debug/local)
|
|
148
|
+
- `pnpm native:build:release` (release + platform artifact)
|
|
149
|
+
- `pnpm native:check-types` (strict check for generated napi `.d.ts`)
|
|
150
|
+
|
|
151
|
+
Native integration acceptance test:
|
|
152
|
+
|
|
153
|
+
- `AA_NATIVE_TEST=1 pnpm vitest run tests/native-napi-integration.test.ts`
|
|
154
|
+
|
|
155
|
+
The `build-addon` GitHub workflow produces prebuilt `index.node` artifacts
|
|
156
|
+
for Node 18/20/22 on Linux/macOS/Windows.
|
|
157
|
+
|
|
158
|
+
## Packaging Layout (AAASM-61)
|
|
159
|
+
|
|
160
|
+
The package now publishes dual module outputs with explicit conditional exports:
|
|
161
|
+
|
|
162
|
+
- ESM entry: `./dist/esm/index.js`
|
|
163
|
+
- CJS entry: `./dist/cjs/index.js`
|
|
164
|
+
- Type declarations: `./dist/types/index.d.ts`
|
|
165
|
+
|
|
166
|
+
Platform-native binaries are declared via `optionalDependencies` and selected
|
|
167
|
+
during `postinstall` based on `process.platform` and `process.arch`.
|
|
168
|
+
|
|
169
|
+
Package verification checks include:
|
|
170
|
+
|
|
171
|
+
- ESM and CJS entry smoke tests
|
|
172
|
+
- export `types` mapping assertion
|
|
173
|
+
- `npm pack` content and package size guard tests
|
|
174
|
+
|
|
175
|
+
## Documentation
|
|
176
|
+
|
|
177
|
+
Full guides, architecture deep-dives, and the complete API reference are published at:
|
|
178
|
+
|
|
179
|
+
**https://ai-agent-assembly.github.io/node-sdk/**
|
|
180
|
+
|
|
181
|
+
The site is built from the `docs/` (content) and `website/` (Docusaurus app) directories
|
|
182
|
+
and is re-published on every push to `master` via the `publish-docs.yml` workflow.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssemblyCallbackHandler = void 0;
|
|
4
|
+
const base_1 = require("@langchain/core/callbacks/base");
|
|
5
|
+
const BLOCKED_OUTPUT = "[BLOCKED] This action was flagged as a policy violation.";
|
|
6
|
+
function getSerializedName(value) {
|
|
7
|
+
if (!value || typeof value !== "object") {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const candidate = value.name;
|
|
11
|
+
return typeof candidate === "string" ? candidate : undefined;
|
|
12
|
+
}
|
|
13
|
+
class AssemblyCallbackHandler extends base_1.BaseCallbackHandler {
|
|
14
|
+
gateway;
|
|
15
|
+
now;
|
|
16
|
+
pendingDenialMaxAgeMs;
|
|
17
|
+
name = "assembly_handler";
|
|
18
|
+
pendingDenials = new Map();
|
|
19
|
+
constructor(gateway, now = () => Date.now(), pendingDenialMaxAgeMs = 5 * 60 * 1000) {
|
|
20
|
+
super();
|
|
21
|
+
this.gateway = gateway;
|
|
22
|
+
this.now = now;
|
|
23
|
+
this.pendingDenialMaxAgeMs = pendingDenialMaxAgeMs;
|
|
24
|
+
}
|
|
25
|
+
async handleToolStart(tool, input, runId) {
|
|
26
|
+
this.cleanupExpiredPendingDenials();
|
|
27
|
+
const toolName = tool.name ?? getSerializedName(tool) ?? "unknown_tool";
|
|
28
|
+
const decision = await this.gateway.check({
|
|
29
|
+
action: "tool_call",
|
|
30
|
+
toolName,
|
|
31
|
+
args: input,
|
|
32
|
+
runId
|
|
33
|
+
});
|
|
34
|
+
await this.gateway.record({
|
|
35
|
+
action: "tool_start_check",
|
|
36
|
+
runId,
|
|
37
|
+
...(decision.reason ? { reason: decision.reason } : {})
|
|
38
|
+
});
|
|
39
|
+
if (decision.denied) {
|
|
40
|
+
this.pendingDenials.set(runId, {
|
|
41
|
+
reason: decision.reason ?? "Tool denied by policy.",
|
|
42
|
+
at: this.now()
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async handleToolEnd(output, runId) {
|
|
47
|
+
this.cleanupExpiredPendingDenials();
|
|
48
|
+
const pending = this.pendingDenials.get(runId);
|
|
49
|
+
if (pending) {
|
|
50
|
+
this.pendingDenials.delete(runId);
|
|
51
|
+
await this.gateway.record({
|
|
52
|
+
action: "policy_post_block",
|
|
53
|
+
runId,
|
|
54
|
+
reason: pending.reason
|
|
55
|
+
});
|
|
56
|
+
return BLOCKED_OUTPUT;
|
|
57
|
+
}
|
|
58
|
+
await this.gateway.recordResult({ runId, output });
|
|
59
|
+
return output;
|
|
60
|
+
}
|
|
61
|
+
async handleLLMStart(llm, prompts, runId) {
|
|
62
|
+
this.cleanupExpiredPendingDenials();
|
|
63
|
+
const modelName = llm.name ?? getSerializedName(llm);
|
|
64
|
+
await this.gateway.scanPrompts({
|
|
65
|
+
prompts,
|
|
66
|
+
runId,
|
|
67
|
+
...(modelName ? { modelName } : {})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async handleLLMEnd(output, runId) {
|
|
71
|
+
this.cleanupExpiredPendingDenials();
|
|
72
|
+
await this.gateway.record({
|
|
73
|
+
action: "llm_response",
|
|
74
|
+
runId,
|
|
75
|
+
output
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
cleanupExpiredPendingDenials(now = this.now()) {
|
|
79
|
+
let removed = 0;
|
|
80
|
+
for (const [runId, denial] of this.pendingDenials.entries()) {
|
|
81
|
+
if (now - denial.at >= this.pendingDenialMaxAgeMs) {
|
|
82
|
+
this.pendingDenials.delete(runId);
|
|
83
|
+
removed += 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return removed;
|
|
87
|
+
}
|
|
88
|
+
// Exposed for deterministic unit testing around cleanup behavior.
|
|
89
|
+
getPendingDenialCount() {
|
|
90
|
+
return this.pendingDenials.size;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.AssemblyCallbackHandler = AssemblyCallbackHandler;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapToolWithAssembly = exports.getRunId = exports.AssemblyCallbackHandler = void 0;
|
|
4
|
+
var assembly_callback_handler_js_1 = require("./assembly-callback-handler.js");
|
|
5
|
+
Object.defineProperty(exports, "AssemblyCallbackHandler", { enumerable: true, get: function () { return assembly_callback_handler_js_1.AssemblyCallbackHandler; } });
|
|
6
|
+
var wrap_tool_with_assembly_js_1 = require("./wrap-tool-with-assembly.js");
|
|
7
|
+
Object.defineProperty(exports, "getRunId", { enumerable: true, get: function () { return wrap_tool_with_assembly_js_1.getRunId; } });
|
|
8
|
+
Object.defineProperty(exports, "wrapToolWithAssembly", { enumerable: true, get: function () { return wrap_tool_with_assembly_js_1.wrapToolWithAssembly; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapToolWithAssembly = wrapToolWithAssembly;
|
|
4
|
+
exports.getRunId = getRunId;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const policy_violation_error_js_1 = require("../../errors/policy-violation-error.js");
|
|
7
|
+
const DEFAULT_APPROVAL_TIMEOUT_MS = 30_000;
|
|
8
|
+
function createRunId() {
|
|
9
|
+
return `run_${(0, node_crypto_1.randomUUID)()}`;
|
|
10
|
+
}
|
|
11
|
+
async function waitForApprovalWithTimeout(gateway, toolName, runId, timeoutMs) {
|
|
12
|
+
let timeoutId;
|
|
13
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
14
|
+
timeoutId = setTimeout(() => {
|
|
15
|
+
resolve({ denied: true, reason: `Approval timeout after ${timeoutMs}ms` });
|
|
16
|
+
}, timeoutMs);
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
const approvalPromise = gateway.waitForApproval(toolName, runId, timeoutMs);
|
|
20
|
+
return await Promise.race([approvalPromise, timeoutPromise]);
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
if (timeoutId) {
|
|
24
|
+
clearTimeout(timeoutId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function wrapToolWithAssembly(tool, gateway, options = {}) {
|
|
29
|
+
const originalInvoke = tool.invoke.bind(tool);
|
|
30
|
+
const generateRunId = options.generateRunId ?? createRunId;
|
|
31
|
+
const approvalTimeoutMs = options.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
|
|
32
|
+
tool.invoke = async (input, config) => {
|
|
33
|
+
const runId = getRunId(config, generateRunId);
|
|
34
|
+
const decision = await gateway.check({
|
|
35
|
+
action: "tool_call",
|
|
36
|
+
toolName: tool.name,
|
|
37
|
+
args: input,
|
|
38
|
+
runId
|
|
39
|
+
});
|
|
40
|
+
if (decision.denied) {
|
|
41
|
+
throw new policy_violation_error_js_1.PolicyViolationError(`Tool '${tool.name}' blocked: ${decision.reason ?? "Denied"}`);
|
|
42
|
+
}
|
|
43
|
+
if (decision.pending) {
|
|
44
|
+
const finalDecision = await waitForApprovalWithTimeout(gateway, tool.name, runId, approvalTimeoutMs);
|
|
45
|
+
if (finalDecision.denied) {
|
|
46
|
+
throw new policy_violation_error_js_1.PolicyViolationError(`Approval rejected for '${tool.name}': ${finalDecision.reason ?? "Rejected"}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return originalInvoke(input, config ? { ...config, runId } : { runId });
|
|
50
|
+
};
|
|
51
|
+
return tool;
|
|
52
|
+
}
|
|
53
|
+
function getRunId(config, generateRunId) {
|
|
54
|
+
return config?.runId ?? generateRunId();
|
|
55
|
+
}
|