@ai-matrx/agents 0.59.176 → 0.59.177
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/CHANGELOG.md +8 -1
- package/dist/content-transfer/index.cjs +1 -1
- package/dist/content-transfer/index.js +1 -1
- package/dist/content-transfer/react/index.cjs +1 -1
- package/dist/content-transfer/react/index.js +1 -1
- package/dist/mandates/index.cjs +4 -4
- package/dist/mandates/index.d.cts +6 -6
- package/dist/mandates/index.d.ts +6 -6
- package/dist/mandates/index.js +4 -4
- package/dist/versions/index.cjs +231 -0
- package/dist/versions/index.d.cts +158 -0
- package/dist/versions/index.d.ts +158 -0
- package/dist/versions/index.js +208 -0
- package/dist/versions/react/index.cjs +1305 -0
- package/dist/versions/react/index.d.cts +137 -0
- package/dist/versions/react/index.d.ts +137 -0
- package/dist/versions/react/index.js +1302 -0
- package/package.json +23 -2
|
@@ -0,0 +1,1305 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// versions/react/index.ts
|
|
22
|
+
var react_exports = {};
|
|
23
|
+
__export(react_exports, {
|
|
24
|
+
AgentDiffRefsProvider: () => AgentDiffRefsProvider,
|
|
25
|
+
AgentDiffViewer: () => AgentDiffViewer,
|
|
26
|
+
VersionHistoryTimeline: () => VersionHistoryTimeline,
|
|
27
|
+
buildAgentAdapterRegistry: () => buildAgentAdapterRegistry,
|
|
28
|
+
readModelTierIdentities: () => readModelTierIdentities,
|
|
29
|
+
useAgentDiffRefs: () => useAgentDiffRefs
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(react_exports);
|
|
32
|
+
|
|
33
|
+
// versions/react/AgentDiffViewer.tsx
|
|
34
|
+
var import_react6 = require("react");
|
|
35
|
+
var import_react7 = require("@ai-matrx/diff/react");
|
|
36
|
+
|
|
37
|
+
// versions/compare.ts
|
|
38
|
+
var import_structural = require("@ai-matrx/diff/structural");
|
|
39
|
+
|
|
40
|
+
// versions/constants.ts
|
|
41
|
+
var AGENT_EXCLUDE_PATHS = /* @__PURE__ */ new Set([
|
|
42
|
+
"id",
|
|
43
|
+
"userId",
|
|
44
|
+
"organizationId",
|
|
45
|
+
"taskId",
|
|
46
|
+
"createdAt",
|
|
47
|
+
"updatedAt",
|
|
48
|
+
"isVersion",
|
|
49
|
+
"parentAgentId",
|
|
50
|
+
"sourceAgentId",
|
|
51
|
+
"sourceSnapshotAt",
|
|
52
|
+
// Lineage and record bookkeeping: who made the row and which version it was
|
|
53
|
+
// copied from never change what the agent does, so a copy never "differs" here.
|
|
54
|
+
"sourceVersion",
|
|
55
|
+
"followsSource",
|
|
56
|
+
"createdBy",
|
|
57
|
+
"runCounts",
|
|
58
|
+
"isOwner",
|
|
59
|
+
"accessLevel",
|
|
60
|
+
"sharedByEmail",
|
|
61
|
+
"agentType",
|
|
62
|
+
"version",
|
|
63
|
+
"changeNote",
|
|
64
|
+
"changedAt"
|
|
65
|
+
]);
|
|
66
|
+
var AGENT_IDENTITY_KEYS = {
|
|
67
|
+
variableDefinitions: "name",
|
|
68
|
+
contextPolicies: "key",
|
|
69
|
+
customTools: "name"
|
|
70
|
+
};
|
|
71
|
+
var AGENT_DIFF_OPTIONS = {
|
|
72
|
+
excludePaths: AGENT_EXCLUDE_PATHS,
|
|
73
|
+
identityKeys: AGENT_IDENTITY_KEYS,
|
|
74
|
+
// Output-schema property order is authored behavior: model providers often
|
|
75
|
+
// emit fields in schema order, so a reorder must be visible in version diffs.
|
|
76
|
+
orderSensitiveObjectPaths: /* @__PURE__ */ new Set(["outputSchema"]),
|
|
77
|
+
// Agent configuration is executable data. `_`/`__` keys (especially
|
|
78
|
+
// output-schema `__kind`) are contract fields, never hidden metadata.
|
|
79
|
+
skipUnderscorePrefix: false
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// versions/compare.ts
|
|
83
|
+
var AGENT_PROFILE_FIELDS = /* @__PURE__ */ new Set(["name", "description", "category", "tags"]);
|
|
84
|
+
var AGENT_LOCAL_STATE_FIELDS = /* @__PURE__ */ new Set([
|
|
85
|
+
"isActive",
|
|
86
|
+
"isArchived",
|
|
87
|
+
"isFavorite"
|
|
88
|
+
]);
|
|
89
|
+
function toComparableAgentRecord(agent) {
|
|
90
|
+
return Object.fromEntries(
|
|
91
|
+
Object.entries(agent).filter(([key]) => !key.startsWith("_"))
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function compareAgentDefinitions(systemAgent, personalAgent) {
|
|
95
|
+
const systemRecord = toComparableAgentRecord(systemAgent);
|
|
96
|
+
const personalRecord = toComparableAgentRecord(personalAgent);
|
|
97
|
+
const diffResult = (0, import_structural.computeDiff)(
|
|
98
|
+
systemRecord,
|
|
99
|
+
personalRecord,
|
|
100
|
+
AGENT_DIFF_OPTIONS
|
|
101
|
+
);
|
|
102
|
+
const changedFields = diffResult.root.filter(
|
|
103
|
+
(node) => node.changeType !== "unchanged"
|
|
104
|
+
);
|
|
105
|
+
const profileFields = changedFields.filter(
|
|
106
|
+
(node) => AGENT_PROFILE_FIELDS.has(node.key)
|
|
107
|
+
);
|
|
108
|
+
const localStateFields = changedFields.filter(
|
|
109
|
+
(node) => AGENT_LOCAL_STATE_FIELDS.has(node.key)
|
|
110
|
+
);
|
|
111
|
+
const behaviorFields = changedFields.filter(
|
|
112
|
+
(node) => !AGENT_PROFILE_FIELDS.has(node.key) && !AGENT_LOCAL_STATE_FIELDS.has(node.key)
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
diffResult,
|
|
116
|
+
changedFields,
|
|
117
|
+
behaviorFields,
|
|
118
|
+
profileFields,
|
|
119
|
+
localStateFields,
|
|
120
|
+
behaviorMatches: behaviorFields.length === 0,
|
|
121
|
+
comparedConfigurationMatches: !diffResult.hasChanges
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// versions/react/adapters/ContextPoliciesAdapter.tsx
|
|
126
|
+
var import_design_system = require("@ai-matrx/design-system");
|
|
127
|
+
|
|
128
|
+
// versions/react/icons.tsx
|
|
129
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
130
|
+
function Glyph({ children, className, ...rest }) {
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
132
|
+
"svg",
|
|
133
|
+
{
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
viewBox: "0 0 24 24",
|
|
136
|
+
fill: "none",
|
|
137
|
+
stroke: "currentColor",
|
|
138
|
+
strokeWidth: 2,
|
|
139
|
+
strokeLinecap: "round",
|
|
140
|
+
strokeLinejoin: "round",
|
|
141
|
+
"aria-hidden": "true",
|
|
142
|
+
focusable: "false",
|
|
143
|
+
className: className ?? "h-4 w-4",
|
|
144
|
+
...rest,
|
|
145
|
+
children
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
var MessageSquare = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Glyph, { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
150
|
+
var Webhook = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2" }),
|
|
152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06" }),
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8" })
|
|
154
|
+
] });
|
|
155
|
+
var Layers = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z" }),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65" }),
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65" })
|
|
159
|
+
] });
|
|
160
|
+
var Layers3 = Layers;
|
|
161
|
+
var Hammer = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m15 12-8.5 8.5c-.83.83-2.17.83-3 0 0 0 0 0 0 0a2.12 2.12 0 0 1 0-3L12 9" }),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M17.64 15 22 10.64" }),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m20.91 11.7-1.25-1.25c-.6-.6-.93-1.4-.93-2.25v-.86L16.01 4.6a5.56 5.56 0 0 0-3.94-1.64H9l.92.82A6.18 6.18 0 0 1 12 8.4v1.56l2 2h2.47l2.26 1.91" })
|
|
165
|
+
] });
|
|
166
|
+
var Server = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: "20", height: "8", x: "2", y: "2", rx: "2", ry: "2" }),
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: "20", height: "8", x: "2", y: "14", rx: "2", ry: "2" }),
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "6", x2: "6.01", y1: "6", y2: "6" }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "6", x2: "6.01", y1: "18", y2: "18" })
|
|
171
|
+
] });
|
|
172
|
+
var Variable = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 21s-4-3-4-9 4-9 4-9" }),
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 3s4 3 4 9-4 9-4 9" }),
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "15", x2: "9", y1: "9", y2: "15" }),
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "9", x2: "15", y1: "9", y2: "15" })
|
|
177
|
+
] });
|
|
178
|
+
var Wrench = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Glyph, { className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" }) });
|
|
179
|
+
var Settings = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
180
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }),
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "3" })
|
|
182
|
+
] });
|
|
183
|
+
var Atom = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "1" }),
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z" }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z" })
|
|
187
|
+
] });
|
|
188
|
+
var ShieldAlert = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" }),
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 8v4" }),
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 16h.01" })
|
|
192
|
+
] });
|
|
193
|
+
var AlertTriangle = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Glyph, { className, children: [
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 9v4" }),
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 17h.01" })
|
|
197
|
+
] });
|
|
198
|
+
var LoaderSpin = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Glyph, { className: `animate-spin ${className ?? "h-8 w-8"}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
199
|
+
|
|
200
|
+
// versions/react/adapters/ContextPoliciesAdapter.tsx
|
|
201
|
+
var import_react = require("@ai-matrx/diff/react");
|
|
202
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
203
|
+
function formatPolicy(policy) {
|
|
204
|
+
if (!policy) return "\u2014";
|
|
205
|
+
const parts = [policy.key];
|
|
206
|
+
if (policy.type) parts.push(`[${policy.type}]`);
|
|
207
|
+
if (policy.label) parts.push(`"${policy.label}"`);
|
|
208
|
+
if (policy.description) parts.push(`
|
|
209
|
+
${policy.description}`);
|
|
210
|
+
return parts.join(" ");
|
|
211
|
+
}
|
|
212
|
+
function ContextPoliciesDiffRenderer({ node }) {
|
|
213
|
+
if (!node.children || node.children.length === 0) {
|
|
214
|
+
const oldJson = node.oldValue != null ? JSON.stringify(node.oldValue, null, 2) : "\u2014";
|
|
215
|
+
const newJson = node.newValue != null ? JSON.stringify(node.newValue, null, 2) : "\u2014";
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary", children: [
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "border-r border-border" }),
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 py-2 border-r border-border", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: "font-mono type-meta text-foreground/70", children: oldJson }) }),
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { className: "font-mono type-meta text-foreground/70", children: newJson }) })
|
|
220
|
+
] });
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: node.children.map((child, i) => {
|
|
223
|
+
const oldPolicy = child.oldValue;
|
|
224
|
+
const newPolicy = child.newValue;
|
|
225
|
+
const policyKey = newPolicy?.key ?? oldPolicy?.key ?? child.key;
|
|
226
|
+
if (child.changeType === "modified" && oldPolicy && newPolicy) {
|
|
227
|
+
const oldText = formatPolicy(oldPolicy);
|
|
228
|
+
const newText = formatPolicy(newPolicy);
|
|
229
|
+
if (oldText !== "" && newText !== "") {
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
className: "grid grid-cols-[200px_1fr] type-secondary border-t border-border/30",
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono", children: policyKey }),
|
|
236
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "min-w-0 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.InlineTextDiff, { original: oldText, modified: newText }) })
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
child.key ?? i
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono", children: policyKey }),
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
className: (0, import_design_system.cn)(
|
|
253
|
+
"px-3 py-1.5 border-r border-border whitespace-pre-wrap",
|
|
254
|
+
child.changeType === "removed" || child.changeType === "modified" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "text-foreground/80",
|
|
255
|
+
child.changeType === "added" ? "text-muted-foreground/50" : ""
|
|
256
|
+
),
|
|
257
|
+
children: formatPolicy(oldPolicy)
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
className: (0, import_design_system.cn)(
|
|
264
|
+
"px-3 py-1.5 whitespace-pre-wrap",
|
|
265
|
+
child.changeType === "added" || child.changeType === "modified" ? "bg-success/10 text-success-ink bg-success/15" : "text-foreground/80",
|
|
266
|
+
child.changeType === "removed" ? "text-muted-foreground/50" : ""
|
|
267
|
+
),
|
|
268
|
+
children: formatPolicy(newPolicy)
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
child.key ?? i
|
|
274
|
+
);
|
|
275
|
+
}) });
|
|
276
|
+
}
|
|
277
|
+
var ContextPoliciesAdapter = {
|
|
278
|
+
label: "Context Policies",
|
|
279
|
+
icon: Layers,
|
|
280
|
+
renderDiff: ContextPoliciesDiffRenderer,
|
|
281
|
+
toSummaryText: (node) => {
|
|
282
|
+
if (!node.children) return "Context policies changed";
|
|
283
|
+
const changed = node.children.filter(
|
|
284
|
+
(c) => c.changeType !== "unchanged"
|
|
285
|
+
).length;
|
|
286
|
+
return `${changed} policy${changed !== 1 ? "s" : ""} changed`;
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// versions/react/adapters/CustomToolsAdapter.tsx
|
|
291
|
+
var import_design_system2 = require("@ai-matrx/design-system");
|
|
292
|
+
var import_react2 = require("@ai-matrx/diff/react");
|
|
293
|
+
var import_text_case = require("@ai-matrx/kit/text-case");
|
|
294
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
295
|
+
function formatCustomTool(tool) {
|
|
296
|
+
if (!tool) return "\u2014";
|
|
297
|
+
const parts = [tool.name];
|
|
298
|
+
if (tool.description) parts.push(`
|
|
299
|
+
${tool.description}`);
|
|
300
|
+
if (tool.input_schema)
|
|
301
|
+
parts.push(`
|
|
302
|
+
Schema: ${JSON.stringify(tool.input_schema, null, 2)}`);
|
|
303
|
+
return parts.join("");
|
|
304
|
+
}
|
|
305
|
+
function CustomToolsDiffRenderer({ node }) {
|
|
306
|
+
if (!node.children || node.children.length === 0) {
|
|
307
|
+
const oldJson = JSON.stringify(node.oldValue, null, 2) ?? "\u2014";
|
|
308
|
+
const newJson = JSON.stringify(node.newValue, null, 2) ?? "\u2014";
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary", children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "border-r border-border" }),
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-2 border-r border-border", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "font-mono type-meta text-foreground/70", children: oldJson }) }),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "font-mono type-meta text-foreground/70", children: newJson }) })
|
|
313
|
+
] });
|
|
314
|
+
}
|
|
315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: node.children.map((child, i) => {
|
|
316
|
+
const oldTool = child.oldValue;
|
|
317
|
+
const newTool = child.newValue;
|
|
318
|
+
const toolName = newTool?.name ?? oldTool?.name ?? `Unknown custom tool (${child.key ?? "missing id"})`;
|
|
319
|
+
if (child.changeType === "modified" && oldTool && newTool) {
|
|
320
|
+
const oldText = formatCustomTool(oldTool);
|
|
321
|
+
const newText = formatCustomTool(newTool);
|
|
322
|
+
if (oldText !== "" && newText !== "") {
|
|
323
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
324
|
+
"div",
|
|
325
|
+
{
|
|
326
|
+
className: "grid grid-cols-[200px_1fr] type-secondary border-t border-border/30",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8", children: (0, import_text_case.humanizeIdentifier)(toolName) }),
|
|
329
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "min-w-0 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.InlineTextDiff, { original: oldText, modified: newText }) })
|
|
330
|
+
]
|
|
331
|
+
},
|
|
332
|
+
child.key ?? i
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
340
|
+
children: [
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8", children: (0, import_text_case.humanizeIdentifier)(toolName) }),
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
className: (0, import_design_system2.cn)(
|
|
346
|
+
"px-3 py-1.5 border-r border-border whitespace-pre-wrap font-mono type-meta",
|
|
347
|
+
child.changeType === "removed" || child.changeType === "modified" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "text-foreground/70",
|
|
348
|
+
child.changeType === "added" ? "text-muted-foreground/50" : ""
|
|
349
|
+
),
|
|
350
|
+
children: formatCustomTool(oldTool)
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
354
|
+
"div",
|
|
355
|
+
{
|
|
356
|
+
className: (0, import_design_system2.cn)(
|
|
357
|
+
"px-3 py-1.5 whitespace-pre-wrap font-mono type-meta",
|
|
358
|
+
child.changeType === "added" || child.changeType === "modified" ? "bg-success/10 text-success-ink bg-success/15" : "text-foreground/70",
|
|
359
|
+
child.changeType === "removed" ? "text-muted-foreground/50" : ""
|
|
360
|
+
),
|
|
361
|
+
children: formatCustomTool(newTool)
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
]
|
|
365
|
+
},
|
|
366
|
+
child.key ?? i
|
|
367
|
+
);
|
|
368
|
+
}) });
|
|
369
|
+
}
|
|
370
|
+
var CustomToolsAdapter = {
|
|
371
|
+
label: "Custom Tools",
|
|
372
|
+
icon: Hammer,
|
|
373
|
+
renderDiff: CustomToolsDiffRenderer,
|
|
374
|
+
toSummaryText: (node) => {
|
|
375
|
+
if (!node.children) return "Custom tools changed";
|
|
376
|
+
const changed = node.children.filter((c) => c.changeType !== "unchanged");
|
|
377
|
+
const added = changed.filter((c) => c.changeType === "added").length;
|
|
378
|
+
const removed = changed.filter((c) => c.changeType === "removed").length;
|
|
379
|
+
const modified = changed.filter((c) => c.changeType === "modified").length;
|
|
380
|
+
const parts = [];
|
|
381
|
+
if (added > 0) parts.push(`${added} added`);
|
|
382
|
+
if (removed > 0) parts.push(`${removed} removed`);
|
|
383
|
+
if (modified > 0) parts.push(`${modified} modified`);
|
|
384
|
+
return parts.join(", ") || "Custom tools changed";
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// versions/react/adapters/McpServersAdapter.tsx
|
|
389
|
+
var import_design_system3 = require("@ai-matrx/design-system");
|
|
390
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
391
|
+
function resolveMcp(id, enrichment) {
|
|
392
|
+
return enrichment?.resolveMcpServerId(id) ?? id;
|
|
393
|
+
}
|
|
394
|
+
function McpServersDiffRenderer({ node, enrichment }) {
|
|
395
|
+
const oldServers = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
396
|
+
const newServers = Array.isArray(node.newValue) ? node.newValue : [];
|
|
397
|
+
const allIds = [.../* @__PURE__ */ new Set([...oldServers, ...newServers])];
|
|
398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: allIds.map((id) => {
|
|
399
|
+
const inOld = oldServers.includes(id);
|
|
400
|
+
const inNew = newServers.includes(id);
|
|
401
|
+
const name = resolveMcp(id, enrichment);
|
|
402
|
+
const status = inOld && inNew ? "unchanged" : inOld ? "removed" : "added";
|
|
403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
404
|
+
"div",
|
|
405
|
+
{
|
|
406
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono truncate", children: name }),
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
410
|
+
"div",
|
|
411
|
+
{
|
|
412
|
+
className: (0, import_design_system3.cn)(
|
|
413
|
+
"px-3 py-1.5 border-r border-border",
|
|
414
|
+
status === "removed" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "",
|
|
415
|
+
status === "added" ? "text-muted-foreground/50" : "",
|
|
416
|
+
status === "unchanged" ? "text-foreground/80" : ""
|
|
417
|
+
),
|
|
418
|
+
children: inOld ? name : "\u2014"
|
|
419
|
+
}
|
|
420
|
+
),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
className: (0, import_design_system3.cn)(
|
|
425
|
+
"px-3 py-1.5",
|
|
426
|
+
status === "added" ? "bg-success/10 text-success-ink bg-success/15" : "",
|
|
427
|
+
status === "removed" ? "text-muted-foreground/50" : "",
|
|
428
|
+
status === "unchanged" ? "text-foreground/80" : ""
|
|
429
|
+
),
|
|
430
|
+
children: inNew ? name : "\u2014"
|
|
431
|
+
}
|
|
432
|
+
)
|
|
433
|
+
]
|
|
434
|
+
},
|
|
435
|
+
id
|
|
436
|
+
);
|
|
437
|
+
}) });
|
|
438
|
+
}
|
|
439
|
+
var McpServersAdapter = {
|
|
440
|
+
label: "MCP Servers",
|
|
441
|
+
icon: Server,
|
|
442
|
+
renderDiff: McpServersDiffRenderer,
|
|
443
|
+
toSummaryText: (node, ctx) => {
|
|
444
|
+
const oldArr = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
445
|
+
const newArr = Array.isArray(node.newValue) ? node.newValue : [];
|
|
446
|
+
const added = newArr.filter((s) => !oldArr.includes(s));
|
|
447
|
+
const removed = oldArr.filter((s) => !newArr.includes(s));
|
|
448
|
+
const parts = [];
|
|
449
|
+
if (added.length > 0)
|
|
450
|
+
parts.push(
|
|
451
|
+
`Added: ${added.map((id) => ctx?.resolveMcpServerId(id) ?? id).join(", ")}`
|
|
452
|
+
);
|
|
453
|
+
if (removed.length > 0)
|
|
454
|
+
parts.push(
|
|
455
|
+
`Removed: ${removed.map((id) => ctx?.resolveMcpServerId(id) ?? id).join(", ")}`
|
|
456
|
+
);
|
|
457
|
+
return parts.join("; ") || "MCP servers changed";
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
// versions/react/adapters/MessagesAdapter.tsx
|
|
462
|
+
var import_controls = require("@ai-matrx/design-system/controls");
|
|
463
|
+
var import_design_system4 = require("@ai-matrx/design-system");
|
|
464
|
+
var import_react3 = require("@ai-matrx/diff/react");
|
|
465
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
466
|
+
function extractText(msg) {
|
|
467
|
+
if (typeof msg.content === "string") return msg.content;
|
|
468
|
+
if (!Array.isArray(msg.content)) return "";
|
|
469
|
+
return msg.content.filter(
|
|
470
|
+
(b) => b.type === "text" && !!b.text
|
|
471
|
+
).map((b) => b.text).join("\n");
|
|
472
|
+
}
|
|
473
|
+
function MessagesDiffRenderer({ node }) {
|
|
474
|
+
const oldMessages = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
475
|
+
const newMessages = Array.isArray(node.newValue) ? node.newValue : [];
|
|
476
|
+
if (node.children && node.children.length > 0) {
|
|
477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: node.children.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(MessageRow, { child, index: i }, child.key ?? i)) });
|
|
478
|
+
}
|
|
479
|
+
const maxLen = Math.max(oldMessages.length, newMessages.length);
|
|
480
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: Array.from({ length: maxLen }, (_, i) => {
|
|
481
|
+
const oldMsg = oldMessages[i];
|
|
482
|
+
const newMsg = newMessages[i];
|
|
483
|
+
const oldT = oldMsg ? extractText(oldMsg) : "";
|
|
484
|
+
const newT = newMsg ? extractText(newMsg) : "";
|
|
485
|
+
const roleLabel = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
486
|
+
"#",
|
|
487
|
+
i + 1,
|
|
488
|
+
" ",
|
|
489
|
+
(newMsg?.role ?? oldMsg?.role ?? "").toUpperCase()
|
|
490
|
+
] });
|
|
491
|
+
if (oldMsg && newMsg && oldT !== "" && newT !== "" && oldT !== newT) {
|
|
492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
493
|
+
"div",
|
|
494
|
+
{
|
|
495
|
+
className: "grid grid-cols-[200px_1fr] type-secondary border-t border-border/30",
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-3 py-2 border-r border-border text-muted-foreground pl-8", children: roleLabel }),
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-0 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react3.InlineTextDiff, { original: oldT, modified: newT }) })
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
i
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
505
|
+
"div",
|
|
506
|
+
{
|
|
507
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
508
|
+
children: [
|
|
509
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-3 py-2 border-r border-border text-muted-foreground pl-8", children: roleLabel }),
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
511
|
+
"div",
|
|
512
|
+
{
|
|
513
|
+
className: (0, import_design_system4.cn)(
|
|
514
|
+
"px-3 py-2 border-r border-border whitespace-pre-wrap",
|
|
515
|
+
!oldMsg ? "text-muted-foreground/50" : oldMsg && newMsg && extractText(oldMsg) !== extractText(newMsg) ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "text-foreground/80"
|
|
516
|
+
),
|
|
517
|
+
children: oldMsg ? extractText(oldMsg) : "\u2014"
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
521
|
+
"div",
|
|
522
|
+
{
|
|
523
|
+
className: (0, import_design_system4.cn)(
|
|
524
|
+
"px-3 py-2 whitespace-pre-wrap",
|
|
525
|
+
!newMsg ? "text-muted-foreground/50" : oldMsg && newMsg && extractText(oldMsg) !== extractText(newMsg) ? "bg-success/10 text-success-ink bg-success/15" : "text-foreground/80"
|
|
526
|
+
),
|
|
527
|
+
children: newMsg ? extractText(newMsg) : "\u2014"
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
i
|
|
533
|
+
);
|
|
534
|
+
}) });
|
|
535
|
+
}
|
|
536
|
+
function MessageRow({ child, index }) {
|
|
537
|
+
const oldMsg = child.oldValue;
|
|
538
|
+
const newMsg = child.newValue;
|
|
539
|
+
const role = (newMsg?.role ?? oldMsg?.role ?? "unknown").toUpperCase();
|
|
540
|
+
const oldText = oldMsg ? extractText(oldMsg) : "";
|
|
541
|
+
const newText = newMsg ? extractText(newMsg) : "";
|
|
542
|
+
const roleBadge = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
544
|
+
"#",
|
|
545
|
+
index + 1
|
|
546
|
+
] }),
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
548
|
+
import_controls.Badge,
|
|
549
|
+
{
|
|
550
|
+
tone: child.changeType === "added" ? "success" : child.changeType === "removed" ? "destructive" : "neutral",
|
|
551
|
+
children: role
|
|
552
|
+
}
|
|
553
|
+
)
|
|
554
|
+
] });
|
|
555
|
+
if (child.changeType === "modified" && oldText !== "" && newText !== "") {
|
|
556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-[200px_1fr] type-secondary border-t border-border/30", children: [
|
|
557
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-3 py-2 border-r border-border text-muted-foreground pl-8", children: roleBadge }),
|
|
558
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-0 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react3.InlineTextDiff, { original: oldText, modified: newText }) })
|
|
559
|
+
] });
|
|
560
|
+
}
|
|
561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30", children: [
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-3 py-2 border-r border-border text-muted-foreground pl-8", children: roleBadge }),
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
564
|
+
"div",
|
|
565
|
+
{
|
|
566
|
+
className: (0, import_design_system4.cn)(
|
|
567
|
+
"px-3 py-2 border-r border-border whitespace-pre-wrap break-words",
|
|
568
|
+
child.changeType === "removed" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "",
|
|
569
|
+
child.changeType === "added" ? "text-muted-foreground/50" : "",
|
|
570
|
+
child.changeType === "unchanged" ? "text-foreground/80" : ""
|
|
571
|
+
),
|
|
572
|
+
children: oldText !== "" ? oldText : "\u2014"
|
|
573
|
+
}
|
|
574
|
+
),
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
576
|
+
"div",
|
|
577
|
+
{
|
|
578
|
+
className: (0, import_design_system4.cn)(
|
|
579
|
+
"px-3 py-2 whitespace-pre-wrap break-words",
|
|
580
|
+
child.changeType === "added" ? "bg-success/10 text-success-ink bg-success/15" : "",
|
|
581
|
+
child.changeType === "removed" ? "text-muted-foreground/50" : "",
|
|
582
|
+
child.changeType === "unchanged" ? "text-foreground/80" : ""
|
|
583
|
+
),
|
|
584
|
+
children: newText !== "" ? newText : "\u2014"
|
|
585
|
+
}
|
|
586
|
+
)
|
|
587
|
+
] });
|
|
588
|
+
}
|
|
589
|
+
var MessagesAdapter = {
|
|
590
|
+
label: "Messages",
|
|
591
|
+
icon: MessageSquare,
|
|
592
|
+
renderDiff: MessagesDiffRenderer,
|
|
593
|
+
toSummaryText: (node) => {
|
|
594
|
+
const oldArr = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
595
|
+
const newArr = Array.isArray(node.newValue) ? node.newValue : [];
|
|
596
|
+
if (oldArr.length !== newArr.length) {
|
|
597
|
+
const diff = newArr.length - oldArr.length;
|
|
598
|
+
return diff > 0 ? `${diff} message${diff !== 1 ? "s" : ""} added` : `${Math.abs(diff)} message${Math.abs(diff) !== 1 ? "s" : ""} removed`;
|
|
599
|
+
}
|
|
600
|
+
if (node.children) {
|
|
601
|
+
const changed = node.children.filter(
|
|
602
|
+
(c) => c.changeType !== "unchanged"
|
|
603
|
+
).length;
|
|
604
|
+
return `${changed} message${changed !== 1 ? "s" : ""} modified`;
|
|
605
|
+
}
|
|
606
|
+
return "Messages changed";
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// versions/react/adapters/ModelAdapter.tsx
|
|
611
|
+
var import_design_system5 = require("@ai-matrx/design-system");
|
|
612
|
+
|
|
613
|
+
// versions/react/refs.tsx
|
|
614
|
+
var import_react4 = require("react");
|
|
615
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
616
|
+
function PlainRef({ id, name, showId, className }) {
|
|
617
|
+
const label = name && name !== id ? name : null;
|
|
618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className, children: [
|
|
619
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "font-medium", children: label }) : null,
|
|
620
|
+
label && showId ? " " : null,
|
|
621
|
+
!label || showId ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "select-all break-all font-mono type-meta text-muted-foreground", children: id }) : null
|
|
622
|
+
] });
|
|
623
|
+
}
|
|
624
|
+
var DefaultModelRef = ({ modelId, name, showId, className }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlainRef, { id: modelId, name, showId, className });
|
|
625
|
+
var DefaultToolRef = ({ toolId, name, showId, className }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PlainRef, { id: toolId, name, showId, className });
|
|
626
|
+
var RefsContext = (0, import_react4.createContext)({ ModelRef: DefaultModelRef, ToolRef: DefaultToolRef });
|
|
627
|
+
function AgentDiffRefsProvider({ refs, children }) {
|
|
628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RefsContext.Provider, { value: { ModelRef: refs?.ModelRef ?? DefaultModelRef, ToolRef: refs?.ToolRef ?? DefaultToolRef }, children });
|
|
629
|
+
}
|
|
630
|
+
function useAgentDiffRefs() {
|
|
631
|
+
return (0, import_react4.useContext)(RefsContext);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// versions/react/adapters/ModelAdapter.tsx
|
|
635
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
636
|
+
function ModelDiffRenderer({ node, enrichment }) {
|
|
637
|
+
const { ModelRef } = useAgentDiffRefs();
|
|
638
|
+
const oldId = typeof node.oldValue === "string" ? node.oldValue : null;
|
|
639
|
+
const newId = typeof node.newValue === "string" ? node.newValue : null;
|
|
640
|
+
const oldName = oldId ? enrichment?.resolveModelId(oldId) : null;
|
|
641
|
+
const newName = newId ? enrichment?.resolveModelId(newId) : null;
|
|
642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary", children: [
|
|
643
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "border-r border-border" }),
|
|
644
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
645
|
+
"div",
|
|
646
|
+
{
|
|
647
|
+
className: (0, import_design_system5.cn)(
|
|
648
|
+
"px-3 py-2 border-r border-border",
|
|
649
|
+
node.changeType !== "unchanged" ? "bg-destructive/10 bg-destructive/15" : ""
|
|
650
|
+
),
|
|
651
|
+
children: oldId ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
652
|
+
ModelRef,
|
|
653
|
+
{
|
|
654
|
+
modelId: oldId,
|
|
655
|
+
name: oldName,
|
|
656
|
+
showId: true,
|
|
657
|
+
className: (0, import_design_system5.cn)(
|
|
658
|
+
node.changeType !== "unchanged" ? "text-destructive" : "text-foreground/80"
|
|
659
|
+
)
|
|
660
|
+
}
|
|
661
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground", children: "Default" })
|
|
662
|
+
}
|
|
663
|
+
),
|
|
664
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
665
|
+
"div",
|
|
666
|
+
{
|
|
667
|
+
className: (0, import_design_system5.cn)(
|
|
668
|
+
"px-3 py-2",
|
|
669
|
+
node.changeType !== "unchanged" ? "bg-success/10 bg-success/15" : ""
|
|
670
|
+
),
|
|
671
|
+
children: newId ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
672
|
+
ModelRef,
|
|
673
|
+
{
|
|
674
|
+
modelId: newId,
|
|
675
|
+
name: newName,
|
|
676
|
+
showId: true,
|
|
677
|
+
className: (0, import_design_system5.cn)(
|
|
678
|
+
node.changeType !== "unchanged" ? "text-success" : "text-foreground/80"
|
|
679
|
+
)
|
|
680
|
+
}
|
|
681
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground", children: "Default" })
|
|
682
|
+
}
|
|
683
|
+
)
|
|
684
|
+
] });
|
|
685
|
+
}
|
|
686
|
+
var ModelAdapter = {
|
|
687
|
+
label: "Model",
|
|
688
|
+
icon: Webhook,
|
|
689
|
+
renderDiff: ModelDiffRenderer,
|
|
690
|
+
toSummaryText: (node, ctx) => {
|
|
691
|
+
const oldId = typeof node.oldValue === "string" ? node.oldValue : null;
|
|
692
|
+
const newId = typeof node.newValue === "string" ? node.newValue : null;
|
|
693
|
+
const resolvedOld = oldId ? ctx?.resolveModelId(oldId) : null;
|
|
694
|
+
const resolvedNew = newId ? ctx?.resolveModelId(newId) : null;
|
|
695
|
+
const oldName = oldId ? resolvedOld && resolvedOld !== oldId ? resolvedOld : `Unknown AI model (${oldId})` : "Default";
|
|
696
|
+
const newName = newId ? resolvedNew && resolvedNew !== newId ? resolvedNew : `Unknown AI model (${newId})` : "Default";
|
|
697
|
+
return `${oldName} \u2192 ${newName}`;
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
// versions/react/adapters/ModelTiersAdapter.tsx
|
|
702
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
703
|
+
function isRecord(value) {
|
|
704
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
705
|
+
}
|
|
706
|
+
function readModelTierIdentities(value) {
|
|
707
|
+
if (!isRecord(value)) return [];
|
|
708
|
+
const identities = [];
|
|
709
|
+
if (typeof value.default === "string" && value.default.trim()) {
|
|
710
|
+
identities.push({ key: "default", role: "Default", modelId: value.default });
|
|
711
|
+
}
|
|
712
|
+
if (isRecord(value.tiers)) {
|
|
713
|
+
for (const [tierKey, rawTier] of Object.entries(value.tiers)) {
|
|
714
|
+
if (!isRecord(rawTier) || typeof rawTier.modelId !== "string") continue;
|
|
715
|
+
const label = typeof rawTier.label === "string" && rawTier.label.trim() ? rawTier.label : tierKey;
|
|
716
|
+
identities.push({ key: `tier:${tierKey}`, role: label, modelId: rawTier.modelId });
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return identities;
|
|
720
|
+
}
|
|
721
|
+
function ModelTierIdentityList({ value }) {
|
|
722
|
+
const { ModelRef } = useAgentDiffRefs();
|
|
723
|
+
const identities = readModelTierIdentities(value);
|
|
724
|
+
if (identities.length === 0) {
|
|
725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-muted-foreground", children: "No model tiers" });
|
|
726
|
+
}
|
|
727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "flex flex-col gap-1.5", children: identities.map((identity) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-start gap-2", children: [
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-muted-foreground", children: identity.role }),
|
|
729
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModelRef, { modelId: identity.modelId, showId: true })
|
|
730
|
+
] }, identity.key)) });
|
|
731
|
+
}
|
|
732
|
+
function ModelTiersDiffRenderer({ node }) {
|
|
733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary", children: [
|
|
734
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "border-r border-border" }),
|
|
735
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "border-r border-border px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModelTierIdentityList, { value: node.oldValue }) }),
|
|
736
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ModelTierIdentityList, { value: node.newValue }) })
|
|
737
|
+
] });
|
|
738
|
+
}
|
|
739
|
+
function summarizeTiers(value, enrichment) {
|
|
740
|
+
const identities = readModelTierIdentities(value);
|
|
741
|
+
if (identities.length === 0) return "none";
|
|
742
|
+
return identities.map(({ role, modelId }) => {
|
|
743
|
+
const name = enrichment?.resolveModelId(modelId);
|
|
744
|
+
return `${role}: ${name ?? `Unknown AI model (${modelId})`}`;
|
|
745
|
+
}).join(", ");
|
|
746
|
+
}
|
|
747
|
+
var ModelTiersAdapter = {
|
|
748
|
+
label: "Model Tiers",
|
|
749
|
+
icon: Layers3,
|
|
750
|
+
renderDiff: ModelTiersDiffRenderer,
|
|
751
|
+
toSummaryText: (node, enrichment) => `${summarizeTiers(node.oldValue, enrichment)} \u2192 ${summarizeTiers(node.newValue, enrichment)}`
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// versions/react/adapters/SettingsAdapter.tsx
|
|
755
|
+
var import_design_system6 = require("@ai-matrx/design-system");
|
|
756
|
+
var import_structural2 = require("@ai-matrx/diff/structural");
|
|
757
|
+
var import_text_case2 = require("@ai-matrx/kit/text-case");
|
|
758
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
759
|
+
function SettingsDiffRenderer({ node }) {
|
|
760
|
+
const entries = node.children ?? buildEntries();
|
|
761
|
+
function buildEntries() {
|
|
762
|
+
const oldSettings = node.oldValue ?? {};
|
|
763
|
+
const newSettings = node.newValue ?? {};
|
|
764
|
+
const allKeys = [
|
|
765
|
+
.../* @__PURE__ */ new Set([...Object.keys(oldSettings), ...Object.keys(newSettings)])
|
|
766
|
+
];
|
|
767
|
+
return allKeys.map((key) => ({
|
|
768
|
+
path: [key],
|
|
769
|
+
key,
|
|
770
|
+
changeType: JSON.stringify(oldSettings[key]) === JSON.stringify(newSettings[key]) ? "unchanged" : "modified",
|
|
771
|
+
oldValue: oldSettings[key],
|
|
772
|
+
newValue: newSettings[key]
|
|
773
|
+
}));
|
|
774
|
+
}
|
|
775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: entries.map((child) => {
|
|
776
|
+
const oldVal = child.oldValue != null ? (0, import_structural2.formatValue)(child.oldValue) : "\u2014";
|
|
777
|
+
const newVal = child.newValue != null ? (0, import_structural2.formatValue)(child.newValue) : "\u2014";
|
|
778
|
+
const changed = child.changeType !== "unchanged";
|
|
779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
780
|
+
"div",
|
|
781
|
+
{
|
|
782
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
783
|
+
children: [
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8", children: (0, import_text_case2.humanizeIdentifier)(child.key) }),
|
|
785
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
786
|
+
"div",
|
|
787
|
+
{
|
|
788
|
+
className: (0, import_design_system6.cn)(
|
|
789
|
+
"px-3 py-1.5 border-r border-border",
|
|
790
|
+
changed && child.changeType !== "added" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "text-foreground/80",
|
|
791
|
+
child.changeType === "added" ? "text-muted-foreground/50" : ""
|
|
792
|
+
),
|
|
793
|
+
children: oldVal
|
|
794
|
+
}
|
|
795
|
+
),
|
|
796
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
797
|
+
"div",
|
|
798
|
+
{
|
|
799
|
+
className: (0, import_design_system6.cn)(
|
|
800
|
+
"px-3 py-1.5",
|
|
801
|
+
changed && child.changeType !== "removed" ? "bg-success/10 text-success-ink bg-success/15" : "text-foreground/80",
|
|
802
|
+
child.changeType === "removed" ? "text-muted-foreground/50" : ""
|
|
803
|
+
),
|
|
804
|
+
children: newVal
|
|
805
|
+
}
|
|
806
|
+
)
|
|
807
|
+
]
|
|
808
|
+
},
|
|
809
|
+
child.key
|
|
810
|
+
);
|
|
811
|
+
}) });
|
|
812
|
+
}
|
|
813
|
+
var SettingsAdapter = {
|
|
814
|
+
label: "Settings",
|
|
815
|
+
icon: Settings,
|
|
816
|
+
renderDiff: SettingsDiffRenderer,
|
|
817
|
+
toSummaryText: (node) => {
|
|
818
|
+
if (node.children) {
|
|
819
|
+
const changed = (0, import_structural2.filterChanges)(node.children);
|
|
820
|
+
if (changed.length === 1) {
|
|
821
|
+
const c = changed[0];
|
|
822
|
+
return `${c.key}: ${(0, import_structural2.formatValue)(c.oldValue)} \u2192 ${(0, import_structural2.formatValue)(c.newValue)}`;
|
|
823
|
+
}
|
|
824
|
+
return `${changed.length} setting${changed.length !== 1 ? "s" : ""} changed`;
|
|
825
|
+
}
|
|
826
|
+
return "Settings changed";
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
// versions/react/adapters/ToolsAdapter.tsx
|
|
831
|
+
var import_design_system7 = require("@ai-matrx/design-system");
|
|
832
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
833
|
+
function resolveTool(id, enrichment) {
|
|
834
|
+
return enrichment?.resolveToolId(id) ?? id;
|
|
835
|
+
}
|
|
836
|
+
function summarizeTool(id, enrichment) {
|
|
837
|
+
const name = enrichment?.resolveToolId(id);
|
|
838
|
+
return name && name !== id ? name : `Unknown tool (${id})`;
|
|
839
|
+
}
|
|
840
|
+
function ToolsDiffRenderer({ node, enrichment }) {
|
|
841
|
+
const { ToolRef } = useAgentDiffRefs();
|
|
842
|
+
const oldTools = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
843
|
+
const newTools = Array.isArray(node.newValue) ? node.newValue : [];
|
|
844
|
+
const allToolIds = [.../* @__PURE__ */ new Set([...oldTools, ...newTools])];
|
|
845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: allToolIds.map((id) => {
|
|
846
|
+
const inOld = oldTools.includes(id);
|
|
847
|
+
const inNew = newTools.includes(id);
|
|
848
|
+
const name = resolveTool(id, enrichment);
|
|
849
|
+
const status = inOld && inNew ? "unchanged" : inOld ? "removed" : "added";
|
|
850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
851
|
+
"div",
|
|
852
|
+
{
|
|
853
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
854
|
+
children: [
|
|
855
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToolRef, { toolId: id, name: name === id ? void 0 : name, showId: true }) }),
|
|
856
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
857
|
+
"div",
|
|
858
|
+
{
|
|
859
|
+
className: (0, import_design_system7.cn)(
|
|
860
|
+
"px-3 py-1.5 border-r border-border",
|
|
861
|
+
status === "removed" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "",
|
|
862
|
+
status === "added" ? "text-muted-foreground/50" : "",
|
|
863
|
+
status === "unchanged" ? "text-foreground/80" : ""
|
|
864
|
+
),
|
|
865
|
+
children: inOld ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToolRef, { toolId: id, name: name === id ? void 0 : name }) : "\u2014"
|
|
866
|
+
}
|
|
867
|
+
),
|
|
868
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
869
|
+
"div",
|
|
870
|
+
{
|
|
871
|
+
className: (0, import_design_system7.cn)(
|
|
872
|
+
"px-3 py-1.5",
|
|
873
|
+
status === "added" ? "bg-success/10 text-success-ink bg-success/15" : "",
|
|
874
|
+
status === "removed" ? "text-muted-foreground/50" : "",
|
|
875
|
+
status === "unchanged" ? "text-foreground/80" : ""
|
|
876
|
+
),
|
|
877
|
+
children: inNew ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToolRef, { toolId: id, name: name === id ? void 0 : name }) : "\u2014"
|
|
878
|
+
}
|
|
879
|
+
)
|
|
880
|
+
]
|
|
881
|
+
},
|
|
882
|
+
id
|
|
883
|
+
);
|
|
884
|
+
}) });
|
|
885
|
+
}
|
|
886
|
+
var ToolsAdapter = {
|
|
887
|
+
label: "Tools",
|
|
888
|
+
icon: Wrench,
|
|
889
|
+
renderDiff: ToolsDiffRenderer,
|
|
890
|
+
toSummaryText: (node, ctx) => {
|
|
891
|
+
const oldArr = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
892
|
+
const newArr = Array.isArray(node.newValue) ? node.newValue : [];
|
|
893
|
+
const added = newArr.filter((t) => !oldArr.includes(t));
|
|
894
|
+
const removed = oldArr.filter((t) => !newArr.includes(t));
|
|
895
|
+
const parts = [];
|
|
896
|
+
if (added.length > 0)
|
|
897
|
+
parts.push(
|
|
898
|
+
`Added: ${added.map((id) => summarizeTool(id, ctx)).join(", ")}`
|
|
899
|
+
);
|
|
900
|
+
if (removed.length > 0)
|
|
901
|
+
parts.push(
|
|
902
|
+
`Removed: ${removed.map((id) => summarizeTool(id, ctx)).join(", ")}`
|
|
903
|
+
);
|
|
904
|
+
return parts.join("; ") || "Tools changed";
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
// versions/react/adapters/VariablesAdapter.tsx
|
|
909
|
+
var import_design_system8 = require("@ai-matrx/design-system");
|
|
910
|
+
var import_structural3 = require("@ai-matrx/diff/structural");
|
|
911
|
+
var import_react5 = require("@ai-matrx/diff/react");
|
|
912
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
913
|
+
function formatVar(v) {
|
|
914
|
+
if (!v) return "\u2014";
|
|
915
|
+
const parts = [`{{${v.name}}}`];
|
|
916
|
+
if (v.type) parts.push(`[${v.type}]`);
|
|
917
|
+
if (v.defaultValue !== void 0)
|
|
918
|
+
parts.push(`= ${(0, import_structural3.formatValue)(v.defaultValue)}`);
|
|
919
|
+
if (v.required) parts.push("(required)");
|
|
920
|
+
if (v.helpText) parts.push(`
|
|
921
|
+
${v.helpText}`);
|
|
922
|
+
return parts.join(" ");
|
|
923
|
+
}
|
|
924
|
+
function VariablesDiffRenderer({ node }) {
|
|
925
|
+
if (node.children && node.children.length > 0) {
|
|
926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: node.children.map((child, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(VariableRow, { child }, child.key ?? i)) });
|
|
927
|
+
}
|
|
928
|
+
const oldVars = Array.isArray(node.oldValue) ? node.oldValue : [];
|
|
929
|
+
const newVars = Array.isArray(node.newValue) ? node.newValue : [];
|
|
930
|
+
const maxLen = Math.max(oldVars.length, newVars.length);
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: Array.from({ length: maxLen }, (_, i) => {
|
|
932
|
+
const oldVar = oldVars[i];
|
|
933
|
+
const newVar = newVars[i];
|
|
934
|
+
const changed = JSON.stringify(oldVar) !== JSON.stringify(newVar);
|
|
935
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
936
|
+
"div",
|
|
937
|
+
{
|
|
938
|
+
className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30",
|
|
939
|
+
children: [
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono", children: newVar?.name ?? oldVar?.name ?? `#${i + 1}` }),
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
942
|
+
"div",
|
|
943
|
+
{
|
|
944
|
+
className: (0, import_design_system8.cn)(
|
|
945
|
+
"px-3 py-1.5 border-r border-border whitespace-pre-wrap",
|
|
946
|
+
changed && oldVar ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "text-foreground/80",
|
|
947
|
+
!oldVar ? "text-muted-foreground/50" : ""
|
|
948
|
+
),
|
|
949
|
+
children: formatVar(oldVar)
|
|
950
|
+
}
|
|
951
|
+
),
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
953
|
+
"div",
|
|
954
|
+
{
|
|
955
|
+
className: (0, import_design_system8.cn)(
|
|
956
|
+
"px-3 py-1.5 whitespace-pre-wrap",
|
|
957
|
+
changed && newVar ? "bg-success/10 text-success-ink bg-success/15" : "text-foreground/80",
|
|
958
|
+
!newVar ? "text-muted-foreground/50" : ""
|
|
959
|
+
),
|
|
960
|
+
children: formatVar(newVar)
|
|
961
|
+
}
|
|
962
|
+
)
|
|
963
|
+
]
|
|
964
|
+
},
|
|
965
|
+
i
|
|
966
|
+
);
|
|
967
|
+
}) });
|
|
968
|
+
}
|
|
969
|
+
function VariableRow({ child }) {
|
|
970
|
+
const oldVar = child.oldValue;
|
|
971
|
+
const newVar = child.newValue;
|
|
972
|
+
const varName = newVar?.name ?? oldVar?.name ?? child.key;
|
|
973
|
+
if (child.changeType === "modified" && oldVar && newVar) {
|
|
974
|
+
const oldText = formatVar(oldVar);
|
|
975
|
+
const newText = formatVar(newVar);
|
|
976
|
+
if (oldText !== "" && newText !== "") {
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "grid grid-cols-[200px_1fr] type-secondary border-t border-border/30", children: [
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono", children: "{{" + varName + "}}" }),
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "min-w-0 overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react5.InlineTextDiff, { original: oldText, modified: newText }) })
|
|
980
|
+
] });
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "grid grid-cols-[200px_1fr_1fr] type-secondary border-t border-border/30", children: [
|
|
984
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 py-1.5 border-r border-border text-muted-foreground pl-8 font-mono", children: "{{" + varName + "}}" }),
|
|
985
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
986
|
+
"div",
|
|
987
|
+
{
|
|
988
|
+
className: (0, import_design_system8.cn)(
|
|
989
|
+
"px-3 py-1.5 border-r border-border whitespace-pre-wrap",
|
|
990
|
+
child.changeType === "removed" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "",
|
|
991
|
+
child.changeType === "modified" ? "bg-destructive/10 text-destructive-ink bg-destructive/15" : "",
|
|
992
|
+
child.changeType === "added" ? "text-muted-foreground/50" : "",
|
|
993
|
+
child.changeType === "unchanged" ? "text-foreground/80" : ""
|
|
994
|
+
),
|
|
995
|
+
children: formatVar(oldVar)
|
|
996
|
+
}
|
|
997
|
+
),
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
999
|
+
"div",
|
|
1000
|
+
{
|
|
1001
|
+
className: (0, import_design_system8.cn)(
|
|
1002
|
+
"px-3 py-1.5 whitespace-pre-wrap",
|
|
1003
|
+
child.changeType === "added" ? "bg-success/10 text-success-ink bg-success/15" : "",
|
|
1004
|
+
child.changeType === "modified" ? "bg-success/10 text-success-ink bg-success/15" : "",
|
|
1005
|
+
child.changeType === "removed" ? "text-muted-foreground/50" : "",
|
|
1006
|
+
child.changeType === "unchanged" ? "text-foreground/80" : ""
|
|
1007
|
+
),
|
|
1008
|
+
children: formatVar(newVar)
|
|
1009
|
+
}
|
|
1010
|
+
)
|
|
1011
|
+
] });
|
|
1012
|
+
}
|
|
1013
|
+
var VariablesAdapter = {
|
|
1014
|
+
label: "Variables",
|
|
1015
|
+
icon: Variable,
|
|
1016
|
+
renderDiff: VariablesDiffRenderer,
|
|
1017
|
+
toSummaryText: (node) => {
|
|
1018
|
+
if (!node.children) return "Variables changed";
|
|
1019
|
+
const changed = node.children.filter((c) => c.changeType !== "unchanged");
|
|
1020
|
+
const added = changed.filter((c) => c.changeType === "added").length;
|
|
1021
|
+
const removed = changed.filter((c) => c.changeType === "removed").length;
|
|
1022
|
+
const modified = changed.filter((c) => c.changeType === "modified").length;
|
|
1023
|
+
const parts = [];
|
|
1024
|
+
if (added > 0) parts.push(`${added} added`);
|
|
1025
|
+
if (removed > 0) parts.push(`${removed} removed`);
|
|
1026
|
+
if (modified > 0) parts.push(`${modified} modified`);
|
|
1027
|
+
return parts.join(", ") || "Variables changed";
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
// versions/react/AgentDiffViewer.tsx
|
|
1032
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1033
|
+
function buildAgentAdapterRegistry() {
|
|
1034
|
+
const registry = (0, import_react7.createAdapterRegistry)();
|
|
1035
|
+
registry.register("messages", MessagesAdapter);
|
|
1036
|
+
registry.register("modelId", ModelAdapter);
|
|
1037
|
+
registry.register("tools", ToolsAdapter);
|
|
1038
|
+
registry.register("settings", SettingsAdapter);
|
|
1039
|
+
registry.register("variableDefinitions", VariablesAdapter);
|
|
1040
|
+
registry.register("contextPolicies", ContextPoliciesAdapter);
|
|
1041
|
+
registry.register("customTools", CustomToolsAdapter);
|
|
1042
|
+
registry.register("mcpServers", McpServersAdapter);
|
|
1043
|
+
registry.register("name", { ...import_react7.TextFieldAdapter, label: "Name" });
|
|
1044
|
+
registry.register("description", { ...import_react7.TextFieldAdapter, label: "Description" });
|
|
1045
|
+
registry.register("category", { ...import_react7.TextFieldAdapter, label: "Category" });
|
|
1046
|
+
registry.register("tags", { ...import_react7.TagsFieldAdapter, label: "Tags" });
|
|
1047
|
+
registry.register("isActive", { ...import_react7.BooleanFieldAdapter, label: "Active" });
|
|
1048
|
+
registry.register("isArchived", { ...import_react7.BooleanFieldAdapter, label: "Archived" });
|
|
1049
|
+
registry.register("isFavorite", { ...import_react7.BooleanFieldAdapter, label: "Favorite" });
|
|
1050
|
+
registry.register("autoToolsDisabled", { ...import_react7.BooleanFieldAdapter, label: "Automatic Tool Injection Disabled" });
|
|
1051
|
+
registry.register("version", { ...import_react7.TextFieldAdapter, label: "Version" });
|
|
1052
|
+
registry.register("changeNote", { ...import_react7.TextFieldAdapter, label: "Change Note" });
|
|
1053
|
+
registry.register("defaultRagBoost", { ...import_react7.TextFieldAdapter, label: "Default Knowledge Boost" });
|
|
1054
|
+
registry.register("ragAwarenessMode", { ...import_react7.TextFieldAdapter, label: "Knowledge Awareness Mode" });
|
|
1055
|
+
registry.register("modelTiers", ModelTiersAdapter);
|
|
1056
|
+
registry.register("outputSchema", { ...import_react7.JsonObjectAdapter, label: "Output Schema" });
|
|
1057
|
+
registry.register("skillConfig", { ...import_react7.JsonObjectAdapter, label: "Skill Configuration" });
|
|
1058
|
+
registry.register("uiGates", { ...import_react7.JsonObjectAdapter, label: "UI Gates" });
|
|
1059
|
+
registry.register("matrxDirectives", { ...import_react7.JsonObjectAdapter, label: "Matrx Directives" });
|
|
1060
|
+
return registry;
|
|
1061
|
+
}
|
|
1062
|
+
function AgentDiffViewer({
|
|
1063
|
+
oldAgent,
|
|
1064
|
+
newAgent,
|
|
1065
|
+
oldLabel,
|
|
1066
|
+
newLabel,
|
|
1067
|
+
temporalMetadata,
|
|
1068
|
+
defaultMode = "changes-only",
|
|
1069
|
+
className,
|
|
1070
|
+
enrichment,
|
|
1071
|
+
refs
|
|
1072
|
+
}) {
|
|
1073
|
+
const adapters = (0, import_react6.useMemo)(() => buildAgentAdapterRegistry(), []);
|
|
1074
|
+
const diffResult = (0, import_react6.useMemo)(() => compareAgentDefinitions(oldAgent, newAgent).diffResult, [oldAgent, newAgent]);
|
|
1075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AgentDiffRefsProvider, { refs, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1076
|
+
import_react7.DiffViewerShell,
|
|
1077
|
+
{
|
|
1078
|
+
diffResult,
|
|
1079
|
+
oldValue: oldAgent,
|
|
1080
|
+
newValue: newAgent,
|
|
1081
|
+
oldLabel,
|
|
1082
|
+
newLabel,
|
|
1083
|
+
adapters,
|
|
1084
|
+
...enrichment ? { enrichment } : {},
|
|
1085
|
+
...temporalMetadata ? { temporalMetadata } : {},
|
|
1086
|
+
defaultMode,
|
|
1087
|
+
...className ? { className } : {}
|
|
1088
|
+
}
|
|
1089
|
+
) });
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// versions/react/VersionHistoryTimeline.tsx
|
|
1093
|
+
var import_react8 = require("react");
|
|
1094
|
+
var import_controls2 = require("@ai-matrx/design-system/controls");
|
|
1095
|
+
var import_design_system9 = require("@ai-matrx/design-system");
|
|
1096
|
+
var import_data_table = require("@ai-matrx/design-system/data-table");
|
|
1097
|
+
var import_design_system10 = require("@ai-matrx/design-system");
|
|
1098
|
+
var import_text_case3 = require("@ai-matrx/kit/text-case");
|
|
1099
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1100
|
+
var SILENT = { success: () => {
|
|
1101
|
+
}, error: () => {
|
|
1102
|
+
} };
|
|
1103
|
+
function VersionHistoryTimeline({
|
|
1104
|
+
agentId,
|
|
1105
|
+
versions,
|
|
1106
|
+
currentVersion,
|
|
1107
|
+
onCompare,
|
|
1108
|
+
history,
|
|
1109
|
+
onDeclareContractBreak,
|
|
1110
|
+
notify = SILENT,
|
|
1111
|
+
rowActions,
|
|
1112
|
+
footer = null,
|
|
1113
|
+
ErrorMenu
|
|
1114
|
+
}) {
|
|
1115
|
+
const {
|
|
1116
|
+
enrichedVersions,
|
|
1117
|
+
loading: enrichLoading,
|
|
1118
|
+
progress,
|
|
1119
|
+
failedVersions,
|
|
1120
|
+
failureReason,
|
|
1121
|
+
fetchEnrichedHistory,
|
|
1122
|
+
fetchGap
|
|
1123
|
+
} = history;
|
|
1124
|
+
const breakPorts = { onDeclare: onDeclareContractBreak, notify };
|
|
1125
|
+
const hasEnrichedData = enrichedVersions.some((v) => v.diffSummary);
|
|
1126
|
+
const entries = (enriched) => enrichedVersions.map((version) => {
|
|
1127
|
+
const changedFields = version.diffSummary?.root.filter((n) => n.changeType !== "unchanged") ?? [];
|
|
1128
|
+
return {
|
|
1129
|
+
number: version.version_number,
|
|
1130
|
+
versionId: version.version_id,
|
|
1131
|
+
idCell: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system10.RecordId, { value: version.version_id, label: "Version" }),
|
|
1132
|
+
at: version.changed_at,
|
|
1133
|
+
note: version.change_note ?? null,
|
|
1134
|
+
loaded: enriched ? version.snapshotLoaded : false,
|
|
1135
|
+
changes: enriched ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VersionChanges, { version, ports: breakPorts }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", children: [
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ContractBreak, { version, ports: breakPorts }),
|
|
1137
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-muted-foreground", children: "Not loaded" })
|
|
1138
|
+
] }),
|
|
1139
|
+
changesText: changedFields.map((n) => (0, import_text_case3.humanizeIdentifier)(n.key) || n.key).join(", ") || null
|
|
1140
|
+
};
|
|
1141
|
+
});
|
|
1142
|
+
const timeline = (enriched) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1143
|
+
import_data_table.MatrxVersionTimeline,
|
|
1144
|
+
{
|
|
1145
|
+
tableId: `agent.${agentId}.versions`,
|
|
1146
|
+
versions: entries(enriched),
|
|
1147
|
+
currentNumber: currentVersion,
|
|
1148
|
+
onCompare,
|
|
1149
|
+
...enriched ? { onLoad: (numbers) => void fetchGap(numbers) } : {},
|
|
1150
|
+
...rowActions ? { rowActions } : {},
|
|
1151
|
+
emptyState: { title: "No version history" }
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
if (versions.length === 0) {
|
|
1155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center justify-center py-12 type-body text-muted-foreground", children: "No version history" });
|
|
1156
|
+
}
|
|
1157
|
+
if (!hasEnrichedData && !enrichLoading) {
|
|
1158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col items-center justify-center py-16 gap-4", children: [
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "text-center", children: [
|
|
1160
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "type-title mb-1", children: [
|
|
1161
|
+
versions.length,
|
|
1162
|
+
" version",
|
|
1163
|
+
versions.length !== 1 ? "s" : "",
|
|
1164
|
+
" ",
|
|
1165
|
+
"available"
|
|
1166
|
+
] }),
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "type-secondary text-muted-foreground max-w-[320px]", children: "Load history to see what changed in each version" })
|
|
1168
|
+
] }),
|
|
1169
|
+
failedVersions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-start gap-2 max-w-[420px] px-3 py-2 rounded-md border border-destructive/30 bg-destructive/10 type-secondary text-destructive-ink", children: [
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AlertTriangle, { className: "w-3.5 h-3.5 mt-0.5 shrink-0" }),
|
|
1171
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { children: [
|
|
1172
|
+
failedVersions.length,
|
|
1173
|
+
" of ",
|
|
1174
|
+
progress.total,
|
|
1175
|
+
" snapshot",
|
|
1176
|
+
failedVersions.length !== 1 ? "s" : "",
|
|
1177
|
+
" could not be read",
|
|
1178
|
+
failureReason ? `: ${failureReason}` : ".",
|
|
1179
|
+
" Retrying loads the ones that are readable."
|
|
1180
|
+
] }),
|
|
1181
|
+
ErrorMenu ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ErrorMenu, {}) : null
|
|
1182
|
+
] }),
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1184
|
+
import_controls2.Button,
|
|
1185
|
+
{
|
|
1186
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Atom, {}),
|
|
1187
|
+
variant: "primary",
|
|
1188
|
+
onClick: () => void fetchEnrichedHistory(),
|
|
1189
|
+
children: "Load Full History"
|
|
1190
|
+
}
|
|
1191
|
+
),
|
|
1192
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w-full mt-4 border-t border-border pt-4 px-4", children: timeline(false) }),
|
|
1193
|
+
footer
|
|
1194
|
+
] });
|
|
1195
|
+
}
|
|
1196
|
+
if (enrichLoading) {
|
|
1197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col items-center justify-center py-16 gap-3", children: [
|
|
1198
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LoaderSpin, { className: "h-8 w-8 text-primary" }),
|
|
1199
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "type-body text-muted-foreground", children: [
|
|
1200
|
+
"Loading version details... ",
|
|
1201
|
+
progress.fetched,
|
|
1202
|
+
"/",
|
|
1203
|
+
progress.total
|
|
1204
|
+
] }),
|
|
1205
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w-48 h-1.5 bg-muted rounded-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1206
|
+
"div",
|
|
1207
|
+
{
|
|
1208
|
+
className: "h-full bg-primary rounded-full transition-all duration-300",
|
|
1209
|
+
style: {
|
|
1210
|
+
width: `${progress.total > 0 ? progress.fetched / progress.total * 100 : 0}%`
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
) })
|
|
1214
|
+
] });
|
|
1215
|
+
}
|
|
1216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "px-4 py-3", children: [
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center justify-between mb-3 pb-3 border-b border-border", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "type-secondary text-muted-foreground", children: [
|
|
1218
|
+
enrichedVersions.filter((v) => v.snapshotLoaded).length,
|
|
1219
|
+
" of",
|
|
1220
|
+
" ",
|
|
1221
|
+
versions.length,
|
|
1222
|
+
" versions loaded",
|
|
1223
|
+
failedVersions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "text-destructive", children: [
|
|
1224
|
+
" ",
|
|
1225
|
+
"\xB7 ",
|
|
1226
|
+
failedVersions.length,
|
|
1227
|
+
" could not be read",
|
|
1228
|
+
ErrorMenu ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ErrorMenu, { error: failureReason ?? "Some version snapshots could not be read" }) : null
|
|
1229
|
+
] })
|
|
1230
|
+
] }) }),
|
|
1231
|
+
timeline(true),
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "h-[50dvh]" }),
|
|
1233
|
+
footer
|
|
1234
|
+
] });
|
|
1235
|
+
}
|
|
1236
|
+
function VersionChanges({ version, ports }) {
|
|
1237
|
+
const diff = version.diffSummary;
|
|
1238
|
+
const changedFields = diff?.root.filter((n) => n.changeType !== "unchanged") ?? [];
|
|
1239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", children: [
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ContractBreak, { version, ports }),
|
|
1241
|
+
diff && changedFields.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_controls2.ChipSet, { children: changedFields.map((n) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1242
|
+
import_controls2.Chip,
|
|
1243
|
+
{
|
|
1244
|
+
tone: n.changeType === "added" ? "success" : n.changeType === "removed" ? "destructive" : "warning",
|
|
1245
|
+
label: `${(0, import_text_case3.humanizeIdentifier)(n.key) || n.key}${n.changeType === "added" ? " +" : n.changeType === "removed" ? " \u2212" : ""}`
|
|
1246
|
+
},
|
|
1247
|
+
n.key
|
|
1248
|
+
)) }) : diff && changedFields.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-muted-foreground", children: "No changes" }) : !version.snapshotLoaded ? (
|
|
1249
|
+
// An unread snapshot says so — never a lone contract-break button where the
|
|
1250
|
+
// changes belong (walk-core 2026-10-18: v9–v2 showed only the shield).
|
|
1251
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-muted-foreground", children: "Not loaded" })
|
|
1252
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-muted-foreground", children: "First version" })
|
|
1253
|
+
] });
|
|
1254
|
+
}
|
|
1255
|
+
function ContractBreak({ version, ports }) {
|
|
1256
|
+
const [declared, setDeclared] = (0, import_react8.useState)(
|
|
1257
|
+
version.contract_break_declared ?? null
|
|
1258
|
+
);
|
|
1259
|
+
async function declareBreak(kind) {
|
|
1260
|
+
if (!ports.onDeclare) return;
|
|
1261
|
+
const previous = declared;
|
|
1262
|
+
setDeclared(kind);
|
|
1263
|
+
try {
|
|
1264
|
+
await ports.onDeclare(version.version_number, kind);
|
|
1265
|
+
} catch (error) {
|
|
1266
|
+
setDeclared(previous);
|
|
1267
|
+
ports.notify.error(`Couldn't record the contract break: ${error instanceof Error ? error.message : String(error)}`);
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
{
|
|
1271
|
+
ports.notify.success(
|
|
1272
|
+
kind ? `v${version.version_number} marked as a ${kind} contract break.` : `Contract-break declaration cleared for v${version.version_number}.`
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
const autoChange = version.contract_change || null;
|
|
1277
|
+
const effectiveChange = declared ?? autoChange;
|
|
1278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1279
|
+
effectiveChange && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1280
|
+
import_controls2.Badge,
|
|
1281
|
+
{
|
|
1282
|
+
tone: "warning",
|
|
1283
|
+
title: declared ? "Manually declared: the way this agent is used could break at this version." : "The declared input/output structure changed at this version \u2014 pinned callers and saved sample inputs may no longer fit.",
|
|
1284
|
+
children: `Contract: ${effectiveChange}${declared ? " (declared)" : ""}`
|
|
1285
|
+
}
|
|
1286
|
+
),
|
|
1287
|
+
ports.onDeclare ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_design_system9.DropdownMenu, { children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system9.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1289
|
+
import_controls2.Button,
|
|
1290
|
+
{
|
|
1291
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ShieldAlert, {}),
|
|
1292
|
+
"aria-label": "Mark this version as a contract break the hashes cannot see (e.g. a prompt-level output change)",
|
|
1293
|
+
variant: "quiet",
|
|
1294
|
+
title: "Mark this version as a contract break the hashes cannot see (e.g. a prompt-level output change)"
|
|
1295
|
+
}
|
|
1296
|
+
) }),
|
|
1297
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_design_system9.DropdownMenuContent, { align: "start", children: [
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system9.DropdownMenuItem, { onClick: () => void declareBreak("input"), children: "Declare input break" }),
|
|
1299
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system9.DropdownMenuItem, { onClick: () => void declareBreak("output"), children: "Declare output break" }),
|
|
1300
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system9.DropdownMenuItem, { onClick: () => void declareBreak("both"), children: "Declare input + output break" }),
|
|
1301
|
+
declared && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_design_system9.DropdownMenuItem, { onClick: () => void declareBreak(null), children: "Clear declaration" })
|
|
1302
|
+
] })
|
|
1303
|
+
] }) : null
|
|
1304
|
+
] });
|
|
1305
|
+
}
|