@wrongstack/cli 1.1.4 → 1.1.6
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/dist/{acp-MZ5MQBFN.js → acp-CZBSFQB7.js} +6 -5
- package/dist/acp-leader/acp-leader-confirm.d.ts +2 -0
- package/dist/acp-leader/acp-leader-host-binding.d.ts +1 -0
- package/dist/acp-leader/acp-leader-host.d.ts +9 -0
- package/dist/acp-leader/acp-leader-picker.d.ts +6 -3
- package/dist/acp-leader/acp-leader-provider.d.ts +10 -0
- package/dist/acp-leader/acp-leader-skills.d.ts +5 -0
- package/dist/acp-leader/acp-leader-stream.d.ts +9 -0
- package/dist/{auth-IHQS6AFW.js → auth-2ZG5DBHS.js} +4 -4
- package/dist/boot/launch-menu-arrow.d.ts +20 -0
- package/dist/boot/launch-menu-types.d.ts +36 -0
- package/dist/boot/launch-menu.d.ts +1 -57
- package/dist/boot/tui-session-resume-rollback.d.ts +31 -0
- package/dist/{boot-auto-thin-7D4OVEWA.js → boot-auto-thin-N2CIGTXE.js} +3 -3
- package/dist/{chunk-TZPKOS5G.js → chunk-2XQ6SRKG.js} +2 -2
- package/dist/{chunk-3EXRPTAU.js → chunk-5TQ65PXQ.js} +17 -17
- package/dist/{chunk-VAQXOZKP.js → chunk-AJM4EFCM.js} +139 -136
- package/dist/{chunk-C2BBH4S4.js → chunk-E3MJFAFR.js} +2 -2
- package/dist/{chunk-COGI7EQU.js → chunk-EAATL6FL.js} +713 -21
- package/dist/{chunk-AWRZWPJ3.js → chunk-FWUIKCCO.js} +152 -123
- package/dist/{chunk-TAE3EGBM.js → chunk-H5DCQFUI.js} +5 -5
- package/dist/{chunk-BIGSVBPI.js → chunk-KNYIEQAY.js} +64 -61
- package/dist/chunk-LYWOV4OX.js +252 -0
- package/dist/{chunk-75OLD563.js → chunk-M7PSENGF.js} +3 -1
- package/dist/{chunk-I5LJLKA3.js → chunk-MKMM5RIW.js} +12 -5
- package/dist/{chunk-ZF4HRR5F.js → chunk-P7MEEUGT.js} +275 -250
- package/dist/chunk-PGC44T7N.js +255 -0
- package/dist/chunk-QLYPIJ7X.js +258 -0
- package/dist/{chunk-JKTJSLUT.js → chunk-QRWXHGLB.js} +242 -18
- package/dist/chunk-RN5CFAVQ.js +292 -0
- package/dist/{chunk-WDXNBYGD.js → chunk-TDP7CZGE.js} +6 -1
- package/dist/{chunk-6VPWQ4TG.js → chunk-UROB7MK5.js} +2 -1
- package/dist/{chunk-IJLIAPCW.js → chunk-VPSAKGLK.js} +47 -47
- package/dist/{chunk-2LTHDKZX.js → chunk-W7X23HI6.js} +18 -18
- package/dist/{chunk-GKGWPFW2.js → chunk-X4DEQLAZ.js} +1 -1
- package/dist/{cli-context-E44HQ4ZO.js → cli-context-6KS3HV5R.js} +247 -236
- package/dist/{cli-main-OT63I2FX.js → cli-main-NF3YGDME.js} +1779 -1494
- package/dist/cli-main-boot.d.ts +1 -1
- package/dist/config-doctor-known-keys.d.ts +33 -0
- package/dist/config-doctor.d.ts +2 -47
- package/dist/config-history-support.d.ts +36 -0
- package/dist/config-history.d.ts +1 -1
- package/dist/{config-transfer-Y7XJMJRN.js → config-transfer-B4GOZTFC.js} +2 -2
- package/dist/{execution-OK34CJKJ.js → execution-RVDUXLNT.js} +6522 -6426
- package/dist/execution-tui.d.ts +30 -0
- package/dist/fleet/acp-wrongstack-bridge.d.ts +11 -3
- package/dist/fleet/host-acp.d.ts +3 -0
- package/dist/fleet/wrongforge-client.d.ts +116 -0
- package/dist/fleet/wrongforge-gateway.d.ts +20 -0
- package/dist/fleet/wrongforge-info.d.ts +32 -0
- package/dist/fleet/wrongforge-quota.d.ts +10 -0
- package/dist/fleet/wrongforge-runner.d.ts +37 -0
- package/dist/fleet/wrongforge-runtime.d.ts +10 -0
- package/dist/{hq-JD5AZVMG.js → hq-V2M4IYCI.js} +320 -306
- package/dist/hq-server/login-attempt-store.d.ts +2 -0
- package/dist/hq-server/sweeps.d.ts +28 -0
- package/dist/{hq-server-BI23EPM7.js → hq-server-QM7EIVGJ.js} +3 -3
- package/dist/index.js +5 -5
- package/dist/mcp-22CFBX4H.js +236 -0
- package/dist/mcp-serve.d.ts +0 -63
- package/dist/{modeldiag-HDIKG37X.js → modeldiag-5PBB777J.js} +4 -4
- package/dist/{per-subcommand-help-4GYSCMLU.js → per-subcommand-help-MQGERD4E.js} +2 -2
- package/dist/plugin-llm-command.d.ts +9 -0
- package/dist/{plugin-usage-TYF5HY4K.js → plugin-usage-UWKYMNQU.js} +3 -3
- package/dist/{plugins-XGAXDLPT.js → plugins-VP7JQH47.js} +4 -4
- package/dist/{sdd-runtime-6MFUXWJK.js → sdd-runtime-HIJ4Z5TF.js} +2 -2
- package/dist/services/sdd/state.d.ts +2 -0
- package/dist/session-event-wiring-types.d.ts +62 -0
- package/dist/session-event-wiring.d.ts +2 -52
- package/dist/{sessions-config-SJVQXCIE.js → sessions-config-7MK742OW.js} +2 -2
- package/dist/short-circuit-flags-276OLPIN.js +11 -0
- package/dist/slash-commands/command-context-fleet.d.ts +187 -0
- package/dist/slash-commands/command-context-sdd-goal.d.ts +102 -0
- package/dist/slash-commands/command-context.d.ts +3 -282
- package/dist/slash-commands/project-switch-interactive.d.ts +11 -0
- package/dist/slash-commands/setmodel-helpers.d.ts +36 -0
- package/dist/subcommands/handlers/hq-token.d.ts +3 -0
- package/dist/subcommands/handlers/hq.d.ts +0 -21
- package/dist/subcommands/handlers/per-subcommand-help-operations.d.ts +8 -0
- package/dist/subcommands/handlers/tools-cli-args.d.ts +57 -0
- package/dist/subcommands/handlers/tools-cli.d.ts +5 -0
- package/dist/subcommands/handlers/tools-serve.d.ts +4 -0
- package/dist/{subcommands-YADUV7IJ.js → subcommands-SKJPUJ7N.js} +2 -2
- package/dist/tool-gateway-http.d.ts +30 -0
- package/dist/tool-gateway.d.ts +185 -0
- package/dist/tools-cli-44MLIUQO.js +509 -0
- package/dist/tools-serve-TRCET2M7.js +102 -0
- package/dist/{tools-skills-55QVTMSK.js → tools-skills-WDTMCE46.js} +7 -2
- package/dist/tuneup-runtime-checks.d.ts +7 -0
- package/dist/tuneup-types.d.ts +118 -0
- package/dist/tuneup.d.ts +3 -122
- package/dist/{typesafe-YBEADNAH.js → typesafe-QLSMFU7J.js} +1 -1
- package/dist/{version-help-RBZC5GZZ.js → version-help-X6CC4CFY.js} +2 -2
- package/dist/{webui-server-CB64CFDG.js → webui-server-6I6QOECV.js} +44 -6
- package/dist/wiring/provider-runtime-setup.d.ts +3 -1
- package/dist/wiring/session-runtime.d.ts +1 -1
- package/dist/wrongforge-gateway-UOFBK56J.js +92 -0
- package/dist/wrongforge-leader/wrongforge-leader-gateway.d.ts +9 -0
- package/dist/wrongforge-leader/wrongforge-leader-picker.d.ts +12 -0
- package/dist/wrongforge-leader/wrongforge-leader-provider.d.ts +56 -0
- package/package.json +1 -1
- package/dist/mcp-W7A5HUXV.js +0 -560
- package/dist/short-circuit-flags-QEXUS3BY.js +0 -11
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `wstack hq` subcommand group — HQ command center lifecycle + browser
|
|
3
|
-
* token management.
|
|
4
|
-
*
|
|
5
|
-
* Subcommand tree:
|
|
6
|
-
* wstack hq → start HQ server (alias for `wstack --hq`)
|
|
7
|
-
* wstack hq serve → start HQ server (explicit form)
|
|
8
|
-
* wstack hq token create [label] [--ttl <duration>] → mint a browser token, write auth.json
|
|
9
|
-
* wstack hq token create --client [label] [--ttl <duration>] → mint a client token (/ws/client)
|
|
10
|
-
* wstack hq token list → list issued browser tokens
|
|
11
|
-
* wstack hq token list --client → list issued client tokens
|
|
12
|
-
* wstack hq token revoke <id> → revoke a browser token (prefix match)
|
|
13
|
-
* wstack hq token revoke --client <id> → revoke a client token
|
|
14
|
-
* wstack hq service install|status|update|uninstall → Ubuntu systemd lifecycle
|
|
15
|
-
*
|
|
16
|
-
* All subcommands accept `--data-dir <path>` to override the HQ data
|
|
17
|
-
* directory (default `~/.wrongstack/hq`, honors `WRONGSTACK_HOME` /
|
|
18
|
-
* `WRONGSTACK_HQ_DATA_DIR`).
|
|
19
|
-
*
|
|
20
|
-
* @module subcommands/handlers/hq
|
|
21
|
-
*/
|
|
22
1
|
import type { SubcommandHandler } from '../contracts.js';
|
|
23
2
|
export declare const hqCmd: SubcommandHandler;
|
|
24
3
|
//# sourceMappingURL=hq.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PerSubcommandHelp } from './per-subcommand-help-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Focused help for the lifecycle, integration and operations subcommands
|
|
4
|
+
* (update, remote, acp, bench, hq, mailbox, permissions, project, sage,
|
|
5
|
+
* chronicle, …) — spread into `helpTable` after the core commands.
|
|
6
|
+
*/
|
|
7
|
+
export declare const OPERATIONS_HELP_ENTRIES: Record<string, PerSubcommandHelp>;
|
|
8
|
+
//# sourceMappingURL=per-subcommand-help-operations.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { JSONSchema } from '@wrongstack/core/types';
|
|
2
|
+
export declare class ToolsCliUsageError extends Error {
|
|
3
|
+
}
|
|
4
|
+
/** Where `wstack tools` writes and reads — injectable for tests. */
|
|
5
|
+
export interface ToolsCliIo {
|
|
6
|
+
stdout(text: string): void;
|
|
7
|
+
stderr(text: string): void;
|
|
8
|
+
readStdin(): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
/** Upper bound for `--input` from stdin or `@file` — tool calls, not a payload upload. */
|
|
11
|
+
export declare const TOOLS_CLI_MAX_INPUT_BYTES: number;
|
|
12
|
+
/**
|
|
13
|
+
* Raw text behind `--input`: absent → undefined; a bare `--input` or
|
|
14
|
+
* `--input=-` → stdin (`--input -` parses as bare: the top-level parser never
|
|
15
|
+
* takes a dash-led token as a value); `@path` → file relative to cwd; anything
|
|
16
|
+
* else → the value itself. A leading BOM (editors, `Out-File`) is dropped.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readInputText(raw: string | boolean | undefined, cwd: string, readStdin: () => Promise<string>): Promise<{
|
|
19
|
+
text: string;
|
|
20
|
+
source: string;
|
|
21
|
+
} | undefined>;
|
|
22
|
+
/** A tool input must be a JSON object; blank text is `{}`. */
|
|
23
|
+
export declare function parseInputObject(text: string, source: string): Record<string, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* `wstack tools run grep -- --pattern foo --path src --context 2`: map the
|
|
26
|
+
* tokens after `--` onto the tool's input schema.
|
|
27
|
+
*
|
|
28
|
+
* Only after `--`: before it, the top-level parser owns every `--flag`, and a
|
|
29
|
+
* field that shares a name with a global switch (`--json`, `--yolo`, `--all`)
|
|
30
|
+
* would be read as that switch. Values are coerced by the property's declared
|
|
31
|
+
* type — string, integer/number, boolean (`--flag`, `--no-flag`,
|
|
32
|
+
* `--flag=false`), array (repeat the flag, or pass a JSON array), object (JSON).
|
|
33
|
+
* Enums, ranges and required fields are left to the executor's schema
|
|
34
|
+
* validation, which reports them as invalid input.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseSchemaArgs(tokens: readonly string[], schema: JSONSchema | undefined): Record<string, unknown>;
|
|
37
|
+
export interface BatchCall {
|
|
38
|
+
/** 1-based line number in the batch input. */
|
|
39
|
+
line: number;
|
|
40
|
+
id?: unknown;
|
|
41
|
+
tool: string;
|
|
42
|
+
input: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
export type BatchLine = BatchCall | {
|
|
45
|
+
line: number;
|
|
46
|
+
id?: unknown;
|
|
47
|
+
error: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* JSONL batch: one `{"tool": "...", "input": {...}, "id"?: any}` per line.
|
|
51
|
+
* Blank lines are skipped. A malformed line becomes an error entry rather than
|
|
52
|
+
* aborting the batch, so every other call still reports; only exceeding
|
|
53
|
+
* {@link TOOLS_CLI_MAX_BATCH_CALLS} rejects the batch as a whole.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseBatchLines(text: string): BatchLine[];
|
|
56
|
+
export declare function readStream(stream: NodeJS.ReadableStream, maxBytes: number): Promise<string>;
|
|
57
|
+
//# sourceMappingURL=tools-cli-args.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SubcommandDeps } from '../contracts.js';
|
|
2
|
+
import { type ToolsCliIo } from './tools-cli-args.js';
|
|
3
|
+
export type { ToolsCliIo } from './tools-cli-args.js';
|
|
4
|
+
export declare function runToolsCli(verb: string, args: readonly string[], deps: SubcommandDeps, io?: ToolsCliIo): Promise<number>;
|
|
5
|
+
//# sourceMappingURL=tools-cli.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SubcommandDeps } from '../contracts.js';
|
|
2
|
+
import type { ToolsCliIo } from './tools-cli-args.js';
|
|
3
|
+
export declare function serveToolsCommand(args: readonly string[], deps: SubcommandDeps, io: ToolsCliIo, waitForShutdown?: () => Promise<void>): Promise<number>;
|
|
4
|
+
//# sourceMappingURL=tools-serve.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
subcommandNames,
|
|
3
3
|
subcommands
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-W7X23HI6.js";
|
|
5
5
|
import "./chunk-W23PY4IJ.js";
|
|
6
6
|
export {
|
|
7
7
|
subcommandNames,
|
|
8
8
|
subcommands
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=subcommands-
|
|
10
|
+
//# sourceMappingURL=subcommands-SKJPUJ7N.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ToolRegistry } from '@wrongstack/core/registry';
|
|
2
|
+
import { type ToolGateway } from './tool-gateway.js';
|
|
3
|
+
export interface ToolGatewayHttpOptions {
|
|
4
|
+
gateway: ToolGateway;
|
|
5
|
+
/** For `withheldReason` on tools the gateway does not expose. */
|
|
6
|
+
registry: ToolRegistry;
|
|
7
|
+
/** Required. Every route but `/health` checks `Authorization: Bearer <token>`. */
|
|
8
|
+
token: string;
|
|
9
|
+
/** TCP port; 0 picks a free one. */
|
|
10
|
+
port?: number | undefined;
|
|
11
|
+
/** Default 127.0.0.1. */
|
|
12
|
+
host?: string | undefined;
|
|
13
|
+
/** Allow `callback.url` to name a non-loopback host. Default false. */
|
|
14
|
+
allowRemoteCallbacks?: boolean | undefined;
|
|
15
|
+
maxConcurrentCalls?: number | undefined;
|
|
16
|
+
/** Do not keep the process alive for this server (an in-process side service). */
|
|
17
|
+
unref?: boolean | undefined;
|
|
18
|
+
log?: ((message: string) => void) | undefined;
|
|
19
|
+
/** Injectable for tests. */
|
|
20
|
+
fetchImpl?: typeof fetch | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface ToolGatewayHttpHandle {
|
|
23
|
+
url: string;
|
|
24
|
+
port: number;
|
|
25
|
+
host: string;
|
|
26
|
+
/** Resolves once every accepted async call has settled and its callback was attempted. */
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export declare function serveToolGatewayHttp(opts: ToolGatewayHttpOptions): Promise<ToolGatewayHttpHandle>;
|
|
30
|
+
//# sourceMappingURL=tool-gateway-http.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool gateway — the one execution core behind every surface that lets an
|
|
3
|
+
* EXTERNAL caller drive WrongStack's built-in tools without an agent loop.
|
|
4
|
+
*
|
|
5
|
+
* Two adapters sit on top of it today:
|
|
6
|
+
* - `wstack mcp serve` — MCP over stdio/HTTP (`mcp-serve.ts`)
|
|
7
|
+
* - `wstack tools run` — one call per process (`subcommands/handlers/tools-cli.ts`)
|
|
8
|
+
*
|
|
9
|
+
* Both used to need the same subtle decisions — which tools are exposed, which
|
|
10
|
+
* permission policy applies, whether file tools are confined to the project
|
|
11
|
+
* root, and that every call gets a fresh Context. Keeping those in one place is
|
|
12
|
+
* the point: a second hand-written copy is how a surface quietly ends up with a
|
|
13
|
+
* wider default than the other.
|
|
14
|
+
*/
|
|
15
|
+
import { Context } from '@wrongstack/core/agent';
|
|
16
|
+
import { ToolRegistry } from '@wrongstack/core/registry';
|
|
17
|
+
import { AutoApprovePermissionPolicy } from '@wrongstack/core/security';
|
|
18
|
+
import type { Config, PermissionPolicy, Tool, ToolSettlement, ToolsConfig } from '@wrongstack/core/types';
|
|
19
|
+
/**
|
|
20
|
+
* The registry a gateway serves: the subcommand's pre-populated one when the
|
|
21
|
+
* dispatcher built it, else a fresh built-in tier. Also binds the Kanban ports
|
|
22
|
+
* the `kanban` tool resolves at call time.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveGatewayRegistry(existing: ToolRegistry | undefined, config: Pick<Config, 'features'>): ToolRegistry;
|
|
25
|
+
/**
|
|
26
|
+
* Parse `--allow fs.write,shell.exec` into capability ids. Every entry must be
|
|
27
|
+
* a known capability — a typo silently granting nothing would read as "the
|
|
28
|
+
* tool is broken", and a typo that matched something unintended would widen
|
|
29
|
+
* the grant. A bare `--allow` (no list) is an error, never "allow everything".
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseCapabilityGrants(raw: string | boolean | undefined): string[];
|
|
32
|
+
/**
|
|
33
|
+
* `--yolo` for the gateway: widen the CAPABILITY allowlist, keep every guard.
|
|
34
|
+
*
|
|
35
|
+
* This replaced an `AllowAllPermissionPolicy extends AutoApprovePermissionPolicy`
|
|
36
|
+
* whose `evaluate()` returned `{ permission: 'auto' }` unconditionally. That
|
|
37
|
+
* override skipped the whole base implementation — the sensitive-read denial,
|
|
38
|
+
* the leader deny rules, the destructive-command classifier, the agent-state
|
|
39
|
+
* write guard, and `LOCKED_DESTRUCTIVE_KINDS`. It was the only place in the
|
|
40
|
+
* codebase where `agent-state` and `credential-bind` could be un-gated, so a
|
|
41
|
+
* third-party MCP client could have written `hooks` into config.json (boot-time
|
|
42
|
+
* RCE) or `auto: true` into trust.json.
|
|
43
|
+
*
|
|
44
|
+
* It did not actually get there — but only by accident, and the accident is the
|
|
45
|
+
* reason this is a rewrite rather than a patch. The override returned
|
|
46
|
+
* `source: 'default'` where the base class returns `source: 'yolo'`, so
|
|
47
|
+
* `ToolExecutor.capabilityDowngraded` re-armed and forced `confirm`; the gateway
|
|
48
|
+
* has no confirmAwaiter, so the call hard-errored. Changing that one string
|
|
49
|
+
* literal to `'yolo'` — which reads as a trivial consistency cleanup — would
|
|
50
|
+
* have made the bypass live. Safety must not rest on a string nobody knows is
|
|
51
|
+
* load-bearing.
|
|
52
|
+
*
|
|
53
|
+
* Granting every capability is what `--yolo` actually means, and it is what
|
|
54
|
+
* lets `ToolExecutor` trust an `auto` instead of downgrading it (see the
|
|
55
|
+
* `dangerousNotAllowed` reasoning in `auto-approve-policy.ts`). The destructive
|
|
56
|
+
* classifier is deliberately NOT relaxed: `yoloConfirmKinds` is left at its
|
|
57
|
+
* default, which gates every destructive kind. Destructive calls therefore
|
|
58
|
+
* still require a confirmation this surface cannot answer, exactly as before —
|
|
59
|
+
* this change removes a latent bypass without widening anything.
|
|
60
|
+
*/
|
|
61
|
+
export declare function yoloServePolicy(yoloPlus?: () => boolean): AutoApprovePermissionPolicy;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the file tools are confined to the project root for the gateway.
|
|
64
|
+
*
|
|
65
|
+
* The gateway is the one surface where the file tools are driven by a REMOTE
|
|
66
|
+
* caller, so an unset config must inherit containment rather than invert it —
|
|
67
|
+
* an unset value here previously became `false`, which short-circuited
|
|
68
|
+
* `ensureInsideRoot` and let `tools/call read` return `~/.ssh/id_rsa`.
|
|
69
|
+
*
|
|
70
|
+
* This lives in one exported function rather than as a literal repeated at each
|
|
71
|
+
* call site so the invariant is testable and a third call site cannot quietly
|
|
72
|
+
* reintroduce the wrong default. Only a trusted user config can opt out:
|
|
73
|
+
* `tools.restrictToProjectRoot` is on the in-project denylist, so a
|
|
74
|
+
* checked-out repository cannot reach it.
|
|
75
|
+
*/
|
|
76
|
+
export declare function resolveServeFsRestriction(config: {
|
|
77
|
+
tools?: {
|
|
78
|
+
restrictToProjectRoot?: boolean | undefined;
|
|
79
|
+
} | undefined;
|
|
80
|
+
}): boolean;
|
|
81
|
+
/** Minimal run context — tools read cwd/projectRoot/signal; provider/session are stubs. */
|
|
82
|
+
export declare function makeServeContext(cwd: string, projectRoot: string, signal: AbortSignal, restrictFsToRoot?: boolean): Context;
|
|
83
|
+
/**
|
|
84
|
+
* Compute the set of tools a gateway exposes: a tool is included only if it
|
|
85
|
+
* passes the whitelist (when set) AND the permission policy returns `auto`.
|
|
86
|
+
* With `AutoApprovePermissionPolicy` this withholds shell/write/edit and
|
|
87
|
+
* dangerous-capability tools; with the `--yolo` policy everything passes.
|
|
88
|
+
*/
|
|
89
|
+
export declare function selectExposedTools(registry: ToolRegistry, ctx: Context, policy: PermissionPolicy, whitelist: Set<string> | null): Promise<Tool[]>;
|
|
90
|
+
/** Whether a one-shot call to this tool first catches the index up with the disk. */
|
|
91
|
+
export declare function readsCodebaseIndex(name: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Why `name` is not callable through `gateway`, in words a caller can act on —
|
|
94
|
+
* one text for every surface (`wstack tools run`, `wstack tools serve`), since
|
|
95
|
+
* the flags it names are the same on both.
|
|
96
|
+
*/
|
|
97
|
+
export declare function withheldReason(gateway: ToolGateway, registry: ToolRegistry, name: string): string;
|
|
98
|
+
export interface ToolGatewayOptions {
|
|
99
|
+
registry: ToolRegistry;
|
|
100
|
+
/** Only the `tools.*` knobs the gateway reads. */
|
|
101
|
+
config: {
|
|
102
|
+
tools?: Partial<Pick<ToolsConfig, 'restrictToProjectRoot' | 'maxToolTimeoutMs' | 'kanbanGovernance'>> | undefined;
|
|
103
|
+
};
|
|
104
|
+
cwd: string;
|
|
105
|
+
projectRoot: string;
|
|
106
|
+
/** Grant every capability; the subagent locks still refuse. */
|
|
107
|
+
yolo: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Under `yolo`: whether the user's YOLO+ is on right now (destructive kinds
|
|
110
|
+
* then pass; the locked ones never do). An in-process worker gateway reads
|
|
111
|
+
* the live config; the CLI surfaces leave it unset.
|
|
112
|
+
*/
|
|
113
|
+
yoloPlus?: (() => boolean) | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Capabilities granted on top of the read-only default (`--allow`), each
|
|
116
|
+
* validated by {@link parseCapabilityGrants}. Ignored under `yolo`.
|
|
117
|
+
*/
|
|
118
|
+
allow?: readonly string[] | undefined;
|
|
119
|
+
/** Restrict to these names; null exposes everything the policy allows. */
|
|
120
|
+
whitelist: Set<string> | null;
|
|
121
|
+
/**
|
|
122
|
+
* Each call is its own process (`wstack tools run`): also withhold tools
|
|
123
|
+
* whose state lives in a session or in the serving process
|
|
124
|
+
* ({@link oneShotWithholdReason}).
|
|
125
|
+
*/
|
|
126
|
+
oneShot?: boolean | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* A long-lived server whose caller edits the tree with its own tools
|
|
129
|
+
* (`wstack tools serve`, called by an external agent): withhold the
|
|
130
|
+
* session-bound tools (process-bound ones work in a long-lived process), and
|
|
131
|
+
* catch the index up before EVERY index-reading call — the caller's edits
|
|
132
|
+
* are invisible to WrongStack, so "once per process" would go stale.
|
|
133
|
+
* Concurrent calls share one catch-up; at most one starts per second.
|
|
134
|
+
*/
|
|
135
|
+
remoteAgent?: boolean | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* One-shot / remote-agent: bring the index up to date with the disk before an
|
|
138
|
+
* index-reading call ({@link readsCodebaseIndex}) — once per process, and
|
|
139
|
+
* again after any mutating call. Incremental by mtime (~0.3s on an
|
|
140
|
+
* unchanged 11k-file repo). Defaults to the real catch-up; injectable for tests.
|
|
141
|
+
*/
|
|
142
|
+
catchUpIndex?: ((projectRoot: string, signal: AbortSignal) => Promise<void>) | undefined;
|
|
143
|
+
/** Non-fatal problems (a failed index catch-up) for the caller to surface. */
|
|
144
|
+
onWarning?: ((message: string) => void) | undefined;
|
|
145
|
+
}
|
|
146
|
+
export type ToolGatewayCallResult = {
|
|
147
|
+
kind: 'result';
|
|
148
|
+
content: string;
|
|
149
|
+
isError: boolean;
|
|
150
|
+
settlement: ToolSettlement;
|
|
151
|
+
durationMs: number;
|
|
152
|
+
}
|
|
153
|
+
/** Not in the exposed set — withheld by policy/whitelist, or unknown. */
|
|
154
|
+
| {
|
|
155
|
+
kind: 'not_exposed';
|
|
156
|
+
}
|
|
157
|
+
/** The call needs an interactive confirmation the gateway cannot give. */
|
|
158
|
+
| {
|
|
159
|
+
kind: 'confirm_required';
|
|
160
|
+
};
|
|
161
|
+
export interface ToolGateway {
|
|
162
|
+
/** `safe` = read-only default, `granted` = default plus `--allow`, `yolo` = everything. */
|
|
163
|
+
readonly mode: 'safe' | 'granted' | 'yolo';
|
|
164
|
+
/** The capability allowlist the policy evaluates against. */
|
|
165
|
+
readonly capabilities: readonly string[];
|
|
166
|
+
/** The root the file tools are confined to; per-call `cwd` must lie inside it. */
|
|
167
|
+
readonly projectRoot: string;
|
|
168
|
+
/** Exposed tools, in registry order. `list` and `call` always agree. */
|
|
169
|
+
readonly tools: readonly Tool[];
|
|
170
|
+
get(name: string): Tool | undefined;
|
|
171
|
+
/** Whether this surface withholds `name` for living in a session / the serving process. */
|
|
172
|
+
withheldBy(name: string): 'session' | 'process' | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* `options.cwd`: this call's working directory (relative paths, shell
|
|
175
|
+
* commands). The caller validates it against {@link projectRoot}; the
|
|
176
|
+
* file tools stay confined to the root either way.
|
|
177
|
+
*/
|
|
178
|
+
call(name: string, input: Record<string, unknown>, options?: {
|
|
179
|
+
cwd?: string | undefined;
|
|
180
|
+
}): Promise<ToolGatewayCallResult>;
|
|
181
|
+
/** Abort in-flight calls and disconnect from the project daemons. */
|
|
182
|
+
close(): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
export declare function createToolGateway(options: ToolGatewayOptions): Promise<ToolGateway>;
|
|
185
|
+
//# sourceMappingURL=tool-gateway.d.ts.map
|