ds-harness-remote 0.4.16 → 0.4.18
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/client-runtime.d.ts.map +1 -1
- package/dist/client-runtime.js +3 -3
- package/dist/client-runtime.js.map +1 -1
- package/dist/client.github.js +77 -36
- package/dist/client.js +77 -36
- package/dist/client.js.map +1 -1
- package/dist/codex/codex-image-codec.d.ts +7 -0
- package/dist/codex/codex-image-codec.d.ts.map +1 -0
- package/dist/codex/codex-image-codec.js +288 -0
- package/dist/codex/codex-image-codec.js.map +1 -0
- package/dist/codex/domain.d.ts +2 -0
- package/dist/codex/domain.d.ts.map +1 -1
- package/dist/codex/domain.js +15 -0
- package/dist/codex/domain.js.map +1 -1
- package/dist/codex/session-id.d.ts +10 -0
- package/dist/codex/session-id.d.ts.map +1 -0
- package/dist/codex/session-id.js +15 -0
- package/dist/codex/session-id.js.map +1 -0
- package/dist/codex/virtual-harness.d.ts +3 -2
- package/dist/codex/virtual-harness.d.ts.map +1 -1
- package/dist/codex/virtual-harness.js +33 -270
- package/dist/codex/virtual-harness.js.map +1 -1
- package/dist/codex-workspace-bridge.d.ts +108 -0
- package/dist/codex-workspace-bridge.d.ts.map +1 -0
- package/dist/codex-workspace-bridge.js +501 -0
- package/dist/codex-workspace-bridge.js.map +1 -0
- package/dist/config.d.ts +13 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -2
- package/dist/config.js.map +1 -1
- package/dist/control-runtime.d.ts +17 -3
- package/dist/control-runtime.d.ts.map +1 -1
- package/dist/control-runtime.js +4 -2
- package/dist/control-runtime.js.map +1 -1
- package/dist/harness-api-bridge.d.ts.map +1 -1
- package/dist/harness-api-bridge.js +2 -53
- package/dist/harness-api-bridge.js.map +1 -1
- package/dist/harness-api-history.d.ts +3 -0
- package/dist/harness-api-history.d.ts.map +1 -0
- package/dist/harness-api-history.js +55 -0
- package/dist/harness-api-history.js.map +1 -0
- package/dist/harness-remote-bridge.d.ts +4 -2
- package/dist/harness-remote-bridge.d.ts.map +1 -1
- package/dist/harness-remote-bridge.js +61 -3
- package/dist/harness-remote-bridge.js.map +1 -1
- package/dist/index.d.ts +24 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1418 -628
- package/dist/index.js.map +4 -4
- package/dist/remote-api-proxy.d.ts +5 -1
- package/dist/remote-api-proxy.d.ts.map +1 -1
- package/dist/remote-api-proxy.js +74 -2
- package/dist/remote-api-proxy.js.map +1 -1
- package/dist/remote-typert-gateway.d.ts +6 -1
- package/dist/remote-typert-gateway.d.ts.map +1 -1
- package/dist/remote-typert-gateway.js +58 -1
- package/dist/remote-typert-gateway.js.map +1 -1
- package/dist/service.d.ts +7 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +8 -2
- package/dist/service.js.map +1 -1
- package/dist/terminal-policy.d.ts.map +1 -1
- package/dist/terminal-policy.js +8 -2
- package/dist/terminal-policy.js.map +1 -1
- package/dist/typert-gateway-contract.d.ts +11 -1
- package/dist/typert-gateway-contract.d.ts.map +1 -1
- package/dist/typert-gateway-switch.d.ts.map +1 -1
- package/dist/typert-gateway-switch.js +65 -4
- package/dist/typert-gateway-switch.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dsh-plugin.json +1 -1
- package/package.json +18 -18
- package/public.d.ts +2 -2
|
@@ -80,6 +80,7 @@ export declare class CodexVirtualHarness implements RemoteTypertGatewayTarget {
|
|
|
80
80
|
private readonly client;
|
|
81
81
|
private readonly host;
|
|
82
82
|
private readonly sessionGeneration;
|
|
83
|
+
private readonly hostCarrier?;
|
|
83
84
|
readonly api: ApiProxy;
|
|
84
85
|
private catalog?;
|
|
85
86
|
private readonly workspaceStreams;
|
|
@@ -104,11 +105,11 @@ export declare class CodexVirtualHarness implements RemoteTypertGatewayTarget {
|
|
|
104
105
|
constructor(client: CodexClientLike, host: {
|
|
105
106
|
deviceId: string;
|
|
106
107
|
name: string;
|
|
107
|
-
}, sessionGeneration?: HarnessSessionGeneration);
|
|
108
|
+
}, sessionGeneration?: HarnessSessionGeneration, hostCarrier?: RemoteTypertGatewayTarget | undefined);
|
|
108
109
|
static remote(core: ConstructorParameters<typeof CodexRemoteClient>[0], host: {
|
|
109
110
|
deviceId: string;
|
|
110
111
|
name: string;
|
|
111
|
-
}, sessionGeneration?: HarnessSessionGeneration): CodexVirtualHarness;
|
|
112
|
+
}, sessionGeneration?: HarnessSessionGeneration, hostCarrier?: RemoteTypertGatewayTarget): CodexVirtualHarness;
|
|
112
113
|
workspaces(signal?: AbortSignal): Promise<CodexVirtualWorkspaceView[]>;
|
|
113
114
|
selectWorkspace(workspaceId: string, signal?: AbortSignal): Promise<CodexVirtualWorkspaceView>;
|
|
114
115
|
preferredSessionId(signal?: AbortSignal): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-harness.d.ts","sourceRoot":"","sources":["../../src/codex/virtual-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA2B,MAAM,oCAAoC,CAAA;AAC3F,OAAO,EACL,iBAAiB,EAIlB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAChB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,KAAK,EAAyB,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC1F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"virtual-harness.d.ts","sourceRoot":"","sources":["../../src/codex/virtual-harness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA2B,MAAM,oCAAoC,CAAA;AAC3F,OAAO,EACL,iBAAiB,EAIlB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EAChB,MAAM,+BAA+B,CAAA;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yBAAyB,CACvC,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,iBAAiB,GAAE,wBAAmC,GACrD,kBAAkB,CAqFpB;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACzE,sBAAsB,CAwBxB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CodexRemoteClient, deriveCodexCwdWorkspaces, projectCodexThread, } from '@dsh-remote/client-core';
|
|
2
2
|
import { codexPermissionPresetFromResponse } from './permissions.js';
|
|
3
|
+
import { collectImageBlocks, contentBlocks, isCanonicalBase64, toolOutputImageBlocks, } from './codex-image-codec.js';
|
|
3
4
|
const CODEX_SESSION_PREFIX = 'codex:';
|
|
4
5
|
const CODEX_WORKSPACE_PREFIX = 'codex-workspace:';
|
|
5
6
|
const CODEX_PROVIDER = 'codex';
|
|
@@ -16,7 +17,18 @@ const MAX_CODEX_PROMPT_TEXT = 256 * 1024;
|
|
|
16
17
|
const MAX_CODEX_IMAGE_BASE64 = 288 * 1024 * 1024;
|
|
17
18
|
const CODEX_IMAGE_MEDIA_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif']);
|
|
18
19
|
const CODEX_IMAGE_ATTACHMENT_PREFIX = 'codex-image:';
|
|
19
|
-
const
|
|
20
|
+
const HOST_WORKSPACE_ENDPOINTS = new Set([
|
|
21
|
+
'workspaceFiles/list', 'workspaceFiles/stat', 'workspaceFiles/read', 'workspaceFiles/readBytes',
|
|
22
|
+
'workspaceFiles/readAll', 'workspaceFiles/readRelated', 'terminal/environment', 'terminal/shells',
|
|
23
|
+
'terminal/list', 'terminal/create', 'terminal/write', 'terminal/resize', 'terminal/rename', 'terminal/close',
|
|
24
|
+
]);
|
|
25
|
+
const HOST_WORKSPACE_STREAM_ENDPOINTS = new Set(['workspaceFiles/changes', 'terminal/follow', 'terminal/retain']);
|
|
26
|
+
function isHostWorkspaceEndpoint(endpoint) {
|
|
27
|
+
return HOST_WORKSPACE_ENDPOINTS.has(endpoint);
|
|
28
|
+
}
|
|
29
|
+
function isHostWorkspaceStreamEndpoint(endpoint) {
|
|
30
|
+
return HOST_WORKSPACE_STREAM_ENDPOINTS.has(endpoint);
|
|
31
|
+
}
|
|
20
32
|
export function codexProjectWorkspaceId(projectId) {
|
|
21
33
|
return `${CODEX_WORKSPACE_PREFIX}project:${projectId}`;
|
|
22
34
|
}
|
|
@@ -33,6 +45,7 @@ export class CodexVirtualHarness {
|
|
|
33
45
|
client;
|
|
34
46
|
host;
|
|
35
47
|
sessionGeneration;
|
|
48
|
+
hostCarrier;
|
|
36
49
|
api;
|
|
37
50
|
catalog;
|
|
38
51
|
workspaceStreams = new Set();
|
|
@@ -54,14 +67,15 @@ export class CodexVirtualHarness {
|
|
|
54
67
|
commandSeq = 0;
|
|
55
68
|
selectedWorkspaceId;
|
|
56
69
|
closed = false;
|
|
57
|
-
constructor(client, host, sessionGeneration = 'legacy') {
|
|
70
|
+
constructor(client, host, sessionGeneration = 'legacy', hostCarrier) {
|
|
58
71
|
this.client = client;
|
|
59
72
|
this.host = host;
|
|
60
73
|
this.sessionGeneration = sessionGeneration;
|
|
74
|
+
this.hostCarrier = hostCarrier;
|
|
61
75
|
this.api = this.createApiProxy();
|
|
62
76
|
}
|
|
63
|
-
static remote(core, host, sessionGeneration = 'legacy') {
|
|
64
|
-
return new CodexVirtualHarness(new CodexRemoteClient(core), host, sessionGeneration);
|
|
77
|
+
static remote(core, host, sessionGeneration = 'legacy', hostCarrier) {
|
|
78
|
+
return new CodexVirtualHarness(new CodexRemoteClient(core), host, sessionGeneration, hostCarrier);
|
|
65
79
|
}
|
|
66
80
|
async workspaces(signal) {
|
|
67
81
|
return (await this.refreshCatalog(signal)).workspaces;
|
|
@@ -115,6 +129,11 @@ export class CodexVirtualHarness {
|
|
|
115
129
|
}
|
|
116
130
|
async dispatch(endpoint, payload, signal) {
|
|
117
131
|
try {
|
|
132
|
+
if (isHostWorkspaceEndpoint(endpoint)) {
|
|
133
|
+
if (this.hostCarrier === undefined)
|
|
134
|
+
return fail('method-not-found', `CodeX virtual Harness does not implement ${endpoint}.`);
|
|
135
|
+
return await this.hostCarrier.dispatch(endpoint, payload, signal);
|
|
136
|
+
}
|
|
118
137
|
const args = carrierArgs(payload);
|
|
119
138
|
switch (endpoint) {
|
|
120
139
|
case '$events/result': return business(await this.answerRemoteEvent(args, signal));
|
|
@@ -173,6 +192,16 @@ export class CodexVirtualHarness {
|
|
|
173
192
|
}
|
|
174
193
|
}
|
|
175
194
|
async open(endpoint, payload, signal) {
|
|
195
|
+
if (isHostWorkspaceStreamEndpoint(endpoint)) {
|
|
196
|
+
if (this.hostCarrier === undefined) {
|
|
197
|
+
throw Object.assign(new Error(`CodeX virtual Harness does not implement stream ${endpoint}.`), {
|
|
198
|
+
isDSHRemoteError: true,
|
|
199
|
+
code: 'method-not-found',
|
|
200
|
+
details: {},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return this.hostCarrier.open(endpoint, payload, signal);
|
|
204
|
+
}
|
|
176
205
|
const args = carrierArgs(payload);
|
|
177
206
|
if (endpoint === 'workspace/follow')
|
|
178
207
|
return this.workspaceFollow(signal);
|
|
@@ -1816,268 +1845,6 @@ function messageContent(item, attachmentSeed, fallbackType, fallbackText, supple
|
|
|
1816
1845
|
}
|
|
1817
1846
|
return [{ type: fallbackType, text: fallbackText ?? '' }];
|
|
1818
1847
|
}
|
|
1819
|
-
function toolOutputImageBlocks(item) {
|
|
1820
|
-
const candidates = [
|
|
1821
|
-
record(item.result).content,
|
|
1822
|
-
record(item.output).content,
|
|
1823
|
-
item.contentItems,
|
|
1824
|
-
Array.isArray(item.output) ? item.output : undefined,
|
|
1825
|
-
];
|
|
1826
|
-
for (const candidate of candidates) {
|
|
1827
|
-
if (!Array.isArray(candidate))
|
|
1828
|
-
continue;
|
|
1829
|
-
const images = candidate.flatMap(value => {
|
|
1830
|
-
const block = record(value);
|
|
1831
|
-
return isImageContent(block) && parseImageBlock(block) !== undefined ? [block] : [];
|
|
1832
|
-
});
|
|
1833
|
-
if (images.length > 0)
|
|
1834
|
-
return images;
|
|
1835
|
-
}
|
|
1836
|
-
return [];
|
|
1837
|
-
}
|
|
1838
|
-
function contentBlocks(value, attachmentSeed) {
|
|
1839
|
-
if (typeof value === 'string')
|
|
1840
|
-
return [{ type: 'text', text: value }];
|
|
1841
|
-
if (!Array.isArray(value))
|
|
1842
|
-
return [];
|
|
1843
|
-
const blocks = [];
|
|
1844
|
-
let imageIndex = 0;
|
|
1845
|
-
for (const raw of value) {
|
|
1846
|
-
if (typeof raw === 'string') {
|
|
1847
|
-
blocks.push({ type: 'text', text: raw });
|
|
1848
|
-
continue;
|
|
1849
|
-
}
|
|
1850
|
-
const block = record(raw);
|
|
1851
|
-
const image = imageContentBlock(block, attachmentSeed, imageIndex);
|
|
1852
|
-
if (image !== undefined) {
|
|
1853
|
-
imageIndex += 1;
|
|
1854
|
-
blocks.push(image);
|
|
1855
|
-
continue;
|
|
1856
|
-
}
|
|
1857
|
-
const text = string(block.text) ?? string(block.content);
|
|
1858
|
-
if (text !== undefined)
|
|
1859
|
-
blocks.push({ type: block.type === 'reasoning' ? 'reasoning' : 'text', text });
|
|
1860
|
-
}
|
|
1861
|
-
return blocks;
|
|
1862
|
-
}
|
|
1863
|
-
function imageContentBlock(block, attachmentSeed, index) {
|
|
1864
|
-
if (!isImageContent(block))
|
|
1865
|
-
return undefined;
|
|
1866
|
-
const image = parseImageBlock(block);
|
|
1867
|
-
if (image === undefined)
|
|
1868
|
-
return undefined;
|
|
1869
|
-
const dimensions = imageDimensions(image.mediaType, image.data);
|
|
1870
|
-
const name = string(block.name);
|
|
1871
|
-
const attachment = {
|
|
1872
|
-
attachmentId: `${CODEX_IMAGE_ATTACHMENT_PREFIX}${hashString(`${attachmentSeed}:${index}`)}:${index}`,
|
|
1873
|
-
mediaType: image.mediaType,
|
|
1874
|
-
bytes: base64ByteLength(image.data),
|
|
1875
|
-
width: dimensions.width,
|
|
1876
|
-
height: dimensions.height,
|
|
1877
|
-
...(name === undefined ? {} : { name }),
|
|
1878
|
-
};
|
|
1879
|
-
return {
|
|
1880
|
-
type: 'image',
|
|
1881
|
-
attachment,
|
|
1882
|
-
mediaType: image.mediaType,
|
|
1883
|
-
data: image.data,
|
|
1884
|
-
url: image.url,
|
|
1885
|
-
...(name === undefined ? {} : { name }),
|
|
1886
|
-
};
|
|
1887
|
-
}
|
|
1888
|
-
function isImageContent(block) {
|
|
1889
|
-
return block.type === 'image' || block.type === 'input_image';
|
|
1890
|
-
}
|
|
1891
|
-
function parseImageBlock(block) {
|
|
1892
|
-
const url = string(block.url)
|
|
1893
|
-
?? string(block.image_url)
|
|
1894
|
-
?? string(record(block.image_url).url);
|
|
1895
|
-
const parsed = url === undefined ? undefined : parseDataImageUrl(url);
|
|
1896
|
-
if (parsed !== undefined)
|
|
1897
|
-
return parsed;
|
|
1898
|
-
const data = string(block.data);
|
|
1899
|
-
if (data === undefined || !isCanonicalBase64(data))
|
|
1900
|
-
return undefined;
|
|
1901
|
-
if (data.length > MAX_CODEX_IMAGE_BASE64)
|
|
1902
|
-
return undefined;
|
|
1903
|
-
const mediaType = string(block.mediaType) ?? string(block.mimeType) ?? sniffImageMediaType(data);
|
|
1904
|
-
return mediaType !== undefined && CODEX_IMAGE_MEDIA_TYPES.has(mediaType)
|
|
1905
|
-
? { mediaType, data, url: `data:${mediaType};base64,${data}` }
|
|
1906
|
-
: undefined;
|
|
1907
|
-
}
|
|
1908
|
-
function parseDataImageUrl(value) {
|
|
1909
|
-
const match = DATA_IMAGE_URL.exec(value);
|
|
1910
|
-
if (match === null)
|
|
1911
|
-
return undefined;
|
|
1912
|
-
const mediaType = match[1];
|
|
1913
|
-
const data = match[2];
|
|
1914
|
-
if (!CODEX_IMAGE_MEDIA_TYPES.has(mediaType) || !isCanonicalBase64(data))
|
|
1915
|
-
return undefined;
|
|
1916
|
-
return { mediaType, data, url: `data:${mediaType};base64,${data}` };
|
|
1917
|
-
}
|
|
1918
|
-
function collectImageBlocks(value, output = []) {
|
|
1919
|
-
if (Array.isArray(value)) {
|
|
1920
|
-
for (const item of value)
|
|
1921
|
-
collectImageBlocks(item, output);
|
|
1922
|
-
return output;
|
|
1923
|
-
}
|
|
1924
|
-
if (!isRecord(value))
|
|
1925
|
-
return output;
|
|
1926
|
-
if (value.type === 'image')
|
|
1927
|
-
output.push(value);
|
|
1928
|
-
for (const [key, child] of Object.entries(value)) {
|
|
1929
|
-
if (key === 'attachment')
|
|
1930
|
-
continue;
|
|
1931
|
-
if (key === 'content' || key === 'message' || key === 'inserted' || key === 'chunk' || key === 'block') {
|
|
1932
|
-
collectImageBlocks(child, output);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
return output;
|
|
1936
|
-
}
|
|
1937
|
-
function base64ByteLength(value) {
|
|
1938
|
-
const padding = value.endsWith('==') ? 2 : value.endsWith('=') ? 1 : 0;
|
|
1939
|
-
return Math.max(1, Math.floor(value.length * 3 / 4) - padding);
|
|
1940
|
-
}
|
|
1941
|
-
function imageDimensions(mediaType, data) {
|
|
1942
|
-
const bytes = base64PrefixBytes(data, 256 * 1024);
|
|
1943
|
-
const parsed = mediaType === 'image/png'
|
|
1944
|
-
? pngDimensions(bytes)
|
|
1945
|
-
: mediaType === 'image/jpeg'
|
|
1946
|
-
? jpegDimensions(bytes)
|
|
1947
|
-
: mediaType === 'image/gif'
|
|
1948
|
-
? gifDimensions(bytes)
|
|
1949
|
-
: mediaType === 'image/webp'
|
|
1950
|
-
? webpDimensions(bytes)
|
|
1951
|
-
: undefined;
|
|
1952
|
-
return parsed ?? { width: 1, height: 1 };
|
|
1953
|
-
}
|
|
1954
|
-
function pngDimensions(bytes) {
|
|
1955
|
-
if (bytes.length < 24
|
|
1956
|
-
|| bytes[0] !== 0x89
|
|
1957
|
-
|| bytes[1] !== 0x50
|
|
1958
|
-
|| bytes[2] !== 0x4e
|
|
1959
|
-
|| bytes[3] !== 0x47
|
|
1960
|
-
|| bytes[4] !== 0x0d
|
|
1961
|
-
|| bytes[5] !== 0x0a
|
|
1962
|
-
|| bytes[6] !== 0x1a
|
|
1963
|
-
|| bytes[7] !== 0x0a)
|
|
1964
|
-
return undefined;
|
|
1965
|
-
return positiveDimensions(readUint32BE(bytes, 16), readUint32BE(bytes, 20));
|
|
1966
|
-
}
|
|
1967
|
-
function jpegDimensions(bytes) {
|
|
1968
|
-
if (bytes.length < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8)
|
|
1969
|
-
return undefined;
|
|
1970
|
-
let offset = 2;
|
|
1971
|
-
while (offset + 9 < bytes.length) {
|
|
1972
|
-
if (bytes[offset] !== 0xff) {
|
|
1973
|
-
offset += 1;
|
|
1974
|
-
continue;
|
|
1975
|
-
}
|
|
1976
|
-
const marker = bytes[offset + 1];
|
|
1977
|
-
offset += 2;
|
|
1978
|
-
if (marker === 0xd8 || marker === 0xd9)
|
|
1979
|
-
continue;
|
|
1980
|
-
if (offset + 2 > bytes.length)
|
|
1981
|
-
return undefined;
|
|
1982
|
-
const length = readUint16BE(bytes, offset);
|
|
1983
|
-
if (length < 2 || offset + length > bytes.length)
|
|
1984
|
-
return undefined;
|
|
1985
|
-
if (isJpegSof(marker) && length >= 7) {
|
|
1986
|
-
return positiveDimensions(readUint16BE(bytes, offset + 5), readUint16BE(bytes, offset + 3));
|
|
1987
|
-
}
|
|
1988
|
-
offset += length;
|
|
1989
|
-
}
|
|
1990
|
-
return undefined;
|
|
1991
|
-
}
|
|
1992
|
-
function gifDimensions(bytes) {
|
|
1993
|
-
if (bytes.length < 10
|
|
1994
|
-
|| bytes[0] !== 0x47
|
|
1995
|
-
|| bytes[1] !== 0x49
|
|
1996
|
-
|| bytes[2] !== 0x46
|
|
1997
|
-
|| bytes[3] !== 0x38
|
|
1998
|
-
|| (bytes[4] !== 0x37 && bytes[4] !== 0x39)
|
|
1999
|
-
|| bytes[5] !== 0x61)
|
|
2000
|
-
return undefined;
|
|
2001
|
-
return positiveDimensions(readUint16LE(bytes, 6), readUint16LE(bytes, 8));
|
|
2002
|
-
}
|
|
2003
|
-
function webpDimensions(bytes) {
|
|
2004
|
-
if (bytes.length < 30
|
|
2005
|
-
|| stringFromBytes(bytes, 0, 4) !== 'RIFF'
|
|
2006
|
-
|| stringFromBytes(bytes, 8, 12) !== 'WEBP')
|
|
2007
|
-
return undefined;
|
|
2008
|
-
const chunk = stringFromBytes(bytes, 12, 16);
|
|
2009
|
-
if (chunk === 'VP8X') {
|
|
2010
|
-
return positiveDimensions(1 + readUint24LE(bytes, 24), 1 + readUint24LE(bytes, 27));
|
|
2011
|
-
}
|
|
2012
|
-
if (chunk === 'VP8L' && bytes[20] === 0x2f) {
|
|
2013
|
-
const b0 = bytes[21];
|
|
2014
|
-
const b1 = bytes[22];
|
|
2015
|
-
const b2 = bytes[23];
|
|
2016
|
-
const b3 = bytes[24];
|
|
2017
|
-
const width = 1 + b0 + ((b1 & 0x3f) << 8);
|
|
2018
|
-
const height = 1 + ((b1 & 0xc0) >> 6) + (b2 << 2) + ((b3 & 0x0f) << 10);
|
|
2019
|
-
return positiveDimensions(width, height);
|
|
2020
|
-
}
|
|
2021
|
-
if (chunk === 'VP8 ' && bytes[23] === 0x9d && bytes[24] === 0x01 && bytes[25] === 0x2a) {
|
|
2022
|
-
return positiveDimensions(readUint16LE(bytes, 26) & 0x3fff, readUint16LE(bytes, 28) & 0x3fff);
|
|
2023
|
-
}
|
|
2024
|
-
return undefined;
|
|
2025
|
-
}
|
|
2026
|
-
function sniffImageMediaType(data) {
|
|
2027
|
-
const bytes = base64PrefixBytes(data, 32);
|
|
2028
|
-
if (pngDimensions(bytes) !== undefined)
|
|
2029
|
-
return 'image/png';
|
|
2030
|
-
if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)
|
|
2031
|
-
return 'image/jpeg';
|
|
2032
|
-
if (gifDimensions(bytes) !== undefined)
|
|
2033
|
-
return 'image/gif';
|
|
2034
|
-
if (bytes.length >= 12 && stringFromBytes(bytes, 0, 4) === 'RIFF' && stringFromBytes(bytes, 8, 12) === 'WEBP')
|
|
2035
|
-
return 'image/webp';
|
|
2036
|
-
return undefined;
|
|
2037
|
-
}
|
|
2038
|
-
function base64PrefixBytes(value, maxBytes) {
|
|
2039
|
-
const chars = value.slice(0, Math.ceil(maxBytes / 3) * 4);
|
|
2040
|
-
let binary;
|
|
2041
|
-
try {
|
|
2042
|
-
binary = atob(chars);
|
|
2043
|
-
}
|
|
2044
|
-
catch {
|
|
2045
|
-
return new Uint8Array();
|
|
2046
|
-
}
|
|
2047
|
-
const bytes = new Uint8Array(Math.min(binary.length, maxBytes));
|
|
2048
|
-
for (let index = 0; index < bytes.length; index += 1)
|
|
2049
|
-
bytes[index] = binary.charCodeAt(index);
|
|
2050
|
-
return bytes;
|
|
2051
|
-
}
|
|
2052
|
-
function readUint16BE(bytes, offset) {
|
|
2053
|
-
return (bytes[offset] << 8) + bytes[offset + 1];
|
|
2054
|
-
}
|
|
2055
|
-
function readUint16LE(bytes, offset) {
|
|
2056
|
-
return bytes[offset] + (bytes[offset + 1] << 8);
|
|
2057
|
-
}
|
|
2058
|
-
function readUint24LE(bytes, offset) {
|
|
2059
|
-
return bytes[offset] + (bytes[offset + 1] << 8) + (bytes[offset + 2] << 16);
|
|
2060
|
-
}
|
|
2061
|
-
function readUint32BE(bytes, offset) {
|
|
2062
|
-
return (bytes[offset] * 0x1000000) + (bytes[offset + 1] * 0x10000) + (bytes[offset + 2] * 0x100) + bytes[offset + 3];
|
|
2063
|
-
}
|
|
2064
|
-
function positiveDimensions(width, height) {
|
|
2065
|
-
return width > 0 && height > 0 ? { width, height } : undefined;
|
|
2066
|
-
}
|
|
2067
|
-
function isJpegSof(marker) {
|
|
2068
|
-
return (marker >= 0xc0 && marker <= 0xc3)
|
|
2069
|
-
|| (marker >= 0xc5 && marker <= 0xc7)
|
|
2070
|
-
|| (marker >= 0xc9 && marker <= 0xcb)
|
|
2071
|
-
|| (marker >= 0xcd && marker <= 0xcf);
|
|
2072
|
-
}
|
|
2073
|
-
function stringFromBytes(bytes, start, end) {
|
|
2074
|
-
if (bytes.length < end)
|
|
2075
|
-
return '';
|
|
2076
|
-
let output = '';
|
|
2077
|
-
for (let index = start; index < end; index += 1)
|
|
2078
|
-
output += String.fromCharCode(bytes[index]);
|
|
2079
|
-
return output;
|
|
2080
|
-
}
|
|
2081
1848
|
function toolResultEvent(item, turn, step, id, resultText) {
|
|
2082
1849
|
const type = string(item.type) ?? 'unknown';
|
|
2083
1850
|
return {
|
|
@@ -2375,10 +2142,6 @@ function codexPromptInput(content) {
|
|
|
2375
2142
|
}
|
|
2376
2143
|
return input;
|
|
2377
2144
|
}
|
|
2378
|
-
function isCanonicalBase64(value) {
|
|
2379
|
-
return value.length >= 4 && value.length % 4 === 0
|
|
2380
|
-
&& /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u.test(value);
|
|
2381
|
-
}
|
|
2382
2145
|
function modelSelectionProjection(selection) {
|
|
2383
2146
|
return { lastUsed: selection, next: selection };
|
|
2384
2147
|
}
|