@qvac/core 1.0.0-rc.6 → 1.0.0-rc.7
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/agents.js +5 -2
- package/dist-lib/lib/api/approval-rules.js +8 -5
- package/dist-lib/lib/api/chat.d.ts +1 -2
- package/dist-lib/lib/api/chat.js +4 -18
- package/dist-lib/lib/api/index.d.ts +0 -1
- package/dist-lib/lib/api/index.js +1 -2
- package/dist-lib/lib/api/mesh.d.ts +1 -1
- package/dist-lib/lib/api/mesh.js +1 -1
- package/dist-lib/lib/api/sync.js +12 -2
- package/dist-lib/lib/assistant.d.ts +0 -1
- package/dist-lib/lib/assistant.js +10 -13
- package/dist-lib/lib/core/archived-mesh.d.ts +1 -0
- package/dist-lib/lib/core/archived-mesh.js +11 -14
- package/dist-lib/lib/core/chat-copy.d.ts +0 -1
- package/dist-lib/lib/core/chat-copy.js +1 -2
- package/dist-lib/lib/core/chat-move.d.ts +3 -1
- package/dist-lib/lib/core/chat-move.js +5 -2
- package/dist-lib/lib/core/contract/joined-meshes.js +2 -1
- package/dist-lib/lib/core/local/index.d.ts +2 -1
- package/dist-lib/lib/core/local/index.js +3 -2
- package/dist-lib/lib/core/public-mesh.d.ts +6 -8
- package/dist-lib/lib/core/public-mesh.js +19 -29
- package/dist-lib/lib/core/sync/index.js +1 -1
- package/dist-lib/lib/core.d.ts +15 -8
- package/dist-lib/lib/core.js +219 -203
- package/dist-lib/lib/errors.d.ts +4 -12
- package/dist-lib/lib/errors.js +4 -12
- package/dist-lib/schema/engine.js +10 -3
- package/dist-lib/schema/local.js +4 -2
- package/dist-lib/schema/qvac.js +2 -1
- package/dist-lib/spec/capabilities.d.ts +2 -2
- package/dist-lib/spec/hrpc/hrpc.json +1 -1
- package/dist-lib/spec/hrpc/index.js +1 -1
- package/dist-lib/spec/hrpc/messages.js +273 -250
- package/dist-lib/spec/hyperschema/index.js +273 -250
- package/dist-lib/spec/hyperschema/schema.json +27 -6
- package/dist-lib/spec/hyperschema/types.d.ts +7 -1
- package/dist-lib/spec/local/hyperdb/messages.js +26 -12
- package/dist-lib/spec/local/hyperschema/index.js +13 -6
- package/dist-lib/spec/local/hyperschema/schema.json +10 -0
- package/dist-lib/spec/local/hyperschema/types.d.ts +2 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +30 -6
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +15 -3
- package/dist-lib/spec/mesh/hyperschema/index.js +15 -3
- package/dist-lib/spec/mesh/hyperschema/schema.json +5 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +1 -0
- package/package.json +1 -1
- package/tui/app.mjs +47 -12
package/tui/app.mjs
CHANGED
|
@@ -283,7 +283,7 @@ const COMMANDS = [
|
|
|
283
283
|
palette: true,
|
|
284
284
|
sub: [
|
|
285
285
|
{ name: 'use', desc: '<n|id> — make one of your meshes the active one' },
|
|
286
|
-
{ name: 'new', desc: '
|
|
286
|
+
{ name: 'new', desc: 'create a workspace' },
|
|
287
287
|
{ name: 'label', desc: '<n|id> <name> — name a mesh, privately to you' },
|
|
288
288
|
{ name: 'move', desc: '<n|id> [chat] — move this chat, or a named one, into another mesh' },
|
|
289
289
|
{ name: 'moved', desc: '[chat] — how the last move from this window is going' },
|
|
@@ -1742,8 +1742,9 @@ const isOwnDefault = (agent, deviceId) =>
|
|
|
1742
1742
|
b4a.equals(agent.providerDeviceId, deviceId)
|
|
1743
1743
|
const ownDefault = (agents, deviceId) => agents.find((agent) => isOwnDefault(agent, deviceId))
|
|
1744
1744
|
|
|
1745
|
-
// deviceInfo carries no model: the recommendation lives on the device's own row in the
|
|
1746
|
-
async function recommendedModel(engine,
|
|
1745
|
+
// deviceInfo carries no model: the recommendation lives on the device's own row in the account
|
|
1746
|
+
async function recommendedModel(engine, deviceId) {
|
|
1747
|
+
const meshId = await accountMeshId(engine)
|
|
1747
1748
|
return (await engine.getDevice({ meshId, deviceId })).recommendedModelName
|
|
1748
1749
|
}
|
|
1749
1750
|
|
|
@@ -1793,7 +1794,7 @@ async function firstAgent(engine, meshId, { deviceId, modelName, remembered, acc
|
|
|
1793
1794
|
name: 'QV.AC',
|
|
1794
1795
|
bio: 'You are a helpful local assistant. Be clear, practical, and concise.',
|
|
1795
1796
|
providerDeviceId: deviceId,
|
|
1796
|
-
modelName: modelName || (await recommendedModel(engine,
|
|
1797
|
+
modelName: modelName || (await recommendedModel(engine, deviceId)),
|
|
1797
1798
|
isDefault: true
|
|
1798
1799
|
}
|
|
1799
1800
|
})
|
|
@@ -1835,7 +1836,28 @@ async function firstChat(engine, meshId, { agent, remembered, account }) {
|
|
|
1835
1836
|
return engine.createChat({ meshId, agentId: agent.id, config: { title: 'New Chat' } })
|
|
1836
1837
|
}
|
|
1837
1838
|
|
|
1838
|
-
|
|
1839
|
+
const NO_WORKSPACE = 'you are in no workspace - /mesh new creates one, /join <invite> joins one'
|
|
1840
|
+
|
|
1841
|
+
// the workspace a window opens on: the last chat's if still listed, else the first, else none
|
|
1842
|
+
async function windowWorkspace(engine) {
|
|
1843
|
+
// from joined on, an empty list means no workspace rather than one still being minted
|
|
1844
|
+
for await (const status of engine.meshStatusWatch?.({}) ?? []) {
|
|
1845
|
+
if (status.state === 'joined') break
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
const { meshes } = await engine.listMeshes({})
|
|
1849
|
+
const workspaces = (meshes ?? []).filter((mesh) => mesh.workspace)
|
|
1850
|
+
const config = engine.getConfig ? await engine.getConfig({}) : null
|
|
1851
|
+
for (const { meshId } of config?.activeChatId ? workspaces : []) {
|
|
1852
|
+
if (await engine.getChat({ meshId, chatId: config.activeChatId }).catch(() => null)) {
|
|
1853
|
+
return meshId
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
return workspaces[0]?.meshId ?? null
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
// the account, where agents and devices live; a kicked device has none until Core mints the next
|
|
1839
1861
|
async function accountMeshId(engine) {
|
|
1840
1862
|
for await (const account of engine.accountWatch({})) {
|
|
1841
1863
|
if (account.meshId) return account.meshId
|
|
@@ -2011,7 +2033,8 @@ export class ChatApp {
|
|
|
2011
2033
|
_resolveAccount() {
|
|
2012
2034
|
return async () => {
|
|
2013
2035
|
try {
|
|
2014
|
-
|
|
2036
|
+
const meshId = await windowWorkspace(this.engine)
|
|
2037
|
+
return meshId ? { type: 'mesh.account', meshId } : { type: 'mesh.none' }
|
|
2015
2038
|
} catch (error) {
|
|
2016
2039
|
return { type: 'boot-error', error }
|
|
2017
2040
|
}
|
|
@@ -2033,14 +2056,15 @@ export class ChatApp {
|
|
|
2033
2056
|
_bootstrap() {
|
|
2034
2057
|
return async () => {
|
|
2035
2058
|
try {
|
|
2036
|
-
|
|
2059
|
+
// a chat names a workspace now, so the first agent and chat are minted in one as in the account
|
|
2060
|
+
const { account, workspace } = await firstWritable(this.engine, this.meshId)
|
|
2037
2061
|
// the pick the last session persisted; null on a fake engine that has no config
|
|
2038
2062
|
const config = this.engine.getConfig ? await this.engine.getConfig({}) : null
|
|
2039
2063
|
let agent = await firstAgent(this.engine, this.meshId, {
|
|
2040
2064
|
deviceId: this.originDeviceId,
|
|
2041
2065
|
modelName: this._modelName,
|
|
2042
2066
|
remembered: config?.activeAgentId,
|
|
2043
|
-
account
|
|
2067
|
+
account: account || workspace
|
|
2044
2068
|
})
|
|
2045
2069
|
if (!agent) {
|
|
2046
2070
|
return { type: 'booted', agent: null, chat: null, remembered: false }
|
|
@@ -2060,7 +2084,7 @@ export class ChatApp {
|
|
|
2060
2084
|
const chat = await firstChat(this.engine, this.meshId, {
|
|
2061
2085
|
agent,
|
|
2062
2086
|
remembered: config?.activeChatId,
|
|
2063
|
-
account
|
|
2087
|
+
account: account || workspace
|
|
2064
2088
|
})
|
|
2065
2089
|
if (!chat) {
|
|
2066
2090
|
return { type: 'booted', agent, chat: null, remembered: false }
|
|
@@ -3100,7 +3124,7 @@ export class ChatApp {
|
|
|
3100
3124
|
modelName:
|
|
3101
3125
|
agent?.modelName ??
|
|
3102
3126
|
this._modelName ??
|
|
3103
|
-
(await recommendedModel(engine, this.
|
|
3127
|
+
(await recommendedModel(engine, this.originDeviceId))
|
|
3104
3128
|
}
|
|
3105
3129
|
})
|
|
3106
3130
|
await this._handChatTo(created)
|
|
@@ -3705,7 +3729,7 @@ export class ChatApp {
|
|
|
3705
3729
|
|
|
3706
3730
|
if (action === 'new') {
|
|
3707
3731
|
return run(async () => {
|
|
3708
|
-
const { meshId } = await engine.
|
|
3732
|
+
const { meshId } = await engine.createWorkspace({ config: { name: 'Workspace' } })
|
|
3709
3733
|
const invite = '/invite member <n|id> invites someone into it'
|
|
3710
3734
|
return `${await this._meshHeading(meshId)}\n${invite}`
|
|
3711
3735
|
})
|
|
@@ -6888,6 +6912,14 @@ export class ChatApp {
|
|
|
6888
6912
|
return [this, this._enterMesh()]
|
|
6889
6913
|
}
|
|
6890
6914
|
|
|
6915
|
+
if (msg.type === 'mesh.none') {
|
|
6916
|
+
this._booting = false
|
|
6917
|
+
this.status = ''
|
|
6918
|
+
this.notice = NO_WORKSPACE
|
|
6919
|
+
this._render()
|
|
6920
|
+
return [this, null]
|
|
6921
|
+
}
|
|
6922
|
+
|
|
6891
6923
|
if (msg.type === 'meshes') {
|
|
6892
6924
|
const ids = new Set(msg.meshes.map((mesh) => mesh.meshId))
|
|
6893
6925
|
// a mesh transition in flight moves the window itself
|
|
@@ -6895,13 +6927,16 @@ export class ChatApp {
|
|
|
6895
6927
|
// only the startup frame: a later closed mesh was closed on purpose
|
|
6896
6928
|
const first = this._meshIds === null
|
|
6897
6929
|
this._meshIds = ids
|
|
6930
|
+
// a window in no workspace opens the first one created or joined
|
|
6931
|
+
const arrived = !this.meshId && !this._booting && msg.meshes.some((mesh) => mesh.workspace)
|
|
6898
6932
|
|
|
6899
6933
|
return [
|
|
6900
6934
|
this,
|
|
6901
6935
|
batch(
|
|
6902
6936
|
this._watchNextMeshes(),
|
|
6903
6937
|
lost ? this._lostMesh(this.meshId) : null,
|
|
6904
|
-
first ? this._reopenMeshes(msg.meshes) : null
|
|
6938
|
+
first ? this._reopenMeshes(msg.meshes) : null,
|
|
6939
|
+
arrived ? this._enterMesh() : null
|
|
6905
6940
|
)
|
|
6906
6941
|
]
|
|
6907
6942
|
}
|