@zq-silk/yui 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +19 -3
  2. package/dist/artifacts/artifactCapability.js +39 -10
  3. package/dist/artifacts/imageMetadata.js +120 -0
  4. package/dist/artifacts/managedGit.js +7 -4
  5. package/dist/artifacts/taskArtifactRepository.js +6 -0
  6. package/dist/cli/commandCatalog.js +25 -11
  7. package/dist/cli/interactionPolicy.js +4 -0
  8. package/dist/cli/invocationAuthority.js +1 -1
  9. package/dist/commands/executionAuditCommands.js +5 -0
  10. package/dist/commands/globalRoleCommands.js +41 -3
  11. package/dist/commands/projectCommands.js +89 -94
  12. package/dist/commands/roleSkillValidation.js +4 -8
  13. package/dist/commands/taskCommands.js +30 -9
  14. package/dist/commands/taskIntegrationCommands.js +5 -16
  15. package/dist/commands/taskUsageCommand.js +38 -0
  16. package/dist/context/roleSessionContext.js +18 -2
  17. package/dist/context/runContextPack.js +5 -1
  18. package/dist/context/sessionBootstrapManifest.js +10 -1
  19. package/dist/context/skillCatalog.js +108 -0
  20. package/dist/context/skillPackage.js +161 -0
  21. package/dist/context/taskContext.js +3 -2
  22. package/dist/context/taskSearch.js +127 -0
  23. package/dist/controlPlaneCli.js +51 -39
  24. package/dist/controller/clientRuntime.js +3 -2
  25. package/dist/controller/fileSchedulerStoreAdapter.js +32 -6
  26. package/dist/controller/jobControl.js +2 -0
  27. package/dist/controller/nativeHostInput.js +37 -0
  28. package/dist/controller/runtime.js +93 -2
  29. package/dist/controller/runtimeEventInbox.js +2 -2
  30. package/dist/controller/runtimeEventProcessor.js +3 -3
  31. package/dist/doctor/doctor.js +10 -0
  32. package/dist/execution/reviewMainRun.js +1 -0
  33. package/dist/execution/workItemMainRun.js +1 -0
  34. package/dist/executor/codexConfigConflict.js +6 -4
  35. package/dist/executor/effectiveLaunch.js +24 -1
  36. package/dist/executor/fileRoleLaunchPlanner.js +13 -5
  37. package/dist/integration/gitIntegrationService.js +15 -79
  38. package/dist/integration/integrationSourceApplication.js +4 -2
  39. package/dist/job/httpPreview.js +61 -0
  40. package/dist/job/jobCleanupInspection.js +67 -0
  41. package/dist/job/jobRunner.js +12 -2
  42. package/dist/kernel/builtinCapabilities.js +3 -1
  43. package/dist/message/message.js +15 -1
  44. package/dist/output/rolePresentation.js +4 -1
  45. package/dist/repository/executionLaneGitSnapshot.js +2 -1
  46. package/dist/repository/gitCompatibility.js +62 -0
  47. package/dist/repository/gitWorkspace.js +86 -80
  48. package/dist/repository/gitWorktreeInventory.js +121 -0
  49. package/dist/repository/project.js +74 -25
  50. package/dist/repository/taskWorkspaceCoordinator.js +72 -145
  51. package/dist/repository/taskWorkspacePreparer.js +39 -43
  52. package/dist/repository/workspaceCleanupInspection.js +88 -7
  53. package/dist/resources/resourceDiscovery.js +2 -2
  54. package/dist/resources/resourceGc.js +7 -4
  55. package/dist/resources/resourceRegistrar.js +18 -11
  56. package/dist/runtime/agentEndpoint.js +8 -0
  57. package/dist/runtime/agentHost.js +170 -3
  58. package/dist/runtime/codexAppServerRuntime.js +1 -1
  59. package/dist/runtime/codexNativeAccess.js +175 -0
  60. package/dist/runtime/controlledCodexTui.js +116 -0
  61. package/dist/runtime/integrationRuntimeIsolation.js +21 -0
  62. package/dist/runtime/publicReply.js +23 -0
  63. package/dist/runtime/runtimeObservation.js +48 -0
  64. package/dist/runtime/structuredProviderHost.js +16 -7
  65. package/dist/runtime/taskCostMetrics.js +133 -0
  66. package/dist/runtime/taskRuntimeIsolation.js +91 -21
  67. package/dist/runtime/taskUsageMetrics.js +11 -2
  68. package/dist/runtime/taskUsageQuery.js +38 -0
  69. package/dist/scheduler/taskExecutionProjection.js +2 -0
  70. package/dist/scheduler/taskObservabilityProjection.js +9 -1
  71. package/dist/storage/homeLayout.js +13 -0
  72. package/dist/storage/sqliteSchema.js +44 -0
  73. package/dist/storage/sqliteStore.js +53 -0
  74. package/dist/storage/storageVersions.js +1 -1
  75. package/dist/storage/storeRpc.js +2 -0
  76. package/dist/storage/taskSearch.js +35 -0
  77. package/dist/storage/upgrade/projectKnowledgeMigration.js +52 -0
  78. package/dist/task/archiveDiagnostics.js +26 -8
  79. package/dist/task/archivePreflight.js +26 -9
  80. package/dist/task/leaderArchive.js +9 -15
  81. package/dist/task/ordinaryArchive.js +42 -0
  82. package/dist/tmux/tmuxManager.js +8 -8
  83. package/dist/web/assets/assetManifest.js +11 -51
  84. package/dist/web/assets/client/app/catalog.js +215 -0
  85. package/dist/web/assets/client/app/main.js +148 -0
  86. package/dist/web/assets/client/app/selection.js +139 -0
  87. package/dist/web/assets/client/app/settings.js +326 -0
  88. package/dist/web/assets/client/app/taskView.js +280 -0
  89. package/dist/web/assets/client/domain/context.js +96 -0
  90. package/dist/web/assets/client/domain/records.js +126 -0
  91. package/dist/web/assets/client/domain/runs.js +119 -0
  92. package/dist/web/assets/client/domain/taskForms.js +197 -0
  93. package/dist/web/assets/client/domain/vocab.js +69 -0
  94. package/dist/web/assets/client/domain/work.js +116 -0
  95. package/dist/web/assets/client/i18n/en.js +900 -0
  96. package/dist/web/assets/client/i18n/zh-CN.js +898 -0
  97. package/dist/web/assets/client/index.js +114 -0
  98. package/dist/web/assets/client/layout/resizer.js +37 -0
  99. package/dist/web/assets/client/layout/router.js +35 -0
  100. package/dist/web/assets/client/layout/shortcuts.js +45 -0
  101. package/dist/web/assets/client/layout/sizing.js +95 -0
  102. package/dist/web/assets/client/layout/workspace.js +247 -0
  103. package/dist/web/assets/client/{api.js → lib/api.js} +28 -4
  104. package/dist/web/assets/client/{dom.js → lib/dom.js} +24 -12
  105. package/dist/web/assets/client/{format.js → lib/format.js} +7 -0
  106. package/dist/web/assets/client/lib/i18n.js +54 -0
  107. package/dist/web/assets/client/lib/markdown.js +167 -0
  108. package/dist/web/assets/client/lib/prefs.js +28 -0
  109. package/dist/web/assets/client/lib/theme.js +68 -0
  110. package/dist/web/assets/client/ui/containers.js +101 -0
  111. package/dist/web/assets/client/ui/controls.js +51 -0
  112. package/dist/web/assets/client/ui/forms.js +48 -0
  113. package/dist/web/assets/client/ui/metrics.js +137 -0
  114. package/dist/web/assets/client/ui/primitives.js +92 -0
  115. package/dist/web/assets/client/ui/text.js +33 -0
  116. package/dist/web/assets/client/ui/toast.js +12 -0
  117. package/dist/web/assets/client/views/bodySearch.js +172 -0
  118. package/dist/web/assets/client/views/createTask.js +85 -0
  119. package/dist/web/assets/client/views/dock/conversation.js +612 -0
  120. package/dist/web/assets/client/views/dock/discussion.js +173 -0
  121. package/dist/web/assets/client/views/dock/preview.js +129 -0
  122. package/dist/web/assets/client/views/dock/terminal.js +199 -0
  123. package/dist/web/assets/client/views/globalInput.js +67 -0
  124. package/dist/web/assets/client/{overview.js → views/overview.js} +62 -56
  125. package/dist/web/assets/client/{sidebar.js → views/sidebar.js} +56 -62
  126. package/dist/web/assets/client/views/skills.js +152 -0
  127. package/dist/web/assets/client/views/task/actions.js +36 -0
  128. package/dist/web/assets/client/views/task/delivery.js +185 -0
  129. package/dist/web/assets/client/views/task/deliveryResults.js +159 -0
  130. package/dist/web/assets/client/views/task/files.js +272 -0
  131. package/dist/web/assets/client/views/task/observation.js +153 -0
  132. package/dist/web/assets/client/views/task/overview.js +161 -0
  133. package/dist/web/assets/client/views/task/page.js +131 -0
  134. package/dist/web/assets/client/views/task/records.js +163 -0
  135. package/dist/web/assets/client/views/task/runtime.js +130 -0
  136. package/dist/web/assets/client/views/task/timeline.js +190 -0
  137. package/dist/web/assets/shared/geometry.js +19 -0
  138. package/dist/web/assets/{icons.js → shared/icons.js} +4 -0
  139. package/dist/web/assets/shared/taskTabs.js +8 -0
  140. package/dist/web/assets/shared/themes.js +93 -0
  141. package/dist/web/assets/shell/dialogs.js +63 -0
  142. package/dist/web/assets/shell/dock.js +40 -0
  143. package/dist/web/assets/shell/index.js +40 -0
  144. package/dist/web/assets/shell/settings.js +34 -0
  145. package/dist/web/assets/shell/sidebar.js +45 -0
  146. package/dist/web/assets/styles/index.js +41 -0
  147. package/dist/web/assets/styles/{responsive.js → layout/responsive.js} +15 -13
  148. package/dist/web/assets/styles/{layout.js → layout/workspace.js} +17 -24
  149. package/dist/web/assets/styles/markdown.js +22 -3
  150. package/dist/web/assets/styles/tokens.js +10 -63
  151. package/dist/web/assets/styles/ui/controls.js +76 -0
  152. package/dist/web/assets/styles/ui/forms.js +46 -0
  153. package/dist/web/assets/styles/ui/surfaces.js +122 -0
  154. package/dist/web/assets/styles/views/delivery.js +29 -0
  155. package/dist/web/assets/styles/views/dock.js +71 -0
  156. package/dist/web/assets/styles/views/page.js +32 -0
  157. package/dist/web/assets/styles/views/records.js +70 -0
  158. package/dist/web/assets/styles/views/settings.js +26 -0
  159. package/dist/web/assets/styles/views/sidebar.js +74 -0
  160. package/dist/web/assets/styles/views/task.js +80 -0
  161. package/dist/web/assets/styles/views/terminal.js +38 -0
  162. package/dist/web/taskPreviews.js +205 -0
  163. package/dist/web/tmuxWebTerminal.js +16 -9
  164. package/dist/web/webConversation.js +373 -0
  165. package/dist/web/webMaterials.js +155 -0
  166. package/dist/web/webServer.js +306 -18
  167. package/dist/web/webSettings.js +331 -0
  168. package/dist/web/webSkills.js +86 -0
  169. package/dist/web/webSnapshot.js +40 -8
  170. package/dist/web/webTaskSurface.js +114 -9
  171. package/dist/workspace/gitChangeSetCapture.js +3 -1
  172. package/docs/managed-turn-and-session-runtime.md +9 -0
  173. package/docs/managed-turn-and-session-runtime.zh-CN.md +7 -0
  174. package/docs/observability/README.md +13 -3
  175. package/docs/observability/README.zh-CN.md +10 -3
  176. package/docs/release-workflow.md +53 -0
  177. package/docs/release-workflow.zh-CN.md +40 -0
  178. package/docs/storage-baseline.md +38 -1
  179. package/docs/storage-baseline.zh-CN.md +22 -0
  180. package/docs/task-delivery.md +36 -8
  181. package/docs/task-delivery.zh-CN.md +24 -7
  182. package/docs/task-discovery.md +28 -0
  183. package/docs/testing/verification-levels.md +2 -2
  184. package/i18n/README.zh-CN.md +4 -3
  185. package/package.json +1 -1
  186. package/skills/yui-leader/references/execution.md +2 -1
  187. package/skills/yui-leader/references/integration.md +20 -0
  188. package/skills/yui-operator/SKILL.md +4 -0
  189. package/skills/yui-reviewer/SKILL.md +3 -0
  190. package/skills/yui-runtime/SKILL.md +4 -0
  191. package/skills/yui-runtime/references/publication.md +20 -4
  192. package/skills/yui-worker/SKILL.md +3 -0
  193. package/dist/web/assets/client/app.js +0 -804
  194. package/dist/web/assets/client/components.js +0 -418
  195. package/dist/web/assets/client/detail.js +0 -333
  196. package/dist/web/assets/client/dock.js +0 -225
  197. package/dist/web/assets/client/evidence.js +0 -172
  198. package/dist/web/assets/client/forms.js +0 -230
  199. package/dist/web/assets/client/i18n.js +0 -1161
  200. package/dist/web/assets/client/markdown.js +0 -114
  201. package/dist/web/assets/client/records.js +0 -63
  202. package/dist/web/assets/client/sections.js +0 -313
  203. package/dist/web/assets/client/theme.js +0 -71
  204. package/dist/web/assets/shell.js +0 -161
  205. package/dist/web/assets/styles/components.js +0 -169
  206. package/dist/web/assets/styles/views.js +0 -292
