@tangle-network/agent-app 0.60.230 → 0.60.232
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/dist/assistant/index.js +8 -8
- package/dist/chat-react/index.js +4 -4
- package/dist/{chunk-5IS3GCMR.js → chunk-232KA6MR.js} +3 -3
- package/dist/{chunk-KMIDRUUH.js → chunk-35APKGPB.js} +2 -2
- package/dist/{chunk-GNBBY3KN.js → chunk-3K45OQ5X.js} +3 -3
- package/dist/{chunk-A3CUVYRZ.js → chunk-4JAXSEYW.js} +3 -3
- package/dist/{chunk-DA5XLDZR.js → chunk-BNFUJNPS.js} +4 -4
- package/dist/{chunk-BQILMP73.js → chunk-FJEGGUOQ.js} +2 -2
- package/dist/{chunk-HEPEGY6Q.js → chunk-JYVUFRRV.js} +2 -2
- package/dist/{chunk-XG6FODYO.js → chunk-XIN7DOAB.js} +108 -100
- package/dist/chunk-XIN7DOAB.js.map +1 -0
- package/dist/{mention-editor-NOS5R3AU.js → mention-editor-6FJ6HRSN.js} +2 -2
- package/dist/public-consultation/index.d.ts +1 -1
- package/dist/settings-react/index.js +1 -1
- package/dist/studio-react/index.js +2 -2
- package/dist/web-react/agent-profile-editor.js +4 -4
- package/dist/web-react/control-glyphs.d.ts +20 -0
- package/dist/web-react/controls.d.ts +6 -358
- package/dist/web-react/effort-picker.d.ts +98 -0
- package/dist/web-react/index.js +8 -8
- package/dist/web-react/model-picker.d.ts +67 -0
- package/dist/web-react/picker-presentation.d.ts +89 -0
- package/dist/web-react/popover-surface.d.ts +89 -0
- package/dist/web-react/use-pending.d.ts +11 -0
- package/dist/work-product/draft-emission-tools.d.ts +5 -0
- package/dist/work-product/draft-tool-context.d.ts +19 -0
- package/dist/work-product/evidence-verification.d.ts +160 -0
- package/dist/work-product/index.js +74 -59
- package/dist/work-product/index.js.map +1 -1
- package/dist/work-product/submission-tool.d.ts +5 -0
- package/dist/work-product/tool-config.d.ts +124 -0
- package/dist/work-product/tools.d.ts +3 -125
- package/dist/workspace-react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-XG6FODYO.js.map +0 -1
- /package/dist/{chunk-5IS3GCMR.js.map → chunk-232KA6MR.js.map} +0 -0
- /package/dist/{chunk-KMIDRUUH.js.map → chunk-35APKGPB.js.map} +0 -0
- /package/dist/{chunk-GNBBY3KN.js.map → chunk-3K45OQ5X.js.map} +0 -0
- /package/dist/{chunk-A3CUVYRZ.js.map → chunk-4JAXSEYW.js.map} +0 -0
- /package/dist/{chunk-DA5XLDZR.js.map → chunk-BNFUJNPS.js.map} +0 -0
- /package/dist/{chunk-BQILMP73.js.map → chunk-FJEGGUOQ.js.map} +0 -0
- /package/dist/{chunk-HEPEGY6Q.js.map → chunk-JYVUFRRV.js.map} +0 -0
- /package/dist/{mention-editor-NOS5R3AU.js.map → mention-editor-6FJ6HRSN.js.map} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Focus treatment for a row inside a popover panel.
|
|
3
|
+
*
|
|
4
|
+
* The ring itself now comes from the `:focus-visible` floor in tokens.css, so
|
|
5
|
+
* this no longer restates a width or a colour. What it still has to say is
|
|
6
|
+
* WHERE the ring is drawn: a popover option is a full-width row inside a panel
|
|
7
|
+
* that clips its own corners (`overflow-hidden rounded-xl`), and an outward
|
|
8
|
+
* ring on the first or last row is clipped away by that panel. Pulling the
|
|
9
|
+
* offset negative draws the same ring just inside the row instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare const POPOVER_OPTION_FOCUS = "focus-visible:[outline-offset:-2px]";
|
|
12
|
+
/**
|
|
13
|
+
* The one overlay elevation for floating surfaces — picker menus, popovers,
|
|
14
|
+
* drawers, modals. Reads the theme's `--shadow-overlay` token, so every overlay
|
|
15
|
+
* lifts with the same shadow and re-themes from one source. The floating
|
|
16
|
+
* composer uses the quieter `shadow-raised` rung instead.
|
|
17
|
+
*
|
|
18
|
+
* Written as an arbitrary value rather than the preset's `shadow-overlay`
|
|
19
|
+
* utility, because that utility only exists where the preset is part of the
|
|
20
|
+
* Tailwind build. A host that gets its tokens through a precompiled bundle —
|
|
21
|
+
* `@tangle-network/sandbox-ui` ships brand's tokens inlined, with no `@theme`
|
|
22
|
+
* block surviving the compile — receives `--shadow-overlay` as a plain custom
|
|
23
|
+
* property, from which no `shadow-overlay` utility can be generated, and these
|
|
24
|
+
* surfaces render flat. The arbitrary form emits from the class alone and works
|
|
25
|
+
* either way.
|
|
26
|
+
*/
|
|
27
|
+
export declare const OVERLAY_SHADOW = "shadow-[var(--shadow-overlay)]";
|
|
28
|
+
/**
|
|
29
|
+
* Root geometry for a picker — the box that holds the trigger — in one place
|
|
30
|
+
* because every picker in this family has to agree on it.
|
|
31
|
+
*
|
|
32
|
+
* Shrink-wrapping (`inline-flex`) is the default: these controls dock on a
|
|
33
|
+
* composer row where an expanding pill shoves its neighbours around. A STACKED
|
|
34
|
+
* panel wants the opposite — the compact `AgentSessionControls` gear popover
|
|
35
|
+
* lays its controls out in a column, and a shrink-wrapped root there makes a
|
|
36
|
+
* trigger's own `w-full` a no-op, since it fills a box the trigger itself
|
|
37
|
+
* sized. That is what left Agent backend short of the panel edge and Thinking
|
|
38
|
+
* narrower still.
|
|
39
|
+
*
|
|
40
|
+
* The panel is portaled ({@link PopoverSurface}), so widening the root widens
|
|
41
|
+
* the TRIGGER only. A menu that should follow it declares `matchTriggerWidth`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function pickerRootClass(fullWidth: boolean): string;
|
|
44
|
+
/**
|
|
45
|
+
* How a picker's TRIGGER is drawn. The menu it opens is the same either way.
|
|
46
|
+
*
|
|
47
|
+
* - `chip` (default): the 32px bordered pill — `rounded-full border
|
|
48
|
+
* border-border bg-card font-medium`, on the composer row's height.
|
|
49
|
+
* - `quiet`: a 32px borderless text button (the control scale's sm, the
|
|
50
|
+
* composer row's one height) — muted label, small glyph, a
|
|
51
|
+
* surface fill on hover and while the menu is open, nothing else. For a
|
|
52
|
+
* composer whose card already draws the border: three pills docked under
|
|
53
|
+
* the input there read as three more cards, not as the input's controls.
|
|
54
|
+
* - `field`: a full-width form field — the same height, radius, border,
|
|
55
|
+
* well, and focus treatment as a text input at `--control-height`. For a
|
|
56
|
+
* settings form, where a pill among inputs reads as a different control.
|
|
57
|
+
*/
|
|
58
|
+
export type PickerVariant = 'chip' | 'quiet' | 'field';
|
|
59
|
+
/**
|
|
60
|
+
* Trigger classes for a `field` picker: `@tangle-network/ui`'s own field
|
|
61
|
+
* presentation and `md` field size, the classes its `Input` and `SelectTrigger`
|
|
62
|
+
* draw, so a model, harness or timezone selector sits in a form as one more
|
|
63
|
+
* field — the same well on every plane, the same border, hover and focus halo.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fieldPickerTriggerClass({ interactive }?: {
|
|
66
|
+
interactive?: boolean;
|
|
67
|
+
}): string;
|
|
68
|
+
/** The chip trigger: a fixed 32px height (no vertical padding, so the 20px
|
|
69
|
+
* line and the border cannot push it to 34px). A full-width EffortPicker in a
|
|
70
|
+
* settings panel keeps the 36px field row instead. */
|
|
71
|
+
export declare const CHIP_PICKER_TRIGGER = "inline-flex h-[var(--control-height-sm,2rem)] items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-card px-3 text-sm font-medium text-foreground transition";
|
|
72
|
+
/**
|
|
73
|
+
* Trigger classes for a `quiet` picker. Height, padding, radius, and type are
|
|
74
|
+
* fixed here so the triggers on one composer row agree; a caller adds only
|
|
75
|
+
* width (`w-full`) and alignment (`justify-between`).
|
|
76
|
+
*
|
|
77
|
+
* The focus ring is drawn on the element rather than left to the tokens.css
|
|
78
|
+
* `:focus-visible` floor: a quiet trigger sits beside the composer's own action
|
|
79
|
+
* buttons (attach, dictate, send), which draw `focus-visible:ring-2
|
|
80
|
+
* focus-visible:ring-ring`, and a row whose controls answer keyboard focus two
|
|
81
|
+
* different ways reads as two families.
|
|
82
|
+
*
|
|
83
|
+
* `interactive: false` is for a PINNED control (see `HarnessPicker`'s
|
|
84
|
+
* `lockReason`): it keeps the resting treatment and draws no hover or open
|
|
85
|
+
* fill, because a fill promises a menu the control will not open.
|
|
86
|
+
*/
|
|
87
|
+
export declare function quietPickerTriggerClass({ interactive }?: {
|
|
88
|
+
interactive?: boolean;
|
|
89
|
+
}): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Portaled popover placement, nested focus, and outside-click ownership. */
|
|
2
|
+
import { useLayoutEffect, type ReactNode, type RefObject } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Keyboard + pointer model for a trigger-and-popover pair, dependency-free.
|
|
5
|
+
* Outside-mousedown and Escape both close; Escape also returns focus to the
|
|
6
|
+
* trigger so keyboard users aren't dropped at the top of the document. The
|
|
7
|
+
* returned `triggerProps` carry the ARIA contract (`aria-haspopup`/
|
|
8
|
+
* `aria-expanded`); spread them onto the trigger button.
|
|
9
|
+
*
|
|
10
|
+
* `panelRef` belongs to the popover panel and MUST be wired when the panel is
|
|
11
|
+
* rendered through {@link PopoverSurface}: a portaled panel is not inside
|
|
12
|
+
* `containerRef`, so a container-only outside test reads every click on the
|
|
13
|
+
* menu's own rows as an outside click and closes before the row's handler runs.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePopover(open: boolean, setOpen: (open: boolean) => void): {
|
|
16
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
17
|
+
triggerRef: RefObject<HTMLButtonElement | null>;
|
|
18
|
+
panelRef: RefObject<HTMLDivElement | null>;
|
|
19
|
+
triggerProps: {
|
|
20
|
+
ref: RefObject<HTMLButtonElement | null>;
|
|
21
|
+
'aria-haspopup': true;
|
|
22
|
+
'aria-expanded': boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Marks the portaled panel in the DOM. Products and audits (see
|
|
27
|
+
* `playground/scripts/popover-hit-test.mjs`) select on this rather than on a
|
|
28
|
+
* Tailwind class, which is presentation and free to change.
|
|
29
|
+
*
|
|
30
|
+
* Its VALUE is the surface's ancestor path (`outer/inner`), which is what
|
|
31
|
+
* restores "is this click inside my popover" after the portal flattens two
|
|
32
|
+
* nested panels into two siblings of `<body>`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const POPOVER_SURFACE_ATTR = "data-agent-app-popover";
|
|
35
|
+
/**
|
|
36
|
+
* `PopoverSurface` is now mounted (closed) inside every server-rendered
|
|
37
|
+
* composer, so its hooks run on the server once per composer per request.
|
|
38
|
+
* React 18 logs "useLayoutEffect does nothing on the server" for that; React 19
|
|
39
|
+
* does not (measured silent on react-dom 19.2.8). The peer floor is `react >=18`,
|
|
40
|
+
* so bind the synchronous hook only where there is a DOM and the effect hook
|
|
41
|
+
* elsewhere — placement never runs on the server either way.
|
|
42
|
+
*/
|
|
43
|
+
export declare const useBrowserLayoutEffect: typeof useLayoutEffect;
|
|
44
|
+
export interface PopoverSurfaceProps {
|
|
45
|
+
open: boolean;
|
|
46
|
+
/** The trigger the panel anchors to — `usePopover`'s `triggerRef`. */
|
|
47
|
+
triggerRef: RefObject<HTMLElement | null>;
|
|
48
|
+
/** `usePopover`'s `panelRef`; also what the outside-click test consults. */
|
|
49
|
+
panelRef: RefObject<HTMLDivElement | null>;
|
|
50
|
+
/** Presentation classes. Placement and elevation are owned here — a caller
|
|
51
|
+
* must not pass `absolute`/`fixed`/`top-*`/`bottom-*`/`z-*`. */
|
|
52
|
+
className?: string;
|
|
53
|
+
role?: string;
|
|
54
|
+
id?: string;
|
|
55
|
+
'aria-label'?: string;
|
|
56
|
+
/** Make the panel at least as wide as its trigger. A portaled panel has no
|
|
57
|
+
* `w-full` to inherit — the trigger is no longer its offset parent — so a
|
|
58
|
+
* menu that used to stretch to a full-width trigger declares it here. */
|
|
59
|
+
matchTriggerWidth?: boolean;
|
|
60
|
+
/** Preferred side. `above` suits controls docked at the bottom of a composer;
|
|
61
|
+
* `below` suits headers, rows, and rails. Either flips when the other side has more room. */
|
|
62
|
+
side?: 'above' | 'below';
|
|
63
|
+
/** Which trigger edge the panel lines up with. `end` keeps a row's trailing menu over the row. */
|
|
64
|
+
align?: 'start' | 'end';
|
|
65
|
+
/** Opt in to remeasurement when asynchronous or filtered content changes. */
|
|
66
|
+
contentKey?: unknown;
|
|
67
|
+
children: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The floating panel every canonical picker opens.
|
|
71
|
+
*
|
|
72
|
+
* It renders through a PORTAL to `document.body` and anchors itself to the
|
|
73
|
+
* trigger in viewport coordinates, because an in-place `absolute` panel's
|
|
74
|
+
* visibility is decided by markup this package does not own. Measured in
|
|
75
|
+
* production: the shipped chat composer docks these controls inside a
|
|
76
|
+
* horizontally scrolling rail (`overflow-x-auto`), and a scroll container
|
|
77
|
+
* clips every positioned descendant whose containing block sits inside it —
|
|
78
|
+
* so a correct 420x457 menu with correct coordinates painted zero pixels and
|
|
79
|
+
* could not be clicked. An ancestor `transform`/`filter`/`contain` would trap
|
|
80
|
+
* it the same way through the stacking context instead of the clip. Leaving
|
|
81
|
+
* the DOM subtree is the only placement a host cannot re-break.
|
|
82
|
+
*
|
|
83
|
+
* Placement prefers ABOVE the trigger (these controls dock at the bottom of a
|
|
84
|
+
* composer), flips below when there is more room there, clamps horizontally
|
|
85
|
+
* into the viewport, and caps its own height to the space on the chosen side.
|
|
86
|
+
* The panel is `visibility: hidden` for the measure pass so it never paints at
|
|
87
|
+
* the pre-placement origin.
|
|
88
|
+
*/
|
|
89
|
+
export declare function PopoverSurface({ open, triggerRef, panelRef, className, role, id, 'aria-label': ariaLabel, matchTriggerWidth, side, align, contentKey, children, }: PopoverSurfaceProps): import("react").ReactPortal | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard an async action against double-submit. `run` ignores re-entrant calls
|
|
3
|
+
* while a promise is in flight and flips `pending` so the caller can disable
|
|
4
|
+
* the control — the fix for double-charge / double-approve on a slow network.
|
|
5
|
+
* Settles (success or throw) before clearing, and no-ops state updates after
|
|
6
|
+
* unmount.
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePending(): {
|
|
9
|
+
pending: boolean;
|
|
10
|
+
run: (action: () => void | Promise<void>) => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AppToolDefinition } from '../tools/registry';
|
|
2
|
+
import type { WorkProductService } from './service';
|
|
3
|
+
import { type WorkProductToolConfig } from './tool-config';
|
|
4
|
+
/** Register the incremental evidence and exception writes that accumulate a draft. */
|
|
5
|
+
export declare function buildDraftEmissionTools(config: WorkProductToolConfig, service: WorkProductService): AppToolDefinition[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AppToolContext } from '../tools/types';
|
|
2
|
+
import type { WorkProductOutcome, WorkProductService } from './service';
|
|
3
|
+
import { type WorkProductToolConfig } from './tool-config';
|
|
4
|
+
import type { WorkProductRecord } from './types';
|
|
5
|
+
/** Unwrap a guarded outcome, retrying ONCE on a lost race (the single
|
|
6
|
+
* serialized turn owner makes real contention rare; one re-read-and-retry
|
|
7
|
+
* absorbs the benign case). A deterministic rejection maps to a correctable
|
|
8
|
+
* `ToolInputError` so the model learns exactly why. */
|
|
9
|
+
export declare function unwrap<T>(run: () => Promise<WorkProductOutcome<T>>, code: string): Promise<T>;
|
|
10
|
+
export declare function requireScopeKey(args: Record<string, unknown>): string;
|
|
11
|
+
export declare function requireBatch(args: Record<string, unknown>, field: string): unknown[];
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the scope's open draft row, creating or reopening as needed:
|
|
14
|
+
* an open `draft`/`blocked` row resumes; a `changes_requested` row reopens as
|
|
15
|
+
* the correction draft (version +1); a `ready` row refuses — the package is
|
|
16
|
+
* awaiting review and must receive a verdict first; otherwise a fresh draft
|
|
17
|
+
* is created at `last reviewed version + 1` with dispatch-stamped provenance.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveDraft(service: WorkProductService, config: WorkProductToolConfig, scopeKey: string, ctx: AppToolContext): Promise<WorkProductRecord>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { AppToolContext } from '../tools/types';
|
|
2
|
+
import { type ConfusableTargetGroup } from './claim-support';
|
|
3
|
+
import type { WorkProductToolConfig } from './tool-config';
|
|
4
|
+
import type { EvidenceEntry } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Resolve every entry's quote against the document it names — the one place
|
|
7
|
+
* lineage text is decided.
|
|
8
|
+
*
|
|
9
|
+
* Two citation forms, and the asymmetry between them is the point:
|
|
10
|
+
*
|
|
11
|
+
* - `locator.span` — the model names `[start, end)` into text it just read
|
|
12
|
+
* and the PLATFORM slices the quote out of the source bytes. There is no
|
|
13
|
+
* retyping step, so a fabricated quote is not rejected, it is impossible.
|
|
14
|
+
* The slice REPLACES any quote the model also sent (the document is the
|
|
15
|
+
* authority, not the model's transcription of it) and the resolved text
|
|
16
|
+
* goes back in the tool result, so the model sees what was stored.
|
|
17
|
+
* - `locator.quote` alone — the legacy free-text form, still verified
|
|
18
|
+
* character-for-character. Kept because evidence written before spans
|
|
19
|
+
* existed, and sources reached through paths that cannot offer offsets,
|
|
20
|
+
* must stay expressible; a product does not lose lineage by upgrading.
|
|
21
|
+
*
|
|
22
|
+
* Entries are MUTATED in place with the resolved quote and its server-set
|
|
23
|
+
* `quoteBasis`, then persisted — so what a reviewer reads is what the platform
|
|
24
|
+
* proved, not what the model typed.
|
|
25
|
+
*
|
|
26
|
+
* Source texts are read once per distinct `sourceRef` in the batch — a
|
|
27
|
+
* 50-entry batch citing three documents is three reads, not fifty.
|
|
28
|
+
*
|
|
29
|
+
* Without `readSourceText` the product has given the shell no way to see its
|
|
30
|
+
* documents: free-text quotes go unchecked (as before — inventing a weaker
|
|
31
|
+
* check would report unverified lineage as verified), and a span is a LOUD
|
|
32
|
+
* refusal rather than a silently dropped locator, because a span the platform
|
|
33
|
+
* cannot slice is a wiring bug in the product, not a model mistake.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveEvidenceQuotes(config: WorkProductToolConfig, entries: readonly EvidenceEntry[], ctx: AppToolContext): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Refuse any entry whose anchored text does not carry the figure it claims.
|
|
38
|
+
*
|
|
39
|
+
* This runs AFTER `resolveEvidenceQuotes`, on the text the platform decided,
|
|
40
|
+
* and it is deliberately independent of how that text was anchored. `find`
|
|
41
|
+
* makes a mis-addressed citation unlikely — the platform locates the line — but
|
|
42
|
+
* `span` still accepts offsets a caller computed, and this is what "accepted
|
|
43
|
+
* only when they independently verify" means concretely: the slice has to
|
|
44
|
+
* contain the value.
|
|
45
|
+
*
|
|
46
|
+
* Row `7256ef49` is the case. Four span citations, every quote a real slice of
|
|
47
|
+
* the right document, every one ~200 characters above the figure it claimed.
|
|
48
|
+
* `resolveEvidenceQuotes` passed all four; nothing else here would have caught
|
|
49
|
+
* them; a reviewer would have read four authoritative-looking citations
|
|
50
|
+
* supporting nothing.
|
|
51
|
+
*
|
|
52
|
+
* Rejection is a `ToolInputError` so it folds back to the model mid-turn, the
|
|
53
|
+
* same posture a non-occurring quote already gets, and the message names both
|
|
54
|
+
* ways out — cite the value, or drop the locator because the figure was
|
|
55
|
+
* computed. An unsatisfiable gate does not stop a bad submit, it selects for
|
|
56
|
+
* one, so naming the second exit is load-bearing rather than politeness.
|
|
57
|
+
*/
|
|
58
|
+
export declare function assertClaimsSupported(config: WorkProductToolConfig, entries: readonly EvidenceEntry[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* Refuse any entry whose cited line belongs to a sibling target.
|
|
61
|
+
*
|
|
62
|
+
* The fifth degree of freedom, and the one the four gates before it pass by
|
|
63
|
+
* construction: `quote_verification` proves the text is in the document,
|
|
64
|
+
* `claim_support` proves the text carries the claimed figure, and neither
|
|
65
|
+
* asks whether the figure belongs on THIS line. Row `95105c8a` shipped
|
|
66
|
+
* `evidence_coverage 6/6`, `claim_support 19/19`, `quote_verification 19/19`
|
|
67
|
+
* with `line_3a` (qualified dividends) pointing at the ordinary-dividends line
|
|
68
|
+
* and `line_3b` pointing at the qualified one.
|
|
69
|
+
*
|
|
70
|
+
* The product supplies which targets are confusable and what their lines say;
|
|
71
|
+
* the shell only compares. Refusal requires the document to positively name a
|
|
72
|
+
* sibling, so silence passes — see `./claim-support` for why that asymmetry is
|
|
73
|
+
* load-bearing rather than lenient.
|
|
74
|
+
*/
|
|
75
|
+
export declare function assertTargetsNotCrossed(config: WorkProductToolConfig, entries: readonly EvidenceEntry[]): void;
|
|
76
|
+
/** Re-verify every persisted quote at submit time. The upsert gate stops new
|
|
77
|
+
* fabrication; this stops a package whose evidence was written BEFORE the
|
|
78
|
+
* gate existed (or under a since-corrected document) from reaching a
|
|
79
|
+
* reviewer. Entries with no quote are neither verified nor failures — they
|
|
80
|
+
* are lineage with no click target, counted separately so the recorded check
|
|
81
|
+
* states how much of the package is quote-backed.
|
|
82
|
+
*
|
|
83
|
+
* A span-anchored entry is re-checked by RE-SLICING the current document and
|
|
84
|
+
* comparing to the stored text, not by substring search. The difference
|
|
85
|
+
* matters exactly when a source has been replaced since the citation was
|
|
86
|
+
* written: a substring search would still pass if the sentence survived
|
|
87
|
+
* anywhere in the new file, while the reviewer's click target has silently
|
|
88
|
+
* moved. Re-slicing says the offsets still select the same characters. */
|
|
89
|
+
export declare function summarizeQuoteVerification(config: WorkProductToolConfig, evidence: readonly EvidenceEntry[], ctx: AppToolContext): Promise<{
|
|
90
|
+
verified: number;
|
|
91
|
+
spanAnchored: number;
|
|
92
|
+
withoutQuote: number;
|
|
93
|
+
failed: string[];
|
|
94
|
+
} | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Re-run claim support over every PERSISTED entry at submit time.
|
|
97
|
+
*
|
|
98
|
+
* Unlike `summarizeQuoteVerification` this needs no `readSourceText`: the
|
|
99
|
+
* question is whether the stored quote carries the stored claim, and both are
|
|
100
|
+
* on the row. So it runs for every product, including one that cannot read its
|
|
101
|
+
* sources back — and it is the check that catches a package whose evidence was
|
|
102
|
+
* written before this gate existed. Row `7256ef49` is exactly that package.
|
|
103
|
+
*/
|
|
104
|
+
export declare function summarizeClaimSupport(evidence: readonly EvidenceEntry[]): {
|
|
105
|
+
supported: number;
|
|
106
|
+
checkable: number;
|
|
107
|
+
unsupported: string[];
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Re-run target correctness over every PERSISTED entry at submit time — the
|
|
111
|
+
* check that catches a package whose evidence was written before this gate
|
|
112
|
+
* existed. Like `summarizeClaimSupport` it reads only the row (the stored quote
|
|
113
|
+
* and the stored target), so it runs for every product.
|
|
114
|
+
*/
|
|
115
|
+
export declare function summarizeTargetCorrectness(evidence: readonly EvidenceEntry[], groups: readonly ConfusableTargetGroup[], targetOf: (entry: EvidenceEntry) => string): {
|
|
116
|
+
correct: number;
|
|
117
|
+
checkable: number;
|
|
118
|
+
crossed: {
|
|
119
|
+
id: string;
|
|
120
|
+
detail: string;
|
|
121
|
+
}[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Run artifact agreement over every PERSISTED entry against the artifact being
|
|
125
|
+
* submitted — the ONLY place it runs, and the "only" is load-bearing.
|
|
126
|
+
*
|
|
127
|
+
* The obvious second placement is the upsert, for the early feedback, and it
|
|
128
|
+
* makes the gate unsatisfiable on the one path that needs it most. A
|
|
129
|
+
* `changes_requested` row keeps the artifact the reviewer REJECTED, and an
|
|
130
|
+
* agent correcting a crossed package has exactly one order available to it:
|
|
131
|
+
* fix the evidence, then submit the corrected artifact, because the artifact
|
|
132
|
+
* is only settable at submit. Comparing the incoming citation to that stale
|
|
133
|
+
* artifact refuses precisely the correction being asked for —
|
|
134
|
+
*
|
|
135
|
+
* artifact (rejected): line_3a = 2204.18, line_3b = 1955.02
|
|
136
|
+
* agent re-emits: line_3a <- 1955.02 <- the fix
|
|
137
|
+
* stale comparison: "1955.02 is line_3b's value" -> refused, forever
|
|
138
|
+
*
|
|
139
|
+
* so the package can never be repaired. Same failure mode as a coverage gate
|
|
140
|
+
* demanding lineage for a computed value, removed for the same reason: an
|
|
141
|
+
* unsatisfiable rule does not stop bad work, it selects for invented work.
|
|
142
|
+
* Here both halves are current and either can be corrected during the turn.
|
|
143
|
+
*
|
|
144
|
+
* Nothing is lost by waiting. Row `95105c8a` is caught here and could only ever
|
|
145
|
+
* have been caught here — its crossed evidence was written turns before there
|
|
146
|
+
* was an artifact to compare it to.
|
|
147
|
+
*
|
|
148
|
+
* Only a real CONTRADICTION is refused: the claim asserts a figure the same
|
|
149
|
+
* artifact reports on another target. A component of an aggregate is not one
|
|
150
|
+
* (row `a68b1943` evidences a 189,750.00 wage line with two W-2s of 128,450.00
|
|
151
|
+
* and 61,300.00, and must keep doing so).
|
|
152
|
+
*/
|
|
153
|
+
export declare function summarizeArtifactAgreement(evidence: readonly EvidenceEntry[], fieldValues: ReadonlyMap<string, string>, targetOf: (entry: EvidenceEntry) => string): {
|
|
154
|
+
agreeing: number;
|
|
155
|
+
checkable: number;
|
|
156
|
+
contradicting: {
|
|
157
|
+
id: string;
|
|
158
|
+
detail: string;
|
|
159
|
+
}[];
|
|
160
|
+
};
|
|
@@ -431,6 +431,60 @@ function workProductTrustInputs(records, verdictsFor) {
|
|
|
431
431
|
return items;
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
// src/work-product/tool-config.ts
|
|
435
|
+
var MAX_WORK_PRODUCT_BATCH = 50;
|
|
436
|
+
var EVIDENCE_COVERAGE_CHECK = "evidence_coverage";
|
|
437
|
+
var QUOTE_VERIFICATION_CHECK = "quote_verification";
|
|
438
|
+
var CLAIM_SUPPORT_CHECK = "claim_support";
|
|
439
|
+
var TARGET_CORRECTNESS_CHECK = "target_correctness";
|
|
440
|
+
var ARTIFACT_AGREEMENT_CHECK = "artifact_agreement";
|
|
441
|
+
|
|
442
|
+
// src/work-product/draft-tool-context.ts
|
|
443
|
+
async function unwrap(run, code) {
|
|
444
|
+
let outcome = await run();
|
|
445
|
+
if (!outcome.succeeded && outcome.conflict) outcome = await run();
|
|
446
|
+
if (!outcome.succeeded) throw new ToolInputError(code, outcome.error, outcome.conflict ? 409 : 400);
|
|
447
|
+
return outcome.value;
|
|
448
|
+
}
|
|
449
|
+
function requireScopeKey(args) {
|
|
450
|
+
const scopeKey = typeof args.scopeKey === "string" ? args.scopeKey.trim() : "";
|
|
451
|
+
if (!scopeKey) throw new ToolInputError("missing_scope_key", "scopeKey is required \u2014 the engagement key this work product belongs to.");
|
|
452
|
+
return scopeKey;
|
|
453
|
+
}
|
|
454
|
+
function requireBatch(args, field) {
|
|
455
|
+
const raw = args[field];
|
|
456
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
457
|
+
throw new ToolInputError("missing_entries", `${field} must be a non-empty array.`);
|
|
458
|
+
}
|
|
459
|
+
if (raw.length > MAX_WORK_PRODUCT_BATCH) {
|
|
460
|
+
throw new ToolInputError("batch_too_large", `${field} accepts at most ${MAX_WORK_PRODUCT_BATCH} entries per call \u2014 send smaller batches.`);
|
|
461
|
+
}
|
|
462
|
+
return raw;
|
|
463
|
+
}
|
|
464
|
+
async function resolveDraft(service, config, scopeKey, ctx) {
|
|
465
|
+
const open = await service.openDraft(ctx.workspaceId, scopeKey);
|
|
466
|
+
if (open) return open;
|
|
467
|
+
const awaitingReview = await service.awaitingReview(ctx.workspaceId, scopeKey);
|
|
468
|
+
if (awaitingReview) {
|
|
469
|
+
throw new ToolInputError(
|
|
470
|
+
"awaiting_review",
|
|
471
|
+
`Work product for ${scopeKey} (v${awaitingReview.version}) is awaiting review \u2014 no further emission until a reviewer verdict.`,
|
|
472
|
+
409
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
const awaitingCorrection = await service.awaitingCorrection(ctx.workspaceId, scopeKey);
|
|
476
|
+
if (awaitingCorrection) {
|
|
477
|
+
return unwrap(() => service.reopen(awaitingCorrection.id), "reopen_failed");
|
|
478
|
+
}
|
|
479
|
+
return service.create({
|
|
480
|
+
workspaceId: ctx.workspaceId,
|
|
481
|
+
threadId: ctx.threadId,
|
|
482
|
+
scopeKey,
|
|
483
|
+
version: await service.nextVersion(ctx.workspaceId, scopeKey),
|
|
484
|
+
provenance: stampProvenance(config.provenance(ctx), config.now)
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
|
|
434
488
|
// src/work-product/quote.ts
|
|
435
489
|
var WHITESPACE = /[\s\p{Zs}\u2028\u2029\u200b-\u200d\ufeff]+/gu;
|
|
436
490
|
var DASHES = /[\u2010-\u2015\u2212\ufe58\ufe63\uff0d]/gu;
|
|
@@ -518,57 +572,7 @@ function sliceSourceSpan(sourceText, span) {
|
|
|
518
572
|
return { ok: true, quote };
|
|
519
573
|
}
|
|
520
574
|
|
|
521
|
-
// src/work-product/
|
|
522
|
-
var MAX_WORK_PRODUCT_BATCH = 50;
|
|
523
|
-
var EVIDENCE_COVERAGE_CHECK = "evidence_coverage";
|
|
524
|
-
var QUOTE_VERIFICATION_CHECK = "quote_verification";
|
|
525
|
-
var CLAIM_SUPPORT_CHECK = "claim_support";
|
|
526
|
-
var TARGET_CORRECTNESS_CHECK = "target_correctness";
|
|
527
|
-
var ARTIFACT_AGREEMENT_CHECK = "artifact_agreement";
|
|
528
|
-
async function unwrap(run, code) {
|
|
529
|
-
let outcome = await run();
|
|
530
|
-
if (!outcome.succeeded && outcome.conflict) outcome = await run();
|
|
531
|
-
if (!outcome.succeeded) throw new ToolInputError(code, outcome.error, outcome.conflict ? 409 : 400);
|
|
532
|
-
return outcome.value;
|
|
533
|
-
}
|
|
534
|
-
function requireScopeKey(args) {
|
|
535
|
-
const scopeKey = typeof args.scopeKey === "string" ? args.scopeKey.trim() : "";
|
|
536
|
-
if (!scopeKey) throw new ToolInputError("missing_scope_key", "scopeKey is required \u2014 the engagement key this work product belongs to.");
|
|
537
|
-
return scopeKey;
|
|
538
|
-
}
|
|
539
|
-
function requireBatch(args, field) {
|
|
540
|
-
const raw = args[field];
|
|
541
|
-
if (!Array.isArray(raw) || raw.length === 0) {
|
|
542
|
-
throw new ToolInputError("missing_entries", `${field} must be a non-empty array.`);
|
|
543
|
-
}
|
|
544
|
-
if (raw.length > MAX_WORK_PRODUCT_BATCH) {
|
|
545
|
-
throw new ToolInputError("batch_too_large", `${field} accepts at most ${MAX_WORK_PRODUCT_BATCH} entries per call \u2014 send smaller batches.`);
|
|
546
|
-
}
|
|
547
|
-
return raw;
|
|
548
|
-
}
|
|
549
|
-
async function resolveDraft(service, config, scopeKey, ctx) {
|
|
550
|
-
const open = await service.openDraft(ctx.workspaceId, scopeKey);
|
|
551
|
-
if (open) return open;
|
|
552
|
-
const awaitingReview = await service.awaitingReview(ctx.workspaceId, scopeKey);
|
|
553
|
-
if (awaitingReview) {
|
|
554
|
-
throw new ToolInputError(
|
|
555
|
-
"awaiting_review",
|
|
556
|
-
`Work product for ${scopeKey} (v${awaitingReview.version}) is awaiting review \u2014 no further emission until a reviewer verdict.`,
|
|
557
|
-
409
|
|
558
|
-
);
|
|
559
|
-
}
|
|
560
|
-
const awaitingCorrection = await service.awaitingCorrection(ctx.workspaceId, scopeKey);
|
|
561
|
-
if (awaitingCorrection) {
|
|
562
|
-
return unwrap(() => service.reopen(awaitingCorrection.id), "reopen_failed");
|
|
563
|
-
}
|
|
564
|
-
return service.create({
|
|
565
|
-
workspaceId: ctx.workspaceId,
|
|
566
|
-
threadId: ctx.threadId,
|
|
567
|
-
scopeKey,
|
|
568
|
-
version: await service.nextVersion(ctx.workspaceId, scopeKey),
|
|
569
|
-
provenance: stampProvenance(config.provenance(ctx), config.now)
|
|
570
|
-
});
|
|
571
|
-
}
|
|
575
|
+
// src/work-product/evidence-verification.ts
|
|
572
576
|
function spanErrorDetail(failure) {
|
|
573
577
|
switch (failure.reason) {
|
|
574
578
|
case "not_integer":
|
|
@@ -788,12 +792,9 @@ function summarizeArtifactAgreement(evidence, fieldValues, targetOf) {
|
|
|
788
792
|
}
|
|
789
793
|
return { agreeing, checkable, contradicting };
|
|
790
794
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
...config.now ? { now: config.now } : {},
|
|
795
|
-
...config.generateId ? { generateId: config.generateId } : {}
|
|
796
|
-
});
|
|
795
|
+
|
|
796
|
+
// src/work-product/draft-emission-tools.ts
|
|
797
|
+
function buildDraftEmissionTools(config, service) {
|
|
797
798
|
const canResolveTextLocators = config.readSourceText !== void 0;
|
|
798
799
|
const locatorProperties = {
|
|
799
800
|
page: { type: "number" },
|
|
@@ -950,7 +951,12 @@ function buildWorkProductTools(config) {
|
|
|
950
951
|
};
|
|
951
952
|
}
|
|
952
953
|
});
|
|
953
|
-
|
|
954
|
+
return [upsertEvidence, flagException];
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/work-product/submission-tool.ts
|
|
958
|
+
function buildSubmissionTool(config, service) {
|
|
959
|
+
return defineAppTool({
|
|
954
960
|
name: "submit_work_product",
|
|
955
961
|
description: "Submit the finished work product for professional review \u2014 the terminal call after evidence and exceptions are recorded. Refused while a blocking exception is unresolved, or when a material target lacks evidence. Include your own quality checks in `checks`.",
|
|
956
962
|
parameters: {
|
|
@@ -1144,7 +1150,16 @@ function buildWorkProductTools(config) {
|
|
|
1144
1150
|
};
|
|
1145
1151
|
}
|
|
1146
1152
|
});
|
|
1147
|
-
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
// src/work-product/tools.ts
|
|
1156
|
+
function buildWorkProductTools(config) {
|
|
1157
|
+
const service = createWorkProductService({
|
|
1158
|
+
store: config.store,
|
|
1159
|
+
...config.now ? { now: config.now } : {},
|
|
1160
|
+
...config.generateId ? { generateId: config.generateId } : {}
|
|
1161
|
+
});
|
|
1162
|
+
return [...buildDraftEmissionTools(config, service), buildSubmissionTool(config, service)];
|
|
1148
1163
|
}
|
|
1149
1164
|
|
|
1150
1165
|
// src/work-product/route.ts
|