aptly 0.1.3 → 0.1.5
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/README.en.md +14 -7
- package/README.ja.md +14 -7
- package/README.md +14 -7
- package/README.zh-CN.md +14 -7
- package/dist/src/automatic-hook.d.ts +56 -2
- package/dist/src/automatic-hook.js +157 -26
- package/dist/src/context-retry.d.ts +15 -0
- package/dist/src/context-retry.js +134 -0
- package/dist/src/hook.d.ts +7 -2
- package/dist/src/hook.js +32 -14
- package/dist/src/routing-observations.d.ts +90 -0
- package/dist/src/routing-observations.js +61 -0
- package/dist/src/server.js +61 -7
- package/dist/src/spawn-context.d.ts +15 -0
- package/dist/src/spawn-context.js +65 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/docs/SPAWN_CONTEXT.md +326 -0
- package/docs/guide/en.md +38 -9
- package/docs/guide/ja.md +38 -9
- package/docs/guide/ko.md +38 -9
- package/docs/guide/zh-CN.md +38 -9
- package/examples/spawn-preflight.codex.json +30 -0
- package/package.json +2 -1
package/README.en.md
CHANGED
|
@@ -20,37 +20,44 @@ Our own tests showed **about 52–58% lower API-equivalent costs**. See the [tes
|
|
|
20
20
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
23
|
-
Requires Node.js **24 or later** and Claude Code or Codex.
|
|
23
|
+
Requires Node.js **24 or later** and Claude Code or Codex. For first-time installation, install and configure the latest stable version globally with these commands.
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
npm install -g aptly@latest --allow-scripts=aptly
|
|
27
27
|
aptly setup --client all --mode defaults
|
|
28
|
+
aptly set env OPENAI_API_KEY
|
|
28
29
|
aptly --version
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
Check the installed version with `aptly --version`. On supported npm versions, `--allow-scripts=aptly` allows Aptly’s installation script. If your npm does not support this option, follow the explicit installation and setup steps in the [installation guide](docs/guide/en.md#installation).
|
|
32
33
|
|
|
33
|
-
Before upgrading, stop all related host, MCP, and CLI processes and review the ledger transition in the [installation and upgrade guide](docs/guide/en.md#installation).
|
|
34
|
-
|
|
35
34
|
During installation, `postinstall` registers the MCP server and a `PreToolUse` Hook in existing host configuration directories. Run `setup` explicitly if automatic registration was skipped or a host has no configuration directory yet. Other settings and Hooks, and any existing Aptly launch command and environment, are preserved.
|
|
36
35
|
|
|
37
36
|
Store the classification key, `OPENAI_API_KEY`, in the OS credential store using the hidden prompt in `aptly set env OPENAI_API_KEY`, or pass it to the MCP process through a secure execution environment. Do not put it in command arguments, requests, configuration JSON, or the repository. Restart the host or MCP server, then **review and trust the new Hook through `/hooks` in Codex**. See [installation, keys, and registration](docs/guide/en.md#installation).
|
|
38
37
|
|
|
38
|
+
## Update
|
|
39
|
+
|
|
40
|
+
To update an existing global npm installation running Aptly 0.1.3 or later, stop all related host, MCP, and CLI writers and review ledger migration and the manual fallback in the [installation and upgrade guide](docs/guide/en.md#installation). Existing key settings are preserved, so there is no need to re-enter the key. Restart afterward.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
aptly update
|
|
44
|
+
aptly setup --client all --mode defaults
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
## Usage modes
|
|
40
48
|
|
|
41
49
|
| Mode | Behavior |
|
|
42
50
|
|---|---|
|
|
43
|
-
| Automatic Hook |
|
|
51
|
+
| Automatic Hook | Checks constraints and recommends unspecified defaults for new calls |
|
|
44
52
|
| Direct recommendation | Returns a profile through `recommend_agent` or `aptly recommend`; review it and decide separately whether to run it in the host |
|
|
45
53
|
| fixture | Tests recommendations generated by local rules without a key or network access; these are not actual Decisions results |
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
From Aptly 0.1.4, inherited calls also reach recommendation. Application still requires explicit `fork_turns: "none"` in Codex or a general-purpose Claude Code call without history constraints; specified fields are preserved. Recommendation, Hook argument updates and child execution are separate facts. See the [guide](docs/guide/en.md#automatic-hook) for application conditions.
|
|
48
56
|
|
|
49
57
|
## Documentation
|
|
50
58
|
|
|
51
|
-
- [CLI configuration](docs/guide/en.md#configure-with-the-cli)
|
|
52
59
|
- [User guide](docs/guide/en.md): installation and removal, keys, Hooks, direct recommendations, and error recovery
|
|
53
|
-
- [Installation and removal](docs/guide/en.md#installation): global npm installation, host registration, restarting, and trust review
|
|
60
|
+
- [Installation and removal](docs/guide/en.md#installation) and [CLI configuration](docs/guide/en.md#configure-with-the-cli): global npm installation, host registration, restarting, and trust review
|
|
54
61
|
- [Models and environment variables](docs/guide/en.md#models-and-environment-variables): six default profiles and candidate configuration
|
|
55
62
|
- [Providing context](docs/guide/en.md#providing-context): encrypted messages and repository URL limitations
|
|
56
63
|
- [Cost benchmark](docs/guide/en.md#cost-benchmark): tokens, converted costs, and measurement scope for a README translation review
|
package/README.ja.md
CHANGED
|
@@ -20,37 +20,44 @@ Aptly は必要最小限のタスク要約を OpenAI Decisions API で分類し
|
|
|
20
20
|
|
|
21
21
|
## クイックスタート
|
|
22
22
|
|
|
23
|
-
Node.js **24 以上**と Claude Code または Codex
|
|
23
|
+
Node.js **24 以上**と Claude Code または Codex が必要です。初めてインストールする場合は、以下のコマンドで最新の安定版をグローバルにインストールして設定してください。
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
npm install -g aptly@latest --allow-scripts=aptly
|
|
27
27
|
aptly setup --client all --mode defaults
|
|
28
|
+
aptly set env OPENAI_API_KEY
|
|
28
29
|
aptly --version
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
`aptly --version` でインストール済みのバージョンを確認してください。対応する npm では、`--allow-scripts=aptly` で Aptly のインストールスクリプトを許可します。このオプションに対応していない npm では、[インストール案内](docs/guide/ja.md#インストール)の明示的なインストール・設定手順に従ってください。
|
|
32
33
|
|
|
33
|
-
アップグレード前に、関連するホスト・MCP・CLI の全プロセスを停止し、[インストールとアップグレードの案内](docs/guide/ja.md#インストール)で台帳の移行手順を確認してください。
|
|
34
|
-
|
|
35
34
|
インストール時の `postinstall` は、既存のホスト設定ディレクトリに MCP と `PreToolUse` Hook を登録します。自動登録をスキップした場合や、ホストに設定ディレクトリがまだない場合も、`setup` を明示的に実行して登録できます。他の既存設定・Hook と、既存の Aptly の実行コマンド・環境は保持します。
|
|
36
35
|
|
|
37
36
|
分類用の `OPENAI_API_KEY` は、`aptly set env OPENAI_API_KEY` の非表示入力で OS の資格情報ストアに保存するか、安全な実行環境から MCP プロセスに渡してください。キーをコマンドライン・リクエスト・設定 JSON・リポジトリに記載しないでください。ホストまたは MCP を再起動した後、**Codex では `/hooks` で新しい Hook を確認し、信頼を承認**してください。[インストール・キー・登録の詳細](docs/guide/ja.md#インストール)を確認してください。
|
|
38
37
|
|
|
38
|
+
## 更新
|
|
39
|
+
|
|
40
|
+
npm でグローバルインストール済みの Aptly 0.1.3 以降を更新するには、関連するホスト・MCP・CLI の書き込みプロセスをすべて停止し、[インストールとアップグレードの案内](docs/guide/ja.md#インストール)で台帳の移行と手動での代替手順を確認してください。既存のキー設定は保持されるため、キーの再入力は不要です。コマンド実行後に再起動してください。
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
aptly update
|
|
44
|
+
aptly setup --client all --mode defaults
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
## 使用方法
|
|
40
48
|
|
|
41
49
|
| 方法 | 動作 |
|
|
42
50
|
|---|---|
|
|
43
|
-
| 自動 Hook |
|
|
51
|
+
| 自動 Hook | 新しい呼び出しの制約を確認し、未指定のデフォルト値を推薦します |
|
|
44
52
|
| 直接推薦 | `recommend_agent` または `aptly recommend` でプロファイルを受け取り、実行するかどうかをホストで明示的に判断します |
|
|
45
53
|
| fixture | キーやネットワークを使わず、ローカルで生成した試験用の推薦を確認できます。実際の Decisions の結果ではありません |
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
Aptly 0.1.4 以降では継承呼び出しも推薦を評価します。適用には Codex の明示的な `fork_turns: "none"`、または履歴制約のない Claude Code の汎用呼び出しが必要で、指定済みフィールドは保持します。推薦・Hook 引数更新・実際の子の実行は別です。適用条件は[ガイド](docs/guide/ja.md#自動-hook)を参照してください。
|
|
48
56
|
|
|
49
57
|
## ドキュメント
|
|
50
58
|
|
|
51
|
-
- [CLI 設定](docs/guide/ja.md#cli-による設定)
|
|
52
59
|
- [使用ガイド](docs/guide/ja.md): インストール・削除、キー、Hook、直接推薦、エラー復旧
|
|
53
|
-
- [インストール・削除](docs/guide/ja.md#インストール): npm のグローバルインストール、ホスト登録、再起動と信頼の承認
|
|
60
|
+
- [インストール・削除](docs/guide/ja.md#インストール)と [CLI 設定](docs/guide/ja.md#cli-による設定): npm のグローバルインストール、ホスト登録、再起動と信頼の承認
|
|
54
61
|
- [モデルと環境変数](docs/guide/ja.md#モデルと環境変数): 6 つのデフォルトプロファイルと候補の設定
|
|
55
62
|
- [コンテキストの提供](docs/guide/ja.md#コンテキストの提供): 暗号化されたメッセージとリポジトリ URL の制約
|
|
56
63
|
- [費用実測](docs/guide/ja.md#費用実測): README 翻訳レビューのトークン・換算費用と測定範囲
|
package/README.md
CHANGED
|
@@ -20,37 +20,44 @@ Aptly는 최소한의 작업 요약을 OpenAI Decisions API로 분류하고 허
|
|
|
20
20
|
|
|
21
21
|
## 빠른 시작
|
|
22
22
|
|
|
23
|
-
Node.js **24 이상**과 Claude Code 또는 Codex가 필요합니다. 다음 명령으로 최신 안정 버전을 전역
|
|
23
|
+
Node.js **24 이상**과 Claude Code 또는 Codex가 필요합니다. 처음 설치할 때는 다음 명령으로 최신 안정 버전을 전역 설치하고 설정하십시오.
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
npm install -g aptly@latest --allow-scripts=aptly
|
|
27
27
|
aptly setup --client all --mode defaults
|
|
28
|
+
aptly set env OPENAI_API_KEY
|
|
28
29
|
aptly --version
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
`aptly --version`으로 설치된 버전을 확인하십시오. `--allow-scripts=aptly`는 지원하는 npm에서 Aptly의 설치 스크립트를 허용합니다. 이 옵션을 지원하지 않는 npm은 [설치 안내](docs/guide/ko.md#설치)의 명시적 설치·설정 절차를 따르십시오.
|
|
32
33
|
|
|
33
|
-
업그레이드 전에는 관련 호스트·MCP·CLI 프로세스를 모두 중지하고 [설치·업그레이드 안내](docs/guide/ko.md#설치)의 원장 전환 절차를 확인하십시오.
|
|
34
|
-
|
|
35
34
|
설치 시 `postinstall`은 기존 호스트 설정 디렉터리에 MCP와 `PreToolUse` Hook을 등록합니다. 명시적인 `setup`은 자동 등록을 건너뛰었거나 아직 설정 디렉터리가 없는 호스트에도 사용할 수 있습니다. 기존 다른 설정·Hook과 기존 Aptly 실행 명령·환경은 보존합니다.
|
|
36
35
|
|
|
37
36
|
분류용 `OPENAI_API_KEY`는 `aptly set env OPENAI_API_KEY`의 숨김 입력으로 OS 자격 저장소에 보관하거나 안전한 실행 환경에서 MCP 프로세스에 전달하십시오. 키를 명령행·요청·설정 JSON·저장소에 기록하지 마십시오. 호스트 또는 MCP를 재시작한 뒤, **Codex에서는 `/hooks`에서 새 Hook을 검토하고 신뢰를 승인하십시오.** [설치·키·등록 상세](docs/guide/ko.md#설치)를 참고하십시오.
|
|
38
37
|
|
|
38
|
+
## 업데이트
|
|
39
|
+
|
|
40
|
+
기존 전역 npm 설치의 Aptly 0.1.3 이상을 업데이트하려면 관련 호스트·MCP·CLI 쓰기 프로세스를 모두 중지하고 [설치·업그레이드 안내](docs/guide/ko.md#설치)의 원장 전환 및 수동 대체 절차를 확인하십시오. 기존 키 설정은 유지하므로 다시 입력할 필요가 없습니다. 명령 실행 후 재시작하십시오.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
aptly update
|
|
44
|
+
aptly setup --client all --mode defaults
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
## 사용 방식
|
|
40
48
|
|
|
41
49
|
| 방식 | 동작 |
|
|
42
50
|
|---|---|
|
|
43
|
-
| 자동 Hook |
|
|
51
|
+
| 자동 Hook | 새 호출의 제약을 검사하고 미지정 기본값을 추천합니다 |
|
|
44
52
|
| 직접 추천 | `recommend_agent` 또는 `aptly recommend`로 프로필을 받고 호스트에서 명시적으로 실행합니다 |
|
|
45
53
|
| fixture | 키·네트워크 없이 시험용 추천을 확인합니다. 실제 Decisions 결과가 아닙니다 |
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
Aptly 0.1.4부터 상속 호출도 추천을 평가합니다. Codex의 적용은 명시적인 `fork_turns: "none"`, Claude Code는 이력 제약 없는 일반 호출로 제한하며 명시한 필드는 보존합니다. 추천·Hook 인자 변경·실제 자식 실행은 별개입니다. 적용 조건은 [가이드](docs/guide/ko.md#자동-hook)에서 확인하십시오.
|
|
48
56
|
|
|
49
57
|
## 문서
|
|
50
58
|
|
|
51
|
-
- [CLI 설정](docs/guide/ko.md#cli로-설정하기)
|
|
52
59
|
- [사용 가이드](docs/guide/ko.md): 설치·제거, 키, Hook, 직접 추천, 오류 복구
|
|
53
|
-
- [설치·제거](docs/guide/ko.md#설치): npm 전역 설치, 호스트 등록, 재시작과 신뢰 승인
|
|
60
|
+
- [설치·제거](docs/guide/ko.md#설치) 및 [CLI 설정](docs/guide/ko.md#cli로-설정하기): npm 전역 설치, 호스트 등록, 재시작과 신뢰 승인
|
|
54
61
|
- [모델과 환경변수](docs/guide/ko.md#모델과-환경변수): 여섯 기본 프로필과 후보 설정
|
|
55
62
|
- [맥락 전달](docs/guide/ko.md#맥락-전달): 암호화된 메시지와 저장소 URL의 한계
|
|
56
63
|
- [비용 실측](docs/guide/ko.md#비용-실측): README 번역 검토의 토큰·환산 비용과 측정 범위
|
package/README.zh-CN.md
CHANGED
|
@@ -20,37 +20,44 @@ Aptly 使用 OpenAI Decisions API 对简要任务摘要进行分类,并推荐
|
|
|
20
20
|
|
|
21
21
|
## 快速开始
|
|
22
22
|
|
|
23
|
-
需要 Node.js **24 或更高版本**以及 Claude Code 或 Codex
|
|
23
|
+
需要 Node.js **24 或更高版本**以及 Claude Code 或 Codex。首次安装时,请使用以下命令全局安装并配置最新稳定版。
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
npm install -g aptly@latest --allow-scripts=aptly
|
|
27
27
|
aptly setup --client all --mode defaults
|
|
28
|
+
aptly set env OPENAI_API_KEY
|
|
28
29
|
aptly --version
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
请使用 `aptly --version` 确认已安装的版本。在支持此选项的 npm 中,`--allow-scripts=aptly` 允许执行 Aptly 的安装脚本。如果 npm 不支持此选项,请按照[安装指南](docs/guide/zh-CN.md#安装)中的显式安装与配置步骤操作。
|
|
32
33
|
|
|
33
|
-
升级前,请停止所有相关宿主、MCP 和 CLI 进程,并查看[安装与升级指南](docs/guide/zh-CN.md#安装)中的账本迁移步骤。
|
|
34
|
-
|
|
35
34
|
安装时的 `postinstall` 会在现有宿主配置目录中注册 MCP 和 `PreToolUse` Hook。如果跳过了自动注册,或宿主尚无配置目录,也可以显式运行 `setup`。其他现有配置与 Hook,以及 Aptly 原有的启动命令和环境均会保留。
|
|
36
35
|
|
|
37
36
|
请通过 `aptly set env OPENAI_API_KEY` 的隐藏输入,将分类用的 `OPENAI_API_KEY` 存入系统凭据存储,或通过安全的运行环境传递给 MCP 进程。不要将密钥写入命令行、请求、配置 JSON 或代码仓库。重启宿主或 MCP 后,**请在 Codex 的 `/hooks` 中审核新 Hook 并批准信任**。详见[安装、密钥与注册](docs/guide/zh-CN.md#安装)。
|
|
38
37
|
|
|
38
|
+
## 更新
|
|
39
|
+
|
|
40
|
+
如需更新通过 npm 全局安装的 Aptly 0.1.3 或更高版本,请先停止所有相关宿主、MCP 和 CLI 写入进程,并查阅[安装与升级指南](docs/guide/zh-CN.md#安装)中的账本迁移和手动备用步骤。现有密钥设置会保留,无需重新输入密钥。执行命令后请重启。
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
aptly update
|
|
44
|
+
aptly setup --client all --mode defaults
|
|
45
|
+
```
|
|
46
|
+
|
|
39
47
|
## 使用方式
|
|
40
48
|
|
|
41
49
|
| 方式 | 行为 |
|
|
42
50
|
|---|---|
|
|
43
|
-
| 自动 Hook |
|
|
51
|
+
| 自动 Hook | 检查新调用的约束,并推荐未指定的默认值 |
|
|
44
52
|
| 直接推荐 | 通过 `recommend_agent` 或 `aptly recommend` 获取执行配置,再在宿主中明确选择并执行 |
|
|
45
53
|
| fixture | 无需密钥或网络即可测试本地模拟推荐;结果并非实际 Decisions 判断 |
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
Aptly 0.1.4 起也会为继承调用评估推荐。应用仍要求 Codex 显式指定 `fork_turns: "none"`,或 Claude Code 使用无历史约束的通用调用;已指定字段会保留。推荐、Hook 参数更新与实际子代理执行是不同事实。应用条件详见[指南](docs/guide/zh-CN.md#自动-hook)。
|
|
48
56
|
|
|
49
57
|
## 文档
|
|
50
58
|
|
|
51
|
-
- [CLI 配置](docs/guide/zh-CN.md#使用-cli-设置)
|
|
52
59
|
- [使用指南](docs/guide/zh-CN.md):安装与移除、密钥、Hook、直接推荐、错误恢复
|
|
53
|
-
- [安装与移除](docs/guide/zh-CN.md#安装):npm 全局安装、宿主注册、重启与信任批准
|
|
60
|
+
- [安装与移除](docs/guide/zh-CN.md#安装)及 [CLI 配置](docs/guide/zh-CN.md#使用-cli-设置):npm 全局安装、宿主注册、重启与信任批准
|
|
54
61
|
- [模型与环境变量](docs/guide/zh-CN.md#模型与环境变量):六个默认配置与候选设置
|
|
55
62
|
- [提供上下文](docs/guide/zh-CN.md#提供上下文):加密消息与仓库 URL 的限制
|
|
56
63
|
- [成本实测](docs/guide/zh-CN.md#成本实测):README 翻译审阅的 token、换算成本与测量范围
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Router } from './core.ts';
|
|
2
2
|
import type { HookOutput } from './hook.ts';
|
|
3
|
+
import type { Client } from './types.ts';
|
|
3
4
|
export interface AutoPolicy {
|
|
4
5
|
schema_version: 1;
|
|
5
6
|
kind: 'aptly-auto-hook';
|
|
@@ -9,16 +10,50 @@ export interface AutoPolicy {
|
|
|
9
10
|
state_directory: string;
|
|
10
11
|
}
|
|
11
12
|
export interface AutomaticHookObservation {
|
|
12
|
-
status: '
|
|
13
|
+
status: 'arguments_updated' | 'advisory' | 'preserved' | 'pending' | 'awaiting_context' | 'blocked';
|
|
14
|
+
preflight: 'observed';
|
|
15
|
+
correlation_id?: string;
|
|
16
|
+
classification: 'unknown' | 'evaluating' | 'not_requested' | 'provider_requested' | 'cache_hit' | 'local_outcome';
|
|
17
|
+
recommendation: 'not_produced' | 'produced';
|
|
18
|
+
application: 'not_attempted' | 'blocked' | 'arguments_updated';
|
|
19
|
+
execution: 'not_observed';
|
|
20
|
+
constraint_provenance: 'unknown';
|
|
13
21
|
reason: string;
|
|
14
22
|
profile_id?: string;
|
|
15
23
|
request_id?: string;
|
|
24
|
+
retry_id?: string;
|
|
25
|
+
context_retry?: {
|
|
26
|
+
outcome?: {
|
|
27
|
+
status: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
classification: string;
|
|
30
|
+
recommendation: 'produced' | 'not_produced';
|
|
31
|
+
application: 'blocked' | 'not_attempted';
|
|
32
|
+
request_id: string;
|
|
33
|
+
profile_id?: string;
|
|
34
|
+
};
|
|
35
|
+
last_attempt: {
|
|
36
|
+
status: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface ContextRetrySeed {
|
|
42
|
+
request_id: string;
|
|
43
|
+
client: Client;
|
|
44
|
+
eligible_profile_ids: string[];
|
|
45
|
+
policy_fingerprint: string;
|
|
46
|
+
application_blocked?: string;
|
|
47
|
+
fill_model?: boolean;
|
|
48
|
+
fill_effort?: boolean;
|
|
16
49
|
}
|
|
17
50
|
export interface AutomaticHookResult {
|
|
18
51
|
output: HookOutput | {
|
|
19
52
|
hookSpecificOutput: {
|
|
20
53
|
hookEventName: 'PreToolUse';
|
|
21
54
|
additionalContext: string;
|
|
55
|
+
permissionDecision?: 'deny';
|
|
56
|
+
permissionDecisionReason?: string;
|
|
22
57
|
};
|
|
23
58
|
};
|
|
24
59
|
observation: AutomaticHookObservation;
|
|
@@ -29,7 +64,20 @@ export interface AutomaticHookOptions {
|
|
|
29
64
|
router: Router;
|
|
30
65
|
/** Internal configuration only: callers read APTLY_HOOK_POLICY_PATH, never MCP arguments. */
|
|
31
66
|
policyPath?: unknown;
|
|
67
|
+
/** Internal process-local handoff; never accepted as native policy/provenance. */
|
|
68
|
+
context?: () => {
|
|
69
|
+
summary?: string;
|
|
70
|
+
fingerprint?: string;
|
|
71
|
+
reason?: string;
|
|
72
|
+
} | undefined;
|
|
32
73
|
signal?: AbortSignal;
|
|
74
|
+
/** Internal diagnostics callback; never supplied through native tool arguments. */
|
|
75
|
+
onObservation?: (observation: AutomaticHookObservation) => void;
|
|
76
|
+
/** Internal bounded recovery issuer; never supplied by native arguments. */
|
|
77
|
+
onNeedsContext?: (seed: ContextRetrySeed, current: () => string | undefined) => {
|
|
78
|
+
retry_id?: string;
|
|
79
|
+
reason?: string;
|
|
80
|
+
};
|
|
33
81
|
/** A caller may revoke the pending event; absence does not certify native dispatch. */
|
|
34
82
|
stillCurrent?: () => boolean | Promise<boolean>;
|
|
35
83
|
}
|
|
@@ -38,5 +86,11 @@ export declare function loadAutomaticHookPolicy(path: unknown): {
|
|
|
38
86
|
reason: string;
|
|
39
87
|
fingerprint?: string;
|
|
40
88
|
};
|
|
89
|
+
export declare function automaticCallIdentity(client: unknown, event: unknown): {
|
|
90
|
+
key: string;
|
|
91
|
+
id: string;
|
|
92
|
+
} | undefined;
|
|
93
|
+
export declare function automaticCallId(client: unknown, event: unknown): string | undefined;
|
|
94
|
+
export declare function initialHookObservation(client: unknown, event: unknown): AutomaticHookObservation;
|
|
41
95
|
/** Operator default selection only. No provenance_verified/evidence_verified host claim. */
|
|
42
|
-
export declare function automaticHook({ client, event, router, policyPath, signal, stillCurrent }: AutomaticHookOptions): Promise<AutomaticHookResult>;
|
|
96
|
+
export declare function automaticHook({ client, event, router, policyPath, signal, context, stillCurrent, onObservation, onNeedsContext }: AutomaticHookOptions): Promise<AutomaticHookResult>;
|
|
@@ -4,7 +4,7 @@ import { closeSync, openSync, writeFileSync } from 'node:fs';
|
|
|
4
4
|
import { isAbsolute, join } from 'node:path';
|
|
5
5
|
import { Router } from './core.js';
|
|
6
6
|
import { assertPrivateStatePath, readRegularFile } from './files.js';
|
|
7
|
-
import { hookInput, hookOutput } from './hook.js';
|
|
7
|
+
import { hookInput, hookOutput, validatedHookProfile, profilePreservesChoices, effortKeys } from './hook.js';
|
|
8
8
|
import { digestToolInput } from './provenance.js';
|
|
9
9
|
const own = (object, key) => Object.hasOwn(object, key);
|
|
10
10
|
const plain = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) &&
|
|
@@ -61,20 +61,40 @@ function readCall(client, event) {
|
|
|
61
61
|
}
|
|
62
62
|
function preservation(call) {
|
|
63
63
|
const input = call.input;
|
|
64
|
-
if (own(input, 'model'))
|
|
65
|
-
return 'explicit_model';
|
|
66
|
-
if (['effort', 'reasoning_effort', 'model_reasoning_effort'].some(key => own(input, key)))
|
|
67
|
-
return 'explicit_effort';
|
|
68
64
|
if (['resume', 'resume_agent', 'agent_id'].some(key => own(input, key)))
|
|
69
65
|
return 'resumed_agent';
|
|
70
66
|
if (['role', 'agent_type'].some(key => own(input, key)) ||
|
|
71
|
-
(call.client === 'claude' && input.subagent_type !== 'general-purpose')
|
|
67
|
+
(call.client === 'claude' && input.subagent_type !== 'general-purpose') ||
|
|
68
|
+
(call.client === 'codex' && own(input, 'subagent_type')))
|
|
72
69
|
return 'fixed_role';
|
|
73
|
-
if (['fork_context', 'fork', 'fork_session', 'inherit_history'].some(key => own(input, key)) ||
|
|
74
|
-
(call.client === 'codex' ? input.fork_turns !== 'none' : own(input, 'fork_turns')))
|
|
75
|
-
return 'inherited_fork';
|
|
76
70
|
return null;
|
|
77
71
|
}
|
|
72
|
+
/** History semantics are checked at application, not used to suppress task advice. */
|
|
73
|
+
function applicationConstraint(call) {
|
|
74
|
+
if (['fork_context', 'fork', 'fork_session', 'inherit_history'].some(key => own(call.input, key)))
|
|
75
|
+
return 'history_semantics_unverified';
|
|
76
|
+
if (call.client === 'codex' && call.input.fork_turns !== 'none')
|
|
77
|
+
return 'inherited_context_application_unverified';
|
|
78
|
+
if (call.client === 'claude' && own(call.input, 'fork_turns'))
|
|
79
|
+
return 'history_semantics_unverified';
|
|
80
|
+
// Only reasoning_effort has an application contract for native Codex spawns.
|
|
81
|
+
if (effortKeys.some(key => key !== 'reasoning_effort' && own(call.input, key)))
|
|
82
|
+
return 'effort_argument_unsupported';
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
export function automaticCallIdentity(client, event) {
|
|
86
|
+
const call = readCall(client, event);
|
|
87
|
+
return call ? { key: call.callKey, id: hash(['aptly-observation-v1', call.callKey, call.payloadDigest]) } : undefined;
|
|
88
|
+
}
|
|
89
|
+
export function automaticCallId(client, event) {
|
|
90
|
+
const call = readCall(client, event);
|
|
91
|
+
return call ? hash(['aptly-observation-v1', call.callKey, call.payloadDigest]) : undefined;
|
|
92
|
+
}
|
|
93
|
+
export function initialHookObservation(client, event) {
|
|
94
|
+
const id = automaticCallId(client, event);
|
|
95
|
+
return { status: 'pending', reason: 'preflight_pending', preflight: 'observed', ...(id ? { correlation_id: id } : {}),
|
|
96
|
+
classification: 'not_requested', recommendation: 'not_produced', application: 'not_attempted', execution: 'not_observed', constraint_provenance: 'unknown' };
|
|
97
|
+
}
|
|
78
98
|
function catalogFingerprint(policy) {
|
|
79
99
|
return hash([policy.version, policy.catalog_version, policy.provider_id ?? null, policy.profiles, policy.profile_descriptions ?? {}]);
|
|
80
100
|
}
|
|
@@ -90,10 +110,14 @@ function boundedSummary(call, maxBytes) {
|
|
|
90
110
|
// it or forward it to the provider: a sufficiently descriptive visible name
|
|
91
111
|
// is a separate, explicitly labelled source of task advice only.
|
|
92
112
|
if (call.client === 'codex' && /^gAAAA[A-Za-z0-9_-]{75,}={0,2}$/.test(body)) {
|
|
93
|
-
if (!safeText(label, 512) ||
|
|
113
|
+
if (!safeText(label, 512) || !/^[a-z0-9]+(?:_[a-z0-9]+)*$/.test(label))
|
|
94
114
|
return { reason: 'insufficient_context' };
|
|
95
115
|
const words = label.split('_');
|
|
96
|
-
|
|
116
|
+
// Short labels need a concrete action, scope and object, not word padding.
|
|
117
|
+
// This is advice from the label alone, never authorization to perform it.
|
|
118
|
+
const concreteShortName = /^(?:cleanup|remove|prune)_merged_(?:worktrees|branches)$/.test(label) ||
|
|
119
|
+
/^(?:review|fix|test)_(?:failing|broken|flaky)_(?:tests|builds)$/.test(label);
|
|
120
|
+
if (!concreteShortName && (Buffer.byteLength(label) < 24 || words.length < 6 || words.filter(word => /^[a-z]{2,}$/.test(word)).length < 3))
|
|
97
121
|
return { reason: 'insufficient_context' };
|
|
98
122
|
const summary = `Task summary from visible task_name only; opaque message not inspected: ${words.join(' ')}`;
|
|
99
123
|
if (Buffer.byteLength(summary) > Math.min(4000, maxBytes))
|
|
@@ -118,9 +142,9 @@ function boundedSummary(call, maxBytes) {
|
|
|
118
142
|
}
|
|
119
143
|
return { summary: prefix + clipped };
|
|
120
144
|
}
|
|
121
|
-
function bindCall(call, policy, policyFingerprint, catalog) {
|
|
122
|
-
const binding = { schema_version: 1, input_digest: call.digest, payload_digest: call.payloadDigest, policy_fingerprint: policyFingerprint, catalog_fingerprint: catalog,
|
|
123
|
-
request_id: hash(['aptly-auto-hook-v1', call.callKey, call.payloadDigest, policyFingerprint, catalog]) };
|
|
145
|
+
function bindCall(call, policy, policyFingerprint, catalog, contextDigest) {
|
|
146
|
+
const binding = { ...(contextDigest ? { context_digest: contextDigest } : {}), schema_version: 1, input_digest: call.digest, payload_digest: call.payloadDigest, policy_fingerprint: policyFingerprint, catalog_fingerprint: catalog,
|
|
147
|
+
request_id: hash(['aptly-auto-hook-v1', call.callKey, call.payloadDigest, policyFingerprint, catalog, ...(contextDigest ? [contextDigest] : [])]) };
|
|
124
148
|
const path = join(policy.state_directory, `hook-call-${call.callKey}.json`);
|
|
125
149
|
let fd;
|
|
126
150
|
try {
|
|
@@ -153,8 +177,23 @@ function bindCall(call, policy, policyFingerprint, catalog) {
|
|
|
153
177
|
}
|
|
154
178
|
}
|
|
155
179
|
/** Operator default selection only. No provenance_verified/evidence_verified host claim. */
|
|
156
|
-
export async function automaticHook({ client, event, router, policyPath, signal, stillCurrent }) {
|
|
157
|
-
const
|
|
180
|
+
export async function automaticHook({ client, event, router, policyPath, signal, context, stillCurrent, onObservation, onNeedsContext }) {
|
|
181
|
+
const observation = initialHookObservation(client, event);
|
|
182
|
+
let activeMode;
|
|
183
|
+
const preserve = (reason, request_id) => {
|
|
184
|
+
const result = { output: {}, observation: { ...observation, status: 'preserved', reason, ...(request_id ? { request_id } : {}) } };
|
|
185
|
+
if (!activeMode || signal?.aborted || reason === 'call_cancelled')
|
|
186
|
+
return result;
|
|
187
|
+
// Respect an operator revocation rather than blocking under a disabled policy.
|
|
188
|
+
const currentPolicy = loadAutomaticHookPolicy(policyPath).policy;
|
|
189
|
+
if (!currentPolicy?.enabled)
|
|
190
|
+
return result;
|
|
191
|
+
const message = `Aptly could not select compatible subagent defaults (${reason}). Original arguments and execution constraints are preserved; no child execution is observed. Report this outcome. Do not repeat an uncertain paid request with a new ID or change history, explicit choices, roles or permissions to bypass this result.`;
|
|
192
|
+
result.output = { hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: message,
|
|
193
|
+
...(currentPolicy.mode === 'defaults' ? { permissionDecision: 'deny', permissionDecisionReason: message } : {}) } };
|
|
194
|
+
result.observation.status = currentPolicy.mode === 'defaults' ? 'blocked' : 'preserved';
|
|
195
|
+
return result;
|
|
196
|
+
};
|
|
158
197
|
try {
|
|
159
198
|
const loaded = loadAutomaticHookPolicy(policyPath);
|
|
160
199
|
if (!loaded.policy || !loaded.policy.enabled || !loaded.fingerprint)
|
|
@@ -165,12 +204,68 @@ export async function automaticHook({ client, event, router, policyPath, signal,
|
|
|
165
204
|
const pinned = preservation(call);
|
|
166
205
|
if (pinned)
|
|
167
206
|
return preserve(pinned);
|
|
207
|
+
const hasModel = own(call.input, 'model'), hasEffort = effortKeys.some(key => own(call.input, key));
|
|
208
|
+
if (hasModel && (hasEffort || call.client === 'claude'))
|
|
209
|
+
return preserve('explicit_model');
|
|
210
|
+
const profiles = router.policy.profiles.filter(profile => profile.client === call.client && profilePreservesChoices(call.input, profile));
|
|
211
|
+
if (!profiles.length)
|
|
212
|
+
return preserve(hasModel ? 'explicit_model' : hasEffort ? 'explicit_effort' : 'no_candidates');
|
|
168
213
|
// Synthetic fixture output must never select a native child's defaults.
|
|
169
214
|
if (loaded.policy.mode === 'defaults' && router.policy.provider_id !== 'decisions')
|
|
170
215
|
return preserve('synthetic_provider');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
216
|
+
activeMode = loaded.policy.mode;
|
|
217
|
+
const needsContext = (reason, request_id) => {
|
|
218
|
+
if (!onNeedsContext)
|
|
219
|
+
return preserve(reason, request_id);
|
|
220
|
+
if (signal?.aborted)
|
|
221
|
+
return preserve('call_cancelled', request_id);
|
|
222
|
+
const currentPolicy = loadAutomaticHookPolicy(policyPath);
|
|
223
|
+
if (!currentPolicy.policy?.enabled || currentPolicy.fingerprint !== loaded.fingerprint)
|
|
224
|
+
return preserve('automatic_policy_changed', request_id);
|
|
225
|
+
const expectedContext = context?.();
|
|
226
|
+
const recovery = onNeedsContext({ request_id, client: call.client, eligible_profile_ids: profiles.map(profile => profile.id),
|
|
227
|
+
policy_fingerprint: loaded.fingerprint, application_blocked: applicationConstraint(call) ?? undefined,
|
|
228
|
+
fill_model: !hasModel, fill_effort: !hasEffort }, () => {
|
|
229
|
+
const latest = context?.();
|
|
230
|
+
if (latest?.reason)
|
|
231
|
+
return latest.reason;
|
|
232
|
+
if (latest?.fingerprint !== expectedContext?.fingerprint)
|
|
233
|
+
return 'context_changed';
|
|
234
|
+
const latestCall = readCall(client, event);
|
|
235
|
+
return latestCall?.payloadDigest === call.payloadDigest ? undefined : 'call_changed';
|
|
236
|
+
});
|
|
237
|
+
const instruction = recovery.retry_id
|
|
238
|
+
? `Call Aptly retry_spawn_recommendation with retry_id "${recovery.retry_id}" and a short description of task purpose, scope, expected output and complexity. Use context you already have; ask the user only for genuinely missing information. One supplementation is allowed. Do not decode the opaque body or invent native call IDs. A recommendation is advice only: preserve explicit choices, roles, permissions and history; never change fork semantics to apply it. If application is blocked, report that limitation. Do not spawn while the retry still needs context or is unavailable.`
|
|
239
|
+
: `Context recovery is unavailable (${recovery.reason ?? 'context_retry_unavailable'}). Report the limitation; do not repeat the spawn unchanged.`;
|
|
240
|
+
const feedback = `Aptly needs additional task context (${reason}). ${instruction}`;
|
|
241
|
+
return { output: { hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: feedback,
|
|
242
|
+
...(loaded.policy.mode === 'defaults' ? { permissionDecision: 'deny', permissionDecisionReason: feedback } : {}) } },
|
|
243
|
+
observation: { ...observation, status: 'awaiting_context', reason, request_id, ...(recovery.retry_id ? { retry_id: recovery.retry_id } : {}) } };
|
|
244
|
+
};
|
|
245
|
+
const supplied = context?.();
|
|
246
|
+
if (supplied?.reason)
|
|
247
|
+
return preserve(supplied.reason);
|
|
248
|
+
const summary = supplied?.summary ? supplied : boundedSummary(call, router.policy.max_summary_bytes);
|
|
249
|
+
if (Buffer.byteLength(summary.summary ?? '') > Math.min(4000, router.policy.max_summary_bytes))
|
|
250
|
+
return preserve('insufficient_context');
|
|
251
|
+
if (!summary.summary) {
|
|
252
|
+
if (summary.reason !== 'insufficient_context' || !onNeedsContext)
|
|
253
|
+
return preserve(summary.reason ?? 'insufficient_context');
|
|
254
|
+
if (signal?.aborted || (stillCurrent && await stillCurrent() !== true))
|
|
255
|
+
return preserve('call_cancelled');
|
|
256
|
+
const legacyId = hookInput({ client, event, policy: router.policy })?.request_id ?? hash([call.client, call.event.session_id, call.event.tool_use_id ?? call.event.tool_call_id]);
|
|
257
|
+
try {
|
|
258
|
+
router.load();
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
return preserve('ledger_error');
|
|
262
|
+
}
|
|
263
|
+
if (own(router.state.requests, legacyId))
|
|
264
|
+
return preserve('legacy_request_exists', legacyId);
|
|
265
|
+
// Reserve the same immutable native-call binding without making a paid request.
|
|
266
|
+
const bound = bindCall(call, loaded.policy, loaded.fingerprint, catalogFingerprint(router.policy), supplied?.fingerprint);
|
|
267
|
+
return bound.request_id ? needsContext('insufficient_context', bound.request_id) : preserve(bound.reason ?? 'automatic_state_unavailable');
|
|
268
|
+
}
|
|
174
269
|
if (signal?.aborted || (stillCurrent && await stillCurrent() !== true))
|
|
175
270
|
return preserve('call_cancelled');
|
|
176
271
|
// Installing an operator policy must not bypass a historical strict-path
|
|
@@ -190,19 +285,40 @@ export async function automaticHook({ client, event, router, policyPath, signal,
|
|
|
190
285
|
}
|
|
191
286
|
if (own(router.state.requests, legacyId))
|
|
192
287
|
return preserve('legacy_request_exists', legacyId);
|
|
288
|
+
const contextBeforePaid = context?.();
|
|
289
|
+
if (contextBeforePaid?.reason || contextBeforePaid?.fingerprint !== supplied?.fingerprint)
|
|
290
|
+
return preserve(contextBeforePaid?.reason ?? 'context_changed');
|
|
193
291
|
const catalog = catalogFingerprint(router.policy);
|
|
194
|
-
const bound = bindCall(call, loaded.policy, loaded.fingerprint, catalog);
|
|
292
|
+
const bound = bindCall(call, loaded.policy, loaded.fingerprint, catalog, supplied?.fingerprint);
|
|
195
293
|
if (!bound.request_id)
|
|
196
294
|
return preserve(bound.reason ?? 'automatic_state_unavailable');
|
|
197
295
|
const request_id = bound.request_id;
|
|
198
296
|
const snapshot = structuredClone(call.event);
|
|
297
|
+
observation.classification = 'evaluating';
|
|
298
|
+
observation.request_id = request_id;
|
|
299
|
+
try {
|
|
300
|
+
onObservation?.({ ...observation });
|
|
301
|
+
}
|
|
302
|
+
catch { /* Diagnostics do not change routing. */ }
|
|
303
|
+
// These flags describe selection of the remaining defaults only. Explicit
|
|
304
|
+
// values constrain the candidate tuples; history is rechecked before application.
|
|
199
305
|
const recommendation = await router.advise({ request_id, client: call.client,
|
|
200
306
|
task: { summary: summary.summary, operation: 'analysis', context_sufficient: true },
|
|
201
|
-
eligible_profile_ids:
|
|
307
|
+
eligible_profile_ids: profiles.map(profile => profile.id),
|
|
202
308
|
constraints: { model_pinned: false, effort_pinned: false, role_pinned: false, fork_inherits: false },
|
|
203
309
|
});
|
|
310
|
+
observation.classification = recommendation.cached ? 'cache_hit' : typeof recommendation.latency_ms === 'number' ? 'provider_requested' : 'local_outcome';
|
|
311
|
+
const profile = validatedHookProfile(client, recommendation, router.policy);
|
|
312
|
+
if (profile && profiles.some(candidate => candidate.id === profile.id)) {
|
|
313
|
+
observation.recommendation = 'produced';
|
|
314
|
+
observation.profile_id = profile.id;
|
|
315
|
+
observation.application = 'blocked';
|
|
316
|
+
}
|
|
204
317
|
if (signal?.aborted || (stillCurrent && await stillCurrent() !== true))
|
|
205
318
|
return preserve('call_cancelled', request_id);
|
|
319
|
+
const currentContext = context?.();
|
|
320
|
+
if (currentContext?.reason || currentContext?.fingerprint !== supplied?.fingerprint)
|
|
321
|
+
return preserve(currentContext?.reason ?? 'context_changed', request_id);
|
|
206
322
|
const current = readCall(client, event), policyNow = loadAutomaticHookPolicy(policyPath);
|
|
207
323
|
if (!current || current.callKey !== call.callKey || current.digest !== call.digest || current.payloadDigest !== call.payloadDigest)
|
|
208
324
|
return preserve('call_changed', request_id);
|
|
@@ -212,21 +328,36 @@ export async function automaticHook({ client, event, router, policyPath, signal,
|
|
|
212
328
|
return preserve('catalog_changed', request_id);
|
|
213
329
|
// The existing narrow catalog/tuple validator is reused. This local flag is an
|
|
214
330
|
// operator-policy decision, never a claim about complete host-setting evidence.
|
|
215
|
-
|
|
216
|
-
|
|
331
|
+
if (!profile || observation.recommendation !== 'produced') {
|
|
332
|
+
if (recommendation.status === 'needs_context')
|
|
333
|
+
return needsContext(recommendation.reason, request_id);
|
|
217
334
|
const allowed = ['preserved_constraints', 'unsupported_profile', 'invalid_response', 'invalid_choice', 'provider_abstained', 'no_candidates', 'insufficient_context',
|
|
218
335
|
'provider_needs_context', 'budget_exhausted', 'concurrency_limit', 'ledger_locked', 'request_conflict', 'outcome_unknown', 'ledger_error', 'timeout', 'refused',
|
|
219
336
|
'truncated', 'invalid_json', 'unauthorized', 'rate_limited', 'network', 'provider_error', 'sensitive_input', 'invalid_input'];
|
|
220
337
|
return preserve(allowed.includes(recommendation.reason) ? recommendation.reason : 'recommendation_unavailable', request_id);
|
|
221
338
|
}
|
|
222
|
-
const
|
|
339
|
+
const blocked = applicationConstraint(call);
|
|
340
|
+
if (blocked) {
|
|
341
|
+
const kept = preserve(blocked, request_id);
|
|
342
|
+
const next = blocked === 'effort_argument_unsupported' ? 'The caller must review the native reasoning_effort argument spelling; Aptly never rewrites an explicit choice.' : 'Inherited model/effort updates are not verified for this host. Verify the host version and native contract before enabling them; task arguments cannot certify support. Aptly never changes history automatically.';
|
|
343
|
+
const message = `Aptly recommends ${profile.id}, but application is blocked (${blocked}). Original history and arguments are preserved; no child execution is observed. ${next} Report this constraint and stop this spawn; do not discard history or create a fresh child merely to apply the recommendation.`;
|
|
344
|
+
kept.output = { hookSpecificOutput: { hookEventName: 'PreToolUse', additionalContext: message,
|
|
345
|
+
...(activeMode === 'defaults' ? { permissionDecision: 'deny', permissionDecisionReason: message } : {}) } };
|
|
346
|
+
kept.observation.status = activeMode === 'defaults' ? 'blocked' : 'preserved';
|
|
347
|
+
return kept;
|
|
348
|
+
}
|
|
349
|
+
const candidate = hookOutput({ client, event: snapshot, recommendation, mode: 'apply', compatibilityVerified: true, policy: router.policy, fillUnspecified: true });
|
|
350
|
+
if (!candidate.hookSpecificOutput)
|
|
351
|
+
return preserve('application_unsupported', request_id);
|
|
223
352
|
if (loaded.policy.mode === 'advisory')
|
|
224
353
|
return { output: { hookSpecificOutput: { hookEventName: 'PreToolUse',
|
|
225
354
|
additionalContext: `Aptly suggests ${profile.model}${profile.reasoning_effort ? ` with ${profile.reasoning_effort} reasoning effort` : ''} for this task (${profile.id}). This is task advice; the host retains execution and permission decisions.` } },
|
|
226
|
-
observation: { status: 'advisory', reason: 'operator_policy_advice', profile_id: profile.id, request_id } };
|
|
227
|
-
return { output: candidate, observation: { status: '
|
|
355
|
+
observation: { ...observation, status: 'advisory', application: 'not_attempted', reason: 'operator_policy_advice', profile_id: profile.id, request_id } };
|
|
356
|
+
return { output: candidate, observation: { ...observation, status: 'arguments_updated', application: 'arguments_updated', reason: 'operator_policy_defaults', profile_id: profile.id, request_id } };
|
|
228
357
|
}
|
|
229
358
|
catch {
|
|
359
|
+
if (observation.classification === 'evaluating')
|
|
360
|
+
observation.classification = 'unknown';
|
|
230
361
|
return preserve('automatic_hook_unavailable');
|
|
231
362
|
}
|
|
232
363
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContextRetrySeed } from './automatic-hook.ts';
|
|
2
|
+
import type { Router } from './core.ts';
|
|
3
|
+
/** One caller-supplied supplement, never an automatic native spawn or a retry chain. */
|
|
4
|
+
export declare class ContextRetries {
|
|
5
|
+
private entries;
|
|
6
|
+
private router;
|
|
7
|
+
private policyPath;
|
|
8
|
+
private now;
|
|
9
|
+
constructor(router: Router, policyPath: unknown, now?: () => number);
|
|
10
|
+
register(seed: ContextRetrySeed, current?: () => string | undefined): {
|
|
11
|
+
retry_id?: string;
|
|
12
|
+
reason?: string;
|
|
13
|
+
};
|
|
14
|
+
retry(retry_id: string, description: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
15
|
+
}
|