@@ -1,418 +0,0 @@
1
- import { AGENT_ADAPTER_CATALOG } from "../../../agent/adapterCatalog.js";
2
- import { AGENT_EXECUTION_COMPONENT_CATALOG } from "../../../agent/executionComponents.js";
3
- export const COMPONENTS_SCRIPT = String.raw `
4
- // Pure builders: data + translator in, DOM out. Views compose these; nothing
5
- // here reads application state or performs a request.
6
- import { h, icon, node } from "/assets/js/dom.js";
7
- import { formatDateTime, relativeTime } from "/assets/js/format.js";
8
- import { renderMarkdown } from "/assets/js/markdown.js";
9
-
10
- // Generated from the server catalogs, not a second product registry.
11
- const adapterLabels = ${JSON.stringify(Object.fromEntries(AGENT_ADAPTER_CATALOG.map(({ id, label }) => [id, label])))};
12
- const componentLabels = ${JSON.stringify(Object.fromEntries(AGENT_EXECUTION_COMPONENT_CATALOG.map(({ id, label }) => [id, label])))};
13
- export function agentLabel(component, adapterId) {
14
- return component ? componentLabels[component] || component : adapterLabels[adapterId] || adapterId;
15
- }
16
-
17
- // --- Vocabulary ----------------------------------------------------------------
18
- // A translated label for a domain value; unknown values stay visible verbatim
19
- // instead of being hidden or guessed.
20
- export function label(t, prefix, value) {
21
- if (value === undefined || value === null || value === "") return "—";
22
- return t(prefix + "." + value, String(value).replace(/[-_]/g, " "));
23
- }
24
-
25
- const TONES = {
26
- task: { draft: "warn", active: "info", completed: "ok", cancelled: "idle", archived: "idle" },
27
- exec: {
28
- "needs-leader-action": "accent", "waiting-on-agents": "info", "waiting-user": "warn",
29
- recovering: "warn", attention: "bad", "progressing-with-attention": "warn", blocked: "bad",
30
- conflicted: "warn", working: "info", completed: "ok", retired: "idle", cancelled: "idle",
31
- accepted: "ok", open: "info", archived: "idle"
32
- },
33
- run: { active: "info", completed: "ok", failed: "bad" },
34
- work: { open: "info", accepted: "ok", retired: "idle" },
35
- review: { pending: "idle", running: "info", completed: "ok", failed: "bad" },
36
- job: { queued: "idle", running: "info", succeeded: "ok", failed: "bad", "timed-out": "bad",
37
- cancelled: "idle", "unknown-needs-attention": "warn" },
38
- session: { active: "ok", waiting: "warn", quiet: "idle", diagnostic: "bad", unknown: "idle",
39
- stopped: "bad", idle: "idle", background: "warn" },
40
- role: { running: "ok", waiting: "warn", idle: "idle", unknown: "idle", failed: "bad", exited: "idle", detached: "idle" },
41
- decision: { active: "ok", superseded: "idle" },
42
- input: { open: "warn", answered: "ok", cancelled: "idle", "auto-resolved": "ok" }
43
- };
44
- export function tone(kind, value) {
45
- return (TONES[kind] && TONES[kind][value]) || "idle";
46
- }
47
-
48
- export function badge(text, toneName, options) {
49
- const element = h("span.badge.tone-" + (toneName || "idle"), null,
50
- options && options.dot ? h("i.badge-dot", { "aria-hidden": "true" }) : null, text);
51
- if (options && options.title) element.title = options.title;
52
- return element;
53
- }
54
-
55
- export function statusBadge(t, kind, prefix, value) {
56
- const element = badge(label(t, prefix, value), tone(kind, value), { dot: true });
57
- element.dataset.status = value;
58
- return element;
59
- }
60
-
61
- export function dot(toneName, title) {
62
- const element = h("span.dot.tone-" + (toneName || "idle"), { "aria-hidden": title ? null : "true" });
63
- if (title) { element.title = title; element.setAttribute("role", "img"); element.setAttribute("aria-label", title); }
64
- return element;
65
- }
66
-
67
- export function chip(text, extraClass) {
68
- return h("span.chip" + (extraClass ? "." + extraClass : ""), null, text);
69
- }
70
-
71
- export function mono(text, extraClass) {
72
- return h("code.id" + (extraClass ? "." + extraClass : ""), null, text);
73
- }
74
-
75
- export function timeTag(iso, locale, t, options) {
76
- if (!iso) return null;
77
- const element = h("time.when", { dateTime: iso }, options && options.absolute
78
- ? formatDateTime(iso, locale) : relativeTime(iso, locale, t));
79
- element.title = formatDateTime(iso, locale);
80
- return element;
81
- }
82
-
83
- // --- Containers -------------------------------------------------------------------
84
- export function card(options) {
85
- const opts = options || {};
86
- const element = h("section.card" + (opts.className ? "." + opts.className.split(" ").join(".") : ""));
87
- if (opts.id) element.id = opts.id;
88
- if (opts.title || opts.actions) {
89
- const head = h("header.card-head", null,
90
- h("h3.card-title", null, opts.icon ? icon(opts.icon) : null, h("span", null, opts.title),
91
- opts.count !== undefined && opts.count !== null ? h("span.count", null, String(opts.count)) : null),
92
- opts.actions ? h("div.card-actions", null, opts.actions) : null);
93
- if (opts.hint) head.append(h("p.card-hint", null, opts.hint));
94
- element.append(head);
95
- }
96
- const body = h("div.card-body");
97
- element.append(body);
98
- element.body = body;
99
- return element;
100
- }
101
-
102
- export function disclosure(title, viewKey, options) {
103
- const opts = options || {};
104
- const element = h("details.disclosure" + (opts.className ? "." + opts.className : ""));
105
- if (viewKey) element.dataset.viewKey = viewKey;
106
- const summary = h("summary", null, icon("chevron", "disclosure-chevron"), h("span.disclosure-title", null, title));
107
- if (opts.meta) summary.append(h("span.disclosure-meta", null, opts.meta));
108
- element.append(summary);
109
- const body = h("div.disclosure-body");
110
- element.append(body);
111
- element.body = body;
112
- return element;
113
- }
114
-
115
- export function sectionTitle(text, count, actions) {
116
- return h("div.section-title", null, h("h2", null, text,
117
- count !== undefined && count !== null ? h("span.count", null, String(count)) : null),
118
- actions ? h("div.section-actions", null, actions) : null);
119
- }
120
-
121
- export function kv(rows) {
122
- const list = h("dl.kv");
123
- rows.forEach(function (row) {
124
- if (!row || row[1] === undefined || row[1] === null || row[1] === "") return;
125
- list.append(h("dt", null, row[0]), h("dd", null, row[1]));
126
- });
127
- return list;
128
- }
129
-
130
- export function emptyState(text, iconName, extra) {
131
- return h("div.empty", null, iconName ? icon(iconName) : null, h("p", null, text), extra || null);
132
- }
133
-
134
- export function note(text, toneName) {
135
- return h("p.note" + (toneName ? ".tone-" + toneName : ""), null, text);
136
- }
137
-
138
- export function button(text, options) {
139
- const opts = options || {};
140
- const element = h("button.btn" + (opts.variant ? ".btn-" + opts.variant : ""), {
141
- type: opts.type || "button", onclick: opts.onClick, disabled: !!opts.disabled, title: opts.title
142
- }, opts.icon ? icon(opts.icon) : null, text ? h("span", null, text) : null);
143
- if (opts.dataset) Object.assign(element.dataset, opts.dataset);
144
- return element;
145
- }
146
-
147
- // --- Rich text ---------------------------------------------------------------------
148
- function shouldCollapse(text, threshold) {
149
- const value = String(text);
150
- if (value.length > (threshold || 700)) return true;
151
- let lines = 0;
152
- for (let index = 0; index < value.length; index += 1) if (value[index] === "\n") lines += 1;
153
- return lines > 12;
154
- }
155
-
156
- export function richText(title, text, t, options) {
157
- if (!text) return null;
158
- const opts = options || {};
159
- const block = h("div.prose-block" + (opts.className ? "." + opts.className : ""));
160
- if (title) block.append(h("h4.prose-label", null, title));
161
- const body = h("div.md" + (opts.muted ? ".muted" : ""));
162
- body.innerHTML = renderMarkdown(text);
163
- block.append(body);
164
- if (shouldCollapse(text, opts.threshold)) {
165
- block.classList.add("is-collapsed");
166
- const toggle = h("button.link-btn", { type: "button" }, t("actions.showMore"));
167
- toggle.addEventListener("click", function () {
168
- const collapsed = block.classList.toggle("is-collapsed");
169
- toggle.textContent = t(collapsed ? "actions.showMore" : "actions.showLess");
170
- });
171
- block.append(toggle);
172
- }
173
- return block;
174
- }
175
-
176
- export function bulletList(items, className) {
177
- const list = (items || []).filter(Boolean);
178
- if (!list.length) return null;
179
- return h("ul.bullets" + (className ? "." + className : ""), null, list.map(function (item) { return h("li", null, item); }));
180
- }
181
-
182
- // First page of a long list plus an in-place "show more".
183
- export function pagedList(container, items, pageSize, renderItem, t) {
184
- let shown = 0;
185
- let more = null;
186
- function renderChunk() {
187
- items.slice(shown, shown + pageSize).forEach(function (item) { container.insertBefore(renderItem(item), more); });
188
- shown = Math.min(items.length, shown + pageSize);
189
- if (!more) return;
190
- const remaining = items.length - shown;
191
- if (remaining <= 0) { more.remove(); more = null; }
192
- else more.textContent = t("actions.showRemaining").replace("{count}", String(remaining));
193
- }
194
- if (items.length > pageSize) {
195
- more = h("button.show-more", { type: "button", onclick: renderChunk });
196
- container.append(more);
197
- }
198
- renderChunk();
199
- }
200
-
201
- // --- Metrics (DOM built with node() only; executed by the usage test) -------------
202
- export function metricTile(labelText, value, options) {
203
- const variant = options && options.tone ? " tone-" + options.tone : "";
204
- const tile = node("div", "metric" + variant);
205
- tile.append(node("span", "metric-label", labelText), node("strong", "metric-value", String(value)));
206
- return tile;
207
- }
208
-
209
- export function usageMetricText(metric, t, suffix) {
210
- if (!metric || metric.value == null) return t("detail.unobserved");
211
- return metric.value + (suffix || "") + (metric.status === "partial" ? " · " + t("detail.partial") : "");
212
- }
213
-
214
- function usageTile(labelText, metric, t, suffix) {
215
- const tile = metricTile(labelText, usageMetricText(metric, t, suffix));
216
- if (metric && metric.reasons && metric.reasons.length) {
217
- tile.append(node("small", "metric-note", metric.reasons.map(function (reason) {
218
- return t("usage.reason." + reason);
219
- }).join("; ")));
220
- }
221
- return tile;
222
- }
223
-
224
- export function observabilityMetricCard(observability, t) {
225
- if (!observability) return null;
226
- const wrap = node("div", "usage");
227
- const grid = node("div", "metric-grid");
228
- const cost = observability.cost || {};
229
- const context = observability.context || {};
230
- grid.append(usageTile(t("usage.tokens"), cost.tokens, t));
231
- grid.append(usageTile(t("usage.toolCalls"), cost.toolCalls, t));
232
- grid.append(usageTile(t("usage.elapsed"), cost.elapsedSeconds, t, "s"));
233
- grid.append(usageTile(t("usage.executionSum"), cost.executionSeconds, t, "s"));
234
- grid.append(metricTile(t("usage.ready"), ((observability.dag && observability.dag.readyIds) || []).length));
235
- grid.append(metricTile(t("usage.contextSnapshots"), context.snapshotCount == null ? t("detail.unobserved") : context.snapshotCount));
236
- wrap.append(grid);
237
- const meta = node("p", "usage-meta");
238
- meta.append(node("span", "", t("usage.scope")));
239
- meta.append(node("span", "", t("usage.observedThrough") + " "
240
- + (cost.observedThrough ? formatDateTime(cost.observedThrough) : t("detail.unobserved"))));
241
- meta.append(node("span", "", t("usage.contextBytes") + " "
242
- + (context.totalBytes == null ? t("detail.partial") : context.totalBytes + " B")));
243
- wrap.append(meta);
244
- return wrap;
245
- }
246
-
247
- // --- Agent identity ------------------------------------------------------------------
248
- export function agentChips(agent) {
249
- if (!agent) return null;
250
- const chips = [];
251
- if (agent.adapterId || agent.component) chips.push(chip(agentLabel(agent.component, agent.adapterId), "chip-strong"));
252
- if (agent.model) chips.push(chip(agent.model));
253
- if (agent.effort) chips.push(chip(agent.effort));
254
- return chips.length ? h("span.chip-row", null, chips) : null;
255
- }
256
-
257
- // --- Input requests ----------------------------------------------------------------
258
- export function inputCard(input, t, locale, onAnswer) {
259
- const policy = input.policy && input.policy.kind;
260
- const element = h("article.input-card");
261
- element.append(h("div.input-head", null,
262
- h("span.input-kicker", null, icon("inbox", "icon-sm"), t("input.kicker")),
263
- policy ? badge(label(t, "input", policy), policy === "required" ? "bad" : "warn") : null,
264
- input.policy && input.policy.timeoutAt
265
- ? h("span.input-timeout", null, icon("clock", "icon-sm"),
266
- t("input.timeoutAt") + " " + relativeTime(input.policy.timeoutAt, locale, t)) : null,
267
- timeTag(input.createdAt, locale, t)));
268
- element.append(h("p.input-question", null, input.question));
269
- const facts = [];
270
- if (input.requester) facts.push(t("input.from") + " " + input.requester.roleName
271
- + " · " + (input.requester.runId || input.requester.nativeSessionId || ""));
272
- if (input.blockedRefs && input.blockedRefs.length) facts.push(t("input.blocks") + " "
273
- + input.blockedRefs.map(function (ref) { return ref.type + " " + ref.id; }).join(", "));
274
- if (facts.length) element.append(h("p.input-facts", null, facts.join(" · ")));
275
- const recommended = input.policy && input.policy.recommendedChoiceKey;
276
- if (input.choices && input.choices.length) {
277
- element.append(h("div.input-choices", null, input.choices.map(function (choice) {
278
- return h("button.choice" + (choice.key === recommended ? ".is-recommended" : ""), {
279
- type: "button",
280
- onclick: function (event) { onAnswer(input, { choiceKey: choice.key }, event.currentTarget); }
281
- }, h("span", null, choice.label), choice.key === recommended ? badge(t("input.recommended"), "accent") : null);
282
- })));
283
- } else {
284
- const field = h("input", { type: "text", required: true, placeholder: t("input.freeText"), maxLength: 8000 });
285
- const form = h("form.input-form", null, field,
286
- h("button.btn.btn-primary", { type: "submit" }, icon("send"), h("span", null, t("actions.answer"))));
287
- form.addEventListener("input", function () { form.dataset.unsent = field.value ? "true" : "false"; });
288
- form.addEventListener("submit", function (event) {
289
- event.preventDefault();
290
- const text = field.value.trim();
291
- if (text) onAnswer(input, { text: text }, form.querySelector("button"));
292
- });
293
- element.append(form);
294
- }
295
- return element;
296
- }
297
-
298
- // --- Records -----------------------------------------------------------------------
299
- export function workItemCard(item, t, locale, titles) {
300
- const settled = item.status !== "open";
301
- const element = h(settled ? "details.work-card.is-settled" : "article.work-card");
302
- element.dataset.viewKey = "work:" + item.id;
303
- const head = h(settled ? "summary.work-head" : "header.work-head", null,
304
- settled ? icon("chevron", "disclosure-chevron") : null,
305
- dot(tone("work", item.status)),
306
- h("span.work-title", null, item.title),
307
- statusBadge(t, "work", "work", item.status));
308
- element.append(head);
309
- const body = h("div.work-body");
310
- body.append(h("div.meta-line", null,
311
- item.assignee ? h("span.meta-strong", null, icon("user", "icon-sm"), item.assignee) : null,
312
- mono(item.id), timeTag(item.updatedAt, locale, t)));
313
- if (item.objective && item.objective !== item.title) body.append(richText(t("work.objective"), item.objective, t));
314
- if (item.acceptance && item.acceptance.length) {
315
- body.append(h("div.prose-block", null, h("h4.prose-label", null, t("work.acceptance")),
316
- h("ul.checklist", null, item.acceptance.map(function (entry) {
317
- return h("li" + (item.status === "accepted" ? ".is-done" : ""), null, icon(item.status === "accepted" ? "check" : "target", "icon-sm"), h("span", null, entry));
318
- }))));
319
- }
320
- const deps = (item.dependsOn || []).map(function (id) { return (titles && titles[id]) || id; });
321
- if (deps.length) body.append(h("div.meta-line", null, h("span.meta-label", null, t("work.dependsOn")), deps.map(function (d) { return chip(d); })));
322
- if (item.writeProjectIds && item.writeProjectIds.length) {
323
- body.append(h("div.meta-line", null, h("span.meta-label", null, t("work.writeProjects")), item.writeProjectIds.map(function (d) { return chip(d); })));
324
- }
325
- if (item.candidates && item.candidates.length) {
326
- body.append(h("div.prose-block", null, h("h4.prose-label", null, t("work.candidates")),
327
- h("ol.candidates", null, item.candidates.slice().sort(function (a, b) { return b.sequence - a.sequence; }).map(function (candidate) {
328
- return h("li", null, h("span.candidate-seq", null, "#" + candidate.sequence), h("span", null, candidate.summary),
329
- h("span.faint", null, candidate.source && candidate.source.type === "run" ? candidate.source.runId : t("work.direct")),
330
- timeTag(candidate.createdAt, locale, t));
331
- }))));
332
- }
333
- if (item.disposition) {
334
- body.append(note(t("work.disposition") + ": " + item.disposition.summary
335
- + (item.disposition.replacementWorkItemId ? " → " + item.disposition.replacementWorkItemId : "")));
336
- }
337
- if (item.outcome) body.append(richText(t("work.outcome"), item.outcome, t, { className: "callout" }));
338
- element.append(body);
339
- return element;
340
- }
341
-
342
- export function runCard(run, t, locale) {
343
- const element = h("article.run-card");
344
- element.dataset.status = run.status;
345
- const input = run.inputs && run.inputs.length ? run.inputs[0].input : null;
346
- element.append(h("header.run-head", null,
347
- dot(tone("run", run.status)),
348
- h("span.run-role", null, run.roleName),
349
- mono(run.id),
350
- run.purpose ? chip(label(t, "run.purpose", run.purpose)) : null,
351
- run.workItemId ? chip(run.workItemId) : null,
352
- h("span.spacer"),
353
- statusBadge(t, "run", "run", run.status)));
354
- element.append(h("div.meta-line", null,
355
- h("span", null, t("run.delivery") + ": " + label(t, "run.delivery", (run.execution && run.execution.delivery) || "unobserved")),
356
- run.mode ? h("span", null, label(t, "mode", run.mode)) : null,
357
- timeTag((run.result && run.result.completedAt) || run.updatedAt, locale, t),
358
- agentChips(run.effective || (run.agentId ? run : null))));
359
- const directive = input && (input.directive || input.action);
360
- if (directive) element.append(richText(t("run.instruction"), directive, t, { threshold: 320 }));
361
- if (run.result && run.result.output) element.append(richText(t("run.output"), run.result.output, t, { threshold: 320, className: "callout" }));
362
- if (run.result && run.result.diagnostic) element.append(richText(t("run.failure"), run.result.diagnostic, t, { threshold: 320, className: "callout.tone-bad" }));
363
- if (run.executionGroupId) {
364
- element.append(h("p.faint.mono-line", null, t("run.lineage") + " " + run.executionGroupId + (run.executionLaneId ? "/" + run.executionLaneId : "")));
365
- }
366
- return element;
367
- }
368
-
369
- export function reviewCard(round, t, locale) {
370
- const element = h("article.review-card");
371
- element.append(h("header.run-head", null,
372
- dot(tone("review", round.status)),
373
- h("span.run-role", null, round.reviewerRoleName || t("review.reviewer")),
374
- mono(round.id),
375
- round.scope ? chip(label(t, "review.scope", round.scope)) : null,
376
- h("span.spacer"),
377
- statusBadge(t, "review", "review", round.status)));
378
- element.append(h("div.meta-line", null,
379
- round.workItemId ? mono(round.workItemId + (round.candidateId ? " · " + round.candidateId : "")) : null,
380
- round.reviewBaseCommit ? h("span", null, t("review.base") + " ", mono(String(round.reviewBaseCommit).slice(0, 12))) : null,
381
- round.reviewerRunId ? h("span", null, t("review.run") + " ", mono(round.reviewerRunId)) : null,
382
- timeTag(round.createdAt, locale, t)));
383
- if (round.failure) element.append(note(round.failure.kind + ": " + round.failure.message, "bad"));
384
- return element;
385
- }
386
-
387
- export function roleCard(role, t, locale, options) {
388
- const opts = options || {};
389
- const session = opts.runtimeRole && opts.runtimeRole.runtimeSession;
390
- const element = h("article.role-card");
391
- const binding = role.agentBindings && role.agentBindings[role.activeAgentId];
392
- element.append(h("header.role-head", null,
393
- h("span.avatar", { "aria-hidden": "true" }, String(role.name || "?").slice(0, 1).toUpperCase()),
394
- h("div.role-title", null, h("strong", null, role.name),
395
- h("span.faint", null, role.activeAgentId || "")),
396
- opts.status ? statusBadge(t, "role", "role", opts.status) : null));
397
- if (binding) element.append(agentChips({
398
- adapterId: binding.adapterId, component: binding.component,
399
- model: binding.config && binding.config.model, effort: binding.config && binding.config.effort
400
- }));
401
- if (role.description) element.append(richText(null, role.description, t, { muted: true, threshold: 280 }));
402
- const rows = [];
403
- rows.push([t("role.session"), session && session.nativeSessionId ? mono(session.nativeSessionId) : t("role.noSession")]);
404
- if (role.launchRevision !== undefined) rows.push([t("role.desired"), "r" + role.launchRevision + (opts.launchDrift ? " · " + t("role.drift") : "")]);
405
- if (role.defaultAccess !== undefined) rows.push([t("role.access"), role.defaultAccess]);
406
- if (opts.retry) rows.push([t("role.providerRetry"), label(t, "retry", opts.retry.status) + " · "
407
- + opts.retry.attempts + "/" + opts.retry.limit
408
- + (opts.retry.status === "waiting" && opts.retry.nextEligibleAt ? " · " + formatDateTime(opts.retry.nextEligibleAt, locale) : "")]);
409
- if (role.skills && role.skills.length) rows.push([t("role.skills"), h("span.chip-row", null, role.skills.map(function (s) { return chip(s); }))]);
410
- element.append(kv(rows));
411
- if (opts.onOpen) {
412
- element.append(h("div.role-actions", null, button(t("role.openSession"), {
413
- icon: "terminal", variant: "ghost", onClick: function () { opts.onOpen(role.name); }
414
- })));
415
- }
416
- return element;
417
- }
418
- `;