ops-agent 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 task-agent contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,239 @@
1
+ # ops-agent
2
+
3
+ `ops-agent` is an AI operations CLI for diagnosing and maintaining Linux servers and macOS workstations. It is built on the reusable [`task-agent`](../task-agent) kernel.
4
+
5
+ The initial release supports system discovery, host file reads and writes, arbitrary approved Bash commands, persistent multi-turn sessions, per-operation approval, and process-scoped full-trust mode.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js `22.19.0` or newer
10
+ - Linux or macOS
11
+ - An OpenAI-, Anthropic-, or Google-compatible model endpoint
12
+ - Normal host command availability for the requested probes (`df`, `du`, `ps`, `ss`/`lsof`/`netstat`, `systemctl`/`launchctl`, and `journalctl`/`log` as applicable)
13
+
14
+ Windows is not supported because Bash execution uses `/bin/sh` and the diagnostic tools target Linux and macOS.
15
+
16
+ ## Local installation from this repository
17
+
18
+ The package has not been published yet. To test the current source checkout:
19
+
20
+ ```bash
21
+ npm install
22
+ npm run check
23
+ npm test
24
+ npm run build
25
+ npm link --workspace ops-agent
26
+ ops-agent --help
27
+ ```
28
+
29
+ Remove the global development link with:
30
+
31
+ ```bash
32
+ npm unlink -g ops-agent
33
+ ```
34
+
35
+ After a public release, installation will be:
36
+
37
+ ```bash
38
+ npm install -g ops-agent
39
+ ```
40
+
41
+ ## Configure a model
42
+
43
+ `init` is optional. A complete environment-only configuration can run immediately:
44
+
45
+ ```bash
46
+ export OPS_AGENT_BASE_URL="https://example.com/v1"
47
+ export OPS_AGENT_MODEL="model-name"
48
+ export OPS_AGENT_API_KEY="..."
49
+
50
+ ops-agent
51
+ ```
52
+
53
+ The protocol defaults to OpenAI Chat Completions (`openai-completions`). `openai-chat` is accepted as an alias. Override it when needed:
54
+
55
+ ```bash
56
+ export OPS_AGENT_PROTOCOL="anthropic-messages"
57
+ ```
58
+
59
+ Product-specific variables have precedence over the config file. `OPENAI_BASE_URL`, `OPENAI_MODEL`, and `OPENAI_API_KEY` are also accepted as fallbacks when the corresponding `OPS_AGENT_*` variable is absent.
60
+
61
+ Supported environment variables:
62
+
63
+ ```text
64
+ OPS_AGENT_BASE_URL
65
+ OPS_AGENT_MODEL
66
+ OPS_AGENT_API_KEY
67
+ OPS_AGENT_PROTOCOL
68
+ OPS_AGENT_PROVIDER
69
+ OPS_AGENT_API_KEY_ENV
70
+ OPS_AGENT_TASKS_DIR
71
+ OPS_AGENT_CONTEXT_WINDOW
72
+ OPS_AGENT_MAX_TOKENS
73
+ OPS_AGENT_REASONING
74
+ ```
75
+
76
+ `OPS_AGENT_REASONING` accepts `true`, `false`, `1`, or `0`.
77
+
78
+ You can persist a baseline configuration with `init`:
79
+
80
+ ```bash
81
+ export OPS_AGENT_API_KEY="..."
82
+
83
+ ops-agent init \
84
+ --base-url https://example.com/v1 \
85
+ --protocol openai-completions \
86
+ --model model-name
87
+ ```
88
+
89
+ Running `init` again performs an incremental update. Explicit flags replace their corresponding values; omitted fields remain unchanged. For example, this changes only the model:
90
+
91
+ ```bash
92
+ ops-agent init --model another-model
93
+ ```
94
+
95
+ Use `--reasoning` to enable reasoning and `--no-reasoning` to disable a previously enabled value.
96
+
97
+ Supported protocol values are:
98
+
99
+ - `openai-completions`
100
+ - `openai-responses`
101
+ - `anthropic-messages`
102
+ - `google-generative-ai`
103
+
104
+ Optional initialization flags include `--provider`, `--api-key-env`, `--api-key`, `--tasks-dir`, `--context-window`, `--max-tokens`, `--reasoning`, and `--no-reasoning`.
105
+
106
+ `--api-key` stores the key in the product config and may expose it in shell history and process listings. The environment-variable flow avoids persisting the key value. Runtime environment overrides are not written back over an existing config file; only normal task metadata such as `lastTask` is updated.
107
+
108
+ Configuration is stored at `${XDG_CONFIG_HOME:-~/.config}/ops-agent/config.json` with mode `0600`. Task sessions default to `${XDG_DATA_HOME:-~/.local/share}/ops-agent/tasks`, with private task directories and append-only event logs.
109
+
110
+ ## Use the Agent
111
+
112
+ Start a persistent interactive session:
113
+
114
+ ```bash
115
+ ops-agent
116
+ ```
117
+
118
+ Run a single prompt:
119
+
120
+ ```bash
121
+ ops-agent "检查 CPU、内存、磁盘和进程压力,不要修改系统"
122
+ ops-agent run "检查 nginx 状态和最近 30 分钟日志"
123
+ ```
124
+
125
+ Continue and inspect tasks:
126
+
127
+ ```bash
128
+ ops-agent resume "继续定位根因"
129
+ ops-agent resume --task <task-id> "验证修复结果"
130
+ ops-agent status --task <task-id>
131
+ ```
132
+
133
+ ## Clear managed local data
134
+
135
+ `clear` removes only local data managed by `ops-agent`:
136
+
137
+ ```bash
138
+ ops-agent clear task --task <task-id>
139
+ ops-agent clear tasks
140
+ ops-agent clear config
141
+ ops-agent clear all
142
+ ```
143
+
144
+ Preview exact paths and sizes without deleting:
145
+
146
+ ```bash
147
+ ops-agent clear all --dry-run
148
+ ```
149
+
150
+ Interactive deletion asks for confirmation. Non-interactive deletion is refused unless `--yes` (or `-y`) is present:
151
+
152
+ ```bash
153
+ ops-agent clear tasks --yes
154
+ ```
155
+
156
+ Scopes:
157
+
158
+ - `task`: one task directory selected by `--task`
159
+ - `tasks`: all valid direct task directories under the configured tasks directory; configuration is retained
160
+ - `config`: `${XDG_CONFIG_HOME:-~/.config}/ops-agent/config.json`; task data is retained
161
+ - `all`: all managed task directories plus the product config file
162
+
163
+ The command refuses active tasks, unreadable run locks, symbolic-link task directories, and paths outside the managed roots. It preflights all selected targets before deleting any of them.
164
+
165
+ `clear all` does **not** mean "remove every trace." It does not remove files created or modified through `host_write_file` or Bash, shell history, npm installation/link state, operating-system logs, audit logs, backups, remote-host changes, or model-provider request logs. Those resources are outside the product's managed data boundary.
166
+
167
+ During a model or tool run:
168
+
169
+ - `Esc` aborts the current run, terminates an active Bash process group, preserves the session, and returns to the interactive prompt.
170
+ - `Ctrl+C` exits the CLI.
171
+ - `/exit` and `/quit` exit from the interactive prompt.
172
+ - `ops-agent abort --task <task-id>` requests cancellation of a background run or a run controlled from another terminal.
173
+
174
+ ## Approval and trust
175
+
176
+ The default mode is `ask`:
177
+
178
+ ```bash
179
+ ops-agent
180
+ ops-agent run "restart nginx"
181
+ ```
182
+
183
+ Approval behavior:
184
+
185
+ | Capability | Default `ask` mode |
186
+ | --- | --- |
187
+ | System, filesystem, process, port, service, and log probes | Runs without confirmation |
188
+ | Ordinary bounded host file read | Runs without confirmation |
189
+ | Read from a commonly sensitive path | Requires confirmation |
190
+ | Host file write or append | Requires confirmation with path and content preview |
191
+ | Arbitrary Bash command | Requires confirmation with command and working directory |
192
+
193
+ Operations requiring approval are denied when no TTY is available. A denial is final for that tool call.
194
+
195
+ Full trust skips every confirmation for the current CLI process only:
196
+
197
+ ```bash
198
+ ops-agent --trust full
199
+ ops-agent run "apply the approved fix and verify it" --trust full
200
+ ```
201
+
202
+ Full trust is not persisted. It gives the model the effective host access of the user running `ops-agent`; use it only with a trusted prompt, model endpoint, and machine context.
203
+
204
+ The audit log still records approval-policy checks in full-trust mode. These decisions are marked with `policy: "full"` and `implicit: true`; they do not represent an interactive terminal confirmation.
205
+
206
+ ## Operations capabilities
207
+
208
+ The built-in tools are:
209
+
210
+ - `system_snapshot`: OS, CPU, load, uptime, memory, and Linux memory-pressure facts
211
+ - `filesystem_usage`: mounted filesystem capacity and inode usage
212
+ - `disk_hotspots`: largest direct children under selected host roots
213
+ - `process_snapshot`: bounded process list sorted by CPU or memory
214
+ - `listening_ports`: listening TCP/UDP sockets and owning processes when available
215
+ - `service_status`: systemd or launchd service state
216
+ - `recent_service_logs`: bounded journald or macOS unified log window
217
+ - `host_read_file`: bounded UTF-8 reads from absolute host paths
218
+ - `host_write_file`: approved UTF-8 overwrite or append to absolute host paths
219
+ - `bash`: approved arbitrary `/bin/sh -lc` command execution
220
+
221
+ Bash runs with no stdin and no pseudo-terminal. Commands requiring an interactive password, terminal UI, or interactive `sudo` prompt will not work unless configured for non-interactive execution. SSH can be invoked through Bash and `SSH_AUTH_SOCK` is retained, but remote observations must be identified as remote by the Agent.
222
+
223
+ Credential-like environment variable names containing terms such as `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `CREDENTIAL`, or `AUTH` are removed from Bash subprocesses. This is defense in depth, not a secret-isolation guarantee; commands can still read files and other host resources available to the invoking user.
224
+
225
+ ## Safety boundary
226
+
227
+ `ops-agent` is not a sandbox. Approval prompts, path checks, output bounds, timeouts, and process cancellation reduce accidental harm but do not isolate arbitrary shell execution from the host.
228
+
229
+ For higher-risk use, run it as a dedicated non-root OS account or inside a container with explicit mounts, resource limits, and network policy. Do not expose a writable home directory, SSH credentials, cloud credentials, or a Docker socket to an untrusted prompt or model endpoint.
230
+
231
+ Host writes refuse final symbolic links, preserve the permissions of existing regular files, and create new files with mode `0600`. These checks do not replace OS isolation or backups.
232
+
233
+ ## Known limitations
234
+
235
+ - The current runtime dependency `@earendil-works/pi-coding-agent@0.83.0` contains `brace-expansion@5.0.7`, affected by `GHSA-mh99-v99m-4gvg` (unbounded brace expansion denial of service). Default Pi extensions and resource discovery are disabled, reducing the reachable surface, but the vulnerable package remains installed. Upgrade is blocked until Pi publishes a fixed version and the runtime contract suite passes.
236
+ - Bash is non-interactive and does not provide a pseudo-terminal.
237
+ - Diagnostics depend on host commands and permissions; unavailable or restricted probes return structured failures rather than fabricated results.
238
+ - Sessions are local files, not a distributed job system. Durable background tools are not implemented.
239
+ - This version has automated Linux/macOS-oriented tool tests, but should be soaked on representative workstations and servers before production use.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { runAgentCli } from "@chao.song/task-agent";
3
+ import { opsScenario } from "./index.js";
4
+ runAgentCli({
5
+ command: "ops-agent",
6
+ displayName: "Operations Agent",
7
+ scenario: opsScenario,
8
+ envPrefix: "OPS_AGENT",
9
+ interactive: true,
10
+ }).catch((error) => {
11
+ console.error(error instanceof Error ? error.message : String(error));
12
+ process.exitCode = 1;
13
+ });
14
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,WAAW,CAAC;IACV,OAAO,EAAE,WAAW;IACpB,WAAW,EAAE,kBAAkB;IAC/B,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1B,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const opsScenario: import("@chao.song/task-agent").ScenarioDefinition;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,oDAiCtB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { defineScenario } from "@chao.song/task-agent";
2
+ import { opsTools } from "./tools.js";
3
+ export const opsScenario = defineScenario({
4
+ name: "ops",
5
+ version: "0.1.0",
6
+ systemPrompt: `You are an operations agent for workstation optimization and server diagnostics.
7
+
8
+ Operating contract:
9
+ - Start with evidence. Establish platform, capacity, load, process, filesystem, service, port, and log facts relevant to the request before diagnosing.
10
+ - Clearly separate observed facts, hypotheses, risk, recommended actions, and commands that have not been executed.
11
+ - Correlate timestamps and multiple signals. A single high metric or log line is not sufficient evidence of root cause.
12
+ - Apply platform semantics before interpreting metrics. On macOS, do not infer memory pressure from free bytes or derive swap usage from the APFS /System/Volumes/VM capacity; use memory_pressure, vm_stat, and sysctl vm.swapusage evidence. Do not claim process states such as zombie or blocked unless the collected process fields include state.
13
+ - When later evidence corrects an earlier observation, explicitly supersede the old observation and do not repeat it as a current fact in summaries.
14
+ - Never claim a command, restart, cleanup, configuration change, or recovery succeeded unless a tool result proves it.
15
+ - Read-only diagnostic tools may run directly. Host writes and Bash are guarded by the runtime's terminal approval policy. A denied operation is final; do not retry it through a different tool.
16
+ - Do not claim or suggest capabilities that are not present in the active tool list. This product has no unapproved workspace-write tool; writing anywhere through host_write_file or Bash remains subject to the runtime approval policy.
17
+ - Before a mutating command, state expected impact, prerequisites, verification, rollback, and risk. Prefer narrow, reversible changes and preserve existing configuration before replacement.
18
+ - In full-trust mode, approval is implicit but the same operational discipline still applies. Full trust is permission to execute necessary work, not permission to skip diagnosis, verification, or rollback planning.
19
+ - Treat secrets, environment variables, command lines, logs, user names, network endpoints, and file paths as potentially sensitive. Quote only the minimum needed for diagnosis.
20
+ - Do not diagnose a remote machine unless tool results are explicitly from that machine. SSH may be executed through Bash after approval; clearly identify the remote target and never imply local observations came from it.
21
+ - For workstation optimization, consider memory pressure, CPU saturation, storage pressure, startup/background processes, thermals when observable, and workload context.
22
+ - For servers, consider capacity, process health, filesystem and inode pressure, listening services, service manager state, recent logs, and exposure.
23
+ - End with severity, confidence, observed evidence, prioritized next actions, and which actions require approval.`,
24
+ tools: opsTools,
25
+ security: {
26
+ workspaceTools: ["workspace_read", "workspace_grep", "workspace_find", "workspace_list"],
27
+ maxToolResultBytes: 64 * 1024,
28
+ toolTimeoutMs: 15 * 60_000,
29
+ },
30
+ limits: { maxTurns: 60, maxWallTimeMinutes: 60, maxToolConcurrency: 2 },
31
+ compaction: {
32
+ reserveTokens: 16_384,
33
+ keepRecentTokens: 20_000,
34
+ requiredSections: ["Goal", "Constraints", "Observed Facts", "Risks", "Approved Changes", "Pending Actions"],
35
+ },
36
+ });
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;IACxC,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE;;;;;;;;;;;;;;;;;kHAiBkG;IAChH,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE;QACR,cAAc,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,CAAC;QACxF,kBAAkB,EAAE,EAAE,GAAG,IAAI;QAC7B,aAAa,EAAE,EAAE,GAAG,MAAM;KAC3B;IACD,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,EAAE;IACvE,UAAU,EAAE;QACV,aAAa,EAAE,MAAM;QACrB,gBAAgB,EAAE,MAAM;QACxB,gBAAgB,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,CAAC;KAC5G;CACF,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { type JsonValue, type ScenarioTool } from "@chao.song/task-agent";
2
+ export declare const systemSnapshotTool: ScenarioTool<Record<string, never>>;
3
+ export declare const filesystemUsageTool: ScenarioTool<Record<string, never>>;
4
+ type HotspotRoot = "root" | "var" | "home" | "tmp" | "user-home";
5
+ interface HotspotInput {
6
+ root: HotspotRoot;
7
+ maxEntries?: number;
8
+ }
9
+ export declare const diskHotspotsTool: ScenarioTool<HotspotInput>;
10
+ interface ProcessInput {
11
+ sortBy?: "cpu" | "memory";
12
+ limit?: number;
13
+ }
14
+ export declare const processSnapshotTool: ScenarioTool<ProcessInput>;
15
+ export declare const listeningPortsTool: ScenarioTool<Record<string, never>>;
16
+ interface ServiceInput {
17
+ service: string;
18
+ }
19
+ export declare const serviceStatusTool: ScenarioTool<ServiceInput>;
20
+ interface LogInput extends ServiceInput {
21
+ sinceMinutes?: number;
22
+ lines?: number;
23
+ }
24
+ export declare const recentServiceLogsTool: ScenarioTool<LogInput>;
25
+ interface ReadFileInput {
26
+ path: string;
27
+ offsetBytes?: number;
28
+ maxBytes?: number;
29
+ }
30
+ export declare const hostReadFileTool: ScenarioTool<ReadFileInput>;
31
+ interface WriteFileInput {
32
+ path: string;
33
+ content: string;
34
+ mode?: "overwrite" | "append";
35
+ }
36
+ export declare const hostWriteFileTool: ScenarioTool<WriteFileInput>;
37
+ interface BashInput {
38
+ command: string;
39
+ cwd?: string;
40
+ timeoutSeconds?: number;
41
+ }
42
+ export declare const bashTool: ScenarioTool<BashInput>;
43
+ export declare const opsTools: ScenarioTool<unknown, JsonValue>[];
44
+ export {};
45
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkB,KAAK,SAAS,EAAE,KAAK,YAAY,EAAqC,MAAM,uBAAuB,CAAC;AAM7H,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAgClE,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUnE,CAAC;AAEF,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,CAAC;AACjE,UAAU,YAAY;IAAG,IAAI,EAAE,WAAW,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE;AAEjE,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,YAAY,CAwBvD,CAAC;AAEF,UAAU,YAAY;IAAG,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAEpE,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,YAAY,CAmB1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAmBlE,CAAC;AAEF,UAAU,YAAY;IAAG,OAAO,EAAE,MAAM,CAAA;CAAE;AAE1C,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,YAAY,CAgBxD,CAAC;AAEF,UAAU,QAAS,SAAQ,YAAY;IAAG,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAEjF,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,QAAQ,CA0BxD,CAAC;AAEF,UAAU,aAAa;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;AAEjF,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,aAAa,CAyCxD,CAAC;AAEF,UAAU,cAAc;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;CAAE;AAEzF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,cAAc,CAkC1D,CAAC;AAEF,UAAU,SAAS;IAAG,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE;AAE9E,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,SAAS,CAuC5C,CAAC;AAkNF,eAAO,MAAM,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAWtD,CAAC"}
package/dist/tools.js ADDED
@@ -0,0 +1,529 @@
1
+ import { execFile, spawn } from "node:child_process";
2
+ import { access, lstat, open, readFile, realpath, stat } from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { constants } from "node:fs";
6
+ import { promisify } from "node:util";
7
+ import { truncateOutput } from "@chao.song/task-agent";
8
+ const execFileAsync = promisify(execFile);
9
+ const MAX_STDOUT = 64 * 1024;
10
+ const SERVICE_NAME = /^[a-zA-Z0-9][a-zA-Z0-9@_.:-]{0,127}$/;
11
+ export const systemSnapshotTool = {
12
+ name: "system_snapshot",
13
+ description: "Collect OS, CPU, memory, load, uptime, and Linux memory-pressure facts without changing the host.",
14
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
15
+ concurrency: "safe",
16
+ async execute(_input, context) {
17
+ const totalMemory = os.totalmem();
18
+ const freeMemory = os.freemem();
19
+ const linuxMemory = os.platform() === "linux" ? await readLinuxMemoryInfo() : undefined;
20
+ const macMemory = os.platform() === "darwin" ? await readMacMemoryPressure(context) : undefined;
21
+ const availableMemory = linuxMemory?.MemAvailable;
22
+ return {
23
+ ok: true,
24
+ output: {
25
+ hostname: os.hostname(),
26
+ platform: os.platform(),
27
+ release: os.release(),
28
+ architecture: os.arch(),
29
+ cpuCount: os.cpus().length,
30
+ cpuModel: os.cpus()[0]?.model ?? "unknown",
31
+ loadAverage: safeFact(() => os.loadavg()),
32
+ uptimeSeconds: safeFact(() => os.uptime()),
33
+ memory: {
34
+ totalBytes: totalMemory,
35
+ freeBytes: freeMemory,
36
+ ...(availableMemory === undefined ? {} : { availableBytes: availableMemory, usedPercent: Math.round(((totalMemory - availableMemory) / totalMemory) * 1000) / 10 }),
37
+ ...(linuxMemory ? { linux: linuxMemory } : {}),
38
+ ...(macMemory ? { macos: macMemory } : {}),
39
+ },
40
+ },
41
+ };
42
+ },
43
+ };
44
+ export const filesystemUsageTool = {
45
+ name: "filesystem_usage",
46
+ description: "Report capacity and inode usage for mounted filesystems using df.",
47
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
48
+ concurrency: "safe",
49
+ async execute(_input, context) {
50
+ const capacity = await runCommand("df", ["-Pk"], context);
51
+ const inodes = await runCommand("df", ["-Pi"], context);
52
+ return commandResult("filesystem_usage", `${capacity.stdout}\n--- inode usage ---\n${inodes.stdout}`, `${capacity.stderr}${inodes.stderr}`, Math.max(capacity.exitCode, inodes.exitCode));
53
+ },
54
+ };
55
+ export const diskHotspotsTool = {
56
+ name: "disk_hotspots",
57
+ description: "Measure the largest direct children under an approved host directory, staying on one filesystem.",
58
+ inputSchema: {
59
+ type: "object",
60
+ required: ["root"],
61
+ properties: {
62
+ root: { type: "string", enum: ["root", "var", "home", "tmp", "user-home"] },
63
+ maxEntries: { type: "integer", minimum: 1, maximum: 50 },
64
+ },
65
+ additionalProperties: false,
66
+ },
67
+ async execute(input, context) {
68
+ const target = hotspotPath(input.root);
69
+ try {
70
+ await access(target);
71
+ }
72
+ catch {
73
+ return { ok: false, error: { code: "path_unavailable", message: `${target} is not available on this host` } };
74
+ }
75
+ const args = os.platform() === "darwin" ? ["-x", "-k", "-d", "1", target] : ["-x", "-k", "--max-depth=1", target];
76
+ const result = await runCommand("du", args, context, 30_000);
77
+ const lines = result.stdout.trim().split("\n").filter(Boolean).sort((left, right) => firstNumber(right) - firstNumber(left));
78
+ return commandResult("disk_hotspots", lines.slice(0, input.maxEntries ?? 20).join("\n"), result.stderr, result.exitCode);
79
+ },
80
+ };
81
+ export const processSnapshotTool = {
82
+ name: "process_snapshot",
83
+ description: "List processes with PID, parent, state, CPU, memory, elapsed time, user, and command, sorted by CPU or memory.",
84
+ inputSchema: {
85
+ type: "object",
86
+ properties: {
87
+ sortBy: { type: "string", enum: ["cpu", "memory"] },
88
+ limit: { type: "integer", minimum: 1, maximum: 100 },
89
+ },
90
+ additionalProperties: false,
91
+ },
92
+ concurrency: "safe",
93
+ async execute(input, context) {
94
+ const result = await runCommand("ps", ["-axo", "pid,ppid,state,%cpu,%mem,etime,user,comm"], context);
95
+ const [header = "", ...rows] = result.stdout.trim().split("\n");
96
+ const column = input.sortBy === "memory" ? 4 : 3;
97
+ rows.sort((left, right) => numericColumn(right, column) - numericColumn(left, column));
98
+ return commandResult("process_snapshot", [header, ...rows.slice(0, input.limit ?? 25)].join("\n"), result.stderr, result.exitCode);
99
+ },
100
+ };
101
+ export const listeningPortsTool = {
102
+ name: "listening_ports",
103
+ description: "List listening TCP/UDP sockets and owning processes when the operating system exposes them.",
104
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
105
+ concurrency: "safe",
106
+ async execute(_input, context) {
107
+ if (os.platform() === "linux" && await commandExists("ss")) {
108
+ const result = await runCommand("ss", ["-lntup"], context);
109
+ return commandResult("listening_ports", result.stdout, result.stderr, result.exitCode);
110
+ }
111
+ if (await commandExists("lsof")) {
112
+ const tcp = await runCommand("lsof", ["-nP", "-iTCP", "-sTCP:LISTEN"], context);
113
+ const udp = await runCommand("lsof", ["-nP", "-iUDP"], context);
114
+ return commandResult("listening_ports", `${tcp.stdout}\n--- UDP ---\n${udp.stdout}`, `${tcp.stderr}${udp.stderr}`, Math.max(tcp.exitCode, udp.exitCode));
115
+ }
116
+ const args = os.platform() === "darwin" ? ["-anv", "-p", "tcp"] : ["-lntup"];
117
+ const result = await runCommand("netstat", args, context);
118
+ return commandResult("listening_ports", result.stdout, result.stderr, result.exitCode);
119
+ },
120
+ };
121
+ export const serviceStatusTool = {
122
+ name: "service_status",
123
+ description: "Inspect one systemd unit or macOS launchd service. Service names are validated and no state is changed.",
124
+ inputSchema: serviceSchema(),
125
+ async execute(input, context) {
126
+ if (!SERVICE_NAME.test(input.service))
127
+ return invalidServiceName();
128
+ if (os.platform() === "linux" && await commandExists("systemctl")) {
129
+ const result = await runCommand("systemctl", ["show", input.service, "--no-pager", "--property=Id,LoadState,ActiveState,SubState,UnitFileState,MainPID,ExecMainStatus,MemoryCurrent,CPUUsageNSec"], context);
130
+ return commandResult("service_status", result.stdout, result.stderr, result.exitCode);
131
+ }
132
+ if (os.platform() === "darwin" && await commandExists("launchctl")) {
133
+ const result = await runCommand("launchctl", ["print", `system/${input.service}`], context);
134
+ return commandResult("service_status", result.stdout, result.stderr, result.exitCode);
135
+ }
136
+ return { ok: false, error: { code: "service_manager_unavailable", message: "No supported service manager was found" } };
137
+ },
138
+ };
139
+ export const recentServiceLogsTool = {
140
+ name: "recent_service_logs",
141
+ description: "Read a bounded window of recent system logs for one validated service using journald or macOS unified logging.",
142
+ inputSchema: {
143
+ ...serviceSchema(),
144
+ properties: {
145
+ service: { type: "string", minLength: 1, maxLength: 128 },
146
+ sinceMinutes: { type: "integer", minimum: 1, maximum: 1440 },
147
+ lines: { type: "integer", minimum: 1, maximum: 500 },
148
+ },
149
+ },
150
+ async execute(input, context) {
151
+ if (!SERVICE_NAME.test(input.service))
152
+ return invalidServiceName();
153
+ const since = input.sinceMinutes ?? 30;
154
+ const lines = input.lines ?? 200;
155
+ if (os.platform() === "linux" && await commandExists("journalctl")) {
156
+ const result = await runCommand("journalctl", ["--unit", input.service, "--since", `${since} minutes ago`, "--lines", String(lines), "--no-pager", "--output", "short-iso"], context);
157
+ return commandResult("recent_service_logs", result.stdout, result.stderr, result.exitCode);
158
+ }
159
+ if (os.platform() === "darwin" && await commandExists("log")) {
160
+ const predicate = `process == "${input.service}"`;
161
+ const result = await runCommand("log", ["show", "--style", "compact", "--last", `${since}m`, "--predicate", predicate], context, 20_000);
162
+ return commandResult("recent_service_logs", result.stdout.split("\n").slice(-lines).join("\n"), result.stderr, result.exitCode);
163
+ }
164
+ return { ok: false, error: { code: "log_service_unavailable", message: "No supported system log service was found" } };
165
+ },
166
+ };
167
+ export const hostReadFileTool = {
168
+ name: "host_read_file",
169
+ description: "Read a bounded byte range from an absolute host file. Use only files relevant to the operational task and avoid exposing secrets.",
170
+ inputSchema: {
171
+ type: "object",
172
+ required: ["path"],
173
+ properties: {
174
+ path: { type: "string", minLength: 1, maxLength: 4096 },
175
+ offsetBytes: { type: "integer", minimum: 0 },
176
+ maxBytes: { type: "integer", minimum: 1, maximum: 262144 },
177
+ },
178
+ additionalProperties: false,
179
+ },
180
+ concurrency: "safe",
181
+ async execute(input, context) {
182
+ if (!input.path.startsWith("/"))
183
+ return absolutePathRequired();
184
+ const target = await realpath(input.path);
185
+ if (isSensitivePath(target)) {
186
+ const approved = await context.requestApproval({
187
+ action: "host_read_sensitive_file",
188
+ description: "Read a file from a path that commonly contains credentials or security configuration.",
189
+ risk: "high",
190
+ path: target,
191
+ });
192
+ if (!approved)
193
+ return approvalDenied();
194
+ }
195
+ const offset = input.offsetBytes ?? 0;
196
+ const maxBytes = input.maxBytes ?? 64 * 1024;
197
+ const handle = await open(target, constants.O_RDONLY | noFollowFlag());
198
+ try {
199
+ const info = await handle.stat();
200
+ if (!info.isFile())
201
+ return { ok: false, error: { code: "not_a_file", message: "Path is not a regular file" } };
202
+ const buffer = Buffer.alloc(Math.min(maxBytes, Math.max(0, info.size - offset)));
203
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
204
+ const data = buffer.subarray(0, bytesRead);
205
+ if (data.includes(0))
206
+ return { ok: false, error: { code: "binary_file", message: "Binary files are not returned to the model" } };
207
+ return { ok: true, output: { path: target, offsetBytes: offset, bytesRead, sizeBytes: info.size, content: data.toString("utf8"), truncated: offset + bytesRead < info.size } };
208
+ }
209
+ finally {
210
+ await handle.close();
211
+ }
212
+ },
213
+ };
214
+ export const hostWriteFileTool = {
215
+ name: "host_write_file",
216
+ description: "Write or append UTF-8 content to an absolute host file after terminal user approval. Parent directories must already exist.",
217
+ inputSchema: {
218
+ type: "object",
219
+ required: ["path", "content"],
220
+ properties: {
221
+ path: { type: "string", minLength: 1, maxLength: 4096 },
222
+ content: { type: "string", maxLength: 1048576 },
223
+ mode: { type: "string", enum: ["overwrite", "append"] },
224
+ },
225
+ additionalProperties: false,
226
+ },
227
+ async execute(input, context) {
228
+ if (!input.path.startsWith("/"))
229
+ return absolutePathRequired();
230
+ const mode = input.mode ?? "overwrite";
231
+ const target = await canonicalWriteTarget(input.path);
232
+ const approved = await context.requestApproval({
233
+ action: "host_write_file",
234
+ description: `${mode === "append" ? "Append" : "Write"} ${Buffer.byteLength(input.content)} bytes to a host file.`,
235
+ risk: target.startsWith("/etc/") || target.startsWith("/System/") || isSensitivePath(target) ? "high" : "medium",
236
+ path: target,
237
+ preview: truncateOutput(input.content, 2000).text,
238
+ });
239
+ if (!approved)
240
+ return approvalDenied();
241
+ if (mode === "append") {
242
+ const handle = await open(target, constants.O_WRONLY | constants.O_APPEND | constants.O_CREAT | noFollowFlag(), 0o600);
243
+ try {
244
+ await handle.writeFile(input.content, "utf8");
245
+ }
246
+ finally {
247
+ await handle.close();
248
+ }
249
+ }
250
+ else {
251
+ await overwriteFile(target, input.content);
252
+ }
253
+ return { ok: true, output: { path: target, mode, bytesWritten: Buffer.byteLength(input.content) } };
254
+ },
255
+ };
256
+ export const bashTool = {
257
+ name: "bash",
258
+ description: "Execute an arbitrary shell command on the host after terminal user approval. Supports full operational changes; inspect first and include verification and rollback for risky actions.",
259
+ inputSchema: {
260
+ type: "object",
261
+ required: ["command"],
262
+ properties: {
263
+ command: { type: "string", minLength: 1, maxLength: 32768 },
264
+ cwd: { type: "string", minLength: 1, maxLength: 4096 },
265
+ timeoutSeconds: { type: "integer", minimum: 1, maximum: 600 },
266
+ },
267
+ additionalProperties: false,
268
+ },
269
+ async execute(input, context) {
270
+ const cwd = input.cwd ?? os.homedir();
271
+ if (!cwd.startsWith("/"))
272
+ return absolutePathRequired();
273
+ if (hasUnsafeControlCharacters(input.command) || hasUnsafeControlCharacters(cwd)) {
274
+ return { ok: false, error: { code: "unsafe_control_characters", message: "Command and cwd cannot contain terminal control characters" } };
275
+ }
276
+ const canonicalCwd = await realpath(cwd);
277
+ if (!(await stat(canonicalCwd)).isDirectory())
278
+ return { ok: false, error: { code: "not_a_directory", message: "Bash cwd is not a directory" } };
279
+ const approved = await context.requestApproval({
280
+ action: "bash",
281
+ description: `Execute a host shell command in ${canonicalCwd}.`,
282
+ risk: "high",
283
+ command: input.command,
284
+ path: canonicalCwd,
285
+ });
286
+ if (!approved)
287
+ return approvalDenied();
288
+ const timeout = (input.timeoutSeconds ?? 120) * 1000;
289
+ const result = await runShell(input.command, canonicalCwd, context, timeout);
290
+ const stdout = truncateOutput(result.stdout, MAX_STDOUT);
291
+ const stderr = truncateOutput(result.stderr, MAX_STDOUT);
292
+ return {
293
+ ok: result.exitCode === 0,
294
+ output: { command: input.command, cwd: canonicalCwd, exitCode: result.exitCode, signal: result.signal, stdout: stdout.text, stderr: stderr.text, truncated: stdout.truncated || stderr.truncated },
295
+ ...(result.exitCode === 0 ? {} : { error: { code: "command_failed", message: `Command exited with status ${result.exitCode}` } }),
296
+ };
297
+ },
298
+ };
299
+ async function runCommand(executable, args, context, timeout = 10_000) {
300
+ try {
301
+ const result = await execFileAsync(executable, args, {
302
+ cwd: context.workDir,
303
+ timeout,
304
+ maxBuffer: 512 * 1024,
305
+ windowsHide: true,
306
+ signal: context.signal,
307
+ env: safeEnvironment(),
308
+ });
309
+ return { ...result, exitCode: 0 };
310
+ }
311
+ catch (error) {
312
+ const details = error;
313
+ return { stdout: details.stdout ?? "", stderr: details.stderr ?? details.message, exitCode: typeof details.code === "number" ? details.code : 1 };
314
+ }
315
+ }
316
+ async function runShell(command, cwd, context, timeout) {
317
+ if (context.signal.aborted) {
318
+ return { stdout: "", stderr: "Command was aborted before it started", exitCode: 1, signal: null };
319
+ }
320
+ return new Promise((resolve) => {
321
+ const child = spawn("/bin/sh", ["-lc", command], {
322
+ cwd,
323
+ detached: true,
324
+ windowsHide: true,
325
+ env: shellEnvironment(),
326
+ stdio: ["ignore", "pipe", "pipe"],
327
+ });
328
+ const stdout = [];
329
+ const stderr = [];
330
+ let stdoutBytes = 0;
331
+ let stderrBytes = 0;
332
+ let finished = false;
333
+ let forcedKill;
334
+ const collect = (chunks, current, chunk) => {
335
+ const remaining = 2 * 1024 * 1024 - current;
336
+ if (remaining > 0)
337
+ chunks.push(chunk.subarray(0, remaining));
338
+ return current + chunk.length;
339
+ };
340
+ child.stdout.on("data", (chunk) => { stdoutBytes = collect(stdout, stdoutBytes, chunk); });
341
+ child.stderr.on("data", (chunk) => { stderrBytes = collect(stderr, stderrBytes, chunk); });
342
+ const killGroup = () => {
343
+ if (!child.pid || finished)
344
+ return;
345
+ try {
346
+ process.kill(-child.pid, "SIGTERM");
347
+ }
348
+ catch {
349
+ child.kill("SIGTERM");
350
+ }
351
+ forcedKill = setTimeout(() => {
352
+ if (finished || !child.pid)
353
+ return;
354
+ try {
355
+ process.kill(-child.pid, "SIGKILL");
356
+ }
357
+ catch {
358
+ child.kill("SIGKILL");
359
+ }
360
+ }, 2000);
361
+ forcedKill.unref();
362
+ };
363
+ const timeoutHandle = setTimeout(killGroup, timeout);
364
+ timeoutHandle.unref();
365
+ context.signal.addEventListener("abort", killGroup, { once: true });
366
+ const finish = (exitCode, signal, extraError = "") => {
367
+ if (finished)
368
+ return;
369
+ finished = true;
370
+ clearTimeout(timeoutHandle);
371
+ if (forcedKill)
372
+ clearTimeout(forcedKill);
373
+ context.signal.removeEventListener("abort", killGroup);
374
+ resolve({
375
+ stdout: Buffer.concat(stdout).toString("utf8"),
376
+ stderr: `${Buffer.concat(stderr).toString("utf8")}${extraError}`,
377
+ exitCode,
378
+ signal,
379
+ });
380
+ };
381
+ child.on("error", (error) => finish(1, null, error.message));
382
+ child.on("close", (code, signal) => finish(code ?? 1, signal));
383
+ });
384
+ }
385
+ function commandResult(command, stdout, stderr, exitCode = 0) {
386
+ const boundedOut = truncateOutput(stdout, MAX_STDOUT);
387
+ const boundedErr = truncateOutput(stderr, 8 * 1024);
388
+ return {
389
+ ok: exitCode === 0,
390
+ output: { command, exitCode, stdout: boundedOut.text, stderr: boundedErr.text, truncated: boundedOut.truncated || boundedErr.truncated },
391
+ ...(exitCode === 0 ? {} : { error: { code: "diagnostic_failed", message: `${command} failed with exit status ${exitCode}` } }),
392
+ ...(stderr.trim() ? { warnings: [{ code: "command_stderr", message: "The diagnostic command produced stderr; inspect it before drawing conclusions." }] } : {}),
393
+ };
394
+ }
395
+ async function readLinuxMemoryInfo() {
396
+ try {
397
+ const wanted = new Set(["MemAvailable", "Buffers", "Cached", "SwapTotal", "SwapFree", "SReclaimable"]);
398
+ return Object.fromEntries((await readFile("/proc/meminfo", "utf8")).split("\n").flatMap((line) => {
399
+ const match = /^(\w+):\s+(\d+)\s+kB$/.exec(line);
400
+ return match && wanted.has(match[1] ?? "") ? [[match[1], Number(match[2]) * 1024]] : [];
401
+ }));
402
+ }
403
+ catch {
404
+ return undefined;
405
+ }
406
+ }
407
+ async function readMacMemoryPressure(context) {
408
+ if (!(await commandExists("memory_pressure")))
409
+ return undefined;
410
+ const result = await runCommand("memory_pressure", ["-Q"], context);
411
+ if (result.exitCode !== 0)
412
+ return undefined;
413
+ const match = /System-wide memory free percentage:\s*(\d+)%/.exec(result.stdout);
414
+ return match ? { availablePercent: Number(match[1]) } : undefined;
415
+ }
416
+ async function commandExists(command) {
417
+ for (const directory of ["/usr/bin", "/bin", "/usr/sbin", "/sbin", "/usr/local/bin"]) {
418
+ try {
419
+ await access(`${directory}/${command}`);
420
+ return true;
421
+ }
422
+ catch { /* continue */ }
423
+ }
424
+ return false;
425
+ }
426
+ function hotspotPath(root) {
427
+ return { root: "/", var: "/var", home: "/home", tmp: os.tmpdir(), "user-home": os.homedir() }[root];
428
+ }
429
+ function firstNumber(line) {
430
+ return Number(/^\s*(\d+)/.exec(line)?.[1] ?? 0);
431
+ }
432
+ function numericColumn(line, index) {
433
+ return Number(line.trim().split(/\s+/)[index] ?? 0);
434
+ }
435
+ function serviceSchema() {
436
+ return {
437
+ type: "object",
438
+ required: ["service"],
439
+ properties: { service: { type: "string", minLength: 1, maxLength: 128 } },
440
+ additionalProperties: false,
441
+ };
442
+ }
443
+ function invalidServiceName() {
444
+ return { ok: false, error: { code: "invalid_service_name", message: "Service name contains unsupported characters" } };
445
+ }
446
+ function absolutePathRequired() {
447
+ return { ok: false, error: { code: "absolute_path_required", message: "An absolute host path is required" } };
448
+ }
449
+ function approvalDenied() {
450
+ return { ok: false, error: { code: "approval_denied", message: "The terminal user did not approve this operation" } };
451
+ }
452
+ function safeEnvironment() {
453
+ const result = { PATH: "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", LANG: "C", LC_ALL: "C", SYSTEMD_COLORS: "0" };
454
+ if (process.env.TMPDIR)
455
+ result.TMPDIR = process.env.TMPDIR;
456
+ return result;
457
+ }
458
+ function safeFact(read) {
459
+ try {
460
+ return read();
461
+ }
462
+ catch {
463
+ return null;
464
+ }
465
+ }
466
+ function shellEnvironment() {
467
+ return Object.fromEntries(Object.entries(process.env).filter(([name, value]) => value !== undefined && (name === "SSH_AUTH_SOCK" || !/(KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL|AUTH)/i.test(name))));
468
+ }
469
+ async function canonicalWriteTarget(candidate) {
470
+ try {
471
+ const info = await lstat(candidate);
472
+ if (info.isSymbolicLink())
473
+ throw new Error("Refusing to write through a symbolic link");
474
+ if (!info.isFile())
475
+ throw new Error("Write target exists but is not a regular file");
476
+ return await realpath(candidate);
477
+ }
478
+ catch (error) {
479
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
480
+ throw error;
481
+ const parent = await realpath(path.dirname(candidate));
482
+ return path.join(parent, path.basename(candidate));
483
+ }
484
+ }
485
+ async function overwriteFile(target, content) {
486
+ let handle;
487
+ try {
488
+ handle = await open(target, constants.O_WRONLY | noFollowFlag());
489
+ }
490
+ catch (error) {
491
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
492
+ throw error;
493
+ handle = await open(target, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollowFlag(), 0o600);
494
+ }
495
+ try {
496
+ await handle.truncate(0);
497
+ await handle.writeFile(content, "utf8");
498
+ await handle.sync();
499
+ }
500
+ finally {
501
+ await handle.close();
502
+ }
503
+ }
504
+ function isSensitivePath(candidate) {
505
+ const normalized = candidate.toLowerCase();
506
+ return /(^|\/)(\.ssh|\.aws|\.gnupg|\.kube|\.config\/ops-agent)(\/|$)/.test(normalized)
507
+ || /(^|\/)(\.env(?:\..*)?|\.npmrc|\.netrc|\.git-credentials|credentials?|secrets?|auth\.json|shadow|sudoers)$/.test(normalized)
508
+ || /(^|\/)\.docker\/config\.json$/.test(normalized)
509
+ || /^\/proc\/\d+\/(environ|cmdline)$/.test(normalized);
510
+ }
511
+ function noFollowFlag() {
512
+ return "O_NOFOLLOW" in constants ? constants.O_NOFOLLOW : 0;
513
+ }
514
+ function hasUnsafeControlCharacters(value) {
515
+ return /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f\u001b]/.test(value);
516
+ }
517
+ export const opsTools = [
518
+ systemSnapshotTool,
519
+ filesystemUsageTool,
520
+ diskHotspotsTool,
521
+ processSnapshotTool,
522
+ listeningPortsTool,
523
+ serviceStatusTool,
524
+ recentServiceLogsTool,
525
+ hostReadFileTool,
526
+ hostWriteFileTool,
527
+ bashTool,
528
+ ];
529
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,cAAc,EAAwE,MAAM,uBAAuB,CAAC;AAE7H,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7B,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAwC;IACrE,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,mGAAmG;IAChH,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE;IAC5E,WAAW,EAAE,MAAM;IACnB,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO;QAC3B,MAAM,WAAW,GAAG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AC;AAED,SAAS,YAAY;IACnB,OAAO,YAAY,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa;IAC/C,OAAO,sDAAsD,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAuC;IAC1D,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;IACjB,qBAAqB;IACrB,gBAAgB;IAChB,iBAAiB;IACjB,QAAQ;CACT,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "ops-agent",
3
+ "version": "0.1.0",
4
+ "description": "An AI operations agent for workstation and server diagnostics",
5
+ "type": "module",
6
+ "bin": { "ops-agent": "./dist/cli.js" },
7
+ "exports": {
8
+ ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
9
+ },
10
+ "files": ["dist", "README.md", "LICENSE"],
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.build.json",
13
+ "check": "tsc --noEmit -p tsconfig.json",
14
+ "test": "node --import tsx --test tests/**/*.test.ts",
15
+ "prepack": "npm run build"
16
+ },
17
+ "engines": { "node": ">=22.19.0" },
18
+ "dependencies": { "@chao.song/task-agent": "0.2.0" },
19
+ "keywords": ["agent", "operations", "server", "diagnostics", "devops"],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Jaysong2012/task-agent.git",
23
+ "directory": "packages/ops-agent"
24
+ },
25
+ "license": "MIT",
26
+ "publishConfig": { "access": "public" }
27
+ }