@witbitz/sdk 0.0.0-stage → 4.3.0
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/LICENSE +21 -0
- package/README.md +20 -2
- package/a2aCore.js +200 -0
- package/a2aShared.js +27 -0
- package/accountErase.js +223 -0
- package/accountIndexDoc.js +122 -0
- package/accountOwner.js +59 -0
- package/accountRecord.js +90 -0
- package/accountScope.js +114 -0
- package/accountSeal.js +42 -0
- package/accountStores.js +173 -0
- package/acctV2App.js +619 -0
- package/acctV2Check.js +29 -0
- package/acctV2Client.js +382 -0
- package/acctV2Keys.js +43 -0
- package/acctV2Legacy.js +14 -0
- package/acctV2Switch.js +80 -0
- package/acctV2UiCore.js +857 -0
- package/acctV2WebAuthn.js +61 -0
- package/acctV2Wire.js +59 -0
- package/address.js +42 -0
- package/attestedBox.js +30 -0
- package/attestedRooms.js +78 -0
- package/awsKey.js +98 -0
- package/backupRecord.js +106 -0
- package/backupVault.js +97 -0
- package/blocks.js +115 -0
- package/blocksPush.js +64 -0
- package/browseSeal.js +103 -0
- package/cbor.js +225 -0
- package/changePush.js +75 -0
- package/chatLock.js +149 -0
- package/chatLockSw.js +13 -0
- package/cloudDeviceBuilds.js +11 -0
- package/cloudDevicePins.js +33 -0
- package/cloudDeviceSeal.js +53 -0
- package/codeBrowse.js +224 -0
- package/codeCloud.js +652 -0
- package/codeCloudKeys.js +112 -0
- package/codeCommands.js +167 -0
- package/codeComputers.js +388 -0
- package/codeEgress.js +123 -0
- package/codeFilesRoutes.js +17 -0
- package/codeMkdir.js +8 -0
- package/codeModes.js +57 -0
- package/codeOrphanKeys.js +42 -0
- package/codeOutputs.js +141 -0
- package/codeRelay.js +505 -0
- package/codeSentinel.js +86 -0
- package/codeTransport.js +295 -0
- package/codeUndo.js +48 -0
- package/compress.js +24 -0
- package/config.js +11 -0
- package/connCatalog.js +164 -0
- package/connDisp.js +76 -0
- package/connOtherWays.js +74 -0
- package/connPending.js +16 -0
- package/connWrap.js +53 -0
- package/connectionEntry.js +89 -0
- package/connections.js +562 -0
- package/credits.js +30 -0
- package/csAttest.js +112 -0
- package/decrypt.html +384 -0
- package/deviceAttest.js +521 -0
- package/deviceCall.js +54 -0
- package/deviceKeyCore.js +41 -0
- package/deviceSeal.js +59 -0
- package/e2ee.js +323 -0
- package/eat.js +103 -0
- package/emailFork.js +275 -0
- package/emailSignIn.js +81 -0
- package/emptySpaces.js +111 -0
- package/encSource.js +55 -0
- package/enclaveAccept.js +214 -0
- package/enclaveClaim.js +241 -0
- package/enclaveRoute.js +102 -0
- package/enclaveSnapshotMerge.js +44 -0
- package/entrySig.js +165 -0
- package/env.js +73 -0
- package/eraseFile.js +58 -0
- package/followImage.js +86 -0
- package/healNames.js +45 -0
- package/idb.js +97 -0
- package/idbSeal.js +119 -0
- package/indexGone.js +12 -0
- package/invite.js +51 -0
- package/inviteEnroll.js +67 -0
- package/inviteSend.js +68 -0
- package/jobAgents.js +87 -0
- package/keptMerge.js +84 -0
- package/l1-worker-src.js +2 -0
- package/l1-worker.js +831 -0
- package/laneConfig.js +57 -0
- package/laneLinkCore.js +177 -0
- package/ledgerView.js +64 -0
- package/manifest.json +220 -0
- package/mcpRecommended.js +25 -0
- package/memberChange.js +123 -0
- package/mkseal.js +101 -0
- package/nativePush.js +153 -0
- package/nitroVerify.js +220 -0
- package/noble-p256.js +27 -0
- package/notice.js +116 -0
- package/notifKey.js +58 -0
- package/offlineBundle.js +62 -0
- package/ohttp.js +177 -0
- package/opencodeWire.js +282 -0
- package/oprf.js +70 -0
- package/ownAgentLink.js +96 -0
- package/ownerPolicy.js +117 -0
- package/package.json +254 -4
- package/pollVerdict.js +33 -0
- package/prefetchPoll.js +60 -0
- package/protectedLocal.js +410 -0
- package/pushCore.js +42 -0
- package/recovery.js +107 -0
- package/regions.js +42 -0
- package/removedMessage.js +11 -0
- package/renameRefusal.js +9 -0
- package/replyQuote.js +34 -0
- package/reqEnvelope.js +126 -0
- package/roomDefaultPrefs.js +76 -0
- package/roomDelete.js +109 -0
- package/roomName.js +177 -0
- package/roomPass.js +256 -0
- package/roomRoster.js +289 -0
- package/roomSettings.js +61 -0
- package/roomState.js +58 -0
- package/roomStreamClient.js +115 -0
- package/rosterCount.js +49 -0
- package/rosterHash.js +13 -0
- package/rowSchema.js +113 -0
- package/safeMedia.js +116 -0
- package/safeMediaPins.js +17 -0
- package/schedulesDoc.js +78 -0
- package/sdkA2A.js +404 -0
- package/sdkAccount.js +470 -0
- package/sdkAccountDoc.js +81 -0
- package/sdkAccountSections.js +223 -0
- package/sdkAgui.js +141 -0
- package/sdkAttest.js +34 -0
- package/sdkBackup.js +480 -0
- package/sdkBackupV2.js +630 -0
- package/sdkBrowserPrivate.js +28 -0
- package/sdkBuilds.js +208 -0
- package/sdkCloudDevice.js +215 -0
- package/sdkComputers.js +480 -0
- package/sdkDictation.js +142 -0
- package/sdkErase.js +283 -0
- package/sdkExports.js +69 -0
- package/sdkInvitations.js +34 -0
- package/sdkKeptAgent.js +188 -0
- package/sdkLaneLink.js +205 -0
- package/sdkPlan.js +94 -0
- package/sdkProtect.js +228 -0
- package/sdkRedact.js +36 -0
- package/sdkRekey.js +307 -0
- package/sdkReport.js +68 -0
- package/sdkSafeMedia.js +255 -0
- package/sdkSchedules.js +39 -0
- package/sdkSpeech.js +54 -0
- package/sdkTurn.js +117 -0
- package/sdkVault.js +124 -0
- package/sealShare.js +18 -0
- package/sealedNames.js +64 -0
- package/sealedReceipt.js +17 -0
- package/sentinelRelease.js +154 -0
- package/shamir.js +85 -0
- package/sharedViews.js +38 -0
- package/sheetChrome.js +450 -0
- package/siri.js +171 -0
- package/spaceClient.js +1418 -0
- package/spaceConfig.js +81 -0
- package/spaceEmailGate.js +813 -0
- package/spaceExport.js +125 -0
- package/spaceFork.js +216 -0
- package/spaceLock.js +358 -0
- package/spacePasskey.js +180 -0
- package/speechOut.js +100 -0
- package/splitKeyClient.js +90 -0
- package/store.js +587 -0
- package/streamHint.js +36 -0
- package/sttCloud.js +220 -0
- package/sttWorklet.js +38 -0
- package/sw-notif-core.js +538 -0
- package/tempList.js +48 -0
- package/tinfoilVerifier.js +78 -0
- package/toolBooks.js +31 -0
- package/toolRules.js +52 -0
- package/turnCerts.js +254 -0
- package/turnFeed.js +58 -0
- package/turnVerdict.js +36 -0
- package/usageReceipts.js +176 -0
- package/usageSummary.js +90 -0
- package/util.js +181 -0
- package/vault-core.js +1958 -0
- package/vault-kit.mjs +354 -0
- package/vault-screens.js +263 -0
- package/vaultAtRest.js +177 -0
- package/vaultCoreLock.js +111 -0
- package/vaultCorePush.js +140 -0
- package/vaultDeviceKey.js +95 -0
- package/vaultEnclaveHandoff.js +114 -0
- package/vaultKeep.js +281 -0
- package/vaultSealedStore.js +77 -0
- package/vaultWorkerHost.js +98 -0
- package/vcWorker.js +34 -0
- package/voiceAttest.js +50 -0
- package/voiceCert.js +51 -0
- package/witbitz-admin.d.ts +135 -0
- package/witbitz-admin.js +529 -0
- package/witbitz-admin.mjs +1459 -0
- package/witbitz-sdk.d.ts +1106 -0
- package/witbitz-sdk.js +3835 -0
- package/workerClient.js +16 -0
- package/workerLiveness.js +21 -0
- package/x509.js +218 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// codeOrphanKeys.js — COMPUTERS THAT HOLD CODING KEYS BUT ARE ON NO LIST (the owner, 2026-10-29: "Why does my laptop appear twice?"
|
|
2
|
+
// — a new laptop was refused "this account already codes on 3 computers (Laptop, Laptop (WSL), Laptop)", and only one
|
|
3
|
+
// "Laptop" was a computer the account still knew). The coding keys live per pairing at the control plane
|
|
4
|
+
// (control-plane/src/lib/codeKeys.mjs); a computer set up again without unpairing first is a NEW pairing, and the old one's
|
|
5
|
+
// keys stay live under the same name, counted against the account's computers (one free, three when invited). The Computers list is the account's registry, so
|
|
6
|
+
// its Remove could never reach them. The control plane has listed every computer with live keys all along
|
|
7
|
+
// (POST /v1/spaces/code-keys/list); this reads it and offers Remove for the ones the registry does not name.
|
|
8
|
+
export const CODE_KEYS_LIST = 'https://api.witbitz.chat/v1/spaces/code-keys/list'
|
|
9
|
+
export const CODE_KEYS_REVOKE = 'https://api.witbitz.chat/v1/spaces/code-keys/revoke'
|
|
10
|
+
|
|
11
|
+
/** The key rows whose computer is on none of `computers` (the registry's entries, by id). */
|
|
12
|
+
export function orphanKeyRows (rows, computers) {
|
|
13
|
+
const known = new Set((computers || []).map((c) => c && c.id).filter(Boolean))
|
|
14
|
+
return (Array.isArray(rows) ? rows : []).filter((r) => r && typeof r.computerId === 'string' && !known.has(r.computerId))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const post = async (fetchImpl, url, body) => {
|
|
18
|
+
const r = await fetchImpl(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
|
|
19
|
+
const j = await r.json().catch(() => null)
|
|
20
|
+
if (!r.ok) throw new Error((j && j.error && (j.error.message || j.error.code)) || 'HTTP ' + r.status)
|
|
21
|
+
return (j && j.data) || {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Every computer of the account with live coding keys: [{ keyId, computerId, name, createdAt }]. */
|
|
25
|
+
export async function listKeyComputers (token, fetchImpl = (...a) => fetch(...a)) {
|
|
26
|
+
const d = await post(fetchImpl, CODE_KEYS_LIST, { idToken: token })
|
|
27
|
+
return Array.isArray(d.computers) ? d.computers : []
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Cancel one computer's coding keys (as removing a listed computer does, drawer.js revokeCodeKeys). → true when revoked. */
|
|
31
|
+
export async function revokeKeyComputer (token, computerId, fetchImpl = (...a) => fetch(...a)) {
|
|
32
|
+
const d = await post(fetchImpl, CODE_KEYS_REVOKE, { idToken: token, computerId })
|
|
33
|
+
return !!d.revoked
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** "added 12 Oct" — which of two same-named computers is the old one. */
|
|
37
|
+
export function addedOn (ms, now = Date.now()) {
|
|
38
|
+
const t = Number(ms); if (!(t > 0)) return ''
|
|
39
|
+
const d = new Date(t)
|
|
40
|
+
const o = { day: 'numeric', month: 'short', ...(new Date(now).getFullYear() !== d.getFullYear() ? { year: 'numeric' } : {}) }
|
|
41
|
+
try { return 'added ' + d.toLocaleDateString(undefined, o) } catch { return 'added ' + d.toISOString().slice(0, 10) }
|
|
42
|
+
}
|
package/codeOutputs.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// spaces/public/codeOutputs.js — the files a Code reply PRODUCED, previewed under it without asking.
|
|
2
|
+
//
|
|
3
|
+
// The owner, after an agent fixed a PDF and — asked to "upload it here" — answered that a PDF cannot be shown in the chat:
|
|
4
|
+
// "I think the user should automatically see a preview". Its answer had named the file's full path all along.
|
|
5
|
+
//
|
|
6
|
+
// A result is a file the reply WROTE or EDITED (its write/edit tools), or one its ANSWER names that CHANGED while the reply
|
|
7
|
+
// ran (the page checks the file's time on the computer: a folder listing that named an old gated_temp2.txt is not a result —
|
|
8
|
+
// "I think the rule for showing files is not good") — the text after its last step, not the narration between steps (the owner's "something went wrong": notes about a test in /tmp named min.html
|
|
9
|
+
// and min.pdf, which read as files in the session folder, while the answer's `דוח מסכם.pdf` was taken for a command
|
|
10
|
+
// because it has a space) — never one it only read, never a path in your own prompt. Only kinds a phone can show preview (a PDF's first page, a picture, the first lines of
|
|
11
|
+
// a table or a text); office files, archives and media get a chip with Download; code gets nothing (its diff is in the
|
|
12
|
+
// steps). Only inside the session's folder — the connector serves nothing else (tools/code-outputs.mjs) — and never a
|
|
13
|
+
// name that looks like a secret. Pure: no DOM, no fs — the page and the JS connector import it; the Python connector
|
|
14
|
+
// holds to the same cases (spaces/test/codeOutputs.vectors.json).
|
|
15
|
+
|
|
16
|
+
/** The connector-owned route a page asks for a produced file on (never forwarded to OpenCode). */
|
|
17
|
+
export const OUTPUT_ROUTE = '/witbitz/output'
|
|
18
|
+
export const MAX_OUTPUTS = 6
|
|
19
|
+
export const MAX_PATH = 4096
|
|
20
|
+
|
|
21
|
+
const KINDS = {
|
|
22
|
+
pdf: 'pdf',
|
|
23
|
+
png: 'image', jpg: 'image', jpeg: 'image', gif: 'image', webp: 'image',
|
|
24
|
+
csv: 'table', tsv: 'table',
|
|
25
|
+
md: 'text', markdown: 'text', txt: 'text',
|
|
26
|
+
docx: 'file', doc: 'file', xlsx: 'file', xls: 'file', pptx: 'file', ppt: 'file', odt: 'file', ods: 'file', odp: 'file',
|
|
27
|
+
rtf: 'file', zip: 'file', epub: 'file', heic: 'file', svg: 'file', html: 'file', htm: 'file',
|
|
28
|
+
mp3: 'file', wav: 'file', m4a: 'file', mp4: 'file', mov: 'file',
|
|
29
|
+
}
|
|
30
|
+
const MIME = {
|
|
31
|
+
pdf: 'application/pdf', png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp',
|
|
32
|
+
csv: 'text/csv', tsv: 'text/tab-separated-values', md: 'text/markdown', markdown: 'text/markdown', txt: 'text/plain',
|
|
33
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', doc: 'application/msword',
|
|
34
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', xls: 'application/vnd.ms-excel',
|
|
35
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', ppt: 'application/vnd.ms-powerpoint',
|
|
36
|
+
odt: 'application/vnd.oasis.opendocument.text', ods: 'application/vnd.oasis.opendocument.spreadsheet',
|
|
37
|
+
odp: 'application/vnd.oasis.opendocument.presentation', rtf: 'application/rtf', zip: 'application/zip',
|
|
38
|
+
epub: 'application/epub+zip', heic: 'image/heic', svg: 'image/svg+xml', html: 'text/html', htm: 'text/html',
|
|
39
|
+
mp3: 'audio/mpeg', wav: 'audio/wav', m4a: 'audio/mp4', mp4: 'video/mp4', mov: 'video/quicktime',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The extension of a file whose name does not start with a dot (`.pdf` alone is a dot-file, not a PDF). */
|
|
43
|
+
const extOf = (path) => { const m = /(?:^|\/)[^/.][^/]*\.([A-Za-z0-9]+)$/.exec(String(path || '')); return m ? m[1].toLowerCase() : '' }
|
|
44
|
+
|
|
45
|
+
/** 'pdf' | 'image' | 'table' | 'text' | 'file' — or null: not something to show. */
|
|
46
|
+
export const outputKind = (path) => KINDS[extOf(path)] || null
|
|
47
|
+
export const outputMime = (path) => MIME[extOf(path)] || 'application/octet-stream'
|
|
48
|
+
|
|
49
|
+
// The same rule Auto mode uses for a name that looks like a secret (tools/code-auto.mjs sensitivePath — the Python
|
|
50
|
+
// connector uses auto.py's): a .git/.ssh/.aws/… folder on the way, a .env, a private key, "secret"/"credential".
|
|
51
|
+
const SENSITIVE_BASE = /^(\.env(\..+)?|\.npmrc|\.netrc|\.pypirc|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?)$/
|
|
52
|
+
const SAFE_ENV = /^\.env\.(example|sample|template|dist)$/
|
|
53
|
+
/** `rel`: the path below the session folder, starting with "/". */
|
|
54
|
+
export function sensitivePath(rel) {
|
|
55
|
+
const parts = String(rel || '').split('/')
|
|
56
|
+
const base = parts[parts.length - 1] || ''
|
|
57
|
+
if (parts.some((p) => ['.git', '.ssh', '.aws', '.gnupg', '.kube', '.docker'].includes(p))) return true
|
|
58
|
+
if (SENSITIVE_BASE.test(base) && !SAFE_ENV.test(base)) return true
|
|
59
|
+
if (/\.(pem|key|p12|pfx|jks|keystore)$/i.test(base)) return true
|
|
60
|
+
return /secret|credential/i.test(base)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A path a page may ask for: absolute, at most 4096 characters, one line, no NUL. */
|
|
64
|
+
export const validOutputPath = (p) => typeof p === 'string' && p.startsWith('/') && p.length <= MAX_PATH && !/[\0\r\n]/.test(p)
|
|
65
|
+
|
|
66
|
+
/** posix normalize of an absolute path; null when it is not absolute. */
|
|
67
|
+
function normalize(p) {
|
|
68
|
+
if (!String(p).startsWith('/')) return null
|
|
69
|
+
const out = []
|
|
70
|
+
for (const seg of String(p).split('/')) {
|
|
71
|
+
if (!seg || seg === '.') continue
|
|
72
|
+
if (seg === '..') { out.pop(); continue }
|
|
73
|
+
out.push(seg)
|
|
74
|
+
}
|
|
75
|
+
return '/' + out.join('/')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const EXT_ALT = Object.keys(KINDS).join('|')
|
|
79
|
+
const BARE = new RegExp(`(?:^|[\\s(\\[<"'«])((?:\\.{1,2}\\/|\\/)?[^\\s\`'"()<>\\[\\]«»]+\\.(?:${EXT_ALT}))(?=$|[\\s)\\]>"'».,;:!?])`, 'giu')
|
|
80
|
+
|
|
81
|
+
// What a command in backticks has and a file name does not: a flag, a pipe or redirect, &&, ;, $, =, a glob.
|
|
82
|
+
const COMMANDISH = /(?:^|\s)--?[A-Za-z]|[|&;<>$=*]/
|
|
83
|
+
|
|
84
|
+
const escapeRe = (x) => x.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')
|
|
85
|
+
/** Candidate paths an answer names: whole `code spans`; then, outside them, paths under the session's folder written out
|
|
86
|
+
* in full — matched from the folder itself, because a folder name with a space ("תיקייה 1") would otherwise be cut at the
|
|
87
|
+
* space into a wrong relative path; then bare tokens in what is left. */
|
|
88
|
+
function namedIn(text, dir) {
|
|
89
|
+
const s = String(text || '')
|
|
90
|
+
const out = []
|
|
91
|
+
for (const m of s.matchAll(/`([^`\n]{1,4096})`/g)) out.push({ raw: m[1].trim(), spaced: true })
|
|
92
|
+
let rest = s.replace(/`[^`\n]*`/g, ' ')
|
|
93
|
+
const underDir = new RegExp(`${escapeRe(dir)}\\/[^\\n\`<>"]*?\\.(?:${EXT_ALT})(?=$|[\\s)\\]>"'».,;:!?])`, 'giu')
|
|
94
|
+
rest = rest.replace(underDir, (m) => { out.push({ raw: m, spaced: false }); return ' ' })
|
|
95
|
+
for (const m of rest.matchAll(BARE)) out.push({ raw: m[1], spaced: false })
|
|
96
|
+
return out
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The results of one reply: `messages` is the run of assistant messages after a prompt (user messages are skipped).
|
|
101
|
+
* → [{path, kind, source: 'wrote'|'shot'|'named'}] — files written first, then screenshots, each once, at most MAX_OUTPUTS.
|
|
102
|
+
*/
|
|
103
|
+
export function replyOutputs(messages, { directory = '', session = '' } = {}) {
|
|
104
|
+
const dir = normalize(directory)
|
|
105
|
+
if (!dir || dir === '/') return []
|
|
106
|
+
const seen = new Set()
|
|
107
|
+
const out = []
|
|
108
|
+
const take = (raw, source, { spaced = false, under = dir } = {}) => {
|
|
109
|
+
if (out.length >= MAX_OUTPUTS || typeof raw !== 'string' || !raw || raw.includes('://') || raw.startsWith('~')) return
|
|
110
|
+
if (!raw.startsWith('/') && spaced && /\s/.test(raw) && COMMANDISH.test(raw)) return // a command in backticks, not a relative path
|
|
111
|
+
const abs = normalize(raw.startsWith('/') ? raw : `${dir}/${raw}`)
|
|
112
|
+
if (!abs || !validOutputPath(abs) || !abs.startsWith(under + '/') || seen.has(abs)) return
|
|
113
|
+
const kind = outputKind(abs)
|
|
114
|
+
if (!kind || sensitivePath(abs.slice(dir.length))) return
|
|
115
|
+
seen.add(abs)
|
|
116
|
+
out.push({ path: abs, kind, source })
|
|
117
|
+
}
|
|
118
|
+
const assistant = (Array.isArray(messages) ? messages : []).filter((m) => m && m.info && m.info.role === 'assistant')
|
|
119
|
+
const parts = assistant.flatMap((m) => (Array.isArray(m.parts) ? m.parts : []))
|
|
120
|
+
for (const p of parts) {
|
|
121
|
+
if (p && p.type === 'tool' && (p.tool === 'write' || p.tool === 'edit') && p.state && p.state.status === 'completed') {
|
|
122
|
+
take(p.state.input && p.state.input.filePath, 'wrote')
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// THE AGENT'S SCREENSHOTS (the owner, 2026-10-25: "how can I get a screen snapshot in the chat"): browser_screenshot saves
|
|
126
|
+
// into <home>/.witbitz/screens/<this session>/ (tools/browse-cdp.mjs) — outside the project, served for this session only
|
|
127
|
+
// (tools/code-outputs.mjs `shots`). Taken from the tool's own result, so a path the answer merely names never reaches there.
|
|
128
|
+
if (/^[A-Za-z0-9_-]{1,128}$/.test(String(session))) {
|
|
129
|
+
const shot = new RegExp(`(\\/[^\\s'"]*\\/\\.witbitz\\/screens\\/${session})\\/screen-[A-Za-z0-9-]+\\.jpg`)
|
|
130
|
+
for (const p of parts) {
|
|
131
|
+
if (!p || p.type !== 'tool' || p.tool !== 'browser_screenshot' || !p.state || p.state.status !== 'completed') continue
|
|
132
|
+
const m = shot.exec(String(p.state.output || ''))
|
|
133
|
+
if (m) take(m[0], 'shot', { under: m[1] })
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const lastStep = parts.map((p) => !!p && p.type === 'tool').lastIndexOf(true)
|
|
137
|
+
for (const p of parts.slice(lastStep + 1)) {
|
|
138
|
+
if (p && p.type === 'text' && !p.synthetic) for (const c of namedIn(p.text, dir)) take(c.raw, 'named', c)
|
|
139
|
+
}
|
|
140
|
+
return out
|
|
141
|
+
}
|