@get-bb/plugin-sdk 0.6.109 → 0.6.116
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/bundled-types/bb-plugin-sdk-app.d.ts +146 -9
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +8 -3
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk-internal-thread-status.d.ts +316 -0
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp-next.d.ts +10 -1
- package/bundled-types/bb-plugin-sdk-provider-bridge-acp.d.ts +10 -1
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +2 -1
- package/bundled-types/bb-plugin-sdk.d.ts +169 -12
- package/dist/app.js +108 -0
- package/dist/index.js +161 -1
- package/dist/internal/plugin-app-collector.js +11 -0
- package/dist/internal/rpc-query-host.js +4 -2
- package/dist/internal/thread-status.js +111 -0
- package/dist/provider-bridge-acp-next.js +30 -22
- package/dist/provider-bridge-acp.js +30 -22
- package/dist/replay-provider-child.mjs +21 -22
- package/dist/testing/app.js +123 -2
- package/package.json +7 -1
package/dist/index.js
CHANGED
|
@@ -918,6 +918,158 @@ var experimental_THREAD_INFO_SECTION_GROUPS = {
|
|
|
918
918
|
changes: "2_changes",
|
|
919
919
|
storage: "3_storage"
|
|
920
920
|
};
|
|
921
|
+
|
|
922
|
+
// ../domain/src/host-path.ts
|
|
923
|
+
var WINDOWS_DRIVE_PATH_PATTERN = /^([A-Za-z]):(?:[\\/]+|$)/u;
|
|
924
|
+
var WINDOWS_UNC_PATH_PATTERN = /^[\\/]{2}([^\\/]+)[\\/]+([^\\/]+)(?:[\\/]+|$)/u;
|
|
925
|
+
var WINDOWS_SEPARATOR_PATTERN = /[\\/]+/u;
|
|
926
|
+
function collapseSegments(rawSegments) {
|
|
927
|
+
const segments = [];
|
|
928
|
+
for (const segment of rawSegments) {
|
|
929
|
+
if (segment.length === 0 || segment === ".") {
|
|
930
|
+
continue;
|
|
931
|
+
}
|
|
932
|
+
if (segment === "..") {
|
|
933
|
+
segments.pop();
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
segments.push(segment);
|
|
937
|
+
}
|
|
938
|
+
return segments;
|
|
939
|
+
}
|
|
940
|
+
function splitHostPathRoot(path) {
|
|
941
|
+
const drive = WINDOWS_DRIVE_PATH_PATTERN.exec(path);
|
|
942
|
+
if (drive) {
|
|
943
|
+
return {
|
|
944
|
+
flavor: "windows",
|
|
945
|
+
root: `${(drive[1] ?? "").toUpperCase()}:\\`,
|
|
946
|
+
relativePath: path.slice(drive[0].length)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
const unc = WINDOWS_UNC_PATH_PATTERN.exec(path);
|
|
950
|
+
if (unc) {
|
|
951
|
+
return {
|
|
952
|
+
flavor: "windows",
|
|
953
|
+
root: `\\\\${unc[1] ?? ""}\\${unc[2] ?? ""}\\`,
|
|
954
|
+
relativePath: path.slice(unc[0].length)
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
if (path.startsWith("/")) {
|
|
958
|
+
return { flavor: "posix", root: "/", relativePath: path.slice(1) };
|
|
959
|
+
}
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
function parseHostPath(path) {
|
|
963
|
+
const split = splitHostPathRoot(path);
|
|
964
|
+
if (split === null) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
return {
|
|
968
|
+
flavor: split.flavor,
|
|
969
|
+
root: split.root,
|
|
970
|
+
segments: collapseSegments(
|
|
971
|
+
split.relativePath.split(
|
|
972
|
+
split.flavor === "windows" ? WINDOWS_SEPARATOR_PATTERN : "/"
|
|
973
|
+
)
|
|
974
|
+
)
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
function formatHostPath(parsed) {
|
|
978
|
+
if (parsed.flavor === "posix") {
|
|
979
|
+
return `/${parsed.segments.join("/")}`;
|
|
980
|
+
}
|
|
981
|
+
if (parsed.segments.length === 0) {
|
|
982
|
+
return parsed.root;
|
|
983
|
+
}
|
|
984
|
+
return `${parsed.root}${parsed.segments.join("\\")}`;
|
|
985
|
+
}
|
|
986
|
+
function comparisonSegments(parsed) {
|
|
987
|
+
return parsed.flavor === "windows" ? parsed.segments.map((segment) => segment.toLowerCase()) : parsed.segments;
|
|
988
|
+
}
|
|
989
|
+
function comparisonRoot(parsed) {
|
|
990
|
+
return parsed.flavor === "windows" ? parsed.root.toLowerCase() : parsed.root;
|
|
991
|
+
}
|
|
992
|
+
function normalizeHostPath(path) {
|
|
993
|
+
const parsed = parseHostPath(path);
|
|
994
|
+
return parsed === null ? null : formatHostPath(parsed);
|
|
995
|
+
}
|
|
996
|
+
function getHostPathComparisonKey(path) {
|
|
997
|
+
const parsed = parseHostPath(path);
|
|
998
|
+
if (parsed === null) {
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
return formatHostPath({
|
|
1002
|
+
flavor: parsed.flavor,
|
|
1003
|
+
root: comparisonRoot(parsed),
|
|
1004
|
+
segments: comparisonSegments(parsed)
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
function isHostPathWithin({
|
|
1008
|
+
rootPath,
|
|
1009
|
+
candidatePath
|
|
1010
|
+
}) {
|
|
1011
|
+
const root = parseHostPath(rootPath);
|
|
1012
|
+
const candidate = parseHostPath(candidatePath);
|
|
1013
|
+
if (root === null || candidate === null || root.flavor !== candidate.flavor || comparisonRoot(root) !== comparisonRoot(candidate)) {
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
const rootSegments = comparisonSegments(root);
|
|
1017
|
+
const candidateSegments = comparisonSegments(candidate);
|
|
1018
|
+
return rootSegments.length <= candidateSegments.length && rootSegments.every((segment, index) => segment === candidateSegments[index]);
|
|
1019
|
+
}
|
|
1020
|
+
function joinHostPath({
|
|
1021
|
+
rootPath,
|
|
1022
|
+
relativePath
|
|
1023
|
+
}) {
|
|
1024
|
+
const parsed = parseHostPath(rootPath);
|
|
1025
|
+
if (parsed === null) {
|
|
1026
|
+
return null;
|
|
1027
|
+
}
|
|
1028
|
+
const relativeSegments = relativePath.split(
|
|
1029
|
+
parsed.flavor === "windows" ? WINDOWS_SEPARATOR_PATTERN : "/"
|
|
1030
|
+
);
|
|
1031
|
+
return formatHostPath({
|
|
1032
|
+
...parsed,
|
|
1033
|
+
segments: collapseSegments([...parsed.segments, ...relativeSegments])
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
function resolveHostPath({
|
|
1037
|
+
rootPath,
|
|
1038
|
+
path
|
|
1039
|
+
}) {
|
|
1040
|
+
if (path.length === 0 || path.includes("\0") || rootPath.includes("\0")) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
const absolute = normalizeHostPath(path);
|
|
1044
|
+
if (absolute !== null) return absolute;
|
|
1045
|
+
if (path.startsWith("\\") || /^[A-Za-z]:/u.test(path)) return null;
|
|
1046
|
+
return joinHostPath({ rootPath, relativePath: path });
|
|
1047
|
+
}
|
|
1048
|
+
function getHostPathDirname(path) {
|
|
1049
|
+
const parsed = parseHostPath(path);
|
|
1050
|
+
if (parsed === null) {
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
return formatHostPath({ ...parsed, segments: parsed.segments.slice(0, -1) });
|
|
1054
|
+
}
|
|
1055
|
+
function getHostPathBasename(path) {
|
|
1056
|
+
const parsed = parseHostPath(path);
|
|
1057
|
+
if (parsed === null) {
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
return parsed.segments.at(-1) ?? "";
|
|
1061
|
+
}
|
|
1062
|
+
function getRelativeHostPath({
|
|
1063
|
+
rootPath,
|
|
1064
|
+
candidatePath
|
|
1065
|
+
}) {
|
|
1066
|
+
if (!isHostPathWithin({ rootPath, candidatePath })) {
|
|
1067
|
+
return null;
|
|
1068
|
+
}
|
|
1069
|
+
const rootSegments = parseHostPath(rootPath)?.segments ?? [];
|
|
1070
|
+
const candidateSegments = parseHostPath(candidatePath)?.segments ?? [];
|
|
1071
|
+
return candidateSegments.slice(rootSegments.length).join("/");
|
|
1072
|
+
}
|
|
921
1073
|
export {
|
|
922
1074
|
PLUGIN_CLI_OUTPUT_MAX_BYTES,
|
|
923
1075
|
PluginCliError,
|
|
@@ -930,5 +1082,13 @@ export {
|
|
|
930
1082
|
experimental_THREAD_CONTEXT_SEGMENT_GROUPS,
|
|
931
1083
|
experimental_THREAD_INFO_ROW_GROUPS,
|
|
932
1084
|
experimental_THREAD_INFO_SECTION_GROUPS,
|
|
933
|
-
experimental_defineHostEntry
|
|
1085
|
+
experimental_defineHostEntry,
|
|
1086
|
+
getHostPathBasename as experimental_getHostPathBasename,
|
|
1087
|
+
getHostPathComparisonKey as experimental_getHostPathComparisonKey,
|
|
1088
|
+
getHostPathDirname as experimental_getHostPathDirname,
|
|
1089
|
+
getRelativeHostPath as experimental_getRelativeHostPath,
|
|
1090
|
+
isHostPathWithin as experimental_isHostPathWithin,
|
|
1091
|
+
joinHostPath as experimental_joinHostPath,
|
|
1092
|
+
normalizeHostPath as experimental_normalizeHostPath,
|
|
1093
|
+
resolveHostPath as experimental_resolveHostPath
|
|
934
1094
|
};
|
|
@@ -484,6 +484,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
484
484
|
homepageSections: [],
|
|
485
485
|
settingsSections: [],
|
|
486
486
|
appOverlays: [],
|
|
487
|
+
setupGuideSections: [],
|
|
487
488
|
navPanels: [],
|
|
488
489
|
tabs: [],
|
|
489
490
|
get threadPanelActions() {
|
|
@@ -528,6 +529,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
528
529
|
homepageSection: /* @__PURE__ */ new Set(),
|
|
529
530
|
settingsSection: /* @__PURE__ */ new Set(),
|
|
530
531
|
appOverlay: /* @__PURE__ */ new Set(),
|
|
532
|
+
setupGuideSection: /* @__PURE__ */ new Set(),
|
|
531
533
|
navPanel: /* @__PURE__ */ new Set(),
|
|
532
534
|
tab: /* @__PURE__ */ new Set(),
|
|
533
535
|
newThreadPanelAction: /* @__PURE__ */ new Set(),
|
|
@@ -730,6 +732,15 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
730
732
|
component: requireComponent(kind, registration.component)
|
|
731
733
|
});
|
|
732
734
|
},
|
|
735
|
+
internal_DO_NOT_USE_setupGuideSection(registration) {
|
|
736
|
+
const kind = "slots.internal_DO_NOT_USE_setupGuideSection";
|
|
737
|
+
const id = requireSlotId(kind, registration?.id);
|
|
738
|
+
requireUniqueId(kind, seenIds.setupGuideSection, id);
|
|
739
|
+
collected.setupGuideSections.push({
|
|
740
|
+
id,
|
|
741
|
+
component: requireComponent(kind, registration.component)
|
|
742
|
+
});
|
|
743
|
+
},
|
|
733
744
|
navPanel(registration) {
|
|
734
745
|
const kind = "slots.navPanel";
|
|
735
746
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -1752,7 +1752,8 @@ var queuedMessageWaitingOnKindValues = [
|
|
|
1752
1752
|
"provisioning",
|
|
1753
1753
|
"host-offline",
|
|
1754
1754
|
"interaction",
|
|
1755
|
-
"plugin"
|
|
1755
|
+
"plugin",
|
|
1756
|
+
"superseded"
|
|
1756
1757
|
];
|
|
1757
1758
|
var queuedMessageWaitingOnKindSchema = z9.enum(
|
|
1758
1759
|
queuedMessageWaitingOnKindValues
|
|
@@ -1775,7 +1776,8 @@ var queuedMessageWaitingOnSchema = z9.discriminatedUnion("kind", [
|
|
|
1775
1776
|
kind: z9.literal("plugin"),
|
|
1776
1777
|
pluginId: pluginIdSchema,
|
|
1777
1778
|
reason: queuedMessageWaitReasonSchema
|
|
1778
|
-
})
|
|
1779
|
+
}),
|
|
1780
|
+
z9.object({ kind: z9.literal("superseded") })
|
|
1779
1781
|
]);
|
|
1780
1782
|
var QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH = 200;
|
|
1781
1783
|
var queuedMessageFailureReasonSchema = z9.string().min(1).max(QUEUED_MESSAGE_FAILURE_REASON_MAX_LENGTH);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/internal/thread-status.ts
|
|
2
|
+
var INDICATOR_LABELS = {
|
|
3
|
+
"unread-error": "Unread thread failed",
|
|
4
|
+
"waiting-for-input": "Thread needs user input",
|
|
5
|
+
"working-draft": "Thread working with unsubmitted draft",
|
|
6
|
+
workflow: "Workflow running",
|
|
7
|
+
"background-agent": "Background agent running",
|
|
8
|
+
"background-command": "Background command running",
|
|
9
|
+
"plan-mode": "Plan mode active",
|
|
10
|
+
goal: "Goal active",
|
|
11
|
+
runtime: "Thread working",
|
|
12
|
+
"queued-failed": "Queued message failed to send",
|
|
13
|
+
"queued-waiting": "Thread has a message waiting to send",
|
|
14
|
+
draft: "Thread has unsubmitted draft",
|
|
15
|
+
"unread-success": "Unread thread succeeded"
|
|
16
|
+
};
|
|
17
|
+
var RUNNING_RUNTIME_STATUSES = {
|
|
18
|
+
active: true,
|
|
19
|
+
provisioning: true,
|
|
20
|
+
starting: true,
|
|
21
|
+
stopping: true,
|
|
22
|
+
error: false,
|
|
23
|
+
idle: false,
|
|
24
|
+
pending: false,
|
|
25
|
+
"waiting-for-host": false
|
|
26
|
+
};
|
|
27
|
+
var DONE_THREAD_STATUSES = {
|
|
28
|
+
error: true,
|
|
29
|
+
idle: true,
|
|
30
|
+
active: false,
|
|
31
|
+
starting: false,
|
|
32
|
+
stopping: false,
|
|
33
|
+
pending: false
|
|
34
|
+
};
|
|
35
|
+
var INDICATORS_OVER_ROW_STATUS = /* @__PURE__ */ new Set(["runtime", "unread-error", "waiting-for-input"]);
|
|
36
|
+
function threadIndicatorLabel(indicator) {
|
|
37
|
+
return indicator === "none" ? null : INDICATOR_LABELS[indicator];
|
|
38
|
+
}
|
|
39
|
+
function visibleThreadRowStatus(indicator, rowStatus) {
|
|
40
|
+
return INDICATORS_OVER_ROW_STATUS.has(indicator) ? null : rowStatus;
|
|
41
|
+
}
|
|
42
|
+
function isUnreadDoneThread(thread) {
|
|
43
|
+
return thread.parentThreadId === null && thread.isUnread && DONE_THREAD_STATUSES[thread.status];
|
|
44
|
+
}
|
|
45
|
+
function addThreadFlags(flags, thread) {
|
|
46
|
+
const unreadDone = isUnreadDoneThread(thread);
|
|
47
|
+
flags.pending ||= thread.hasPendingInteraction;
|
|
48
|
+
flags.unreadError ||= unreadDone && thread.status === "error";
|
|
49
|
+
flags.unreadSuccess ||= unreadDone && thread.status !== "error";
|
|
50
|
+
flags.runtime ||= RUNNING_RUNTIME_STATUSES[thread.runtimeStatus];
|
|
51
|
+
flags.workflow ||= thread.activity.workflows > 0;
|
|
52
|
+
flags.backgroundAgent ||= thread.activity.backgroundAgents > 0;
|
|
53
|
+
flags.backgroundCommand ||= thread.activity.backgroundCommands > 0;
|
|
54
|
+
flags.planMode ||= thread.activity.planMode > 0;
|
|
55
|
+
flags.goal ||= thread.activity.goals > 0;
|
|
56
|
+
}
|
|
57
|
+
function resolveIndicator(flags, queuedWork, hasUnsubmittedDraft, isWorking) {
|
|
58
|
+
if (flags.unreadError) return "unread-error";
|
|
59
|
+
if (flags.pending) return "waiting-for-input";
|
|
60
|
+
if (hasUnsubmittedDraft && isWorking) return "working-draft";
|
|
61
|
+
if (flags.planMode) return "plan-mode";
|
|
62
|
+
if (flags.goal) return "goal";
|
|
63
|
+
if (flags.runtime) return "runtime";
|
|
64
|
+
if (flags.workflow) return "workflow";
|
|
65
|
+
if (queuedWork === "failed") return "queued-failed";
|
|
66
|
+
if (flags.unreadSuccess) return "unread-success";
|
|
67
|
+
if (flags.backgroundAgent) return "background-agent";
|
|
68
|
+
if (flags.backgroundCommand) return "background-command";
|
|
69
|
+
if (queuedWork === "waiting") return "queued-waiting";
|
|
70
|
+
if (hasUnsubmittedDraft) return "draft";
|
|
71
|
+
return "none";
|
|
72
|
+
}
|
|
73
|
+
function experimental_resolveThreadStatus({
|
|
74
|
+
thread,
|
|
75
|
+
hiddenThreads,
|
|
76
|
+
hasUnsubmittedDraft,
|
|
77
|
+
rowStatus
|
|
78
|
+
}) {
|
|
79
|
+
const flags = {
|
|
80
|
+
pending: false,
|
|
81
|
+
unreadError: false,
|
|
82
|
+
unreadSuccess: false,
|
|
83
|
+
runtime: false,
|
|
84
|
+
workflow: false,
|
|
85
|
+
backgroundAgent: false,
|
|
86
|
+
backgroundCommand: false,
|
|
87
|
+
planMode: false,
|
|
88
|
+
goal: false
|
|
89
|
+
};
|
|
90
|
+
if (thread !== null) addThreadFlags(flags, thread);
|
|
91
|
+
for (const hiddenThread of hiddenThreads) addThreadFlags(flags, hiddenThread);
|
|
92
|
+
const isThreadWorking = flags.runtime || flags.workflow || flags.backgroundAgent || flags.backgroundCommand || flags.planMode || flags.goal;
|
|
93
|
+
const indicator = resolveIndicator(
|
|
94
|
+
flags,
|
|
95
|
+
thread?.queuedWork ?? "none",
|
|
96
|
+
hasUnsubmittedDraft,
|
|
97
|
+
isThreadWorking
|
|
98
|
+
);
|
|
99
|
+
const shownRowStatus = visibleThreadRowStatus(indicator, rowStatus);
|
|
100
|
+
return {
|
|
101
|
+
indicator,
|
|
102
|
+
rowStatus: shownRowStatus,
|
|
103
|
+
label: shownRowStatus?.label ?? threadIndicatorLabel(indicator),
|
|
104
|
+
isWorking: isThreadWorking || rowStatus?.tone === "running"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
experimental_resolveThreadStatus,
|
|
109
|
+
threadIndicatorLabel,
|
|
110
|
+
visibleThreadRowStatus
|
|
111
|
+
};
|
|
@@ -15058,7 +15058,7 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15058
15058
|
};
|
|
15059
15059
|
}
|
|
15060
15060
|
function commandCloseFields(event, status) {
|
|
15061
|
-
const normalizedEvent = dialect.normalizeCommandEvent?.(event) ?? event;
|
|
15061
|
+
const normalizedEvent = dialect.normalizeCommandEvent?.(event, event) ?? event;
|
|
15062
15062
|
const result = dialect.commandResult?.(normalizedEvent) ?? extractAcpCommandResult(normalizedEvent);
|
|
15063
15063
|
const exitCode = result.exitCode ?? (status === "failed" ? 1 : void 0);
|
|
15064
15064
|
return {
|
|
@@ -15067,7 +15067,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15067
15067
|
};
|
|
15068
15068
|
}
|
|
15069
15069
|
function genericCloseFields(event) {
|
|
15070
|
-
const
|
|
15070
|
+
const normalizedEvent = dialect.normalizeToolCallEvent?.(event, event) ?? event;
|
|
15071
|
+
const outputText = extractAcpToolCallOutputText(normalizedEvent);
|
|
15071
15072
|
return outputText === void 0 ? {} : { resultText: outputText };
|
|
15072
15073
|
}
|
|
15073
15074
|
function drainOpenToolCalls(context, status) {
|
|
@@ -15206,7 +15207,7 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15206
15207
|
...open?.clientFileWrites === void 0 ? {} : { clientFileWrites: open.clientFileWrites }
|
|
15207
15208
|
});
|
|
15208
15209
|
if (event.status === "in_progress" && mergedType === "command" && open?.openedType === "command") {
|
|
15209
|
-
const normalizedEvent = dialect.normalizeCommandEvent?.(event) ?? event;
|
|
15210
|
+
const normalizedEvent = dialect.normalizeCommandEvent?.(event, merged) ?? event;
|
|
15210
15211
|
const streamed = extractAcpStreamedCommandOutput(normalizedEvent);
|
|
15211
15212
|
return streamed === void 0 ? suppressedUnhandled(rawEvent) : [
|
|
15212
15213
|
{
|
|
@@ -15216,7 +15217,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15216
15217
|
}
|
|
15217
15218
|
];
|
|
15218
15219
|
}
|
|
15219
|
-
const
|
|
15220
|
+
const progressEvent = dialect.normalizeToolCallEvent?.(event, merged) ?? event;
|
|
15221
|
+
const progressText = extractAcpToolCallOutputText(progressEvent);
|
|
15220
15222
|
if (progressText === void 0) {
|
|
15221
15223
|
return suppressedUnhandled(rawEvent);
|
|
15222
15224
|
}
|
|
@@ -22910,24 +22912,30 @@ async function discoverAcpNativeModelSupport(args) {
|
|
|
22910
22912
|
for (const model of modelsToProbe) {
|
|
22911
22913
|
if (timedOut) break;
|
|
22912
22914
|
try {
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
|
|
22929
|
-
|
|
22930
|
-
|
|
22915
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
22916
|
+
const configState = await args.connection.request({
|
|
22917
|
+
method: "session/set_config_option",
|
|
22918
|
+
params: {
|
|
22919
|
+
sessionId: args.sessionId,
|
|
22920
|
+
configId: modelOption.id,
|
|
22921
|
+
value: model.value
|
|
22922
|
+
},
|
|
22923
|
+
resultSchema: acpConfigStateResultSchema
|
|
22924
|
+
});
|
|
22925
|
+
if (timedOut) break;
|
|
22926
|
+
if (findAcpModelConfigOption(configState.configOptions)?.currentValue !== model.value) {
|
|
22927
|
+
continue;
|
|
22928
|
+
}
|
|
22929
|
+
supportByModel.set(model.value, {
|
|
22930
|
+
...buildAcpNativeReasoningSupport(
|
|
22931
|
+
findAcpThoughtLevelConfigOption(configState.configOptions)
|
|
22932
|
+
),
|
|
22933
|
+
supportedServiceTiers: findAcpFastConfigOption(
|
|
22934
|
+
configState.configOptions
|
|
22935
|
+
)?.options?.some((option) => option.value === "true") ? [{ id: "fast" }] : []
|
|
22936
|
+
});
|
|
22937
|
+
break;
|
|
22938
|
+
}
|
|
22931
22939
|
} catch (error) {
|
|
22932
22940
|
if (timedOut) {
|
|
22933
22941
|
break;
|
|
@@ -15058,7 +15058,7 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15058
15058
|
};
|
|
15059
15059
|
}
|
|
15060
15060
|
function commandCloseFields(event, status) {
|
|
15061
|
-
const normalizedEvent = dialect.normalizeCommandEvent?.(event) ?? event;
|
|
15061
|
+
const normalizedEvent = dialect.normalizeCommandEvent?.(event, event) ?? event;
|
|
15062
15062
|
const result = dialect.commandResult?.(normalizedEvent) ?? extractAcpCommandResult(normalizedEvent);
|
|
15063
15063
|
const exitCode = result.exitCode ?? (status === "failed" ? 1 : void 0);
|
|
15064
15064
|
return {
|
|
@@ -15067,7 +15067,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15067
15067
|
};
|
|
15068
15068
|
}
|
|
15069
15069
|
function genericCloseFields(event) {
|
|
15070
|
-
const
|
|
15070
|
+
const normalizedEvent = dialect.normalizeToolCallEvent?.(event, event) ?? event;
|
|
15071
|
+
const outputText = extractAcpToolCallOutputText(normalizedEvent);
|
|
15071
15072
|
return outputText === void 0 ? {} : { resultText: outputText };
|
|
15072
15073
|
}
|
|
15073
15074
|
function drainOpenToolCalls(context, status) {
|
|
@@ -15206,7 +15207,7 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15206
15207
|
...open?.clientFileWrites === void 0 ? {} : { clientFileWrites: open.clientFileWrites }
|
|
15207
15208
|
});
|
|
15208
15209
|
if (event.status === "in_progress" && mergedType === "command" && open?.openedType === "command") {
|
|
15209
|
-
const normalizedEvent = dialect.normalizeCommandEvent?.(event) ?? event;
|
|
15210
|
+
const normalizedEvent = dialect.normalizeCommandEvent?.(event, merged) ?? event;
|
|
15210
15211
|
const streamed = extractAcpStreamedCommandOutput(normalizedEvent);
|
|
15211
15212
|
return streamed === void 0 ? suppressedUnhandled(rawEvent) : [
|
|
15212
15213
|
{
|
|
@@ -15216,7 +15217,8 @@ function createAcpDeltaTranslator(options = {}) {
|
|
|
15216
15217
|
}
|
|
15217
15218
|
];
|
|
15218
15219
|
}
|
|
15219
|
-
const
|
|
15220
|
+
const progressEvent = dialect.normalizeToolCallEvent?.(event, merged) ?? event;
|
|
15221
|
+
const progressText = extractAcpToolCallOutputText(progressEvent);
|
|
15220
15222
|
if (progressText === void 0) {
|
|
15221
15223
|
return suppressedUnhandled(rawEvent);
|
|
15222
15224
|
}
|
|
@@ -22910,24 +22912,30 @@ async function discoverAcpNativeModelSupport(args) {
|
|
|
22910
22912
|
for (const model of modelsToProbe) {
|
|
22911
22913
|
if (timedOut) break;
|
|
22912
22914
|
try {
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
|
|
22929
|
-
|
|
22930
|
-
|
|
22915
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
22916
|
+
const configState = await args.connection.request({
|
|
22917
|
+
method: "session/set_config_option",
|
|
22918
|
+
params: {
|
|
22919
|
+
sessionId: args.sessionId,
|
|
22920
|
+
configId: modelOption.id,
|
|
22921
|
+
value: model.value
|
|
22922
|
+
},
|
|
22923
|
+
resultSchema: acpConfigStateResultSchema
|
|
22924
|
+
});
|
|
22925
|
+
if (timedOut) break;
|
|
22926
|
+
if (findAcpModelConfigOption(configState.configOptions)?.currentValue !== model.value) {
|
|
22927
|
+
continue;
|
|
22928
|
+
}
|
|
22929
|
+
supportByModel.set(model.value, {
|
|
22930
|
+
...buildAcpNativeReasoningSupport(
|
|
22931
|
+
findAcpThoughtLevelConfigOption(configState.configOptions)
|
|
22932
|
+
),
|
|
22933
|
+
supportedServiceTiers: findAcpFastConfigOption(
|
|
22934
|
+
configState.configOptions
|
|
22935
|
+
)?.options?.some((option) => option.value === "true") ? [{ id: "fast" }] : []
|
|
22936
|
+
});
|
|
22937
|
+
break;
|
|
22938
|
+
}
|
|
22931
22939
|
} catch (error) {
|
|
22932
22940
|
if (timedOut) {
|
|
22933
22941
|
break;
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
* STALL_MS is answered with a generic success, and a child past the end of its
|
|
34
34
|
* segment answers everything generically. Both are logged on stderr.
|
|
35
35
|
*/
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
36
|
+
import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
|
|
37
|
+
import { connect } from "node:net";
|
|
38
38
|
import { StringDecoder } from "node:string_decoder";
|
|
39
39
|
import { join } from "node:path";
|
|
40
40
|
|
|
@@ -159,15 +159,15 @@ const DIALECTS = {
|
|
|
159
159
|
* `pi --mode rpc`: commands carry `{ id, type }`, responses are
|
|
160
160
|
* `{ id, type: "response", command, success }`, and every other line is a
|
|
161
161
|
* raw AgentSessionEvent (or an `extension_ui_request`). The bb extension's
|
|
162
|
-
* channel (
|
|
163
|
-
* same lanes wrapped as `{ bbChannel: <message> }`; this
|
|
164
|
-
* those back onto
|
|
162
|
+
* channel (the socket the bridge names in `BB_PI_BRIDGE_CHANNEL`) is
|
|
163
|
+
* recorded on the same lanes wrapped as `{ bbChannel: <message> }`; this
|
|
164
|
+
* dialect routes those back onto that socket.
|
|
165
165
|
*/
|
|
166
166
|
"pi-rpc": {
|
|
167
167
|
channel: {
|
|
168
168
|
key: "bbChannel",
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
addressEnv: "BB_PI_BRIDGE_CHANNEL",
|
|
170
|
+
tokenEnv: "BB_PI_BRIDGE_CHANNEL_TOKEN",
|
|
171
171
|
},
|
|
172
172
|
classify(message) {
|
|
173
173
|
const channel = message.bbChannel;
|
|
@@ -353,6 +353,14 @@ function readNewlineDelimitedLines(input, onLine) {
|
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
+
function connectChannel(channel) {
|
|
357
|
+
const socket = connect(process.env[channel.addressEnv]);
|
|
358
|
+
socket.on("error", () => {});
|
|
359
|
+
socket.unref();
|
|
360
|
+
socket.write(`${process.env[channel.tokenEnv]}\n`);
|
|
361
|
+
return socket;
|
|
362
|
+
}
|
|
363
|
+
|
|
356
364
|
// ---------------------------------------------------------------------------
|
|
357
365
|
// Player
|
|
358
366
|
// ---------------------------------------------------------------------------
|
|
@@ -381,14 +389,11 @@ function servePiCatalog(entries) {
|
|
|
381
389
|
}
|
|
382
390
|
}
|
|
383
391
|
}
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
channelIn.on("error", () => {});
|
|
387
|
-
channelIn.unref();
|
|
388
|
-
readNewlineDelimitedLines(channelIn, (line) => {
|
|
392
|
+
const channel = connectChannel(DIALECTS["pi-rpc"].channel);
|
|
393
|
+
readNewlineDelimitedLines(channel, (line) => {
|
|
389
394
|
const message = parseLine(line);
|
|
390
395
|
if (message?.kind !== "request" || message.method !== "model-scope") return;
|
|
391
|
-
|
|
396
|
+
channel.write(
|
|
392
397
|
`${JSON.stringify({
|
|
393
398
|
kind: "reply",
|
|
394
399
|
id: message.id,
|
|
@@ -471,10 +476,10 @@ function main() {
|
|
|
471
476
|
let emitTimer = null;
|
|
472
477
|
|
|
473
478
|
const channel = dialect.channel ?? null;
|
|
474
|
-
const
|
|
479
|
+
const channelSocket = channel ? connectChannel(channel) : null;
|
|
475
480
|
function emit(message) {
|
|
476
481
|
if (channel && typeof message[channel.key] === "object" && message[channel.key] !== null) {
|
|
477
|
-
|
|
482
|
+
channelSocket.write(`${JSON.stringify(message[channel.key])}\n`);
|
|
478
483
|
return;
|
|
479
484
|
}
|
|
480
485
|
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
@@ -710,13 +715,7 @@ function main() {
|
|
|
710
715
|
process.exit(0);
|
|
711
716
|
});
|
|
712
717
|
if (channel) {
|
|
713
|
-
|
|
714
|
-
// their own fd; wrap them the way the recorder did so they match. A
|
|
715
|
-
// net.Socket reads the pipe non-blockingly, as the real extension does.
|
|
716
|
-
const channelIn = new Socket({ fd: channel.bridgeToChildFd, readable: true, writable: false });
|
|
717
|
-
channelIn.on("error", () => {});
|
|
718
|
-
channelIn.unref();
|
|
719
|
-
readNewlineDelimitedLines(channelIn, (line) => {
|
|
718
|
+
readNewlineDelimitedLines(channelSocket, (line) => {
|
|
720
719
|
const message = parseLine(line);
|
|
721
720
|
if (message !== null) onLiveMessage({ [channel.key]: message });
|
|
722
721
|
});
|