@get-bb/plugin-sdk 0.6.89 → 0.6.94
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 +157 -83
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +14 -3
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +8 -1
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +18 -2
- package/bundled-types/bb-plugin-sdk.d.ts +152 -82
- package/dist/app.js +16 -0
- package/dist/host.js +93 -1
- package/dist/internal/plugin-app-collector.js +29 -10
- package/dist/internal/rpc-query-host.js +130 -84
- package/dist/process.js +100 -3
- package/dist/provider-bridge-acp-next.js +133 -22
- package/dist/provider-bridge-acp.js +133 -22
- package/dist/provider-bridge-testing.js +95 -5
- package/dist/provider-bridge-worker-entry.mjs +93 -1
- package/dist/provider-bridge.js +95 -5
- package/dist/testing/app.js +172 -97
- package/package.json +3 -3
package/dist/host.js
CHANGED
|
@@ -906,6 +906,97 @@ function whichCommandSync(command, options = {}) {
|
|
|
906
906
|
return void 0;
|
|
907
907
|
}
|
|
908
908
|
|
|
909
|
+
// ../process-utils/src/node-network.ts
|
|
910
|
+
var NODE_NETWORK_FLAGS = {
|
|
911
|
+
"--use-system-ca": "NODE_USE_SYSTEM_CA",
|
|
912
|
+
"--use-env-proxy": "NODE_USE_ENV_PROXY"
|
|
913
|
+
};
|
|
914
|
+
var ENV_PROXY_FLAG = "--use-env-proxy";
|
|
915
|
+
var PROXY_KEYS = /* @__PURE__ */ new Set(["HTTP_PROXY", "HTTPS_PROXY"]);
|
|
916
|
+
var NO_PROXY_KEY = "NO_PROXY";
|
|
917
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
918
|
+
function isNodeNetworkFlag(arg) {
|
|
919
|
+
return Object.hasOwn(NODE_NETWORK_FLAGS, arg);
|
|
920
|
+
}
|
|
921
|
+
function isHttpProxyUrl(value) {
|
|
922
|
+
if (/[\r\n]/u.test(value)) return false;
|
|
923
|
+
try {
|
|
924
|
+
const url = new URL(value);
|
|
925
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.hostname !== "";
|
|
926
|
+
} catch {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function proxyEntries(env) {
|
|
931
|
+
return Object.entries(env).filter(
|
|
932
|
+
(entry) => PROXY_KEYS.has(entry[0].toUpperCase()) && entry[1] !== void 0 && entry[1] !== ""
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function appendLoopback(value) {
|
|
936
|
+
const entries = value.split(/[\s,]+/u).filter(Boolean);
|
|
937
|
+
if (entries.includes("*")) return value;
|
|
938
|
+
const present = new Set(entries.map((entry) => entry.toLowerCase()));
|
|
939
|
+
return [
|
|
940
|
+
...entries,
|
|
941
|
+
...LOOPBACK_HOSTS.filter((host) => !present.has(host))
|
|
942
|
+
].join(",");
|
|
943
|
+
}
|
|
944
|
+
function withLoopbackNoProxy(env) {
|
|
945
|
+
const result = { ...env };
|
|
946
|
+
const keys = Object.keys(result).filter(
|
|
947
|
+
(key) => key.toUpperCase() === NO_PROXY_KEY && result[key] !== void 0
|
|
948
|
+
);
|
|
949
|
+
for (const key of keys.length > 0 ? keys : [NO_PROXY_KEY])
|
|
950
|
+
result[key] = appendLoopback(result[key] ?? "");
|
|
951
|
+
return result;
|
|
952
|
+
}
|
|
953
|
+
function nodeNetworkLaunch(nodeArgs, env) {
|
|
954
|
+
const enabled = nodeArgs.filter(
|
|
955
|
+
(arg) => !isNodeNetworkFlag(arg) || env[NODE_NETWORK_FLAGS[arg]] !== "0"
|
|
956
|
+
);
|
|
957
|
+
if (!enabled.includes(ENV_PROXY_FLAG))
|
|
958
|
+
return { nodeArgs: enabled, env, rejectedProxyKeys: [] };
|
|
959
|
+
const proxies = proxyEntries(env);
|
|
960
|
+
const rejectedProxyKeys = proxies.filter(([, value]) => !isHttpProxyUrl(value)).map(([key]) => key);
|
|
961
|
+
if (rejectedProxyKeys.length > 0)
|
|
962
|
+
return {
|
|
963
|
+
nodeArgs: enabled.filter((arg) => arg !== ENV_PROXY_FLAG),
|
|
964
|
+
env,
|
|
965
|
+
rejectedProxyKeys
|
|
966
|
+
};
|
|
967
|
+
return {
|
|
968
|
+
nodeArgs: enabled,
|
|
969
|
+
env: proxies.length > 0 ? withLoopbackNoProxy(env) : env,
|
|
970
|
+
rejectedProxyKeys: []
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
var warnedProxyKeys = /* @__PURE__ */ new Set();
|
|
974
|
+
function prepareNodeNetworkLaunch(nodeArgs, env) {
|
|
975
|
+
const launch = nodeNetworkLaunch(nodeArgs, env);
|
|
976
|
+
const unwarned = launch.rejectedProxyKeys.filter(
|
|
977
|
+
(key) => !warnedProxyKeys.has(key)
|
|
978
|
+
);
|
|
979
|
+
if (unwarned.length > 0) {
|
|
980
|
+
for (const key of unwarned) warnedProxyKeys.add(key);
|
|
981
|
+
process.emitWarning(
|
|
982
|
+
`bb started a Node process without --use-env-proxy because ${unwarned.join(", ")} is not an http:// or https:// URL. Add the scheme, for example http://proxy.example:3128, so bb uses the proxy.`,
|
|
983
|
+
{ code: "BB_INVALID_PROXY_ENV" }
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
return { nodeArgs: launch.nodeArgs, env: launch.env };
|
|
987
|
+
}
|
|
988
|
+
function prepareNodeNetworkCommand(args, env) {
|
|
989
|
+
const scriptIndex = args.findIndex(
|
|
990
|
+
(arg) => arg === "--" || !arg.startsWith("-")
|
|
991
|
+
);
|
|
992
|
+
const optionCount = scriptIndex < 0 ? args.length : scriptIndex;
|
|
993
|
+
const launch = prepareNodeNetworkLaunch(args.slice(0, optionCount), env);
|
|
994
|
+
return {
|
|
995
|
+
args: [...launch.nodeArgs, ...args.slice(optionCount)],
|
|
996
|
+
env: launch.env
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
|
|
909
1000
|
// ../process-utils/src/host-toolchain.ts
|
|
910
1001
|
var NETWORK_KEYS = [
|
|
911
1002
|
"HTTP_PROXY",
|
|
@@ -1266,7 +1357,8 @@ var HostToolchain = class {
|
|
|
1266
1357
|
if (/(?:^|[\\/])(?:npm|npx)-cli\.js$/u.test(args[0] ?? "")) {
|
|
1267
1358
|
env.PATH = mergePath(dirname(file), env.PATH);
|
|
1268
1359
|
}
|
|
1269
|
-
|
|
1360
|
+
const network = prepareNodeNetworkCommand(args, env);
|
|
1361
|
+
return { command: file, args: network.args, env: network.env };
|
|
1270
1362
|
}
|
|
1271
1363
|
};
|
|
1272
1364
|
var toolchainKey = /* @__PURE__ */ Symbol.for("@bb/process-utils/host-toolchain");
|
|
@@ -501,6 +501,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
501
501
|
threadHeaderActions: [],
|
|
502
502
|
threadContextSegments: [],
|
|
503
503
|
threadInfoRows: [],
|
|
504
|
+
threadRowMetadata: [],
|
|
504
505
|
threadInfoSections: [],
|
|
505
506
|
threadActions: [],
|
|
506
507
|
browserToolbarActions: [],
|
|
@@ -537,6 +538,7 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
537
538
|
threadHeaderAction: /* @__PURE__ */ new Set(),
|
|
538
539
|
threadContextSegment: /* @__PURE__ */ new Set(),
|
|
539
540
|
threadInfoRow: /* @__PURE__ */ new Set(),
|
|
541
|
+
threadRowMetadata: /* @__PURE__ */ new Set(),
|
|
540
542
|
threadInfoSection: /* @__PURE__ */ new Set(),
|
|
541
543
|
threadAction: /* @__PURE__ */ new Set(),
|
|
542
544
|
browserToolbarAction: /* @__PURE__ */ new Set(),
|
|
@@ -657,6 +659,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
657
659
|
onWarning(`Legacy threadPanelAction ignored: ${String(error)}`);
|
|
658
660
|
}
|
|
659
661
|
},
|
|
662
|
+
experimental_threadHeaderAction(registration) {
|
|
663
|
+
const kind = "slots.experimental_threadHeaderAction";
|
|
664
|
+
const id = requireSlotId(kind, registration?.id);
|
|
665
|
+
requireUniqueId(kind, seenIds.threadHeaderAction, id);
|
|
666
|
+
collected.threadHeaderActions.push({
|
|
667
|
+
id,
|
|
668
|
+
title: requireNonEmptyString(kind, "title", registration.title),
|
|
669
|
+
component: requireComponent(kind, registration.component)
|
|
670
|
+
});
|
|
671
|
+
},
|
|
660
672
|
experimental_sidebarHeader(registration) {
|
|
661
673
|
legacySidebarHeaders.push(
|
|
662
674
|
collectTitledComponent(
|
|
@@ -862,16 +874,6 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
862
874
|
...headerComponent !== void 0 ? { headerComponent } : {}
|
|
863
875
|
});
|
|
864
876
|
},
|
|
865
|
-
experimental_threadHeaderAction(registration) {
|
|
866
|
-
const kind = "slots.experimental_threadHeaderAction";
|
|
867
|
-
const id = requireSlotId(kind, registration?.id);
|
|
868
|
-
requireUniqueId(kind, seenIds.threadHeaderAction, id);
|
|
869
|
-
collected.threadHeaderActions.push({
|
|
870
|
-
id,
|
|
871
|
-
title: requireNonEmptyString(kind, "title", registration.title),
|
|
872
|
-
component: requireComponent(kind, registration.component)
|
|
873
|
-
});
|
|
874
|
-
},
|
|
875
877
|
experimental_threadContextSegment(registration) {
|
|
876
878
|
const kind = "slots.experimental_threadContextSegment";
|
|
877
879
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -905,6 +907,19 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
905
907
|
...registration.useVisible !== void 0 ? { useVisible: registration.useVisible } : {}
|
|
906
908
|
});
|
|
907
909
|
},
|
|
910
|
+
experimental_threadRowMetadata(registration) {
|
|
911
|
+
const kind = "slots.experimental_threadRowMetadata";
|
|
912
|
+
const id = requireSlotId(kind, registration?.id);
|
|
913
|
+
requireUniqueId(kind, seenIds.threadRowMetadata, id);
|
|
914
|
+
if (registration.useData !== void 0 && typeof registration.useData !== "function")
|
|
915
|
+
throw new Error(`${kind}: "useData" must be a function`);
|
|
916
|
+
collected.threadRowMetadata.push({
|
|
917
|
+
id,
|
|
918
|
+
...requireOptionalOrder(kind, registration.order),
|
|
919
|
+
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
920
|
+
component: requireComponent(kind, registration.component)
|
|
921
|
+
});
|
|
922
|
+
},
|
|
908
923
|
experimental_threadInfoRow(registration) {
|
|
909
924
|
const kind = "slots.experimental_threadInfoRow";
|
|
910
925
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -942,12 +957,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
942
957
|
`${kind}: "experimental_bulkItem" must be a function`
|
|
943
958
|
);
|
|
944
959
|
}
|
|
960
|
+
if (registration.placement !== void 0 && registration.placement !== "menu" && registration.placement !== "header") {
|
|
961
|
+
throw new Error(`${kind}: "placement" must be "menu" or "header"`);
|
|
962
|
+
}
|
|
945
963
|
collected.threadActions.push({
|
|
946
964
|
id,
|
|
947
965
|
title: requireNonEmptyString(kind, "title", registration.title),
|
|
948
966
|
icon: requireNonEmptyString(kind, "icon", registration.icon),
|
|
949
967
|
group: requireNonEmptyString(kind, "group", registration.group),
|
|
950
968
|
...requireOptionalOrder(kind, registration.order),
|
|
969
|
+
...registration.placement !== void 0 ? { placement: registration.placement } : {},
|
|
951
970
|
...registration.useData !== void 0 ? { useData: registration.useData } : {},
|
|
952
971
|
item: registration.item,
|
|
953
972
|
...registration.experimental_bulkItem !== void 0 ? {
|
|
@@ -80,7 +80,7 @@ var experimental_PluginRpcRefusal = class extends Error {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
// src/internal/rpc-query-host.ts
|
|
83
|
-
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
83
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
84
84
|
import { useIsFetching } from "@tanstack/react-query";
|
|
85
85
|
|
|
86
86
|
// ../query-tags/src/index.ts
|
|
@@ -1089,11 +1089,16 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1089
1089
|
registerKeyedView(client, queryKey, keyedRowsView(collection));
|
|
1090
1090
|
const keys = /* @__PURE__ */ new Map();
|
|
1091
1091
|
let readingKeys = /* @__PURE__ */ new Set();
|
|
1092
|
+
let collecting = false;
|
|
1092
1093
|
let missingOnly = false;
|
|
1093
1094
|
let refreshAll = false;
|
|
1094
1095
|
const dirtyKeys = /* @__PURE__ */ new Set();
|
|
1095
|
-
const
|
|
1096
|
-
queueMicrotask(() =>
|
|
1096
|
+
const takeSubscribedKeys = (take) => new Promise((resolve) => {
|
|
1097
|
+
queueMicrotask(() => {
|
|
1098
|
+
readingKeys = new Set(take([...keys.keys()]));
|
|
1099
|
+
collecting = false;
|
|
1100
|
+
resolve([...readingKeys]);
|
|
1101
|
+
});
|
|
1097
1102
|
});
|
|
1098
1103
|
const observer = new QueryObserver(client, {
|
|
1099
1104
|
queryKey,
|
|
@@ -1120,23 +1125,26 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1120
1125
|
const refreshedKeys = /* @__PURE__ */ new Set();
|
|
1121
1126
|
let refreshedAll = false;
|
|
1122
1127
|
return runTaggedRead(client, queryKey, async () => {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1128
|
+
collecting = true;
|
|
1129
|
+
let all = false;
|
|
1130
|
+
const requested = await takeSubscribedKeys((subscribed) => {
|
|
1131
|
+
all = refreshAll || refresh;
|
|
1132
|
+
refresh = false;
|
|
1133
|
+
const dirty = new Set(dirtyKeys);
|
|
1134
|
+
refreshedAll ||= all;
|
|
1135
|
+
if (all)
|
|
1136
|
+
for (const key of Object.keys(previous?.result ?? {}))
|
|
1137
|
+
dirtyKeys.add(key);
|
|
1138
|
+
refreshAll = false;
|
|
1139
|
+
const taken = subscribed.filter(
|
|
1140
|
+
(key) => all || dirty.has(key) || !Object.hasOwn(previous?.result ?? {}, key)
|
|
1141
|
+
);
|
|
1142
|
+
for (const key of taken) {
|
|
1143
|
+
refreshedKeys.add(key);
|
|
1144
|
+
dirtyKeys.delete(key);
|
|
1145
|
+
}
|
|
1146
|
+
return taken;
|
|
1147
|
+
});
|
|
1140
1148
|
const started = tick();
|
|
1141
1149
|
try {
|
|
1142
1150
|
const results = await Promise.all(
|
|
@@ -1192,6 +1200,17 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1192
1200
|
let stop;
|
|
1193
1201
|
return {
|
|
1194
1202
|
observer,
|
|
1203
|
+
async refresh(requested) {
|
|
1204
|
+
const subscribed = requested.filter((key) => keys.has(key));
|
|
1205
|
+
if (subscribed.length === 0) return;
|
|
1206
|
+
const fetching = observer.getCurrentQuery().state.fetchStatus === "fetching";
|
|
1207
|
+
const unread = fetching && !collecting ? subscribed.filter((key) => !readingKeys.has(key)) : subscribed;
|
|
1208
|
+
if (unread.length === 0) return;
|
|
1209
|
+
for (const key of unread) dirtyKeys.add(key);
|
|
1210
|
+
if (fetching && !collecting)
|
|
1211
|
+
restartTaggedRead(observer.getCurrentQuery());
|
|
1212
|
+
await observer.refetch({ cancelRefetch: false });
|
|
1213
|
+
},
|
|
1195
1214
|
subscribe(requested, listener) {
|
|
1196
1215
|
let added = false;
|
|
1197
1216
|
for (const key of requested) {
|
|
@@ -1211,7 +1230,7 @@ function createTaggedKeyedQueryOwner(options) {
|
|
|
1211
1230
|
}
|
|
1212
1231
|
if (added && pending.length > 0) {
|
|
1213
1232
|
if (observer.getCurrentResult().isFetching) {
|
|
1214
|
-
if (
|
|
1233
|
+
if (!collecting && pending.some((key) => !readingKeys.has(key)))
|
|
1215
1234
|
restartTaggedRead(observer.getCurrentQuery());
|
|
1216
1235
|
} else {
|
|
1217
1236
|
missingOnly = true;
|
|
@@ -1500,11 +1519,15 @@ var projectExecutionDefaultsSchema = z2.object({
|
|
|
1500
1519
|
permissionMode: permissionModeSchema
|
|
1501
1520
|
});
|
|
1502
1521
|
|
|
1522
|
+
// ../domain/src/plugin-id.ts
|
|
1523
|
+
import { z as z3 } from "zod";
|
|
1524
|
+
var pluginIdSchema = z3.string().regex(/^[a-z0-9][a-z0-9-]*$/u);
|
|
1525
|
+
|
|
1503
1526
|
// ../domain/src/change-kinds.ts
|
|
1504
1527
|
import { z as z17 } from "zod";
|
|
1505
1528
|
|
|
1506
1529
|
// ../domain/src/thread-event-types.ts
|
|
1507
|
-
import { z as
|
|
1530
|
+
import { z as z4 } from "zod";
|
|
1508
1531
|
var systemEventTypeValues = [
|
|
1509
1532
|
"client/thread/start",
|
|
1510
1533
|
"client/turn/requested",
|
|
@@ -1563,7 +1586,7 @@ var threadEventTypeValues = [
|
|
|
1563
1586
|
...systemEventTypeValues
|
|
1564
1587
|
];
|
|
1565
1588
|
var threadEventTypeSet = new Set(threadEventTypeValues);
|
|
1566
|
-
var threadEventTypeSchema =
|
|
1589
|
+
var threadEventTypeSchema = z4.string().refine(
|
|
1567
1590
|
(value) => threadEventTypeSet.has(value),
|
|
1568
1591
|
"Invalid thread event type"
|
|
1569
1592
|
);
|
|
@@ -1572,21 +1595,21 @@ var threadEventTypeSchema = z3.string().refine(
|
|
|
1572
1595
|
import { z as z16 } from "zod";
|
|
1573
1596
|
|
|
1574
1597
|
// ../domain/src/thread-create-origin.ts
|
|
1575
|
-
import { z as
|
|
1598
|
+
import { z as z5 } from "zod";
|
|
1576
1599
|
var threadCreateOriginValues = ["app", "cli", "sdk", "plugin"];
|
|
1577
|
-
var threadCreateOriginSchema =
|
|
1600
|
+
var threadCreateOriginSchema = z5.enum(threadCreateOriginValues);
|
|
1578
1601
|
|
|
1579
1602
|
// ../domain/src/environment.ts
|
|
1580
|
-
import { z as
|
|
1581
|
-
var environmentMachineSelectionSchema =
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
type:
|
|
1585
|
-
machineProviderId:
|
|
1603
|
+
import { z as z6 } from "zod";
|
|
1604
|
+
var environmentMachineSelectionSchema = z6.discriminatedUnion("type", [
|
|
1605
|
+
z6.object({ type: z6.literal("existing"), hostId: z6.string().min(1) }),
|
|
1606
|
+
z6.object({
|
|
1607
|
+
type: z6.literal("new"),
|
|
1608
|
+
machineProviderId: z6.string().min(1),
|
|
1586
1609
|
inputs: jsonValueSchema.nullable()
|
|
1587
1610
|
})
|
|
1588
1611
|
]);
|
|
1589
|
-
var environmentProviderSelectionSchema =
|
|
1612
|
+
var environmentProviderSelectionSchema = z6.object({
|
|
1590
1613
|
machine: environmentMachineSelectionSchema,
|
|
1591
1614
|
inputs: jsonValueSchema.nullable()
|
|
1592
1615
|
});
|
|
@@ -1597,14 +1620,14 @@ var environmentStatusValues = [
|
|
|
1597
1620
|
"error",
|
|
1598
1621
|
"destroyed"
|
|
1599
1622
|
];
|
|
1600
|
-
var environmentStatusSchema =
|
|
1623
|
+
var environmentStatusSchema = z6.enum(environmentStatusValues);
|
|
1601
1624
|
var environmentHostLifecycleValues = [
|
|
1602
1625
|
"active",
|
|
1603
1626
|
"removing",
|
|
1604
1627
|
"cleanup-failed",
|
|
1605
1628
|
"removed"
|
|
1606
1629
|
];
|
|
1607
|
-
var environmentHostLifecycleSchema =
|
|
1630
|
+
var environmentHostLifecycleSchema = z6.enum(
|
|
1608
1631
|
environmentHostLifecycleValues
|
|
1609
1632
|
);
|
|
1610
1633
|
var WORKSPACE_PROVISION_TYPES = [
|
|
@@ -1612,62 +1635,58 @@ var WORKSPACE_PROVISION_TYPES = [
|
|
|
1612
1635
|
"managed-worktree",
|
|
1613
1636
|
"personal"
|
|
1614
1637
|
];
|
|
1615
|
-
var workspaceProvisionTypeSchema =
|
|
1638
|
+
var workspaceProvisionTypeSchema = z6.enum(WORKSPACE_PROVISION_TYPES);
|
|
1616
1639
|
var environmentWorkspaceDisplayKindValues = [
|
|
1617
1640
|
"managed-worktree",
|
|
1618
1641
|
"unmanaged-worktree",
|
|
1619
1642
|
"other"
|
|
1620
1643
|
];
|
|
1621
|
-
var environmentWorkspaceDisplayKindSchema =
|
|
1644
|
+
var environmentWorkspaceDisplayKindSchema = z6.enum(
|
|
1622
1645
|
environmentWorkspaceDisplayKindValues
|
|
1623
1646
|
);
|
|
1624
|
-
var discoveredWorkspacePropertiesSchema =
|
|
1625
|
-
path:
|
|
1626
|
-
isGitRepo:
|
|
1627
|
-
isWorktree:
|
|
1628
|
-
branchName:
|
|
1629
|
-
defaultBranch:
|
|
1647
|
+
var discoveredWorkspacePropertiesSchema = z6.object({
|
|
1648
|
+
path: z6.string().min(1),
|
|
1649
|
+
isGitRepo: z6.boolean(),
|
|
1650
|
+
isWorktree: z6.boolean(),
|
|
1651
|
+
branchName: z6.string().nullable(),
|
|
1652
|
+
defaultBranch: z6.string().nullable()
|
|
1630
1653
|
});
|
|
1631
|
-
var environmentLifecycleSchema =
|
|
1632
|
-
phase:
|
|
1633
|
-
retireAt:
|
|
1634
|
-
teardown:
|
|
1635
|
-
status:
|
|
1636
|
-
attempt:
|
|
1637
|
-
message:
|
|
1654
|
+
var environmentLifecycleSchema = z6.object({
|
|
1655
|
+
phase: z6.enum(["active", "retiring", "teardown", "destroyed"]),
|
|
1656
|
+
retireAt: z6.number().nullable(),
|
|
1657
|
+
teardown: z6.object({
|
|
1658
|
+
status: z6.enum(["running", "failed", "removed"]),
|
|
1659
|
+
attempt: z6.number().int().nonnegative(),
|
|
1660
|
+
message: z6.string().optional()
|
|
1638
1661
|
}).nullable()
|
|
1639
1662
|
});
|
|
1640
|
-
var environmentSchema =
|
|
1641
|
-
id:
|
|
1642
|
-
name:
|
|
1643
|
-
projectId:
|
|
1644
|
-
hostId:
|
|
1645
|
-
path:
|
|
1646
|
-
isGitRepo:
|
|
1647
|
-
isWorktree:
|
|
1648
|
-
branchName:
|
|
1649
|
-
baseBranch:
|
|
1650
|
-
defaultBranch:
|
|
1651
|
-
mergeBaseBranch:
|
|
1663
|
+
var environmentSchema = z6.object({
|
|
1664
|
+
id: z6.string(),
|
|
1665
|
+
name: z6.string().nullable(),
|
|
1666
|
+
projectId: z6.string(),
|
|
1667
|
+
hostId: z6.string(),
|
|
1668
|
+
path: z6.string().nullable(),
|
|
1669
|
+
isGitRepo: z6.boolean(),
|
|
1670
|
+
isWorktree: z6.boolean(),
|
|
1671
|
+
branchName: z6.string().nullable(),
|
|
1672
|
+
baseBranch: z6.string().nullable(),
|
|
1673
|
+
defaultBranch: z6.string().nullable(),
|
|
1674
|
+
mergeBaseBranch: z6.string().nullable(),
|
|
1652
1675
|
status: environmentStatusSchema,
|
|
1653
|
-
environmentProviderId:
|
|
1676
|
+
environmentProviderId: z6.string().nullable(),
|
|
1654
1677
|
lifecycle: environmentLifecycleSchema,
|
|
1655
1678
|
hostLifecycle: environmentHostLifecycleSchema,
|
|
1656
1679
|
environmentProviderSelection: environmentProviderSelectionSchema.nullable(),
|
|
1657
|
-
environmentProviderInstanceKey:
|
|
1658
|
-
managed:
|
|
1680
|
+
environmentProviderInstanceKey: z6.string().nullable(),
|
|
1681
|
+
managed: z6.boolean(),
|
|
1659
1682
|
workspaceProvisionType: workspaceProvisionTypeSchema.nullable(),
|
|
1660
|
-
createdAt:
|
|
1661
|
-
updatedAt:
|
|
1683
|
+
createdAt: z6.number(),
|
|
1684
|
+
updatedAt: z6.number()
|
|
1662
1685
|
});
|
|
1663
1686
|
|
|
1664
1687
|
// ../domain/src/queued-message.ts
|
|
1665
1688
|
import { z as z9 } from "zod";
|
|
1666
1689
|
|
|
1667
|
-
// ../domain/src/plugin-id.ts
|
|
1668
|
-
import { z as z6 } from "zod";
|
|
1669
|
-
var pluginIdSchema = z6.string().regex(/^[a-z0-9][a-z0-9-]*$/u);
|
|
1670
|
-
|
|
1671
1690
|
// ../domain/src/protocol-ids.ts
|
|
1672
1691
|
import { z as z7 } from "zod";
|
|
1673
1692
|
var clientTurnRequestIdSchema = z7.string().regex(/^creq_[23456789abcdefghijkmnpqrstuvwxyz]{10}$/u);
|
|
@@ -2274,6 +2293,8 @@ var rpcQueryKey = (pluginId, method, input) => [
|
|
|
2274
2293
|
input
|
|
2275
2294
|
];
|
|
2276
2295
|
var keyedQueryKey = (pluginId, method) => rpcQueryKey(pluginId, method, { keyed: true });
|
|
2296
|
+
var keyListSchema = z19.array(z19.string());
|
|
2297
|
+
var jsonRecordSchema = z19.record(z19.string(), jsonValueSchema);
|
|
2277
2298
|
var keyedCollections = /* @__PURE__ */ new Map();
|
|
2278
2299
|
function keyedCollection(pluginId, method) {
|
|
2279
2300
|
const name = JSON.stringify([pluginId, method]);
|
|
@@ -2408,7 +2429,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2408
2429
|
const enabled = options.enabled ?? true;
|
|
2409
2430
|
const identity = JSON.stringify([...new Set(options.keys)].sort());
|
|
2410
2431
|
const keys = useMemo2(
|
|
2411
|
-
() =>
|
|
2432
|
+
() => keyListSchema.parse(JSON.parse(identity)),
|
|
2412
2433
|
[identity]
|
|
2413
2434
|
);
|
|
2414
2435
|
let cache = owners.get(host.queryClient);
|
|
@@ -2434,7 +2455,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2434
2455
|
);
|
|
2435
2456
|
return {
|
|
2436
2457
|
...response,
|
|
2437
|
-
result:
|
|
2458
|
+
result: jsonRecordSchema.parse(response.result)
|
|
2438
2459
|
};
|
|
2439
2460
|
}
|
|
2440
2461
|
});
|
|
@@ -2443,8 +2464,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2443
2464
|
const current = owner;
|
|
2444
2465
|
useSubscription(host, pluginId, enabled && keys.length > 0);
|
|
2445
2466
|
const subscribe = useCallback2(
|
|
2446
|
-
(listener) => enabled
|
|
2447
|
-
},
|
|
2467
|
+
(listener) => current.subscribe(enabled ? keys : [], listener),
|
|
2448
2468
|
[current, keys, enabled]
|
|
2449
2469
|
);
|
|
2450
2470
|
const getSnapshot = useCallback2(
|
|
@@ -2471,21 +2491,46 @@ function createRpcQueryHooks(useHost) {
|
|
|
2471
2491
|
[keys, enabled, selectRows]
|
|
2472
2492
|
);
|
|
2473
2493
|
const query = useQuerySelection(subscribe, getSnapshot, select);
|
|
2494
|
+
const watches = useMemo2(
|
|
2495
|
+
() => /* @__PURE__ */ new Map(),
|
|
2496
|
+
[host, pluginId, options.method]
|
|
2497
|
+
);
|
|
2498
|
+
useEffect2(
|
|
2499
|
+
() => () => {
|
|
2500
|
+
for (const release of watches.values()) release?.();
|
|
2501
|
+
watches.clear();
|
|
2502
|
+
},
|
|
2503
|
+
[watches]
|
|
2504
|
+
);
|
|
2474
2505
|
useEffect2(() => {
|
|
2475
|
-
|
|
2476
|
-
const
|
|
2477
|
-
(
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2506
|
+
const wanted = new Set(enabled ? keys : []);
|
|
2507
|
+
for (const [key, release] of watches) {
|
|
2508
|
+
if (wanted.has(key)) continue;
|
|
2509
|
+
release?.();
|
|
2510
|
+
watches.delete(key);
|
|
2511
|
+
}
|
|
2512
|
+
for (const key of wanted) {
|
|
2513
|
+
if (!watches.has(key))
|
|
2514
|
+
watches.set(key, host.watch?.(pluginId, options.method, { key }));
|
|
2515
|
+
}
|
|
2516
|
+
}, [host, pluginId, options.method, keys, enabled, watches]);
|
|
2517
|
+
const heldKeys = useRef2(keys);
|
|
2518
|
+
useEffect2(() => {
|
|
2519
|
+
heldKeys.current = keys;
|
|
2520
|
+
}, [keys]);
|
|
2483
2521
|
const refetch = useCallback2(async () => {
|
|
2484
|
-
await current.
|
|
2522
|
+
await current.refresh(heldKeys.current);
|
|
2485
2523
|
}, [current]);
|
|
2524
|
+
const refetchKeys = useCallback2(
|
|
2525
|
+
async (requested) => {
|
|
2526
|
+
await current.refresh(requested.filter((key) => keys.includes(key)));
|
|
2527
|
+
},
|
|
2528
|
+
[current, keys]
|
|
2529
|
+
);
|
|
2486
2530
|
return {
|
|
2487
2531
|
...query,
|
|
2488
|
-
refetch
|
|
2532
|
+
refetch,
|
|
2533
|
+
refetchKeys
|
|
2489
2534
|
};
|
|
2490
2535
|
}
|
|
2491
2536
|
function experimental_useRpcMutation(options) {
|
|
@@ -2493,6 +2538,7 @@ function createRpcQueryHooks(useHost) {
|
|
|
2493
2538
|
const pluginId = resolvePluginId(host, options.pluginId);
|
|
2494
2539
|
const mutation = useTaggedMutation({
|
|
2495
2540
|
client: host.queryClient,
|
|
2541
|
+
meta: { showErrorToast: false },
|
|
2496
2542
|
invalidate: (tags) => invalidateTags(host.queryClient, pluginTagScope(pluginId), tags),
|
|
2497
2543
|
call: async (input) => {
|
|
2498
2544
|
const response = await callRpc(
|