@agenshield/daemon 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +118 -0
- package/acl.d.ts +44 -0
- package/acl.d.ts.map +1 -0
- package/auth/index.d.ts +9 -0
- package/auth/index.d.ts.map +1 -0
- package/auth/middleware.d.ts +49 -0
- package/auth/middleware.d.ts.map +1 -0
- package/auth/passcode.d.ts +70 -0
- package/auth/passcode.d.ts.map +1 -0
- package/auth/session.d.ts +71 -0
- package/auth/session.d.ts.map +1 -0
- package/command-sync.d.ts +41 -0
- package/command-sync.d.ts.map +1 -0
- package/config/defaults.d.ts +10 -0
- package/config/defaults.d.ts.map +1 -0
- package/config/index.d.ts +7 -0
- package/config/index.d.ts.map +1 -0
- package/config/loader.d.ts +25 -0
- package/config/loader.d.ts.map +1 -0
- package/config/paths.d.ts +20 -0
- package/config/paths.d.ts.map +1 -0
- package/data/integration-catalog.d.ts +32 -0
- package/data/integration-catalog.d.ts.map +1 -0
- package/events/emitter.d.ts +126 -0
- package/events/emitter.d.ts.map +1 -0
- package/events/index.d.ts +5 -0
- package/events/index.d.ts.map +1 -0
- package/index.d.ts +19 -0
- package/index.d.ts.map +1 -0
- package/index.js +7591 -0
- package/main.d.ts +6 -0
- package/main.d.ts.map +1 -0
- package/main.js +7539 -0
- package/mcp/client.d.ts +73 -0
- package/mcp/client.d.ts.map +1 -0
- package/mcp/index.d.ts +7 -0
- package/mcp/index.d.ts.map +1 -0
- package/mcp/oauth-provider.d.ts +27 -0
- package/mcp/oauth-provider.d.ts.map +1 -0
- package/mcp/state.d.ts +31 -0
- package/mcp/state.d.ts.map +1 -0
- package/package.json +43 -0
- package/routes/agenco.d.ts +13 -0
- package/routes/agenco.d.ts.map +1 -0
- package/routes/auth.d.ts +11 -0
- package/routes/auth.d.ts.map +1 -0
- package/routes/config.d.ts +6 -0
- package/routes/config.d.ts.map +1 -0
- package/routes/discovery.d.ts +8 -0
- package/routes/discovery.d.ts.map +1 -0
- package/routes/exec.d.ts +6 -0
- package/routes/exec.d.ts.map +1 -0
- package/routes/fs.d.ts +6 -0
- package/routes/fs.d.ts.map +1 -0
- package/routes/health.d.ts +6 -0
- package/routes/health.d.ts.map +1 -0
- package/routes/index.d.ts +9 -0
- package/routes/index.d.ts.map +1 -0
- package/routes/marketplace.d.ts +9 -0
- package/routes/marketplace.d.ts.map +1 -0
- package/routes/rpc.d.ts +9 -0
- package/routes/rpc.d.ts.map +1 -0
- package/routes/secrets.d.ts +6 -0
- package/routes/secrets.d.ts.map +1 -0
- package/routes/security.d.ts +6 -0
- package/routes/security.d.ts.map +1 -0
- package/routes/skills.d.ts +11 -0
- package/routes/skills.d.ts.map +1 -0
- package/routes/sse.d.ts +9 -0
- package/routes/sse.d.ts.map +1 -0
- package/routes/status.d.ts +6 -0
- package/routes/status.d.ts.map +1 -0
- package/routes/wrappers.d.ts +12 -0
- package/routes/wrappers.d.ts.map +1 -0
- package/server.d.ts +18 -0
- package/server.d.ts.map +1 -0
- package/services/activity-log.d.ts +21 -0
- package/services/activity-log.d.ts.map +1 -0
- package/services/broker-bridge.d.ts +43 -0
- package/services/broker-bridge.d.ts.map +1 -0
- package/services/integration-skills.d.ts +26 -0
- package/services/integration-skills.d.ts.map +1 -0
- package/services/marketplace.d.ts +79 -0
- package/services/marketplace.d.ts.map +1 -0
- package/services/openclaw-config.d.ts +15 -0
- package/services/openclaw-config.d.ts.map +1 -0
- package/services/skill-analyzer.d.ts +21 -0
- package/services/skill-analyzer.d.ts.map +1 -0
- package/services/skill-lifecycle.d.ts +23 -0
- package/services/skill-lifecycle.d.ts.map +1 -0
- package/state/index.d.ts +76 -0
- package/state/index.d.ts.map +1 -0
- package/static.d.ts +9 -0
- package/static.d.ts.map +1 -0
- package/ui-assets/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/ui-assets/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/ui-assets/assets/index-CC_zbvUx.css +1 -0
- package/ui-assets/assets/index-Chp3YFDr.js +947 -0
- package/ui-assets/assets/manrope-latin-400-normal-8tf8FM3T.woff +0 -0
- package/ui-assets/assets/manrope-latin-400-normal-PaqtzbVb.woff2 +0 -0
- package/ui-assets/assets/manrope-latin-500-normal-BYYD-dBL.woff2 +0 -0
- package/ui-assets/assets/manrope-latin-500-normal-DMZssgOp.woff +0 -0
- package/ui-assets/assets/manrope-latin-600-normal-4f0koTD-.woff2 +0 -0
- package/ui-assets/assets/manrope-latin-600-normal-BqgrALkZ.woff +0 -0
- package/ui-assets/assets/manrope-latin-700-normal-BZp_XxE4.woff2 +0 -0
- package/ui-assets/assets/manrope-latin-700-normal-DGRFkw-m.woff +0 -0
- package/ui-assets/assets/manrope-latin-800-normal-BfWYOv1c.woff2 +0 -0
- package/ui-assets/assets/manrope-latin-800-normal-uHUdIJgA.woff +0 -0
- package/ui-assets/favicon.svg +1 -0
- package/ui-assets/index.html +14 -0
- package/ui-assets/package.json +34 -0
- package/utils/logged-fetch.d.ts +13 -0
- package/utils/logged-fetch.d.ts.map +1 -0
- package/vault/crypto.d.ts +28 -0
- package/vault/crypto.d.ts.map +1 -0
- package/vault/index.d.ts +64 -0
- package/vault/index.d.ts.map +1 -0
- package/watchers/index.d.ts +6 -0
- package/watchers/index.d.ts.map +1 -0
- package/watchers/security.d.ts +20 -0
- package/watchers/security.d.ts.map +1 -0
- package/watchers/skills.d.ts +85 -0
- package/watchers/skills.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# @agenshield/daemon
|
|
2
|
+
|
|
3
|
+
AgenShield daemon is a Fastify-based HTTP service that exposes the management API and (optionally) serves the embedded UI. It is separate from the broker: this daemon focuses on control-plane operations, status, and UI interactions.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
- Provide a local HTTP API for status, config, and security checks.
|
|
7
|
+
- Serve the management UI if assets are present.
|
|
8
|
+
- Stream live events over Server-Sent Events (SSE).
|
|
9
|
+
- Handle passcode authentication and session management.
|
|
10
|
+
- Offer AgenCo integration for MCP tool access.
|
|
11
|
+
|
|
12
|
+
## Key Components
|
|
13
|
+
- `src/main.ts` - Entry point, PID file handling, and server startup.
|
|
14
|
+
- `src/server.ts` - Fastify server setup + static UI serving.
|
|
15
|
+
- `src/routes/*` - HTTP endpoints and SSE routes.
|
|
16
|
+
- `src/auth/*` - Passcode hashing, session manager, auth middleware.
|
|
17
|
+
- `src/config/*` - Config loader and defaults.
|
|
18
|
+
- `src/state/*` - Persistent state file management.
|
|
19
|
+
- `src/vault/*` - Encrypted vault for tokens/secrets.
|
|
20
|
+
- `src/watchers/*` - Background watchers (security status).
|
|
21
|
+
- `src/events/*` - Event emitter feeding SSE.
|
|
22
|
+
|
|
23
|
+
## API Overview
|
|
24
|
+
Base prefix is `/api` (see `@agenshield/ipc` constants).
|
|
25
|
+
|
|
26
|
+
Core endpoints:
|
|
27
|
+
- `GET /api/health` - Health check.
|
|
28
|
+
- `GET /api/status` - Daemon status + version.
|
|
29
|
+
- `GET /api/config` - Current config.
|
|
30
|
+
- `PUT /api/config` - Update config.
|
|
31
|
+
- `GET /api/security` - Security status snapshot.
|
|
32
|
+
|
|
33
|
+
Wrappers:
|
|
34
|
+
- `GET /api/wrappers` - List available wrappers.
|
|
35
|
+
- `GET /api/wrappers/:name` - Wrapper details + generated content.
|
|
36
|
+
- `GET /api/wrappers/status` - Installed status.
|
|
37
|
+
- `POST /api/wrappers/install` - Install wrappers.
|
|
38
|
+
- `DELETE /api/wrappers/:name` - Uninstall wrapper.
|
|
39
|
+
- `PUT /api/wrappers/:name` - Update wrapper.
|
|
40
|
+
- `POST /api/wrappers/custom` - Add a custom wrapper.
|
|
41
|
+
- `DELETE /api/wrappers/custom/:name` - Remove a custom wrapper.
|
|
42
|
+
- `POST /api/wrappers/sync` - Sync wrapper set based on policy.
|
|
43
|
+
- `POST /api/wrappers/regenerate` - Regenerate installed wrappers.
|
|
44
|
+
|
|
45
|
+
Auth:
|
|
46
|
+
- `GET /api/auth/status`
|
|
47
|
+
- `POST /api/auth/setup`
|
|
48
|
+
- `POST /api/auth/unlock`
|
|
49
|
+
- `POST /api/auth/lock`
|
|
50
|
+
- `POST /api/auth/change`
|
|
51
|
+
- `POST /api/auth/refresh`
|
|
52
|
+
- `POST /api/auth/enable`
|
|
53
|
+
- `POST /api/auth/disable`
|
|
54
|
+
|
|
55
|
+
AgenCo:
|
|
56
|
+
- `POST /api/agenco/auth/start`
|
|
57
|
+
- `POST /api/agenco/auth/callback`
|
|
58
|
+
- `GET /api/agenco/auth/status`
|
|
59
|
+
- `POST /api/agenco/auth/logout`
|
|
60
|
+
- `POST /api/agenco/tool/run`
|
|
61
|
+
- `GET /api/agenco/tool/list`
|
|
62
|
+
- `GET /api/agenco/tool/search`
|
|
63
|
+
- `GET /api/agenco/integrations`
|
|
64
|
+
- `GET /api/agenco/integrations/connected`
|
|
65
|
+
- `POST /api/agenco/integrations/connect`
|
|
66
|
+
|
|
67
|
+
SSE:
|
|
68
|
+
- `GET /sse/events?token=...`
|
|
69
|
+
- `GET /sse/events/:filter?token=...`
|
|
70
|
+
|
|
71
|
+
## Authentication Model
|
|
72
|
+
- Passcodes are hashed with PBKDF2 and stored in the encrypted vault.
|
|
73
|
+
- Sessions are in-memory only (lost on daemon restart).
|
|
74
|
+
- Tokens can be supplied via `Authorization: Bearer <token>` or `?token=...` for SSE.
|
|
75
|
+
- Root users bypass authentication.
|
|
76
|
+
- Only selected routes are protected when passcode protection is enabled.
|
|
77
|
+
|
|
78
|
+
## Configuration and State
|
|
79
|
+
- Config file: `~/.agenshield/config.json`
|
|
80
|
+
- State file: `~/.agenshield/state.json`
|
|
81
|
+
- Vault file: `~/.agenshield/vault.enc` (encrypted with machine-bound key)
|
|
82
|
+
|
|
83
|
+
Defaults are defined in `@agenshield/ipc` and `src/config/defaults.ts`.
|
|
84
|
+
|
|
85
|
+
## Limitations and Caveats
|
|
86
|
+
- No HTTPS/TLS built in; intended for localhost use.
|
|
87
|
+
- CORS is fully enabled for development.
|
|
88
|
+
- Sessions are not persisted; tokens become invalid after restart.
|
|
89
|
+
- Wrapper operations depend on `@agenshield/sandbox` (macOS-specific).
|
|
90
|
+
- SSE is best-effort; no replay or persistence of events.
|
|
91
|
+
- Default wrapper target dir is hardcoded to `/Users/clawagent/bin`.
|
|
92
|
+
|
|
93
|
+
## Roadmap (Ideas)
|
|
94
|
+
- Persisted sessions and stronger auth/scopes.
|
|
95
|
+
- OpenAPI schema for clients.
|
|
96
|
+
- Cross-platform wrapper management.
|
|
97
|
+
- Metrics and health probes beyond `/health`.
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
```bash
|
|
101
|
+
# Run directly
|
|
102
|
+
npx tsx libs/shield-daemon/src/main.ts
|
|
103
|
+
|
|
104
|
+
# Build
|
|
105
|
+
npx nx build shield-daemon
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Contribution Guide
|
|
109
|
+
- Add new routes in `src/routes/` and register in `src/routes/index.ts`.
|
|
110
|
+
- Update `src/auth/middleware.ts` if new endpoints need protection.
|
|
111
|
+
- Keep response shapes aligned with `@agenshield/ipc` types.
|
|
112
|
+
- Emit SSE events through `src/events/emitter.ts` for UI reactivity.
|
|
113
|
+
|
|
114
|
+
## Agent Notes
|
|
115
|
+
- `startServer()` starts the security watcher; remember to stop it on shutdown.
|
|
116
|
+
- The UI assets are served from `ui-assets` (prod) or `dist/apps/shield-ui` (dev).
|
|
117
|
+
- AgenCo tokens are stored in the vault; expect network calls to the MCP gateway.
|
|
118
|
+
- Config updates are persisted via `src/config/loader.ts` (JSON + Zod).
|
package/acl.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS ACL utilities for filesystem policies.
|
|
3
|
+
*
|
|
4
|
+
* Uses `chmod +a / -a` to grant/revoke group-level ACLs on paths
|
|
5
|
+
* derived from policy patterns. Failures are logged but never thrown.
|
|
6
|
+
*/
|
|
7
|
+
import type { PolicyConfig } from '@agenshield/ipc';
|
|
8
|
+
interface Logger {
|
|
9
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Strip glob wildcards from a path, returning the deepest concrete directory.
|
|
13
|
+
*
|
|
14
|
+
* /Users/me/projects/** → /Users/me/projects
|
|
15
|
+
* /tmp/* → /tmp
|
|
16
|
+
* ~/docs/** → /Users/<user>/docs
|
|
17
|
+
*/
|
|
18
|
+
export declare function stripGlobToBasePath(pattern: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Map AgenShield operation names to macOS ACL permission keywords.
|
|
21
|
+
*/
|
|
22
|
+
export declare function operationsToAclPerms(operations: string[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* Add a group ACL entry to a path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function addGroupAcl(targetPath: string, groupName: string, permissions: string, log?: Logger): void;
|
|
27
|
+
/**
|
|
28
|
+
* Remove all ACL entries for a group from a path.
|
|
29
|
+
*
|
|
30
|
+
* Reads current ACL entries via `ls -le`, finds entries matching the group,
|
|
31
|
+
* and removes them by index (highest-first so indices stay valid).
|
|
32
|
+
*/
|
|
33
|
+
export declare function removeGroupAcl(targetPath: string, groupName: string, log?: Logger): void;
|
|
34
|
+
/**
|
|
35
|
+
* Synchronise filesystem policy ACLs after a config change.
|
|
36
|
+
*
|
|
37
|
+
* Compares old and new policy arrays, and for filesystem-target policies:
|
|
38
|
+
* - Removed policies → revoke ACLs for each pattern
|
|
39
|
+
* - Added policies → apply ACLs for each pattern
|
|
40
|
+
* - Changed policies → revoke old patterns, apply new ones
|
|
41
|
+
*/
|
|
42
|
+
export declare function syncFilesystemPolicyAcls(oldPolicies: PolicyConfig[], newPolicies: PolicyConfig[], groupName: string, logger?: Logger): void;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=acl.d.ts.map
|
package/acl.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.d.ts","sourceRoot":"","sources":["../src/acl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,UAAU,MAAM;IACd,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC7C;AAID;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CASjE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,GAAE,MAAa,GAAG,IAAI,CAahH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,GAAE,MAAa,GAAG,IAAI,CAoC9F;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,YAAY,EAAE,EAC3B,WAAW,EAAE,YAAY,EAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CAkDN"}
|
package/auth/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication module
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all auth functionality.
|
|
5
|
+
*/
|
|
6
|
+
export { hashPasscode, verifyPasscode, isPasscodeSet, getPasscodeData, setPasscode, checkPasscode, isProtectionEnabled, setProtectionEnabled, isLockedOut, recordFailedAttempt, clearFailedAttempts, isRunningAsRoot, } from './passcode';
|
|
7
|
+
export { SessionManager, getSessionManager, resetSessionManager, } from './session';
|
|
8
|
+
export { extractToken, isAuthenticated, requireAuth, decorateWithAuth, PUBLIC_ROUTES, PROTECTED_ROUTES, isProtectedRoute, createAuthHook, } from './middleware';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication middleware
|
|
3
|
+
*
|
|
4
|
+
* Protects routes that require authentication.
|
|
5
|
+
*/
|
|
6
|
+
import type { FastifyRequest, FastifyReply, FastifyInstance } from 'fastify';
|
|
7
|
+
/**
|
|
8
|
+
* Extract token from request
|
|
9
|
+
* Checks Authorization header first, then query parameter
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractToken(request: FastifyRequest): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Check if request is authenticated
|
|
14
|
+
* Returns true if:
|
|
15
|
+
* - Protection is disabled
|
|
16
|
+
* - Running as root (bypass)
|
|
17
|
+
* - Valid session token provided
|
|
18
|
+
*/
|
|
19
|
+
export declare function isAuthenticated(request: FastifyRequest): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Authentication preHandler hook
|
|
22
|
+
* Use this on routes that require authentication
|
|
23
|
+
*/
|
|
24
|
+
export declare function requireAuth(request: FastifyRequest, reply: FastifyReply): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Decorate Fastify instance with auth utilities
|
|
27
|
+
*/
|
|
28
|
+
export declare function decorateWithAuth(app: FastifyInstance): void;
|
|
29
|
+
/**
|
|
30
|
+
* Routes that should always be public (no auth required)
|
|
31
|
+
*/
|
|
32
|
+
export declare const PUBLIC_ROUTES: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Routes that require authentication when protection is enabled
|
|
35
|
+
*/
|
|
36
|
+
export declare const PROTECTED_ROUTES: {
|
|
37
|
+
method: string;
|
|
38
|
+
path: string;
|
|
39
|
+
}[];
|
|
40
|
+
/**
|
|
41
|
+
* Check if a request matches a protected route
|
|
42
|
+
*/
|
|
43
|
+
export declare function isProtectedRoute(method: string, path: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Global auth hook for selective route protection
|
|
46
|
+
* Applies auth check to protected routes only
|
|
47
|
+
*/
|
|
48
|
+
export declare function createAuthHook(): (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
49
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI7E;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAcxE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAoBhE;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI,CAQ3D;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,UAUzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;GAY5B,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAItE;AAED;;;GAGG;AACH,wBAAgB,cAAc,KACd,SAAS,cAAc,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC,CAmB3E"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passcode hashing and verification
|
|
3
|
+
*
|
|
4
|
+
* Uses PBKDF2 with SHA-512 for secure password hashing.
|
|
5
|
+
* This is a secure alternative to bcrypt using native Node.js crypto.
|
|
6
|
+
*/
|
|
7
|
+
import type { PasscodeData } from '@agenshield/ipc';
|
|
8
|
+
/**
|
|
9
|
+
* Hash a passcode using PBKDF2
|
|
10
|
+
*/
|
|
11
|
+
export declare function hashPasscode(passcode: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Verify a passcode against a hash
|
|
14
|
+
*/
|
|
15
|
+
export declare function verifyPasscode(passcode: string, storedHash: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a passcode has been set
|
|
18
|
+
*/
|
|
19
|
+
export declare function isPasscodeSet(): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Get passcode data from vault
|
|
22
|
+
*/
|
|
23
|
+
export declare function getPasscodeData(): Promise<PasscodeData | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Set a new passcode
|
|
26
|
+
*/
|
|
27
|
+
export declare function setPasscode(passcode: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Verify the provided passcode
|
|
30
|
+
* Returns true if passcode is correct
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkPasscode(passcode: string): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Check if protection is enabled
|
|
35
|
+
*/
|
|
36
|
+
export declare function isProtectionEnabled(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Enable or disable passcode protection
|
|
39
|
+
*/
|
|
40
|
+
export declare function setProtectionEnabled(enabled: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* Check if anonymous read-only access is allowed
|
|
43
|
+
* Returns true by default if not explicitly set
|
|
44
|
+
*/
|
|
45
|
+
export declare function isAnonymousReadOnlyAllowed(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Set anonymous read-only access
|
|
48
|
+
*/
|
|
49
|
+
export declare function setAnonymousReadOnly(allowed: boolean): void;
|
|
50
|
+
/**
|
|
51
|
+
* Check if authentication is locked out
|
|
52
|
+
*/
|
|
53
|
+
export declare function isLockedOut(): {
|
|
54
|
+
locked: boolean;
|
|
55
|
+
lockedUntil?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Record a failed authentication attempt
|
|
59
|
+
* Returns the number of remaining attempts before lockout
|
|
60
|
+
*/
|
|
61
|
+
export declare function recordFailedAttempt(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Clear failed attempts on successful authentication
|
|
64
|
+
*/
|
|
65
|
+
export declare function clearFailedAttempts(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Check if running as root (bypass passcode)
|
|
68
|
+
*/
|
|
69
|
+
export declare function isRunningAsRoot(): boolean;
|
|
70
|
+
//# sourceMappingURL=passcode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passcode.d.ts","sourceRoot":"","sources":["../../src/auth/passcode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAWpD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoBrF;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAItD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAGzE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAajE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAG7C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE3D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,OAAO,CAGpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE3D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAgBvE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAiB5C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session manager
|
|
3
|
+
*
|
|
4
|
+
* Manages authentication sessions with in-memory storage.
|
|
5
|
+
* Sessions are cleared on daemon restart.
|
|
6
|
+
*/
|
|
7
|
+
import type { Session } from '@agenshield/ipc';
|
|
8
|
+
/**
|
|
9
|
+
* Session manager class
|
|
10
|
+
*/
|
|
11
|
+
declare class SessionManager {
|
|
12
|
+
private sessions;
|
|
13
|
+
private sessionTtlMs;
|
|
14
|
+
private cleanupInterval;
|
|
15
|
+
constructor(sessionTtlMs?: number);
|
|
16
|
+
/**
|
|
17
|
+
* Generate a secure random token
|
|
18
|
+
*/
|
|
19
|
+
private generateToken;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new session
|
|
22
|
+
*/
|
|
23
|
+
createSession(clientId?: string): Session;
|
|
24
|
+
/**
|
|
25
|
+
* Validate a session token
|
|
26
|
+
* Returns the session if valid, undefined if invalid or expired
|
|
27
|
+
*/
|
|
28
|
+
validateSession(token: string): Session | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Invalidate a session
|
|
31
|
+
*/
|
|
32
|
+
invalidateSession(token: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Refresh a session's expiration time
|
|
35
|
+
*/
|
|
36
|
+
refreshSession(token: string): Session | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get all active sessions
|
|
39
|
+
*/
|
|
40
|
+
getActiveSessions(): Session[];
|
|
41
|
+
/**
|
|
42
|
+
* Clear all sessions
|
|
43
|
+
*/
|
|
44
|
+
clearAllSessions(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Start periodic cleanup of expired sessions
|
|
47
|
+
*/
|
|
48
|
+
private startCleanup;
|
|
49
|
+
/**
|
|
50
|
+
* Stop the cleanup interval
|
|
51
|
+
*/
|
|
52
|
+
stopCleanup(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Remove expired sessions
|
|
55
|
+
*/
|
|
56
|
+
private cleanupExpiredSessions;
|
|
57
|
+
/**
|
|
58
|
+
* Get session count
|
|
59
|
+
*/
|
|
60
|
+
getSessionCount(): number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the singleton session manager instance
|
|
64
|
+
*/
|
|
65
|
+
export declare function getSessionManager(): SessionManager;
|
|
66
|
+
/**
|
|
67
|
+
* Reset the session manager singleton (for testing)
|
|
68
|
+
*/
|
|
69
|
+
export declare function resetSessionManager(): void;
|
|
70
|
+
export { SessionManager };
|
|
71
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/auth/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAA+C;gBAE1D,YAAY,GAAE,MAAyC;IAKnE;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAezC;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAcnD;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIzC;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAgBlD;;OAEG;IACH,iBAAiB,IAAI,OAAO,EAAE;IAa9B;;OAEG;IACH,gBAAgB,IAAI,IAAI;IAIxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,WAAW,IAAI,IAAI;IAOnB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAS9B;;OAEG;IACH,eAAe,IAAI,MAAM;CAG1B;AAKD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Policy Sync
|
|
3
|
+
*
|
|
4
|
+
* Syncs daemon command policies to the broker's dynamic allowlist
|
|
5
|
+
* (/opt/agenshield/config/allowed-commands.json) and ensures wrappers
|
|
6
|
+
* are installed in both user bin directories.
|
|
7
|
+
*
|
|
8
|
+
* Flow:
|
|
9
|
+
* 1. Extract command names from `allow` + `target: 'command'` policies
|
|
10
|
+
* 2. Resolve each command name to absolute binary paths
|
|
11
|
+
* 3. Write the allowed-commands.json for the broker to pick up
|
|
12
|
+
* 4. Install all proxied command wrappers in agent + workspace user $HOME/bin
|
|
13
|
+
*/
|
|
14
|
+
import type { PolicyConfig, SystemState } from '@agenshield/ipc';
|
|
15
|
+
interface Logger {
|
|
16
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
17
|
+
info(msg: string, ...args: unknown[]): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sync command policies to the broker's dynamic allowlist.
|
|
21
|
+
*
|
|
22
|
+
* Reads allowed command policies, resolves binary paths,
|
|
23
|
+
* and writes /opt/agenshield/config/allowed-commands.json.
|
|
24
|
+
*/
|
|
25
|
+
export declare function syncCommandPolicies(policies: PolicyConfig[], logger?: Logger): void;
|
|
26
|
+
/**
|
|
27
|
+
* Ensure wrappers are installed in both the agent user's and
|
|
28
|
+
* the workspace user's bin directories.
|
|
29
|
+
*
|
|
30
|
+
* Both directories are derived from state.json:
|
|
31
|
+
* - Agent user (type='agent') → homeDir/bin
|
|
32
|
+
* - If AGENSHIELD_AGENT_HOME is set, also use that
|
|
33
|
+
*/
|
|
34
|
+
export declare function ensureWrappersInstalled(state: SystemState, logger?: Logger): void;
|
|
35
|
+
/**
|
|
36
|
+
* Full sync: update allowlist + ensure wrappers installed.
|
|
37
|
+
* Called from PUT /config when policies change.
|
|
38
|
+
*/
|
|
39
|
+
export declare function syncCommandPoliciesAndWrappers(policies: PolicyConfig[], state: SystemState, logger?: Logger): void;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=command-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-sync.d.ts","sourceRoot":"","sources":["../src/command-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjE,UAAU,MAAM;IACd,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC7C;AAuFD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CAkDN;AAuCD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CAoBN;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,YAAY,EAAE,EACxB,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CAGN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration for AgenShield daemon
|
|
3
|
+
*/
|
|
4
|
+
import type { ShieldConfig } from '@agenshield/ipc';
|
|
5
|
+
export declare const VERSION = "0.1.0";
|
|
6
|
+
/**
|
|
7
|
+
* Get default configuration
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDefaultConfig(): ShieldConfig;
|
|
10
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,CAe/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
|