@qvac/core 0.3.5 → 0.4.1
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/CHANGELOG.md +177 -9
- package/README.md +19 -17
- package/dist-lib/lib/api/agents.d.ts +3 -3
- package/dist-lib/lib/api/agents.js +31 -20
- package/dist-lib/lib/api/approval-rules.d.ts +2 -2
- package/dist-lib/lib/api/approval-rules.js +2 -2
- package/dist-lib/lib/api/attachments.d.ts +2 -2
- package/dist-lib/lib/api/attachments.js +14 -25
- package/dist-lib/lib/api/chat-groups.d.ts +2 -2
- package/dist-lib/lib/api/chat-groups.js +9 -9
- package/dist-lib/lib/api/chat.d.ts +4 -2
- package/dist-lib/lib/api/chat.js +18 -18
- package/dist-lib/lib/api/chunks.d.ts +2 -2
- package/dist-lib/lib/api/chunks.js +27 -36
- package/dist-lib/lib/api/current-mesh.d.ts +7 -15
- package/dist-lib/lib/api/current-mesh.js +7 -22
- package/dist-lib/lib/api/devices.d.ts +4 -3
- package/dist-lib/lib/api/devices.js +18 -18
- package/dist-lib/lib/api/execution.d.ts +2 -2
- package/dist-lib/lib/api/execution.js +6 -6
- package/dist-lib/lib/api/files.d.ts +2 -2
- package/dist-lib/lib/api/files.js +4 -4
- package/dist-lib/lib/api/index.d.ts +12 -11
- package/dist-lib/lib/api/index.js +15 -13
- package/dist-lib/lib/api/inference-calls.d.ts +1 -1
- package/dist-lib/lib/api/inference-calls.js +2 -2
- package/dist-lib/lib/api/knowledge.d.ts +2 -2
- package/dist-lib/lib/api/knowledge.js +22 -11
- package/dist-lib/lib/api/local-files.d.ts +3 -0
- package/dist-lib/lib/api/local-files.js +23 -0
- package/dist-lib/lib/api/members.d.ts +6 -2
- package/dist-lib/lib/api/members.js +24 -17
- package/dist-lib/lib/api/mesh.d.ts +4 -5
- package/dist-lib/lib/api/mesh.js +7 -9
- package/dist-lib/lib/api/notifications.d.ts +2 -13
- package/dist-lib/lib/api/notifications.js +20 -52
- package/dist-lib/lib/api/rag.d.ts +2 -2
- package/dist-lib/lib/api/rag.js +4 -4
- package/dist-lib/lib/api/range.d.ts +11 -0
- package/dist-lib/lib/api/range.js +10 -0
- package/dist-lib/lib/api/sync.d.ts +2 -2
- package/dist-lib/lib/api/sync.js +3 -3
- package/dist-lib/lib/api/tool-activity.d.ts +2 -2
- package/dist-lib/lib/api/tool-activity.js +11 -10
- package/dist-lib/lib/api/tool-configs.d.ts +2 -2
- package/dist-lib/lib/api/tool-configs.js +6 -7
- package/dist-lib/lib/api/upload-frames.d.ts +9 -0
- package/dist-lib/lib/api/upload-frames.js +17 -0
- package/dist-lib/lib/api/watchable.d.ts +1 -6
- package/dist-lib/lib/api/watchable.js +4 -13
- package/dist-lib/lib/assistant/history.d.ts +3 -3
- package/dist-lib/lib/assistant-client.js +3 -2
- package/dist-lib/lib/assistant-tree.js +1 -1
- package/dist-lib/lib/assistant.d.ts +16 -14
- package/dist-lib/lib/assistant.js +166 -137
- package/dist-lib/lib/collabora/convert.js +1 -1
- package/dist-lib/lib/core/agent.d.ts +5 -7
- package/dist-lib/lib/core/agent.js +26 -6
- package/dist-lib/lib/core/archived-mesh.js +1 -0
- package/dist-lib/lib/core/chat-order.d.ts +20 -0
- package/dist-lib/lib/core/chat-order.js +96 -0
- package/dist-lib/lib/core/chat.d.ts +0 -5
- package/dist-lib/lib/core/chat.js +1 -3
- package/dist-lib/lib/core/chunk.d.ts +7 -14
- package/dist-lib/lib/core/chunk.js +17 -35
- package/dist-lib/lib/core/contract/agents.js +8 -0
- package/dist-lib/lib/core/contract/compute.d.ts +1 -1
- package/dist-lib/lib/core/contract/compute.js +1 -0
- package/dist-lib/lib/core/contract/joined-meshes.js +4 -3
- package/dist-lib/lib/core/contract/members.js +4 -3
- package/dist-lib/lib/core/contract/writers.js +5 -4
- package/dist-lib/lib/core/departures.js +5 -4
- package/dist-lib/lib/core/device-invites.js +2 -1
- package/dist-lib/lib/core/files/attachments.d.ts +8 -1
- package/dist-lib/lib/core/files/index.d.ts +4 -4
- package/dist-lib/lib/core/files/index.js +18 -8
- package/dist-lib/lib/core/files/local-index.d.ts +16 -0
- package/dist-lib/lib/core/files/local-index.js +38 -0
- package/dist-lib/lib/core/files/processing/document.js +2 -1
- package/dist-lib/lib/core/files/processing/ownership.js +6 -3
- package/dist-lib/lib/core/files/records/chunks.js +1 -0
- package/dist-lib/lib/core/files/records/reclaim.js +1 -0
- package/dist-lib/lib/core/files/records/routing.js +2 -1
- package/dist-lib/lib/core/files/store/blob.d.ts +1 -1
- package/dist-lib/lib/core/files/store/blob.js +6 -3
- package/dist-lib/lib/core/files/store/index.d.ts +1 -1
- package/dist-lib/lib/core/files/store/reference.js +4 -3
- package/dist-lib/lib/core/files/store/server.d.ts +8 -4
- package/dist-lib/lib/core/files/store/server.js +16 -12
- package/dist-lib/lib/core/files/store/sweep.js +2 -1
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/hosted-agents.js +1 -1
- package/dist-lib/lib/core/image/cache-sweep.d.ts +1 -0
- package/dist-lib/lib/core/image/cache-sweep.js +7 -3
- package/dist-lib/lib/core/local/files.d.ts +24 -0
- package/dist-lib/lib/core/local/files.js +154 -0
- package/dist-lib/lib/core/local/index.d.ts +21 -5
- package/dist-lib/lib/core/local/index.js +75 -45
- package/dist-lib/lib/core/membership.d.ts +4 -1
- package/dist-lib/lib/core/membership.js +17 -2
- package/dist-lib/lib/core/mesh.d.ts +5 -0
- package/dist-lib/lib/core/mesh.js +10 -5
- package/dist-lib/lib/core/migrations/agent-indexes.d.ts +2 -0
- package/dist-lib/lib/core/migrations/agent-indexes.js +30 -0
- package/dist-lib/lib/core/migrations/file-index.d.ts +2 -0
- package/dist-lib/lib/core/migrations/file-index.js +27 -0
- package/dist-lib/lib/core/migrations/index.js +3 -1
- package/dist-lib/lib/core/notification.js +5 -5
- package/dist-lib/lib/core/range.d.ts +18 -0
- package/dist-lib/lib/core/range.js +17 -0
- package/dist-lib/lib/core/sync/index.js +39 -32
- package/dist-lib/lib/core/sync-status.js +3 -2
- package/dist-lib/lib/core/tool-activity.d.ts +2 -5
- package/dist-lib/lib/core/tool-activity.js +4 -7
- package/dist-lib/lib/core.d.ts +48 -29
- package/dist-lib/lib/core.js +465 -359
- package/dist-lib/lib/knowledge-search.d.ts +2 -2
- package/dist-lib/lib/kv-cache.js +1 -1
- package/dist-lib/lib/log.js +2 -3
- package/dist-lib/lib/mesh-scoped-engine.d.ts +8 -1
- package/dist-lib/lib/mesh-scoped-engine.js +62 -15
- package/dist-lib/lib/model-download.d.ts +14 -5
- package/dist-lib/lib/model-download.js +25 -17
- package/dist-lib/lib/oauth/browser-connect.d.ts +0 -14
- package/dist-lib/lib/oauth/browser-connect.js +1 -26
- package/dist-lib/lib/oauth/token-exchange.d.ts +1 -2
- package/dist-lib/lib/oauth/token-exchange.js +1 -4
- package/dist-lib/lib/run-transcript.d.ts +2 -2
- package/dist-lib/lib/run-transcript.js +3 -2
- package/dist-lib/lib/task.d.ts +1 -0
- package/dist-lib/lib/task.js +3 -2
- package/dist-lib/schema/build.js +4 -10
- package/dist-lib/schema/engine.js +261 -91
- package/dist-lib/schema/field-order.js +1 -4
- package/dist-lib/schema/helpers.d.ts +4 -0
- package/dist-lib/schema/helpers.js +20 -0
- package/dist-lib/schema/local.d.ts +1 -1
- package/dist-lib/schema/local.js +70 -2
- package/dist-lib/schema/qvac.js +30 -0
- package/dist-lib/spec/bind.js +20 -3
- package/dist-lib/spec/calls.js +19 -15
- package/dist-lib/spec/capabilities.d.ts +42 -34
- package/dist-lib/spec/hrpc/hrpc.json +82 -30
- package/dist-lib/spec/hrpc/index.js +106 -57
- package/dist-lib/spec/hrpc/messages.js +5420 -5019
- package/dist-lib/spec/hyperschema/index.js +5424 -5023
- package/dist-lib/spec/hyperschema/schema.json +3202 -2666
- package/dist-lib/spec/hyperschema/types.d.ts +455 -319
- package/dist-lib/spec/local/hyperdb/db.json +119 -1
- package/dist-lib/spec/local/hyperdb/index.js +414 -2
- package/dist-lib/spec/local/hyperdb/messages.js +505 -124
- package/dist-lib/spec/local/hyperschema/index.js +203 -5
- package/dist-lib/spec/local/hyperschema/schema.json +136 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +32 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +55 -3
- package/dist-lib/spec/mesh/hyperdb/index.js +119 -3
- package/dist-lib/spec/mesh/hyperdb/messages.js +244 -172
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +74 -2
- package/dist-lib/spec/mesh/hyperschema/index.js +74 -2
- package/dist-lib/spec/mesh/hyperschema/schema.json +27 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +9 -1
- package/package.json +15 -9
- package/tui/app.mjs +376 -151
- package/tui/boot.mjs +2 -1
- package/tui/lib/busy-words.mjs +2 -1
- package/tui/lib/knowledge-command.mjs +11 -10
- package/tui/lib/knowledge-import.mjs +7 -5
- package/tui/lib/render.mjs +4 -3
- package/tui/lib/usage.mjs +2 -1
- package/tui/main.mjs +2 -1
- package/tui/lib/projection-env.mjs +0 -24
package/tui/boot.mjs
CHANGED
|
@@ -39,7 +39,8 @@ async function startSidecar({ entry, config, logger }) {
|
|
|
39
39
|
return {
|
|
40
40
|
engine,
|
|
41
41
|
close: () => engine.close(),
|
|
42
|
-
skills: async (agentId, modelName
|
|
42
|
+
skills: async (agentId, modelName, meshId) =>
|
|
43
|
+
(await engine.skills({ agentId, modelName, meshId })).skills ?? []
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
package/tui/lib/busy-words.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import b4a from 'b4a'
|
|
1
2
|
// What the busy line says while a run is in flight, in place of `thinking…`.
|
|
2
3
|
// Every word has to read as a mind at work first and a duck second — so the
|
|
3
4
|
// real words here already mean thinking or grinding (Pondering, Brooding,
|
|
@@ -75,7 +76,7 @@ export const SLIP_DELETE_MS = 45 // per character backspaced
|
|
|
75
76
|
export const SLIP_TYPE_MS = 65 // per character of the correction typed
|
|
76
77
|
|
|
77
78
|
function hashOf(runId) {
|
|
78
|
-
const key = typeof runId === 'string' ? runId :
|
|
79
|
+
const key = typeof runId === 'string' ? runId : b4a.toHex(runId)
|
|
79
80
|
let hash = 0
|
|
80
81
|
for (let i = 0; i < key.length; i++) hash = (hash * 31 + key.charCodeAt(i)) >>> 0
|
|
81
82
|
return hash
|
|
@@ -5,48 +5,49 @@ import { saveUniqueStream } from './save-file.mjs'
|
|
|
5
5
|
const USAGE =
|
|
6
6
|
'usage: /knowledge [list] · /knowledge add <file> · /knowledge add-dir <directory> · /knowledge download <n|id> · /knowledge remove <n|id>'
|
|
7
7
|
|
|
8
|
-
export async function knowledgeCommand(engine, { chatId, saveDir }, input) {
|
|
8
|
+
export async function knowledgeCommand(engine, { chatId, meshId, saveDir }, input) {
|
|
9
9
|
try {
|
|
10
|
-
return { type: 'notice', text: await execute(engine, chatId, saveDir, input) }
|
|
10
|
+
return { type: 'notice', text: await execute(engine, { chatId, meshId }, saveDir, input) }
|
|
11
11
|
} catch (error) {
|
|
12
12
|
return { type: 'run.error', error }
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async function execute(engine,
|
|
16
|
+
async function execute(engine, scope, saveDir, input) {
|
|
17
|
+
const { chatId, meshId } = scope
|
|
17
18
|
const { action, argument } = parseInput(input)
|
|
18
19
|
if ((!action || action === 'list') && !argument) {
|
|
19
20
|
const [{ knowledge }, { statuses }] = await Promise.all([
|
|
20
|
-
engine.listKnowledge({ chatId }),
|
|
21
|
-
engine.listIndexing({ chatId })
|
|
21
|
+
engine.listKnowledge({ chatId, meshId }),
|
|
22
|
+
engine.listIndexing({ chatId, meshId })
|
|
22
23
|
])
|
|
23
24
|
return formatKnowledge(sortKnowledge(knowledge ?? []), statuses ?? [])
|
|
24
25
|
}
|
|
25
26
|
if (action === 'add' || action === 'add-dir') {
|
|
26
27
|
if (!argument) return USAGE
|
|
27
28
|
if (action === 'add') {
|
|
28
|
-
const added = await importKnowledgeFile(engine,
|
|
29
|
+
const added = await importKnowledgeFile(engine, scope, argument)
|
|
29
30
|
return `uploaded ${singleLine(added.fileName)} (${added.byteLength}B) · run /knowledge to track indexing`
|
|
30
31
|
}
|
|
31
|
-
return formatDirectoryImport(await importKnowledgeDirectory(engine,
|
|
32
|
+
return formatDirectoryImport(await importKnowledgeDirectory(engine, scope, argument))
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const [selector, ...extra] = argument.split(/\s+/)
|
|
35
36
|
if ((action !== 'download' && action !== 'remove') || !selector || extra.length) return USAGE
|
|
36
37
|
|
|
37
|
-
const { knowledge } = await engine.listKnowledge({ chatId })
|
|
38
|
+
const { knowledge } = await engine.listKnowledge({ chatId, meshId })
|
|
38
39
|
const selected = resolveKnowledge(sortKnowledge(knowledge ?? []), selector)
|
|
39
40
|
if (selected.error) return selected.error
|
|
40
41
|
const row = selected.knowledge
|
|
41
42
|
if (action === 'remove') {
|
|
42
|
-
await engine.removeKnowledge({ knowledgeId: row.id, at: Date.now() })
|
|
43
|
+
await engine.removeKnowledge({ knowledgeId: row.id, at: Date.now(), meshId })
|
|
43
44
|
return `removed ${singleLine(row.fileName)} (${row.id.slice(0, 8)})`
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const saved = await saveUniqueStream(
|
|
47
48
|
saveDir,
|
|
48
49
|
row.fileName,
|
|
49
|
-
frameData(engine.downloadKnowledge({ blobId: row.blobId }))
|
|
50
|
+
frameData(engine.downloadKnowledge({ blobId: row.blobId, meshId }))
|
|
50
51
|
)
|
|
51
52
|
if (saved) return `saved ${singleLine(row.fileName)} (${saved.bytesWritten}B) to ${saved.file}`
|
|
52
53
|
return `not saved: 100 files named ${singleLine(row.fileName)} already exist in ${saveDir}`
|
|
@@ -28,15 +28,15 @@ const MIME_TYPES = new Map([
|
|
|
28
28
|
['.odt', 'application/vnd.oasis.opendocument.text']
|
|
29
29
|
])
|
|
30
30
|
|
|
31
|
-
export async function importKnowledgeFile(engine,
|
|
31
|
+
export async function importKnowledgeFile(engine, scope, inputPath) {
|
|
32
32
|
const file = resolvePath(inputPath)
|
|
33
33
|
const stat = await fs.promises.stat(file)
|
|
34
34
|
if (!stat.isFile()) throw new Error(`not a file: ${file}`)
|
|
35
35
|
if (!supported(file)) throw new Error(`unsupported knowledge file: ${path.basename(file)}`)
|
|
36
|
-
return upload(engine,
|
|
36
|
+
return upload(engine, scope, file, stat.size)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export async function importKnowledgeDirectory(engine,
|
|
39
|
+
export async function importKnowledgeDirectory(engine, scope, inputPath) {
|
|
40
40
|
const directory = resolvePath(inputPath)
|
|
41
41
|
const stat = await fs.promises.stat(directory)
|
|
42
42
|
if (!stat.isDirectory()) throw new Error(`not a directory: ${directory}`)
|
|
@@ -59,7 +59,7 @@ export async function importKnowledgeDirectory(engine, chatId, inputPath) {
|
|
|
59
59
|
continue
|
|
60
60
|
}
|
|
61
61
|
try {
|
|
62
|
-
added.push(await upload(engine,
|
|
62
|
+
added.push(await upload(engine, scope, file, fileStat.size))
|
|
63
63
|
} catch (error) {
|
|
64
64
|
failed.push({ fileName: name, error: errorMessage(error) })
|
|
65
65
|
}
|
|
@@ -79,7 +79,7 @@ function supported(file) {
|
|
|
79
79
|
return ACCEPTED.has(path.extname(file).toLowerCase())
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
async function upload(engine, chatId, file, byteLength) {
|
|
82
|
+
async function upload(engine, { chatId, meshId }, file, byteLength) {
|
|
83
83
|
const fileName = path.basename(file)
|
|
84
84
|
const extension = path.extname(file).toLowerCase()
|
|
85
85
|
const stream = engine.uploadKnowledge()
|
|
@@ -92,7 +92,9 @@ async function upload(engine, chatId, file, byteLength) {
|
|
|
92
92
|
const source = fs.createReadStream(file, { highWaterMark: UPLOAD_FRAME_BYTES })
|
|
93
93
|
|
|
94
94
|
try {
|
|
95
|
+
// the first frame names the mesh; the rest carry bytes
|
|
95
96
|
const metadataWritten = await writeFrame(stream, {
|
|
97
|
+
meshId,
|
|
96
98
|
chatId,
|
|
97
99
|
fileName,
|
|
98
100
|
mimeType: MIME_TYPES.get(extension) ?? 'application/octet-stream',
|
package/tui/lib/render.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { busyWord } from './busy-words.mjs'
|
|
2
|
+
import b4a from 'b4a'
|
|
2
3
|
|
|
3
4
|
const PAYLOAD_FIELDS = {
|
|
4
5
|
content: 'content',
|
|
@@ -33,7 +34,7 @@ export function turnsFromChunks(chunks) {
|
|
|
33
34
|
if (chunk.type === 'user-message') {
|
|
34
35
|
turns.push({
|
|
35
36
|
from: 'user',
|
|
36
|
-
deviceId: chunk.originDeviceId
|
|
37
|
+
deviceId: chunk.originDeviceId && b4a.toHex(chunk.originDeviceId),
|
|
37
38
|
segments: [{ type: 'user-message', text: chunk.userMessage.text }]
|
|
38
39
|
})
|
|
39
40
|
continue
|
|
@@ -44,7 +45,7 @@ export function turnsFromChunks(chunks) {
|
|
|
44
45
|
if (chunk.type === 'attachment' && !chunk.runId) {
|
|
45
46
|
turns.push({
|
|
46
47
|
from: 'user',
|
|
47
|
-
deviceId: chunk.originDeviceId
|
|
48
|
+
deviceId: chunk.originDeviceId && b4a.toHex(chunk.originDeviceId),
|
|
48
49
|
segments: [{ type: 'attachment', detail: chunk.attachment }]
|
|
49
50
|
})
|
|
50
51
|
continue
|
|
@@ -71,7 +72,7 @@ export function turnsFromChunks(chunks) {
|
|
|
71
72
|
turn.statusDetail = chunk.runStatus
|
|
72
73
|
// Status chunks are stamped by the device doing the work (the
|
|
73
74
|
// provider), so progress can be labelled with WHERE it's happening.
|
|
74
|
-
turn.statusDeviceId = chunk.originDeviceId
|
|
75
|
+
turn.statusDeviceId = chunk.originDeviceId && b4a.toHex(chunk.originDeviceId)
|
|
75
76
|
continue
|
|
76
77
|
}
|
|
77
78
|
// An approval-request chunk IS the approval state (see runAgent's
|
package/tui/lib/usage.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import b4a from 'b4a'
|
|
1
2
|
// What the run itself reported, and nothing counted here: `ctxSize` is the window the device
|
|
2
3
|
// that ran the turn had loaded, `cacheTokens` the SDK's occupancy reading, `usage` the
|
|
3
4
|
// harness's attribution of the prompt it sent (docs/decisions in @qvac/harness).
|
|
@@ -29,7 +30,7 @@ export function usageReport(statuses, folds = []) {
|
|
|
29
30
|
occupied: metrics.cacheTokens ?? null,
|
|
30
31
|
rows: promptRows(metrics.usage, metrics.cacheTokens),
|
|
31
32
|
last: {
|
|
32
|
-
deviceId: last.originDeviceId
|
|
33
|
+
deviceId: last.originDeviceId ? b4a.toHex(last.originDeviceId) : null,
|
|
33
34
|
totalTokens: metrics.totalTokens ?? null,
|
|
34
35
|
tokensPerSecond: metrics.tokensPerSecond ?? null,
|
|
35
36
|
timeToFirstToken: metrics.timeToFirstToken ?? null,
|
package/tui/main.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { spawn } from 'child_process'
|
|
|
9
9
|
import path from 'path'
|
|
10
10
|
import { readBootTiming } from './lib/boot-timing.mjs'
|
|
11
11
|
import { ChatApp } from './app.mjs'
|
|
12
|
+
import b4a from 'b4a'
|
|
12
13
|
|
|
13
14
|
const { Program } = tui
|
|
14
15
|
|
|
@@ -245,7 +246,7 @@ async function run(args) {
|
|
|
245
246
|
const { deviceId, meshInvite } = await connect()
|
|
246
247
|
console.log(`storage ${booted.storagePath}`)
|
|
247
248
|
console.log(`log ${booted.logFile}`)
|
|
248
|
-
console.log(`device ${booted.deviceName} ${
|
|
249
|
+
console.log(`device ${booted.deviceName} ${b4a.toHex(deviceId)}`)
|
|
249
250
|
console.log(`invite ${meshInvite ?? '(none — mesh not writable)'}`)
|
|
250
251
|
printBootTiming(booted)
|
|
251
252
|
return
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// QVAC_MMPROJ: one mmproj for every model, or per-model pairs
|
|
2
|
-
// "model=mmproj,model2=mmproj2" (keys match the agent's model name/path)
|
|
3
|
-
export function parseProjectionEnv(value) {
|
|
4
|
-
if (!value) return undefined
|
|
5
|
-
const eq = value.indexOf('=')
|
|
6
|
-
if (eq < 0) return value
|
|
7
|
-
const scheme = value.indexOf('://')
|
|
8
|
-
// '=' appearing only inside a URL (…?token=x) is one global source, not pairs
|
|
9
|
-
if (scheme >= 0 && scheme < eq) return value
|
|
10
|
-
const map = {}
|
|
11
|
-
let key = null
|
|
12
|
-
for (const segment of value.split(',')) {
|
|
13
|
-
const i = segment.indexOf('=')
|
|
14
|
-
if (i > 0) {
|
|
15
|
-
key = segment.slice(0, i).trim()
|
|
16
|
-
map[key] = segment.slice(i + 1).trim()
|
|
17
|
-
} else if (key) {
|
|
18
|
-
// no '=' means the comma belonged to the previous value (a url like
|
|
19
|
-
// …?token=a,b); a comma followed by k=v stays ambiguous and unsupported
|
|
20
|
-
map[key] += ',' + segment.trim()
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return map
|
|
24
|
-
}
|