@volter-ai-dev/supercode-ui 0.1.66 → 0.1.68
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/activity.mjs +249 -4
- package/components.d.ts +3 -0
- package/components.mjs +382 -14
- package/composer.mjs +18 -3
- package/controller.mjs +5 -0
- package/conversation.mjs +42 -3
- package/core.d.ts +13 -0
- package/core.mjs +390 -1
- package/embed.mjs +377 -13
- package/index.d.ts +159 -0
- package/messenger.mjs +377 -13
- package/package.json +1 -1
- package/react/activity.mjs +249 -4
- package/react/components.mjs +382 -14
- package/react/composer.mjs +18 -3
- package/react/conversation.mjs +42 -3
- package/react/messenger.mjs +377 -13
- package/react/sessions.mjs +68 -4
- package/react/settings.mjs +10 -1
- package/react/subagents.mjs +42 -3
- package/sessions.mjs +68 -4
- package/settings.mjs +10 -1
- package/styles.css +11 -1
- package/subagents.mjs +42 -3
package/react/activity.mjs
CHANGED
|
@@ -29,6 +29,10 @@ var EMPTY_UI_STATE = Object.freeze({
|
|
|
29
29
|
harness: "",
|
|
30
30
|
mode: "none",
|
|
31
31
|
strategy: null,
|
|
32
|
+
participant: Object.freeze({ kind: "local-user", label: null, origin: null }),
|
|
33
|
+
workspaceRef: Object.freeze({ kind: "none", value: null }),
|
|
34
|
+
mirror: null,
|
|
35
|
+
holder: null,
|
|
32
36
|
canSend: false,
|
|
33
37
|
canSteer: false,
|
|
34
38
|
canResume: false,
|
|
@@ -66,7 +70,12 @@ var EMPTY_UI_STATE = Object.freeze({
|
|
|
66
70
|
subagentInspector: null,
|
|
67
71
|
attached: null,
|
|
68
72
|
owned: null,
|
|
69
|
-
attachError: null
|
|
73
|
+
attachError: null,
|
|
74
|
+
agentPackage: null,
|
|
75
|
+
contributions: Object.freeze([]),
|
|
76
|
+
agentPackageError: null,
|
|
77
|
+
agentPackageCapabilityState: null,
|
|
78
|
+
agentPackageCapabilityError: null
|
|
70
79
|
});
|
|
71
80
|
var ROLES = /* @__PURE__ */ new Set(["system", "user", "assistant", "tool", "reasoning", "request", "notice"]);
|
|
72
81
|
var MODES = /* @__PURE__ */ new Set(["none", "control", "mirror"]);
|
|
@@ -79,6 +88,10 @@ var AUTHENTICATION_PHASES = /* @__PURE__ */ new Set(["idle", "checking", "requir
|
|
|
79
88
|
var MAX_TOOL_FIELDS = 8;
|
|
80
89
|
var MAX_TOOL_FIELD_CHARS = 800;
|
|
81
90
|
var MAX_TOOL_PREVIEW_CHARS = 4e3;
|
|
91
|
+
var MAX_CONTRIBUTIONS = 64;
|
|
92
|
+
var MAX_CONTRIBUTION_JSON_DEPTH = 12;
|
|
93
|
+
var MAX_CONTRIBUTION_COLLECTION = 100;
|
|
94
|
+
var MAX_CONTRIBUTION_STRING_CHARS = 16e3;
|
|
82
95
|
function record(value) {
|
|
83
96
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
84
97
|
}
|
|
@@ -111,6 +124,126 @@ function number(value, fallback = 0) {
|
|
|
111
124
|
function nullableNumber(value) {
|
|
112
125
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
113
126
|
}
|
|
127
|
+
function relativeContributionPath(value) {
|
|
128
|
+
if (typeof value !== "string" || value.startsWith("/") || /^[a-z]:[\\/]/i.test(value)) return null;
|
|
129
|
+
return value.replaceAll("\\", "/").split("/").some((segment) => segment === "..") ? null : boundedString(value, 1e3);
|
|
130
|
+
}
|
|
131
|
+
function contributionJson(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
132
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
133
|
+
return typeof value === "string" ? boundedString(value, MAX_CONTRIBUTION_STRING_CHARS) : value;
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
136
|
+
if (depth >= MAX_CONTRIBUTION_JSON_DEPTH || !value || typeof value !== "object" || seen.has(value)) {
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
seen.add(value);
|
|
140
|
+
if (Array.isArray(value)) {
|
|
141
|
+
const result2 = [];
|
|
142
|
+
for (const item of value.slice(0, MAX_CONTRIBUTION_COLLECTION)) {
|
|
143
|
+
const normalized = contributionJson(item, depth + 1, seen);
|
|
144
|
+
if (normalized !== void 0) result2.push(normalized);
|
|
145
|
+
}
|
|
146
|
+
seen.delete(value);
|
|
147
|
+
return result2;
|
|
148
|
+
}
|
|
149
|
+
const source = record(value);
|
|
150
|
+
if (!source) return void 0;
|
|
151
|
+
const result = {};
|
|
152
|
+
for (const [key, item] of Object.entries(source).slice(0, MAX_CONTRIBUTION_COLLECTION)) {
|
|
153
|
+
const normalized = contributionJson(item, depth + 1, seen);
|
|
154
|
+
if (normalized !== void 0) result[boundedString(key, 200)] = normalized;
|
|
155
|
+
}
|
|
156
|
+
seen.delete(value);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
function normalizeContributions(value) {
|
|
160
|
+
if (!Array.isArray(value)) return [];
|
|
161
|
+
return value.slice(0, MAX_CONTRIBUTIONS).flatMap((candidate) => {
|
|
162
|
+
const item = record(candidate);
|
|
163
|
+
const placement = record(item?.placement);
|
|
164
|
+
const source = relativeContributionPath(item?.source);
|
|
165
|
+
if (item?.schema !== "supercode/contribution-v1" || typeof item.id !== "string" || !item.id.trim() || typeof item.kind !== "string" || !item.kind.trim() || source === null) return [];
|
|
166
|
+
const data = contributionJson(item.data);
|
|
167
|
+
if (data === void 0) return [];
|
|
168
|
+
return [{
|
|
169
|
+
schema: "supercode/contribution-v1",
|
|
170
|
+
id: boundedString(item.id, 200),
|
|
171
|
+
kind: boundedString(item.kind, 100),
|
|
172
|
+
...typeof item.title === "string" ? { title: boundedString(item.title, 500) } : {},
|
|
173
|
+
...placement ? { placement: {
|
|
174
|
+
...typeof placement.surface === "string" ? { surface: boundedString(placement.surface, 100) } : {},
|
|
175
|
+
...typeof placement.region === "string" ? { region: boundedString(placement.region, 100) } : {}
|
|
176
|
+
} } : {},
|
|
177
|
+
data,
|
|
178
|
+
source
|
|
179
|
+
}];
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function readAgentPackage(value) {
|
|
183
|
+
const agentPackage = record(value);
|
|
184
|
+
const capabilities = record(agentPackage?.capabilities);
|
|
185
|
+
const storage = record(agentPackage?.storage);
|
|
186
|
+
const relativePath = relativeContributionPath(storage?.relativePath);
|
|
187
|
+
if (agentPackage?.schemaVersion !== 1 || typeof agentPackage.id !== "string" || typeof agentPackage.name !== "string" || typeof agentPackage.version !== "string" || !capabilities || !Array.isArray(capabilities.required) || !Array.isArray(capabilities.optional) || !storage || relativePath === null) return null;
|
|
188
|
+
const resources = record(agentPackage.resources);
|
|
189
|
+
return {
|
|
190
|
+
id: boundedString(agentPackage.id, 200),
|
|
191
|
+
name: boundedString(agentPackage.name, 500),
|
|
192
|
+
version: boundedString(agentPackage.version, 100),
|
|
193
|
+
description: typeof agentPackage.description === "string" ? boundedString(agentPackage.description, 2e3) : null,
|
|
194
|
+
capabilities: {
|
|
195
|
+
required: capabilities.required.filter((item) => typeof item === "string").slice(0, 100).map((item) => boundedString(item, 200)),
|
|
196
|
+
optional: capabilities.optional.filter((item) => typeof item === "string").slice(0, 100).map((item) => boundedString(item, 200))
|
|
197
|
+
},
|
|
198
|
+
storage: { relativePath },
|
|
199
|
+
resources: resources ? Object.fromEntries(Object.entries(resources).flatMap(([id, candidate]) => {
|
|
200
|
+
const state = record(candidate);
|
|
201
|
+
if (state?.schema !== "supercode/package-resource-state-v1") return [];
|
|
202
|
+
if (state.status === "absent" && typeof state.contributionId === "string") {
|
|
203
|
+
return [[boundedString(id, 200), {
|
|
204
|
+
schema: "supercode/package-resource-state-v1",
|
|
205
|
+
status: "absent",
|
|
206
|
+
contributionId: boundedString(state.contributionId, 200)
|
|
207
|
+
}]];
|
|
208
|
+
}
|
|
209
|
+
if (state.status === "error" && typeof state.contributionId === "string" && typeof state.message === "string") {
|
|
210
|
+
return [[boundedString(id, 200), {
|
|
211
|
+
schema: "supercode/package-resource-state-v1",
|
|
212
|
+
status: "error",
|
|
213
|
+
contributionId: boundedString(state.contributionId, 200),
|
|
214
|
+
message: boundedString(state.message)
|
|
215
|
+
}]];
|
|
216
|
+
}
|
|
217
|
+
const resource = record(state?.resource);
|
|
218
|
+
const data = contributionJson(resource?.data);
|
|
219
|
+
if (state?.status !== "ready" || resource?.schema !== "supercode/package-resource-v1" || typeof resource.contributionId !== "string" || !["json", "text"].includes(resource.format) || typeof resource.mediaType !== "string" || data === void 0) return [];
|
|
220
|
+
return [[boundedString(id, 200), {
|
|
221
|
+
schema: "supercode/package-resource-state-v1",
|
|
222
|
+
status: "ready",
|
|
223
|
+
resource: {
|
|
224
|
+
schema: "supercode/package-resource-v1",
|
|
225
|
+
contributionId: boundedString(resource.contributionId, 200),
|
|
226
|
+
format: resource.format,
|
|
227
|
+
mediaType: boundedString(resource.mediaType, 200),
|
|
228
|
+
data
|
|
229
|
+
}
|
|
230
|
+
}]];
|
|
231
|
+
})) : {}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function readAgentPackageCapabilityState(value) {
|
|
235
|
+
const state = record(value);
|
|
236
|
+
if (!state) return null;
|
|
237
|
+
const fields = ["availableRequired", "missingRequired", "enabledOptional", "unavailableOptional"];
|
|
238
|
+
if (!fields.every((field) => Array.isArray(state[field]))) return null;
|
|
239
|
+
return {
|
|
240
|
+
ready: state.ready === true,
|
|
241
|
+
...Object.fromEntries(fields.map((field) => [
|
|
242
|
+
field,
|
|
243
|
+
state[field].filter((item) => typeof item === "string").slice(0, 100).map((item) => boundedString(item, 200))
|
|
244
|
+
]))
|
|
245
|
+
};
|
|
246
|
+
}
|
|
114
247
|
function boundedString(value, max = 2e3) {
|
|
115
248
|
if (typeof value !== "string") return "";
|
|
116
249
|
return value.length <= max ? value : `${value.slice(0, max)}\u2026`;
|
|
@@ -500,12 +633,40 @@ function readToolPresentation(value, entry) {
|
|
|
500
633
|
matches: nullableNumber(item.matches) ?? generated.matches
|
|
501
634
|
};
|
|
502
635
|
}
|
|
636
|
+
var OPAQUE_RAW_CHARS = 4e3;
|
|
637
|
+
function opaqueEntry(item) {
|
|
638
|
+
const previouslyOpaque = item.role === "opaque";
|
|
639
|
+
let raw;
|
|
640
|
+
if (previouslyOpaque && typeof item.raw === "string") {
|
|
641
|
+
raw = item.raw;
|
|
642
|
+
} else {
|
|
643
|
+
try {
|
|
644
|
+
raw = JSON.stringify(item, null, 2) ?? "";
|
|
645
|
+
} catch {
|
|
646
|
+
raw = "[unserializable entry payload]";
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const kind = previouslyOpaque && typeof item.kind === "string" ? item.kind : typeof item.role === "string" ? item.role : "";
|
|
650
|
+
return {
|
|
651
|
+
id: item.id,
|
|
652
|
+
role: "opaque",
|
|
653
|
+
kind: boundedString(kind, 120) || "unknown",
|
|
654
|
+
text: typeof item.text === "string" ? boundedString(item.text, OPAQUE_RAW_CHARS) : "",
|
|
655
|
+
ts: nullableNumber(item.ts),
|
|
656
|
+
truncated: item.truncated === true || raw.length > OPAQUE_RAW_CHARS,
|
|
657
|
+
raw: boundedString(raw, OPAQUE_RAW_CHARS)
|
|
658
|
+
};
|
|
659
|
+
}
|
|
503
660
|
function readTranscript(value) {
|
|
504
661
|
if (!Array.isArray(value)) return [];
|
|
505
662
|
const result = [];
|
|
506
663
|
for (const candidate of value) {
|
|
507
664
|
const item = record(candidate);
|
|
508
|
-
if (!item || typeof item.id !== "string"
|
|
665
|
+
if (!item || typeof item.id !== "string") continue;
|
|
666
|
+
if (typeof item.text !== "string" || !ROLES.has(item.role)) {
|
|
667
|
+
result.push(opaqueEntry(item));
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
509
670
|
const entry = {
|
|
510
671
|
id: item.id,
|
|
511
672
|
role: item.role,
|
|
@@ -563,6 +724,75 @@ function readTranscript(value) {
|
|
|
563
724
|
}
|
|
564
725
|
return result;
|
|
565
726
|
}
|
|
727
|
+
function readParticipant(value) {
|
|
728
|
+
const participant = record(value);
|
|
729
|
+
if (!participant) return { kind: "local-user", label: null, origin: null };
|
|
730
|
+
return {
|
|
731
|
+
kind: ["local-user", "foreign", "unknown"].includes(participant.kind) ? participant.kind : "unknown",
|
|
732
|
+
label: typeof participant.label === "string" && participant.label ? boundedString(participant.label, 200) : null,
|
|
733
|
+
origin: typeof participant.origin === "string" && participant.origin ? boundedString(participant.origin, 100) : null
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function readWorkspaceRef(value, fallbackPath = "") {
|
|
737
|
+
const ref = record(value);
|
|
738
|
+
if (ref && ["repo", "none", "channel"].includes(ref.kind)) {
|
|
739
|
+
return {
|
|
740
|
+
kind: ref.kind,
|
|
741
|
+
value: ref.kind === "none" ? null : typeof ref.value === "string" && ref.value ? boundedString(ref.value, 500) : null
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
return fallbackPath ? { kind: "repo", value: boundedString(fallbackPath, 500) } : { kind: "none", value: null };
|
|
745
|
+
}
|
|
746
|
+
function readMirror(value) {
|
|
747
|
+
const mirror = record(value);
|
|
748
|
+
if (!mirror || typeof mirror.canonicalHarness !== "string" || !mirror.canonicalHarness) return null;
|
|
749
|
+
return {
|
|
750
|
+
canonicalHarness: boundedString(mirror.canonicalHarness, 100),
|
|
751
|
+
canonicalKey: typeof mirror.canonicalKey === "string" && mirror.canonicalKey ? boundedString(mirror.canonicalKey, 300) : null,
|
|
752
|
+
bounded: mirror.bounded === true,
|
|
753
|
+
truncated: mirror.truncated === true,
|
|
754
|
+
origin: typeof mirror.origin === "string" && mirror.origin ? boundedString(mirror.origin, 200) : null
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
function readHolder(value) {
|
|
758
|
+
const holder = record(value);
|
|
759
|
+
if (!holder) return null;
|
|
760
|
+
const surface = typeof holder.surface === "string" && holder.surface ? boundedString(holder.surface, 100) : null;
|
|
761
|
+
return {
|
|
762
|
+
surface,
|
|
763
|
+
canTakeOver: holder.canTakeOver === true && surface !== null && surface !== "supercode"
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
var TRIGGER_KINDS = ["human", "channel", "cron", "heartbeat", "webhook", "parent", "api", "unknown"];
|
|
767
|
+
function readTrigger(value) {
|
|
768
|
+
const trigger = record(value);
|
|
769
|
+
if (!trigger) return null;
|
|
770
|
+
const kind = trigger.kind === "manual" ? "human" : trigger.kind;
|
|
771
|
+
return {
|
|
772
|
+
kind: TRIGGER_KINDS.includes(kind) ? kind : "unknown",
|
|
773
|
+
label: typeof trigger.label === "string" && trigger.label ? boundedString(trigger.label, 200) : null,
|
|
774
|
+
surface: typeof trigger.surface === "string" && trigger.surface ? boundedString(trigger.surface, 300) : null
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function readCrossSurface(value) {
|
|
778
|
+
const moved = record(value);
|
|
779
|
+
if (!moved || typeof moved.state !== "string" || !moved.state) return null;
|
|
780
|
+
return {
|
|
781
|
+
state: boundedString(moved.state, 100),
|
|
782
|
+
platform: typeof moved.platform === "string" && moved.platform ? boundedString(moved.platform, 100) : null,
|
|
783
|
+
error: typeof moved.error === "string" && moved.error ? boundedString(moved.error, 500) : null
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function readRecurring(value) {
|
|
787
|
+
const recurring = record(value);
|
|
788
|
+
if (!recurring || typeof recurring.groupKey !== "string" || !recurring.groupKey) return null;
|
|
789
|
+
const runs = Number.isSafeInteger(recurring.runs) && recurring.runs > 0 ? recurring.runs : 1;
|
|
790
|
+
return {
|
|
791
|
+
groupKey: boundedString(recurring.groupKey, 300),
|
|
792
|
+
runs,
|
|
793
|
+
lastStatus: ["ok", "failed", "mixed"].includes(recurring.lastStatus) ? recurring.lastStatus : null
|
|
794
|
+
};
|
|
795
|
+
}
|
|
566
796
|
function readSessions(value) {
|
|
567
797
|
if (!Array.isArray(value)) return [];
|
|
568
798
|
return value.flatMap((raw) => {
|
|
@@ -584,7 +814,13 @@ function readSessions(value) {
|
|
|
584
814
|
live: row.live === true,
|
|
585
815
|
runtimeStatus: row.runtimeStatus === "running" || row.runtimeStatus === "busy" || row.runtimeStatus === "idle" ? row.runtimeStatus : null,
|
|
586
816
|
...Number.isSafeInteger(row.subagentCount) && row.subagentCount > 0 ? { subagentCount: row.subagentCount } : {},
|
|
587
|
-
activity: ACTIVITY_PRIORITY[row.activity] !== void 0 ? row.activity : void 0
|
|
817
|
+
activity: ACTIVITY_PRIORITY[row.activity] !== void 0 ? row.activity : void 0,
|
|
818
|
+
...row.participant !== void 0 ? { participant: readParticipant(row.participant) } : {},
|
|
819
|
+
workspaceRef: readWorkspaceRef(row.workspaceRef, string(row.cwd)),
|
|
820
|
+
...readMirror(row.mirror) ? { mirror: readMirror(row.mirror) } : {},
|
|
821
|
+
...readTrigger(row.trigger) ? { trigger: readTrigger(row.trigger) } : {},
|
|
822
|
+
...readRecurring(row.recurring) ? { recurring: readRecurring(row.recurring) } : {},
|
|
823
|
+
...readCrossSurface(row.crossSurface) ? { crossSurface: readCrossSurface(row.crossSurface) } : {}
|
|
588
824
|
}];
|
|
589
825
|
});
|
|
590
826
|
}
|
|
@@ -768,6 +1004,10 @@ function normalizeUiState(value) {
|
|
|
768
1004
|
canConfigureSettings: raw.canConfigureSettings === true,
|
|
769
1005
|
messaging: raw.messaging === "live_peer" ? "live_peer" : null,
|
|
770
1006
|
workspace: string(raw.workspace),
|
|
1007
|
+
workspaceRef: readWorkspaceRef(raw.workspaceRef, string(raw.workspace)),
|
|
1008
|
+
participant: readParticipant(raw.participant),
|
|
1009
|
+
mirror: readMirror(raw.mirror),
|
|
1010
|
+
holder: readHolder(raw.holder),
|
|
771
1011
|
taskPlan: readTaskPlan(raw.taskPlan),
|
|
772
1012
|
semantics: readSemantics(raw.semantics),
|
|
773
1013
|
terminalHandoff: readTerminalHandoff(raw.terminalHandoff),
|
|
@@ -819,7 +1059,12 @@ function normalizeUiState(value) {
|
|
|
819
1059
|
subagentInspector: readSubagentInspector(raw.subagentInspector),
|
|
820
1060
|
attached: readAttached(raw.attached),
|
|
821
1061
|
owned: readAttached(raw.owned),
|
|
822
|
-
attachError: attachError && typeof attachError.key === "string" && typeof attachError.message === "string" ? { key: attachError.key, message: attachError.message } : null
|
|
1062
|
+
attachError: attachError && typeof attachError.key === "string" && typeof attachError.message === "string" ? { key: attachError.key, message: attachError.message } : null,
|
|
1063
|
+
agentPackage: readAgentPackage(raw.agentPackage),
|
|
1064
|
+
contributions: normalizeContributions(raw.contributions),
|
|
1065
|
+
agentPackageError: typeof raw.agentPackageError === "string" ? boundedString(raw.agentPackageError) : null,
|
|
1066
|
+
agentPackageCapabilityState: readAgentPackageCapabilityState(raw.agentPackageCapabilityState),
|
|
1067
|
+
agentPackageCapabilityError: typeof raw.agentPackageCapabilityError === "string" ? boundedString(raw.agentPackageCapabilityError) : null
|
|
823
1068
|
};
|
|
824
1069
|
}
|
|
825
1070
|
function harnessDisplayName(id) {
|