@agenshield/broker 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.
Files changed (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +141 -0
  3. package/audit/logger.d.ts +69 -0
  4. package/audit/logger.d.ts.map +1 -0
  5. package/client/broker-client.d.ts +91 -0
  6. package/client/broker-client.d.ts.map +1 -0
  7. package/client/index.d.ts +8 -0
  8. package/client/index.d.ts.map +1 -0
  9. package/client/index.js +222 -0
  10. package/client/shield-client.d.ts +8 -0
  11. package/client/shield-client.d.ts.map +1 -0
  12. package/client/shield-client.js +410 -0
  13. package/handlers/exec.d.ts +13 -0
  14. package/handlers/exec.d.ts.map +1 -0
  15. package/handlers/file.d.ts +20 -0
  16. package/handlers/file.d.ts.map +1 -0
  17. package/handlers/http.d.ts +9 -0
  18. package/handlers/http.d.ts.map +1 -0
  19. package/handlers/index.d.ts +12 -0
  20. package/handlers/index.d.ts.map +1 -0
  21. package/handlers/open-url.d.ts +9 -0
  22. package/handlers/open-url.d.ts.map +1 -0
  23. package/handlers/ping.d.ts +9 -0
  24. package/handlers/ping.d.ts.map +1 -0
  25. package/handlers/secret-inject.d.ts +9 -0
  26. package/handlers/secret-inject.d.ts.map +1 -0
  27. package/handlers/skill-install.d.ts +17 -0
  28. package/handlers/skill-install.d.ts.map +1 -0
  29. package/handlers/types.d.ts +28 -0
  30. package/handlers/types.d.ts.map +1 -0
  31. package/http-fallback.d.ts +54 -0
  32. package/http-fallback.d.ts.map +1 -0
  33. package/index.d.ts +18 -0
  34. package/index.d.ts.map +1 -0
  35. package/index.js +2636 -0
  36. package/main.d.ts +8 -0
  37. package/main.d.ts.map +1 -0
  38. package/main.js +2136 -0
  39. package/package.json +34 -0
  40. package/policies/builtin.d.ts +15 -0
  41. package/policies/builtin.d.ts.map +1 -0
  42. package/policies/command-allowlist.d.ts +62 -0
  43. package/policies/command-allowlist.d.ts.map +1 -0
  44. package/policies/enforcer.d.ts +98 -0
  45. package/policies/enforcer.d.ts.map +1 -0
  46. package/policies/index.d.ts +8 -0
  47. package/policies/index.d.ts.map +1 -0
  48. package/seatbelt/generator.d.ts +39 -0
  49. package/seatbelt/generator.d.ts.map +1 -0
  50. package/seatbelt/templates.d.ts +36 -0
  51. package/seatbelt/templates.d.ts.map +1 -0
  52. package/secrets/vault.d.ts +67 -0
  53. package/secrets/vault.d.ts.map +1 -0
  54. package/server.d.ts +54 -0
  55. package/server.d.ts.map +1 -0
  56. package/types.d.ts +285 -0
  57. package/types.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,141 @@
1
+ # @agenshield/broker
2
+
3
+ Core broker daemon for AgenShield. It enforces security policies and performs privileged operations on behalf of sandboxed agents.
4
+
5
+ ## Purpose
6
+ - Enforce policy decisions for network, file, and exec operations.
7
+ - Provide a Unix socket JSON-RPC API for local, privileged actions.
8
+ - Offer a restricted HTTP fallback for environments that cannot use Unix sockets.
9
+ - Emit auditable logs for every operation.
10
+
11
+ ## Key Components
12
+ - `src/main.ts` - Broker daemon entry point.
13
+ - `src/server.ts` - Unix socket JSON-RPC server (newline-delimited JSON).
14
+ - `src/http-fallback.ts` - Restricted HTTP JSON-RPC server (`/rpc`).
15
+ - `src/handlers/*` - Operation handlers (`http_request`, `file_*`, `exec`, etc.).
16
+ - `src/policies/*` - Policy enforcement and built-in rules.
17
+ - `src/audit/logger.ts` - JSONL audit log with rotation.
18
+ - `src/secrets/vault.ts` - Encrypted secret storage for `secret_inject`.
19
+ - `src/client/broker-client.ts` - Type-safe client for code integrations.
20
+ - `src/client/shield-client.ts` - CLI client (`shield-client`).
21
+
22
+ ## Operations (JSON-RPC methods)
23
+ - `http_request` - Proxy HTTP requests.
24
+ - `file_read`, `file_write`, `file_list` - File system operations.
25
+ - `exec` - Execute a command.
26
+ - `open_url` - Open a URL in the default browser (macOS `open`).
27
+ - `secret_inject` - Read a secret from the vault (socket-only).
28
+ - `ping` - Health check.
29
+
30
+ ## Usage
31
+ ### Run the broker
32
+ ```bash
33
+ agenshield-broker
34
+
35
+ # Custom socket path
36
+ AGENSHIELD_SOCKET=/tmp/agenshield.sock agenshield-broker
37
+
38
+ # Disable HTTP fallback
39
+ AGENSHIELD_HTTP_ENABLED=false agenshield-broker
40
+ ```
41
+
42
+ ### Use the client library
43
+ ```ts
44
+ import { BrokerClient } from '@agenshield/broker/client';
45
+
46
+ const client = new BrokerClient({
47
+ socketPath: '/var/run/agenshield.sock',
48
+ });
49
+
50
+ const response = await client.httpRequest({
51
+ url: 'https://api.example.com/data',
52
+ method: 'GET',
53
+ });
54
+
55
+ const file = await client.fileRead({ path: '/path/to/file.txt' });
56
+ const execResult = await client.exec({ command: 'ls', args: ['-la'] });
57
+ ```
58
+
59
+ ### Use the CLI client
60
+ ```bash
61
+ shield-client ping
62
+ shield-client http GET https://api.example.com/data
63
+ shield-client file read /path/to/file.txt
64
+ shield-client exec ls -la
65
+ ```
66
+
67
+ ## Configuration
68
+ The broker loads configuration from a file (default: `/opt/agenshield/config/shield.json`) and overlays environment variables.
69
+
70
+ Environment variables:
71
+ - `AGENSHIELD_CONFIG` - Config file path.
72
+ - `AGENSHIELD_SOCKET` - Unix socket path (default: `/var/run/agenshield.sock`).
73
+ - `AGENSHIELD_HTTP_ENABLED` - `true`/`false` to enable HTTP fallback.
74
+ - `AGENSHIELD_HTTP_HOST` - HTTP fallback host (default: `localhost`).
75
+ - `AGENSHIELD_HTTP_PORT` - HTTP fallback port (default: `5200`).
76
+ - `AGENSHIELD_POLICIES` - Policies directory (default: `/opt/agenshield/policies`).
77
+ - `AGENSHIELD_AUDIT_LOG` - Audit log path (default: `/var/log/agenshield/audit.log`).
78
+ - `AGENSHIELD_LOG_LEVEL` - `debug|info|warn|error`.
79
+ - `AGENSHIELD_FAIL_OPEN` - `true` to allow on policy-check failure.
80
+
81
+ Config file fields (subset):
82
+ ```json
83
+ {
84
+ "socketPath": "/var/run/agenshield.sock",
85
+ "httpEnabled": true,
86
+ "httpHost": "localhost",
87
+ "httpPort": 5200,
88
+ "policiesPath": "/opt/agenshield/policies",
89
+ "auditLogPath": "/var/log/agenshield/audit.log",
90
+ "logLevel": "info",
91
+ "failOpen": false,
92
+ "socketMode": 504
93
+ }
94
+ ```
95
+
96
+ ## Policy Model
97
+ - Policies are loaded from `policiesPath/default.json` plus any JSON files in `policiesPath/custom/`.
98
+ - Rules are allowlist/denylist with glob-style matching and priority ordering.
99
+ - File and network constraints can enforce allowed paths/hosts/ports.
100
+ - Policies are reloaded on a timer (every 60 seconds).
101
+
102
+ ## HTTP Fallback Constraints
103
+ The HTTP fallback server is intentionally restricted:
104
+ - Allowed: `http_request`, `file_read`, `file_list`, `open_url`, `ping`.
105
+ - Denied: `exec`, `file_write`, `secret_inject`.
106
+ - Only accepts `POST /rpc` from localhost.
107
+ - `GET /health` returns a simple health response.
108
+
109
+ ## Limitations and Caveats
110
+ - No authentication layer; security relies on Unix socket permissions and policy rules.
111
+ - HTTP fallback is localhost-only and still policy-enforced but should be treated as a last resort.
112
+ - `open_url` is macOS-specific (uses `open`).
113
+ - `exec` output is capped at 10MB and does not stream.
114
+ - The secret vault stores a `.key` file alongside the encrypted vault; it does not integrate with OS keychains.
115
+ - Policy reload is timer-based; updates are not immediate.
116
+
117
+ ## Roadmap (Ideas)
118
+ - Per-client identity from socket credentials and scoped policies.
119
+ - Optional auth and mTLS for the HTTP fallback.
120
+ - Streaming responses for large outputs.
121
+ - Cross-platform URL opening.
122
+
123
+ ## Development
124
+ ```bash
125
+ # Build
126
+ npx nx build shield-broker
127
+ ```
128
+
129
+ ## Contribution Guide
130
+ - When adding a new operation, update:
131
+ - `src/handlers/*` (handler implementation)
132
+ - `src/server.ts` and `src/http-fallback.ts` (method routing + HTTP allowlist)
133
+ - `@agenshield/ipc` operation types and schemas
134
+ - Keep all handler errors mapped to a stable error code.
135
+ - Audit entries should include a deterministic `target` field for policy visibility.
136
+
137
+ ## Agent Notes
138
+ - `BrokerClient` enforces socket-only channels for `exec`, `file_write`, and `secret_inject`.
139
+ - The policy enforcer merges built-in rules with user rules; custom policies are additive.
140
+ - `AuditLogger` is append-only JSONL with rotation; use it for operational forensics.
141
+ - Any changes to JSON-RPC method names must be mirrored in `@agenshield/ipc`.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Audit Logger
3
+ *
4
+ * Logs all broker operations for security auditing.
5
+ */
6
+ import type { AuditEntry } from '../types.js';
7
+ export interface AuditLoggerOptions {
8
+ logPath: string;
9
+ logLevel: 'debug' | 'info' | 'warn' | 'error';
10
+ maxFileSize?: number;
11
+ maxFiles?: number;
12
+ }
13
+ export declare class AuditLogger {
14
+ private logPath;
15
+ private logLevel;
16
+ private maxFileSize;
17
+ private maxFiles;
18
+ private writeStream;
19
+ private currentSize;
20
+ private readonly levelPriority;
21
+ constructor(options: AuditLoggerOptions);
22
+ /**
23
+ * Initialize the write stream
24
+ */
25
+ private initializeStream;
26
+ /**
27
+ * Rotate log files if needed
28
+ */
29
+ private maybeRotate;
30
+ /**
31
+ * Log an audit entry
32
+ */
33
+ log(entry: AuditEntry): Promise<void>;
34
+ /**
35
+ * Check if we should log at the given level
36
+ */
37
+ private shouldLog;
38
+ /**
39
+ * Log a debug message
40
+ */
41
+ debug(message: string, data?: Record<string, unknown>): void;
42
+ /**
43
+ * Log an info message
44
+ */
45
+ info(message: string, data?: Record<string, unknown>): void;
46
+ /**
47
+ * Log a warning message
48
+ */
49
+ warn(message: string, data?: Record<string, unknown>): void;
50
+ /**
51
+ * Log an error message
52
+ */
53
+ error(message: string, data?: Record<string, unknown>): void;
54
+ /**
55
+ * Query audit logs
56
+ */
57
+ query(options: {
58
+ startTime?: Date;
59
+ endTime?: Date;
60
+ operation?: string;
61
+ allowed?: boolean;
62
+ limit?: number;
63
+ }): Promise<AuditEntry[]>;
64
+ /**
65
+ * Close the logger
66
+ */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AC,GAAG,IAAI;IAM3D;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAM5D;;OAEG;IACG,KAAK,CAAC,OAAO,EAAE;QACnB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,OAAO,CAAC,EAAE,IAAI,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAqCzB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAY7B"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Broker Client
3
+ *
4
+ * Client for communicating with the broker daemon via Unix socket or HTTP.
5
+ */
6
+ import type { HttpRequestParams, HttpRequestResult, FileReadParams, FileReadResult, FileWriteParams, FileWriteResult, FileListParams, FileListResult, ExecParams, ExecResult, OpenUrlParams, OpenUrlResult, SecretInjectParams, SecretInjectResult, PingResult, SkillInstallParams, SkillInstallResult, SkillUninstallParams, SkillUninstallResult } from '../types.js';
7
+ export interface BrokerClientOptions {
8
+ /** Unix socket path */
9
+ socketPath?: string;
10
+ /** HTTP fallback host */
11
+ httpHost?: string;
12
+ /** HTTP fallback port */
13
+ httpPort?: number;
14
+ /** Request timeout in ms */
15
+ timeout?: number;
16
+ /** Whether to prefer socket over HTTP */
17
+ preferSocket?: boolean;
18
+ }
19
+ export interface RequestOptions {
20
+ /** Request timeout override */
21
+ timeout?: number;
22
+ /** Force specific channel */
23
+ channel?: 'socket' | 'http';
24
+ }
25
+ export declare class BrokerClient {
26
+ private socketPath;
27
+ private httpHost;
28
+ private httpPort;
29
+ private timeout;
30
+ private preferSocket;
31
+ constructor(options?: BrokerClientOptions);
32
+ /**
33
+ * Make an HTTP request through the broker
34
+ */
35
+ httpRequest(params: HttpRequestParams, options?: RequestOptions): Promise<HttpRequestResult>;
36
+ /**
37
+ * Read a file through the broker
38
+ */
39
+ fileRead(params: FileReadParams, options?: RequestOptions): Promise<FileReadResult>;
40
+ /**
41
+ * Write a file through the broker
42
+ */
43
+ fileWrite(params: FileWriteParams, options?: RequestOptions): Promise<FileWriteResult>;
44
+ /**
45
+ * List files through the broker
46
+ */
47
+ fileList(params: FileListParams, options?: RequestOptions): Promise<FileListResult>;
48
+ /**
49
+ * Execute a command through the broker
50
+ */
51
+ exec(params: ExecParams, options?: RequestOptions): Promise<ExecResult>;
52
+ /**
53
+ * Open a URL through the broker
54
+ */
55
+ openUrl(params: OpenUrlParams, options?: RequestOptions): Promise<OpenUrlResult>;
56
+ /**
57
+ * Inject a secret through the broker
58
+ */
59
+ secretInject(params: SecretInjectParams, options?: RequestOptions): Promise<SecretInjectResult>;
60
+ /**
61
+ * Ping the broker
62
+ */
63
+ ping(echo?: string, options?: RequestOptions): Promise<PingResult>;
64
+ /**
65
+ * Install a skill through the broker
66
+ * Socket-only operation due to privileged file operations
67
+ */
68
+ skillInstall(params: SkillInstallParams, options?: RequestOptions): Promise<SkillInstallResult>;
69
+ /**
70
+ * Uninstall a skill through the broker
71
+ * Socket-only operation due to privileged file operations
72
+ */
73
+ skillUninstall(params: SkillUninstallParams, options?: RequestOptions): Promise<SkillUninstallResult>;
74
+ /**
75
+ * Check if the broker is available
76
+ */
77
+ isAvailable(): Promise<boolean>;
78
+ /**
79
+ * Make a request to the broker
80
+ */
81
+ private request;
82
+ /**
83
+ * Make a request via Unix socket
84
+ */
85
+ private socketRequest;
86
+ /**
87
+ * Make a request via HTTP
88
+ */
89
+ private httpRequest_internal;
90
+ }
91
+ //# sourceMappingURL=broker-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-client.d.ts","sourceRoot":"","sources":["../../src/client/broker-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAGV,iBAAiB,EACjB,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AAQ,CACZ,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC;IAI1B;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAO7E;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,aAAa,CAAC;IAIzB;;OAEG;IACG,YAAY,CAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAO9B;;OAEG;IACG,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IAIxE;;;OAGG;IACG,YAAY,CAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAO9B;;;OAGG;IACG,cAAc,CAClB,MAAM,EAAE,oBAAoB,EAC5B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,oBAAoB,CAAC;IAOhC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;OAEG;YACW,OAAO;IAuBrB;;OAEG;YACW,aAAa;IA+D3B;;OAEG;YACW,oBAAoB;CAqDnC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Broker Client
3
+ *
4
+ * Client library for communicating with the broker daemon.
5
+ */
6
+ export { BrokerClient } from './broker-client.js';
7
+ export type { BrokerClientOptions, RequestOptions } from './broker-client.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}