Archived
手改是**兜 AI 的错**的那一手 —— 这一轮把它从「摆在那儿但落不了地」做成真的: 件上就地改 · 保存**按地址收**,不看当下那张卡:载荷从前借道工单的 `blocks[i]` 取列名, 于是熔断卡(没有 blocks)在屏上时,人补的那一格一个字都送不出去 —— 而他要补的恰恰是把这一单卡住的那个必填格。授权面改由活动清单的台账声明把关。 · **能增删行**:错不止「这一格填错了」,还有「这一行不该在」与「漏了一行」。 删挂记号不当场抹掉(看得见、可后悔),且**删要说出来**(`drops`)—— 「没回传就是删了」会把一次不完整的回传变成一次删表。 · **必填没填按不下提交**:与放行门 L1 同一个数同一套算法;闸上摆出差在哪一行哪一格。 · 只写真改了的那几行 —— 改一格却留「修订 4 行」的痕,那句话是假的。 判据与门 · 裁量判据带谓词时**谓词说了算**:「选填缺口已补齐」基座数得出来, 人填好的目标价它照样判「客户未提供」的毛病由此消掉。 · 验收卡判据**读时现算** —— 人在成果件上补一格,判据跟着变。 · 放行门认「**办完了没有**」不认「有人写过」:从前写个 `false` 就把门推开, 于是一单没打标就进了放行门。三个数全由基座现数。 · 拒回把「活没干完」说成「数或行对不上」的毛病:判据点名的表一行都没写时直说那一步没办。 **指向两扇打不开的门,比不指还糟。** 界面不撒谎 · 日志只有三色:负责人绿 · 智能体蓝 · 系统灰(归侧五种是度量的分法,不是给人看的)。 · 验收收口答两件事:落了什么(按**交付物**点名,一份成果的几张表并成一行)、 往哪儿去(转出哪一口、带过去哪些字段);一个口都没发就直说到此为止。 · 签完到收尾之间那一段有自己的话「字已签下,正在落地」—— 中间态本来就该说出来,只是要说对。 · 消息不再被内部事件刷屏:只有从通道进来的件才谈得上「无人认领」。 · 建客户公司与联系人**一次确认落两行**;联系人编码自增不问人;卡面摆表的人读名。 A1 三案例端到端全 released:全 A 类直通 12 拍 / 客户点名跳一条 10 拍 / 新客户缺必填 14 拍。 五道门禁全绿(971 passed)。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JsTDjoHovERXyy6Wmw1ALp
89 lines
3.1 KiB
TypeScript
89 lines
3.1 KiB
TypeScript
/**
|
|
* module: toolbox —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
|
|
*/
|
|
import type { ToolContract } from './internal/domain/tool-contract.ts';
|
|
import type { ToolCall, ToolResult } from './contract.ts';
|
|
export type Clock = {
|
|
now(): Date;
|
|
};
|
|
export type IdGenerator = {
|
|
next(): string;
|
|
};
|
|
/** 凭证密封 —— 与 llm 同一实现,由 app 注入(ADR-009) */
|
|
export type SecretBox = {
|
|
seal(plaintext: string): string;
|
|
open(cipher: string): string;
|
|
};
|
|
export type ToolRegistry = {
|
|
list(): Promise<ToolContract[]>;
|
|
get(name: string): Promise<ToolContract | undefined>;
|
|
isEnabled(name: string): Promise<boolean>;
|
|
upsert(contract: ToolContract, connectionCipher: Record<string, string> | null): Promise<void>;
|
|
setEnabled(name: string, enabled: boolean): Promise<void>;
|
|
connectionCipher(name: string): Promise<Record<string, string> | undefined>;
|
|
setAllowlist(activityId: string, tools: readonly string[]): Promise<void>;
|
|
allowlistOf(activityId: string): Promise<string[]>;
|
|
/** 有活动声明引用即不得删除 */
|
|
referencedBy(name: string): Promise<string[]>;
|
|
};
|
|
/** 工具录制回放存储 —— 与 llm 的 ReplayStore 同构,另存一表(§7.3) */
|
|
export type ToolReplayStore = {
|
|
put(record: {
|
|
key: string;
|
|
call: ToolCall;
|
|
result: ToolResult;
|
|
recordedAt: Date;
|
|
}): Promise<void>;
|
|
get(key: string): Promise<{
|
|
call: ToolCall;
|
|
result: ToolResult;
|
|
} | undefined>;
|
|
};
|
|
/**
|
|
* 工具执行 —— 实现对系统:server 侧执行代码,运行时受限,
|
|
* **只可访问注册申报的连接目标,无其他环境能力**(OS 7.3)。
|
|
*/
|
|
/**
|
|
* 工具转人台(§6.2)—— 人是工具的一种实现:发出去的卡、答回来的出参都记在这。
|
|
* 内容地址 `callKey` 保证同一次调用只问人一次。
|
|
*/
|
|
export type ToolHandoffStore = {
|
|
find(taskId: string, callKey: string): Promise<ToolHandoff | undefined>;
|
|
open(handoff: Omit<ToolHandoff, 'state' | 'output'>): Promise<void>;
|
|
/** 人答完:值即出参 */
|
|
answer(workOrderId: string, output: Record<string, unknown>): Promise<ToolHandoff | undefined>;
|
|
};
|
|
export type ToolHandoff = {
|
|
readonly id: string;
|
|
readonly taskId: string;
|
|
readonly tool: string;
|
|
readonly callKey: string;
|
|
readonly input: Record<string, unknown>;
|
|
readonly workOrderId: string;
|
|
readonly state: 'pending' | 'answered';
|
|
readonly output?: Record<string, unknown> | undefined;
|
|
};
|
|
export type ToolRuntime = {
|
|
execute(input: {
|
|
readonly contract: ToolContract;
|
|
readonly connection: Readonly<Record<string, string>>;
|
|
readonly call: ToolCall;
|
|
readonly idempotencyKey?: string;
|
|
}): Promise<{
|
|
ok: boolean;
|
|
output?: Record<string, unknown>;
|
|
error?: {
|
|
code: string;
|
|
retryable: boolean;
|
|
message: string;
|
|
};
|
|
}>;
|
|
};
|
|
/** JSON Schema 校验 —— ajv 在 adapter,usecase 只见本端口(ADR-003) */
|
|
export type SchemaValidator = {
|
|
validate(schema: Record<string, unknown>, value: unknown): {
|
|
ok: boolean;
|
|
errors: string[];
|
|
};
|
|
};
|