@linxin666/dsh-client-ui-task-board 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +59 -20
  3. package/README.zh.md +59 -20
  4. package/lib/client.js +6208 -624
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +4774 -493
  7. package/lib/types/client/PluginSettingsCard.d.ts +7 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +31 -3
  9. package/lib/types/client/board/ClampedMarkdown.d.ts +3 -0
  10. package/lib/types/client/board/ConfirmDialog.d.ts +4 -1
  11. package/lib/types/client/board/EditTaskModal.d.ts +5 -2
  12. package/lib/types/client/board/LinkSubtaskModal.d.ts +5 -2
  13. package/lib/types/client/board/NewTaskModal.d.ts +4 -1
  14. package/lib/types/client/board/TagManagerModal.d.ts +26 -0
  15. package/lib/types/client/board/TaskBoard.d.ts +10 -1
  16. package/lib/types/client/board/TaskCard.d.ts +14 -1
  17. package/lib/types/client/board/TaskDetail.d.ts +3 -1
  18. package/lib/types/client/board/TaskForm.d.ts +4 -1
  19. package/lib/types/client/board/VerificationReport.d.ts +23 -0
  20. package/lib/types/client/board/card-view.d.ts +113 -0
  21. package/lib/types/client/board/icons.d.ts +32 -0
  22. package/lib/types/client/board/overlay.d.ts +69 -0
  23. package/lib/types/client/board/status-key.d.ts +15 -0
  24. package/lib/types/client/board/task-markdown.d.ts +19 -0
  25. package/lib/types/client/index.d.ts +23 -5
  26. package/lib/types/client/locales.d.ts +168 -1
  27. package/lib/types/client/native-panel.d.ts +6 -20
  28. package/lib/types/client/plugin-card-seat.d.ts +5 -0
  29. package/lib/types/client/schedule-zone.d.ts +50 -0
  30. package/lib/types/client/seats.d.ts +18 -0
  31. package/lib/types/client/service.d.ts +32 -0
  32. package/lib/types/client/settings-form.d.ts +16 -0
  33. package/lib/types/core/controller.d.ts +46 -11
  34. package/lib/types/core/extension.d.ts +283 -0
  35. package/lib/types/core/handover.d.ts +13 -1
  36. package/lib/types/core/issue-form.d.ts +16 -0
  37. package/lib/types/core/poll-cadence.d.ts +31 -0
  38. package/lib/types/core/tasks.d.ts +228 -17
  39. package/lib/types/core/use-cases/task-schedule.d.ts +68 -10
  40. package/lib/types/core/use-cases/task-tag.d.ts +48 -0
  41. package/lib/types/core/use-cases/task-update.d.ts +5 -3
  42. package/lib/types/core/verification-budget.d.ts +52 -0
  43. package/lib/types/core/verification.d.ts +753 -0
  44. package/lib/types/core/workspace-target.d.ts +41 -0
  45. package/lib/types/host/agent-tools.d.ts +1 -1
  46. package/lib/types/host/extension-registry.d.ts +111 -0
  47. package/lib/types/host/llm-dispatch.d.ts +63 -0
  48. package/lib/types/host/verification-gate.d.ts +95 -0
  49. package/lib/types/host/verification-runner.d.ts +139 -0
  50. package/lib/types/host/workspace-evidence.d.ts +53 -0
  51. package/lib/types/host-ledger.d.ts +133 -14
  52. package/lib/types/host-runner.d.ts +55 -10
  53. package/lib/types/host-service.d.ts +205 -11
  54. package/lib/types/index.d.ts +134 -26
  55. package/lib/types/protocol.d.ts +92 -10
  56. package/lib/types/tool-surface.d.ts +71 -0
  57. package/package.json +28 -31
  58. package/src/client/PluginSettingsCard.tsx +9 -0
  59. package/src/client/TaskBoardSettingsCard.tsx +378 -66
  60. package/src/client/board/ClampedMarkdown.tsx +69 -0
  61. package/src/client/board/ConfirmDialog.tsx +7 -3
  62. package/src/client/board/EditTaskModal.tsx +5 -2
  63. package/src/client/board/LinkSubtaskModal.tsx +12 -7
  64. package/src/client/board/NewTaskModal.tsx +168 -21
  65. package/src/client/board/TagManagerModal.tsx +235 -0
  66. package/src/client/board/TaskBoard.tsx +259 -103
  67. package/src/client/board/TaskCard.tsx +214 -81
  68. package/src/client/board/TaskDetail.tsx +289 -43
  69. package/src/client/board/TaskForm.tsx +13 -3
  70. package/src/client/board/VerificationReport.tsx +322 -0
  71. package/src/client/board/card-view.ts +220 -0
  72. package/src/client/board/icons.tsx +89 -0
  73. package/src/client/board/overlay.tsx +189 -0
  74. package/src/client/board/status-key.ts +30 -0
  75. package/src/client/board/task-markdown.module.css +137 -0
  76. package/src/client/board/task-markdown.tsx +106 -0
  77. package/src/client/board-settings.module.css +66 -0
  78. package/src/client/board.module.css +488 -63
  79. package/src/client/index.ts +82 -51
  80. package/src/client/locales.ts +343 -6
  81. package/src/client/native-panel.tsx +18 -2
  82. package/src/client/plugin-card-seat.ts +7 -0
  83. package/src/client/schedule-zone.ts +100 -2
  84. package/src/client/seats.tsx +58 -0
  85. package/src/client/service.ts +94 -0
  86. package/src/client/settings-card.module.css +31 -5
  87. package/src/client/settings-form.ts +27 -1
  88. package/src/core/controller.ts +105 -10
  89. package/src/core/extension.ts +376 -0
  90. package/src/core/freeze-snapshot.ts +2 -2
  91. package/src/core/handover.ts +16 -1
  92. package/src/core/issue-form.ts +19 -0
  93. package/src/core/poll-cadence.ts +41 -0
  94. package/src/core/store.ts +80 -15
  95. package/src/core/tasks.ts +293 -45
  96. package/src/core/use-cases/task-create.ts +30 -9
  97. package/src/core/use-cases/task-parent.ts +3 -2
  98. package/src/core/use-cases/task-schedule.ts +190 -25
  99. package/src/core/use-cases/task-tag.ts +110 -0
  100. package/src/core/use-cases/task-update.ts +13 -7
  101. package/src/core/verification-budget.ts +115 -0
  102. package/src/core/verification.ts +1594 -0
  103. package/src/core/workspace-target.ts +59 -0
  104. package/src/host/agent-tools.ts +125 -38
  105. package/src/host/extension-registry.ts +509 -0
  106. package/src/host/llm-dispatch.ts +87 -0
  107. package/src/host/verification-gate.ts +487 -0
  108. package/src/host/verification-runner.ts +702 -0
  109. package/src/host/workspace-evidence.ts +176 -0
  110. package/src/host-ai.ts +15 -9
  111. package/src/host-ledger.ts +468 -71
  112. package/src/host-routes.ts +15 -2
  113. package/src/host-runner.ts +106 -24
  114. package/src/host-service.ts +546 -40
  115. package/src/index.ts +305 -21
  116. package/src/protocol.ts +226 -28
  117. package/src/tool-surface.ts +95 -0
  118. package/lib/invariant.js +0 -6
  119. package/lib/types/invariant.d.ts +0 -3
  120. package/src/invariant.ts +0 -4
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Workspace targeting for cards that pin none.
3
+ *
4
+ * The Host answers two questions here instead of leaving them to
5
+ * `session.create`, whose own fallback is the Host process working directory
6
+ * (the desktop app's profile directory): which workspace a root card inherits
7
+ * from the session that created it, and which workspace an unpinned run lands
8
+ * in when nothing could be inherited.
9
+ *
10
+ * Structural types only — the Host's `Workspace` entity satisfies them — so the
11
+ * browser program compiles this module without importing an SDK value.
12
+ *
13
+ * @module dsh-task-board/core/workspace-target
14
+ */
15
+ /** The workspace facts these rules read (a `Workspace` entity subset). */
16
+ export interface WorkspaceCandidate {
17
+ /** Stable workspace record id. */
18
+ readonly id: string;
19
+ /** ISO-8601 instant of the workspace's last durable mutation. */
20
+ readonly updatedAt: string;
21
+ /** Header-validated session ids the workspace owns, most recent first. */
22
+ readonly sessionIds: readonly string[];
23
+ }
24
+ /**
25
+ * The workspace that owns one session.
26
+ * @param items - the deployment's workspaces.
27
+ * @param sessionId - the session whose workspace is requested.
28
+ * @returns the owning workspace id, or undefined when none claims the session.
29
+ */
30
+ export declare function workspaceOwningSession(items: readonly WorkspaceCandidate[], sessionId: string): string | undefined;
31
+ /**
32
+ * The workspace the board treats as most recently used: the one whose record
33
+ * changed last. Attaching a session stamps that instant, so the newest stamp
34
+ * tracks where the user most recently opened or resumed a session. The
35
+ * deployment's own list order breaks ties, and a stamp that does not parse
36
+ * never outranks one that does; a registry whose stamps are all unreadable
37
+ * falls back to list order rather than to "no workspace at all".
38
+ * @param items - the deployment's workspaces.
39
+ * @returns the most recently used workspace id, or undefined when there is none.
40
+ */
41
+ export declare function mostRecentWorkspaceId(items: readonly WorkspaceCandidate[]): string | undefined;
@@ -8,7 +8,7 @@ export interface TaskBoardToolHost {
8
8
  /** Current board snapshot (tasks + scheduler + power + deployment constants). */
9
9
  snapshot(): TaskBoardSnapshot;
10
10
  /** Submit one confirmed Host action; returns the resulting snapshot. */
11
- apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot;
11
+ apply(requestId: string, action: TaskBoardAction, initiator?: string): TaskBoardSnapshot | Promise<TaskBoardSnapshot>;
12
12
  }
13
13
  /** Registered tool names, in registration order. */
14
14
  export declare const TASK_BOARD_TOOL_NAMES: readonly ["task_board_list", "task_board_get", "task_board_create", "task_board_update", "task_board_set_parent", "task_board_run", "task_board_manage", "task_board_schedule"];
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Host-side extension registry: the one place that admits external providers,
3
+ * negotiates the contract version, gates them on the board's own enable state,
4
+ * fans board events out to them, and routes dispatched provider actions back.
5
+ *
6
+ * Failure policy (mirrors the board's plugin philosophy): a provider that
7
+ * throws, mis-declares its version, or disables itself degrades only its own
8
+ * surface. The board keeps serving; the registry records what it refused.
9
+ *
10
+ * @module dsh-task-board/host/extension-registry
11
+ */
12
+ import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
13
+ import type { HostTaskLedger } from '../host-ledger.ts';
14
+ import type { TaskBoardAction, TaskBoardSnapshot } from '../protocol.ts';
15
+ import { type TaskBoardExecutionSettledEvent, type TaskBoardExtension, type TaskBoardExtensionActionRequest, type TaskBoardExtensionPayload, type TaskBoardStatusChangedEvent, type TaskBoardTaskDeletedEvent } from '../core/extension.ts';
16
+ /** Diagnosable refusal raised by the registry and the capability face. */
17
+ export declare class TaskBoardExtensionError extends Error {
18
+ readonly code: string;
19
+ constructor(code: string, message: string);
20
+ }
21
+ /** Logging seat the registry uses; a deployment may supply its own. */
22
+ export interface TaskBoardExtensionLogger {
23
+ warn(message: string, ...rest: unknown[]): void;
24
+ error(message: string, ...rest: unknown[]): void;
25
+ }
26
+ /** The deployment's model-visible tool registry, resolved lazily. */
27
+ export interface TaskBoardExtensionToolRegistry {
28
+ register(definition: ToolDefinition): () => void;
29
+ }
30
+ /** Applies one board action with every board gate intact (never an extension action). */
31
+ export type TaskBoardActionApplier = (action: Exclude<TaskBoardAction, {
32
+ kind: 'extension-action';
33
+ }>, initiator?: string) => TaskBoardSnapshot;
34
+ /** Registry dependencies. */
35
+ export interface TaskBoardExtensionRegistryOptions {
36
+ ledger: HostTaskLedger;
37
+ /** Apply an action through the board service (gates, run dispatch, schedule). */
38
+ apply?: TaskBoardActionApplier;
39
+ /** Resolve the deployment's tool registry; absent loses the tool surface only. */
40
+ toolRegistry?: () => TaskBoardExtensionToolRegistry | undefined;
41
+ now?: () => number;
42
+ uuid?: () => string;
43
+ logger?: TaskBoardExtensionLogger;
44
+ }
45
+ export declare class TaskBoardExtensionRegistry {
46
+ private readonly entries;
47
+ private readonly ledger;
48
+ private readonly applyAction;
49
+ private readonly now;
50
+ private readonly uuid;
51
+ private readonly logger;
52
+ private toolResolver;
53
+ /** Board master switch (enabled config); providers start only while it is on. */
54
+ private boardEnabled;
55
+ private disposed;
56
+ constructor(options: TaskBoardExtensionRegistryOptions);
57
+ /**
58
+ * Pin (or replace) the deployment's tool registry. A registry that appears
59
+ * after a provider started is picked up here, which is what keeps the tool
60
+ * surface alive across the board's own late service resolution.
61
+ */
62
+ setToolRegistry(resolver: (() => TaskBoardExtensionToolRegistry | undefined) | undefined): void;
63
+ /** Apply the board's master switch; providers start and stop with it. */
64
+ setEnabled(enabled: boolean): void;
65
+ /** Whether the board currently runs a given extension (board x extension). */
66
+ isActive(extensionId: string): boolean;
67
+ /**
68
+ * Admit one provider. Idempotent by id: a second registration of the same id
69
+ * is a no-op that returns the same release handle. A contract-version
70
+ * mismatch is refused visibly (logged and thrown) without disturbing the
71
+ * board or any other provider.
72
+ * @param extension - the provider to admit.
73
+ * @returns a disposer releasing the registration (idempotent).
74
+ */
75
+ registerExtension(extension: TaskBoardExtension): () => void;
76
+ /** Remove one provider; its provider-side work stops and its payload stays stored. */
77
+ unregister(extensionId: string): void;
78
+ /**
79
+ * Route one dispatched provider action. Refuses visibly when the extension is
80
+ * unknown, currently gated off, or does not implement the action.
81
+ */
82
+ handleAction(request: TaskBoardExtensionActionRequest): Promise<unknown>;
83
+ /** Published summaries of currently running providers, keyed by extension id. */
84
+ published(): Record<string, TaskBoardExtensionPayload>;
85
+ /** Fan a status change out to every running provider, isolated per callback. */
86
+ emitStatusChanged(event: TaskBoardStatusChangedEvent): void;
87
+ /** Fan an execution settlement out to every running provider. */
88
+ emitExecutionSettled(event: TaskBoardExecutionSettledEvent): void;
89
+ /** Fan a task deletion out to every running provider. */
90
+ emitTaskDeleted(event: TaskBoardTaskDeletedEvent): void;
91
+ /** Stop every provider and release the registry (idempotent). */
92
+ dispose(): void;
93
+ private emit;
94
+ /** Start or stop one entry against the current board + extension gate. */
95
+ private reconcile;
96
+ private startEntry;
97
+ private stopEntry;
98
+ /** (Re)register every buffered tool against the current tool registry. */
99
+ private syncTools;
100
+ private disposeTools;
101
+ private assertActive;
102
+ /** Build the per-extension capability face. */
103
+ private capabilities;
104
+ private createTask;
105
+ private patchContent;
106
+ private setStatus;
107
+ private linkedTasks;
108
+ private writeIntegration;
109
+ private publish;
110
+ private registerTool;
111
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * One-shot model dispatch for the board's Host half.
3
+ *
4
+ * The board makes two one-shot model calls: the goal-acceptance judge
5
+ * (`verification-runner.ts`) and the "parse pasted text" action
6
+ * (`host-ai.ts`). Both call the official `llm` service, and both must call it
7
+ * the way the official agent loop does.
8
+ *
9
+ * The runtime exposes two entry points with the same name shape. The public
10
+ * `stream(options)` is a single-argument convenience method, and it is an
11
+ * ordinary instance property — any plugin may overwrite it. The registration
12
+ * bound path `prepareCall(config)` returns a one-shot handle whose
13
+ * `stream(request)` reaches the adapter through the runtime's internal
14
+ * dispatch instead, and `ctx.on('llm/stream')` remains the supported seam every
15
+ * extension is expected to register on.
16
+ *
17
+ * A third-party provider plugin that patched `llm.stream` with the waterfall
18
+ * listener signature `(options, next)` broke every caller that used the public
19
+ * method: `llm.stream(options)` invoked the listener with `next === undefined`,
20
+ * so the guard's `for await (const chunk of next())` raised
21
+ * `TypeError: next(...) is not a function or its return value is not async
22
+ * iterable`. The agent loop was unaffected because it already dispatches
23
+ * through `prepareCall(...).stream(...)`; the board's two one-shot calls were
24
+ * not, and each completed acceptance was recorded as an anomaly
25
+ * ("验收异常(裁判请求失败)") after two judge attempts.
26
+ *
27
+ * Dispatching through the prepared call fixes that at the owner: the board no
28
+ * longer depends on a mutable instance property that a plugin may legitimately
29
+ * replace, and a plugin that registers on `llm/stream` is still invoked. The
30
+ * public method remains the fallback for a runtime that exposes no
31
+ * `prepareCall` at all, so an older or proxied service keeps working.
32
+ */
33
+ import { type GenerateOptions, type LlmRuntime, type StreamChunk } from '@deepseek-ai/dsh-llm';
34
+ /** The request fields the board adds around a call config. */
35
+ export type OneShotRequest = Pick<GenerateOptions, 'messages' | 'signal'> & Pick<GenerateOptions, 'system'>;
36
+ /**
37
+ * The call config as this board's own domain types carry it.
38
+ *
39
+ * `VerificationRoute.reasoningEffort` and the parse route are plain strings (the
40
+ * catalog publishes effort ids as strings), while the SDK brands them
41
+ * nominally; the single crossing is branded here so no caller repeats the
42
+ * assertion.
43
+ */
44
+ export interface OneShotCallConfig {
45
+ provider: string;
46
+ model: string;
47
+ reasoningEffort?: string;
48
+ temperature?: number;
49
+ maxTokens?: number;
50
+ }
51
+ /**
52
+ * Open one one-shot model stream on the registration-bound dispatch path.
53
+ *
54
+ * The call-config fields must travel inside `config` (not the request): the
55
+ * prepared handle refuses a request whose config fields differ from the ones it
56
+ * resolved, so the request carries only messages, signal, and the optional
57
+ * one-shot system prompt.
58
+ * @param llm - the Host's llm service.
59
+ * @param config - provider/model route plus the caller's sampling controls.
60
+ * @param request - the assembled messages and cancellation for this call.
61
+ * @returns the chunk stream, including any registered `llm/stream` listener.
62
+ */
63
+ export declare function openOneShotStream(llm: LlmRuntime, config: OneShotCallConfig, request: OneShotRequest): Promise<AsyncIterable<StreamChunk>>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Goal acceptance gate: the board's evaluator-backed certification of a goal
3
+ * completion claim.
4
+ *
5
+ * The gate sits on the official tool pre-execute lifecycle and intercepts the
6
+ * one call that ends a goal run — `update_goal` with `action: 'complete'`
7
+ * — BEFORE it takes effect. This is why the board does not ask the agent to
8
+ * verify itself: the tool call that finishes the goal is refused until a
9
+ * matching acceptance pass record exists, so no prompt wording and no
10
+ * self-report can route around it.
11
+ *
12
+ * Semantics owned here:
13
+ * - one acceptance cycle per EXECUTION, spent at most twice: the first failure
14
+ * returns its findings to the fixing agent, the second ends the cycle;
15
+ * - a repeated completion call during a repair, a new automatic goal round, a
16
+ * plugin reload and a Host restart all reuse the same cycle rather than
17
+ * resetting it (the budget is persisted on the execution record);
18
+ * - an anomaly (timeout, authentication, unparseable answer, an unusable judge
19
+ * route) is recorded separately from a quality verdict and is never treated
20
+ * as one;
21
+ * - exhausting the anomaly budget does NOT judge the card: an environment that
22
+ * cannot answer is not the work failing, so the cycle is held open with no
23
+ * judge call until a user clears the recorded anomalies (issue #1828);
24
+ * - an attempt the time budget ends before any verdict is recorded as its own
25
+ * stage and charged to no budget at all (issue #1828);
26
+ * - an INVALID acceptance (a veto whose required evidence is missing,
27
+ * unlocatable, or aimed at the empty-work baseline) is recorded in its own
28
+ * stage, spends its OWN bounded budget, and never consumes a quality attempt
29
+ * or fails the card; when that budget is spent the cycle is held for a human
30
+ * exactly like a spent anomaly budget;
31
+ * - concurrent completion calls for one execution share one acceptance.
32
+
33
+ * The validity check itself is program-level (`assessAcceptanceValidity` in
34
+ * `core/verification.ts`), applied after the judge answers and BEFORE any
35
+ * quality verdict is written: a stronger prompt alone could not enforce it.
36
+ */
37
+ import type { PreToolDecision } from '@deepseek-ai/dsh-tools';
38
+ import type { LlmRuntime } from '@deepseek-ai/dsh-llm';
39
+ import { type WorkspaceChangeSource } from './workspace-evidence.ts';
40
+ import type { HostTaskLedger } from '../host-ledger.ts';
41
+ /** The subset of the official goal service this gate drives. */
42
+ export interface GoalFace {
43
+ get(agent: unknown): {
44
+ id: string;
45
+ revision: number;
46
+ objective: string;
47
+ } | undefined;
48
+ block(agent: unknown, ref: {
49
+ id: string;
50
+ revision: number;
51
+ }, reason: {
52
+ code: string;
53
+ message: string;
54
+ }): unknown;
55
+ }
56
+ /** Everything the gate needs from its owner. */
57
+ export interface GoalVerificationGateDeps {
58
+ ledger: HostTaskLedger;
59
+ /** Resolve the optional model runtime lazily (it may activate later). */
60
+ llm?: () => LlmRuntime | undefined;
61
+ /** Resolve the optional goal service lazily. */
62
+ goals?: () => GoalFace | undefined;
63
+ /**
64
+ * Resolve the optional host change service lazily. Absent (or a deployment
65
+ * that serves none) simply means the judge sees the trajectory alone.
66
+ */
67
+ workspaceChanges?: () => WorkspaceChangeSource | undefined;
68
+ /**
69
+ * Ceiling of one judge request, read per acceptance (a row setting). Absent
70
+ * keeps the default, so a programmatic mount still judges.
71
+ */
72
+ callTimeoutMs?: () => number;
73
+ /**
74
+ * Total ceiling of one acceptance attempt, read per acceptance (a row
75
+ * setting). Absent keeps the default.
76
+ */
77
+ budgetMs?: () => number;
78
+ logger: {
79
+ warn(message: string, ...rest: unknown[]): void;
80
+ };
81
+ now?: () => number;
82
+ }
83
+ /** The shape of one tool pre-execution the gate inspects. */
84
+ export interface GateExecution {
85
+ name: string;
86
+ arguments: unknown;
87
+ agent?: unknown;
88
+ signal: AbortSignal;
89
+ }
90
+ /**
91
+ * Create the goal acceptance gate.
92
+ * @param deps - the ledger, the model runtime, the goal service and the settings.
93
+ * @returns the `tools/pre-execute` listener body (without the waterfall next()).
94
+ */
95
+ export declare function createGoalVerificationGate(deps: GoalVerificationGateDeps): (exec: GateExecution) => Promise<PreToolDecision | undefined>;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Goal acceptance runner: evidence assembly and the judge calls of one
3
+ * acceptance attempt.
4
+ *
5
+ * Lives in the host half because it needs the live session event log and the
6
+ * official `llm` service; every rule it applies (criteria, scale, tags,
7
+ * thresholds, budgets, caps) comes from `../core/verification.ts`, which mirrors
8
+ * the installed dsh-llm-verifier 0.8.4 default final acceptance.
9
+ */
10
+ import { type LlmRuntime } from '@deepseek-ai/dsh-llm';
11
+ import { type VerificationAttempt, type VerificationRoute, type VerificationUsage } from '../core/verification.ts';
12
+ /** Largest trace handed to the judge, mirroring the verifier's default cap. */
13
+ export declare const VERIFICATION_MAX_TRACE_CHARS = 80000;
14
+ /** Largest single trace entry; one huge tool result must not eat the budget. */
15
+ export declare const VERIFICATION_MAX_ENTRY_CHARS = 4000;
16
+ /** Largest per-finding text kept from one judge answer. */
17
+ export declare const VERIFICATION_MAX_FINDING_CHARS = 400;
18
+ /** Largest verbatim citation kept from one finding. */
19
+ export declare const VERIFICATION_MAX_QUOTE_CHARS = 600;
20
+ /** Largest requirement/observation/gap statement kept from one finding. */
21
+ export declare const VERIFICATION_MAX_PROBLEM_CHARS = 400;
22
+ /** Structured findings kept per judge answer and per acceptance. */
23
+ export declare const VERIFICATION_MAX_FINDINGS_PER_CALL = 3;
24
+ export declare const VERIFICATION_MAX_FINDINGS = 12;
25
+ /**
26
+ * Default ceiling of ONE judge request. The effective ceiling is a row setting
27
+ * (`goalVerificationCallTimeoutSeconds`), read live by the gate, because 120s was
28
+ * tight for a reasoning model reading an 80,000 character trace with a 16,384
29
+ * token output cap: every timeout it produced was charged as an acceptance
30
+ * anomaly against a budget that then failed the card.
31
+ */
32
+ export declare const VERIFICATION_CALL_TIMEOUT_MS = 150000;
33
+ export declare const VERIFICATION_MAX_TOKENS = 16384;
34
+ export declare const VERIFICATION_TEMPERATURE = 0.2;
35
+ export declare const VERIFICATION_REQUEST_ATTEMPTS = 3;
36
+ /** Redaction patterns, mirrored from the verifier's defaults. */
37
+ export declare const VERIFICATION_REDACT_PATTERNS: readonly string[];
38
+ /** Why one acceptance could not produce a verdict. */
39
+ export type VerificationErrorKind = 'route-unavailable' | 'timeout' | 'auth' | 'parse' | 'request' | 'aborted' | 'budget';
40
+ /**
41
+ * The time one acceptance attempt may still spend.
42
+ *
43
+ * `deadline` is the instant the whole attempt runs out; `callTimeoutMs` is the
44
+ * ceiling of a single judge call. The pair is what ties the retry budget to the
45
+ * acceptance budget: a call is not started unless its own ceiling still fits
46
+ * inside what is left, because starting one the outer budget will abort anyway
47
+ * only burns wall time and turns a slow machine into an anomaly.
48
+ */
49
+ export interface AcceptanceBudget {
50
+ /** Absolute instant (ms epoch) the acceptance attempt runs out at. */
51
+ deadline: number;
52
+ /** Ceiling of one judge call in milliseconds. */
53
+ callTimeoutMs: number;
54
+ /** Clock the caller runs on, injected so tests drive it deterministically. */
55
+ now: () => number;
56
+ }
57
+ /** An acceptance anomaly: never a quality verdict, always recorded as one. */
58
+ export declare class VerificationError extends Error {
59
+ readonly kind: VerificationErrorKind;
60
+ readonly usage: VerificationUsage;
61
+ constructor(kind: VerificationErrorKind, message: string, usage?: VerificationUsage, options?: {
62
+ cause?: unknown;
63
+ });
64
+ }
65
+ /** Fresh zeroed usage counters. */
66
+ export declare function emptyUsage(): VerificationUsage;
67
+ /** Structural view of one session event, as the host log carries it. */
68
+ interface RawEvent {
69
+ type?: unknown;
70
+ seq?: unknown;
71
+ time?: unknown;
72
+ data?: unknown;
73
+ }
74
+ /** Read one session's events across the shapes the SDK cohort exposes. */
75
+ export declare function sessionEvents(session: unknown): readonly RawEvent[];
76
+ /** Evidence assembled for one acceptance attempt. */
77
+ export interface AcceptanceEvidence {
78
+ problem: string;
79
+ trace: string;
80
+ entries: number;
81
+ fromSeq?: number;
82
+ toSeq?: number;
83
+ omittedCharacters: number;
84
+ hash: string;
85
+ }
86
+ /**
87
+ * Assemble the evidence one acceptance judges.
88
+ *
89
+ * The window starts at the execution's own `startedAt`, never at the session's
90
+ * first event: a reused session carries the history of earlier executions, and
91
+ * those runs must not be judged as this one's work. Only observed output is
92
+ * rendered — tool calls with their arguments and their results, assistant
93
+ * prose, goal round markers and team messages — and the result is redacted and
94
+ * capped before it ever reaches a judge.
95
+ * @param session - the live session of the execution.
96
+ * @param problem - the execution's composed prompt, shown as the task statement.
97
+ * @param startedAt - the instant the execution opened (ms epoch).
98
+ * @returns the bounded, redacted evidence.
99
+ */
100
+ /**
101
+ * The session events inside one execution's own window.
102
+ *
103
+ * A reused session carries the history of earlier executions; only the events
104
+ * at or after this execution's start belong to the work being judged.
105
+ * @param session - the live session.
106
+ * @param startedAt - the execution's start instant (ms epoch).
107
+ * @returns the events of this execution, oldest first.
108
+ */
109
+ export declare function evidenceEvents(session: unknown, startedAt: number): readonly RawEvent[];
110
+ export declare function collectEvidence(session: unknown, problem: string, startedAt: number): AcceptanceEvidence;
111
+ /** The verdict of one acceptance attempt. */
112
+ export interface AcceptanceResult {
113
+ attempt: VerificationAttempt;
114
+ }
115
+ /**
116
+ * Run one acceptance: every criterion is judged twice, the odd round with the
117
+ * A/B slots swapped, and the per-round scores are mapped back and averaged per
118
+ * criterion.
119
+ * @param input - the judge route, evidence, threshold, time budget and cancellation.
120
+ * @returns the recorded attempt (quality verdict, anomaly, or budget stop).
121
+ */
122
+ export declare function runAcceptance(input: {
123
+ llm: LlmRuntime;
124
+ route: VerificationRoute;
125
+ evidence: AcceptanceEvidence;
126
+ threshold: number;
127
+ index: number;
128
+ signal: AbortSignal;
129
+ /** Instant (ms epoch) the attempt runs out at; defaults to now plus the default budget. */
130
+ deadline?: number;
131
+ /** Ceiling of one judge call; defaults to {@link VERIFICATION_CALL_TIMEOUT_MS}. */
132
+ callTimeoutMs?: number;
133
+ /** Host-observed workspace changes, rendered as the prompt's reference context. */
134
+ context?: string;
135
+ /** How many changed files that context shows. */
136
+ workspaceFiles?: number;
137
+ now?: () => number;
138
+ }): Promise<AcceptanceResult>;
139
+ export {};
@@ -0,0 +1,53 @@
1
+ /** The subset of the host change service this module drives. */
2
+ export interface WorkspaceChangeSource {
3
+ summary(sessionId: string, seq: number): unknown;
4
+ diff(sessionId: string, seq: number, index: number, signal: AbortSignal): Promise<unknown>;
5
+ }
6
+ /** One session event, as the host log carries it. */
7
+ interface RawEvent {
8
+ type?: unknown;
9
+ seq?: unknown;
10
+ }
11
+ /** How many changed files one evidence block renders. */
12
+ export declare const MAX_WORKSPACE_FILES = 8;
13
+ /** Character ceiling for the whole rendered block. */
14
+ export declare const WORKSPACE_EVIDENCE_MAX_CHARS = 24000;
15
+ /** Character ceiling for one file's rendered comparison. */
16
+ export declare const WORKSPACE_EVIDENCE_MAX_FILE_CHARS = 6000;
17
+ /**
18
+ * Resolve the optional host change service from a context-like object.
19
+ * @param ctx - anything exposing @@get(name)@@.
20
+ * @returns the service, or undefined when this deployment serves none.
21
+ */
22
+ export declare function probeWorkspaceChanges(ctx: {
23
+ get(name: string): unknown;
24
+ }): WorkspaceChangeSource | undefined;
25
+ /** The sequence of the newest change event inside the reviewed window. */
26
+ export declare function latestChangeEvent(events: readonly RawEvent[]): {
27
+ seq: number;
28
+ turn?: number;
29
+ } | undefined;
30
+ /**
31
+ * Render the host's own record of what the reviewed window changed.
32
+ *
33
+ * Bounded twice — at most {@link MAX_WORKSPACE_FILES} files, and a shared
34
+ * character budget split across them — so one enormous generated file cannot
35
+ * crowd out every other change. Every failure degrades to less evidence (or an
36
+ * empty block) instead of an error, because the acceptance being prepared must
37
+ * still reach a verdict.
38
+ * @param events - session events already bounded to the execution's window.
39
+ * @param sessionId - the session whose changes these are.
40
+ * @param source - the probed host service.
41
+ * @param options - budget, cancellation and the diagnostic sink.
42
+ * @returns the rendered block plus how many files it shows.
43
+ */
44
+ export declare function renderWorkspaceEvidence(events: readonly RawEvent[], sessionId: string, source: WorkspaceChangeSource, options: {
45
+ signal: AbortSignal;
46
+ warn?: (message: string) => void;
47
+ maxChars?: number;
48
+ }): Promise<{
49
+ text: string;
50
+ files: number;
51
+ hash: string;
52
+ }>;
53
+ export {};