@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.
- package/README.md +19 -3
- package/dist/artifacts/artifactCapability.js +39 -10
- package/dist/artifacts/imageMetadata.js +120 -0
- package/dist/artifacts/managedGit.js +7 -4
- package/dist/artifacts/taskArtifactRepository.js +6 -0
- package/dist/cli/commandCatalog.js +25 -11
- package/dist/cli/interactionPolicy.js +4 -0
- package/dist/cli/invocationAuthority.js +1 -1
- package/dist/commands/executionAuditCommands.js +5 -0
- package/dist/commands/globalRoleCommands.js +41 -3
- package/dist/commands/projectCommands.js +89 -94
- package/dist/commands/roleSkillValidation.js +4 -8
- package/dist/commands/taskCommands.js +30 -9
- package/dist/commands/taskIntegrationCommands.js +5 -16
- package/dist/commands/taskUsageCommand.js +38 -0
- package/dist/context/roleSessionContext.js +18 -2
- package/dist/context/runContextPack.js +5 -1
- package/dist/context/sessionBootstrapManifest.js +10 -1
- package/dist/context/skillCatalog.js +108 -0
- package/dist/context/skillPackage.js +161 -0
- package/dist/context/taskContext.js +3 -2
- package/dist/context/taskSearch.js +127 -0
- package/dist/controlPlaneCli.js +51 -39
- package/dist/controller/clientRuntime.js +3 -2
- package/dist/controller/fileSchedulerStoreAdapter.js +32 -6
- package/dist/controller/jobControl.js +2 -0
- package/dist/controller/nativeHostInput.js +37 -0
- package/dist/controller/runtime.js +93 -2
- package/dist/controller/runtimeEventInbox.js +2 -2
- package/dist/controller/runtimeEventProcessor.js +3 -3
- package/dist/doctor/doctor.js +10 -0
- package/dist/execution/reviewMainRun.js +1 -0
- package/dist/execution/workItemMainRun.js +1 -0
- package/dist/executor/codexConfigConflict.js +6 -4
- package/dist/executor/effectiveLaunch.js +24 -1
- package/dist/executor/fileRoleLaunchPlanner.js +13 -5
- package/dist/integration/gitIntegrationService.js +15 -79
- package/dist/integration/integrationSourceApplication.js +4 -2
- package/dist/job/httpPreview.js +61 -0
- package/dist/job/jobCleanupInspection.js +67 -0
- package/dist/job/jobRunner.js +12 -2
- package/dist/kernel/builtinCapabilities.js +3 -1
- package/dist/message/message.js +15 -1
- package/dist/output/rolePresentation.js +4 -1
- package/dist/repository/executionLaneGitSnapshot.js +2 -1
- package/dist/repository/gitCompatibility.js +62 -0
- package/dist/repository/gitWorkspace.js +86 -80
- package/dist/repository/gitWorktreeInventory.js +121 -0
- package/dist/repository/project.js +74 -25
- package/dist/repository/taskWorkspaceCoordinator.js +72 -145
- package/dist/repository/taskWorkspacePreparer.js +39 -43
- package/dist/repository/workspaceCleanupInspection.js +88 -7
- package/dist/resources/resourceDiscovery.js +2 -2
- package/dist/resources/resourceGc.js +7 -4
- package/dist/resources/resourceRegistrar.js +18 -11
- package/dist/runtime/agentEndpoint.js +8 -0
- package/dist/runtime/agentHost.js +170 -3
- package/dist/runtime/codexAppServerRuntime.js +1 -1
- package/dist/runtime/codexNativeAccess.js +175 -0
- package/dist/runtime/controlledCodexTui.js +116 -0
- package/dist/runtime/integrationRuntimeIsolation.js +21 -0
- package/dist/runtime/publicReply.js +23 -0
- package/dist/runtime/runtimeObservation.js +48 -0
- package/dist/runtime/structuredProviderHost.js +16 -7
- package/dist/runtime/taskCostMetrics.js +133 -0
- package/dist/runtime/taskRuntimeIsolation.js +91 -21
- package/dist/runtime/taskUsageMetrics.js +11 -2
- package/dist/runtime/taskUsageQuery.js +38 -0
- package/dist/scheduler/taskExecutionProjection.js +2 -0
- package/dist/scheduler/taskObservabilityProjection.js +9 -1
- package/dist/storage/homeLayout.js +13 -0
- package/dist/storage/sqliteSchema.js +44 -0
- package/dist/storage/sqliteStore.js +53 -0
- package/dist/storage/storageVersions.js +1 -1
- package/dist/storage/storeRpc.js +2 -0
- package/dist/storage/taskSearch.js +35 -0
- package/dist/storage/upgrade/projectKnowledgeMigration.js +52 -0
- package/dist/task/archiveDiagnostics.js +26 -8
- package/dist/task/archivePreflight.js +26 -9
- package/dist/task/leaderArchive.js +9 -15
- package/dist/task/ordinaryArchive.js +42 -0
- package/dist/tmux/tmuxManager.js +8 -8
- package/dist/web/assets/assetManifest.js +11 -51
- package/dist/web/assets/client/app/catalog.js +215 -0
- package/dist/web/assets/client/app/main.js +148 -0
- package/dist/web/assets/client/app/selection.js +139 -0
- package/dist/web/assets/client/app/settings.js +326 -0
- package/dist/web/assets/client/app/taskView.js +280 -0
- package/dist/web/assets/client/domain/context.js +96 -0
- package/dist/web/assets/client/domain/records.js +126 -0
- package/dist/web/assets/client/domain/runs.js +119 -0
- package/dist/web/assets/client/domain/taskForms.js +197 -0
- package/dist/web/assets/client/domain/vocab.js +69 -0
- package/dist/web/assets/client/domain/work.js +116 -0
- package/dist/web/assets/client/i18n/en.js +900 -0
- package/dist/web/assets/client/i18n/zh-CN.js +898 -0
- package/dist/web/assets/client/index.js +114 -0
- package/dist/web/assets/client/layout/resizer.js +37 -0
- package/dist/web/assets/client/layout/router.js +35 -0
- package/dist/web/assets/client/layout/shortcuts.js +45 -0
- package/dist/web/assets/client/layout/sizing.js +95 -0
- package/dist/web/assets/client/layout/workspace.js +247 -0
- package/dist/web/assets/client/{api.js → lib/api.js} +28 -4
- package/dist/web/assets/client/{dom.js → lib/dom.js} +24 -12
- package/dist/web/assets/client/{format.js → lib/format.js} +7 -0
- package/dist/web/assets/client/lib/i18n.js +54 -0
- package/dist/web/assets/client/lib/markdown.js +167 -0
- package/dist/web/assets/client/lib/prefs.js +28 -0
- package/dist/web/assets/client/lib/theme.js +68 -0
- package/dist/web/assets/client/ui/containers.js +101 -0
- package/dist/web/assets/client/ui/controls.js +51 -0
- package/dist/web/assets/client/ui/forms.js +48 -0
- package/dist/web/assets/client/ui/metrics.js +137 -0
- package/dist/web/assets/client/ui/primitives.js +92 -0
- package/dist/web/assets/client/ui/text.js +33 -0
- package/dist/web/assets/client/ui/toast.js +12 -0
- package/dist/web/assets/client/views/bodySearch.js +172 -0
- package/dist/web/assets/client/views/createTask.js +85 -0
- package/dist/web/assets/client/views/dock/conversation.js +612 -0
- package/dist/web/assets/client/views/dock/discussion.js +173 -0
- package/dist/web/assets/client/views/dock/preview.js +129 -0
- package/dist/web/assets/client/views/dock/terminal.js +199 -0
- package/dist/web/assets/client/views/globalInput.js +67 -0
- package/dist/web/assets/client/{overview.js → views/overview.js} +62 -56
- package/dist/web/assets/client/{sidebar.js → views/sidebar.js} +56 -62
- package/dist/web/assets/client/views/skills.js +152 -0
- package/dist/web/assets/client/views/task/actions.js +36 -0
- package/dist/web/assets/client/views/task/delivery.js +185 -0
- package/dist/web/assets/client/views/task/deliveryResults.js +159 -0
- package/dist/web/assets/client/views/task/files.js +272 -0
- package/dist/web/assets/client/views/task/observation.js +153 -0
- package/dist/web/assets/client/views/task/overview.js +161 -0
- package/dist/web/assets/client/views/task/page.js +131 -0
- package/dist/web/assets/client/views/task/records.js +163 -0
- package/dist/web/assets/client/views/task/runtime.js +130 -0
- package/dist/web/assets/client/views/task/timeline.js +190 -0
- package/dist/web/assets/shared/geometry.js +19 -0
- package/dist/web/assets/{icons.js → shared/icons.js} +4 -0
- package/dist/web/assets/shared/taskTabs.js +8 -0
- package/dist/web/assets/shared/themes.js +93 -0
- package/dist/web/assets/shell/dialogs.js +63 -0
- package/dist/web/assets/shell/dock.js +40 -0
- package/dist/web/assets/shell/index.js +40 -0
- package/dist/web/assets/shell/settings.js +34 -0
- package/dist/web/assets/shell/sidebar.js +45 -0
- package/dist/web/assets/styles/index.js +41 -0
- package/dist/web/assets/styles/{responsive.js → layout/responsive.js} +15 -13
- package/dist/web/assets/styles/{layout.js → layout/workspace.js} +17 -24
- package/dist/web/assets/styles/markdown.js +22 -3
- package/dist/web/assets/styles/tokens.js +10 -63
- package/dist/web/assets/styles/ui/controls.js +76 -0
- package/dist/web/assets/styles/ui/forms.js +46 -0
- package/dist/web/assets/styles/ui/surfaces.js +122 -0
- package/dist/web/assets/styles/views/delivery.js +29 -0
- package/dist/web/assets/styles/views/dock.js +71 -0
- package/dist/web/assets/styles/views/page.js +32 -0
- package/dist/web/assets/styles/views/records.js +70 -0
- package/dist/web/assets/styles/views/settings.js +26 -0
- package/dist/web/assets/styles/views/sidebar.js +74 -0
- package/dist/web/assets/styles/views/task.js +80 -0
- package/dist/web/assets/styles/views/terminal.js +38 -0
- package/dist/web/taskPreviews.js +205 -0
- package/dist/web/tmuxWebTerminal.js +16 -9
- package/dist/web/webConversation.js +373 -0
- package/dist/web/webMaterials.js +155 -0
- package/dist/web/webServer.js +306 -18
- package/dist/web/webSettings.js +331 -0
- package/dist/web/webSkills.js +86 -0
- package/dist/web/webSnapshot.js +40 -8
- package/dist/web/webTaskSurface.js +114 -9
- package/dist/workspace/gitChangeSetCapture.js +3 -1
- package/docs/managed-turn-and-session-runtime.md +9 -0
- package/docs/managed-turn-and-session-runtime.zh-CN.md +7 -0
- package/docs/observability/README.md +13 -3
- package/docs/observability/README.zh-CN.md +10 -3
- package/docs/release-workflow.md +53 -0
- package/docs/release-workflow.zh-CN.md +40 -0
- package/docs/storage-baseline.md +38 -1
- package/docs/storage-baseline.zh-CN.md +22 -0
- package/docs/task-delivery.md +36 -8
- package/docs/task-delivery.zh-CN.md +24 -7
- package/docs/task-discovery.md +28 -0
- package/docs/testing/verification-levels.md +2 -2
- package/i18n/README.zh-CN.md +4 -3
- package/package.json +1 -1
- package/skills/yui-leader/references/execution.md +2 -1
- package/skills/yui-leader/references/integration.md +20 -0
- package/skills/yui-operator/SKILL.md +4 -0
- package/skills/yui-reviewer/SKILL.md +3 -0
- package/skills/yui-runtime/SKILL.md +4 -0
- package/skills/yui-runtime/references/publication.md +20 -4
- package/skills/yui-worker/SKILL.md +3 -0
- package/dist/web/assets/client/app.js +0 -804
- package/dist/web/assets/client/components.js +0 -418
- package/dist/web/assets/client/detail.js +0 -333
- package/dist/web/assets/client/dock.js +0 -225
- package/dist/web/assets/client/evidence.js +0 -172
- package/dist/web/assets/client/forms.js +0 -230
- package/dist/web/assets/client/i18n.js +0 -1161
- package/dist/web/assets/client/markdown.js +0 -114
- package/dist/web/assets/client/records.js +0 -63
- package/dist/web/assets/client/sections.js +0 -313
- package/dist/web/assets/client/theme.js +0 -71
- package/dist/web/assets/shell.js +0 -161
- package/dist/web/assets/styles/components.js +0 -169
- package/dist/web/assets/styles/views.js +0 -292
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
export const DETAIL_SCRIPT = String.raw `
|
|
2
|
-
// Task detail: header, section tabs and the Overview section. The runtime
|
|
3
|
-
// observation arrives separately from the Context snapshot, so every fact it
|
|
4
|
-
// feeds lives in a [data-slot] that updateObservation() can redraw in place.
|
|
5
|
-
import { h, icon, clear } from "/assets/js/dom.js";
|
|
6
|
-
import { formatDateTime, formatClock, relativeTime } from "/assets/js/format.js";
|
|
7
|
-
import {
|
|
8
|
-
badge, statusBadge, label, tone, card, disclosure, richText, bulletList, emptyState,
|
|
9
|
-
note, button, chip, mono, inputCard, kv, dot, timeTag
|
|
10
|
-
} from "/assets/js/components.js";
|
|
11
|
-
import { entriesOf, valuesOf, recordCard } from "/assets/js/records.js";
|
|
12
|
-
import { renderWork, renderExecution, renderHistory, renderDetails } from "/assets/js/sections.js";
|
|
13
|
-
|
|
14
|
-
export const TABS = ["overview", "work", "execution", "history", "details"];
|
|
15
|
-
const TAB_ICONS = { overview: "target", work: "layers", execution: "pulse", history: "history", details: "dots" };
|
|
16
|
-
const SESSION_GROUPS = ["active", "waiting", "background", "quiet", "diagnostic", "stopped", "unknown", "idle"];
|
|
17
|
-
|
|
18
|
-
export function renderTaskDetail(container, data, t, locale, ctx) {
|
|
19
|
-
clear(container);
|
|
20
|
-
const task = data.task;
|
|
21
|
-
const core = data.core;
|
|
22
|
-
container.dataset.taskId = task.id;
|
|
23
|
-
const page = h("div.page.task-page");
|
|
24
|
-
|
|
25
|
-
// --- Header ----------------------------------------------------------------
|
|
26
|
-
const bar = h("div.task-bar", null,
|
|
27
|
-
h("button.icon-btn.back-btn", { type: "button", "aria-label": t("actions.back"), title: t("actions.back"), onclick: ctx.onBack }, icon("back")),
|
|
28
|
-
h("nav.crumbs", { "aria-label": t("crumbs.label") },
|
|
29
|
-
h("button.crumb", { type: "button", onclick: ctx.onBack }, t("crumbs.tasks")),
|
|
30
|
-
h("span.crumb-sep", { "aria-hidden": "true" }, "/"),
|
|
31
|
-
h("code.crumb-current", null, task.id)),
|
|
32
|
-
h("span.spacer"),
|
|
33
|
-
h("button.btn.btn-ghost.dock-toggle", {
|
|
34
|
-
type: "button", dataset: { dockToggle: "discussion" }, title: t("dock.discussion") + " · D",
|
|
35
|
-
onclick: function () { ctx.showDock("discussion"); }
|
|
36
|
-
}, icon("chat"), h("span", null, t("dock.discussion"))),
|
|
37
|
-
h("button.btn.btn-ghost.dock-toggle", {
|
|
38
|
-
type: "button", dataset: { dockToggle: "session" }, title: t("dock.session"),
|
|
39
|
-
onclick: function () { ctx.showDock("session"); }
|
|
40
|
-
}, icon("terminal"), h("span", null, t("dock.session"))));
|
|
41
|
-
|
|
42
|
-
const meta = h("div.task-meta", null,
|
|
43
|
-
statusBadge(t, "task", "status", task.status),
|
|
44
|
-
h("span", { dataset: { slot: "exec-badge" } }),
|
|
45
|
-
task.priority ? badge(label(t, "priority", task.priority), task.priority === "urgent" || task.priority === "high" ? "accent" : "idle") : null,
|
|
46
|
-
(task.tags || []).map(function (tag) { return chip("#" + tag); }),
|
|
47
|
-
h("span.meta-item", null, icon("clock", "icon-sm"), t("task.updated") + " ", timeTag(task.updatedAt, locale, t)),
|
|
48
|
-
(task.projectBindings || []).length ? h("span.meta-item", null, icon("layers", "icon-sm"),
|
|
49
|
-
task.projectBindings.map(function (binding) { return binding.projectId; }).join(", ")) : null);
|
|
50
|
-
|
|
51
|
-
const counts = {
|
|
52
|
-
work: entriesOf(core, "work-item").length,
|
|
53
|
-
execution: entriesOf(core, "run").length,
|
|
54
|
-
history: entriesOf(core, "task-decision").length + entriesOf(core, "task-milestone").length + entriesOf(core, "task-message").length
|
|
55
|
-
};
|
|
56
|
-
const tabs = h("nav.tabs", { role: "tablist", "aria-label": t("tabs.label") }, TABS.map(function (tab, index) {
|
|
57
|
-
return h("button.tab", {
|
|
58
|
-
type: "button", role: "tab", id: "tab-" + tab,
|
|
59
|
-
"aria-controls": "panel-" + tab,
|
|
60
|
-
"aria-selected": String(ctx.activeTab === tab),
|
|
61
|
-
tabIndex: ctx.activeTab === tab ? 0 : -1,
|
|
62
|
-
title: t("tabs." + tab) + " · " + (index + 1),
|
|
63
|
-
dataset: { tab: tab },
|
|
64
|
-
onclick: function () { ctx.onTab(tab); }
|
|
65
|
-
}, icon(TAB_ICONS[tab], "icon-sm"), h("span", null, t("tabs." + tab)),
|
|
66
|
-
counts[tab] ? h("span.count", null, String(counts[tab])) : null);
|
|
67
|
-
}));
|
|
68
|
-
tabs.addEventListener("keydown", function (event) {
|
|
69
|
-
if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
|
|
70
|
-
event.preventDefault();
|
|
71
|
-
const selected = tabs.querySelector('[aria-selected="true"]');
|
|
72
|
-
const index = TABS.indexOf(selected.dataset.tab);
|
|
73
|
-
const next = TABS[(index + (event.key === "ArrowRight" ? 1 : TABS.length - 1)) % TABS.length];
|
|
74
|
-
ctx.onTab(next);
|
|
75
|
-
const button = tabs.querySelector('[data-tab="' + next + '"]');
|
|
76
|
-
if (button) button.focus();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
page.append(h("header.task-header", null, bar),
|
|
80
|
-
h("div.task-hero", null, h("h1.task-title", null, task.title), meta),
|
|
81
|
-
h("div.tabs-wrap", null, tabs));
|
|
82
|
-
|
|
83
|
-
// --- Panels ------------------------------------------------------------------
|
|
84
|
-
const panels = {};
|
|
85
|
-
TABS.forEach(function (tab) {
|
|
86
|
-
panels[tab] = h("section.tab-panel", { id: "panel-" + tab, role: "tabpanel", "aria-labelledby": "tab-" + tab, hidden: ctx.activeTab !== tab });
|
|
87
|
-
page.append(panels[tab]);
|
|
88
|
-
});
|
|
89
|
-
renderOverviewPanel(panels.overview, data, t, locale, ctx);
|
|
90
|
-
renderWork(panels.work, data, t, locale, ctx);
|
|
91
|
-
renderExecution(panels.execution, data, t, locale, ctx);
|
|
92
|
-
renderHistory(panels.history, data, t, locale, ctx);
|
|
93
|
-
renderDetails(panels.details, data, t, locale, ctx);
|
|
94
|
-
container.append(page);
|
|
95
|
-
updateObservation(container, data, t, locale, ctx);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function selectTab(container, tab) {
|
|
99
|
-
container.querySelectorAll(".tab").forEach(function (button) {
|
|
100
|
-
const active = button.dataset.tab === tab;
|
|
101
|
-
button.setAttribute("aria-selected", String(active));
|
|
102
|
-
button.tabIndex = active ? 0 : -1;
|
|
103
|
-
});
|
|
104
|
-
container.querySelectorAll(".tab-panel").forEach(function (panel) { panel.hidden = panel.id !== "panel-" + tab; });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function renderOverviewPanel(panel, data, t, locale, ctx) {
|
|
108
|
-
const task = data.task;
|
|
109
|
-
const core = data.core;
|
|
110
|
-
// Now: the derived execution status (observation) plus the open questions.
|
|
111
|
-
const now = card({ className: "now-card" });
|
|
112
|
-
now.body.append(h("div", { dataset: { slot: "now" } }));
|
|
113
|
-
panel.append(now);
|
|
114
|
-
|
|
115
|
-
// Needs you: open InputRequests with their answer controls.
|
|
116
|
-
const inputs = entriesOf(core, "input-request").filter(function (entry) { return !entry.omitted && entry.value.status === "open"; });
|
|
117
|
-
const missing = core.attention.openInputs.refs.filter(function (ref) {
|
|
118
|
-
return !inputs.some(function (entry) { return entry.ref.refId === ref.refId; });
|
|
119
|
-
});
|
|
120
|
-
const inputCount = core.attention.openInputs.count;
|
|
121
|
-
if (inputCount) {
|
|
122
|
-
const needs = card({ title: t("overview.needsYou"), icon: "inbox", count: inputCount, className: "needs-card" });
|
|
123
|
-
needs.id = "detail-attention";
|
|
124
|
-
inputs.forEach(function (entry) { needs.body.append(inputCard(entry.value, t, locale, ctx.answerInput)); });
|
|
125
|
-
missing.forEach(function (ref) { needs.body.append(recordCard({ ref: ref, omitted: true }, task.id, t, ctx)); });
|
|
126
|
-
if (inputCount > inputs.length + missing.length) {
|
|
127
|
-
needs.body.append(note(t("overview.moreInputs"), "warn"), h("pre.code-block", null, "yui task input list " + task.id));
|
|
128
|
-
}
|
|
129
|
-
panel.append(needs);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Independent column stacks, not paired rows: a long progress card must not
|
|
133
|
-
// push the next row down and leave a gap under the shorter Session card.
|
|
134
|
-
// Main column: what the Task is and where it stands. Rail: live and decided facts.
|
|
135
|
-
const sessions = card({ title: t("sessions.title"), icon: "terminal", hint: t("sessions.hint") });
|
|
136
|
-
sessions.body.append(h("div", { dataset: { slot: "sessions" } }));
|
|
137
|
-
panel.append(h("div.card-columns", null,
|
|
138
|
-
h("div.card-column", null, progressCard(data, t, locale, ctx), goalCard(data, t, ctx)),
|
|
139
|
-
h("div.card-column", null, sessions, decisionsCard(data, t, locale, ctx))));
|
|
140
|
-
if (task.status === "draft") panel.append(planningCard(data, t, locale));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function progressCard(data, t, locale, ctx) {
|
|
144
|
-
const task = data.task;
|
|
145
|
-
const element = card({ title: t("progress.title"), icon: "flag" });
|
|
146
|
-
const working = task.status === "draft" || task.status === "active";
|
|
147
|
-
if (task.completionSummary) element.body.append(richText(t("progress.completion"), task.completionSummary, t, { className: "callout.tone-ok" }));
|
|
148
|
-
if (task.retirementSummary) element.body.append(richText(t("progress.retirement"), task.retirementSummary, t, { className: "callout" }));
|
|
149
|
-
if (task.archiveSummary || task.archiveReason) element.body.append(richText(t("progress.archive"), [task.archiveSummary, task.archiveReason].filter(Boolean).join("\n\n"), t, { className: "callout" }));
|
|
150
|
-
const briefEntry = entriesOf(data.core, "task-brief")[0];
|
|
151
|
-
const brief = valuesOf(data.core, "task-brief")[0];
|
|
152
|
-
if (brief) {
|
|
153
|
-
element.body.append(richText(t(working ? "progress.focus" : "progress.lastFocus"), brief.currentFocus, t));
|
|
154
|
-
element.body.append(richText(t(working ? "progress.report" : "progress.lastReport"), brief.leaderSummary, t, { muted: true }));
|
|
155
|
-
element.body.append(h("p.faint.small", null, t("progress.briefUpdated") + " " + formatDateTime(brief.updatedAt, locale)));
|
|
156
|
-
} else if (briefEntry) element.body.append(recordCard(briefEntry, task.id, t, ctx, { compact: true }));
|
|
157
|
-
else element.body.append(emptyState(t("progress.none")));
|
|
158
|
-
element.body.append(h("p.next-line", { dataset: { slot: "next" } }));
|
|
159
|
-
return element;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function goalCard(data, t, ctx) {
|
|
163
|
-
const task = data.task;
|
|
164
|
-
const brief = valuesOf(data.core, "task-brief")[0];
|
|
165
|
-
const element = card({ title: t("goal.title"), icon: "target" });
|
|
166
|
-
if (brief && brief.objective) element.body.append(richText(null, brief.objective, t));
|
|
167
|
-
if (brief && brief.boundaries && brief.boundaries.length) {
|
|
168
|
-
element.body.append(h("div.prose-block", null, h("h4.prose-label", null, t("goal.boundaries")), bulletList(brief.boundaries)));
|
|
169
|
-
}
|
|
170
|
-
if (brief && brief.technicalApproach) {
|
|
171
|
-
const approach = disclosure(t("goal.approach"), "approach");
|
|
172
|
-
approach.body.append(richText(null, brief.technicalApproach, t));
|
|
173
|
-
element.body.append(approach);
|
|
174
|
-
}
|
|
175
|
-
if (task.description) {
|
|
176
|
-
const requirements = disclosure(t("goal.requirements"), "requirements");
|
|
177
|
-
requirements.body.append(richText(null, task.description, t));
|
|
178
|
-
element.body.append(requirements);
|
|
179
|
-
}
|
|
180
|
-
if (!element.body.childNodes.length) element.body.append(emptyState(t("goal.none")));
|
|
181
|
-
return element;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function decisionsCard(data, t, locale, ctx) {
|
|
185
|
-
const entries = entriesOf(data.core, "task-decision");
|
|
186
|
-
const active = entries.filter(function (entry) { return !entry.omitted && entry.value.status === "active"; });
|
|
187
|
-
const element = card({ title: t("decisions.title"), icon: "check", count: active.length || null, hint: t("decisions.hint") });
|
|
188
|
-
active.slice(0, 3).forEach(function (entry) {
|
|
189
|
-
const value = entry.value;
|
|
190
|
-
element.body.append(h("article.decision", null,
|
|
191
|
-
h("header.decision-head", null, dot("ok"), h("strong", null, value.title), timeTag(value.createdAt, locale, t)),
|
|
192
|
-
value.rationale ? richText(null, value.rationale, t, { muted: true, threshold: 260 }) : null));
|
|
193
|
-
});
|
|
194
|
-
if (!active.length) element.body.append(emptyState(t("decisions.none")));
|
|
195
|
-
if (active.length > 3 || data.core.omitted.records || entries.some(function (entry) { return entry.omitted; })) {
|
|
196
|
-
element.body.append(button(t("decisions.more"), { variant: "link", icon: "chevron", onClick: function () { ctx.onTab("history"); } }));
|
|
197
|
-
}
|
|
198
|
-
return element;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// A Draft's Leader conversation is its planning Turn. Report the snapshot's
|
|
202
|
-
// real planning facts; a withheld value is reported as withheld, never as
|
|
203
|
-
// "not dispatched".
|
|
204
|
-
function planningCard(data, t, locale) {
|
|
205
|
-
const runEntries = entriesOf(data.core, "run");
|
|
206
|
-
const planning = valuesOf(data.core, "run").filter(function (run) { return run.roleName === "leader" && run.purpose === "planning"; });
|
|
207
|
-
const turn = planning[planning.length - 1] || null;
|
|
208
|
-
const withheld = turn === null && runEntries.some(function (entry) { return entry.omitted; });
|
|
209
|
-
const live = ((data.runtime && data.runtime.roles) || []).find(function (role) { return role.name === "leader"; }) || null;
|
|
210
|
-
const element = card({ title: t("planning.title"), icon: "sparkle", className: "planning-card" });
|
|
211
|
-
element.dataset.planning = turn ? turn.status : withheld ? "withheld" : "not-dispatched";
|
|
212
|
-
element.body.append(note(withheld ? t("planning.withheld") : turn === null ? t("planning.none")
|
|
213
|
-
: turn.status === "active" ? t("planning.open") : t("planning.settled").replace("{status}", turn.status)));
|
|
214
|
-
const environment = turn && turn.effective && turn.effective.executionEnvironment;
|
|
215
|
-
element.body.append(kv([
|
|
216
|
-
[t("planning.run"), turn ? mono(turn.id + " (" + turn.status + ")") : withheld ? t("planning.withheldValue") : t("common.none")],
|
|
217
|
-
[t("planning.providerTerminal"), (turn && turn.result && turn.result.provider && turn.result.provider.status) || t("common.notReported")],
|
|
218
|
-
[t("planning.conversation"), (turn && turn.result && turn.result.provider && turn.result.provider.conversationId) || t("common.notReported")],
|
|
219
|
-
[t("planning.liveSession"), (live && live.runtimeSession && live.runtimeSession.nativeSessionId) || t("planning.notRunning")],
|
|
220
|
-
[t("planning.environment"), (environment && environment.environmentRef) || t("planning.emptyEnvironment")],
|
|
221
|
-
[t("planning.updated"), turn ? formatDateTime((turn.result && turn.result.completedAt) || turn.updatedAt, locale) : t("common.unknown")]
|
|
222
|
-
]));
|
|
223
|
-
return element;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// --- Observation slots -------------------------------------------------------
|
|
227
|
-
export function updateObservation(container, data, t, locale, ctx) {
|
|
228
|
-
const available = data.runtimeStatus === "available" && data.runtime;
|
|
229
|
-
const execution = available ? data.runtime.execution : null;
|
|
230
|
-
const execBadge = container.querySelector('[data-slot="exec-badge"]');
|
|
231
|
-
if (execBadge) {
|
|
232
|
-
clear(execBadge);
|
|
233
|
-
if (execution && execution.status !== data.task.status) execBadge.append(statusBadge(t, "exec", "exec.status", execution.status));
|
|
234
|
-
}
|
|
235
|
-
const now = container.querySelector('[data-slot="now"]');
|
|
236
|
-
if (now && !now.contains(document.activeElement)) drawNow(now, data, execution, t, locale);
|
|
237
|
-
const next = container.querySelector('[data-slot="next"]');
|
|
238
|
-
if (next) {
|
|
239
|
-
clear(next);
|
|
240
|
-
if (execution && !(execution.next.owner === "none" && execution.next.action === "none")) next.append(icon("flag", "icon-sm"), h("span", null, t("now.nextOwner") + " "),
|
|
241
|
-
h("strong", null, label(t, "exec.owner", execution.next.owner)), h("span", null, " · " + label(t, "exec.action", execution.next.action)));
|
|
242
|
-
}
|
|
243
|
-
const sessions = container.querySelector('[data-slot="sessions"]');
|
|
244
|
-
if (sessions && !sessions.contains(document.activeElement)) {
|
|
245
|
-
const open = sessions.querySelector("details") && sessions.querySelector("details").open;
|
|
246
|
-
drawSessions(sessions, available ? data.runtime.sessions : null, t, locale);
|
|
247
|
-
if (open && sessions.querySelector("details")) sessions.querySelector("details").open = true;
|
|
248
|
-
}
|
|
249
|
-
const raw = container.querySelector('[data-slot="runtime-raw"]');
|
|
250
|
-
if (raw) raw.textContent = available ? JSON.stringify({ roles: data.runtime.roles, runtimeHealth: data.runtime.runtimeHealth }, null, 2) : "";
|
|
251
|
-
const rawStatus = container.querySelector('[data-slot="runtime-status"]');
|
|
252
|
-
if (rawStatus) rawStatus.textContent = t("observation." + data.runtimeStatus) + " · " + formatDateTime(data.runtimeObservedAt, locale);
|
|
253
|
-
container.querySelectorAll("[data-role-status]").forEach(function (slot) {
|
|
254
|
-
const role = available ? (data.runtime.roles || []).find(function (item) { return item.name === slot.dataset.roleStatus; }) : null;
|
|
255
|
-
clear(slot);
|
|
256
|
-
if (role) slot.append(statusBadge(t, "role", "role", role.status));
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function drawNow(slot, data, execution, t, locale) {
|
|
261
|
-
clear(slot);
|
|
262
|
-
const inputCount = data.core.attention.openInputs.count;
|
|
263
|
-
if (!execution) {
|
|
264
|
-
slot.append(h("div.now-head", null,
|
|
265
|
-
badge(t("observation." + data.runtimeStatus), data.runtimeStatus === "unavailable" ? "bad" : "idle", { dot: true }),
|
|
266
|
-
h("span.now-owner", null, inputCount ? t("now.inputs").replace("{count}", String(inputCount)) : t("now.noInputs"))));
|
|
267
|
-
slot.append(h("p.now-note", null, data.runtimeStatus === "waiting" ? t("now.reading") : t("now.unavailable")));
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const head = h("div.now-head", null,
|
|
271
|
-
statusBadge(t, "exec", "exec.status", execution.status),
|
|
272
|
-
execution.owner === "none" && execution.action === "none" ? null
|
|
273
|
-
: h("span.now-owner", null, label(t, "exec.owner", execution.owner) + " · " + label(t, "exec.action", execution.action)));
|
|
274
|
-
if (execution.activeRuns && execution.activeRuns.length) head.append(badge(execution.activeRuns.length + " " + t("now.activeRuns"), "info"));
|
|
275
|
-
if (execution.monitoring === "stopped") head.append(badge(t("now.monitoringStopped"), "warn"));
|
|
276
|
-
if (execution.failClosed) head.append(badge(t("now.failClosed"), "bad"));
|
|
277
|
-
head.append(h("span.spacer"), h("span.faint.small", { title: formatDateTime(data.runtimeObservedAt, locale) },
|
|
278
|
-
t("now.observed") + " " + formatClock(data.runtimeObservedAt, locale)));
|
|
279
|
-
slot.append(head);
|
|
280
|
-
if (execution.summary) slot.append(h("p.now-summary", null, execution.summary));
|
|
281
|
-
if (execution.reason) slot.append(h("p.now-reason", null, execution.reason));
|
|
282
|
-
const signals = [];
|
|
283
|
-
(execution.attention || []).forEach(function (item) {
|
|
284
|
-
signals.push(h("li.signal-row.tone-warn", null, icon("alert", "icon-sm"),
|
|
285
|
-
h("span.signal-kind", null, label(t, "exec.attention", item.kind)), h("span", null, item.summary),
|
|
286
|
-
item.owner ? h("span.faint.small", null, label(t, "exec.owner", item.owner)) : null));
|
|
287
|
-
});
|
|
288
|
-
(execution.blockers || []).forEach(function (item) {
|
|
289
|
-
signals.push(h("li.signal-row.tone-bad", null, icon("alert", "icon-sm"),
|
|
290
|
-
h("span.signal-kind", null, label(t, "exec.blocker", item.kind)), h("span", null, item.summary),
|
|
291
|
-
h("span.faint.small", null, label(t, "exec.owner", item.owner))));
|
|
292
|
-
});
|
|
293
|
-
const sessions = (data.runtime.sessions && data.runtime.sessions.sessions) || [];
|
|
294
|
-
sessions.filter(function (session) { return session.group === "waiting" && ["user", "permission"].includes(session.waitingReason); })
|
|
295
|
-
.forEach(function (session) {
|
|
296
|
-
signals.push(h("li.signal-row.tone-warn", null, icon("user", "icon-sm"),
|
|
297
|
-
h("span.signal-kind", null, session.roleName), h("span", null, t("now.nativeWait"))));
|
|
298
|
-
});
|
|
299
|
-
if (signals.length) slot.append(h("ul.signal-list", null, signals));
|
|
300
|
-
else slot.append(h("p.now-note", null, inputCount ? t("now.inputs").replace("{count}", String(inputCount)) : t("now.clear")));
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function drawSessions(slot, observation, t, locale) {
|
|
304
|
-
clear(slot);
|
|
305
|
-
if (!observation) { slot.append(emptyState(t("sessions.unavailable"))); return; }
|
|
306
|
-
const chips = SESSION_GROUPS.filter(function (group) { return observation.counts[group]; }).map(function (group) {
|
|
307
|
-
return badge(observation.counts[group] + " " + t("session." + group), tone("session", group), { dot: true });
|
|
308
|
-
});
|
|
309
|
-
if (chips.length) slot.append(h("div.chip-row", null, chips));
|
|
310
|
-
if (!observation.sessions.length) { slot.append(note(t("sessions.none"))); return; }
|
|
311
|
-
slot.append(h("ul.session-list", null, observation.sessions.map(function (session) {
|
|
312
|
-
return h("li.session-row", null,
|
|
313
|
-
h("div.session-row-head", null, dot(tone("session", session.group)), h("strong", null, session.roleName),
|
|
314
|
-
h("span.faint", null, t("session." + session.group)), h("span.spacer"),
|
|
315
|
-
h("span.faint.small", null, session.lastActivityAt ? relativeTime(session.lastActivityAt, locale, t) : t("sessions.unobserved"))),
|
|
316
|
-
h("p.small", null, session.reason),
|
|
317
|
-
session.waitingReason ? h("p.small", null, t("sessions.waitingFor") + " " + session.waitingReason) : null);
|
|
318
|
-
})));
|
|
319
|
-
const facts = disclosure(t("sessions.facts"), "sessions");
|
|
320
|
-
observation.sessions.forEach(function (session) {
|
|
321
|
-
facts.body.append(kv([
|
|
322
|
-
[t("sessions.role"), session.roleName],
|
|
323
|
-
[t("sessions.lastActivity"), session.lastActivityAt ? formatDateTime(session.lastActivityAt, locale) : t("sessions.unobserved")],
|
|
324
|
-
[t("sessions.inputUpdated"), formatDateTime(session.sourceUpdatedAt, locale)],
|
|
325
|
-
[t("sessions.operations"), session.operations.length ? session.operations.join(", ") : null],
|
|
326
|
-
[t("sessions.background"), session.background.length ? session.background.map(function (item) { return item.id + " · " + item.execution; }).join(", ") : null],
|
|
327
|
-
[t("sessions.identity"), mono([session.nativeSessionId, session.nativeTurnId, session.attemptId].filter(Boolean).join(" / "))]
|
|
328
|
-
]));
|
|
329
|
-
});
|
|
330
|
-
facts.body.append(h("p.faint.small", null, t("sessions.scope") + " " + formatDateTime(observation.readAt, locale)));
|
|
331
|
-
slot.append(facts);
|
|
332
|
-
}
|
|
333
|
-
`;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
export const DOCK_SCRIPT = String.raw `
|
|
2
|
-
// The session dock: the Task discussion (recorded Task messages plus the
|
|
3
|
-
// composer) and the live native Session terminal. The feed is a read-only
|
|
4
|
-
// projection and redraws on every refresh; the composer is kept per Task so a
|
|
5
|
-
// refresh can never discard an unsent draft or a pending receipt.
|
|
6
|
-
import { Terminal } from "/assets/vendor/xterm.mjs";
|
|
7
|
-
import { FitAddon } from "/assets/vendor/addon-fit.mjs";
|
|
8
|
-
import { h, icon, clear } from "/assets/js/dom.js";
|
|
9
|
-
import { formatShort } from "/assets/js/format.js";
|
|
10
|
-
import { label, chip, emptyState, richText, dot } from "/assets/js/components.js";
|
|
11
|
-
import { entriesOf, recordCard, recordReader } from "/assets/js/records.js";
|
|
12
|
-
import { messageComposer } from "/assets/js/forms.js";
|
|
13
|
-
import { pageToken } from "/assets/js/api.js";
|
|
14
|
-
|
|
15
|
-
export function renderDiscussion(host, data, t, locale, actions) {
|
|
16
|
-
const task = data.task;
|
|
17
|
-
const composerKey = task.id + "|" + task.status + "|" + locale;
|
|
18
|
-
let feed = host.querySelector(".feed");
|
|
19
|
-
const composerWrap = host.querySelector(".composer-wrap");
|
|
20
|
-
const composer = composerWrap && composerWrap.firstChild;
|
|
21
|
-
const keepComposer = host.dataset.taskId === task.id && composer
|
|
22
|
-
&& (composer.dataset.key === composerKey || composer.dataset.unsent === "true" || composer.contains(document.activeElement));
|
|
23
|
-
const previousScroll = feed ? feed.scrollTop : 0;
|
|
24
|
-
const atEnd = !feed || host.dataset.taskId !== task.id || feed.scrollHeight - feed.clientHeight - feed.scrollTop < 40;
|
|
25
|
-
if (host.dataset.taskId !== task.id || !feed) {
|
|
26
|
-
clear(host);
|
|
27
|
-
host.append(
|
|
28
|
-
h("div.dock-sub", null, h("span.dock-sub-title", null, t("discussion.title")), h("span.dock-sub-note", null, t("discussion.source"))),
|
|
29
|
-
h("div.feed", { "aria-label": t("discussion.feed"), tabIndex: 0 }),
|
|
30
|
-
h("div.composer-wrap"));
|
|
31
|
-
feed = host.querySelector(".feed");
|
|
32
|
-
}
|
|
33
|
-
host.dataset.taskId = task.id;
|
|
34
|
-
if (!feed.querySelector('[data-reading="true"]')) drawFeed(feed, data, t, locale, actions);
|
|
35
|
-
feed.scrollTop = atEnd ? feed.scrollHeight : previousScroll;
|
|
36
|
-
if (!keepComposer) {
|
|
37
|
-
const next = messageComposer(task, t, actions);
|
|
38
|
-
next.dataset.key = composerKey;
|
|
39
|
-
host.querySelector(".composer-wrap").replaceChildren(next);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function discussionHasUnsent(host) {
|
|
44
|
-
return !!host.querySelector('[data-unsent="true"]');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function drawFeed(feed, data, t, locale, actions) {
|
|
48
|
-
clear(feed);
|
|
49
|
-
const core = data.core;
|
|
50
|
-
const entries = entriesOf(core, "task-message").slice().sort(function (a, b) {
|
|
51
|
-
return Date.parse((a.value && a.value.createdAt) || 0) - Date.parse((b.value && b.value.createdAt) || 0);
|
|
52
|
-
});
|
|
53
|
-
if (core.omitted.records) feed.append(h("p.feed-note", null, t("discussion.omitted")));
|
|
54
|
-
if (!entries.length) {
|
|
55
|
-
feed.append(emptyState(t("discussion.empty"), "chat"));
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
let lastDay = "";
|
|
59
|
-
entries.forEach(function (entry) {
|
|
60
|
-
if (entry.omitted) { feed.append(recordCard(entry, data.task.id, t, actions, { compact: true })); return; }
|
|
61
|
-
const value = entry.value;
|
|
62
|
-
const day = value.createdAt ? new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(new Date(value.createdAt)) : "";
|
|
63
|
-
if (day && day !== lastDay) { feed.append(h("div.feed-day", null, h("span", null, day))); lastDay = day; }
|
|
64
|
-
const type = (value.author && value.author.type) || "system";
|
|
65
|
-
const author = (value.author && value.author.roleName) || label(t, "author", type);
|
|
66
|
-
const message = h("article.msg.from-" + (type === "user" || type === "operator" ? "user" : type === "role" ? "role" : "system"));
|
|
67
|
-
message.append(h("span.msg-avatar", { "aria-hidden": "true" }, String(author).slice(0, 1).toUpperCase()));
|
|
68
|
-
const main = h("div.msg-main", null,
|
|
69
|
-
h("header.msg-head", null, h("strong", null, author),
|
|
70
|
-
value.intent ? chip(label(t, "intent", value.intent)) : null,
|
|
71
|
-
value.kind === "role-result" ? chip(label(t, "messageKind", value.kind)) : null,
|
|
72
|
-
h("time", { dateTime: value.createdAt || "" }, formatShort(value.createdAt, locale))),
|
|
73
|
-
h("div.msg-bubble", null, richText(null, value.body || "", t, { threshold: 900 })));
|
|
74
|
-
main.append(recordReader(entry, data.task.id, t, actions));
|
|
75
|
-
message.append(main);
|
|
76
|
-
feed.append(message);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// --- Live native Session ----------------------------------------------------------
|
|
81
|
-
function cssVar(name, fallback) {
|
|
82
|
-
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
83
|
-
return value || fallback;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function terminalTheme() {
|
|
87
|
-
return {
|
|
88
|
-
background: cssVar("--term-bg", "#0b0c0d"),
|
|
89
|
-
foreground: cssVar("--term-fg", "#e6e6e8"),
|
|
90
|
-
cursor: cssVar("--term-cursor", "#ff7a52"),
|
|
91
|
-
selectionBackground: cssVar("--term-sel", "#3a2a24")
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function cliFor(target) {
|
|
96
|
-
if (target.scope === "task") return "yui task role session inspect " + target.taskId + " " + target.roleName;
|
|
97
|
-
return target.roleName === "operator" ? "yui operator enter" : "yui session enter " + target.roleName;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function sameTarget(left, right) {
|
|
101
|
-
return !!left && !!right && left.scope === right.scope && left.roleName === right.roleName
|
|
102
|
-
&& (left.scope !== "task" || left.taskId === right.taskId);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function createTerminalController(elements, t, locale, notify) {
|
|
106
|
-
let session = null;
|
|
107
|
-
let current = null;
|
|
108
|
-
let stateKey = "terminal.idle";
|
|
109
|
-
let targets = [];
|
|
110
|
-
|
|
111
|
-
function setState(key, state) {
|
|
112
|
-
stateKey = key;
|
|
113
|
-
elements.state.dataset.state = state;
|
|
114
|
-
elements.state.lastChild.textContent = t(key);
|
|
115
|
-
}
|
|
116
|
-
function drawTargets() {
|
|
117
|
-
clear(elements.targets);
|
|
118
|
-
targets.forEach(function (target) {
|
|
119
|
-
elements.targets.append(h("button.target-chip", {
|
|
120
|
-
type: "button",
|
|
121
|
-
"aria-pressed": String(sameTarget(target, current)),
|
|
122
|
-
title: target.scope === "task" ? target.taskId + " / " + target.roleName : t("terminal.global") + " / " + target.roleName,
|
|
123
|
-
onclick: function () { open(target); }
|
|
124
|
-
}, target.scope === "task" ? dot(target.live ? "ok" : "idle") : icon("broadcast", "icon-sm"), h("span", null, target.roleName)));
|
|
125
|
-
});
|
|
126
|
-
if (!targets.length) elements.targets.append(h("span.faint.small", null, t("terminal.noTargets")));
|
|
127
|
-
}
|
|
128
|
-
function dispose() {
|
|
129
|
-
if (!session) return;
|
|
130
|
-
const owned = session;
|
|
131
|
-
session = null;
|
|
132
|
-
owned.resizeObserver.disconnect();
|
|
133
|
-
owned.input.dispose();
|
|
134
|
-
owned.socket.close();
|
|
135
|
-
owned.terminal.dispose();
|
|
136
|
-
clear(elements.host);
|
|
137
|
-
}
|
|
138
|
-
function close() {
|
|
139
|
-
dispose();
|
|
140
|
-
current = null;
|
|
141
|
-
elements.empty.hidden = false;
|
|
142
|
-
elements.cli.textContent = "yui operator enter";
|
|
143
|
-
setState("terminal.idle", "idle");
|
|
144
|
-
drawTargets();
|
|
145
|
-
}
|
|
146
|
-
function open(target) {
|
|
147
|
-
dispose();
|
|
148
|
-
current = target;
|
|
149
|
-
elements.empty.hidden = true;
|
|
150
|
-
elements.cli.textContent = cliFor(target);
|
|
151
|
-
setState("terminal.connecting", "connecting");
|
|
152
|
-
drawTargets();
|
|
153
|
-
const terminal = new Terminal({
|
|
154
|
-
cursorBlink: true,
|
|
155
|
-
scrollback: 0,
|
|
156
|
-
convertEol: false,
|
|
157
|
-
fontFamily: '"JetBrains Mono","SFMono-Regular",Menlo,Consolas,monospace',
|
|
158
|
-
fontSize: 12.5,
|
|
159
|
-
lineHeight: 1.15,
|
|
160
|
-
theme: terminalTheme()
|
|
161
|
-
});
|
|
162
|
-
const fit = new FitAddon();
|
|
163
|
-
terminal.loadAddon(fit);
|
|
164
|
-
terminal.open(elements.host);
|
|
165
|
-
try { fit.fit(); } catch {}
|
|
166
|
-
let writable = false;
|
|
167
|
-
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
168
|
-
const parameters = new URLSearchParams({
|
|
169
|
-
scope: target.scope, role: target.roleName, cols: String(terminal.cols), rows: String(terminal.rows), token: pageToken()
|
|
170
|
-
});
|
|
171
|
-
if (target.scope === "task") parameters.set("task", target.taskId);
|
|
172
|
-
const socket = new WebSocket(protocol + "//" + window.location.host + "/api/terminal?" + parameters.toString());
|
|
173
|
-
const input = terminal.onData(function (data) {
|
|
174
|
-
if (writable && socket.readyState === WebSocket.OPEN) socket.send(JSON.stringify({ type: "input", data: data }));
|
|
175
|
-
});
|
|
176
|
-
const resizeObserver = new ResizeObserver(function () {
|
|
177
|
-
if (!session || session.terminal !== terminal || !elements.host.offsetWidth) return;
|
|
178
|
-
try { fit.fit(); } catch { return; }
|
|
179
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
180
|
-
socket.send(JSON.stringify({ type: "resize", columns: terminal.cols, rows: terminal.rows }));
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
resizeObserver.observe(elements.host);
|
|
184
|
-
socket.addEventListener("message", function (event) {
|
|
185
|
-
let message;
|
|
186
|
-
try { message = JSON.parse(event.data); } catch { return; }
|
|
187
|
-
if (message.type === "ready") {
|
|
188
|
-
writable = !message.readOnly;
|
|
189
|
-
setState(writable ? "terminal.writable" : "terminal.readOnly", writable ? "writable" : "readonly");
|
|
190
|
-
if (message.history && message.history.limit < message.history.target) {
|
|
191
|
-
const number = new Intl.NumberFormat(locale());
|
|
192
|
-
notify(t("terminal.historyLimited").replace("{current}", number.format(message.history.limit))
|
|
193
|
-
.replace("{target}", number.format(message.history.target)));
|
|
194
|
-
}
|
|
195
|
-
terminal.focus();
|
|
196
|
-
} else if (message.type === "data") terminal.write(message.data);
|
|
197
|
-
else if (message.type === "exit") setState("terminal.closed", "closed");
|
|
198
|
-
else if (message.type === "error") {
|
|
199
|
-
setState("terminal.error", "error");
|
|
200
|
-
terminal.writeln("\r\n" + message.message);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
socket.addEventListener("close", function () {
|
|
204
|
-
writable = false;
|
|
205
|
-
if (stateKey !== "terminal.error") setState("terminal.closed", "closed");
|
|
206
|
-
});
|
|
207
|
-
socket.addEventListener("error", function () {
|
|
208
|
-
writable = false;
|
|
209
|
-
setState("terminal.error", "error");
|
|
210
|
-
terminal.writeln(t("terminal.errorDetail"));
|
|
211
|
-
});
|
|
212
|
-
session = { terminal, socket, input, resizeObserver };
|
|
213
|
-
}
|
|
214
|
-
drawTargets();
|
|
215
|
-
return {
|
|
216
|
-
open: open,
|
|
217
|
-
close: close,
|
|
218
|
-
current: function () { return current; },
|
|
219
|
-
connected: function () { return !!session; },
|
|
220
|
-
setTargets: function (next) { targets = next; drawTargets(); },
|
|
221
|
-
relabel: function () { setState(stateKey, elements.state.dataset.state); drawTargets(); },
|
|
222
|
-
retheme: function () { if (session) session.terminal.options.theme = terminalTheme(); }
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
`;
|