@qvac/core 0.3.0 → 0.3.2
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-lib/lib/api/chat.d.ts +3 -1
- package/dist-lib/lib/api/chat.js +6 -2
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +3 -1
- package/dist-lib/lib/api/inference-calls.d.ts +18 -0
- package/dist-lib/lib/api/inference-calls.js +15 -0
- package/dist-lib/lib/api/rag.js +10 -2
- package/dist-lib/lib/assistant/harness.d.ts +1 -0
- package/dist-lib/lib/assistant/history.d.ts +10 -1
- package/dist-lib/lib/assistant/history.js +36 -1
- package/dist-lib/lib/assistant/message.d.ts +2 -0
- package/dist-lib/lib/assistant/message.js +11 -0
- package/dist-lib/lib/assistant/skill-encode.js +27 -1
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +11 -2
- package/dist-lib/lib/assistant.d.ts +19 -3
- package/dist-lib/lib/assistant.js +148 -23
- package/dist-lib/lib/core/chunk.js +5 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/build.js +1 -2
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +4 -24
- package/dist-lib/lib/core/files/rag/index.js +3 -17
- package/dist-lib/lib/core/files/rag/load.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/load.js +1 -2
- package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -4
- package/dist-lib/lib/core/files/rag/similarity.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/similarity.js +6 -0
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +20 -0
- package/dist-lib/lib/core/inference-calls-handoff.js +37 -0
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +14 -0
- package/dist-lib/lib/core/inference-calls-receiver.js +39 -0
- package/dist-lib/lib/core/notification.js +5 -4
- package/dist-lib/lib/core/skill-secrets.js +3 -6
- package/dist-lib/lib/core.d.ts +9 -1
- package/dist-lib/lib/core.js +129 -13
- package/dist-lib/lib/credential-pusher.d.ts +2 -3
- package/dist-lib/lib/credential-pusher.js +67 -39
- package/dist-lib/lib/inference-calls.d.ts +40 -0
- package/dist-lib/lib/inference-calls.js +266 -0
- package/dist-lib/lib/integrations/index.d.ts +1 -2
- package/dist-lib/lib/integrations/index.js +0 -1
- package/dist-lib/lib/integrations/setup-routes.js +0 -15
- package/dist-lib/lib/oauth/flow-core.js +1 -1
- package/dist-lib/lib/oauth/flow.d.ts +4 -2
- package/dist-lib/lib/oauth/flow.js +3 -4
- package/dist-lib/lib/oauth/host.d.ts +3 -1
- package/dist-lib/lib/oauth/host.js +3 -1
- package/dist-lib/lib/oauth/keys.d.ts +21 -20
- package/dist-lib/lib/oauth/keys.js +59 -85
- package/dist-lib/lib/oauth/loopback.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.js +32 -19
- package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
- package/dist-lib/lib/oauth/loopback.stub.js +2 -2
- package/dist-lib/lib/oauth/providers.d.ts +3 -5
- package/dist-lib/lib/oauth/providers.js +20 -67
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/oauth/registry.d.ts +10 -0
- package/dist-lib/lib/oauth/registry.js +25 -0
- package/dist-lib/lib/oauth/resolve.js +1 -1
- package/dist-lib/lib/oauth/token-exchange-core.js +2 -1
- package/dist-lib/lib/oauth/types.d.ts +1 -1
- package/dist-lib/lib/oauth.client.d.ts +3 -1
- package/dist-lib/lib/oauth.client.js +3 -1
- package/dist-lib/lib/oauth.d.ts +4 -7
- package/dist-lib/lib/oauth.js +4 -7
- package/dist-lib/lib/skill-types.d.ts +12 -0
- package/dist-lib/schema/content.js +5 -1
- package/dist-lib/schema/engine.js +63 -2
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +284 -52
- package/dist-lib/spec/hyperschema/index.js +284 -52
- package/dist-lib/spec/hyperschema/schema.json +210 -1
- package/dist-lib/spec/hyperschema/types.d.ts +51 -1
- package/dist-lib/spec/local/hyperdb/messages.js +64 -128
- package/dist-lib/spec/local/hyperschema/index.js +32 -64
- package/dist-lib/spec/local/hyperschema/schema.json +16 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +176 -311
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/index.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/schema.json +70 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +15 -18
- package/tui/app.mjs +98 -155
- package/tui/lib/knowledge-import.mjs +1 -1
- package/tui/lib/save-file.mjs +1 -1
- package/.claude/skills/asana/SKILL.md +0 -86
- package/.claude/skills/compaction/SKILL.md +0 -136
- package/.claude/skills/device-mesh-debug/SKILL.md +0 -328
- package/.claude/skills/gh-stack/SKILL.md +0 -181
- package/.claude/skills/gh-stack/references/commands.md +0 -177
- package/.claude/skills/gh-stack/references/stack-design.md +0 -97
- package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
- package/.claude/skills/js-house-style/SKILL.md +0 -671
- package/.claude/skills/pr-create/SKILL.md +0 -243
- package/.claude/skills/pr-review/SKILL.md +0 -428
- package/.claude/skills/release/SKILL.md +0 -122
- package/CLAUDE.md +0 -48
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/artifact/codec.js +0 -172
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/artifact/id.js +0 -39
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +0 -24
- package/dist-lib/lib/core/files/rag/artifact/types.js +0 -41
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +0 -117
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +0 -30
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +0 -89
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +0 -7
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +0 -18
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +0 -117
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +0 -22
- package/dist-lib/lib/core/files/rag/extract/document-types.js +0 -152
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/extract.js +0 -81
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +0 -125
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-text.js +0 -132
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +0 -141
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +0 -43
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +0 -15
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +0 -91
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +0 -36
- package/dist-lib/lib/core/files/rag/extract/types.js +0 -12
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/extract/utf.js +0 -18
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +0 -4
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +0 -48
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +0 -37
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +0 -5
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/format.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +0 -54
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +0 -27
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +0 -82
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/retrieval/search.js +0 -49
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +0 -11
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +0 -93
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +0 -79
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +0 -20
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/target.js +0 -89
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +0 -70
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +0 -29
- package/dist-lib/lib/core/files/rag/retrieval/types.js +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +0 -41
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +0 -96
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +0 -15
- package/dist-lib/lib/core/files/rag/vector/memory.js +0 -135
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +0 -28
- package/dist-lib/lib/core/files/rag/vector/types.js +0 -1
- package/dist-lib/lib/integrations/oauth-providers.d.ts +0 -14
- package/dist-lib/lib/integrations/oauth-providers.js +0 -116
- package/dist-lib/lib/oauth/asana.d.ts +0 -35
- package/dist-lib/lib/oauth/asana.js +0 -71
- package/dist-lib/lib/oauth/google.d.ts +0 -37
- package/dist-lib/lib/oauth/google.js +0 -77
- package/dist-lib/lib/oauth/notion.d.ts +0 -34
- package/dist-lib/lib/oauth/notion.js +0 -82
- package/dist-lib/lib/oauth/spotify.d.ts +0 -32
- package/dist-lib/lib/oauth/spotify.js +0 -74
- package/dist-lib/lib/oauth/verify.d.ts +0 -8
- package/dist-lib/lib/oauth/verify.js +0 -58
package/tui/app.mjs
CHANGED
|
@@ -9,13 +9,9 @@ import { TOOLSETS } from '@qvac/harness/lib/tools/toolsets.ts'
|
|
|
9
9
|
import os from 'os'
|
|
10
10
|
import path from 'path'
|
|
11
11
|
import process from 'process'
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
oauthKeySpec,
|
|
16
|
-
scopedKey,
|
|
17
|
-
SPOTIFY_CREDENTIAL_KEY
|
|
18
|
-
} from '../dist-lib/lib/oauth/keys.js'
|
|
12
|
+
import { scopedKey } from '../dist-lib/lib/oauth/keys.js'
|
|
13
|
+
import { oauthSpecs } from '../dist-lib/lib/oauth/registry.js'
|
|
14
|
+
import { settingConfigKey } from '../dist-lib/lib/credential-pusher.js'
|
|
19
15
|
import {
|
|
20
16
|
COMPACTION_MIN_CTX_SIZE,
|
|
21
17
|
contextOptionsForModel,
|
|
@@ -42,6 +38,7 @@ import { compactionTriggerRatio } from '../dist-lib/lib/compaction.js'
|
|
|
42
38
|
import { rememberSelection } from './lib/selection.mjs'
|
|
43
39
|
import {
|
|
44
40
|
configureActions,
|
|
41
|
+
connectSlug,
|
|
45
42
|
isReady,
|
|
46
43
|
setupAction,
|
|
47
44
|
setupActions,
|
|
@@ -245,20 +242,7 @@ const COMMANDS = [
|
|
|
245
242
|
},
|
|
246
243
|
{ name: 'meshes', desc: 'list the meshes this device belongs to', palette: true },
|
|
247
244
|
{ name: 'cred', desc: 'set a credential value for this agent' },
|
|
248
|
-
{
|
|
249
|
-
name: 'connect',
|
|
250
|
-
desc: 'OAuth-connect a skill for this agent',
|
|
251
|
-
sub: [
|
|
252
|
-
{ name: 'gmail', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
253
|
-
{ name: 'google-calendar', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
254
|
-
{ name: 'google-docs', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
255
|
-
{ name: 'google-drive', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
256
|
-
{ name: 'google-sheets', desc: 'Google OAuth (needs GOOGLE_OAUTH_CLIENT_ID + _SECRET)' },
|
|
257
|
-
{ name: 'spotify', desc: 'Spotify OAuth, PKCE only (needs SPOTIFY_OAUTH_CLIENT_ID)' },
|
|
258
|
-
{ name: 'notion', desc: 'Notion MCP OAuth, PKCE + dynamic registration (no env)' },
|
|
259
|
-
{ name: 'asana', desc: 'Asana MCP OAuth, PKCE (needs ASANA_OAUTH_CLIENT_ID + _SECRET)' }
|
|
260
|
-
]
|
|
261
|
-
},
|
|
245
|
+
{ name: 'connect', desc: 'OAuth-connect a skill for this agent', palette: true },
|
|
262
246
|
{
|
|
263
247
|
name: 'my-device',
|
|
264
248
|
desc: 'CPU/GPU inventory for this device (manufacturer, cores, drivers, …)'
|
|
@@ -1738,10 +1722,8 @@ export class ChatApp {
|
|
|
1738
1722
|
' /image [model <choice> | steps <n> | size <WxH> | reset] — the agent’s image-generation defaults',
|
|
1739
1723
|
'',
|
|
1740
1724
|
'Connections — a skill that needs an account or a token (Menu ▸ Agent ▸ Connections lists them with their state)',
|
|
1741
|
-
' /connect
|
|
1742
|
-
'
|
|
1743
|
-
' /connect notion — OAuth-connect Notion MCP via PKCE + dynamic registration (no env, no secret)',
|
|
1744
|
-
' /connect asana — OAuth-connect Asana MCP via PKCE (needs ASANA_OAUTH_CLIENT_ID + ASANA_OAUTH_CLIENT_SECRET)',
|
|
1725
|
+
' /connect <skill> — OAuth-connect a skill that declares one (the Connections page lists them)',
|
|
1726
|
+
' the client app credentials come from <PROVIDER>_OAUTH_CLIENT_ID and <PROVIDER>_OAUTH_CLIENT_SECRET; a skill that registers its own client needs neither',
|
|
1745
1727
|
'',
|
|
1746
1728
|
'Voice',
|
|
1747
1729
|
' /speak <text> — synthesize speech (TTS) to a WAV file in the save dir',
|
|
@@ -2092,7 +2074,7 @@ export class ChatApp {
|
|
|
2092
2074
|
const bytes = Buffer.concat(pieces)
|
|
2093
2075
|
if (!bytes.length) return `empty download for ${att.fileName}`
|
|
2094
2076
|
const ext = { 'image/jpeg': '.jpg', 'image/png': '.png' }[att.mimeType]
|
|
2095
|
-
const file = await saveUniqueFile(this._saveDir, att.fileName, bytes, ext
|
|
2077
|
+
const file = await saveUniqueFile(this._saveDir, att.fileName, bytes, ext)
|
|
2096
2078
|
if (file) return `saved ${att.fileName} (${bytes.length}B) to ${file}`
|
|
2097
2079
|
return `not saved: 100 files named ${att.fileName} already exist in ${this._saveDir}`
|
|
2098
2080
|
})
|
|
@@ -2213,134 +2195,103 @@ export class ChatApp {
|
|
|
2213
2195
|
}
|
|
2214
2196
|
|
|
2215
2197
|
if (cmd === 'connect') {
|
|
2216
|
-
const [
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
return
|
|
2198
|
+
const [slug = ''] = rest
|
|
2199
|
+
if (!slug) return notice('usage: /connect <skill> — Menu ▸ Agent ▸ Connections lists them')
|
|
2200
|
+
return run(async () => {
|
|
2201
|
+
let skills
|
|
2202
|
+
try {
|
|
2203
|
+
skills = this._skills ? await this._skills(agent.id, agent.modelName) : []
|
|
2204
|
+
} catch (error) {
|
|
2205
|
+
return `could not read the skill catalog: ${error?.message ?? error}`
|
|
2224
2206
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
credentialKey: googleSpec.credentialKey,
|
|
2231
|
-
openUrl: (url) => {
|
|
2232
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2233
|
-
this._render()
|
|
2234
|
-
openInBrowser(url)
|
|
2235
|
-
}
|
|
2236
|
-
})
|
|
2237
|
-
await engine.configSet({
|
|
2238
|
-
key: credKey(agent.id, googleSpec.credentialKey),
|
|
2239
|
-
value: tokens.accessToken
|
|
2240
|
-
})
|
|
2241
|
-
await engine.configSet({
|
|
2242
|
-
key: credKey(agent.id, googleSpec.stateKey),
|
|
2243
|
-
value: JSON.stringify({
|
|
2244
|
-
refreshToken: tokens.refreshToken,
|
|
2245
|
-
expiresAt: tokens.expiresAt,
|
|
2246
|
-
clientId,
|
|
2247
|
-
clientSecret
|
|
2248
|
-
})
|
|
2249
|
-
})
|
|
2250
|
-
return `${provider} connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2251
|
-
})
|
|
2252
|
-
}
|
|
2253
|
-
if (provider === 'spotify') {
|
|
2254
|
-
const clientId = process.env.SPOTIFY_OAUTH_CLIENT_ID
|
|
2255
|
-
if (!clientId) {
|
|
2256
|
-
return notice('set SPOTIFY_OAUTH_CLIENT_ID, then retry')
|
|
2207
|
+
const matches = oauthSpecs(skills ?? []).filter(
|
|
2208
|
+
(candidate) => connectSlug(candidate.credentialKey) === slug
|
|
2209
|
+
)
|
|
2210
|
+
if (matches.length === 0) {
|
|
2211
|
+
return `no connectable skill named ${slug} — Menu ▸ Agent ▸ Connections`
|
|
2257
2212
|
}
|
|
2258
|
-
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2261
|
-
clientId,
|
|
2262
|
-
openUrl: (url) => {
|
|
2263
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2264
|
-
this._render()
|
|
2265
|
-
openInBrowser(url)
|
|
2266
|
-
}
|
|
2267
|
-
})
|
|
2268
|
-
await engine.configSet({
|
|
2269
|
-
key: credKey(agent.id, SPOTIFY_CREDENTIAL_KEY),
|
|
2270
|
-
value: tokens.accessToken
|
|
2271
|
-
})
|
|
2272
|
-
await engine.configSet({
|
|
2273
|
-
key: credKey(agent.id, SPOTIFY_OAUTH_STATE_KEY),
|
|
2274
|
-
value: JSON.stringify({
|
|
2275
|
-
refreshToken: tokens.refreshToken,
|
|
2276
|
-
expiresAt: tokens.expiresAt,
|
|
2277
|
-
clientId
|
|
2278
|
-
})
|
|
2279
|
-
})
|
|
2280
|
-
return `spotify connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2281
|
-
})
|
|
2282
|
-
}
|
|
2283
|
-
if (provider === 'notion') {
|
|
2284
|
-
return run(async () => {
|
|
2285
|
-
const { connectNotion, NOTION_OAUTH_STATE_KEY } = await import('../dist-lib/lib/oauth.js')
|
|
2286
|
-
const tokens = await connectNotion({
|
|
2287
|
-
openUrl: (url) => {
|
|
2288
|
-
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2289
|
-
this._render()
|
|
2290
|
-
openInBrowser(url)
|
|
2291
|
-
}
|
|
2292
|
-
})
|
|
2293
|
-
await engine.configSet({
|
|
2294
|
-
key: credKey(agent.id, NOTION_MCP_CREDENTIAL_KEY),
|
|
2295
|
-
value: tokens.accessToken
|
|
2296
|
-
})
|
|
2297
|
-
await engine.configSet({
|
|
2298
|
-
key: credKey(agent.id, NOTION_OAUTH_STATE_KEY),
|
|
2299
|
-
value: JSON.stringify({
|
|
2300
|
-
refreshToken: tokens.refreshToken,
|
|
2301
|
-
expiresAt: tokens.expiresAt,
|
|
2302
|
-
clientId: tokens.clientId
|
|
2303
|
-
})
|
|
2304
|
-
})
|
|
2305
|
-
return `notion connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2306
|
-
})
|
|
2307
|
-
}
|
|
2308
|
-
if (provider === 'asana') {
|
|
2309
|
-
const clientId = process.env.ASANA_OAUTH_CLIENT_ID
|
|
2310
|
-
const clientSecret = process.env.ASANA_OAUTH_CLIENT_SECRET
|
|
2311
|
-
if (!clientId || !clientSecret) {
|
|
2312
|
-
return notice('set ASANA_OAUTH_CLIENT_ID and ASANA_OAUTH_CLIENT_SECRET, then retry')
|
|
2213
|
+
if (matches.length > 1) {
|
|
2214
|
+
const keys = matches.map((m) => m.credentialKey).join(', ')
|
|
2215
|
+
return `${slug} is ambiguous — matches ${keys}, use the full credential key`
|
|
2313
2216
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2217
|
+
const [spec] = matches
|
|
2218
|
+
// the setup fields are stored per declaring skill, and a `secret` one lands in the
|
|
2219
|
+
// credential namespace rather than the settings one (see lib/core/skill-secrets.ts)
|
|
2220
|
+
const owner = (skills ?? []).find((skill) =>
|
|
2221
|
+
(skill.setup?.routes ?? []).some((route) => route.credentialKey === spec.credentialKey)
|
|
2222
|
+
)
|
|
2223
|
+
const ownerRoute = (owner?.setup?.routes ?? []).find(
|
|
2224
|
+
(route) => route.credentialKey === spec.credentialKey
|
|
2225
|
+
)
|
|
2226
|
+
const storedField = async (name) => {
|
|
2227
|
+
const field = (ownerRoute?.fields ?? []).find((entry) => entry.key === name)
|
|
2228
|
+
if (!field || !owner) return ''
|
|
2229
|
+
const key =
|
|
2230
|
+
field.secret === true
|
|
2231
|
+
? credKey(agent.id, field.key)
|
|
2232
|
+
: settingConfigKey(agent.id, owner.name, field.key)
|
|
2233
|
+
const { value } = await engine.configGet({ key })
|
|
2234
|
+
return typeof value === 'string' ? value : ''
|
|
2235
|
+
}
|
|
2236
|
+
const env = spec.provider.toUpperCase().replaceAll('-', '_')
|
|
2237
|
+
const idVar = `${env}_OAUTH_CLIENT_ID`
|
|
2238
|
+
const secretVar = `${env}_OAUTH_CLIENT_SECRET`
|
|
2239
|
+
const needsSecret = spec.tokenAuth !== 'pkce-only'
|
|
2240
|
+
const clientId = (await storedField('clientId')) || process.env[idVar] || ''
|
|
2241
|
+
const clientSecret = (await storedField('clientSecret')) || process.env[secretVar] || ''
|
|
2242
|
+
// registrationEndpoint implies pkce-only (keys.ts specFromRoute), so a DCR skill never
|
|
2243
|
+
// reaches the secret check below demanding one it has no use for
|
|
2244
|
+
if (!clientId && !spec.registrationEndpoint) {
|
|
2245
|
+
return needsSecret
|
|
2246
|
+
? `set ${idVar} and ${secretVar}, then retry`
|
|
2247
|
+
: `set ${idVar}, then retry`
|
|
2248
|
+
}
|
|
2249
|
+
if (needsSecret && !clientSecret) return `set ${idVar} and ${secretVar}, then retry`
|
|
2250
|
+
|
|
2251
|
+
const { buildProviderConfig, runOAuthFlow } = await import('../dist-lib/lib/oauth.js')
|
|
2252
|
+
let registeredClientId = ''
|
|
2253
|
+
const tokens = await runOAuthFlow(
|
|
2254
|
+
buildProviderConfig(spec, {
|
|
2317
2255
|
clientId,
|
|
2318
|
-
clientSecret
|
|
2256
|
+
...(needsSecret ? { clientSecret } : {})
|
|
2257
|
+
}),
|
|
2258
|
+
{
|
|
2319
2259
|
openUrl: (url) => {
|
|
2320
2260
|
this.status = fg.dim.render(`authorize in your browser: ${url}`)
|
|
2321
2261
|
this._render()
|
|
2322
2262
|
openInBrowser(url)
|
|
2263
|
+
},
|
|
2264
|
+
getClientId: async () => {
|
|
2265
|
+
// a prior run may have registered a client already — read it back from state
|
|
2266
|
+
// instead of re-registering a fresh one at the provider every /connect
|
|
2267
|
+
const { value } = await engine.configGet({ key: credKey(agent.id, spec.stateKey) })
|
|
2268
|
+
try {
|
|
2269
|
+
const state = typeof value === 'string' ? JSON.parse(value) : null
|
|
2270
|
+
return state?.clientId || undefined
|
|
2271
|
+
} catch {
|
|
2272
|
+
return undefined
|
|
2273
|
+
}
|
|
2274
|
+
},
|
|
2275
|
+
saveClientId: async (id) => {
|
|
2276
|
+
registeredClientId = id
|
|
2323
2277
|
}
|
|
2278
|
+
}
|
|
2279
|
+
)
|
|
2280
|
+
await engine.configSet({
|
|
2281
|
+
key: credKey(agent.id, spec.credentialKey),
|
|
2282
|
+
value: tokens.accessToken
|
|
2283
|
+
})
|
|
2284
|
+
await engine.configSet({
|
|
2285
|
+
key: credKey(agent.id, spec.stateKey),
|
|
2286
|
+
value: JSON.stringify({
|
|
2287
|
+
refreshToken: tokens.refreshToken,
|
|
2288
|
+
expiresAt: tokens.expiresAt,
|
|
2289
|
+
clientId: clientId || registeredClientId,
|
|
2290
|
+
...(needsSecret ? { clientSecret } : {})
|
|
2324
2291
|
})
|
|
2325
|
-
await engine.configSet({
|
|
2326
|
-
key: credKey(agent.id, ASANA_MCP_CREDENTIAL_KEY),
|
|
2327
|
-
value: tokens.accessToken
|
|
2328
|
-
})
|
|
2329
|
-
await engine.configSet({
|
|
2330
|
-
key: credKey(agent.id, ASANA_OAUTH_STATE_KEY),
|
|
2331
|
-
value: JSON.stringify({
|
|
2332
|
-
refreshToken: tokens.refreshToken,
|
|
2333
|
-
expiresAt: tokens.expiresAt,
|
|
2334
|
-
clientId,
|
|
2335
|
-
clientSecret
|
|
2336
|
-
})
|
|
2337
|
-
})
|
|
2338
|
-
return `asana connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2339
2292
|
})
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
'usage: /connect gmail|google-calendar|google-docs|google-drive|google-sheets|spotify|notion|asana'
|
|
2343
|
-
)
|
|
2293
|
+
return `${slug} connected for agent ${agent.name} — token stored, auto-refreshes on use`
|
|
2294
|
+
})
|
|
2344
2295
|
}
|
|
2345
2296
|
|
|
2346
2297
|
if (cmd === 'cred') {
|
|
@@ -3237,23 +3188,15 @@ export class ChatApp {
|
|
|
3237
3188
|
}
|
|
3238
3189
|
}
|
|
3239
3190
|
|
|
3191
|
+
// The fallback page when the engine cannot report skills: which skills are connectable is
|
|
3192
|
+
// theirs to declare, so all this can offer is the command itself.
|
|
3240
3193
|
_connectMenu() {
|
|
3241
3194
|
return {
|
|
3242
3195
|
title: 'Connections',
|
|
3243
3196
|
cursor: 0,
|
|
3244
3197
|
entries: [
|
|
3245
|
-
{ label: 'Connect
|
|
3246
|
-
{
|
|
3247
|
-
label: 'Connect Google Calendar',
|
|
3248
|
-
hint: 'OAuth Calendar',
|
|
3249
|
-
command: '/connect google-calendar'
|
|
3250
|
-
},
|
|
3251
|
-
{ label: 'Connect Google Docs', hint: 'OAuth Docs', command: '/connect google-docs' },
|
|
3252
|
-
{ label: 'Connect Google Drive', hint: 'OAuth Drive', command: '/connect google-drive' },
|
|
3253
|
-
{ label: 'Connect Google Sheets', hint: 'OAuth Sheets', command: '/connect google-sheets' },
|
|
3254
|
-
{ label: 'Connect Spotify', hint: 'OAuth Spotify (PKCE)', command: '/connect spotify' },
|
|
3255
|
-
{ label: 'Connect Notion', hint: 'OAuth Notion MCP', command: '/connect notion' },
|
|
3256
|
-
{ label: 'Connect Asana', hint: 'OAuth Asana MCP', command: '/connect asana' }
|
|
3198
|
+
{ label: 'Connect a skill…', hint: '/connect <skill>', prefill: '/connect ' },
|
|
3199
|
+
{ label: 'Set a credential…', hint: '/cred <key> <value>', prefill: '/cred ' }
|
|
3257
3200
|
]
|
|
3258
3201
|
}
|
|
3259
3202
|
}
|
|
@@ -2,7 +2,7 @@ import fs from 'fs'
|
|
|
2
2
|
import os from 'os'
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import { fileURLToPath } from 'url'
|
|
5
|
-
import { RAG_ACCEPT_EXTENSIONS } from '
|
|
5
|
+
import { RAG_ACCEPT_EXTENSIONS } from 'rag-extract'
|
|
6
6
|
import { UPLOAD_FRAME_BYTES, writeFrame } from './upload-frames.mjs'
|
|
7
7
|
const ACCEPTED = new Set(RAG_ACCEPT_EXTENSIONS)
|
|
8
8
|
const MIME_TYPES = new Map([
|
package/tui/lib/save-file.mjs
CHANGED
|
@@ -44,7 +44,7 @@ async function claimUniqueFile(dir, fileName, extension, source) {
|
|
|
44
44
|
const safe = !sanitized || sanitized === '.' || sanitized === '..' ? 'download' : sanitized
|
|
45
45
|
const dot = safe.lastIndexOf('.')
|
|
46
46
|
const base = (dot > 0 ? safe.slice(0, dot) : safe) || 'download'
|
|
47
|
-
const ext =
|
|
47
|
+
const ext = dot > 0 ? safe.slice(dot) : (extension ?? '')
|
|
48
48
|
|
|
49
49
|
for (let n = 0; n < 100; n++) {
|
|
50
50
|
const file = path.join(dir, `${base}${n ? `-${n + 1}` : ''}${ext}`)
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: asana
|
|
3
|
-
description: Conventions for the QVAC Assistant Asana board when working through the Asana MCP server — what the MCP cannot do and what that silently breaks, the Context field that decides whether a task is visible at all, and the rule against consuming task descriptions. Use before creating, moving, or reading any Asana task for this project.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Asana — QVAC Assistant board
|
|
7
|
-
|
|
8
|
-
Asana work here goes through the **Asana MCP server**. This skill is not a tool;
|
|
9
|
-
it is the handful of things the MCP does not tell you and will not stop you
|
|
10
|
-
getting wrong.
|
|
11
|
-
|
|
12
|
-
- Workspace `45238840754660` (tether.to)
|
|
13
|
-
- Project `1214754188814246` (QVAC Assistant)
|
|
14
|
-
- Board: <https://app.asana.com/1/45238840754660/project/1214754188814246>
|
|
15
|
-
|
|
16
|
-
## Do not create tasks through the MCP
|
|
17
|
-
|
|
18
|
-
`asana_create_task` takes `resource_subtype` of only `default_task`, `milestone`
|
|
19
|
-
or `approval`, and neither it nor `asana_update_task` accepts `custom_type` or
|
|
20
|
-
`custom_type_status_option`. This board runs on the **QVAC Basic Task** custom
|
|
21
|
-
type (`1214533632534265`), whose status options _are_ the workflow — the project
|
|
22
|
-
has one real section and tracks status entirely through the custom type.
|
|
23
|
-
|
|
24
|
-
So an MCP-created task is a plain default task that:
|
|
25
|
-
|
|
26
|
-
- is not a `QVAC Basic Task`,
|
|
27
|
-
- has no status (To Do / In Progress / In Code Review / Blocked /
|
|
28
|
-
Completed-Ready for QA / Fully Verified / Closed-Won't Fix), and
|
|
29
|
-
- cannot be given one afterwards through the API.
|
|
30
|
-
|
|
31
|
-
It lands on the board looking almost right and is undriveable. **Ask the user to
|
|
32
|
-
create the task in the Asana UI**, where the custom type is the default, and then
|
|
33
|
-
use the MCP to fill fields or comment on it. Do not create it yourself and
|
|
34
|
-
promise to "fix the type later" — the API has no route to do that.
|
|
35
|
-
|
|
36
|
-
Moving a task's status has the same limitation: the status lives on
|
|
37
|
-
`custom_type_status_option`, which the MCP cannot set. Status changes are a UI
|
|
38
|
-
action.
|
|
39
|
-
|
|
40
|
-
## Context is mandatory, and the MCP will not warn you
|
|
41
|
-
|
|
42
|
-
The project's Dev Board tabs are saved views filtered on the **Context** custom
|
|
43
|
-
field. A task with Context unset appears only in "Full List" and "Overview" — it
|
|
44
|
-
is invisible on every Dev Board tab and silently slips off the team's radar.
|
|
45
|
-
|
|
46
|
-
Whenever you set fields on a task, set Context. Field `1214754188814251`:
|
|
47
|
-
|
|
48
|
-
| Value | GID | For |
|
|
49
|
-
| -------------- | ------------------ | ------------------------------------------------- |
|
|
50
|
-
| `harness` | `1214754188814252` | engine, mesh and sync, storage, build and release |
|
|
51
|
-
| `integrations` | `1214754188814253` | assistant runtime, agents, tools, skills |
|
|
52
|
-
| `other` | `1214758268571416` | genuinely cross-cutting: org, legal, product docs |
|
|
53
|
-
|
|
54
|
-
Surface which one you picked and why, and let the user correct it. Never guess
|
|
55
|
-
silently, and never leave it blank to avoid choosing.
|
|
56
|
-
|
|
57
|
-
## Release grouping
|
|
58
|
-
|
|
59
|
-
Each Dev Board tab groups by **QVAC Workbench Release** (field
|
|
60
|
-
`1214111405360914`) first. A task with none lands in an "Untitled" bucket at the
|
|
61
|
-
bottom of every tab. Default to `tbc` (`1214757840453965`) when the release is
|
|
62
|
-
undecided.
|
|
63
|
-
|
|
64
|
-
**That field is the app's release, not a package version.** `@qvac/harness`,
|
|
65
|
-
`@qvac/core` and `@qvac/skills` each ship their own `0.x` line; putting one of
|
|
66
|
-
those numbers here files the task against a release that does not exist.
|
|
67
|
-
|
|
68
|
-
## Never consume task descriptions
|
|
69
|
-
|
|
70
|
-
Work from task metadata only: GID, name, permalink, completion state, assignee,
|
|
71
|
-
memberships, custom fields, custom type and status, timestamps, and comments.
|
|
72
|
-
|
|
73
|
-
- `asana_get_task` returns the description by default. Pass an explicit
|
|
74
|
-
`opt_fields` list that omits `notes`, `html_notes` and `description`.
|
|
75
|
-
- Do not use Asana full-text search as a fallback — it matches descriptions.
|
|
76
|
-
Find tasks by the QVAC custom field (`1209150993228635`, text) or by GID.
|
|
77
|
-
- If the user wants you to act on a description, ask them to paste the relevant
|
|
78
|
-
excerpt rather than fetching it.
|
|
79
|
-
|
|
80
|
-
## Before any mutation
|
|
81
|
-
|
|
82
|
-
Show the exact change and wait for a yes. That includes field edits, comments and
|
|
83
|
-
completion — this board is shared with the whole team, and a comment cannot be
|
|
84
|
-
unsent.
|
|
85
|
-
|
|
86
|
-
Never put tokens, secrets or internal-only URLs in a task or comment.
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: compaction
|
|
3
|
-
description: Reason about prompt compaction (the fold), chat history and KV-cache invalidation in @qvac/core — why history is never evicted client-side, what compactChat is allowed to do, and which events must delete a chat's cache key. Read this BEFORE proposing any history windowing, trimming, token budgeting or "the model forgot the conversation" fix.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Compaction + cache invalidation
|
|
7
|
-
|
|
8
|
-
This repo owns the **prompt**: what history a run is given, when that history is
|
|
9
|
-
folded, and when a chat's cache key has to be thrown away. The **cache itself** —
|
|
10
|
-
the `kvCache` key, the context window, the overflow ladder, `ContextOverflowError`
|
|
11
|
-
— belongs to `@qvac/harness`; read its **kvcache** skill and
|
|
12
|
-
`@qvac/harness → docs/kvcache-reference.md` before changing anything on this side.
|
|
13
|
-
|
|
14
|
-
## The rule that governs everything here
|
|
15
|
-
|
|
16
|
-
Three state sets exist and are **never reconciled**:
|
|
17
|
-
|
|
18
|
-
| Layer | State | Keyed by |
|
|
19
|
-
| --------- | -------------------------------------------------------- | --------------- |
|
|
20
|
-
| this repo | the message **list** (shrinks only on an overflow retry) | chat |
|
|
21
|
-
| SDK | the message **count** (`savedCount`) | cache file path |
|
|
22
|
-
| addon | token **positions** + the on-disk `.bin` | cache key |
|
|
23
|
-
|
|
24
|
-
`savedCount` means "already sent", never "still resident": nothing below the SDK
|
|
25
|
-
reports what it evicted. So **anything that quietly removes messages from the
|
|
26
|
-
middle of the history is a correctness bug, not an optimisation** — the model
|
|
27
|
-
loses that span with no signal anywhere. That is what killed the retired sliding
|
|
28
|
-
window, and it is the test any new idea has to pass.
|
|
29
|
-
|
|
30
|
-
**No client-side token math, ever.** Use the SDK's real `cacheTokens` /
|
|
31
|
-
`promptTokens` from `completion()` stats, and react to the typed
|
|
32
|
-
`ContextOverflowError`. Never estimate chars-per-token, never reserve a response
|
|
33
|
-
budget.
|
|
34
|
-
|
|
35
|
-
## Before proposing history eviction
|
|
36
|
-
|
|
37
|
-
Ask whether the SDK cache already handles it. It does, for ordinary history
|
|
38
|
-
growth. The cases that genuinely need handling here are a message (or tool
|
|
39
|
-
result) larger than `ctx_size`, and the cross-device cold start — the cache is
|
|
40
|
-
device-local, so a chat that moves to another device legitimately re-primes.
|
|
41
|
-
|
|
42
|
-
**Compaction is the one sanctioned exception, and it already exists — do not
|
|
43
|
-
build a second one.** [`lib/compaction.ts`](../../../lib/compaction.ts) folds a
|
|
44
|
-
chat's older turns into one summary turn, persisted as a replicated `compaction`
|
|
45
|
-
chunk so every device rebuilds the same prompt; `historyFromChunks` in
|
|
46
|
-
[`lib/assistant.ts`](../../../lib/assistant.ts) applies it.
|
|
47
|
-
|
|
48
|
-
What makes the fold legal under the rule above:
|
|
49
|
-
|
|
50
|
-
- **It evicts from the prompt, never from the KV.** The chunks it folds stay in
|
|
51
|
-
the store and keep rendering; only what `completion()` is sent shrinks.
|
|
52
|
-
- **No token math.** The triggers read the SDK's own `cacheTokens` against the
|
|
53
|
-
`ctxSize` of the run that reported them, and the summary is bounded by prompt
|
|
54
|
-
shape rather than a computed budget.
|
|
55
|
-
- **It is a divergence writer, so it invalidates.** `compactChat` deletes the
|
|
56
|
-
chat key after the fold lands, and each device deletes once for a fold that
|
|
57
|
-
arrived from another one (`_reconcileCompaction`).
|
|
58
|
-
- **It has a floor.** Below `COMPACTION_MIN_CTX_SIZE` (4,096, in
|
|
59
|
-
[`lib/model-context.ts`](../../../lib/model-context.ts)) a fold cannot pay for
|
|
60
|
-
the ~420-token prefix it shares the window with, so those chats stay on the
|
|
61
|
-
harness overflow ladder. A client must read that constant before promising a
|
|
62
|
-
summary — the context picker still offers 1k and 2k.
|
|
63
|
-
- **It keeps one turn, and refuses to grow the prompt.** `COMPACTION_KEEP_TURNS`
|
|
64
|
-
is 1: the last user message stays verbatim because nothing else can answer it,
|
|
65
|
-
and a second kept turn would drag its assistant answer — usually the biggest
|
|
66
|
-
thing in the chat — along with it. `foldReducesPrompt` then refuses any summary
|
|
67
|
-
longer than the turns it replaces.
|
|
68
|
-
- **It narrows instead of failing.** The fold's own prompt is the range it folds,
|
|
69
|
-
so on a summarizer overflow `compactChat` halves the range and retries; a
|
|
70
|
-
boundary no later than the last fold's is refused, so it cannot un-fold a chat.
|
|
71
|
-
The boundary also walks back over the uploads bound to the first kept message,
|
|
72
|
-
which are appended before it.
|
|
73
|
-
- **The summarizing run is tool- and skill-less and passes no `cacheKey`**, so it
|
|
74
|
-
cannot answer the question instead of summarizing it, and cannot pollute the
|
|
75
|
-
chat's own cache file.
|
|
76
|
-
|
|
77
|
-
Triggers: proactively before a run on the previous round's numbers, and
|
|
78
|
-
reactively once the harness overflow ladder is exhausted. Never at the end of a
|
|
79
|
-
run on its own numbers — that path existed and was removed (see the decision
|
|
80
|
-
record): the turn that fills the window ends cleanly, publishes its full reading,
|
|
81
|
-
and the next message folds first, keeping itself verbatim. The proactive share is
|
|
82
|
-
tiered by window — 75% under 12k, 82% under 16k, 85% under 32k, 90% under 64k,
|
|
83
|
-
95% from there — because the band has to hold a whole thinking turn and
|
|
84
|
-
`cacheTokens` reports a turn with its thinking stripped. Both folds announce a
|
|
85
|
-
`compacting` phase. The before-run fold announces before anything streamed and
|
|
86
|
-
clears the phase, because its run carries on; the overflow fold can land behind
|
|
87
|
-
a partial answer, since a mid-stream overflow is not retried, and its failed
|
|
88
|
-
status closes the phase. That announcement is not an attempt start in
|
|
89
|
-
`historyFromChunks` — reading it as one drops the streamed answer from every
|
|
90
|
-
later prompt — and clients exempt it from their restart rule for the same
|
|
91
|
-
reason.
|
|
92
|
-
|
|
93
|
-
After the fact the fold is visible from its chunk (`thread.compactionMarkers`,
|
|
94
|
-
anchored before the user message the fold precedes). Only the device that ran the
|
|
95
|
-
turn is a valid reading: `ctxSize` is per-device, so a chat that moved from a
|
|
96
|
-
phone carries a window this host does not have.
|
|
97
|
-
|
|
98
|
-
## Invalidation — when the chat key must die
|
|
99
|
-
|
|
100
|
-
[`lib/kv-cache-reclaim.ts`](../../../lib/kv-cache-reclaim.ts) owns the keys:
|
|
101
|
-
`chatKvCacheKey(chatId)` and `chatRepairKvCacheKey(chatId, acceptedRepairs)` — a
|
|
102
|
-
repair generation nests under the chat key, so deleting the chat key reclaims
|
|
103
|
-
every generation.
|
|
104
|
-
|
|
105
|
-
This repo deletes a chat's cache at three moments, and **a new feature that
|
|
106
|
-
changes history in place must route through the same invalidation**:
|
|
107
|
-
|
|
108
|
-
1. Before executing a superseding run — retry or regenerate, the `parentId`
|
|
109
|
-
run-request.
|
|
110
|
-
2. When a chat disappears from the chat list (`disappearedChatIds`).
|
|
111
|
-
3. For an agent's chats when its re-key fields change — bio, model, ctx,
|
|
112
|
-
kv-quant, tool and skill selection (`agentRekeyFingerprint`).
|
|
113
|
-
|
|
114
|
-
A future edit-message or delete-message feature is exactly case 1 in disguise.
|
|
115
|
-
Editing text that is already in the KV without dropping the key leaves the model
|
|
116
|
-
answering the _old_ text, invisibly.
|
|
117
|
-
|
|
118
|
-
Apps delete device-locally through the engine API: `clearKvCache()` and
|
|
119
|
-
`deleteChatKvCache({ id })` in [`lib/api/`](../../../lib/api/). Neither
|
|
120
|
-
replicates — the chat's warm cache may live on the provider device.
|
|
121
|
-
|
|
122
|
-
## Symptoms, and where they actually come from
|
|
123
|
-
|
|
124
|
-
| Symptom | Look here first |
|
|
125
|
-
| --------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
126
|
-
| "the model forgot the middle of the chat" | something evicted history without invalidating — never the cache doing its job |
|
|
127
|
-
| "it answers the question I asked an hour ago" | a stale cache key that should have been deleted (retry/regenerate, agent re-key) |
|
|
128
|
-
| every turn is slow to first token | `configHash` churn — a volatile system prompt or a changing tool set re-keys the file each turn |
|
|
129
|
-
| a long chat errors instead of folding | `ctxSize` below `COMPACTION_MIN_CTX_SIZE`; the fold is refused by design |
|
|
130
|
-
| the summary is longer than what it replaced | `foldReducesPrompt` refused it — that is the guard working |
|
|
131
|
-
|
|
132
|
-
## Sibling skills
|
|
133
|
-
|
|
134
|
-
- The cache, the context window and the overflow ladder → **kvcache**, in
|
|
135
|
-
`@qvac/harness`.
|
|
136
|
-
- How the code itself should be shaped → **js-house-style**.
|