@ai-agent-forge/plugin-decision-escalation 0.0.0-stage → 0.88.15
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.md +67 -2
- package/agent-forge.json +19 -0
- package/dist/adjudication.d.ts +89 -0
- package/dist/adjudication.d.ts.map +1 -0
- package/dist/adjudication.js +289 -0
- package/dist/adjudication.js.map +1 -0
- package/dist/engine.d.ts +111 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +333 -0
- package/dist/engine.js.map +1 -0
- package/dist/entry.d.ts +14 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +23 -0
- package/dist/entry.js.map +1 -0
- package/dist/http-server.d.ts +46 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +219 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +592 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -5
- package/plugin.json +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAEN,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EAEpB,YAAY,EACZ,oBAAoB,EACpB,aAAa,GAGb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAwC,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,O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AO,EAAE,CAAC;YACvB,KAAK,MAAM,UAAU,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;gBAAE,UAAU,CAAC,UAAU,CAAC,CAAC;YACpE,UAAU,EAAE,CAAC;QAAA,CACb;KACD,CAAC;IAEF,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;AAAA,CACnD","sourcesContent":["/**\n * Decision escalation capability plugin (`docs/design/决策升级插件设计.md`):\n * a formal ask channel for forks (decision_ask), a local confirmation page\n * plus TUI-text answers resolved through decision_resolve, a factory-180s\n * timeout de-escalation chain (single adjudicator for routine forks,\n * advocates + judge for significant ones, via the public\n * `agent-forge.agent-task-scheduler@1` capability), and an irreversible\n * redline that keeps the agent stopped.\n *\n * Persistence protocol, structurally identical to the goal/plan/alignment\n * plugins: append-only `decision.state` full snapshots (the single rebuild\n * source) plus one `decision.transition` audit entry per conversion,\n * announced as `decision.changed` (version 1, correlationId\n * \"decision.state\", data = the complete DecisionState snapshot).\n *\n * Injections (设计 §6): user answers ride `decision.answered`\n * (`display: false`, model context like alignment.feedback); timeout\n * adjudication/halted notices ride `decision.notice` (`display: true`, the\n * user must see them). Both trigger a new turn via `sendMessage`.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport type {\n\tCapabilityAPI,\n\tCapabilityCommandResult,\n\tDisposableRegistration,\n\tPluginConfig,\n} from \"@agent-forge/plugin-sdk\";\nimport { Type } from \"typebox\";\nimport { requireSchedulerCaller, runAdjudication } from \"./adjudication.ts\";\nimport {\n\ttype AdjudicationFailureCode,\n\tapplyAdjudicationFailure,\n\tapplyDecisionAnswer,\n\tapplyDecisionAsk,\n\tapplyDecisionCancel,\n\tapplyDecisionTimeout,\n\ttype DecisionAskInput,\n\tfindDecision,\n\trebuildDecisionState,\n\trecordVerdict,\n\ttype StateEntryView,\n\ttype TimeoutMode,\n} from \"./engine.ts\";\nimport { type AnswerPost, type DecisionServer, startDecisionServer } from \"./http-server.ts\";\nimport {\n\tDECISION_LIMITS,\n\tDecisionError,\n\ttype DecisionPageView,\n\ttype DecisionRecord,\n\ttype DecisionState,\n\ttype DecisionTransitionEntry,\n} from \"./types.ts\";\n\nconst STATE_ENTRY = \"decision.state\";\nconst TRANSITION_ENTRY = \"decision.transition\";\n/** 出厂默认(设计 §10):问询超时 180 秒,config `timeoutMs` 可覆盖。 */\nconst DEFAULT_TIMEOUT_MS = 180_000;\n/**\n * 注入接受判定的兜底窗口(alignment v3.10 同款):宿主在回合开头落\n * custom_message 条目(正常毫秒级可见)。第三方宿主若不投影该类条目,窗口\n * 结束仍未拒绝即视为已接受。\n */\nconst INJECT_ACCEPT_TIMEOUT_MS = 750;\n\nexport interface DecisionCapabilityOptions {\n\t/** Injection seam for deterministic tests; production binds an OS-assigned port. */\n\tserverPort?: number;\n\t/** Injection seam for deterministic tests; production reads config `timeoutMs`. */\n\ttimeoutMs?: number;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/**\n * 双调用约定(goal/alignment 同款):会话路径以 (toolCallId, params, signal,\n * onUpdate) 调用插件工具——first 是调用 id 字符串;runtime facade 以\n * (input, context?, signal?) 调用——first 是入参对象。按 first 的类型区分,\n * 两条路径(含 runtime 携带 context)都取到真实入参。\n */\nfunction toolInput(first: unknown, second?: unknown): Record<string, unknown> {\n\tif (typeof first === \"string\") {\n\t\tif (!isObject(second)) return {};\n\t\treturn second;\n\t}\n\tif (!isObject(first)) throw new Error(\"decision tool input must be an object\");\n\treturn first;\n}\n\n/** config `timeoutMs`(设计 §10):数值覆盖出厂 180s;非法类型显式报错。 */\nfunction readTimeoutMs(config: PluginConfig): number {\n\tconst value = config.timeoutMs;\n\tif (value === undefined) return DEFAULT_TIMEOUT_MS;\n\tif (typeof value !== \"number\" || !Number.isSafeInteger(value) || value <= 0) {\n\t\tthrow new Error(\"decision-escalation: config.timeoutMs must be a positive integer (ms)\");\n\t}\n\treturn value;\n}\n\nfunction loadState(api: CapabilityAPI): DecisionState {\n\tconst entries = (api.session?.getBranchEntries() ?? []) as readonly StateEntryView[];\n\treturn rebuildDecisionState(entries);\n}\n\nfunction loadTransitions(api: CapabilityAPI): DecisionTransitionEntry[] {\n\tconst entries = api.session?.getBranchEntries() ?? [];\n\treturn entries\n\t\t.filter((item) => item.customType === TRANSITION_ENTRY)\n\t\t.map((item) => item.data as DecisionTransitionEntry)\n\t\t.filter((item): item is DecisionTransitionEntry => isObject(item));\n}\n\nfunction pageView(record: DecisionRecord, timeoutMs: number): DecisionPageView {\n\treturn {\n\t\tdecisionId: record.id,\n\t\tquestion: record.question,\n\t\toptions: record.options,\n\t\tcontextDigest: record.contextDigest,\n\t\triskClass: record.riskClass,\n\t\tredLine: record.redLine,\n\t\tstatus: record.status,\n\t\t...(record.status === \"answered\" && record.choice !== undefined ? { answeredChoice: record.choice } : {}),\n\t\ttimeoutMs,\n\t\trevision: record.revision,\n\t};\n}\n\nfunction optionLine(record: DecisionRecord, choice: number): string {\n\tconst option = record.options[choice];\n\treturn option === undefined ? `choice ${choice}` : `[${choice}] ${option.label}`;\n}\n\n/** `decision.answered` injection body (设计 §6): user choice delivered to the model. */\nfunction answeredMessage(record: DecisionRecord, choice: number, note?: string): string {\n\tconst lines = [\n\t\t`[decision.answered] 决策 ${record.id} 已作答:${optionLine(record, choice)}`,\n\t\t`问题:${record.question}`,\n\t];\n\tif (note !== undefined && note !== \"\") lines.push(`用户补充:${note}`);\n\tlines.push(\n\t\t`请立即调用 decision_resolve(decisionId \"${record.id}\",choice ${choice},source \"user\")落账,然后按选择继续执行。`,\n\t);\n\treturn lines.join(\"\\n\");\n}\n\n/** `decision.notice` halted body (设计 §5.1): redline / failed adjudication. */\nfunction haltedMessage(record: DecisionRecord, detail?: string): string {\n\tconst lines = [\n\t\t`[decision.notice] 决策 ${record.id} 已停止推进(问题:${record.question})`,\n\t\t...record.options.map(\n\t\t\t(option, index) =>\n\t\t\t\t`[${index}] ${option.label} — ${option.description}(后果:${option.consequences},可逆性:${option.reversibility ?? \"未声明\"})`,\n\t\t),\n\t];\n\tif (detail !== undefined && detail !== \"\") lines.push(`原因:${detail}`);\n\tlines.push(\n\t\t\"纪律:停止执行,把该分叉与上述选项整理后写给用户,等待用户明示;不得自行裁决后继续,不得自动调用 decision_resolve。\",\n\t);\n\treturn lines.join(\"\\n\");\n}\n\n/** `decision.notice` adjudication body (设计 §5): the full verdict drives the next turn. */\nfunction adjudicationNoticeMessage(record: DecisionRecord): string {\n\tconst verdict = record.verdict;\n\tif (verdict === undefined) throw new DecisionError(\"invalid-input\", `no verdict stored on decision ${record.id}`);\n\treturn [\n\t\t`[decision.notice] 决策 ${record.id} 已超时,由独立裁决链裁决完成(问题:${record.question})`,\n\t\t`裁决:${optionLine(record, verdict.choice)}(置信度 ${verdict.confidence})`,\n\t\t`理由:${verdict.rationale}`,\n\t\t`关键证据:${verdict.keyEvidence.join(\";\")}`,\n\t\t`请立即调用 decision_resolve(decisionId \"${record.id}\",choice ${verdict.choice},source \"adjudication\")落账,然后按裁决继续执行。`,\n\t\t\"纪律:有实质异议时停止并说明异议与依据,不得静默推翻,也不得静默服从明知有致命缺陷的裁决。\",\n\t].join(\"\\n\");\n}\n\nconst PROMPT_GUIDELINES: readonly string[] = [\n\t\"L0 微小分叉自主决策,不问;L1+ 且无法从既有指令推出用户偏好时才 decision_ask。\",\n\t\"context_digest 必须对称:每个选项都要写支持与反对证据;不得为倾向选项写更充分的论证。\",\n\t\"任何选项不可逆时必须如实声明 reversibility,不得打包成 reversible 规避红线。\",\n\t\"收到 halted 通知:停止执行,把分叉与选项整理给用户,不得自行裁决后继续。\",\n\t\"收到裁决书:执行裁决;有实质异议时停止并说明异议与依据,不得静默推翻,也不得静默服从明知有致命缺陷的裁决。\",\n];\n\nconst askSchema = Type.Object({\n\tquestion: Type.String({ description: \"分叉一句话\" }),\n\toptions: Type.Array(\n\t\tType.Object({\n\t\t\tlabel: Type.String({ description: \"选项短标签\" }),\n\t\t\tdescription: Type.String({ description: \"选项一句话说明\" }),\n\t\t\tconsequences: Type.String({ description: \"选它的直接后果\" }),\n\t\t\treversibility: Type.Optional(\n\t\t\t\tType.Union([Type.Literal(\"reversible\"), Type.Literal(\"irreversible\")], {\n\t\t\t\t\tdescription: \"可逆性;缺失按红线处理(保守默认)\",\n\t\t\t\t}),\n\t\t\t),\n\t\t}),\n\t\t{ description: \"2..4 个封闭选项\", minItems: 2, maxItems: 4 },\n\t),\n\tcontext_digest: Type.String({\n\t\tdescription: \"对称决策简报:每个选项的支持证据、反对证据、影响范围;缺项视为无效简报\",\n\t}),\n\trisk_class: Type.Union([Type.Literal(\"routine\"), Type.Literal(\"significant\")], {\n\t\tdescription: \"L1/L2 自评,仅决定超时后走单裁还是对抗裁决\",\n\t}),\n});\n\nconst resolveSchema = Type.Object({\n\tdecisionId: Type.String({ description: \"decision_ask 返回的决策 id\" }),\n\tchoice: Type.Integer({ description: \"选项下标(0 起)\" }),\n\tsource: Type.Union([Type.Literal(\"user\"), Type.Literal(\"adjudication\")], {\n\t\tdescription: \"user=用户作答;adjudication=已注入的裁决书(必须与裁决一致,不得伪造)\",\n\t}),\n\tnote: Type.Optional(Type.String({ description: \"落账备注(可选)\" })),\n});\n\nfunction listLines(state: DecisionState, count: number): string {\n\tif (state.decisions.length === 0) return \"no decisions in this session; ask one with decision_ask\";\n\tconst lines = [`decisions: ${state.decisions.length}`];\n\tfor (const record of state.decisions.slice(-count).reverse()) {\n\t\tlines.push(\n\t\t\t`- ${record.id} [${record.status}${record.redLine ? \"/redline\" : `/${record.riskClass}`}] ${record.question.replace(/\\n/g, \" \").slice(0, 80)} · ${record.resolvedBy ?? \"-\"}${record.choice === undefined ? \"\" : ` choice=${record.choice}`} · ${new Date(record.createdAt).toISOString()}`,\n\t\t);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nfunction showLines(record: DecisionRecord, transitions: DecisionTransitionEntry[]): string {\n\tconst lines = [\n\t\t`${record.id} [${record.status}${record.redLine ? \"/redline\" : `/${record.riskClass}`}] ${record.question}`,\n\t\t`created: ${new Date(record.createdAt).toISOString()} · revision ${record.revision}`,\n\t];\n\tfor (const [index, option] of record.options.entries()) {\n\t\tconst marker = record.choice === index ? \" ← 已选\" : \"\";\n\t\tlines.push(`[${index}] ${option.label} — ${option.description}`);\n\t\tlines.push(` 后果:${option.consequences} · 可逆性:${option.reversibility}${marker}`);\n\t}\n\tlines.push(`对称简报:${record.contextDigest}`);\n\tif (record.resolvedBy !== undefined)\n\t\tlines.push(\n\t\t\t`resolved_by: ${record.resolvedBy}${record.choice === undefined ? \"\" : `(${optionLine(record, record.choice)})`}`,\n\t\t);\n\tif (record.note !== undefined) lines.push(`note: ${record.note}`);\n\tif (record.verdict !== undefined) {\n\t\tlines.push(\n\t\t\t`裁决书:choice=${record.verdict.choice} confidence=${record.verdict.confidence}`,\n\t\t\t`理由:${record.verdict.rationale}`,\n\t\t\t`关键证据:${record.verdict.keyEvidence.map((item) => `\\n - ${item}`).join(\"\")}`,\n\t\t);\n\t}\n\tconst events = transitions.filter((entry) => entry.decisionId === record.id);\n\tif (events.length > 0) {\n\t\tlines.push(\"审计:\");\n\t\tfor (const entry of events) {\n\t\t\tlines.push(\n\t\t\t\t` rev${entry.revision} ${entry.event}${entry.reason.detail === undefined ? \"\" : ` — ${entry.reason.detail}`}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn lines.join(\"\\n\");\n}\n\nexport function createCapability(\n\tapi: CapabilityAPI,\n\toptions: DecisionCapabilityOptions = {},\n): readonly DisposableRegistration[] {\n\tlet state = loadState(api);\n\tlet server: DecisionServer | undefined;\n\t/** Disposed sessions never inject again: checked at every timer-job await point. */\n\tlet disposed = false;\n\tconst effectiveTimeoutMs = options.timeoutMs ?? readTimeoutMs(api.config);\n\tconst timers = new Map<string, ReturnType<typeof setTimeout>>();\n\t/**\n\t * 计时路径没有调用方可观察异常:注入失败在这里保留原始错误(不吞不改,\n\t * 不产生未处理的 promise 拒绝),并在 /decision log 可见。\n\t */\n\tconst timeoutFailures: unknown[] = [];\n\t/**\n\t * 双 POST 幂等标记:内存态,不进持久化——同一决策的页面作答\n\t * 只注入一次,重复提交直接幂等返回。\n\t */\n\tconst deliveredAnswers = new Map<string, number>();\n\n\tconst persist = (next: DecisionState, transitions: DecisionTransitionEntry[]): DecisionState => {\n\t\tstate = next;\n\t\tapi.session?.appendEntry(STATE_ENTRY, state);\n\t\tfor (const entry of transitions) api.session?.appendEntry(TRANSITION_ENTRY, entry);\n\t\tvoid api.publish({ type: \"decision.changed\", version: 1, correlationId: STATE_ENTRY, data: state });\n\t\treturn state;\n\t};\n\n\t/**\n\t * 注入是否已被会话接受(alignment v3.10 同款):宿主在回合开始时就把\n\t * custom message 落成条目并持久化,因此\"条目可见\"就是送达事实;不能等\n\t * `sendMessage` 的 promise——它要到整个模型回合结束才 resolve。\n\t */\n\tconst customMessageCount = (): number => {\n\t\tconst entries = api.session?.getBranchEntries() ?? [];\n\t\treturn entries.filter((entry) => (entry as { type?: string }).type === \"custom_message\").length;\n\t};\n\n\tconst awaitAccepted = async (baseline: number, sent: Promise<void>): Promise<void> => {\n\t\tlet settled = false;\n\t\tlet failure: unknown;\n\t\tconst outcome = sent.then(\n\t\t\t() => {\n\t\t\t\tsettled = true;\n\t\t\t},\n\t\t\t(error) => {\n\t\t\t\tsettled = true;\n\t\t\t\tfailure = error;\n\t\t\t},\n\t\t);\n\t\tconst started = Date.now();\n\t\t// 迭代上限是假定时器(Date 也被冻结)时的兜底:不靠时钟也能退出循环。\n\t\tfor (let attempt = 0; attempt < 100_000; attempt += 1) {\n\t\t\tif (customMessageCount() > baseline) {\n\t\t\t\t// 回合继续在后台跑;它之后的失败由宿主呈现。\n\t\t\t\tvoid outcome;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (settled) {\n\t\t\t\tawait outcome;\n\t\t\t\tif (failure !== undefined) throw failure;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (Date.now() - started >= INJECT_ACCEPT_TIMEOUT_MS) {\n\t\t\t\t// 无条目证据的宿主:sendMessage 已调用且未拒绝,按已接受处理。\n\t\t\t\tvoid outcome;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// setImmediate 而不是 setTimeout:条目写入在毫秒级,且宿主的单测可能\n\t\t\t// 伪造 setTimeout(假定时器下 setTimeout 不推进会把送达判定挂死)。\n\t\t\tawait new Promise((resolve) => setImmediate(resolve));\n\t\t}\n\t\tawait outcome;\n\t\tif (failure !== undefined) throw failure;\n\t};\n\n\tconst inject = async (customType: string, content: string, display: boolean): Promise<void> => {\n\t\t// alignment 两处降级同款:sendMessage 缺失显式抛错,不静默。\n\t\tconst send = api.session?.sendMessage;\n\t\tif (!send) {\n\t\t\tthrow new DecisionError(\n\t\t\t\t\"invalid-input\",\n\t\t\t\t\"host session does not expose sendMessage; the decision answer cannot be injected\",\n\t\t\t);\n\t\t}\n\t\tconst baseline = customMessageCount();\n\t\tconst sent = send({ customType, content, display }, { triggerTurn: true });\n\t\tawait awaitAccepted(baseline, sent);\n\t\t// triggerTurn 注入会同步驱动模型回合,回合内的 decision_resolve 已把变更\n\t\t// 落账 entries——此处从 entries 重建内存态,不回写回合前快照。\n\t\tif (api.session) state = loadState(api);\n\t};\n\n\tconst clearTimer = (decisionId: string): void => {\n\t\tconst timer = timers.get(decisionId);\n\t\tif (timer !== undefined) {\n\t\t\tclearTimeout(timer);\n\t\t\ttimers.delete(decisionId);\n\t\t}\n\t};\n\n\tconst requireAsked = (decisionId: string): DecisionRecord => {\n\t\tconst record = findDecision(state, decisionId);\n\t\tif (!record) throw new DecisionError(\"not-found\", `unknown decision: ${decisionId}`);\n\t\tif (record.status !== \"asked\") {\n\t\t\tthrow new DecisionError(\"not-active\", `decision is not active (status ${record.status}): ${decisionId}`);\n\t\t}\n\t\treturn record;\n\t};\n\n\tconst injectNotice = (record: DecisionRecord, detail?: string): Promise<void> =>\n\t\tinject(\"decision.notice\", haltedMessage(record, detail), true);\n\n\t/** Timeout fire (设计 §5): halt redlines, adjudicate reversible levels. */\n\tconst handleTimeout = async (decisionId: string): Promise<void> => {\n\t\ttimers.delete(decisionId);\n\t\tif (disposed) return; // 会话已关闭:不派发、不注入\n\t\tconst record = requireAsked(decisionId);\n\t\tconst mode: TimeoutMode = record.redLine ? \"halt\" : \"adjudicate\";\n\t\tconst run = applyDecisionTimeout(state, { decisionId, mode }, Date.now());\n\t\tpersist(run.state, run.transitions);\n\t\tif (disposed) return; // 已关闭:落账保留,放弃后续派发\n\t\tif (mode === \"halt\") {\n\t\t\tawait injectNotice(run.state.decisions.find((item) => item.id === decisionId) ?? record);\n\t\t\treturn;\n\t\t}\n\t\t// 裁决链(§5):scheduler 缺失、submit/drain 抛错、协议失败一律按 halted\n\t\t// 通知收尾——不重试、不静默降级。\n\t\tconst caller = requireSchedulerCaller(api);\n\t\tconst outcome =\n\t\t\tcaller === undefined\n\t\t\t\t? ({\n\t\t\t\t\t\tok: false,\n\t\t\t\t\t\tcode: \"unavailable\",\n\t\t\t\t\t\tdetail: \"agent-forge.agent-task-scheduler capability is not available\",\n\t\t\t\t\t} as const)\n\t\t\t\t: await runAdjudication(caller, {\n\t\t\t\t\t\tdecisionId: record.id,\n\t\t\t\t\t\tquestion: record.question,\n\t\t\t\t\t\toptions: record.options,\n\t\t\t\t\t\tcontextDigest: record.contextDigest,\n\t\t\t\t\t\triskClass: record.riskClass,\n\t\t\t\t\t});\n\t\tif (disposed) return; // 已关闭:放弃裁决落账与注入\n\t\tconst adjudicating = findDecision(state, decisionId);\n\t\tif (adjudicating === undefined)\n\t\t\tthrow new DecisionError(\"not-found\", `decision vanished during adjudication: ${decisionId}`);\n\t\tif (!outcome.ok) {\n\t\t\tconst failed = applyAdjudicationFailure(\n\t\t\t\tstate,\n\t\t\t\t{ decisionId, code: outcome.code as AdjudicationFailureCode, detail: outcome.detail },\n\t\t\t\tDate.now(),\n\t\t\t);\n\t\t\tpersist(failed.state, failed.transitions);\n\t\t\tawait injectNotice(\n\t\t\t\tfailed.state.decisions.find((item) => item.id === decisionId) ?? adjudicating,\n\t\t\t\toutcome.detail,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst verdictRun = recordVerdict(state, { decisionId, verdict: outcome.verdict }, Date.now());\n\t\tconst withVerdict = persist(verdictRun.state, verdictRun.transitions);\n\t\tconst decided = findDecision(withVerdict, decisionId);\n\t\tif (decided === undefined) throw new DecisionError(\"not-found\", `decision vanished after verdict: ${decisionId}`);\n\t\tawait inject(\"decision.notice\", adjudicationNoticeMessage(decided), true);\n\t};\n\n\tconst recordTimeoutFailure = (error: unknown): void => {\n\t\t// 计时路径没有调用方可观察异常:保留原始错误供 /decision 诊断与\n\t\t// 测试断言,不吞不改。\n\t\ttimeoutFailures.push(error);\n\t};\n\n\tconst timerFired = (decisionId: string): void => {\n\t\tvoid handleTimeout(decisionId).catch(recordTimeoutFailure);\n\t};\n\n\tconst armTimer = (decisionId: string, remainingMs?: number): void => {\n\t\tclearTimer(decisionId);\n\t\ttimers.set(\n\t\t\tdecisionId,\n\t\t\tsetTimeout(() => timerFired(decisionId), remainingMs ?? effectiveTimeoutMs),\n\t\t);\n\t};\n\n\t/**\n\t * 页面目标决策从 state 派生:\n\t * 最新的 asked 优先;否则最近一条(超时降级/终态记录保持可查看)。\n\t * 重载后同一 URL 继续可答旧决策,不再依赖一次性捕获。\n\t */\n\tconst pageRecord = (): DecisionRecord | undefined =>\n\t\tstate.decisions.find((record) => record.status === \"asked\") ?? state.decisions.at(-1);\n\n\tconst ensureServer = async (): Promise<DecisionServer> => {\n\t\t// 页面生命周期(alignment 走查 2026-10-04 同款):服务随第一个\n\t\t// decision_ask 启动后常驻到插件 dispose(会话关闭);下一次问询在\n\t\t// 同一 URL 上覆盖内容。\n\t\tif (server) return server;\n\t\tserver = await startDecisionServer(\n\t\t\t{\n\t\t\t\tgetState: () => {\n\t\t\t\t\tconst record = pageRecord();\n\t\t\t\t\treturn record === undefined ? undefined : pageView(record, effectiveTimeoutMs);\n\t\t\t\t},\n\t\t\t\tonAnswer: (post: AnswerPost) => handleAnswerPost(post),\n\t\t\t},\n\t\t\t{ port: options.serverPort },\n\t\t);\n\t\treturn server;\n\t};\n\n\t/** Page POST (设计 §7): validate the choice, inject `decision.answered`. */\n\tconst handleAnswerPost = async (post: AnswerPost): Promise<{ status: number; body: unknown }> => {\n\t\tconst record = pageRecord();\n\t\tif (record === undefined) return { status: 409, body: { error: \"no decision awaiting an answer\" } };\n\t\t// 双 POST 幂等:同一决策的作答只注入一次,重复提交直接返回。\n\t\tconst deliveredChoice = deliveredAnswers.get(record.id);\n\t\tif (deliveredChoice !== undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 200,\n\t\t\t\tbody: { ok: true, delivered: true, idempotent: true, decisionId: record.id, choice: deliveredChoice },\n\t\t\t};\n\t\t}\n\t\tif (record.status !== \"asked\") {\n\t\t\treturn {\n\t\t\t\tstatus: 409,\n\t\t\t\tbody: { code: \"not-active\", error: `decision is not active (status ${record.status}): ${record.id}` },\n\t\t\t};\n\t\t}\n\t\tif (!Number.isInteger(post.choice)) {\n\t\t\treturn { status: 400, body: { code: \"invalid-input\", error: \"choice must be an option index\" } };\n\t\t}\n\t\tconst choice = post.choice as number;\n\t\tif (choice < 0 || choice >= record.options.length) {\n\t\t\treturn {\n\t\t\t\tstatus: 400,\n\t\t\t\tbody: { code: \"choice-out-of-range\", error: `choice must be within 0..${record.options.length - 1}` },\n\t\t\t};\n\t\t}\n\t\tlet note: string | undefined;\n\t\tif (post.note !== undefined && post.note !== null && post.note !== \"\") {\n\t\t\tif (typeof post.note !== \"string\") {\n\t\t\t\treturn { status: 400, body: { code: \"invalid-input\", error: \"note must be a string\" } };\n\t\t\t}\n\t\t\tif (post.note.length > DECISION_LIMITS.noteMaxLength) {\n\t\t\t\treturn {\n\t\t\t\t\tstatus: 400,\n\t\t\t\t\tbody: { code: \"invalid-input\", error: `note exceeds ${DECISION_LIMITS.noteMaxLength} characters` },\n\t\t\t\t};\n\t\t\t}\n\t\t\tnote = post.note;\n\t\t}\n\t\ttry {\n\t\t\tawait inject(\"decision.answered\", answeredMessage(record, choice, note), false);\n\t\t\tdeliveredAnswers.set(record.id, choice);\n\t\t\t// 作答送达即撤销超时计时器:否则窗口末端作答会在模型\n\t\t\t// resolve 前被计时器触发的裁决链推翻。\n\t\t\tclearTimer(record.id);\n\t\t\treturn { status: 200, body: { ok: true, delivered: true, decisionId: record.id, choice } };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tstatus: 503,\n\t\t\t\tbody: {\n\t\t\t\t\terror: `answer delivery failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\tretry: true,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t};\n\n\tconst runAsk = async (input: Record<string, unknown>): Promise<Record<string, unknown>> => {\n\t\t// 作答通道依赖注入(设计 §2/§7):sendMessage 缺失在落账前显式失败,\n\t\t// 不留下一个永远等不到作答的决策(alignment 两处降级同款)。\n\t\tif (!api.session?.sendMessage) {\n\t\t\tthrow new DecisionError(\n\t\t\t\t\"invalid-input\",\n\t\t\t\t\"host session does not expose sendMessage; decision answers cannot be delivered on this host\",\n\t\t\t);\n\t\t}\n\t\t// 决策 id 由插件生成(设计 §4.1 输入没有 id 字段):模型拿到的\n\t\t// decisionId 是本工具返回值,不自己起名。\n\t\tconst askInput: DecisionAskInput = {\n\t\t\tid: `decision-${randomUUID().replace(/-/g, \"\").slice(0, 12)}`,\n\t\t\tquestion: input.question as string,\n\t\t\toptions: input.options as DecisionAskInput[\"options\"],\n\t\t\tcontextDigest: input.context_digest as string,\n\t\t\triskClass: input.risk_class as DecisionAskInput[\"riskClass\"],\n\t\t};\n\t\t// 先懒启动页面(失败不落账),再落 asked 快照与计时器,最后立即返回。\n\t\t// 已有 asked 决策时 applyDecisionAsk 结构化拒绝(decision-active-exists),\n\t\t// 服务已在同一 URL 上服务该决策。\n\t\tconst running = await ensureServer();\n\t\tconst run = applyDecisionAsk(state, askInput, Date.now());\n\t\tpersist(run.state, run.transitions);\n\t\tarmTimer(askInput.id);\n\t\tconst record = findDecision(state, askInput.id) as DecisionRecord;\n\t\treturn {\n\t\t\tdecisionId: record.id,\n\t\t\turl: running.url,\n\t\t\ttimeoutMs: effectiveTimeoutMs,\n\t\t\triskClass: record.riskClass,\n\t\t\tredLine: record.redLine,\n\t\t};\n\t};\n\n\tconst askTool = api.registerTool({\n\t\tname: \"decision_ask\",\n\t\tlabel: \"Ask a fork decision\",\n\t\tdescription:\n\t\t\t\"Ask the user to decide a fork (2..4 closed options): returns a decision id, a local confirmation-page URL and progress facts immediately. Non-blocking: the answer arrives later as a decision.answered message; on timeout reversible forks are adjudicated independently and irreversible ones halt\",\n\t\tparameters: askSchema,\n\t\tpromptGuidelines: PROMPT_GUIDELINES,\n\t\treadonlySafe: true,\n\t\texecute: async (first: unknown, second?: unknown) => runAsk(toolInput(first, second)),\n\t});\n\n\tconst resolveTool = api.registerTool({\n\t\tname: \"decision_resolve\",\n\t\tlabel: \"Resolve a decision\",\n\t\tdescription:\n\t\t\t'Record the answer that closed a decision_ask fork: source \"user\" for a user reply (from the page or TUI text), source \"adjudication\" only to book an injected adjudication verdict (must match it; fabricating one is rejected)',\n\t\tparameters: resolveSchema,\n\t\tpromptGuidelines: PROMPT_GUIDELINES,\n\t\treadonlySafe: true,\n\t\texecute: async (first: unknown, second?: unknown) => {\n\t\t\tconst input = toolInput(first, second);\n\t\t\tconst run = applyDecisionAnswer(\n\t\t\t\tstate,\n\t\t\t\t{\n\t\t\t\t\tdecisionId: typeof input.decisionId === \"string\" ? input.decisionId : \"\",\n\t\t\t\t\tchoice: input.choice as number,\n\t\t\t\t\tsource: input.source as \"user\" | \"adjudication\",\n\t\t\t\t\tnote: input.note as string | undefined,\n\t\t\t\t},\n\t\t\t\tDate.now(),\n\t\t\t);\n\t\t\tpersist(run.state, run.transitions);\n\t\t\t// 决策已终态:超时计时器随之撤销。\n\t\t\tclearTimer(typeof input.decisionId === \"string\" ? input.decisionId : \"\");\n\t\t\tconst record = findDecision(\n\t\t\t\tstate,\n\t\t\t\ttypeof input.decisionId === \"string\" ? input.decisionId : \"\",\n\t\t\t) as DecisionRecord;\n\t\t\treturn {\n\t\t\t\tdecisionId: record.id,\n\t\t\t\tstatus: record.status,\n\t\t\t\tresolvedBy: record.resolvedBy,\n\t\t\t\tchoice: record.choice,\n\t\t\t\toption: record.choice === undefined ? undefined : record.options[record.choice]?.label,\n\t\t\t};\n\t\t},\n\t});\n\n\tconst command = api.registerCommand({\n\t\tname: \"decision\",\n\t\tdescription:\n\t\t\t\"Decision audit: `log [N]` lists the recent forks (id, question, status, resolved_by, choice), `show <id>` prints the full record including the adjudication verdict, `cancel <id>` cancels an active fork\",\n\t\texecute: async (args: string): Promise<CapabilityCommandResult> => {\n\t\t\ttry {\n\t\t\t\tconst parts = args\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split(/\\s+/)\n\t\t\t\t\t.filter((part) => part !== \"\");\n\t\t\t\tif (parts.length === 0) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\tmessage: \"Usage: /decision log [N] | /decision show <id> | /decision cancel <id>\",\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (parts[0] === \"log\") {\n\t\t\t\t\tconst count = Number.parseInt(parts[1] ?? \"20\", 10);\n\t\t\t\t\tconst lines = [listLines(loadState(api), Number.isFinite(count) && count > 0 ? count : 20)];\n\t\t\t\t\t// 超时作业的注入失败在这里可见(原始错误保留,不吞不改)。\n\t\t\t\t\tfor (const failure of timeoutFailures) {\n\t\t\t\t\t\tlines.push(`timeout-job failure: ${failure instanceof Error ? failure.message : String(failure)}`);\n\t\t\t\t\t}\n\t\t\t\t\treturn { status: \"success\", message: lines.join(\"\\n\") };\n\t\t\t\t}\n\t\t\t\tif (parts[0] === \"show\") {\n\t\t\t\t\tconst id = parts[1] ?? \"\";\n\t\t\t\t\tconst record = findDecision(loadState(api), id);\n\t\t\t\t\tif (!record) return { status: \"error\", message: `unknown decision: ${id || \"(none given)\"}` };\n\t\t\t\t\treturn { status: \"success\", message: showLines(record, loadTransitions(api)) };\n\t\t\t\t}\n\t\t\t\tif (parts[0] === \"cancel\") {\n\t\t\t\t\tconst id = parts[1] ?? \"\";\n\t\t\t\t\tconst run = applyDecisionCancel(state, { decisionId: id }, Date.now());\n\t\t\t\t\tpersist(run.state, run.transitions);\n\t\t\t\t\tclearTimer(id);\n\t\t\t\t\treturn { status: \"success\", message: `cancelled: ${id}` };\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\tmessage: \"Usage: /decision log [N] | /decision show <id> | /decision cancel <id>\",\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn { status: \"error\", message: error instanceof Error ? error.message : String(error) };\n\t\t\t}\n\t\t},\n\t});\n\n\tconst stopServer = (): void => {\n\t\tconst stopping = server;\n\t\tserver = undefined;\n\t\tif (stopping) void stopping.stop().catch(() => undefined);\n\t};\n\n\t// 会话重载重臂:装载时对仍处 asked 的决策按剩余时间重臂计时器\n\t//(createdAt + timeoutMs - now);已过期(<=0)立即走与正常超时同一语义\n\t// 的降级链,不留一个静默失效的窗口。\n\tfor (const reloaded of state.decisions) {\n\t\tif (reloaded.status !== \"asked\") continue;\n\t\tconst remaining = reloaded.createdAt + effectiveTimeoutMs - Date.now();\n\t\tif (remaining <= 0) timerFired(reloaded.id);\n\t\telse armTimer(reloaded.id, remaining);\n\t}\n\n\t// The command registration doubles as the teardown hook for the local\n\t// confirmation server and the pending timeout timers (plugin dispose must\n\t// release the port and must not fire adjudications into a closed session).\n\tconst commandWithTeardown: DisposableRegistration = {\n\t\tid: command.id,\n\t\tkind: command.kind,\n\t\tdispose: () => {\n\t\t\tdisposed = true; // 先置位,在途超时作业在 await 点放弃注入\n\t\t\tvoid command.dispose();\n\t\t\tfor (const decisionId of [...timers.keys()]) clearTimer(decisionId);\n\t\t\tstopServer();\n\t\t},\n\t};\n\n\treturn [askTool, resolveTool, commandWithTeardown];\n}\n"]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data model of the decision-escalation capability plugin
|
|
3
|
+
* (`docs/design/决策升级插件设计.md` §3/§4/§6). This module declares shapes
|
|
4
|
+
* only — every conversion rule lives in `engine.ts`, the adjudication chain
|
|
5
|
+
* lives in `adjudication.ts`, and every host-facing side effect (entries,
|
|
6
|
+
* events, injection, HTTP, timers) lives in `index.ts` / `http-server.ts`.
|
|
7
|
+
*/
|
|
8
|
+
/** L1/L2 self-assessed risk class (§3): only picks single-adjudicator vs adversarial on timeout. */
|
|
9
|
+
export type DecisionRiskClass = "routine" | "significant";
|
|
10
|
+
/** Per-option reversibility declared by the model; a missing field is a redline (§3). */
|
|
11
|
+
export type DecisionReversibility = "reversible" | "irreversible";
|
|
12
|
+
/**
|
|
13
|
+
* Escalation level (§3). "redline" is engine-derived from the options
|
|
14
|
+
* (any `irreversible` or missing reversibility); the other two mirror the
|
|
15
|
+
* model's `risk_class` self-assessment. L0 never enters this plugin.
|
|
16
|
+
*/
|
|
17
|
+
export type DecisionLevel = DecisionRiskClass | "redline";
|
|
18
|
+
export interface DecisionOption {
|
|
19
|
+
label: string;
|
|
20
|
+
description: string;
|
|
21
|
+
consequences: string;
|
|
22
|
+
/** 缺失按红线处理(保守默认,§3)——类型上允许缺席以保持留痕保真。 */
|
|
23
|
+
reversibility?: DecisionReversibility;
|
|
24
|
+
}
|
|
25
|
+
/** Adjudication verdict protocol (§5): the only output shape subagents may emit. */
|
|
26
|
+
export interface AdjudicationVerdict {
|
|
27
|
+
choice: number;
|
|
28
|
+
confidence: "high" | "low";
|
|
29
|
+
rationale: string;
|
|
30
|
+
keyEvidence: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Decision lifecycle status. "asked" waits for user or timeout; "adjudicating"
|
|
34
|
+
* covers from `timed-out.adjudicating` until the model resolves the injected
|
|
35
|
+
* verdict; "halted" / "unavailable" / "unparseable" / "answered" /
|
|
36
|
+
* "cancelled" are terminal (§5, §6).
|
|
37
|
+
*/
|
|
38
|
+
export type DecisionStatus = "asked" | "adjudicating" | "halted" | "unavailable" | "unparseable" | "answered" | "cancelled";
|
|
39
|
+
/** Append-only audit vocabulary (§6) — exactly these eight events. */
|
|
40
|
+
export type DecisionTransitionEvent = "asked" | "answered.user" | "answered.adjudication" | "timed-out.halted" | "timed-out.adjudicating" | "adjudication.unavailable" | "adjudication.unparseable" | "cancelled";
|
|
41
|
+
export interface DecisionTransitionEntry {
|
|
42
|
+
decisionId: string;
|
|
43
|
+
event: DecisionTransitionEvent;
|
|
44
|
+
reason: {
|
|
45
|
+
code: string;
|
|
46
|
+
detail?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Anchors the adjacent decision.state snapshot. */
|
|
49
|
+
revision: number;
|
|
50
|
+
}
|
|
51
|
+
export interface DecisionRecord {
|
|
52
|
+
id: string;
|
|
53
|
+
question: string;
|
|
54
|
+
options: DecisionOption[];
|
|
55
|
+
/** Symmetric decision brief (§4.1): support/opposition evidence per option. */
|
|
56
|
+
contextDigest: string;
|
|
57
|
+
riskClass: DecisionRiskClass;
|
|
58
|
+
/** Engine-derived redline: any option irreversible or missing reversibility (§3). */
|
|
59
|
+
redLine: boolean;
|
|
60
|
+
status: DecisionStatus;
|
|
61
|
+
revision: number;
|
|
62
|
+
/** Creation time (epoch ms) supplied by the caller — the engine stays clock-free. */
|
|
63
|
+
createdAt: number;
|
|
64
|
+
resolvedBy?: "user" | "adjudication";
|
|
65
|
+
choice?: number;
|
|
66
|
+
note?: string;
|
|
67
|
+
/** Full adjudication record, stored when the chain succeeded (§5 留痕). */
|
|
68
|
+
verdict?: AdjudicationVerdict;
|
|
69
|
+
}
|
|
70
|
+
/** Versioned full snapshot (设计 §6): `{ version: 1, decisions }` — the single rebuild source. */
|
|
71
|
+
export interface DecisionState {
|
|
72
|
+
version: 1;
|
|
73
|
+
decisions: DecisionRecord[];
|
|
74
|
+
}
|
|
75
|
+
/** Page projection (设计 §7): everything the fixed confirmation template renders. */
|
|
76
|
+
export interface DecisionPageView {
|
|
77
|
+
decisionId: string;
|
|
78
|
+
question: string;
|
|
79
|
+
options: DecisionOption[];
|
|
80
|
+
contextDigest: string;
|
|
81
|
+
riskClass: DecisionRiskClass;
|
|
82
|
+
redLine: boolean;
|
|
83
|
+
status: DecisionStatus;
|
|
84
|
+
/** Set when status is "answered" — the page shows what was chosen. */
|
|
85
|
+
answeredChoice?: number;
|
|
86
|
+
/** Effective timeout (factory default or config override) shown as progress facts. */
|
|
87
|
+
timeoutMs: number;
|
|
88
|
+
revision: number;
|
|
89
|
+
}
|
|
90
|
+
/** Error codes thrown by the engine; index.ts lets them surface as tool errors verbatim. */
|
|
91
|
+
export type DecisionErrorCode = "invalid-id" | "invalid-input" | "invalid-option" | "not-found" | "not-active" | "choice-out-of-range" | "adjudication-not-recorded" | "adjudication-choice-mismatch" | "decision-active-exists" | "state-limit-reached";
|
|
92
|
+
export declare class DecisionError extends Error {
|
|
93
|
+
readonly code: DecisionErrorCode;
|
|
94
|
+
constructor(code: DecisionErrorCode, message: string);
|
|
95
|
+
}
|
|
96
|
+
/** Hard bounds: decision state enters session entries, keep it bounded. */
|
|
97
|
+
export declare const DECISION_LIMITS: {
|
|
98
|
+
readonly questionMaxLength: 2048;
|
|
99
|
+
readonly labelMaxLength: 200;
|
|
100
|
+
readonly descriptionMaxLength: 2048;
|
|
101
|
+
readonly consequencesMaxLength: 2048;
|
|
102
|
+
readonly contextDigestMaxLength: 8192;
|
|
103
|
+
readonly noteMaxLength: 2048;
|
|
104
|
+
readonly optionsMin: 2;
|
|
105
|
+
readonly optionsMax: 4;
|
|
106
|
+
readonly verdictRationaleMaxLength: 8192;
|
|
107
|
+
readonly verdictEvidenceMax: 16;
|
|
108
|
+
readonly verdictEvidenceItemMaxLength: 512;
|
|
109
|
+
/** Rolling retention for decision records (bounded session-entry snapshots). */
|
|
110
|
+
readonly decisionsMax: 50;
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qGAAoG;AACpG,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1D,0FAAyF;AACzF,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,cAAc,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,uGAAwC;IACxC,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACtC;AAED,qFAAoF;AACpF,MAAM,WAAW,mBAAmB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACvB,OAAO,GACP,cAAc,GACd,QAAQ,GACR,aAAa,GACb,aAAa,GACb,UAAU,GACV,WAAW,CAAC;AAEf,yEAAsE;AACtE,MAAM,MAAM,uBAAuB,GAChC,OAAO,GACP,eAAe,GACf,uBAAuB,GACvB,kBAAkB,GAClB,wBAAwB,GACxB,0BAA0B,GAC1B,0BAA0B,GAC1B,WAAW,CAAC;AAEf,MAAM,WAAW,uBAAuB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,uBAAuB,CAAC;IAC/B,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE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B,8BAA8B,GAC9B,wBAAwB,GACxB,qBAAqB,CAAC;AAEzB,qBAAa,aAAc,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAEjC,YAAY,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAInD;CACD;AAED,2EAA2E;AAC3E,eAAO,MAAM,eAAe;;;;;;;;;;;;IAY3B,gFAAgF;;CAEvE,CAAC","sourcesContent":["/**\n * Data model of the decision-escalation capability plugin\n * (`docs/design/决策升级插件设计.md` §3/§4/§6). This module declares shapes\n * only — every conversion rule lives in `engine.ts`, the adjudication chain\n * lives in `adjudication.ts`, and every host-facing side effect (entries,\n * events, injection, HTTP, timers) lives in `index.ts` / `http-server.ts`.\n */\n\n/** L1/L2 self-assessed risk class (§3): only picks single-adjudicator vs adversarial on timeout. */\nexport type DecisionRiskClass = \"routine\" | \"significant\";\n\n/** Per-option reversibility declared by the model; a missing field is a redline (§3). */\nexport type DecisionReversibility = \"reversible\" | \"irreversible\";\n\n/**\n * Escalation level (§3). \"redline\" is engine-derived from the options\n * (any `irreversible` or missing reversibility); the other two mirror the\n * model's `risk_class` self-assessment. L0 never enters this plugin.\n */\nexport type DecisionLevel = DecisionRiskClass | \"redline\";\n\nexport interface DecisionOption {\n\tlabel: string;\n\tdescription: string;\n\tconsequences: string;\n\t/** 缺失按红线处理(保守默认,§3)——类型上允许缺席以保持留痕保真。 */\n\treversibility?: DecisionReversibility;\n}\n\n/** Adjudication verdict protocol (§5): the only output shape subagents may emit. */\nexport interface AdjudicationVerdict {\n\tchoice: number;\n\tconfidence: \"high\" | \"low\";\n\trationale: string;\n\tkeyEvidence: string[];\n}\n\n/**\n * Decision lifecycle status. \"asked\" waits for user or timeout; \"adjudicating\"\n * covers from `timed-out.adjudicating` until the model resolves the injected\n * verdict; \"halted\" / \"unavailable\" / \"unparseable\" / \"answered\" /\n * \"cancelled\" are terminal (§5, §6).\n */\nexport type DecisionStatus =\n\t| \"asked\"\n\t| \"adjudicating\"\n\t| \"halted\"\n\t| \"unavailable\"\n\t| \"unparseable\"\n\t| \"answered\"\n\t| \"cancelled\";\n\n/** Append-only audit vocabulary (§6) — exactly these eight events. */\nexport type DecisionTransitionEvent =\n\t| \"asked\"\n\t| \"answered.user\"\n\t| \"answered.adjudication\"\n\t| \"timed-out.halted\"\n\t| \"timed-out.adjudicating\"\n\t| \"adjudication.unavailable\"\n\t| \"adjudication.unparseable\"\n\t| \"cancelled\";\n\nexport interface DecisionTransitionEntry {\n\tdecisionId: string;\n\tevent: DecisionTransitionEvent;\n\treason: { code: string; detail?: string };\n\t/** Anchors the adjacent decision.state snapshot. */\n\trevision: number;\n}\n\nexport interface DecisionRecord {\n\tid: string;\n\tquestion: string;\n\toptions: DecisionOption[];\n\t/** Symmetric decision brief (§4.1): support/opposition evidence per option. */\n\tcontextDigest: string;\n\triskClass: DecisionRiskClass;\n\t/** Engine-derived redline: any option irreversible or missing reversibility (§3). */\n\tredLine: boolean;\n\tstatus: DecisionStatus;\n\trevision: number;\n\t/** Creation time (epoch ms) supplied by the caller — the engine stays clock-free. */\n\tcreatedAt: number;\n\tresolvedBy?: \"user\" | \"adjudication\";\n\tchoice?: number;\n\tnote?: string;\n\t/** Full adjudication record, stored when the chain succeeded (§5 留痕). */\n\tverdict?: AdjudicationVerdict;\n}\n\n/** Versioned full snapshot (设计 §6): `{ version: 1, decisions }` — the single rebuild source. */\nexport interface DecisionState {\n\tversion: 1;\n\tdecisions: DecisionRecord[];\n}\n\n/** Page projection (设计 §7): everything the fixed confirmation template renders. */\nexport interface DecisionPageView {\n\tdecisionId: string;\n\tquestion: string;\n\toptions: DecisionOption[];\n\tcontextDigest: string;\n\triskClass: DecisionRiskClass;\n\tredLine: boolean;\n\tstatus: DecisionStatus;\n\t/** Set when status is \"answered\" — the page shows what was chosen. */\n\tansweredChoice?: number;\n\t/** Effective timeout (factory default or config override) shown as progress facts. */\n\ttimeoutMs: number;\n\trevision: number;\n}\n\n/** Error codes thrown by the engine; index.ts lets them surface as tool errors verbatim. */\nexport type DecisionErrorCode =\n\t| \"invalid-id\"\n\t| \"invalid-input\"\n\t| \"invalid-option\"\n\t| \"not-found\"\n\t| \"not-active\"\n\t| \"choice-out-of-range\"\n\t| \"adjudication-not-recorded\"\n\t| \"adjudication-choice-mismatch\"\n\t| \"decision-active-exists\"\n\t| \"state-limit-reached\";\n\nexport class DecisionError extends Error {\n\treadonly code: DecisionErrorCode;\n\n\tconstructor(code: DecisionErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"DecisionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Hard bounds: decision state enters session entries, keep it bounded. */\nexport const DECISION_LIMITS = {\n\tquestionMaxLength: 2048,\n\tlabelMaxLength: 200,\n\tdescriptionMaxLength: 2048,\n\tconsequencesMaxLength: 2048,\n\tcontextDigestMaxLength: 8192,\n\tnoteMaxLength: 2048,\n\toptionsMin: 2,\n\toptionsMax: 4,\n\tverdictRationaleMaxLength: 8192,\n\tverdictEvidenceMax: 16,\n\tverdictEvidenceItemMaxLength: 512,\n\t/** Rolling retention for decision records (bounded session-entry snapshots). */\n\tdecisionsMax: 50,\n} as const;\n"]}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data model of the decision-escalation capability plugin
|
|
3
|
+
* (`docs/design/决策升级插件设计.md` §3/§4/§6). This module declares shapes
|
|
4
|
+
* only — every conversion rule lives in `engine.ts`, the adjudication chain
|
|
5
|
+
* lives in `adjudication.ts`, and every host-facing side effect (entries,
|
|
6
|
+
* events, injection, HTTP, timers) lives in `index.ts` / `http-server.ts`.
|
|
7
|
+
*/
|
|
8
|
+
export class DecisionError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
constructor(code, message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "DecisionError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Hard bounds: decision state enters session entries, keep it bounded. */
|
|
17
|
+
export const DECISION_LIMITS = {
|
|
18
|
+
questionMaxLength: 2048,
|
|
19
|
+
labelMaxLength: 200,
|
|
20
|
+
descriptionMaxLength: 2048,
|
|
21
|
+
consequencesMaxLength: 2048,
|
|
22
|
+
contextDigestMaxLength: 8192,
|
|
23
|
+
noteMaxLength: 2048,
|
|
24
|
+
optionsMin: 2,
|
|
25
|
+
optionsMax: 4,
|
|
26
|
+
verdictRationaleMaxLength: 8192,
|
|
27
|
+
verdictEvidenceMax: 16,
|
|
28
|
+
verdictEvidenceItemMaxLength: 512,
|
|
29
|
+
/** Rolling retention for decision records (bounded session-entry snapshots). */
|
|
30
|
+
decisionsMax: 50,
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwHH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC9B,IAAI,CAAoB;IAEjC,YAAY,IAAuB,EAAE,OAAe,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAAA,CACjB;CACD;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,GAAG;IACnB,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,CAAC;IACb,yBAAyB,EAAE,IAAI;IAC/B,kBAAkB,EAAE,EAAE;IACtB,4BAA4B,EAAE,GAAG;IACjC,gFAAgF;IAChF,YAAY,EAAE,EAAE;CACP,CAAC","sourcesContent":["/**\n * Data model of the decision-escalation capability plugin\n * (`docs/design/决策升级插件设计.md` §3/§4/§6). This module declares shapes\n * only — every conversion rule lives in `engine.ts`, the adjudication chain\n * lives in `adjudication.ts`, and every host-facing side effect (entries,\n * events, injection, HTTP, timers) lives in `index.ts` / `http-server.ts`.\n */\n\n/** L1/L2 self-assessed risk class (§3): only picks single-adjudicator vs adversarial on timeout. */\nexport type DecisionRiskClass = \"routine\" | \"significant\";\n\n/** Per-option reversibility declared by the model; a missing field is a redline (§3). */\nexport type DecisionReversibility = \"reversible\" | \"irreversible\";\n\n/**\n * Escalation level (§3). \"redline\" is engine-derived from the options\n * (any `irreversible` or missing reversibility); the other two mirror the\n * model's `risk_class` self-assessment. L0 never enters this plugin.\n */\nexport type DecisionLevel = DecisionRiskClass | \"redline\";\n\nexport interface DecisionOption {\n\tlabel: string;\n\tdescription: string;\n\tconsequences: string;\n\t/** 缺失按红线处理(保守默认,§3)——类型上允许缺席以保持留痕保真。 */\n\treversibility?: DecisionReversibility;\n}\n\n/** Adjudication verdict protocol (§5): the only output shape subagents may emit. */\nexport interface AdjudicationVerdict {\n\tchoice: number;\n\tconfidence: \"high\" | \"low\";\n\trationale: string;\n\tkeyEvidence: string[];\n}\n\n/**\n * Decision lifecycle status. \"asked\" waits for user or timeout; \"adjudicating\"\n * covers from `timed-out.adjudicating` until the model resolves the injected\n * verdict; \"halted\" / \"unavailable\" / \"unparseable\" / \"answered\" /\n * \"cancelled\" are terminal (§5, §6).\n */\nexport type DecisionStatus =\n\t| \"asked\"\n\t| \"adjudicating\"\n\t| \"halted\"\n\t| \"unavailable\"\n\t| \"unparseable\"\n\t| \"answered\"\n\t| \"cancelled\";\n\n/** Append-only audit vocabulary (§6) — exactly these eight events. */\nexport type DecisionTransitionEvent =\n\t| \"asked\"\n\t| \"answered.user\"\n\t| \"answered.adjudication\"\n\t| \"timed-out.halted\"\n\t| \"timed-out.adjudicating\"\n\t| \"adjudication.unavailable\"\n\t| \"adjudication.unparseable\"\n\t| \"cancelled\";\n\nexport interface DecisionTransitionEntry {\n\tdecisionId: string;\n\tevent: DecisionTransitionEvent;\n\treason: { code: string; detail?: string };\n\t/** Anchors the adjacent decision.state snapshot. */\n\trevision: number;\n}\n\nexport interface DecisionRecord {\n\tid: string;\n\tquestion: string;\n\toptions: DecisionOption[];\n\t/** Symmetric decision brief (§4.1): support/opposition evidence per option. */\n\tcontextDigest: string;\n\triskClass: DecisionRiskClass;\n\t/** Engine-derived redline: any option irreversible or missing reversibility (§3). */\n\tredLine: boolean;\n\tstatus: DecisionStatus;\n\trevision: number;\n\t/** Creation time (epoch ms) supplied by the caller — the engine stays clock-free. */\n\tcreatedAt: number;\n\tresolvedBy?: \"user\" | \"adjudication\";\n\tchoice?: number;\n\tnote?: string;\n\t/** Full adjudication record, stored when the chain succeeded (§5 留痕). */\n\tverdict?: AdjudicationVerdict;\n}\n\n/** Versioned full snapshot (设计 §6): `{ version: 1, decisions }` — the single rebuild source. */\nexport interface DecisionState {\n\tversion: 1;\n\tdecisions: DecisionRecord[];\n}\n\n/** Page projection (设计 §7): everything the fixed confirmation template renders. */\nexport interface DecisionPageView {\n\tdecisionId: string;\n\tquestion: string;\n\toptions: DecisionOption[];\n\tcontextDigest: string;\n\triskClass: DecisionRiskClass;\n\tredLine: boolean;\n\tstatus: DecisionStatus;\n\t/** Set when status is \"answered\" — the page shows what was chosen. */\n\tansweredChoice?: number;\n\t/** Effective timeout (factory default or config override) shown as progress facts. */\n\ttimeoutMs: number;\n\trevision: number;\n}\n\n/** Error codes thrown by the engine; index.ts lets them surface as tool errors verbatim. */\nexport type DecisionErrorCode =\n\t| \"invalid-id\"\n\t| \"invalid-input\"\n\t| \"invalid-option\"\n\t| \"not-found\"\n\t| \"not-active\"\n\t| \"choice-out-of-range\"\n\t| \"adjudication-not-recorded\"\n\t| \"adjudication-choice-mismatch\"\n\t| \"decision-active-exists\"\n\t| \"state-limit-reached\";\n\nexport class DecisionError extends Error {\n\treadonly code: DecisionErrorCode;\n\n\tconstructor(code: DecisionErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"DecisionError\";\n\t\tthis.code = code;\n\t}\n}\n\n/** Hard bounds: decision state enters session entries, keep it bounded. */\nexport const DECISION_LIMITS = {\n\tquestionMaxLength: 2048,\n\tlabelMaxLength: 200,\n\tdescriptionMaxLength: 2048,\n\tconsequencesMaxLength: 2048,\n\tcontextDigestMaxLength: 8192,\n\tnoteMaxLength: 2048,\n\toptionsMin: 2,\n\toptionsMax: 4,\n\tverdictRationaleMaxLength: 8192,\n\tverdictEvidenceMax: 16,\n\tverdictEvidenceItemMaxLength: 512,\n\t/** Rolling retention for decision records (bounded session-entry snapshots). */\n\tdecisionsMax: 50,\n} as const;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@ai-agent-forge/plugin-decision-escalation",
|
|
3
|
+
"version": "0.88.15",
|
|
4
|
+
"description": "Decision escalation capability plugin for Agent Forge (formal fork-decision ask with a local confirmation page, timeout de-escalation to an independent adjudication chain, and an irreversible redline)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"agent-forge.json",
|
|
17
|
+
"plugin.json",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "shx rm -rf dist",
|
|
22
|
+
"build": "tsgo -p tsconfig.build.json",
|
|
23
|
+
"test": "vitest --run",
|
|
24
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
25
|
+
"test:coverage": "vitest --run --coverage"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"agent-forge",
|
|
29
|
+
"plugin",
|
|
30
|
+
"decision-escalation"
|
|
31
|
+
],
|
|
32
|
+
"author": "Agent Forge contributors",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/agent-forge/agent-forge.git",
|
|
37
|
+
"directory": "plugins/decision-escalation"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/agent-forge/agent-forge/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/agent-forge/agent-forge#readme",
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22.19.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"typebox": "1.3.27",
|
|
48
|
+
"@ai-agent-forge/plugin-sdk": "^0.88.15"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"shx": "0.3.4",
|
|
52
|
+
"vitest": "4.1.11"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/plugin.json
ADDED