@arnilo/prism-coding-agent 0.0.8 → 0.0.11
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/CHANGELOG.md +37 -6
- package/README.md +22 -7
- package/dist/artifacts.d.ts +6 -0
- package/dist/artifacts.js +35 -0
- package/dist/ask-user-decision.d.ts +160 -0
- package/dist/ask-user-decision.js +471 -0
- package/dist/checks.d.ts +26 -0
- package/dist/checks.js +249 -0
- package/dist/coding-checkpoint.d.ts +159 -0
- package/dist/coding-checkpoint.js +576 -0
- package/dist/git-exec.d.ts +62 -0
- package/dist/git-exec.js +257 -0
- package/dist/git-status.d.ts +30 -0
- package/dist/git-status.js +146 -0
- package/dist/git-tools.d.ts +34 -0
- package/dist/git-tools.js +502 -0
- package/dist/git.d.ts +139 -0
- package/dist/git.js +495 -0
- package/dist/goal-verify.d.ts +66 -0
- package/dist/goal-verify.js +283 -0
- package/dist/index.d.ts +40 -4
- package/dist/index.js +43 -5
- package/dist/limits.d.ts +76 -0
- package/dist/limits.js +81 -0
- package/dist/list.d.ts +14 -0
- package/dist/list.js +144 -0
- package/dist/repository.d.ts +119 -0
- package/dist/repository.js +633 -0
- package/dist/search.d.ts +14 -0
- package/dist/search.js +166 -0
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [Unreleased]
|
|
3
|
+
|
|
4
|
+
## [0.0.11] - 2026-07-22
|
|
5
|
+
|
|
6
|
+
### Docs
|
|
7
|
+
|
|
8
|
+
- Documented ask_user_decision multi/free-text/suspend glue + `runCodingGoalVerify` in `docs/coding-agent-tools.md` / README.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `runCodingGoalVerify` / `createCodingGoalVerifyWorkflow`: thin goal→verify composition over plan Markdown, named checks, workflow suspend/approve, and bounded PR handoff (peer `@arnilo/prism-workflows`). No Goal table / second runtime.
|
|
13
|
+
- Opt-in `createAskUserDecisionTool({ ask })`: model proposes 2+ options with exactly 3 pros + 3 cons each; host `ask` returns `selectedId` / `selectedIds` / `customText`. Supports `selectionMode: "single" | "multiple"` and `allowCustom` (custom XOR selection; default/hard custom bytes match question caps). Not in `createCodingTools` / `createAllTools` / `createReadOnlyTools`.
|
|
14
|
+
- Durable ask-user helpers: `suspendAskUserDecision`, `createAskUserDecisionResumeValidator`, `validateAskUserDecisionResume`, `validateAskUserDecisionAgentResume` (workflow-first; agent path reuses same validator without new `AgentRunInterruption` kinds).
|
|
15
|
+
|
|
16
|
+
## [0.0.10] - 2026-07-21
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Released with exact 0.0.10 graph.
|
|
21
|
+
|
|
22
|
+
### Notes
|
|
23
|
+
|
|
24
|
+
- Sandbox composition / workspace-mode contract lives in `@arnilo/prism-coding-security` (required `workspaceMode`, same-tree Git via `createGitTools(composition.workspaceRoot, { execFile })`). Coding-agent tool surfaces unchanged for 0.0.10.
|
|
25
|
+
|
|
26
|
+
## [0.0.96] - 2026-07-21
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Released with exact 0.0.96 graph.
|
|
31
|
+
|
|
32
|
+
## [0.0.9] - 2026-07-21
|
|
33
|
+
|
|
34
|
+
- Added bounded native `repo_list` / `repo_search` tools with streaming walks, literal/regex search, finite depth/entry/match/scan/time caps, and pluggable `RepositoryOperations`.
|
|
35
|
+
- `createCodingTools()` / `createAllTools()` now include list/search; `createReadOnlyTools()` deliberately expands to `read` + `repo_list` + `repo_search`.
|
|
36
|
+
- Added opt-in structured Git tools via `createGitTools()` / `createGitOperations()`: status (porcelain v2), bounded diff, branch validate/create/switch, worktree add/list/remove, patch check/apply/reverse with rollback, explicit-path commit (host `commitIdentity`), and bounded PR handoff artifacts. Named `coding_check` runs host-declared executables only. Git uses argument arrays with hooks/credential prompts/external diff disabled and never pushes.
|
|
37
|
+
- Added bounded durable coding-plan/checkpoint helpers (`writeCodingPlanFile`, `buildCodingCheckpointMetadata`, `assertCodingResumeAllowed`, `fingerprintJson`) so hosts compose plans/todos/background resume from existing workflow primitives without a second runtime.
|
|
38
|
+
- Added network-free adversarial evaluation fixtures (`eval-fixtures.test.ts`) grading safe native list vs shell, Git injection, dirty-tree rollback, named-check failure, PR-handoff artifacts, and prompt-injection file content via `@arnilo/prism-evals`.
|
|
2
39
|
|
|
3
40
|
## [0.0.8] - 2026-07-20
|
|
4
41
|
|
|
@@ -8,11 +45,6 @@
|
|
|
8
45
|
|
|
9
46
|
- Released with the exact 0.0.7 first-party package graph.
|
|
10
47
|
|
|
11
|
-
All notable changes to this project will be documented in this file.
|
|
12
|
-
|
|
13
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
14
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
15
|
-
|
|
16
48
|
## [0.0.6] - 2026-07-19
|
|
17
49
|
|
|
18
50
|
### Added
|
|
@@ -32,7 +64,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
32
64
|
|
|
33
65
|
- Pinned the required `@arnilo/prism` peer and package metadata to 0.0.5; runtime behavior is unchanged.
|
|
34
66
|
|
|
35
|
-
|
|
36
67
|
## [0.0.4] - 2026-07-14
|
|
37
68
|
|
|
38
69
|
### Added
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @arnilo/prism-coding-agent
|
|
2
2
|
|
|
3
|
-
Optional first-party coding tools package for [Prism](https://www.npmjs.com/package/@arnilo/prism). Provides host shell/filesystem tools — `shell`, `read`, `write`, `edit` — as Prism `ToolDefinition` objects. **Inert until a host imports it and registers the tools into a `ToolRegistry`.**
|
|
3
|
+
Optional first-party coding tools package for [Prism](https://www.npmjs.com/package/@arnilo/prism). Provides host shell/filesystem/repository tools — `shell`, `read`, `write`, `edit`, `repo_list`, `repo_search` — plus opt-in structured Git/check tools via `createGitTools()`, opt-in `createAskUserDecisionTool({ ask })`, and durable plan/checkpoint helpers for workflow composition — as Prism `ToolDefinition` objects. **Inert until a host imports it and registers the tools into a `ToolRegistry`.** No tool is auto-registered; hosts pick factories (or filter aggregator output) and may mix in their own `ToolDefinition`s.
|
|
4
4
|
|
|
5
|
-
Behavior is a behavioral port of the pi coding agent's `bash`/`read`/`write`/`edit` tools, adapted to Prism's `ToolDefinition` / `ToolResult` contracts (no `@earendil-works/*` or `typebox` dependencies).
|
|
5
|
+
Behavior is a behavioral port of the pi coding agent's `bash`/`read`/`write`/`edit` tools, adapted to Prism's `ToolDefinition` / `ToolResult` contracts (no `@earendil-works/*` or `typebox` dependencies). List/search/Git are native Prism tools.
|
|
6
6
|
|
|
7
|
-
> ⚠️ **These tools perform real shell and filesystem operations on the host. They provide no sandbox.** Gate them with Prism `PermissionPolicy` / `ToolValidator` / trust policies before registering them for any provider turn. See the [coding agent tools docs](https://github.com/ashiqrniloy/prism/blob/main/docs/coding-agent-tools.md) and the [host security guide](https://github.com/ashiqrniloy/prism/blob/main/docs/host-security.md).
|
|
7
|
+
> ⚠️ **These tools perform real shell and filesystem operations on the host. They provide no sandbox.** Gate them with Prism `PermissionPolicy` / `ToolValidator` / trust policies before registering them for any provider turn. For disposable sandbox composition with required `workspaceMode`, use `@arnilo/prism-coding-security` (`createSandboxCodingComposition`). See the [coding agent tools docs](https://github.com/ashiqrniloy/prism/blob/main/docs/coding-agent-tools.md) and the [host security guide](https://github.com/ashiqrniloy/prism/blob/main/docs/host-security.md).
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ Behavior is a behavioral port of the pi coding agent's `bash`/`read`/`write`/`ed
|
|
|
12
12
|
npm install @arnilo/prism-coding-agent
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`@arnilo/prism` is a peer dependency.
|
|
15
|
+
`@arnilo/prism` is a peer dependency. `runCodingGoalVerify` also peers `@arnilo/prism-workflows`.
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ Shared `ToolsOptions.executionPolicy` applies to every tool returned by full, al
|
|
|
38
38
|
Individual tools with options:
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import { createShellTool, createWriteTool } from "@arnilo/prism-coding-agent";
|
|
41
|
+
import { createShellTool, createWriteTool, createAskUserDecisionTool } from "@arnilo/prism-coding-agent";
|
|
42
42
|
|
|
43
43
|
const shell = createShellTool(process.cwd(), {
|
|
44
44
|
shellPath: "/bin/bash", // force bash; default: SHELL env → /bin/bash → sh
|
|
@@ -54,6 +54,14 @@ const remoteWrite = createWriteTool(process.cwd(), {
|
|
|
54
54
|
mkdir: async (dir) => { /* mkdir -p remotely */ },
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
// Opt-in: not in createCodingTools(). Host owns the UI.
|
|
59
|
+
const askUser = createAskUserDecisionTool({
|
|
60
|
+
ask: async ({ question, options }) => {
|
|
61
|
+
const selectedId = await host.promptChoice(question, options);
|
|
62
|
+
return { selectedId };
|
|
63
|
+
},
|
|
64
|
+
});
|
|
57
65
|
```
|
|
58
66
|
|
|
59
67
|
## Tools
|
|
@@ -64,6 +72,10 @@ const remoteWrite = createWriteTool(process.cwd(), {
|
|
|
64
72
|
| `read` | `{ path, offset?, limit? }` | Streamed bounded text page or bounded `[note, ImageContent]`. |
|
|
65
73
|
| `write` | `{ path, content }` | Bounded UTF-8 input; `Successfully wrote N bytes (M lines) to <abs>`. |
|
|
66
74
|
| `edit` | `{ path, edits: [{oldText,newText}] }` | Bounded target/input/count; `Successfully replaced N block(s)` + diff metadata. |
|
|
75
|
+
| `repo_list` | `{ path?, includeHidden?, maxDepth?, maxResults?, offset? }` | Deterministic relative entries; skips hidden/excluded basenames; does not follow symlinks; paginates with `nextOffset`. |
|
|
76
|
+
| `repo_search` | `{ query, path?, mode?, caseSensitive?, includeHidden?, context?, maxMatches? }` | Literal (default) or bounded regex matches with context; skips binary/excluded paths; finite scan/match/time caps. |
|
|
77
|
+
| `git_*` / `coding_check` | via `createGitTools(cwd, { commitIdentity, checks? })` | Opt-in structured Git status/diff/branch/worktree/apply/commit/PR-handoff and named checks. Not in `createCodingTools()`. |
|
|
78
|
+
| `ask_user_decision` | via `createAskUserDecisionTool({ ask })` | Opt-in user choice: question + options (3 pros/3 cons); `selectionMode` single\|multiple; `allowCustom` for XOR free-text; host `ask` returns `selectedId` / `selectedIds` / `customText`. Durable: `suspendAskUserDecision` + resume validators. Not in default aggregators. |
|
|
67
79
|
|
|
68
80
|
### pi name mapping
|
|
69
81
|
|
|
@@ -71,17 +83,20 @@ const remoteWrite = createWriteTool(process.cwd(), {
|
|
|
71
83
|
| --- | --- |
|
|
72
84
|
| `shell` | `bash` |
|
|
73
85
|
| `read` / `write` / `edit` | `read` / `write` / `edit` |
|
|
86
|
+
| `repo_list` / `repo_search` | _(native; no pi equivalent shipped)_ |
|
|
74
87
|
|
|
75
88
|
## Exports
|
|
76
89
|
|
|
77
|
-
Factories: `createShellTool`, `createReadTool`, `createWriteTool`, `createEditTool`, `createCodingTools`, `createReadOnlyTools`, `createAllTools`, `createLocalBashOperations`.
|
|
90
|
+
Factories: `createShellTool`, `createReadTool`, `createWriteTool`, `createEditTool`, `createRepoListTool`, `createRepoSearchTool`, `createCodingTools`, `createReadOnlyTools`, `createAllTools`, `createGitTools`, `createCodingCheckTool`, `createAskUserDecisionTool`, `createLocalBashOperations`, `createLocalRepositoryOperations`, `createGitOperations`.
|
|
78
91
|
|
|
79
|
-
Helpers: `detectSupportedImageMimeType`, `detectSupportedImageMimeTypeFromFile`, `getShellConfig`, `killProcessTree`, `waitForChildProcess`, `withFileMutationQueue`. Default/hard coding limit constants are exported for host configuration.
|
|
92
|
+
Helpers: `detectSupportedImageMimeType`, `detectSupportedImageMimeTypeFromFile`, `getShellConfig`, `killProcessTree`, `waitForChildProcess`, `withFileMutationQueue`, `resolveRepositoryLimits`, `writeCodingPlanFile`, `readCodingPlanFile`, `buildCodingCheckpointMetadata`, `validateCodingCheckpointMetadata`, `assertCodingResumeAllowed`, `fingerprintJson`, `runCodingGoalVerify`, `createCodingGoalVerifyWorkflow`, `suspendAskUserDecision`, `createAskUserDecisionResumeValidator`, `validateAskUserDecisionResume`, `validateAskUserDecisionAgentResume`. Default/hard coding, repository, Git, and plan/checkpoint limit constants are exported for host configuration.
|
|
80
93
|
|
|
81
94
|
Option/operation types: `ToolsOptions`, `ShellToolOptions`/`BashOperations`, `ReadToolOptions`/`ReadOperations`/`ReadTextOptions`/`ReadTextResult`, `WriteToolOptions`/`WriteOperations`, `EditToolOptions`/`EditOperations`/`EditToolDetails`.
|
|
82
95
|
|
|
83
96
|
Text reads stop after one page or `maxScanBytes` instead of loading the file. Custom `ReadOperations` must implement bounded `readText` and `statFile`; custom `EditOperations` must implement `statFile` and honor the supplied read cap/signal. Successful truncated shell output is retained in an exclusive Unix `0600` temp file owned by the host; timeout, abort, output-limit, and spill failures remove unpublished spill files. Hosts should delete published `metadata.fullOutputPath` files after use.
|
|
84
97
|
|
|
98
|
+
Network-free adversarial evaluation fixtures live in `src/__tests__/eval-fixtures.test.ts` and reuse `@arnilo/prism-evals` for CI thresholds. See `examples/coding-browser-evaluation.ts` and `docs/evaluations.md`.
|
|
99
|
+
|
|
85
100
|
## License
|
|
86
101
|
|
|
87
102
|
MIT
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArtifactWriter } from "./git.js";
|
|
2
|
+
export declare function sha256Hex(data: Buffer): string;
|
|
3
|
+
/** Write artifacts under a host directory as `file://` URIs with SHA-256 metadata. */
|
|
4
|
+
export declare function createDirectoryArtifactWriter(rootDir: string): ArtifactWriter;
|
|
5
|
+
/** Spill into the process temp directory (tests / ephemeral hosts). */
|
|
6
|
+
export declare function createTempArtifactWriter(prefix?: string): ArtifactWriter;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-owned artifact helpers for Git patch/bundle/PR-handoff spill.
|
|
3
|
+
*
|
|
4
|
+
* Prism never pushes, authenticates to GitHub/GitLab, or opens a PR. Artifacts
|
|
5
|
+
* are written only through an explicit host callback or a bounded temp-file writer.
|
|
6
|
+
*/
|
|
7
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
8
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
export function sha256Hex(data) {
|
|
12
|
+
return createHash("sha256").update(data).digest("hex");
|
|
13
|
+
}
|
|
14
|
+
/** Write artifacts under a host directory as `file://` URIs with SHA-256 metadata. */
|
|
15
|
+
export function createDirectoryArtifactWriter(rootDir) {
|
|
16
|
+
return async ({ kind, filename, bytes }) => {
|
|
17
|
+
const safeName = filename.replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
18
|
+
const dir = join(rootDir, kind);
|
|
19
|
+
await mkdir(dir, { recursive: true });
|
|
20
|
+
const path = join(dir, `${randomBytes(8).toString("hex")}-${safeName}`);
|
|
21
|
+
await writeFile(path, bytes, { mode: 0o600 });
|
|
22
|
+
return {
|
|
23
|
+
kind,
|
|
24
|
+
uri: `file://${path}`,
|
|
25
|
+
sha256: sha256Hex(bytes),
|
|
26
|
+
bytes: bytes.length,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Spill into the process temp directory (tests / ephemeral hosts). */
|
|
31
|
+
export function createTempArtifactWriter(prefix = "prism-git-artifact") {
|
|
32
|
+
const root = join(tmpdir(), `${prefix}-${randomBytes(6).toString("hex")}`);
|
|
33
|
+
return createDirectoryArtifactWriter(root);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in `ask_user_decision` tool: model proposes choices with pros/cons;
|
|
3
|
+
* host-injected `ask` blocks until the user picks one or more option ids.
|
|
4
|
+
*
|
|
5
|
+
* Durable path (opt-in): `suspendAskUserDecision` / `validateAskUserDecisionResume`
|
|
6
|
+
* compose `@arnilo/prism-workflows` suspend/resume — no Goal DB, no second store.
|
|
7
|
+
* Blocking `ask()` remains the default. Agent durable interruption kinds are
|
|
8
|
+
* unchanged; hosts reuse the same resume validator against host-held request data.
|
|
9
|
+
*
|
|
10
|
+
* Not included in `createCodingTools` / `createAllTools` / `createReadOnlyTools`.
|
|
11
|
+
*/
|
|
12
|
+
import type { ExecutionPolicy, JsonObject, ToolDefinition } from "@arnilo/prism";
|
|
13
|
+
import { type WorkflowResumeValidator, type WorkflowSuspension } from "@arnilo/prism-workflows";
|
|
14
|
+
export declare const ASK_USER_DECISION_TOOL_NAME: "ask_user_decision";
|
|
15
|
+
export declare const ASK_USER_DECISION_SUSPEND_REASON: "ask_user_decision";
|
|
16
|
+
/** Exactly three rationale bullets per side. */
|
|
17
|
+
export declare const ASK_USER_DECISION_RATIONALE_COUNT: 3;
|
|
18
|
+
export declare const DEFAULT_MAX_ASK_USER_DECISION_OPTIONS = 6;
|
|
19
|
+
export declare const HARD_MAX_ASK_USER_DECISION_OPTIONS = 16;
|
|
20
|
+
export declare const DEFAULT_MAX_ASK_USER_DECISION_QUESTION_BYTES = 2048;
|
|
21
|
+
export declare const HARD_MAX_ASK_USER_DECISION_QUESTION_BYTES = 8192;
|
|
22
|
+
export declare const DEFAULT_MAX_ASK_USER_DECISION_LABEL_BYTES = 512;
|
|
23
|
+
export declare const HARD_MAX_ASK_USER_DECISION_LABEL_BYTES = 2048;
|
|
24
|
+
export declare const DEFAULT_MAX_ASK_USER_DECISION_BULLET_BYTES = 512;
|
|
25
|
+
export declare const HARD_MAX_ASK_USER_DECISION_BULLET_BYTES = 2048;
|
|
26
|
+
/** Same ceiling as question text — free-text answers stay short. */
|
|
27
|
+
export declare const DEFAULT_MAX_ASK_USER_DECISION_CUSTOM_BYTES = 2048;
|
|
28
|
+
export declare const HARD_MAX_ASK_USER_DECISION_CUSTOM_BYTES = 8192;
|
|
29
|
+
export type AskUserDecisionSelectionMode = "single" | "multiple";
|
|
30
|
+
export interface AskUserDecisionOption {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
readonly label: string;
|
|
33
|
+
readonly pros: readonly [string, string, string];
|
|
34
|
+
readonly cons: readonly [string, string, string];
|
|
35
|
+
}
|
|
36
|
+
export interface AskUserDecisionRequest {
|
|
37
|
+
readonly question: string;
|
|
38
|
+
readonly options: readonly AskUserDecisionOption[];
|
|
39
|
+
readonly selectionMode: AskUserDecisionSelectionMode;
|
|
40
|
+
readonly allowCustom: boolean;
|
|
41
|
+
readonly toolCallId: string;
|
|
42
|
+
readonly sessionId?: string;
|
|
43
|
+
readonly runId?: string;
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Host answer shapes. Custom text is XOR with selection (v1): never both.
|
|
48
|
+
* `allowCustom` must be true for `{ customText }`.
|
|
49
|
+
*/
|
|
50
|
+
export type AskUserDecisionAnswer = {
|
|
51
|
+
readonly selectedId: string;
|
|
52
|
+
readonly selectedIds?: never;
|
|
53
|
+
readonly customText?: never;
|
|
54
|
+
} | {
|
|
55
|
+
readonly selectedIds: readonly string[];
|
|
56
|
+
readonly selectedId?: never;
|
|
57
|
+
readonly customText?: never;
|
|
58
|
+
} | {
|
|
59
|
+
readonly selectedId: string;
|
|
60
|
+
readonly selectedIds: readonly string[];
|
|
61
|
+
readonly customText?: never;
|
|
62
|
+
} | {
|
|
63
|
+
readonly customText: string;
|
|
64
|
+
readonly selectedId?: never;
|
|
65
|
+
readonly selectedIds?: never;
|
|
66
|
+
};
|
|
67
|
+
export type ResolvedAskUserDecisionAnswer = {
|
|
68
|
+
readonly kind: "selection";
|
|
69
|
+
readonly selectedId: string;
|
|
70
|
+
readonly selectedIds: readonly string[];
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "custom";
|
|
73
|
+
readonly customText: string;
|
|
74
|
+
};
|
|
75
|
+
export type AskUserDecisionHandler = (request: AskUserDecisionRequest) => Promise<AskUserDecisionAnswer>;
|
|
76
|
+
export interface AskUserDecisionToolOptions {
|
|
77
|
+
/** Required host UI/callback — tool fails closed without it. */
|
|
78
|
+
readonly ask: AskUserDecisionHandler;
|
|
79
|
+
readonly executionPolicy?: ExecutionPolicy;
|
|
80
|
+
readonly maxOptions?: number;
|
|
81
|
+
readonly maxQuestionBytes?: number;
|
|
82
|
+
readonly maxLabelBytes?: number;
|
|
83
|
+
readonly maxBulletBytes?: number;
|
|
84
|
+
readonly maxCustomTextBytes?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ResolvedAskUserDecisionLimits {
|
|
87
|
+
readonly maxOptions: number;
|
|
88
|
+
readonly maxQuestionBytes: number;
|
|
89
|
+
readonly maxLabelBytes: number;
|
|
90
|
+
readonly maxBulletBytes: number;
|
|
91
|
+
readonly maxCustomTextBytes: number;
|
|
92
|
+
}
|
|
93
|
+
export declare function resolveAskUserDecisionLimits(options?: Pick<AskUserDecisionToolOptions, "maxOptions" | "maxQuestionBytes" | "maxLabelBytes" | "maxBulletBytes" | "maxCustomTextBytes">): ResolvedAskUserDecisionLimits;
|
|
94
|
+
/** Normalize host answer against mode + allowCustom. Exported for tests. */
|
|
95
|
+
export declare function resolveAskUserDecisionAnswer(answer: AskUserDecisionAnswer | null | undefined, selectionMode: AskUserDecisionSelectionMode, options: readonly AskUserDecisionOption[], gates: {
|
|
96
|
+
readonly allowCustom: boolean;
|
|
97
|
+
readonly maxCustomTextBytes: number;
|
|
98
|
+
}): ResolvedAskUserDecisionAnswer;
|
|
99
|
+
/** Parse + validate model args into a bounded decision request. Exported for tests. */
|
|
100
|
+
export declare function parseAskUserDecisionArgs(args: Record<string, unknown>, limits: ResolvedAskUserDecisionLimits): {
|
|
101
|
+
question: string;
|
|
102
|
+
options: AskUserDecisionOption[];
|
|
103
|
+
selectionMode: AskUserDecisionSelectionMode;
|
|
104
|
+
allowCustom: boolean;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Create the opt-in `ask_user_decision` tool.
|
|
108
|
+
* Host must supply `ask`; factory throws if missing.
|
|
109
|
+
*/
|
|
110
|
+
export declare function createAskUserDecisionTool(options: AskUserDecisionToolOptions): ToolDefinition;
|
|
111
|
+
/** Durable decision payload for workflow suspension `data` (no AbortSignal / secrets). */
|
|
112
|
+
export interface AskUserDecisionSuspendData {
|
|
113
|
+
readonly question: string;
|
|
114
|
+
readonly options: readonly AskUserDecisionOption[];
|
|
115
|
+
readonly selectionMode: AskUserDecisionSelectionMode;
|
|
116
|
+
readonly allowCustom: boolean;
|
|
117
|
+
readonly toolCallId?: string;
|
|
118
|
+
readonly sessionId?: string;
|
|
119
|
+
readonly runId?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface SuspendAskUserDecisionOptions {
|
|
122
|
+
readonly reason?: string;
|
|
123
|
+
readonly maxCustomTextBytes?: number;
|
|
124
|
+
}
|
|
125
|
+
/** JSON Schema describing resume `input` (= AskUserDecisionAnswer). */
|
|
126
|
+
export declare function askUserDecisionResumeSchema(request: Pick<AskUserDecisionSuspendData, "selectionMode" | "allowCustom" | "options">): JsonObject;
|
|
127
|
+
export declare function toAskUserDecisionSuspendData(request: {
|
|
128
|
+
readonly question: string;
|
|
129
|
+
readonly options: readonly AskUserDecisionOption[];
|
|
130
|
+
readonly selectionMode: AskUserDecisionSelectionMode;
|
|
131
|
+
readonly allowCustom: boolean;
|
|
132
|
+
readonly toolCallId?: string;
|
|
133
|
+
readonly sessionId?: string;
|
|
134
|
+
readonly runId?: string;
|
|
135
|
+
}): AskUserDecisionSuspendData;
|
|
136
|
+
/**
|
|
137
|
+
* Return from a workflow node to pause for a user decision (opt-in durable path).
|
|
138
|
+
* Host resumes via `resumeWorkflow` + `createAskUserDecisionResumeValidator` / `validateAskUserDecisionResume`.
|
|
139
|
+
*/
|
|
140
|
+
export declare function suspendAskUserDecision(request: AskUserDecisionSuspendData | Pick<AskUserDecisionRequest, "question" | "options" | "selectionMode" | "allowCustom" | "toolCallId" | "sessionId" | "runId">, options?: SuspendAskUserDecisionOptions): WorkflowSuspension<AskUserDecisionAnswer>;
|
|
141
|
+
/**
|
|
142
|
+
* Validate resume input against the original decision request.
|
|
143
|
+
* Shared by workflow `validateResume` and host-held agent resume adapters.
|
|
144
|
+
*/
|
|
145
|
+
export declare function validateAskUserDecisionResume(request: AskUserDecisionSuspendData, value: unknown, limits?: Pick<ResolvedAskUserDecisionLimits, "maxCustomTextBytes">): ResolvedAskUserDecisionAnswer;
|
|
146
|
+
/**
|
|
147
|
+
* Workflow `validateResume` adapter. Reads durable request from `suspension.data`
|
|
148
|
+
* (written by `suspendAskUserDecision`). Deny paths skip answer validation.
|
|
149
|
+
*/
|
|
150
|
+
export declare function createAskUserDecisionResumeValidator(limits?: Pick<ResolvedAskUserDecisionLimits, "maxCustomTextBytes">): WorkflowResumeValidator;
|
|
151
|
+
/**
|
|
152
|
+
* Thin agent-path adapter: same validation as workflow resume, for hosts that
|
|
153
|
+
* persist `AskUserDecisionSuspendData` outside `AgentRunInterruption` (core kinds
|
|
154
|
+
* unchanged in 0.0.11). Call after operator supplies an answer.
|
|
155
|
+
*/
|
|
156
|
+
export declare function validateAskUserDecisionAgentResume(input: {
|
|
157
|
+
readonly request: AskUserDecisionSuspendData;
|
|
158
|
+
readonly answer: unknown;
|
|
159
|
+
readonly maxCustomTextBytes?: number;
|
|
160
|
+
}): ResolvedAskUserDecisionAnswer;
|