@locusgraph/loop 0.5.0 → 0.6.1
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 +10 -2
- package/dist/approval/gate/approval-gate.d.ts +7 -0
- package/dist/approval/gate/approval-gate.js +51 -0
- package/dist/approval/gate/use-approval-gate.d.ts +30 -0
- package/dist/approval/gate/use-approval-gate.js +210 -0
- package/dist/approval/index.d.ts +3 -0
- package/dist/approval/index.js +3 -0
- package/dist/approval/log/decision-log.d.ts +7 -0
- package/dist/approval/log/decision-log.js +93 -0
- package/dist/approval/spend/spend-meter.js +1 -1
- package/dist/approval/tool/approval.d.ts +4 -2
- package/dist/approval/tool/approval.js +55 -42
- package/dist/approval/tool/change-preview.d.ts +4 -0
- package/dist/approval/tool/change-preview.js +50 -0
- package/dist/approval/tool/tool-inputs.js +4 -4
- package/dist/approval/types.d.ts +13 -0
- package/dist/chat/chat/chat.js +1 -1
- package/dist/chat/composer/composer-actions.js +1 -0
- package/dist/chat/composer/composer.js +2 -2
- package/dist/cost/shared/context-breakdown.js +2 -2
- package/dist/cost/shared/meter-marks.js +2 -2
- package/dist/cost/shared/step-cost-row.js +1 -1
- package/dist/shared/decision-summary.d.ts +4 -1
- package/dist/shared/decision-summary.js +16 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# @locusgraph/loop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img alt="Locus Design: design that keeps humans in the loop" src="https://raw.githubusercontent.com/locusgraph/design/master/.github/assets/hero-light.png">
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@locusgraph/loop) [](https://github.com/locusgraph/design/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
[Docs](https://design.locusgraph.com/human-in-the-loop) · [Source](https://github.com/locusgraph/design/tree/master/packages/loop) · [All packages](https://github.com/locusgraph/design#packages)
|
|
8
|
+
|
|
9
|
+
Loop is the agent kit from Locus Design: chat, what the agent is doing, human-in-the-loop approvals, memory and cost. Components take data and callbacks only and never call a model. Message shapes follow the Vercel AI SDK `UIMessage` parts, so `useChat()` output can be passed straight in.
|
|
4
10
|
|
|
5
11
|
```bash
|
|
6
12
|
pnpm add @locusgraph/loop @locusgraph/components
|
|
@@ -29,10 +35,12 @@ import { Chat, Composer, Turn } from "@locusgraph/loop";
|
|
|
29
35
|
| Chat | `Chat`, `Turn`, `Reply`, `Composer`, `Files` |
|
|
30
36
|
| Thread | `Starters`, `Actions`, `History`, `Code`, `Canvas` |
|
|
31
37
|
| Agent | `Thinking`, `Steps`, `Tool`, `Pulse` |
|
|
32
|
-
| Human in the loop | `Approval`, `ArgsEditor`, `PlanReview`, `Question`, `SpendGate`, `MemoryReview`, `RunBar`, `Inbox` |
|
|
38
|
+
| Human in the loop | `Approval`, `ArgsEditor`, `PlanReview`, `Question`, `SpendGate`, `MemoryReview`, `RunBar`, `Inbox`, `ApprovalGate` with `useApprovalGate`, `DecisionLog` |
|
|
33
39
|
| Memory | `Cite`, `Sources`, `Recall`, `Memorized` |
|
|
34
40
|
| Cost | `Context`, `Cost`, `CostSteps`, `ModelPicker` |
|
|
35
41
|
|
|
36
42
|
`Turn` renders reasoning, tool and source parts with `Thinking`, `Tool` and `Sources`; pass `renderReasoning`, `renderTool` or `renderSources` to replace them. Data parts (`data-*`, such as a json-render `data-spec`) render only through `renderData`; without it they are skipped. A tool part in the `approval-requested` state is where `Approval` goes: wire its `onApprove` and `onDeny` to the AI SDK's tool approval response.
|
|
37
43
|
|
|
38
44
|
Approvals follow one rule: tools that only read run without asking; tools that write, pay, send or delete pause and show exactly what is being approved, with stronger warnings for destructive ones. Money is integer micro-USD, formatted with `@locusgraph/utils`.
|
|
45
|
+
|
|
46
|
+
`Approval` takes `changes` to show what an action will change, before and after, and `onAllowForRun` to stop asking for that tool for the rest of the run (never offered for destructive tools). `useApprovalGate` puts an approval in front of any action, including a button a model generated: `await gate.ask({ toolName, risk, input })` settles when a person decides, `<ApprovalGate gate={gate} />` renders it, and `gate.log` feeds `<DecisionLog />`.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApprovalGateController } from "./use-approval-gate.js";
|
|
2
|
+
export type ApprovalGateProps = {
|
|
3
|
+
gate: ApprovalGateController;
|
|
4
|
+
allowForRun?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function ApprovalGate({ gate, allowForRun, className }: ApprovalGateProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { Approval } from "../tool/approval.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function ApprovalGate(t0) {
|
|
7
|
+
const $ = _c(11);
|
|
8
|
+
const {
|
|
9
|
+
gate,
|
|
10
|
+
allowForRun: t1,
|
|
11
|
+
className
|
|
12
|
+
} = t0;
|
|
13
|
+
const allowForRun = t1 === undefined ? true : t1;
|
|
14
|
+
if (!gate.open) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
part,
|
|
19
|
+
request
|
|
20
|
+
} = gate.open;
|
|
21
|
+
const t2 = allowForRun ? gate.allowForRun : undefined;
|
|
22
|
+
let t3;
|
|
23
|
+
if ($[0] !== className || $[1] !== gate.approve || $[2] !== gate.decision || $[3] !== gate.deny || $[4] !== part || $[5] !== request.actionLabel || $[6] !== request.changes || $[7] !== request.description || $[8] !== request.risk || $[9] !== t2) {
|
|
24
|
+
t3 = /*#__PURE__*/_jsx(Approval, {
|
|
25
|
+
part: part,
|
|
26
|
+
risk: request.risk,
|
|
27
|
+
actionLabel: request.actionLabel,
|
|
28
|
+
description: request.description,
|
|
29
|
+
changes: request.changes,
|
|
30
|
+
decision: gate.decision,
|
|
31
|
+
onApprove: gate.approve,
|
|
32
|
+
onDeny: gate.deny,
|
|
33
|
+
onAllowForRun: t2,
|
|
34
|
+
className: className
|
|
35
|
+
}, part.toolCallId);
|
|
36
|
+
$[0] = className;
|
|
37
|
+
$[1] = gate.approve;
|
|
38
|
+
$[2] = gate.decision;
|
|
39
|
+
$[3] = gate.deny;
|
|
40
|
+
$[4] = part;
|
|
41
|
+
$[5] = request.actionLabel;
|
|
42
|
+
$[6] = request.changes;
|
|
43
|
+
$[7] = request.description;
|
|
44
|
+
$[8] = request.risk;
|
|
45
|
+
$[9] = t2;
|
|
46
|
+
$[10] = t3;
|
|
47
|
+
} else {
|
|
48
|
+
t3 = $[10];
|
|
49
|
+
}
|
|
50
|
+
return t3;
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RiskLevel, ToolPart } from "../../types.js";
|
|
2
|
+
import type { ApprovalChange, ApprovalDecision, DecidedAt, DecisionLogEntry } from "../types.js";
|
|
3
|
+
export type ApprovalRequest = {
|
|
4
|
+
toolName: string;
|
|
5
|
+
input?: unknown;
|
|
6
|
+
risk?: RiskLevel;
|
|
7
|
+
title?: string;
|
|
8
|
+
actionLabel?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
changes?: ApprovalChange[];
|
|
11
|
+
};
|
|
12
|
+
export type OpenApproval = {
|
|
13
|
+
request: ApprovalRequest;
|
|
14
|
+
part: ToolPart;
|
|
15
|
+
};
|
|
16
|
+
export type UseApprovalGateOptions = {
|
|
17
|
+
by?: string;
|
|
18
|
+
now?: () => DecidedAt;
|
|
19
|
+
};
|
|
20
|
+
export type ApprovalGateController = {
|
|
21
|
+
open: OpenApproval | null;
|
|
22
|
+
decision?: ApprovalDecision;
|
|
23
|
+
log: DecisionLogEntry[];
|
|
24
|
+
ask: (request: ApprovalRequest) => Promise<ApprovalDecision>;
|
|
25
|
+
approve: () => void;
|
|
26
|
+
deny: (reason?: string) => void;
|
|
27
|
+
allowForRun: () => void;
|
|
28
|
+
resetRun: () => void;
|
|
29
|
+
};
|
|
30
|
+
export declare function useApprovalGate({ by, now, }?: UseApprovalGateOptions): ApprovalGateController;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
const supersededReason = "A newer request replaced this one";
|
|
6
|
+
const allowedForRunBy = "Allowed for this run";
|
|
7
|
+
function partFor(request, toolCallId) {
|
|
8
|
+
return {
|
|
9
|
+
type: `tool-${request.toolName}`,
|
|
10
|
+
toolCallId,
|
|
11
|
+
state: "approval-requested",
|
|
12
|
+
input: request.input
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function titleOf(request) {
|
|
16
|
+
return request.title ?? request.actionLabel ?? request.toolName;
|
|
17
|
+
}
|
|
18
|
+
export function useApprovalGate(t0) {
|
|
19
|
+
const $ = _c(26);
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] !== t0) {
|
|
22
|
+
t1 = t0 === undefined ? {} : t0;
|
|
23
|
+
$[0] = t0;
|
|
24
|
+
$[1] = t1;
|
|
25
|
+
} else {
|
|
26
|
+
t1 = $[1];
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
by: t2,
|
|
30
|
+
now: t3
|
|
31
|
+
} = t1;
|
|
32
|
+
const by = t2 === undefined ? "You" : t2;
|
|
33
|
+
const now = t3 === undefined ? Date.now : t3;
|
|
34
|
+
const [open, setOpen] = useState(null);
|
|
35
|
+
const [decision, setDecision] = useState();
|
|
36
|
+
let t4;
|
|
37
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
38
|
+
t4 = [];
|
|
39
|
+
$[2] = t4;
|
|
40
|
+
} else {
|
|
41
|
+
t4 = $[2];
|
|
42
|
+
}
|
|
43
|
+
const [log, setLog] = useState(t4);
|
|
44
|
+
const resolveRef = useRef(null);
|
|
45
|
+
const openRef = useRef(null);
|
|
46
|
+
let t5;
|
|
47
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
48
|
+
t5 = new Set();
|
|
49
|
+
$[3] = t5;
|
|
50
|
+
} else {
|
|
51
|
+
t5 = $[3];
|
|
52
|
+
}
|
|
53
|
+
const allowedRef = useRef(t5);
|
|
54
|
+
const countRef = useRef(0);
|
|
55
|
+
let t6;
|
|
56
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
57
|
+
t6 = () => {
|
|
58
|
+
countRef.current = countRef.current + 1;
|
|
59
|
+
return `decision_${countRef.current}`;
|
|
60
|
+
};
|
|
61
|
+
$[4] = t6;
|
|
62
|
+
} else {
|
|
63
|
+
t6 = $[4];
|
|
64
|
+
}
|
|
65
|
+
const nextId = t6;
|
|
66
|
+
let t7;
|
|
67
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
+
t7 = (request, next, kind, detail) => {
|
|
69
|
+
const entry = {
|
|
70
|
+
id: nextId(),
|
|
71
|
+
title: titleOf(request),
|
|
72
|
+
kind,
|
|
73
|
+
decision: next,
|
|
74
|
+
detail
|
|
75
|
+
};
|
|
76
|
+
setLog(current => [...current, entry]);
|
|
77
|
+
};
|
|
78
|
+
$[5] = t7;
|
|
79
|
+
} else {
|
|
80
|
+
t7 = $[5];
|
|
81
|
+
}
|
|
82
|
+
const record = t7;
|
|
83
|
+
let t8;
|
|
84
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
85
|
+
t8 = (next_0, kind_0, detail_0) => {
|
|
86
|
+
const current_0 = openRef.current;
|
|
87
|
+
if (!current_0 || !resolveRef.current) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setDecision(next_0);
|
|
91
|
+
record(current_0.request, next_0, kind_0, detail_0);
|
|
92
|
+
resolveRef.current(next_0);
|
|
93
|
+
resolveRef.current = null;
|
|
94
|
+
};
|
|
95
|
+
$[6] = t8;
|
|
96
|
+
} else {
|
|
97
|
+
t8 = $[6];
|
|
98
|
+
}
|
|
99
|
+
const settle = t8;
|
|
100
|
+
let t9;
|
|
101
|
+
if ($[7] !== by || $[8] !== now) {
|
|
102
|
+
t9 = request_0 => {
|
|
103
|
+
if (request_0.risk !== "destructive" && allowedRef.current.has(request_0.toolName)) {
|
|
104
|
+
const allowed = {
|
|
105
|
+
approved: true,
|
|
106
|
+
by: allowedForRunBy,
|
|
107
|
+
at: now()
|
|
108
|
+
};
|
|
109
|
+
record(request_0, allowed, "rule");
|
|
110
|
+
return Promise.resolve(allowed);
|
|
111
|
+
}
|
|
112
|
+
settle({
|
|
113
|
+
approved: false,
|
|
114
|
+
by,
|
|
115
|
+
at: now(),
|
|
116
|
+
reason: supersededReason
|
|
117
|
+
}, "approval");
|
|
118
|
+
const next_1 = {
|
|
119
|
+
request: request_0,
|
|
120
|
+
part: partFor(request_0, nextId())
|
|
121
|
+
};
|
|
122
|
+
openRef.current = next_1;
|
|
123
|
+
setOpen(next_1);
|
|
124
|
+
setDecision(undefined);
|
|
125
|
+
return new Promise(resolve => {
|
|
126
|
+
resolveRef.current = resolve;
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
$[7] = by;
|
|
130
|
+
$[8] = now;
|
|
131
|
+
$[9] = t9;
|
|
132
|
+
} else {
|
|
133
|
+
t9 = $[9];
|
|
134
|
+
}
|
|
135
|
+
const ask = t9;
|
|
136
|
+
let t10;
|
|
137
|
+
if ($[10] !== by || $[11] !== now) {
|
|
138
|
+
t10 = () => {
|
|
139
|
+
const current_1 = openRef.current;
|
|
140
|
+
if (!current_1) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
allowedRef.current.add(current_1.request.toolName);
|
|
144
|
+
settle({
|
|
145
|
+
approved: true,
|
|
146
|
+
by,
|
|
147
|
+
at: now()
|
|
148
|
+
}, "approval", "Allowed for the rest of this run");
|
|
149
|
+
};
|
|
150
|
+
$[10] = by;
|
|
151
|
+
$[11] = now;
|
|
152
|
+
$[12] = t10;
|
|
153
|
+
} else {
|
|
154
|
+
t10 = $[12];
|
|
155
|
+
}
|
|
156
|
+
const allowForRun = t10;
|
|
157
|
+
let t11;
|
|
158
|
+
let t12;
|
|
159
|
+
if ($[13] !== by || $[14] !== now) {
|
|
160
|
+
t11 = () => settle({
|
|
161
|
+
approved: true,
|
|
162
|
+
by,
|
|
163
|
+
at: now()
|
|
164
|
+
}, "approval");
|
|
165
|
+
t12 = reason => settle({
|
|
166
|
+
approved: false,
|
|
167
|
+
by,
|
|
168
|
+
at: now(),
|
|
169
|
+
reason
|
|
170
|
+
}, "approval");
|
|
171
|
+
$[13] = by;
|
|
172
|
+
$[14] = now;
|
|
173
|
+
$[15] = t11;
|
|
174
|
+
$[16] = t12;
|
|
175
|
+
} else {
|
|
176
|
+
t11 = $[15];
|
|
177
|
+
t12 = $[16];
|
|
178
|
+
}
|
|
179
|
+
let t13;
|
|
180
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
181
|
+
t13 = () => allowedRef.current.clear();
|
|
182
|
+
$[17] = t13;
|
|
183
|
+
} else {
|
|
184
|
+
t13 = $[17];
|
|
185
|
+
}
|
|
186
|
+
let t14;
|
|
187
|
+
if ($[18] !== allowForRun || $[19] !== ask || $[20] !== decision || $[21] !== log || $[22] !== open || $[23] !== t11 || $[24] !== t12) {
|
|
188
|
+
t14 = {
|
|
189
|
+
open,
|
|
190
|
+
decision,
|
|
191
|
+
log,
|
|
192
|
+
ask,
|
|
193
|
+
approve: t11,
|
|
194
|
+
deny: t12,
|
|
195
|
+
allowForRun,
|
|
196
|
+
resetRun: t13
|
|
197
|
+
};
|
|
198
|
+
$[18] = allowForRun;
|
|
199
|
+
$[19] = ask;
|
|
200
|
+
$[20] = decision;
|
|
201
|
+
$[21] = log;
|
|
202
|
+
$[22] = open;
|
|
203
|
+
$[23] = t11;
|
|
204
|
+
$[24] = t12;
|
|
205
|
+
$[25] = t14;
|
|
206
|
+
} else {
|
|
207
|
+
t14 = $[25];
|
|
208
|
+
}
|
|
209
|
+
return t14;
|
|
210
|
+
}
|
package/dist/approval/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from "./gate/approval-gate.js";
|
|
2
|
+
export * from "./gate/use-approval-gate.js";
|
|
1
3
|
export * from "./inbox/inbox.js";
|
|
4
|
+
export * from "./log/decision-log.js";
|
|
2
5
|
export * from "./memory/memory-review.js";
|
|
3
6
|
export * from "./plan/plan-review.js";
|
|
4
7
|
export * from "./plan/question.js";
|
package/dist/approval/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from "./gate/approval-gate.js";
|
|
2
|
+
export * from "./gate/use-approval-gate.js";
|
|
1
3
|
export * from "./inbox/inbox.js";
|
|
4
|
+
export * from "./log/decision-log.js";
|
|
2
5
|
export * from "./memory/memory-review.js";
|
|
3
6
|
export * from "./plan/plan-review.js";
|
|
4
7
|
export * from "./plan/question.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DecisionLogEntry } from "../types.js";
|
|
2
|
+
export type DecisionLogProps = {
|
|
3
|
+
entries: DecisionLogEntry[];
|
|
4
|
+
emptyText?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function DecisionLog({ entries, emptyText, className, }: DecisionLogProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { cn } from "@locusgraph/components";
|
|
2
|
+
import { DecisionSummary, isoOf } from "../../shared/decision-summary.js";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
const kindVerbs = {
|
|
5
|
+
approval: {
|
|
6
|
+
approved: "Approved",
|
|
7
|
+
denied: "Denied"
|
|
8
|
+
},
|
|
9
|
+
spend: {
|
|
10
|
+
approved: "Allowed",
|
|
11
|
+
denied: "Stopped"
|
|
12
|
+
},
|
|
13
|
+
stop: {
|
|
14
|
+
approved: "Resumed",
|
|
15
|
+
denied: "Stopped"
|
|
16
|
+
},
|
|
17
|
+
rule: {
|
|
18
|
+
approved: "Allowed by a rule",
|
|
19
|
+
denied: "Blocked by a rule"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function dayOf(entry) {
|
|
23
|
+
return entry.decision.at === undefined ? undefined : isoOf(entry.decision.at)?.slice(0, 10);
|
|
24
|
+
}
|
|
25
|
+
function timeStylesFor(entries) {
|
|
26
|
+
const days = entries.map(dayOf);
|
|
27
|
+
const allOnOneDay = new Set(days).size <= 1;
|
|
28
|
+
return days.map((day, index) => allOnOneDay || index > 0 && days[index - 1] === day ? "time" : "full");
|
|
29
|
+
}
|
|
30
|
+
function summaryAndNotes(entry) {
|
|
31
|
+
const {
|
|
32
|
+
reason,
|
|
33
|
+
by,
|
|
34
|
+
...rest
|
|
35
|
+
} = entry.decision;
|
|
36
|
+
const isRule = entry.kind === "rule";
|
|
37
|
+
const decision = isRule || by === undefined ? rest : {
|
|
38
|
+
...rest,
|
|
39
|
+
by
|
|
40
|
+
};
|
|
41
|
+
const notes = [isRule ? by : undefined, entry.detail, reason].filter(note => Boolean(note));
|
|
42
|
+
return {
|
|
43
|
+
decision,
|
|
44
|
+
notes
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function TimelineRail() {
|
|
48
|
+
return /*#__PURE__*/_jsx("span", {
|
|
49
|
+
"aria-hidden": true,
|
|
50
|
+
"data-slot": "decision-log-rail",
|
|
51
|
+
className: "absolute top-5 -bottom-4 left-2 w-px -translate-x-1/2 bg-faint/60"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export function DecisionLog({
|
|
55
|
+
entries,
|
|
56
|
+
emptyText = "No decisions yet.",
|
|
57
|
+
className
|
|
58
|
+
}) {
|
|
59
|
+
if (entries.length === 0) {
|
|
60
|
+
return /*#__PURE__*/_jsx("p", {
|
|
61
|
+
"data-slot": "decision-log",
|
|
62
|
+
className: cn("text-sm text-faint", className),
|
|
63
|
+
children: emptyText
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const timeStyles = timeStylesFor(entries);
|
|
67
|
+
return /*#__PURE__*/_jsx("ol", {
|
|
68
|
+
"data-slot": "decision-log",
|
|
69
|
+
"aria-label": "Decision log",
|
|
70
|
+
className: cn("flex flex-col gap-4", className),
|
|
71
|
+
children: entries.map((entry, index) => {
|
|
72
|
+
const kind = entry.kind ?? "approval";
|
|
73
|
+
const {
|
|
74
|
+
decision,
|
|
75
|
+
notes
|
|
76
|
+
} = summaryAndNotes(entry);
|
|
77
|
+
return /*#__PURE__*/_jsxs("li", {
|
|
78
|
+
"data-kind": kind,
|
|
79
|
+
className: "relative flex flex-col gap-0.5",
|
|
80
|
+
children: [index < entries.length - 1 && /*#__PURE__*/_jsx(TimelineRail, {}), /*#__PURE__*/_jsx(DecisionSummary, {
|
|
81
|
+
decision: decision,
|
|
82
|
+
result: entry.title,
|
|
83
|
+
approvedVerb: kindVerbs[kind].approved,
|
|
84
|
+
deniedVerb: kindVerbs[kind].denied,
|
|
85
|
+
timeStyle: timeStyles[index]
|
|
86
|
+
}), notes.map(note => /*#__PURE__*/_jsx("p", {
|
|
87
|
+
className: "pl-6.5 text-xs text-muted-foreground",
|
|
88
|
+
children: note
|
|
89
|
+
}, note))]
|
|
90
|
+
}, entry.id);
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -127,7 +127,7 @@ export function SpendMeter(props) {
|
|
|
127
127
|
}
|
|
128
128
|
}), /*#__PURE__*/_jsx("span", {
|
|
129
129
|
"aria-hidden": true,
|
|
130
|
-
className: cn("absolute inset-y-0", muted ? "bg-muted-foreground/25" : outOfCredits ? "bg-destructive" : "bg-warn"),
|
|
130
|
+
className: cn("absolute inset-y-0", muted ? "bg-muted-foreground/25" : outOfCredits ? "bg-destructive" : "bg-warn-fill"),
|
|
131
131
|
style: {
|
|
132
132
|
left: `${baseWidth}%`,
|
|
133
133
|
width: `${estimateWidth}%`
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { type RiskLevel, type ToolPart } from "../../types.js";
|
|
2
|
-
import type { ApprovalDecision } from "../types.js";
|
|
2
|
+
import type { ApprovalChange, ApprovalDecision } from "../types.js";
|
|
3
3
|
export type ApprovalProps = {
|
|
4
4
|
part: ToolPart;
|
|
5
5
|
risk?: RiskLevel;
|
|
6
6
|
actionLabel?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
decision?: ApprovalDecision;
|
|
9
|
+
changes?: ApprovalChange[];
|
|
9
10
|
onApprove: () => void;
|
|
10
11
|
onDeny: (reason?: string) => void;
|
|
12
|
+
onAllowForRun?: () => void;
|
|
11
13
|
autoFocus?: boolean;
|
|
12
14
|
className?: string;
|
|
13
15
|
};
|
|
14
|
-
export declare function Approval({ part, risk, actionLabel, description, decision, onApprove, onDeny, autoFocus, className, }: ApprovalProps): import("react").JSX.Element;
|
|
16
|
+
export declare function Approval({ part, risk, actionLabel, description, decision, changes, onApprove, onDeny, onAllowForRun, autoFocus, className, }: ApprovalProps): import("react").JSX.Element;
|
|
@@ -11,6 +11,7 @@ import { ApprovalHeadline, SettledLine } from "../shared/approval-line.js";
|
|
|
11
11
|
import { riskCopy } from "../shared/risk-badge.js";
|
|
12
12
|
import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
|
|
13
13
|
import { useFocusWhenSettled } from "../shared/use-focus-when-settled.js";
|
|
14
|
+
import { ChangePreview } from "./change-preview.js";
|
|
14
15
|
import { DenyForm } from "./deny-form.js";
|
|
15
16
|
import { ToolInputs } from "./tool-inputs.js";
|
|
16
17
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -27,15 +28,17 @@ function decidedResult(toolName, state, decision) {
|
|
|
27
28
|
return settledStateLabels[state] ?? `${toolName} ${decision.approved ? "approved" : "denied"}`;
|
|
28
29
|
}
|
|
29
30
|
export function Approval(t0) {
|
|
30
|
-
const $ = _c(
|
|
31
|
+
const $ = _c(42);
|
|
31
32
|
const {
|
|
32
33
|
part,
|
|
33
34
|
risk: t1,
|
|
34
35
|
actionLabel,
|
|
35
36
|
description,
|
|
36
37
|
decision,
|
|
38
|
+
changes,
|
|
37
39
|
onApprove,
|
|
38
40
|
onDeny,
|
|
41
|
+
onAllowForRun,
|
|
39
42
|
autoFocus: t2,
|
|
40
43
|
className
|
|
41
44
|
} = t0;
|
|
@@ -72,7 +75,7 @@ export function Approval(t0) {
|
|
|
72
75
|
t7 = $[5];
|
|
73
76
|
}
|
|
74
77
|
let t8;
|
|
75
|
-
if ($[6] !== actionLabel || $[7] !== approveRef || $[8] !== awaiting || $[9] !==
|
|
78
|
+
if ($[6] !== actionLabel || $[7] !== approveRef || $[8] !== awaiting || $[9] !== changes || $[10] !== denying || $[11] !== description || $[12] !== destructive || $[13] !== name || $[14] !== onAllowForRun || $[15] !== onApprove || $[16] !== onDeny || $[17] !== part || $[18] !== risk) {
|
|
76
79
|
t8 = awaiting && /*#__PURE__*/_jsxs(_Fragment, {
|
|
77
80
|
children: [/*#__PURE__*/_jsx(ApprovalHeadline, {
|
|
78
81
|
name: name,
|
|
@@ -85,6 +88,8 @@ export function Approval(t0) {
|
|
|
85
88
|
input: part.input,
|
|
86
89
|
muted: denying
|
|
87
90
|
})
|
|
91
|
+
}), changes && changes.length > 0 && /*#__PURE__*/_jsx(ChangePreview, {
|
|
92
|
+
changes: changes
|
|
88
93
|
}), denying ? /*#__PURE__*/_jsx(DenyForm, {
|
|
89
94
|
onDeny: onDeny,
|
|
90
95
|
onBack: () => setDenying(false)
|
|
@@ -97,6 +102,12 @@ export function Approval(t0) {
|
|
|
97
102
|
variant: destructive ? "destructive" : "default",
|
|
98
103
|
onClick: onApprove,
|
|
99
104
|
children: actionLabel ?? `Run ${name}`
|
|
105
|
+
}), onAllowForRun && !destructive && /*#__PURE__*/_jsx(Button, {
|
|
106
|
+
type: "button",
|
|
107
|
+
size: "sm",
|
|
108
|
+
variant: "outline",
|
|
109
|
+
onClick: onAllowForRun,
|
|
110
|
+
children: "Allow for this run"
|
|
100
111
|
}), /*#__PURE__*/_jsx(Button, {
|
|
101
112
|
type: "button",
|
|
102
113
|
size: "sm",
|
|
@@ -109,20 +120,22 @@ export function Approval(t0) {
|
|
|
109
120
|
$[6] = actionLabel;
|
|
110
121
|
$[7] = approveRef;
|
|
111
122
|
$[8] = awaiting;
|
|
112
|
-
$[9] =
|
|
113
|
-
$[10] =
|
|
114
|
-
$[11] =
|
|
115
|
-
$[12] =
|
|
116
|
-
$[13] =
|
|
117
|
-
$[14] =
|
|
118
|
-
$[15] =
|
|
119
|
-
$[16] =
|
|
120
|
-
$[17] =
|
|
123
|
+
$[9] = changes;
|
|
124
|
+
$[10] = denying;
|
|
125
|
+
$[11] = description;
|
|
126
|
+
$[12] = destructive;
|
|
127
|
+
$[13] = name;
|
|
128
|
+
$[14] = onAllowForRun;
|
|
129
|
+
$[15] = onApprove;
|
|
130
|
+
$[16] = onDeny;
|
|
131
|
+
$[17] = part;
|
|
132
|
+
$[18] = risk;
|
|
133
|
+
$[19] = t8;
|
|
121
134
|
} else {
|
|
122
|
-
t8 = $[
|
|
135
|
+
t8 = $[19];
|
|
123
136
|
}
|
|
124
137
|
let t9;
|
|
125
|
-
if ($[
|
|
138
|
+
if ($[20] !== awaiting || $[21] !== decision || $[22] !== name || $[23] !== part) {
|
|
126
139
|
t9 = !awaiting && /*#__PURE__*/_jsx(SettledLine, {
|
|
127
140
|
name: name,
|
|
128
141
|
children: decision ? /*#__PURE__*/_jsx(DecisionSummary, {
|
|
@@ -133,37 +146,37 @@ export function Approval(t0) {
|
|
|
133
146
|
children: settledLabel(part.state)
|
|
134
147
|
})
|
|
135
148
|
});
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
149
|
+
$[20] = awaiting;
|
|
150
|
+
$[21] = decision;
|
|
151
|
+
$[22] = name;
|
|
152
|
+
$[23] = part;
|
|
153
|
+
$[24] = t9;
|
|
141
154
|
} else {
|
|
142
|
-
t9 = $[
|
|
155
|
+
t9 = $[24];
|
|
143
156
|
}
|
|
144
157
|
let t10;
|
|
145
|
-
if ($[
|
|
158
|
+
if ($[25] !== awaiting || $[26] !== decision || $[27] !== name || $[28] !== part) {
|
|
146
159
|
t10 = decision ? `${name} ${decision.approved ? "approved" : "denied"} by ${decision.by}` : awaiting ? `${name} is waiting for your approval` : settledLabel(part.state);
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
160
|
+
$[25] = awaiting;
|
|
161
|
+
$[26] = decision;
|
|
162
|
+
$[27] = name;
|
|
163
|
+
$[28] = part;
|
|
164
|
+
$[29] = t10;
|
|
152
165
|
} else {
|
|
153
|
-
t10 = $[
|
|
166
|
+
t10 = $[29];
|
|
154
167
|
}
|
|
155
168
|
let t11;
|
|
156
|
-
if ($[
|
|
169
|
+
if ($[30] !== t10) {
|
|
157
170
|
t11 = /*#__PURE__*/_jsx(LiveStatus, {
|
|
158
171
|
message: t10
|
|
159
172
|
});
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
173
|
+
$[30] = t10;
|
|
174
|
+
$[31] = t11;
|
|
162
175
|
} else {
|
|
163
|
-
t11 = $[
|
|
176
|
+
t11 = $[31];
|
|
164
177
|
}
|
|
165
178
|
let t12;
|
|
166
|
-
if ($[
|
|
179
|
+
if ($[32] !== risk || $[33] !== sectionRef || $[34] !== t11 || $[35] !== t4 || $[36] !== t5 || $[37] !== t7 || $[38] !== t8 || $[39] !== t9 || $[40] !== toolName) {
|
|
167
180
|
t12 = /*#__PURE__*/_jsxs("section", {
|
|
168
181
|
ref: sectionRef,
|
|
169
182
|
tabIndex: -1,
|
|
@@ -175,18 +188,18 @@ export function Approval(t0) {
|
|
|
175
188
|
className: t7,
|
|
176
189
|
children: [t8, t9, t11]
|
|
177
190
|
});
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
185
|
-
$[
|
|
186
|
-
$[
|
|
187
|
-
$[
|
|
191
|
+
$[32] = risk;
|
|
192
|
+
$[33] = sectionRef;
|
|
193
|
+
$[34] = t11;
|
|
194
|
+
$[35] = t4;
|
|
195
|
+
$[36] = t5;
|
|
196
|
+
$[37] = t7;
|
|
197
|
+
$[38] = t8;
|
|
198
|
+
$[39] = t9;
|
|
199
|
+
$[40] = toolName;
|
|
200
|
+
$[41] = t12;
|
|
188
201
|
} else {
|
|
189
|
-
t12 = $[
|
|
202
|
+
t12 = $[41];
|
|
190
203
|
}
|
|
191
204
|
return t12;
|
|
192
205
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readableValue } from "./tool-inputs.js";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
function ChangeValue({
|
|
4
|
+
change
|
|
5
|
+
}) {
|
|
6
|
+
const after = /*#__PURE__*/_jsx("ins", {
|
|
7
|
+
className: "font-medium no-underline",
|
|
8
|
+
children: readableValue(change.after)
|
|
9
|
+
});
|
|
10
|
+
if (change.before === undefined) return after;
|
|
11
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
12
|
+
children: [/*#__PURE__*/_jsx("del", {
|
|
13
|
+
className: "text-faint",
|
|
14
|
+
children: readableValue(change.before)
|
|
15
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
16
|
+
"aria-hidden": true,
|
|
17
|
+
className: "px-1.5 text-faint",
|
|
18
|
+
children: "\u2192"
|
|
19
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
20
|
+
className: "sr-only",
|
|
21
|
+
children: " becomes "
|
|
22
|
+
}), after]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function ChangePreview({
|
|
26
|
+
changes
|
|
27
|
+
}) {
|
|
28
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
29
|
+
"data-slot": "change-preview",
|
|
30
|
+
className: "@container flex flex-col gap-2",
|
|
31
|
+
children: [/*#__PURE__*/_jsx("p", {
|
|
32
|
+
className: "text-xs font-medium text-muted-foreground",
|
|
33
|
+
children: "What changes"
|
|
34
|
+
}), /*#__PURE__*/_jsx("dl", {
|
|
35
|
+
className: "flex flex-col gap-3 text-sm @sm:grid @sm:grid-cols-[8rem_minmax(0,1fr)] @sm:gap-x-4 @sm:gap-y-2",
|
|
36
|
+
children: changes.map(change => /*#__PURE__*/_jsxs("div", {
|
|
37
|
+
className: "flex flex-col gap-0.5 @sm:contents",
|
|
38
|
+
children: [/*#__PURE__*/_jsx("dt", {
|
|
39
|
+
className: "truncate text-muted-foreground",
|
|
40
|
+
children: change.label
|
|
41
|
+
}), /*#__PURE__*/_jsx("dd", {
|
|
42
|
+
className: "min-w-0 break-words",
|
|
43
|
+
children: /*#__PURE__*/_jsx(ChangeValue, {
|
|
44
|
+
change: change
|
|
45
|
+
})
|
|
46
|
+
})]
|
|
47
|
+
}, change.label))
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -54,13 +54,13 @@ export function ToolInputs(t0) {
|
|
|
54
54
|
if ($[0] !== input || $[1] !== muted || $[2] !== showRaw) {
|
|
55
55
|
entries = isPlainRecord(input) ? Object.entries(input) : null;
|
|
56
56
|
t2 = "tool-inputs";
|
|
57
|
-
t3 = "flex flex-col gap-2";
|
|
57
|
+
t3 = "@container flex flex-col gap-2";
|
|
58
58
|
t4 = entries && !showRaw && /*#__PURE__*/_jsxs("dl", {
|
|
59
|
-
className: cn("
|
|
59
|
+
className: cn("flex flex-col gap-3 text-sm @sm:grid @sm:grid-cols-[8rem_minmax(0,1fr)] @sm:gap-x-4 @sm:gap-y-2", muted ? "text-faint" : "text-foreground"),
|
|
60
60
|
children: [entries.map(t5 => {
|
|
61
61
|
const [key, value] = t5;
|
|
62
62
|
return /*#__PURE__*/_jsxs("div", {
|
|
63
|
-
className: "contents",
|
|
63
|
+
className: "flex flex-col gap-0.5 @sm:contents",
|
|
64
64
|
children: [/*#__PURE__*/_jsx("dt", {
|
|
65
65
|
className: "truncate text-muted-foreground",
|
|
66
66
|
children: humanizeKey(key)
|
|
@@ -104,7 +104,7 @@ export function ToolInputs(t0) {
|
|
|
104
104
|
if ($[11] !== entries || $[12] !== showRaw) {
|
|
105
105
|
t6 = entries && /*#__PURE__*/_jsx("button", {
|
|
106
106
|
type: "button",
|
|
107
|
-
className: "
|
|
107
|
+
className: "self-start text-xs @sm:ml-36 text-faint locus-focus-ring hover:text-interactive motion-safe:transition-colors",
|
|
108
108
|
onClick: () => setShowRaw(_temp),
|
|
109
109
|
children: showRaw ? "Show fields" : "Show raw"
|
|
110
110
|
});
|
package/dist/approval/types.d.ts
CHANGED
|
@@ -57,3 +57,16 @@ export type PendingApproval = {
|
|
|
57
57
|
requestedAt: DecidedAt;
|
|
58
58
|
summary?: string;
|
|
59
59
|
};
|
|
60
|
+
export type ApprovalChange = {
|
|
61
|
+
label: string;
|
|
62
|
+
before?: ArgValue | null;
|
|
63
|
+
after: ArgValue | null;
|
|
64
|
+
};
|
|
65
|
+
export type DecisionLogKind = "approval" | "spend" | "stop" | "rule";
|
|
66
|
+
export type DecisionLogEntry = {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
kind?: DecisionLogKind;
|
|
70
|
+
decision: ApprovalDecision;
|
|
71
|
+
detail?: string;
|
|
72
|
+
};
|
package/dist/chat/chat/chat.js
CHANGED
|
@@ -129,7 +129,7 @@ export function Chat(t0) {
|
|
|
129
129
|
"aria-busy": t8,
|
|
130
130
|
tabIndex: 0,
|
|
131
131
|
onScroll: handleScroll,
|
|
132
|
-
className: "min-h-0 flex-1 overflow-y-auto overscroll-contain locus-focus-ring-inset",
|
|
132
|
+
className: "min-h-0 flex-1 [mask-image:linear-gradient(to_bottom,transparent,black_1rem,black_calc(100%-1.5rem),transparent)] overflow-y-auto overscroll-contain locus-focus-ring-inset",
|
|
133
133
|
children: t10
|
|
134
134
|
});
|
|
135
135
|
$[25] = handleScroll;
|
|
@@ -223,7 +223,7 @@ export function Composer(t0) {
|
|
|
223
223
|
rows: 1,
|
|
224
224
|
onChange: t18,
|
|
225
225
|
onKeyDown: t19,
|
|
226
|
-
className: "max-h-48 min-h-
|
|
226
|
+
className: "max-h-48 min-h-12 resize-none border-0 bg-transparent px-4 pt-3.5 pb-0 text-sm leading-relaxed shadow-none placeholder:text-faint focus-visible:ring-0 dark:bg-transparent"
|
|
227
227
|
});
|
|
228
228
|
$[44] = disabled;
|
|
229
229
|
$[45] = label;
|
|
@@ -302,7 +302,7 @@ export function Composer(t0) {
|
|
|
302
302
|
if ($[69] !== t22 || $[70] !== t23 || $[71] !== t24) {
|
|
303
303
|
t25 = /*#__PURE__*/_jsxs("div", {
|
|
304
304
|
"data-slot": "composer-toolbar",
|
|
305
|
-
className: "flex items-center gap-1 px-2
|
|
305
|
+
className: "flex items-center gap-1 px-2 pt-1 pb-2",
|
|
306
306
|
children: [t22, t23, t24]
|
|
307
307
|
});
|
|
308
308
|
$[69] = t22;
|
|
@@ -9,7 +9,7 @@ const ringStroke = {
|
|
|
9
9
|
};
|
|
10
10
|
const barFill = {
|
|
11
11
|
ok: "bg-primary",
|
|
12
|
-
near: "bg-warn",
|
|
12
|
+
near: "bg-warn-fill",
|
|
13
13
|
full: "bg-destructive"
|
|
14
14
|
};
|
|
15
15
|
export function MeterRing({
|
|
@@ -45,7 +45,7 @@ export function MeterBar({
|
|
|
45
45
|
}) {
|
|
46
46
|
return /*#__PURE__*/_jsx("span", {
|
|
47
47
|
"aria-hidden": true,
|
|
48
|
-
className: "relative block h-1 w-full overflow-hidden bg-
|
|
48
|
+
className: "relative block h-1 w-full overflow-hidden bg-foreground/10",
|
|
49
49
|
children: /*#__PURE__*/_jsx("span", {
|
|
50
50
|
className: cn("absolute inset-y-0 left-0 transition-[width] duration-300 motion-reduce:transition-none", barFill[status]),
|
|
51
51
|
style: {
|
|
@@ -7,7 +7,7 @@ export function isWastedStep(step) {
|
|
|
7
7
|
}
|
|
8
8
|
function barTone(step) {
|
|
9
9
|
if (isWastedStep(step)) return "bg-destructive";
|
|
10
|
-
if (step.status === "running") return "bg-warn/60 motion-safe:animate-pulse";
|
|
10
|
+
if (step.status === "running") return "bg-warn-fill/60 motion-safe:animate-pulse";
|
|
11
11
|
return "bg-muted-foreground/50";
|
|
12
12
|
}
|
|
13
13
|
const statusMark = {
|
|
@@ -2,6 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { DecidedAt } from "../approval/types.js";
|
|
3
3
|
export declare function toDate(value: DecidedAt): Date;
|
|
4
4
|
export declare function isoOf(value: DecidedAt): string | undefined;
|
|
5
|
+
export type DecisionTimeStyle = "full" | "time";
|
|
6
|
+
export declare function formatDecidedTime(value: DecidedAt): string;
|
|
5
7
|
export declare function formatDecidedAt(value: DecidedAt): string;
|
|
6
8
|
export type DecisionOutcome = {
|
|
7
9
|
approved: boolean;
|
|
@@ -14,5 +16,6 @@ export type DecisionSummaryProps = {
|
|
|
14
16
|
result: ReactNode;
|
|
15
17
|
approvedVerb?: string;
|
|
16
18
|
deniedVerb?: string;
|
|
19
|
+
timeStyle?: DecisionTimeStyle;
|
|
17
20
|
};
|
|
18
|
-
export declare function DecisionSummary({ decision, result, approvedVerb, deniedVerb, }: DecisionSummaryProps): import("react").JSX.Element;
|
|
21
|
+
export declare function DecisionSummary({ decision, result, approvedVerb, deniedVerb, timeStyle, }: DecisionSummaryProps): import("react").JSX.Element;
|
|
@@ -12,21 +12,31 @@ export function isoOf(value) {
|
|
|
12
12
|
const date = toDate(value);
|
|
13
13
|
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
14
14
|
}
|
|
15
|
+
const decisionClockFormat = new Intl.DateTimeFormat("en-US", {
|
|
16
|
+
timeStyle: "short",
|
|
17
|
+
timeZone: "UTC"
|
|
18
|
+
});
|
|
19
|
+
export function formatDecidedTime(value) {
|
|
20
|
+
const date = toDate(value);
|
|
21
|
+
return Number.isNaN(date.getTime()) ? "" : decisionClockFormat.format(date);
|
|
22
|
+
}
|
|
15
23
|
export function formatDecidedAt(value) {
|
|
16
24
|
const date = toDate(value);
|
|
17
25
|
return Number.isNaN(date.getTime()) ? "" : `${decisionTimeFormat.format(date)} UTC`;
|
|
18
26
|
}
|
|
19
27
|
function DecisionMeta({
|
|
20
28
|
decision,
|
|
21
|
-
verb
|
|
29
|
+
verb,
|
|
30
|
+
timeStyle
|
|
22
31
|
}) {
|
|
23
32
|
return /*#__PURE__*/_jsxs("p", {
|
|
24
33
|
className: "text-xs text-muted-foreground",
|
|
25
34
|
children: [verb, decision.by && ` by ${decision.by}`, decision.at !== undefined && /*#__PURE__*/_jsxs(_Fragment, {
|
|
26
35
|
children: [" · ", /*#__PURE__*/_jsx("time", {
|
|
27
36
|
dateTime: isoOf(decision.at),
|
|
37
|
+
title: formatDecidedAt(decision.at),
|
|
28
38
|
className: "tabular-nums",
|
|
29
|
-
children: formatDecidedAt(decision.at)
|
|
39
|
+
children: timeStyle === "time" ? formatDecidedTime(decision.at) : formatDecidedAt(decision.at)
|
|
30
40
|
})]
|
|
31
41
|
})]
|
|
32
42
|
});
|
|
@@ -35,7 +45,8 @@ export function DecisionSummary({
|
|
|
35
45
|
decision,
|
|
36
46
|
result,
|
|
37
47
|
approvedVerb = "Approved",
|
|
38
|
-
deniedVerb = "Denied"
|
|
48
|
+
deniedVerb = "Denied",
|
|
49
|
+
timeStyle = "full"
|
|
39
50
|
}) {
|
|
40
51
|
const Icon = decision.approved ? CheckIcon : XIcon;
|
|
41
52
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -53,7 +64,8 @@ export function DecisionSummary({
|
|
|
53
64
|
children: result
|
|
54
65
|
}), /*#__PURE__*/_jsx(DecisionMeta, {
|
|
55
66
|
decision: decision,
|
|
56
|
-
verb: decision.approved ? approvedVerb : deniedVerb
|
|
67
|
+
verb: decision.approved ? approvedVerb : deniedVerb,
|
|
68
|
+
timeStyle: timeStyle
|
|
57
69
|
}), decision.reason && /*#__PURE__*/_jsxs("p", {
|
|
58
70
|
className: "text-xs text-muted-foreground",
|
|
59
71
|
children: ["Reason: ", decision.reason]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locusgraph/loop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Agent components for LocusGraph apps: chat, agent steps, human-in-the-loop approvals, memory and cost. Takes Vercel AI SDK UIMessage parts; never calls a model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,22 +29,22 @@
|
|
|
29
29
|
"provenance": true
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@locusgraph/components": "^0.
|
|
32
|
+
"@locusgraph/components": "^0.6.1",
|
|
33
33
|
"react": "^19.2.0",
|
|
34
34
|
"react-dom": "^19.2.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@phosphor-icons/react": "2.1.10",
|
|
38
|
-
"@locusgraph/brand": "0.
|
|
39
|
-
"@locusgraph/utils": "0.1.
|
|
38
|
+
"@locusgraph/brand": "0.3.1",
|
|
39
|
+
"@locusgraph/utils": "0.1.3",
|
|
40
40
|
"@tanstack/react-virtual": "3.14.13",
|
|
41
41
|
"react-markdown": "^10.1.0",
|
|
42
42
|
"remark-gfm": "^4.0.1",
|
|
43
43
|
"shiki": "^4.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@locusgraph/components": "0.
|
|
47
|
-
"@locusgraph/config": "0.1.
|
|
46
|
+
"@locusgraph/components": "0.6.1",
|
|
47
|
+
"@locusgraph/config": "0.1.2",
|
|
48
48
|
"@types/node": "^22.0.0",
|
|
49
49
|
"@types/react": "^19.2.0",
|
|
50
50
|
"@types/react-dom": "^19.2.0",
|