@qvac/core 1.0.0-rc.2 → 1.0.0-rc.5
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 +238 -12
- package/dist-lib/index.d.ts +3 -1
- package/dist-lib/index.js +1 -0
- package/dist-lib/lib/api/approval-rules.d.ts +1 -1
- package/dist-lib/lib/api/approval-rules.js +5 -1
- package/dist-lib/lib/api/chunk-delta.d.ts +7 -2
- package/dist-lib/lib/api/chunk-delta.js +89 -7
- package/dist-lib/lib/api/chunks.js +14 -8
- package/dist-lib/lib/api/config.d.ts +10 -3
- package/dist-lib/lib/api/config.js +51 -6
- package/dist-lib/lib/api/custom-models.js +3 -5
- package/dist-lib/lib/api/devices.js +3 -1
- package/dist-lib/lib/api/files.d.ts +1 -1
- package/dist-lib/lib/api/files.js +65 -8
- package/dist-lib/lib/api/index.d.ts +12 -2
- package/dist-lib/lib/api/index.js +6 -1
- package/dist-lib/lib/api/instrument.js +12 -4
- package/dist-lib/lib/api/members.js +7 -13
- package/dist-lib/lib/api/mesh.d.ts +1 -3
- package/dist-lib/lib/api/mesh.js +2 -2
- package/dist-lib/lib/api/notifications.js +8 -4
- package/dist-lib/lib/api/projects.js +5 -1
- package/dist-lib/lib/api/rag.js +32 -19
- package/dist-lib/lib/api/served.js +2 -1
- package/dist-lib/lib/api/workspace.js +0 -1
- package/dist-lib/lib/assistant/harness.d.ts +8 -2
- package/dist-lib/lib/assistant/harness.js +17 -4
- package/dist-lib/lib/assistant/history.d.ts +1 -1
- package/dist-lib/lib/assistant/history.js +19 -13
- package/dist-lib/lib/assistant/message.d.ts +6 -1
- package/dist-lib/lib/assistant/message.js +22 -2
- package/dist-lib/lib/assistant/model-round.d.ts +5 -0
- package/dist-lib/lib/assistant/model-round.js +47 -19
- package/dist-lib/lib/assistant/pdf-budget.d.ts +10 -2
- package/dist-lib/lib/assistant/pdf-budget.js +10 -11
- package/dist-lib/lib/assistant/pdf-pages.d.ts +25 -0
- package/dist-lib/lib/assistant/pdf-pages.js +75 -0
- package/dist-lib/lib/assistant/round-host.js +5 -3
- package/dist-lib/lib/assistant-client.d.ts +2 -1
- package/dist-lib/lib/assistant-client.js +24 -6
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +8 -5
- package/dist-lib/lib/assistant.d.ts +21 -7
- package/dist-lib/lib/assistant.js +481 -244
- package/dist-lib/lib/client.js +10 -1
- package/dist-lib/lib/compaction.d.ts +3 -1
- package/dist-lib/lib/compaction.js +18 -4
- package/dist-lib/lib/constants.d.ts +3 -0
- package/dist-lib/lib/constants.js +3 -0
- package/dist-lib/lib/core/agent-copies.js +7 -1
- package/dist-lib/lib/core/agent.js +1 -0
- package/dist-lib/lib/core/approval-rules.d.ts +5 -1
- package/dist-lib/lib/core/approval-rules.js +16 -1
- package/dist-lib/lib/core/chat-activity.js +13 -16
- package/dist-lib/lib/core/chat-copy.js +1 -1
- package/dist-lib/lib/core/chat-fork.js +2 -1
- package/dist-lib/lib/core/chat-move.d.ts +4 -0
- package/dist-lib/lib/core/chat-move.js +42 -11
- package/dist-lib/lib/core/chat.d.ts +0 -1
- package/dist-lib/lib/core/chat.js +1 -1
- package/dist-lib/lib/core/chunk.d.ts +14 -3
- package/dist-lib/lib/core/chunk.js +116 -25
- package/dist-lib/lib/core/collections.d.ts +12 -1
- package/dist-lib/lib/core/collections.js +12 -1
- package/dist-lib/lib/core/config-value.d.ts +7 -0
- package/dist-lib/lib/core/config-value.js +15 -0
- package/dist-lib/lib/core/contract/activity.d.ts +3 -2
- package/dist-lib/lib/core/contract/activity.js +39 -21
- package/dist-lib/lib/core/contract/agent-join.js +15 -19
- package/dist-lib/lib/core/contract/agents.js +8 -7
- package/dist-lib/lib/core/contract/chat.d.ts +3 -0
- package/dist-lib/lib/core/contract/chat.js +12 -1
- package/dist-lib/lib/core/contract/chunks.js +16 -6
- package/dist-lib/lib/core/contract/devices.js +6 -4
- package/dist-lib/lib/core/contract/index.js +2 -1
- package/dist-lib/lib/core/contract/invites.js +12 -31
- package/dist-lib/lib/core/contract/joined-meshes.js +2 -1
- package/dist-lib/lib/core/contract/mesh-rules.js +4 -0
- package/dist-lib/lib/core/contract/model-requests.js +7 -6
- package/dist-lib/lib/core/contract/project-device-keys.js +15 -6
- package/dist-lib/lib/core/contract/project-host-keys.js +5 -4
- package/dist-lib/lib/core/contract/projects.js +12 -13
- package/dist-lib/lib/core/contract/public-seeds.js +5 -5
- package/dist-lib/lib/core/contract/roles.js +2 -1
- package/dist-lib/lib/core/contract/run-requests.d.ts +1 -1
- package/dist-lib/lib/core/contract/run-requests.js +19 -13
- package/dist-lib/lib/core/contract/shipped-rows.d.ts +2 -0
- package/dist-lib/lib/core/contract/shipped-rows.js +22 -0
- package/dist-lib/lib/core/contract/workspace.js +6 -12
- package/dist-lib/lib/core/contract/writers.js +20 -6
- package/dist-lib/lib/core/deleted-agent-runs.d.ts +7 -0
- package/dist-lib/lib/core/deleted-agent-runs.js +46 -0
- package/dist-lib/lib/core/devices.d.ts +2 -1
- package/dist-lib/lib/core/devices.js +4 -2
- package/dist-lib/lib/core/document-attachment.d.ts +6 -3
- package/dist-lib/lib/core/document-attachment.js +10 -5
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +8 -5
- package/dist-lib/lib/core/files/index.js +111 -18
- package/dist-lib/lib/core/files/processing/index.d.ts +1 -1
- package/dist-lib/lib/core/files/processing/index.js +8 -2
- package/dist-lib/lib/core/files/processing/source.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/source.js +3 -0
- package/dist-lib/lib/core/files/processing/state.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/state.js +7 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/build.js +14 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.js +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +7 -1
- package/dist-lib/lib/core/first-event.d.ts +6 -0
- package/dist-lib/lib/core/first-event.js +13 -0
- package/dist-lib/lib/core/invite.d.ts +2 -2
- package/dist-lib/lib/core/invite.js +5 -4
- package/dist-lib/lib/core/local/index.d.ts +16 -1
- package/dist-lib/lib/core/local/index.js +119 -10
- package/dist-lib/lib/core/mesh.d.ts +14 -3
- package/dist-lib/lib/core/mesh.js +127 -54
- package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
- package/dist-lib/lib/core/migrations/chat-chunks.js +47 -0
- package/dist-lib/lib/core/migrations/file-index.d.ts +1 -1
- package/dist-lib/lib/core/migrations/file-index.js +6 -2
- package/dist-lib/lib/core/migrations/index.d.ts +2 -1
- package/dist-lib/lib/core/migrations/index.js +66 -9
- package/dist-lib/lib/core/notification.js +96 -23
- package/dist-lib/lib/core/pdf/figure.d.ts +22 -0
- package/dist-lib/lib/core/pdf/figure.js +64 -0
- package/dist-lib/lib/core/pdf/rasterize.d.ts +10 -1
- package/dist-lib/lib/core/pdf/rasterize.js +72 -22
- package/dist-lib/lib/core/peer-duplex.js +57 -5
- package/dist-lib/lib/core/public-mesh.js +8 -2
- package/dist-lib/lib/core/run-requests.js +2 -3
- package/dist-lib/lib/core/senders.d.ts +7 -6
- package/dist-lib/lib/core/senders.js +23 -30
- package/dist-lib/lib/core/shared-agents.d.ts +1 -0
- package/dist-lib/lib/core/shared-agents.js +47 -19
- package/dist-lib/lib/core/skill-secrets.d.ts +3 -2
- package/dist-lib/lib/core/skill-secrets.js +4 -1
- package/dist-lib/lib/core/sync/background.d.ts +3 -15
- package/dist-lib/lib/core/sync/background.js +25 -102
- package/dist-lib/lib/core/sync/devices.js +6 -3
- package/dist-lib/lib/core/sync/index.js +25 -3
- package/dist-lib/lib/core/sync-status.js +3 -3
- package/dist-lib/lib/core/vault-managed-skills.d.ts +18 -0
- package/dist-lib/lib/core/vault-managed-skills.js +105 -0
- package/dist-lib/lib/core.d.ts +66 -10
- package/dist-lib/lib/core.js +768 -179
- package/dist-lib/lib/credential-pusher.d.ts +11 -7
- package/dist-lib/lib/credential-pusher.js +40 -8
- package/dist-lib/lib/device-tree.d.ts +18 -0
- package/dist-lib/lib/device-tree.js +32 -0
- package/dist-lib/lib/doctor/redact.js +1 -1
- package/dist-lib/lib/errors.d.ts +12 -0
- package/dist-lib/lib/errors.js +12 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +7 -0
- package/dist-lib/lib/fs-drive-bridge.js +308 -30
- package/dist-lib/lib/integrations/setup-routes.js +7 -5
- package/dist-lib/lib/knowledge-search.d.ts +1 -1
- package/dist-lib/lib/knowledge-search.js +5 -46
- package/dist-lib/lib/kv-cache-retention.d.ts +35 -0
- package/dist-lib/lib/kv-cache-retention.js +98 -0
- package/dist-lib/lib/latest-frame.d.ts +10 -0
- package/dist-lib/lib/latest-frame.js +48 -0
- package/dist-lib/lib/mesh-scoped-engine.js +1 -0
- package/dist-lib/lib/model-download.d.ts +6 -1
- package/dist-lib/lib/model-download.js +32 -17
- package/dist-lib/lib/oauth/resolve.js +13 -5
- package/dist-lib/lib/reconnecting-watch.js +19 -11
- package/dist-lib/lib/run-notices.d.ts +2 -0
- package/dist-lib/lib/run-notices.js +5 -0
- package/dist-lib/lib/run-replay.d.ts +13 -1
- package/dist-lib/lib/run-replay.js +58 -21
- package/dist-lib/schema/build.js +66 -57
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/content.js +2 -1
- package/dist-lib/schema/engine.js +70 -6
- package/dist-lib/schema/field-order.js +7 -1
- package/dist-lib/schema/indexes.d.ts +4 -0
- package/dist-lib/schema/indexes.js +18 -0
- package/dist-lib/schema/local.js +9 -2
- package/dist-lib/schema/qvac.js +116 -6
- package/dist-lib/spec/bind.js +15 -0
- package/dist-lib/spec/calls.js +5 -0
- package/dist-lib/spec/capabilities.d.ts +10 -0
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +65 -0
- package/dist-lib/spec/hrpc/index.js +63 -3
- package/dist-lib/spec/hrpc/messages.js +1537 -1395
- package/dist-lib/spec/hyperschema/index.js +1537 -1395
- package/dist-lib/spec/hyperschema/schema.json +126 -1
- package/dist-lib/spec/hyperschema/types.d.ts +33 -1
- package/dist-lib/spec/local/hyperdb/messages.js +110 -54
- package/dist-lib/spec/local/hyperschema/index.js +56 -28
- package/dist-lib/spec/local/hyperschema/schema.json +55 -20
- package/dist-lib/spec/local/hyperschema/types.d.ts +8 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +255 -51
- package/dist-lib/spec/mesh/hyperdb/index.js +1063 -404
- package/dist-lib/spec/mesh/hyperdb/messages.js +1673 -1202
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +62 -56
- package/dist-lib/spec/mesh/hyperdispatch/index.js +156 -139
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +809 -632
- package/dist-lib/spec/mesh/hyperschema/index.js +809 -632
- package/dist-lib/spec/mesh/hyperschema/schema.json +293 -174
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +31 -1
- package/package.json +32 -26
- package/worker/assistant-sidecar.mjs +3 -0
- package/dist-lib/lib/core/files/processing/settle.d.ts +0 -13
- package/dist-lib/lib/core/files/processing/settle.js +0 -86
- package/dist-lib/lib/core/migrations/device-indexes.d.ts +0 -2
- package/dist-lib/lib/core/migrations/device-indexes.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Harness } from './assistant.ts';
|
|
2
2
|
import { type ConfigEngine } from './oauth.ts';
|
|
3
|
-
import type { OAuthRouteLike } from './oauth/keys.ts';
|
|
3
|
+
import type { OAuthKeySpec, OAuthRouteLike } from './oauth/keys.ts';
|
|
4
4
|
export interface CredentialEntry {
|
|
5
5
|
key: string;
|
|
6
6
|
token?: string | null;
|
|
@@ -14,19 +14,21 @@ export interface SettingEntry {
|
|
|
14
14
|
value: string;
|
|
15
15
|
agentId?: string | null;
|
|
16
16
|
}
|
|
17
|
+
type PusherRoute = OAuthRouteLike & {
|
|
18
|
+
fields?: ReadonlyArray<{
|
|
19
|
+
key: string;
|
|
20
|
+
secret?: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
17
23
|
export interface PusherSkill {
|
|
18
24
|
name: string;
|
|
25
|
+
origin?: string;
|
|
19
26
|
credentials?: readonly string[];
|
|
20
27
|
requires?: {
|
|
21
28
|
credentials?: readonly string[];
|
|
22
29
|
};
|
|
23
30
|
setup?: {
|
|
24
|
-
routes?: ReadonlyArray<
|
|
25
|
-
fields?: ReadonlyArray<{
|
|
26
|
-
key: string;
|
|
27
|
-
secret?: boolean;
|
|
28
|
-
}>;
|
|
29
|
-
}>;
|
|
31
|
+
routes?: ReadonlyArray<PusherRoute>;
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
export interface CredentialEngine extends ConfigEngine {
|
|
@@ -67,6 +69,8 @@ export type CredentialPusherHandle = (() => Promise<void>) & {
|
|
|
67
69
|
};
|
|
68
70
|
export declare function nextRefreshDelay(entries: ReadonlyArray<Pick<CredentialEntry, 'expiresAt'>>, now?: number): number;
|
|
69
71
|
export declare function credentialOwners(catalog: ReadonlyArray<PusherSkill>): ReadonlyMap<string, readonly string[]>;
|
|
72
|
+
export declare function plainCredentialKeys(catalog: ReadonlyArray<PusherSkill>, specs: ReadonlyArray<OAuthKeySpec>): ReadonlyArray<string>;
|
|
70
73
|
export declare function settingFields(catalog: ReadonlyArray<PusherSkill>): ReadonlyArray<Pick<SettingEntry, 'skill' | 'key'>>;
|
|
71
74
|
export declare function settingConfigKey(agentId: string | undefined, skill: string, key: string): string;
|
|
72
75
|
export declare function startCredentialPusher(harness: CredentialTarget, engine: CredentialEngine, logger?: CredentialPusherLogger | null): CredentialPusherHandle;
|
|
76
|
+
export {};
|
|
@@ -8,6 +8,7 @@ import ScopeLock from 'scope-lock';
|
|
|
8
8
|
import { credentialSlots } from '@qvac/harness/skill-manifest';
|
|
9
9
|
import { errorMessage } from './guards.js';
|
|
10
10
|
const PLAIN_KEYS = ['github_access_token', OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY];
|
|
11
|
+
const PLAIN_KEY = /^[A-Za-z0-9_-]+$/;
|
|
11
12
|
const REFRESH_INTERVAL = 10 * 60 * 1000;
|
|
12
13
|
const MIN_REFRESH_DELAY = 30_000;
|
|
13
14
|
function storeKey(key, agentId) {
|
|
@@ -69,7 +70,7 @@ async function plainEntry(engine, key, agentId) {
|
|
|
69
70
|
}
|
|
70
71
|
export function credentialOwners(catalog) {
|
|
71
72
|
const owners = new Map();
|
|
72
|
-
for (const skill of catalog) {
|
|
73
|
+
for (const skill of trusted(catalog)) {
|
|
73
74
|
for (const key of credentialSlots(skill).flat()) {
|
|
74
75
|
const list = owners.get(key) ?? [];
|
|
75
76
|
if (!list.includes(skill.name)) {
|
|
@@ -80,6 +81,37 @@ export function credentialOwners(catalog) {
|
|
|
80
81
|
}
|
|
81
82
|
return owners;
|
|
82
83
|
}
|
|
84
|
+
function trusted(catalog) {
|
|
85
|
+
return catalog.filter((skill) => skill.origin !== 'overlay');
|
|
86
|
+
}
|
|
87
|
+
export function plainCredentialKeys(catalog, specs) {
|
|
88
|
+
const oauth = new Set(specs.map((spec) => spec.credentialKey));
|
|
89
|
+
const reserved = new Set();
|
|
90
|
+
const declared = new Set(PLAIN_KEYS);
|
|
91
|
+
for (const skill of trusted(catalog)) {
|
|
92
|
+
for (const key of credentialSlots(skill).flat()) {
|
|
93
|
+
declared.add(key);
|
|
94
|
+
}
|
|
95
|
+
for (const route of skill.setup?.routes ?? []) {
|
|
96
|
+
routeKeys(route, route.oauth ? reserved : declared);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const allowed = (key) => PLAIN_KEYS.includes(key) || (!reserved.has(key) && PLAIN_KEY.test(key));
|
|
100
|
+
return [...declared].filter((key) => !oauth.has(key) && allowed(key));
|
|
101
|
+
}
|
|
102
|
+
function routeKeys(route, into) {
|
|
103
|
+
if (route.oauth?.stateKey) {
|
|
104
|
+
into.add(route.oauth.stateKey);
|
|
105
|
+
}
|
|
106
|
+
if (route.credentialKey && !route.oauth) {
|
|
107
|
+
into.add(route.credentialKey);
|
|
108
|
+
}
|
|
109
|
+
for (const field of route.fields ?? []) {
|
|
110
|
+
if (route.oauth || field.secret === true) {
|
|
111
|
+
into.add(field.key);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
83
115
|
export function settingFields(catalog) {
|
|
84
116
|
const fields = [];
|
|
85
117
|
for (const skill of catalog) {
|
|
@@ -118,15 +150,14 @@ async function resolveEntry({ mk, failure, read }, { last, owners, logger }) {
|
|
|
118
150
|
}
|
|
119
151
|
}
|
|
120
152
|
async function resolveScope(agentId, resolution) {
|
|
121
|
-
const { engine, specs } = resolution;
|
|
122
|
-
const specKeys = new Set(specs.map((spec) => spec.credentialKey));
|
|
153
|
+
const { engine, specs, plainKeys } = resolution;
|
|
123
154
|
const pending = [
|
|
124
155
|
...specs.map((spec) => ({
|
|
125
156
|
mk: storeKey(spec.credentialKey, agentId),
|
|
126
157
|
failure: `credential resolve failed for ${spec.credentialKey}`,
|
|
127
158
|
read: () => oauthEntry(engine, spec, agentId)
|
|
128
159
|
})),
|
|
129
|
-
...
|
|
160
|
+
...plainKeys.map((key) => ({
|
|
130
161
|
mk: storeKey(key, agentId),
|
|
131
162
|
failure: `credential read failed for ${key}`,
|
|
132
163
|
read: () => plainEntry(engine, key, agentId)
|
|
@@ -192,10 +223,10 @@ export function startCredentialPusher(harness, engine, logger) {
|
|
|
192
223
|
logger?.warn('credential-pusher', `credential watch ended for ${key}`, errorMessage(err));
|
|
193
224
|
});
|
|
194
225
|
};
|
|
195
|
-
const syncWatches = (
|
|
226
|
+
const syncWatches = (pushedKeys, scopes) => {
|
|
196
227
|
if (disposed)
|
|
197
228
|
return;
|
|
198
|
-
const keys = new Set(
|
|
229
|
+
const keys = new Set(pushedKeys);
|
|
199
230
|
const wanted = new Set(scopes.flatMap((agentId) => [...keys].map((key) => scopedKey(agentId, key))));
|
|
200
231
|
for (const [key, stream] of watches) {
|
|
201
232
|
if (wanted.has(key))
|
|
@@ -272,10 +303,11 @@ export function startCredentialPusher(harness, engine, logger) {
|
|
|
272
303
|
}
|
|
273
304
|
const owners = credentialOwners(skills);
|
|
274
305
|
const specs = oauthSpecs(skills);
|
|
306
|
+
const plainKeys = plainCredentialKeys(skills, specs);
|
|
275
307
|
const { meshId, scopes } = await accountScopes(engine);
|
|
276
|
-
syncWatches(specs.map((spec) => spec.credentialKey), scopes);
|
|
308
|
+
syncWatches([...specs.map((spec) => spec.credentialKey), ...plainKeys], scopes);
|
|
277
309
|
syncAgentsWatch(meshId);
|
|
278
|
-
const resolution = { engine, last, owners, specs, logger };
|
|
310
|
+
const resolution = { engine, last, owners, specs, plainKeys, logger };
|
|
279
311
|
const resolved = await Promise.all(scopes.map((agentId) => resolveScope(agentId, resolution)));
|
|
280
312
|
entries.push(...resolved.flat());
|
|
281
313
|
if (disposed) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Supervisor from 'bare-supervisor';
|
|
2
|
+
import type { Transport } from '@qvac/harness/rpc';
|
|
3
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
4
|
+
import { type AssistantChildOptions } from './assistant-tree.ts';
|
|
5
|
+
import { Core, type CoreOptions } from './core.ts';
|
|
6
|
+
export interface DeviceTreeOptions {
|
|
7
|
+
core: Omit<CoreOptions, 'apiLifecycle'>;
|
|
8
|
+
assistant: Omit<AssistantChildOptions, 'core'>;
|
|
9
|
+
office?: {
|
|
10
|
+
close: () => unknown;
|
|
11
|
+
};
|
|
12
|
+
logger?: LoggerInterface | null;
|
|
13
|
+
}
|
|
14
|
+
export interface DeviceTree {
|
|
15
|
+
supervisor: Supervisor;
|
|
16
|
+
core: Core;
|
|
17
|
+
}
|
|
18
|
+
export declare function deviceTree(transport: Transport, opts: DeviceTreeOptions): DeviceTree;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Supervisor from 'bare-supervisor';
|
|
2
|
+
import { assistantChild } from './assistant-tree.js';
|
|
3
|
+
import { Core } from './core.js';
|
|
4
|
+
export function deviceTree(transport, opts) {
|
|
5
|
+
const { office, logger = null } = opts;
|
|
6
|
+
const supervisor = new Supervisor();
|
|
7
|
+
const core = new Core(transport, {
|
|
8
|
+
...opts.core,
|
|
9
|
+
apiLifecycle: {
|
|
10
|
+
suspend: () => supervisor.suspend(),
|
|
11
|
+
resume: () => supervisor.resume()
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (office) {
|
|
15
|
+
supervisor.add('office', { start: () => office });
|
|
16
|
+
}
|
|
17
|
+
supervisor.add('core', {
|
|
18
|
+
deps: office ? ['office'] : [],
|
|
19
|
+
start: () => core,
|
|
20
|
+
presuspend: (handle) => handle.presuspend(),
|
|
21
|
+
suspend: (handle) => handle.suspend(),
|
|
22
|
+
wakeup: (handle) => handle.wakeup(),
|
|
23
|
+
resume: (handle) => handle.resume()
|
|
24
|
+
});
|
|
25
|
+
supervisor.add('assistant', assistantChild({ logger, ...opts.assistant }));
|
|
26
|
+
for (const event of ['child-died', 'child-restarting', 'stall']) {
|
|
27
|
+
supervisor.on(event, (payload) => logger?.warn('device-tree', event, { ...payload, error: payload.error?.message }));
|
|
28
|
+
}
|
|
29
|
+
supervisor.on('gave-up', ({ name, error }) => logger?.error('device-tree', `${name} gave up`, error?.message));
|
|
30
|
+
supervisor.on('power', (payload) => logger?.info('device-tree', 'power', payload));
|
|
31
|
+
return { supervisor, core };
|
|
32
|
+
}
|
|
@@ -25,7 +25,7 @@ export function redact(value) {
|
|
|
25
25
|
}
|
|
26
26
|
const out = {};
|
|
27
27
|
for (const [key, child] of Object.entries(value)) {
|
|
28
|
-
out[key] = REDACTED_KEYS.has(key) ? REDACTED : redact(child);
|
|
28
|
+
out[redactString(key)] = REDACTED_KEYS.has(key) ? REDACTED : redact(child);
|
|
29
29
|
}
|
|
30
30
|
return out;
|
|
31
31
|
}
|
package/dist-lib/lib/errors.d.ts
CHANGED
|
@@ -383,6 +383,10 @@ declare const DEFINITIONS: {
|
|
|
383
383
|
readonly code: 100625;
|
|
384
384
|
readonly message: () => string;
|
|
385
385
|
};
|
|
386
|
+
readonly SKILL_SECRET_NOT_VAULT_SAFE: {
|
|
387
|
+
readonly code: 100626;
|
|
388
|
+
readonly message: () => string;
|
|
389
|
+
};
|
|
386
390
|
readonly CHAT_NOT_FOUND: {
|
|
387
391
|
readonly code: 100701;
|
|
388
392
|
readonly message: (chatId: string) => string;
|
|
@@ -499,6 +503,10 @@ declare const DEFINITIONS: {
|
|
|
499
503
|
readonly code: 100730;
|
|
500
504
|
readonly message: (chunkId: string) => string;
|
|
501
505
|
};
|
|
506
|
+
readonly APPROVAL_RULE_NOT_FOUND: {
|
|
507
|
+
readonly code: 100731;
|
|
508
|
+
readonly message: (ruleId: string) => string;
|
|
509
|
+
};
|
|
502
510
|
readonly CHAT_MOVE_NOT_FOUND: {
|
|
503
511
|
readonly code: 100801;
|
|
504
512
|
readonly message: () => string;
|
|
@@ -751,6 +759,10 @@ declare const DEFINITIONS: {
|
|
|
751
759
|
readonly code: 101304;
|
|
752
760
|
readonly message: () => string;
|
|
753
761
|
};
|
|
762
|
+
readonly SIDECAR_BOOT_FAILED: {
|
|
763
|
+
readonly code: 101305;
|
|
764
|
+
readonly message: (reason: string) => string;
|
|
765
|
+
};
|
|
754
766
|
readonly RUN_LOG_NOT_ASSIGNED: {
|
|
755
767
|
readonly code: 101401;
|
|
756
768
|
readonly message: (runId: string) => string;
|
package/dist-lib/lib/errors.js
CHANGED
|
@@ -297,6 +297,10 @@ const DEFINITIONS = {
|
|
|
297
297
|
code: 100625,
|
|
298
298
|
message: () => "This chat's agent is no longer shared with you: pick another agent"
|
|
299
299
|
},
|
|
300
|
+
SKILL_SECRET_NOT_VAULT_SAFE: {
|
|
301
|
+
code: 100626,
|
|
302
|
+
message: () => 'Vault-managed skill state requires vault migration or reconnect'
|
|
303
|
+
},
|
|
300
304
|
CHAT_NOT_FOUND: {
|
|
301
305
|
code: 100701,
|
|
302
306
|
message: (chatId) => `chat not found: ${chatId}`
|
|
@@ -413,6 +417,10 @@ const DEFINITIONS = {
|
|
|
413
417
|
code: 100730,
|
|
414
418
|
message: (chunkId) => `run-request ${chunkId} is not open to take`
|
|
415
419
|
},
|
|
420
|
+
APPROVAL_RULE_NOT_FOUND: {
|
|
421
|
+
code: 100731,
|
|
422
|
+
message: (ruleId) => `no approval rule of yours: ${ruleId}`
|
|
423
|
+
},
|
|
416
424
|
CHAT_MOVE_NOT_FOUND: {
|
|
417
425
|
code: 100801,
|
|
418
426
|
message: () => 'no move of this chat is recorded on this device'
|
|
@@ -666,6 +674,10 @@ const DEFINITIONS = {
|
|
|
666
674
|
code: 101304,
|
|
667
675
|
message: () => 'assistant is closing'
|
|
668
676
|
},
|
|
677
|
+
SIDECAR_BOOT_FAILED: {
|
|
678
|
+
code: 101305,
|
|
679
|
+
message: (reason) => `the sidecar failed to start: ${reason}`
|
|
680
|
+
},
|
|
669
681
|
RUN_LOG_NOT_ASSIGNED: {
|
|
670
682
|
code: 101401,
|
|
671
683
|
message: (runId) => `run ${runId} is not one this device runs`
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { type AbortSignal } from 'bare-abort-controller';
|
|
1
2
|
import type { DriveOpFn, GrantedDrive } from '@qvac/harness';
|
|
2
3
|
import type { AcquiredDrive, DriveHost } from './core/fs-drives.ts';
|
|
3
4
|
import type { FsGrant } from './fs-grants.ts';
|
|
4
5
|
export declare const DRIVE_OP_TIMEOUT_MS = 15000;
|
|
5
6
|
export declare function sweepDriveStaging(now?: number): Promise<void>;
|
|
7
|
+
interface PipeCappedOptions {
|
|
8
|
+
readonly cap: number;
|
|
9
|
+
readonly signal: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export declare function pipeCapped(source: AsyncIterable<Uint8Array>, target: string, { cap, signal }: PipeCappedOptions): Promise<boolean>;
|
|
6
12
|
export declare function createDriveOp(drives: ReadonlyMap<string, AcquiredDrive>): DriveOpFn;
|
|
7
13
|
export interface ResolvedFsGrants {
|
|
8
14
|
readonly grantedDirs: string[];
|
|
@@ -10,3 +16,4 @@ export interface ResolvedFsGrants {
|
|
|
10
16
|
readonly driveOp?: DriveOpFn;
|
|
11
17
|
}
|
|
12
18
|
export declare function resolveFsGrants(grants: readonly FsGrant[], driveHost: DriveHost | undefined, onDropped?: (key: string, err: unknown) => void): Promise<ResolvedFsGrants>;
|
|
19
|
+
export {};
|