acpx 0.19.2 → 0.19.3
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/dist/{agent-registry-DWlx5BQ4.js → agent-registry-DWnqUICY.js} +20 -17
- package/dist/agent-registry-DWnqUICY.js.map +1 -0
- package/dist/agent-registry.js +1 -1
- package/dist/{cli-D-s_eTUy.js → cli-C1uofM8S.js} +5 -5
- package/dist/{cli-D-s_eTUy.js.map → cli-C1uofM8S.js.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +56 -40
- package/dist/cli.js.map +1 -1
- package/dist/{client-BchvQRpz.d.ts → client-CdG6nVDG.d.ts} +4 -3
- package/dist/client-CdG6nVDG.d.ts.map +1 -0
- package/dist/{flows-DdxEaeZo.js → flows-hz_Pfsp-.js} +9 -5
- package/dist/flows-hz_Pfsp-.js.map +1 -0
- package/dist/flows.d.ts +2 -2
- package/dist/flows.js +1 -1
- package/dist/{invocation-options-HjxSBsK0.js → invocation-options-DbZzMvKM.js} +5 -5
- package/dist/{invocation-options-HjxSBsK0.js.map → invocation-options-DbZzMvKM.js.map} +1 -1
- package/dist/{ipc-D0ZMQ0q9.js → ipc-BW06Pbb8.js} +338 -289
- package/dist/ipc-BW06Pbb8.js.map +1 -0
- package/dist/{output-GQnhkJMU.js → output-BjeeG-cj.js} +3 -3
- package/dist/{output-GQnhkJMU.js.map → output-BjeeG-cj.js.map} +1 -1
- package/dist/{queue-owner-runtime-W0lly6ap.js → queue-owner-runtime-Dhr4gxNE.js} +427 -368
- package/dist/queue-owner-runtime-Dhr4gxNE.js.map +1 -0
- package/dist/runtime.d.ts +7 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +24 -17
- package/dist/runtime.js.map +1 -1
- package/dist/{session-options-Dp6mzNSy.d.ts → session-options-X7LhX9BF.d.ts} +2 -1
- package/dist/{session-options-Dp6mzNSy.d.ts.map → session-options-X7LhX9BF.d.ts.map} +1 -1
- package/dist/{session-watch-_8yxQ6ba.js → session-watch-CgfkUKLA.js} +4 -4
- package/dist/{session-watch-_8yxQ6ba.js.map → session-watch-CgfkUKLA.js.map} +1 -1
- package/dist/{watch-C0mwpJcN.js → watch-BGdqBiNX.js} +2 -2
- package/dist/{watch-C0mwpJcN.js.map → watch-BGdqBiNX.js.map} +1 -1
- package/package.json +11 -11
- package/skills/acpx/SKILL.md +7 -2
- package/dist/agent-registry-DWlx5BQ4.js.map +0 -1
- package/dist/client-BchvQRpz.d.ts.map +0 -1
- package/dist/flows-DdxEaeZo.js.map +0 -1
- package/dist/ipc-D0ZMQ0q9.js.map +0 -1
- package/dist/queue-owner-runtime-W0lly6ap.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as PROCESS_HELPER_TIMEOUT_MS, E as isChildProcessRunning, N as runTimedExecFile, S as PROCESS_HELPER_MAX_BUFFER_BYTES, n as AGENT_REGISTRY, r as BUILT_IN_AGENT_PACKAGES, t as AGENT_ARGV_REGISTRY } from "./agent-registry-
|
|
1
|
+
import { C as PROCESS_HELPER_TIMEOUT_MS, E as isChildProcessRunning, N as runTimedExecFile, S as PROCESS_HELPER_MAX_BUFFER_BYTES, n as AGENT_REGISTRY, r as BUILT_IN_AGENT_PACKAGES, t as AGENT_ARGV_REGISTRY } from "./agent-registry-DWnqUICY.js";
|
|
2
2
|
import fs, { statSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs$1 from "node:fs/promises";
|
|
@@ -857,9 +857,7 @@ var SessionJournalReader = class {
|
|
|
857
857
|
const segments = [];
|
|
858
858
|
try {
|
|
859
859
|
const paths = await this.openPresentSegments(segments);
|
|
860
|
-
|
|
861
|
-
const identities = new Map(segments.map((entry) => [entry.filePath, entry.identity]));
|
|
862
|
-
if (paths.every((filePath, index) => current[index] === identities.get(filePath))) return segments;
|
|
860
|
+
if (await this.matchesSnapshot(paths, segments)) return segments;
|
|
863
861
|
} catch (error) {
|
|
864
862
|
if (!retryableSnapshotError(error)) {
|
|
865
863
|
await this.closeSnapshot(segments);
|
|
@@ -900,10 +898,33 @@ var SessionJournalReader = class {
|
|
|
900
898
|
async closeSnapshot(segments) {
|
|
901
899
|
await Promise.all(segments.map(({ opened }) => opened[Symbol.asyncDispose]()));
|
|
902
900
|
}
|
|
901
|
+
async matchesSnapshot(paths, segments) {
|
|
902
|
+
const current = await Promise.all(paths.map(pathIdentity));
|
|
903
|
+
const identities = new Map(segments.map((entry) => [entry.filePath, entry.identity]));
|
|
904
|
+
return paths.every((filePath, index) => current[index] === identities.get(filePath));
|
|
905
|
+
}
|
|
906
|
+
async withSnapshot(read, signal) {
|
|
907
|
+
for (;;) {
|
|
908
|
+
const segments = await this.openSnapshot(signal);
|
|
909
|
+
try {
|
|
910
|
+
const outcome = await read(segments).then((value) => ({ value }), (error) => {
|
|
911
|
+
if (!(error instanceof SessionWatchError) || error.code !== "WATCH_JOURNAL_CORRUPT") throw error;
|
|
912
|
+
return { error };
|
|
913
|
+
});
|
|
914
|
+
if (await this.matchesSnapshot(this.paths(), segments)) {
|
|
915
|
+
signal?.throwIfAborted();
|
|
916
|
+
if ("error" in outcome) throw outcome.error;
|
|
917
|
+
return outcome.value;
|
|
918
|
+
}
|
|
919
|
+
} finally {
|
|
920
|
+
await this.closeSnapshot(segments);
|
|
921
|
+
}
|
|
922
|
+
await setTimeout$1(5, void 0, { signal });
|
|
923
|
+
}
|
|
924
|
+
}
|
|
903
925
|
async readAcpMessages() {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
try {
|
|
926
|
+
return await this.withSnapshot(async (segments) => {
|
|
927
|
+
const messages = [];
|
|
907
928
|
for (const { opened } of segments) {
|
|
908
929
|
const payload = await opened.handle.readFile("utf8");
|
|
909
930
|
for (const line of payload.split("\n")) try {
|
|
@@ -912,15 +933,12 @@ var SessionJournalReader = class {
|
|
|
912
933
|
} catch {}
|
|
913
934
|
}
|
|
914
935
|
return messages;
|
|
915
|
-
}
|
|
916
|
-
await this.closeSnapshot(segments);
|
|
917
|
-
}
|
|
936
|
+
});
|
|
918
937
|
}
|
|
919
938
|
async readTail() {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
try {
|
|
939
|
+
return await this.withSnapshot(async (segments) => {
|
|
940
|
+
let tail = emptySegment();
|
|
941
|
+
let active = emptySegment();
|
|
924
942
|
for (const segment of segments.toReversed()) {
|
|
925
943
|
const state = emptySegment();
|
|
926
944
|
await this.readSegment(segment.opened.handle, segment.opened.stat.size, state, void 0);
|
|
@@ -938,22 +956,20 @@ var SessionJournalReader = class {
|
|
|
938
956
|
activeAnchored: active.firstSequence !== void 0,
|
|
939
957
|
activePartial: active.pending.length > 0
|
|
940
958
|
};
|
|
941
|
-
}
|
|
942
|
-
await this.closeSnapshot(segments);
|
|
943
|
-
}
|
|
959
|
+
});
|
|
944
960
|
}
|
|
945
961
|
async read(signal, options) {
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
962
|
+
const { result, states } = await this.withSnapshot(async (segments) => {
|
|
963
|
+
const page = createJournalPage(options);
|
|
964
|
+
const states = new Map(this.states);
|
|
965
|
+
let hasMore = false;
|
|
966
|
+
let firstSequence;
|
|
967
|
+
let tail = emptySegment();
|
|
968
|
+
let active = emptySegment();
|
|
953
969
|
for (const segment of segments) {
|
|
954
|
-
const state =
|
|
970
|
+
const state = { ...states.get(segment.identity) ?? emptySegment() };
|
|
955
971
|
await this.readSegment(segment.opened.handle, segment.opened.stat.size, state, page, signal);
|
|
956
|
-
|
|
972
|
+
states.set(segment.identity, state);
|
|
957
973
|
if (state.firstSequence !== void 0) {
|
|
958
974
|
if (firstSequence === void 0) firstSequence = state.firstSequence;
|
|
959
975
|
else if (state.firstSequence !== tail.sequence) corrupt("Session journal segments are not contiguous");
|
|
@@ -965,25 +981,29 @@ var SessionJournalReader = class {
|
|
|
965
981
|
break;
|
|
966
982
|
}
|
|
967
983
|
}
|
|
968
|
-
this.pruneStates(segments);
|
|
984
|
+
this.pruneStates(states, segments);
|
|
969
985
|
return {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
986
|
+
states,
|
|
987
|
+
result: {
|
|
988
|
+
events: page.events,
|
|
989
|
+
hasMore,
|
|
990
|
+
firstSequence,
|
|
991
|
+
sequence: tail.sequence,
|
|
992
|
+
messageSequence: tail.messageSequence,
|
|
993
|
+
requestId: tail.requestId,
|
|
994
|
+
activeSize: active.offset,
|
|
995
|
+
activeAnchored: active.firstSequence !== void 0,
|
|
996
|
+
activePartial: active.pending.length > 0
|
|
997
|
+
}
|
|
979
998
|
};
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
|
|
999
|
+
}, signal);
|
|
1000
|
+
signal?.throwIfAborted();
|
|
1001
|
+
this.states = states;
|
|
1002
|
+
return result;
|
|
983
1003
|
}
|
|
984
|
-
pruneStates(segments) {
|
|
1004
|
+
pruneStates(states, segments) {
|
|
985
1005
|
const retained = new Set(segments.map((entry) => entry.identity));
|
|
986
|
-
for (const identity of
|
|
1006
|
+
for (const identity of states.keys()) if (!retained.has(identity)) states.delete(identity);
|
|
987
1007
|
}
|
|
988
1008
|
async readSegment(handle, size, state, page, signal) {
|
|
989
1009
|
if (size < state.offset) corrupt("Session journal was truncated while watching");
|
|
@@ -1398,12 +1418,15 @@ function parseRequestTokenUsage(raw) {
|
|
|
1398
1418
|
}
|
|
1399
1419
|
return usage;
|
|
1400
1420
|
}
|
|
1421
|
+
function isValidImageSize(size) {
|
|
1422
|
+
if (size === void 0 || size === null) return true;
|
|
1423
|
+
const record = asRecord$2(size);
|
|
1424
|
+
return !!record && isFiniteNumber(record.width) && isFiniteNumber(record.height);
|
|
1425
|
+
}
|
|
1401
1426
|
function isSessionMessageImage(raw) {
|
|
1402
1427
|
const record = asRecord$2(raw);
|
|
1403
|
-
if (!record || typeof record.source !== "string") return false;
|
|
1404
|
-
|
|
1405
|
-
const size = asRecord$2(record.size);
|
|
1406
|
-
return !!size && isFiniteNumber(size.width) && isFiniteNumber(size.height);
|
|
1428
|
+
if (!record || typeof record.source !== "string" || !isOptionalString(record.mime_type)) return false;
|
|
1429
|
+
return isValidImageSize(record.size);
|
|
1407
1430
|
}
|
|
1408
1431
|
function isSessionMessageAudio(raw) {
|
|
1409
1432
|
const record = asRecord$2(raw);
|
|
@@ -2027,182 +2050,6 @@ async function unlinkCountingBytes(filePath) {
|
|
|
2027
2050
|
return bytes;
|
|
2028
2051
|
}
|
|
2029
2052
|
//#endregion
|
|
2030
|
-
//#region src/prompt-content.ts
|
|
2031
|
-
var PromptInputValidationError = class extends Error {
|
|
2032
|
-
constructor(message) {
|
|
2033
|
-
super(message);
|
|
2034
|
-
this.name = "PromptInputValidationError";
|
|
2035
|
-
}
|
|
2036
|
-
};
|
|
2037
|
-
function asRecord$1(value) {
|
|
2038
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
2039
|
-
return value;
|
|
2040
|
-
}
|
|
2041
|
-
function isNonEmptyString(value) {
|
|
2042
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
2043
|
-
}
|
|
2044
|
-
function isBase64Data(value) {
|
|
2045
|
-
if (value.length === 0 || value.length % 4 !== 0) return false;
|
|
2046
|
-
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value);
|
|
2047
|
-
}
|
|
2048
|
-
function isImageMimeType(value) {
|
|
2049
|
-
return /^image\/[A-Za-z0-9.+-]+$/i.test(value);
|
|
2050
|
-
}
|
|
2051
|
-
function isAudioMimeType(value) {
|
|
2052
|
-
return /^audio\/[A-Za-z0-9.+-]+$/i.test(value);
|
|
2053
|
-
}
|
|
2054
|
-
function isTextBlock(value) {
|
|
2055
|
-
const record = asRecord$1(value);
|
|
2056
|
-
return record?.type === "text" && typeof record.text === "string";
|
|
2057
|
-
}
|
|
2058
|
-
function isImageBlock(value) {
|
|
2059
|
-
const record = asRecord$1(value);
|
|
2060
|
-
return record?.type === "image" && isNonEmptyString(record.mimeType) && isImageMimeType(record.mimeType) && typeof record.data === "string" && isBase64Data(record.data);
|
|
2061
|
-
}
|
|
2062
|
-
function isAudioBlock(value) {
|
|
2063
|
-
const record = asRecord$1(value);
|
|
2064
|
-
return record?.type === "audio" && isNonEmptyString(record.mimeType) && isAudioMimeType(record.mimeType) && typeof record.data === "string" && isBase64Data(record.data);
|
|
2065
|
-
}
|
|
2066
|
-
function isResourceLinkBlock(value) {
|
|
2067
|
-
const record = asRecord$1(value);
|
|
2068
|
-
return record?.type === "resource_link" && isNonEmptyString(record.uri) && (record.title == null || typeof record.title === "string") && typeof record.name === "string";
|
|
2069
|
-
}
|
|
2070
|
-
function isResourcePayload(value) {
|
|
2071
|
-
const record = asRecord$1(value);
|
|
2072
|
-
if (!record || !isNonEmptyString(record.uri)) return false;
|
|
2073
|
-
return typeof record.text === "string" || typeof record.blob === "string";
|
|
2074
|
-
}
|
|
2075
|
-
function isResourceBlock(value) {
|
|
2076
|
-
const record = asRecord$1(value);
|
|
2077
|
-
return record?.type === "resource" && isResourcePayload(record.resource);
|
|
2078
|
-
}
|
|
2079
|
-
const CONTENT_BLOCK_VALIDATORS = [
|
|
2080
|
-
isTextBlock,
|
|
2081
|
-
isImageBlock,
|
|
2082
|
-
isAudioBlock,
|
|
2083
|
-
isResourceLinkBlock,
|
|
2084
|
-
isResourceBlock
|
|
2085
|
-
];
|
|
2086
|
-
function isContentBlock(value) {
|
|
2087
|
-
return CONTENT_BLOCK_VALIDATORS.some((validator) => validator(value));
|
|
2088
|
-
}
|
|
2089
|
-
const CONTENT_BLOCK_ERROR_VALIDATORS = {
|
|
2090
|
-
text: validateTextContentBlock,
|
|
2091
|
-
image: validateImageContentBlock,
|
|
2092
|
-
audio: validateAudioContentBlock,
|
|
2093
|
-
resource_link: validateResourceLinkContentBlock,
|
|
2094
|
-
resource: validateResourceContentBlock
|
|
2095
|
-
};
|
|
2096
|
-
function contentBlockErrorValidator(type) {
|
|
2097
|
-
return Object.hasOwn(CONTENT_BLOCK_ERROR_VALIDATORS, type) ? CONTENT_BLOCK_ERROR_VALIDATORS[type] : void 0;
|
|
2098
|
-
}
|
|
2099
|
-
function validateTextContentBlock(record, index) {
|
|
2100
|
-
return typeof record.text === "string" ? void 0 : `prompt[${index}] text block must include a string text field`;
|
|
2101
|
-
}
|
|
2102
|
-
function validateImageContentBlock(record, index) {
|
|
2103
|
-
if (!isNonEmptyString(record.mimeType)) return `prompt[${index}] image block must include a non-empty mimeType`;
|
|
2104
|
-
if (!isImageMimeType(record.mimeType)) return `prompt[${index}] image block mimeType must start with image/`;
|
|
2105
|
-
if (typeof record.data !== "string" || record.data.length === 0) return `prompt[${index}] image block must include non-empty base64 data`;
|
|
2106
|
-
return isBase64Data(record.data) ? void 0 : `prompt[${index}] image block data must be valid base64`;
|
|
2107
|
-
}
|
|
2108
|
-
function validateAudioContentBlock(record, index) {
|
|
2109
|
-
if (!isNonEmptyString(record.mimeType)) return `prompt[${index}] audio block must include a non-empty mimeType`;
|
|
2110
|
-
if (!isAudioMimeType(record.mimeType)) return `prompt[${index}] audio block mimeType must start with audio/`;
|
|
2111
|
-
if (typeof record.data !== "string" || record.data.length === 0) return `prompt[${index}] audio block must include non-empty base64 data`;
|
|
2112
|
-
return isBase64Data(record.data) ? void 0 : `prompt[${index}] audio block data must be valid base64`;
|
|
2113
|
-
}
|
|
2114
|
-
function validateResourceLinkContentBlock(record, index) {
|
|
2115
|
-
if (!isNonEmptyString(record.uri)) return `prompt[${index}] resource_link block must include a non-empty uri`;
|
|
2116
|
-
if (record.title != null && typeof record.title !== "string") return `prompt[${index}] resource_link block title must be a string or null when present`;
|
|
2117
|
-
if (typeof record.name !== "string") return `prompt[${index}] resource_link block must include a string name`;
|
|
2118
|
-
}
|
|
2119
|
-
function validateResourceContentBlock(record, index) {
|
|
2120
|
-
if (!asRecord$1(record.resource)) return `prompt[${index}] resource block must include a resource object`;
|
|
2121
|
-
return isResourcePayload(record.resource) ? void 0 : `prompt[${index}] resource block resource must include a non-empty uri and a string text or blob field`;
|
|
2122
|
-
}
|
|
2123
|
-
function getContentBlockValidationError(value, index) {
|
|
2124
|
-
const record = asRecord$1(value);
|
|
2125
|
-
if (!record || typeof record.type !== "string") return `prompt[${index}] must be an ACP content block object`;
|
|
2126
|
-
const validator = contentBlockErrorValidator(record.type);
|
|
2127
|
-
return validator ? validator(record, index) : `prompt[${index}] has unsupported content block type ${JSON.stringify(record.type)}`;
|
|
2128
|
-
}
|
|
2129
|
-
function isPromptInput(value) {
|
|
2130
|
-
return Array.isArray(value) && value.every((entry) => isContentBlock(entry));
|
|
2131
|
-
}
|
|
2132
|
-
function promptCapabilityRequirement(block) {
|
|
2133
|
-
switch (block.type) {
|
|
2134
|
-
case "image": return {
|
|
2135
|
-
blockType: "image",
|
|
2136
|
-
capability: "image"
|
|
2137
|
-
};
|
|
2138
|
-
case "audio": return {
|
|
2139
|
-
blockType: "audio",
|
|
2140
|
-
capability: "audio"
|
|
2141
|
-
};
|
|
2142
|
-
case "resource": return {
|
|
2143
|
-
blockType: "resource",
|
|
2144
|
-
capability: "embeddedContext"
|
|
2145
|
-
};
|
|
2146
|
-
default: return;
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
function getUnsupportedPromptContentMessage(prompt, agentCapabilities) {
|
|
2150
|
-
for (const [index, block] of prompt.entries()) {
|
|
2151
|
-
const requirement = promptCapabilityRequirement(block);
|
|
2152
|
-
if (!requirement) continue;
|
|
2153
|
-
if (agentCapabilities?.promptCapabilities?.[requirement.capability] === true) continue;
|
|
2154
|
-
return `prompt[${index}] ${requirement.blockType} content requires agentCapabilities.promptCapabilities.${requirement.capability}`;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
function textPrompt(text) {
|
|
2158
|
-
return [{
|
|
2159
|
-
type: "text",
|
|
2160
|
-
text
|
|
2161
|
-
}];
|
|
2162
|
-
}
|
|
2163
|
-
function parseStructuredPrompt(source) {
|
|
2164
|
-
if (!source.startsWith("[")) return;
|
|
2165
|
-
try {
|
|
2166
|
-
const parsed = JSON.parse(source);
|
|
2167
|
-
if (isPromptInput(parsed)) return parsed;
|
|
2168
|
-
if (Array.isArray(parsed)) throw new PromptInputValidationError(parsed.map((entry, index) => getContentBlockValidationError(entry, index)).find((message) => message !== void 0) ?? "Structured prompt JSON must be an array of valid ACP content blocks");
|
|
2169
|
-
return;
|
|
2170
|
-
} catch (error) {
|
|
2171
|
-
if (error instanceof PromptInputValidationError) throw error;
|
|
2172
|
-
return;
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
function parsePromptSource(source) {
|
|
2176
|
-
const trimmed = source.trim();
|
|
2177
|
-
const structured = parseStructuredPrompt(trimmed);
|
|
2178
|
-
if (structured) return structured;
|
|
2179
|
-
if (!trimmed) return [];
|
|
2180
|
-
return textPrompt(trimmed);
|
|
2181
|
-
}
|
|
2182
|
-
function mergePromptSourceWithText(source, suffixText) {
|
|
2183
|
-
const prompt = parsePromptSource(source);
|
|
2184
|
-
const appended = suffixText.trim();
|
|
2185
|
-
if (!appended) return prompt;
|
|
2186
|
-
if (prompt.length === 0) return textPrompt(appended);
|
|
2187
|
-
return [...prompt, ...textPrompt(appended)];
|
|
2188
|
-
}
|
|
2189
|
-
function promptToDisplayText(prompt) {
|
|
2190
|
-
return prompt.map((block) => contentBlockDisplayText(block)).filter((entry) => entry.trim().length > 0).join("\n\n").trim();
|
|
2191
|
-
}
|
|
2192
|
-
function contentBlockDisplayText(block) {
|
|
2193
|
-
switch (block.type) {
|
|
2194
|
-
case "text": return block.text;
|
|
2195
|
-
case "resource_link": return block.title ?? block.name ?? block.uri;
|
|
2196
|
-
case "resource": return resourceBlockDisplayText(block);
|
|
2197
|
-
case "image": return `[image] ${block.mimeType}`;
|
|
2198
|
-
case "audio": return `[audio] ${block.mimeType}`;
|
|
2199
|
-
default: return "";
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
function resourceBlockDisplayText(block) {
|
|
2203
|
-
return "text" in block.resource && typeof block.resource.text === "string" ? block.resource.text : block.resource.uri;
|
|
2204
|
-
}
|
|
2205
|
-
//#endregion
|
|
2206
2053
|
//#region src/process-identity.ts
|
|
2207
2054
|
const IDENTITY_QUERY_TIMEOUT_MS$1 = 2e3;
|
|
2208
2055
|
const LINUX_PROCESS_QUERY = `
|
|
@@ -2599,6 +2446,222 @@ async function getOwnProcessIdentity() {
|
|
|
2599
2446
|
return await ownIdentityPending;
|
|
2600
2447
|
}
|
|
2601
2448
|
//#endregion
|
|
2449
|
+
//#region src/session/lock-owner.ts
|
|
2450
|
+
const OBSERVATION_REUSE_MS = 1e3;
|
|
2451
|
+
const IDENTITY_QUERY_TIMEOUT_MS = 1e3;
|
|
2452
|
+
function lockOwnerPid(value) {
|
|
2453
|
+
if (!value || typeof value !== "object" || !("pid" in value)) return;
|
|
2454
|
+
const pid = value.pid;
|
|
2455
|
+
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 ? pid : void 0;
|
|
2456
|
+
}
|
|
2457
|
+
function canReuseObservation(preserved, pid, identity, fresh) {
|
|
2458
|
+
return !fresh && preserved?.pid === pid && compareProcessBirthIdentity(preserved.identity, identity) === "matching" && performance.now() - preserved.checkedAt < OBSERVATION_REUSE_MS;
|
|
2459
|
+
}
|
|
2460
|
+
async function createLockOwner(options = {}) {
|
|
2461
|
+
const { signal, capturedIdentity } = options;
|
|
2462
|
+
signal?.throwIfAborted();
|
|
2463
|
+
const processIdentity = capturedIdentity === void 0 ? await getOwnProcessIdentity() : capturedIdentity.processIdentity;
|
|
2464
|
+
signal?.throwIfAborted();
|
|
2465
|
+
let preserved;
|
|
2466
|
+
return {
|
|
2467
|
+
payload: {
|
|
2468
|
+
pid: process.pid,
|
|
2469
|
+
processIdentity
|
|
2470
|
+
},
|
|
2471
|
+
async hasExited(payload, fresh, signal) {
|
|
2472
|
+
signal?.throwIfAborted();
|
|
2473
|
+
const pid = lockOwnerPid(payload);
|
|
2474
|
+
if (!pid) return false;
|
|
2475
|
+
const identity = parseProcessBirthIdentity(payload.processIdentity);
|
|
2476
|
+
if (identity && canReuseObservation(preserved, pid, identity, fresh)) return false;
|
|
2477
|
+
const incarnation = await observeProcessIncarnation(pid, identity, IDENTITY_QUERY_TIMEOUT_MS);
|
|
2478
|
+
signal?.throwIfAborted();
|
|
2479
|
+
if (identity && incarnation !== "gone") preserved = {
|
|
2480
|
+
pid,
|
|
2481
|
+
identity,
|
|
2482
|
+
checkedAt: performance.now()
|
|
2483
|
+
};
|
|
2484
|
+
return incarnation === "gone";
|
|
2485
|
+
}
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
//#endregion
|
|
2489
|
+
//#region src/prompt-content.ts
|
|
2490
|
+
var PromptInputValidationError = class extends Error {
|
|
2491
|
+
constructor(message) {
|
|
2492
|
+
super(message);
|
|
2493
|
+
this.name = "PromptInputValidationError";
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2496
|
+
function asRecord$1(value) {
|
|
2497
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
2498
|
+
return value;
|
|
2499
|
+
}
|
|
2500
|
+
function isNonEmptyString(value) {
|
|
2501
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
2502
|
+
}
|
|
2503
|
+
function isBase64Data(value) {
|
|
2504
|
+
if (value.length === 0 || value.length % 4 !== 0) return false;
|
|
2505
|
+
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value);
|
|
2506
|
+
}
|
|
2507
|
+
function isImageMimeType(value) {
|
|
2508
|
+
return /^image\/[A-Za-z0-9.+-]+$/i.test(value);
|
|
2509
|
+
}
|
|
2510
|
+
function isAudioMimeType(value) {
|
|
2511
|
+
return /^audio\/[A-Za-z0-9.+-]+$/i.test(value);
|
|
2512
|
+
}
|
|
2513
|
+
function isTextBlock(value) {
|
|
2514
|
+
const record = asRecord$1(value);
|
|
2515
|
+
return record?.type === "text" && typeof record.text === "string";
|
|
2516
|
+
}
|
|
2517
|
+
function isImageBlock(value) {
|
|
2518
|
+
const record = asRecord$1(value);
|
|
2519
|
+
return record?.type === "image" && isNonEmptyString(record.mimeType) && isImageMimeType(record.mimeType) && typeof record.data === "string" && isBase64Data(record.data);
|
|
2520
|
+
}
|
|
2521
|
+
function isAudioBlock(value) {
|
|
2522
|
+
const record = asRecord$1(value);
|
|
2523
|
+
return record?.type === "audio" && isNonEmptyString(record.mimeType) && isAudioMimeType(record.mimeType) && typeof record.data === "string" && isBase64Data(record.data);
|
|
2524
|
+
}
|
|
2525
|
+
function isResourceLinkBlock(value) {
|
|
2526
|
+
const record = asRecord$1(value);
|
|
2527
|
+
return record?.type === "resource_link" && isNonEmptyString(record.uri) && (record.title == null || typeof record.title === "string") && typeof record.name === "string";
|
|
2528
|
+
}
|
|
2529
|
+
function isResourcePayload(value) {
|
|
2530
|
+
const record = asRecord$1(value);
|
|
2531
|
+
if (!record || !isNonEmptyString(record.uri)) return false;
|
|
2532
|
+
return typeof record.text === "string" || typeof record.blob === "string";
|
|
2533
|
+
}
|
|
2534
|
+
function isResourceBlock(value) {
|
|
2535
|
+
const record = asRecord$1(value);
|
|
2536
|
+
return record?.type === "resource" && isResourcePayload(record.resource);
|
|
2537
|
+
}
|
|
2538
|
+
const CONTENT_BLOCK_VALIDATORS = [
|
|
2539
|
+
isTextBlock,
|
|
2540
|
+
isImageBlock,
|
|
2541
|
+
isAudioBlock,
|
|
2542
|
+
isResourceLinkBlock,
|
|
2543
|
+
isResourceBlock
|
|
2544
|
+
];
|
|
2545
|
+
function isContentBlock(value) {
|
|
2546
|
+
return CONTENT_BLOCK_VALIDATORS.some((validator) => validator(value));
|
|
2547
|
+
}
|
|
2548
|
+
const CONTENT_BLOCK_ERROR_VALIDATORS = {
|
|
2549
|
+
text: validateTextContentBlock,
|
|
2550
|
+
image: validateImageContentBlock,
|
|
2551
|
+
audio: validateAudioContentBlock,
|
|
2552
|
+
resource_link: validateResourceLinkContentBlock,
|
|
2553
|
+
resource: validateResourceContentBlock
|
|
2554
|
+
};
|
|
2555
|
+
function contentBlockErrorValidator(type) {
|
|
2556
|
+
return Object.hasOwn(CONTENT_BLOCK_ERROR_VALIDATORS, type) ? CONTENT_BLOCK_ERROR_VALIDATORS[type] : void 0;
|
|
2557
|
+
}
|
|
2558
|
+
function validateTextContentBlock(record, index) {
|
|
2559
|
+
return typeof record.text === "string" ? void 0 : `prompt[${index}] text block must include a string text field`;
|
|
2560
|
+
}
|
|
2561
|
+
function validateImageContentBlock(record, index) {
|
|
2562
|
+
if (!isNonEmptyString(record.mimeType)) return `prompt[${index}] image block must include a non-empty mimeType`;
|
|
2563
|
+
if (!isImageMimeType(record.mimeType)) return `prompt[${index}] image block mimeType must start with image/`;
|
|
2564
|
+
if (typeof record.data !== "string" || record.data.length === 0) return `prompt[${index}] image block must include non-empty base64 data`;
|
|
2565
|
+
return isBase64Data(record.data) ? void 0 : `prompt[${index}] image block data must be valid base64`;
|
|
2566
|
+
}
|
|
2567
|
+
function validateAudioContentBlock(record, index) {
|
|
2568
|
+
if (!isNonEmptyString(record.mimeType)) return `prompt[${index}] audio block must include a non-empty mimeType`;
|
|
2569
|
+
if (!isAudioMimeType(record.mimeType)) return `prompt[${index}] audio block mimeType must start with audio/`;
|
|
2570
|
+
if (typeof record.data !== "string" || record.data.length === 0) return `prompt[${index}] audio block must include non-empty base64 data`;
|
|
2571
|
+
return isBase64Data(record.data) ? void 0 : `prompt[${index}] audio block data must be valid base64`;
|
|
2572
|
+
}
|
|
2573
|
+
function validateResourceLinkContentBlock(record, index) {
|
|
2574
|
+
if (!isNonEmptyString(record.uri)) return `prompt[${index}] resource_link block must include a non-empty uri`;
|
|
2575
|
+
if (record.title != null && typeof record.title !== "string") return `prompt[${index}] resource_link block title must be a string or null when present`;
|
|
2576
|
+
if (typeof record.name !== "string") return `prompt[${index}] resource_link block must include a string name`;
|
|
2577
|
+
}
|
|
2578
|
+
function validateResourceContentBlock(record, index) {
|
|
2579
|
+
if (!asRecord$1(record.resource)) return `prompt[${index}] resource block must include a resource object`;
|
|
2580
|
+
return isResourcePayload(record.resource) ? void 0 : `prompt[${index}] resource block resource must include a non-empty uri and a string text or blob field`;
|
|
2581
|
+
}
|
|
2582
|
+
function getContentBlockValidationError(value, index) {
|
|
2583
|
+
const record = asRecord$1(value);
|
|
2584
|
+
if (!record || typeof record.type !== "string") return `prompt[${index}] must be an ACP content block object`;
|
|
2585
|
+
const validator = contentBlockErrorValidator(record.type);
|
|
2586
|
+
return validator ? validator(record, index) : `prompt[${index}] has unsupported content block type ${JSON.stringify(record.type)}`;
|
|
2587
|
+
}
|
|
2588
|
+
function isPromptInput(value) {
|
|
2589
|
+
return Array.isArray(value) && value.every((entry) => isContentBlock(entry));
|
|
2590
|
+
}
|
|
2591
|
+
function promptCapabilityRequirement(block) {
|
|
2592
|
+
switch (block.type) {
|
|
2593
|
+
case "image": return {
|
|
2594
|
+
blockType: "image",
|
|
2595
|
+
capability: "image"
|
|
2596
|
+
};
|
|
2597
|
+
case "audio": return {
|
|
2598
|
+
blockType: "audio",
|
|
2599
|
+
capability: "audio"
|
|
2600
|
+
};
|
|
2601
|
+
case "resource": return {
|
|
2602
|
+
blockType: "resource",
|
|
2603
|
+
capability: "embeddedContext"
|
|
2604
|
+
};
|
|
2605
|
+
default: return;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
function getUnsupportedPromptContentMessage(prompt, agentCapabilities) {
|
|
2609
|
+
for (const [index, block] of prompt.entries()) {
|
|
2610
|
+
const requirement = promptCapabilityRequirement(block);
|
|
2611
|
+
if (!requirement) continue;
|
|
2612
|
+
if (agentCapabilities?.promptCapabilities?.[requirement.capability] === true) continue;
|
|
2613
|
+
return `prompt[${index}] ${requirement.blockType} content requires agentCapabilities.promptCapabilities.${requirement.capability}`;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
function textPrompt(text) {
|
|
2617
|
+
return [{
|
|
2618
|
+
type: "text",
|
|
2619
|
+
text
|
|
2620
|
+
}];
|
|
2621
|
+
}
|
|
2622
|
+
function parseStructuredPrompt(source) {
|
|
2623
|
+
if (!source.startsWith("[")) return;
|
|
2624
|
+
try {
|
|
2625
|
+
const parsed = JSON.parse(source);
|
|
2626
|
+
if (isPromptInput(parsed)) return parsed;
|
|
2627
|
+
if (Array.isArray(parsed)) throw new PromptInputValidationError(parsed.map((entry, index) => getContentBlockValidationError(entry, index)).find((message) => message !== void 0) ?? "Structured prompt JSON must be an array of valid ACP content blocks");
|
|
2628
|
+
return;
|
|
2629
|
+
} catch (error) {
|
|
2630
|
+
if (error instanceof PromptInputValidationError) throw error;
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
function parsePromptSource(source) {
|
|
2635
|
+
const trimmed = source.trim();
|
|
2636
|
+
const structured = parseStructuredPrompt(trimmed);
|
|
2637
|
+
if (structured) return structured;
|
|
2638
|
+
if (!trimmed) return [];
|
|
2639
|
+
return textPrompt(trimmed);
|
|
2640
|
+
}
|
|
2641
|
+
function mergePromptSourceWithText(source, suffixText) {
|
|
2642
|
+
const prompt = parsePromptSource(source);
|
|
2643
|
+
const appended = suffixText.trim();
|
|
2644
|
+
if (!appended) return prompt;
|
|
2645
|
+
if (prompt.length === 0) return textPrompt(appended);
|
|
2646
|
+
return [...prompt, ...textPrompt(appended)];
|
|
2647
|
+
}
|
|
2648
|
+
function promptToDisplayText(prompt) {
|
|
2649
|
+
return prompt.map((block) => contentBlockDisplayText(block)).filter((entry) => entry.trim().length > 0).join("\n\n").trim();
|
|
2650
|
+
}
|
|
2651
|
+
function contentBlockDisplayText(block) {
|
|
2652
|
+
switch (block.type) {
|
|
2653
|
+
case "text": return block.text;
|
|
2654
|
+
case "resource_link": return block.title ?? block.name ?? block.uri;
|
|
2655
|
+
case "resource": return resourceBlockDisplayText(block);
|
|
2656
|
+
case "image": return `[image] ${block.mimeType}`;
|
|
2657
|
+
case "audio": return `[audio] ${block.mimeType}`;
|
|
2658
|
+
default: return "";
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
function resourceBlockDisplayText(block) {
|
|
2662
|
+
return "text" in block.resource && typeof block.resource.text === "string" ? block.resource.text : block.resource.uri;
|
|
2663
|
+
}
|
|
2664
|
+
//#endregion
|
|
2602
2665
|
//#region src/acp/process-descendants.ts
|
|
2603
2666
|
function hasStaleWindowsParent(identity, parent) {
|
|
2604
2667
|
return identity.birth.kind === "windows-creation" && (parent?.birth.kind !== "windows-creation" || parent.birth.value > identity.birth.value);
|
|
@@ -2623,6 +2686,8 @@ var ProcessDescendants = class {
|
|
|
2623
2686
|
rootBirth;
|
|
2624
2687
|
pending;
|
|
2625
2688
|
retired = false;
|
|
2689
|
+
failedRootObservation = false;
|
|
2690
|
+
unresolvedOwnership = false;
|
|
2626
2691
|
ownProcessGroup;
|
|
2627
2692
|
captureGroupAfterExit;
|
|
2628
2693
|
groupExitedAt;
|
|
@@ -2657,10 +2722,18 @@ var ProcessDescendants = class {
|
|
|
2657
2722
|
}
|
|
2658
2723
|
return true;
|
|
2659
2724
|
} catch {
|
|
2660
|
-
|
|
2725
|
+
this.recordSnapshotFailure(captureRootGroup);
|
|
2661
2726
|
return false;
|
|
2662
2727
|
}
|
|
2663
2728
|
}
|
|
2729
|
+
recordSnapshotFailure(captureRootGroup) {
|
|
2730
|
+
if (isChildProcessRunning(this.child)) {
|
|
2731
|
+
this.failedRootObservation = true;
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (captureRootGroup) this.unresolvedOwnership = true;
|
|
2735
|
+
this.captureGroupAfterExit = false;
|
|
2736
|
+
}
|
|
2664
2737
|
requiredSnapshotPids(rootWasRunning) {
|
|
2665
2738
|
return [...this.identities.keys(), ...rootWasRunning && this.child.pid ? [this.child.pid] : []];
|
|
2666
2739
|
}
|
|
@@ -2672,6 +2745,10 @@ var ProcessDescendants = class {
|
|
|
2672
2745
|
if (observed && compareProcessBirthIdentity(identity.birth, observed.birth) === "matching") owned.add(pid);
|
|
2673
2746
|
}
|
|
2674
2747
|
this.includeRoot(table, owned);
|
|
2748
|
+
if (owned.has(this.child.pid ?? 0)) {
|
|
2749
|
+
this.failedRootObservation = false;
|
|
2750
|
+
this.unresolvedOwnership = false;
|
|
2751
|
+
}
|
|
2675
2752
|
if (this.ownProcessGroup) this.includeProcessGroup(table, owned, rootWasRunning);
|
|
2676
2753
|
includeProcessDescendants(table, owned);
|
|
2677
2754
|
owned.delete(this.child.pid ?? 0);
|
|
@@ -2692,29 +2769,40 @@ var ProcessDescendants = class {
|
|
|
2692
2769
|
}
|
|
2693
2770
|
includeProcessGroup(table, owned, rootWasRunning) {
|
|
2694
2771
|
const root = this.child.pid;
|
|
2695
|
-
if (root
|
|
2696
|
-
|
|
2772
|
+
if (!root || !(rootWasRunning || [...owned].some((pid) => table.get(pid)?.groupPid === root))) return;
|
|
2773
|
+
this.unresolvedOwnership = !this.admitGroupMembers(table, owned, root);
|
|
2774
|
+
if (!this.unresolvedOwnership) this.failedRootObservation = false;
|
|
2775
|
+
}
|
|
2776
|
+
admitGroupMembers(table, owned, groupPid) {
|
|
2777
|
+
let verified = true;
|
|
2778
|
+
for (const identity of table.values()) {
|
|
2779
|
+
if (identity.groupPid !== groupPid) continue;
|
|
2780
|
+
const beforeExit = this.startedBeforeRootExit(identity);
|
|
2781
|
+
if (beforeExit === void 0) verified = false;
|
|
2782
|
+
else if (beforeExit) owned.add(identity.pid);
|
|
2697
2783
|
}
|
|
2784
|
+
return verified;
|
|
2698
2785
|
}
|
|
2699
2786
|
startedBeforeRootExit(identity) {
|
|
2700
2787
|
const cutoff = this.groupExitedAt;
|
|
2701
2788
|
if (cutoff === void 0) return true;
|
|
2702
|
-
if (cutoff === null) return
|
|
2703
|
-
if (identity.birth.kind !== "linux-proc") return typeof cutoff === "number"
|
|
2704
|
-
if (typeof cutoff === "number" || identity.birth.timeNamespace !== cutoff.timeNamespace || !identity.clockTicksPerSecond) return
|
|
2789
|
+
if (cutoff === null) return;
|
|
2790
|
+
if (identity.birth.kind !== "linux-proc") return typeof cutoff === "number" ? Date.parse(identity.birth.value) <= cutoff : void 0;
|
|
2791
|
+
if (typeof cutoff === "number" || identity.birth.timeNamespace !== cutoff.timeNamespace || !identity.clockTicksPerSecond) return;
|
|
2705
2792
|
return BigInt(identity.birth.startTicks) * 100n < (cutoff.centiseconds + 1n) * identity.clockTicksPerSecond;
|
|
2706
2793
|
}
|
|
2707
2794
|
async signal(signal, timeoutMs) {
|
|
2708
2795
|
if (!await this.capture(timeoutMs) || this.retired) return;
|
|
2709
2796
|
for (const pid of this.identities.keys()) try {
|
|
2710
2797
|
process.kill(pid, signal);
|
|
2711
|
-
} catch {
|
|
2712
|
-
this.identities.delete(pid);
|
|
2713
|
-
}
|
|
2798
|
+
} catch {}
|
|
2714
2799
|
}
|
|
2715
2800
|
hasTrackedProcesses() {
|
|
2716
2801
|
return this.identities.size > 0;
|
|
2717
2802
|
}
|
|
2803
|
+
hasUnresolvedOwnership() {
|
|
2804
|
+
return this.unresolvedOwnership || !this.ownProcessGroup && this.failedRootObservation && !isChildProcessRunning(this.child);
|
|
2805
|
+
}
|
|
2718
2806
|
async waitForExit(timeoutMs) {
|
|
2719
2807
|
const deadline = performance.now() + timeoutMs;
|
|
2720
2808
|
do {
|
|
@@ -2731,46 +2819,6 @@ var ProcessDescendants = class {
|
|
|
2731
2819
|
}
|
|
2732
2820
|
};
|
|
2733
2821
|
//#endregion
|
|
2734
|
-
//#region src/session/lock-owner.ts
|
|
2735
|
-
const OBSERVATION_REUSE_MS = 1e3;
|
|
2736
|
-
const IDENTITY_QUERY_TIMEOUT_MS = 1e3;
|
|
2737
|
-
function lockOwnerPid(value) {
|
|
2738
|
-
if (!value || typeof value !== "object" || !("pid" in value)) return;
|
|
2739
|
-
const pid = value.pid;
|
|
2740
|
-
return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 ? pid : void 0;
|
|
2741
|
-
}
|
|
2742
|
-
function canReuseObservation(preserved, pid, identity, fresh) {
|
|
2743
|
-
return !fresh && preserved?.pid === pid && compareProcessBirthIdentity(preserved.identity, identity) === "matching" && performance.now() - preserved.checkedAt < OBSERVATION_REUSE_MS;
|
|
2744
|
-
}
|
|
2745
|
-
async function createLockOwner(options = {}) {
|
|
2746
|
-
const { signal, capturedIdentity } = options;
|
|
2747
|
-
signal?.throwIfAborted();
|
|
2748
|
-
const processIdentity = capturedIdentity === void 0 ? await getOwnProcessIdentity() : capturedIdentity.processIdentity;
|
|
2749
|
-
signal?.throwIfAborted();
|
|
2750
|
-
let preserved;
|
|
2751
|
-
return {
|
|
2752
|
-
payload: {
|
|
2753
|
-
pid: process.pid,
|
|
2754
|
-
processIdentity
|
|
2755
|
-
},
|
|
2756
|
-
async hasExited(payload, fresh, signal) {
|
|
2757
|
-
signal?.throwIfAborted();
|
|
2758
|
-
const pid = lockOwnerPid(payload);
|
|
2759
|
-
if (!pid) return false;
|
|
2760
|
-
const identity = parseProcessBirthIdentity(payload.processIdentity);
|
|
2761
|
-
if (identity && canReuseObservation(preserved, pid, identity, fresh)) return false;
|
|
2762
|
-
const incarnation = await observeProcessIncarnation(pid, identity, IDENTITY_QUERY_TIMEOUT_MS);
|
|
2763
|
-
signal?.throwIfAborted();
|
|
2764
|
-
if (identity && incarnation !== "gone") preserved = {
|
|
2765
|
-
pid,
|
|
2766
|
-
identity,
|
|
2767
|
-
checkedAt: performance.now()
|
|
2768
|
-
};
|
|
2769
|
-
return incarnation === "gone";
|
|
2770
|
-
}
|
|
2771
|
-
};
|
|
2772
|
-
}
|
|
2773
|
-
//#endregion
|
|
2774
2822
|
//#region src/session/queue/paths.ts
|
|
2775
2823
|
function shortHash(value, length) {
|
|
2776
2824
|
return createHash("sha256").update(value).digest("hex").slice(0, length);
|
|
@@ -4039,7 +4087,7 @@ function parseStringResultOwnerMessage(message, context, type, field) {
|
|
|
4039
4087
|
function parseSetModelOwnerMessage(message, context) {
|
|
4040
4088
|
if (typeof message.modelId !== "string") return null;
|
|
4041
4089
|
const response = asRecord(message.response);
|
|
4042
|
-
if (message.response !== void 0 && (!response || !Array.isArray(response.configOptions))) return null;
|
|
4090
|
+
if (message.response !== void 0 && (!response || response.configOptions !== void 0 && !Array.isArray(response.configOptions))) return null;
|
|
4043
4091
|
return {
|
|
4044
4092
|
type: "set_model_result",
|
|
4045
4093
|
...context,
|
|
@@ -4049,7 +4097,7 @@ function parseSetModelOwnerMessage(message, context) {
|
|
|
4049
4097
|
}
|
|
4050
4098
|
function parseSetConfigOptionOwnerMessage(message, context) {
|
|
4051
4099
|
const response = asRecord(message.response);
|
|
4052
|
-
if (!response || !Array.isArray(response.configOptions)) return null;
|
|
4100
|
+
if (!response || response.configOptions !== void 0 && !Array.isArray(response.configOptions)) return null;
|
|
4053
4101
|
return {
|
|
4054
4102
|
type: "set_config_option_result",
|
|
4055
4103
|
...context,
|
|
@@ -4699,7 +4747,6 @@ var SessionQueueOwner = class SessionQueueOwner {
|
|
|
4699
4747
|
};
|
|
4700
4748
|
//#endregion
|
|
4701
4749
|
//#region src/session/queue/ipc.ts
|
|
4702
|
-
const MAX_MESSAGE_BUFFER_SIZE = 10485760;
|
|
4703
4750
|
function assertOwnerGeneration(owner, message) {
|
|
4704
4751
|
if (owner.ownerGeneration !== void 0 && message.ownerGeneration !== void 0 && message.ownerGeneration !== owner.ownerGeneration) throw new QueueProtocolError("Queue owner returned mismatched generation", {
|
|
4705
4752
|
detailCode: "QUEUE_OWNER_GENERATION_MISMATCH",
|
|
@@ -4785,7 +4832,7 @@ async function runQueueOwnerRequest(options) {
|
|
|
4785
4832
|
socket.setEncoding("utf8");
|
|
4786
4833
|
return await new Promise((resolve, reject) => {
|
|
4787
4834
|
let settled = false;
|
|
4788
|
-
|
|
4835
|
+
const responseFragments = [];
|
|
4789
4836
|
const state = { acknowledged: false };
|
|
4790
4837
|
const finishResolve = (result) => {
|
|
4791
4838
|
if (settled) return;
|
|
@@ -4829,19 +4876,21 @@ async function runQueueOwnerRequest(options) {
|
|
|
4829
4876
|
}
|
|
4830
4877
|
};
|
|
4831
4878
|
socket.on("data", (chunk) => {
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4879
|
+
try {
|
|
4880
|
+
let offset = 0;
|
|
4881
|
+
let newline = chunk.indexOf("\n");
|
|
4882
|
+
while (newline >= 0) {
|
|
4883
|
+
if (settled) return;
|
|
4884
|
+
responseFragments.push(chunk.slice(offset, newline));
|
|
4885
|
+
const line = responseFragments.join("").trim();
|
|
4886
|
+
responseFragments.length = 0;
|
|
4887
|
+
if (line.length > 0) processLine(line);
|
|
4888
|
+
offset = newline + 1;
|
|
4889
|
+
newline = chunk.indexOf("\n", offset);
|
|
4890
|
+
}
|
|
4891
|
+
if (!settled && offset < chunk.length) responseFragments.push(chunk.slice(offset));
|
|
4892
|
+
} catch (error) {
|
|
4893
|
+
finishReject(uncertainQueueOutcome(error));
|
|
4845
4894
|
}
|
|
4846
4895
|
});
|
|
4847
4896
|
socket.once("error", (error) => {
|
|
@@ -5168,6 +5217,6 @@ async function trySetConfigOptionOnRunningOwner(sessionId, configId, value, time
|
|
|
5168
5217
|
});
|
|
5169
5218
|
}
|
|
5170
5219
|
//#endregion
|
|
5171
|
-
export { resetPerfMetrics as $, findSession as A,
|
|
5220
|
+
export { resetPerfMetrics as $, findSession as A, PERMISSION_MODES as At, assertPersistedKeyPolicy as B, GeminiAcpStartupTimeoutError as Bt, textPrompt as C, normalizeOutputError as Ct, DEFAULT_HISTORY_LIMIT as D, EXIT_CODES as Dt, observeProcessIncarnation as E, AUTH_POLICIES as Et, normalizeName as F, AgentSpawnError as Ft, SESSION_JOURNAL_SCHEMA as G, SessionModeReplayError as Gt, serializeSessionRecordForDisk as H, PermissionPromptUnavailableError as Ht, pruneSessions as I, AgentStartupError as It, watchSession as J, SessionResumeRequiredError as Jt, SessionJournalReader as K, SessionModelReplayError as Kt, readSessionRecord as L, AuthPolicyError as Lt, isoNow as M, SESSION_RECORD_SCHEMA as Mt, listSessions as N, AcpxOperationalError as Nt, absolutePath as O, NON_INTERACTIVE_PERMISSION_POLICIES as Ot, listSessionsForAgent as P, AgentDisconnectedError as Pt, measurePerf as Q, resolveSessionRecord as R, ClaudeAcpSessionCreateTimeoutError as Rt, promptToDisplayText as S, isRetryablePromptError as St, lockOwnerPid as T, isAcpResourceNotFoundError as Tt, extractAgentSessionId as U, QueueConnectionError as Ut, parseSessionRecord as V, PermissionDeniedError as Vt, normalizeAgentSessionId as W, SessionConfigOptionReplayError as Wt, getPerfMetricsSnapshot as X, formatPerfMetric as Y, UnsupportedPromptContentError as Yt, incrementPerfCounter as Z, ProcessDescendants as _, _usingCtx as _t, trySetModelOnRunningOwner as a, isSessionUpdateNotification as at, mergePromptSourceWithText as b, formatErrorMessage as bt, probeQueueOwnerHealth as c, parsePromptStopReason as ct, releaseQueueOwnerLease as d, sessionBaseDir as dt, setPerfGauge as et, terminateProcess as f, sessionEventActivePath as ft, QueueLeaseGuardSettlementError as g, writePrivateJsonFile as gt, waitMs as h, writePrivateFile as ht, trySetModeOnRunningOwner as i, isAcpMessageObject as it, findSessionByDirectoryWalk as j, PERMISSION_POLICY_ACTIONS as jt, findGitRepositoryRoot as k, OUTPUT_FORMATS as kt, readQueueOwnerRecord as l, DEFAULT_EVENT_SEGMENT_MAX_BYTES as lt, tryAcquireQueueOwnerLease as m, sessionEventSegmentPath as mt, tryCloseSessionOnRunningOwner as n, extractSessionUpdateNotification as nt, trySubmitToRunningOwner as o, parseJsonRpcErrorMessage as ot, terminateQueueOwnerForSession as p, sessionEventLockPath as pt, SessionWatchError as q, SessionNotFoundError as qt, trySetConfigOptionOnRunningOwner as r, isAcpJsonRpcMessage as rt, SessionQueueOwner as s, parsePermissionNotice as st, tryCancelOnRunningOwner as t, startPerfTimer as tt, refreshQueueOwnerLease as u, defaultSessionEventLog as ut, PromptInputValidationError as v, isProcessAlive as vt, createLockOwner as w, extractAcpError as wt, parsePromptSource as x, isAcpQueryClosedBeforeResponseError as xt, getUnsupportedPromptContentMessage as y, exitCodeForOutputErrorCode as yt, writeSessionRecord as z, CopilotAcpUnsupportedError as zt };
|
|
5172
5221
|
|
|
5173
|
-
//# sourceMappingURL=ipc-
|
|
5222
|
+
//# sourceMappingURL=ipc-BW06Pbb8.js.map
|