@corenel/tools-web 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/protocol.d.ts +144 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +2 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/idb.d.ts +12 -0
- package/dist/idb.d.ts.map +1 -0
- package/dist/idb.js +100 -0
- package/dist/idb.js.map +1 -0
- package/dist/memory/index.d.ts +11 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +21 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/local.d.ts +16 -0
- package/dist/memory/local.d.ts.map +1 -0
- package/dist/memory/local.js +51 -0
- package/dist/memory/local.js.map +1 -0
- package/dist/memory/prompdApi.d.ts +20 -0
- package/dist/memory/prompdApi.d.ts.map +1 -0
- package/dist/memory/prompdApi.js +68 -0
- package/dist/memory/prompdApi.js.map +1 -0
- package/dist/prompts/history.d.ts +27 -0
- package/dist/prompts/history.d.ts.map +1 -0
- package/dist/prompts/history.js +82 -0
- package/dist/prompts/history.js.map +1 -0
- package/dist/sessions/store.d.ts +10 -0
- package/dist/sessions/store.d.ts.map +1 -0
- package/dist/sessions/store.js +37 -0
- package/dist/sessions/store.js.map +1 -0
- package/dist/storageHealth.d.ts +16 -0
- package/dist/storageHealth.d.ts.map +1 -0
- package/dist/storageHealth.js +64 -0
- package/dist/storageHealth.js.map +1 -0
- package/dist/tools/result-store.d.ts +20 -0
- package/dist/tools/result-store.d.ts.map +1 -0
- package/dist/tools/result-store.js +52 -0
- package/dist/tools/result-store.js.map +1 -0
- package/dist/workerClient.d.ts +81 -0
- package/dist/workerClient.d.ts.map +1 -0
- package/dist/workerClient.js +192 -0
- package/dist/workerClient.js.map +1 -0
- package/dist/workerHandler.d.ts +6 -0
- package/dist/workerHandler.d.ts.map +1 -0
- package/dist/workerHandler.js +442 -0
- package/dist/workerHandler.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ISessionStore, AgentSession, SessionSurface } from '@corenel/protocol';
|
|
2
|
+
export declare class LocalSessionStore implements ISessionStore {
|
|
3
|
+
create(title: string, surface?: SessionSurface): Promise<AgentSession>;
|
|
4
|
+
get(id: string): Promise<AgentSession | null>;
|
|
5
|
+
list(surface?: SessionSurface): Promise<AgentSession[]>;
|
|
6
|
+
save(session: AgentSession): Promise<void>;
|
|
7
|
+
rename(id: string, title: string): Promise<void>;
|
|
8
|
+
delete(id: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../sessions/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOhF,qBAAa,iBAAkB,YAAW,aAAa;IAC/C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAMtE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAG7C,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAMvD,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { idbGet, idbGetAll, idbPut, idbDelete } from '../idb';
|
|
2
|
+
function uid(prefix) {
|
|
3
|
+
return `${prefix}_${Date.now().toString(36)}${Math.floor(Math.random() * 1e6).toString(36)}`;
|
|
4
|
+
}
|
|
5
|
+
export class LocalSessionStore {
|
|
6
|
+
async create(title, surface) {
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
const session = { id: uid('ses'), title, createdAt: now, updatedAt: now, messages: [], ...(surface ? { surface } : {}) };
|
|
9
|
+
await idbPut('sessions', session.id, session);
|
|
10
|
+
return session;
|
|
11
|
+
}
|
|
12
|
+
async get(id) {
|
|
13
|
+
return (await idbGet('sessions', id)) ?? null;
|
|
14
|
+
}
|
|
15
|
+
async list(surface) {
|
|
16
|
+
const all = await idbGetAll('sessions');
|
|
17
|
+
// Untagged legacy sessions belong to the standalone agent page.
|
|
18
|
+
const scoped = surface ? all.filter((s) => s.surface === surface || (surface === 'agent' && !s.surface)) : all;
|
|
19
|
+
return scoped.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
20
|
+
}
|
|
21
|
+
async save(session) {
|
|
22
|
+
session.updatedAt = Date.now();
|
|
23
|
+
await idbPut('sessions', session.id, session);
|
|
24
|
+
}
|
|
25
|
+
async rename(id, title) {
|
|
26
|
+
const s = await this.get(id);
|
|
27
|
+
if (!s)
|
|
28
|
+
return;
|
|
29
|
+
s.title = title;
|
|
30
|
+
s.titleLocked = true;
|
|
31
|
+
await this.save(s);
|
|
32
|
+
}
|
|
33
|
+
async delete(id) {
|
|
34
|
+
await idbDelete('sessions', id);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../sessions/store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9D,SAAS,GAAG,CAAC,MAAc;IACzB,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,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S,CAAC,CAAC;IAC1D,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAqB;QAC9B,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,KAAa;QACpC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,CAAC;YAAE,OAAO;QACf,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;QAChB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Listener = (full: boolean) => void;
|
|
2
|
+
export declare function isStorageFull(): boolean;
|
|
3
|
+
/** True for the DOMException names browsers throw when a write can't be persisted:
|
|
4
|
+
* quota exhausted, or (Chrome) an UnknownError wrapping a disk-space failure. */
|
|
5
|
+
export declare function isStorageFullError(e: unknown): boolean;
|
|
6
|
+
/** Mark storage degraded (notifies only on the transition into the full state). */
|
|
7
|
+
export declare function reportStorageFull(): void;
|
|
8
|
+
/** Clear the degraded flag after a write succeeds (e.g. once space is freed). */
|
|
9
|
+
export declare function reportStorageOk(): void;
|
|
10
|
+
export declare function onStorageHealth(cb: Listener): () => void;
|
|
11
|
+
/** localStorage.setItem that reports (not throws) when the write is refused.
|
|
12
|
+
* Returns true on success. Use for non-critical persisted UI state (layouts,
|
|
13
|
+
* settings) so a full disk doesn't throw mid-render. */
|
|
14
|
+
export declare function safeLocalStorageSet(key: string, value: string): boolean;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=storageHealth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storageHealth.d.ts","sourceRoot":"","sources":["../storageHealth.ts"],"names":[],"mappings":"AAUA,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;AAGxC,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;iFACiF;AACjF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAMtD;AAQD,mFAAmF;AACnF,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED,iFAAiF;AACjF,wBAAgB,eAAe,IAAI,IAAI,CAItC;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAGxD;AAED;;wDAEwD;AACxD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CASvE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* Storage health — a single signal for "the browser refused to persist a write"
|
|
2
|
+
* (origin quota exhausted, or the disk is full: Chrome surfaces the latter as an
|
|
3
|
+
* IndexedDB `UnknownError` wrapping FILE_ERROR_NO_SPACE).
|
|
4
|
+
*
|
|
5
|
+
* Write paths report through here and FAIL SOFT — the in-memory state still updates,
|
|
6
|
+
* the flow keeps working, it just isn't saved — so a full disk degrades the app
|
|
7
|
+
* instead of crashing a chat or silently dropping a layout. The UI subscribes to
|
|
8
|
+
* show one banner. Worker-safe: no window/DOM, just module state + listeners. */
|
|
9
|
+
let full = false;
|
|
10
|
+
const listeners = new Set();
|
|
11
|
+
export function isStorageFull() {
|
|
12
|
+
return full;
|
|
13
|
+
}
|
|
14
|
+
/** True for the DOMException names browsers throw when a write can't be persisted:
|
|
15
|
+
* quota exhausted, or (Chrome) an UnknownError wrapping a disk-space failure. */
|
|
16
|
+
export function isStorageFullError(e) {
|
|
17
|
+
const name = e?.name;
|
|
18
|
+
return name === 'QuotaExceededError'
|
|
19
|
+
|| name === 'UnknownError' // Chrome IndexedDB FILE_ERROR_NO_SPACE
|
|
20
|
+
|| name === 'NS_ERROR_DOM_QUOTA_REACHED' // Firefox
|
|
21
|
+
|| name === 'QUOTA_EXCEEDED_ERR'; // legacy
|
|
22
|
+
}
|
|
23
|
+
function emit() {
|
|
24
|
+
for (const cb of listeners) {
|
|
25
|
+
try {
|
|
26
|
+
cb(full);
|
|
27
|
+
}
|
|
28
|
+
catch { /* a listener must not break a write path */ }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Mark storage degraded (notifies only on the transition into the full state). */
|
|
32
|
+
export function reportStorageFull() {
|
|
33
|
+
if (full)
|
|
34
|
+
return;
|
|
35
|
+
full = true;
|
|
36
|
+
emit();
|
|
37
|
+
}
|
|
38
|
+
/** Clear the degraded flag after a write succeeds (e.g. once space is freed). */
|
|
39
|
+
export function reportStorageOk() {
|
|
40
|
+
if (!full)
|
|
41
|
+
return;
|
|
42
|
+
full = false;
|
|
43
|
+
emit();
|
|
44
|
+
}
|
|
45
|
+
export function onStorageHealth(cb) {
|
|
46
|
+
listeners.add(cb);
|
|
47
|
+
return () => { listeners.delete(cb); };
|
|
48
|
+
}
|
|
49
|
+
/** localStorage.setItem that reports (not throws) when the write is refused.
|
|
50
|
+
* Returns true on success. Use for non-critical persisted UI state (layouts,
|
|
51
|
+
* settings) so a full disk doesn't throw mid-render. */
|
|
52
|
+
export function safeLocalStorageSet(key, value) {
|
|
53
|
+
try {
|
|
54
|
+
localStorage.setItem(key, value);
|
|
55
|
+
reportStorageOk();
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (isStorageFullError(e))
|
|
60
|
+
reportStorageFull();
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=storageHealth.js.map
|
|
@@ -0,0 +1 @@
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,EAAE,KAAa;IAC5D,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjC,eAAe,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,kBAAkB,CAAC,CAAC,CAAC;YAAE,iBAAiB,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type OffloadRef } from '@corenel/harness/compression';
|
|
2
|
+
import type { IRecallStore } from '@corenel/protocol';
|
|
3
|
+
export interface RecallRecord {
|
|
4
|
+
id: string;
|
|
5
|
+
toolName: string;
|
|
6
|
+
bytes: number;
|
|
7
|
+
content: string;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
}
|
|
10
|
+
/** All offloaded records, newest first (for the Context Manager). */
|
|
11
|
+
export declare function listRecall(): Promise<RecallRecord[]>;
|
|
12
|
+
/** Drop all offloaded records (housekeeping). */
|
|
13
|
+
export declare function clearRecall(): Promise<void>;
|
|
14
|
+
export declare class IdbRecallStore implements IRecallStore {
|
|
15
|
+
private counter;
|
|
16
|
+
private readonly prefix;
|
|
17
|
+
record(toolName: string, content: unknown): Promise<OffloadRef>;
|
|
18
|
+
read(id: string): Promise<string | null>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=result-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-store.d.ts","sourceRoot":"","sources":["../../tools/result-store.ts"],"names":[],"mappings":"AAKA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,WAAW,YAAY;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAEjH,qEAAqE;AACrE,wBAAsB,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAG1D;AAED,iDAAiD;AACjD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAEjD;AAED,qBAAa,cAAe,YAAW,YAAY;IACjD,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IAE3D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAQ/D,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAI/C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* RecallStore — persists offloaded tool outputs so they're recoverable in full.
|
|
2
|
+
* IndexedDB-backed (worker-safe), the browser analog of Marshal's per-run
|
|
3
|
+
* result-store. Records are keyed by a unique id carried in the inline reference;
|
|
4
|
+
* `recall_result({ id })` reads them back. */
|
|
5
|
+
import { idbPut, idbGet, idbGetAll, idbClear } from '../idb';
|
|
6
|
+
import { PREVIEW_BYTES } from '@corenel/harness/compression';
|
|
7
|
+
const STORE = 'recall';
|
|
8
|
+
/** All offloaded records, newest first (for the Context Manager). */
|
|
9
|
+
export async function listRecall() {
|
|
10
|
+
const all = await idbGetAll(STORE);
|
|
11
|
+
return all.sort((a, b) => b.createdAt - a.createdAt);
|
|
12
|
+
}
|
|
13
|
+
/** Drop all offloaded records (housekeeping). */
|
|
14
|
+
export async function clearRecall() {
|
|
15
|
+
await idbClear(STORE);
|
|
16
|
+
}
|
|
17
|
+
export class IdbRecallStore {
|
|
18
|
+
constructor() {
|
|
19
|
+
Object.defineProperty(this, "counter", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: 0
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(this, "prefix", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
value: Math.random().toString(36).slice(2, 7)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async record(toolName, content) {
|
|
33
|
+
const text = typeof content === 'string' ? content : safe(content);
|
|
34
|
+
const id = `art-${this.prefix}-${++this.counter}`;
|
|
35
|
+
const rec = { id, toolName, bytes: text.length, content: text, createdAt: Date.now() };
|
|
36
|
+
await idbPut(STORE, id, rec);
|
|
37
|
+
return { id, toolName, bytes: text.length, preview: text.slice(0, PREVIEW_BYTES) };
|
|
38
|
+
}
|
|
39
|
+
async read(id) {
|
|
40
|
+
const rec = await idbGet(STORE, id);
|
|
41
|
+
return rec ? rec.content : null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function safe(v) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.stringify(v);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return String(v);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=result-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-store.js","sourceRoot":"","sources":["../../tools/result-store.ts"],"names":[],"mappings":"AAAA;;;8CAG8C;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAmB,MAAM,8BAA8B,CAAC;AAG9E,MAAM,KAAK,GAAc,QAAQ,CAAC;AAIlC,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAe,KAAK,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CA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IAAI,CAAC,CAAU;IACtB,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
2
|
+
import type { RunAgentResult } from '@corenel/harness/core/loop';
|
|
3
|
+
import type { RunNodeResult, NodeSpec } from '@corenel/harness/dag/executeNode';
|
|
4
|
+
import type { NodeOutput, NodeEvent } from '@corenel/protocol';
|
|
5
|
+
import type { AgentEvent, AskQuestion, AskAnswers, EditReviewOutcome } from '@corenel/protocol';
|
|
6
|
+
import type { Policy, PermissionCeiling } from '@corenel/harness/guardrail';
|
|
7
|
+
import type { CompressionConfig } from '@corenel/harness/compression';
|
|
8
|
+
import type { FileService } from '@corenel/protocol';
|
|
9
|
+
import type { ToolDecl } from '@corenel/protocol';
|
|
10
|
+
/** Options for runNode — like RunOpts but the node's internal turns arrive via
|
|
11
|
+
* onNodeEvent (the node-tagged stream); onEvent only ever sees a terminal error. */
|
|
12
|
+
export interface RunNodeOpts {
|
|
13
|
+
model?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
policy?: Policy;
|
|
16
|
+
ceiling?: PermissionCeiling;
|
|
17
|
+
compression?: CompressionConfig;
|
|
18
|
+
onNodeEvent?: (e: NodeEvent) => void;
|
|
19
|
+
onEvent?: (e: AgentEvent) => void;
|
|
20
|
+
onPermission?: (req: {
|
|
21
|
+
tool: string;
|
|
22
|
+
summary: string;
|
|
23
|
+
}) => Promise<boolean>;
|
|
24
|
+
onAsk?: (questions: AskQuestion[]) => Promise<AskAnswers | null>;
|
|
25
|
+
}
|
|
26
|
+
/** Options for a chat run (createAgent.run and WorkerAgent.run share this). The
|
|
27
|
+
* port type lives in the kernel — the app assembly (prompd/agent) imports it,
|
|
28
|
+
* never the other way. */
|
|
29
|
+
export interface RunOpts {
|
|
30
|
+
model?: string;
|
|
31
|
+
system?: string;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
/** Governance policy for the run. Defaults to STANDARD_POLICY (ask before writes). */
|
|
34
|
+
policy?: Policy;
|
|
35
|
+
/** Optional hard ceiling clamped onto every permission resolution. */
|
|
36
|
+
ceiling?: PermissionCeiling;
|
|
37
|
+
/** Context-compression config (rung-1 offload). */
|
|
38
|
+
compression?: CompressionConfig;
|
|
39
|
+
onEvent?: (e: AgentEvent) => void;
|
|
40
|
+
/** Node-tagged events from the run's sub-agents (the DAG canvas stream). */
|
|
41
|
+
onNodeEvent?: (e: NodeEvent) => void;
|
|
42
|
+
onPermission?: (req: {
|
|
43
|
+
tool: string;
|
|
44
|
+
summary: string;
|
|
45
|
+
}) => Promise<boolean>;
|
|
46
|
+
/** Resolve the agent's ask_user questions with the user's answers (null = dismissed). */
|
|
47
|
+
onAsk?: (questions: AskQuestion[]) => Promise<AskAnswers | null>;
|
|
48
|
+
/** Await the user's verdict on a propose_edit (null = run ended unreviewed). */
|
|
49
|
+
onEditReview?: (callId: string) => Promise<EditReviewOutcome | null>;
|
|
50
|
+
}
|
|
51
|
+
export interface WorkerAgent {
|
|
52
|
+
run(messages: ChatCompletionMessageParam[], opts?: RunOpts): Promise<RunAgentResult>;
|
|
53
|
+
/** Run ONE DAG node in the worker; streams node-tagged events via onNodeEvent. */
|
|
54
|
+
runNode(node: NodeSpec, inputs: Record<string, NodeOutput>, opts?: RunNodeOpts): Promise<RunNodeResult>;
|
|
55
|
+
dispose(): void;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkerAgentOpts {
|
|
58
|
+
/** Resolve the active file workspace, so the worker's file tools read/write it.
|
|
59
|
+
* A getter (not a value) so swapping the source — e.g. opening a folder — is
|
|
60
|
+
* picked up without recreating the worker. */
|
|
61
|
+
getFileService?: () => FileService | null;
|
|
62
|
+
/** Construct the worker. The host owns this so the kernel client carries no
|
|
63
|
+
* reference to the app's worker entry — the entry's `new URL('./worker.ts',
|
|
64
|
+
* import.meta.url)` must live in app space for the bundler to resolve it. */
|
|
65
|
+
createWorker: () => Worker;
|
|
66
|
+
/** Fetch the short-lived auth token the worker requests per call (the worker
|
|
67
|
+
* can't read the session). Defaults to unauthenticated. */
|
|
68
|
+
getToken?: () => Promise<string | null>;
|
|
69
|
+
/** Identity scope for the worker's per-user IndexedDB namespace. Defaults to
|
|
70
|
+
* 'anon'. */
|
|
71
|
+
getScope?: () => string;
|
|
72
|
+
/** Tool declarations from connected sidecars to advertise to the worker for a
|
|
73
|
+
* run. A getter so connecting/disconnecting a sidecar is picked up per run
|
|
74
|
+
* without recreating the worker. Mirrors getFileService. */
|
|
75
|
+
getRemoteTools?: () => ToolDecl[];
|
|
76
|
+
/** Execute a sidecar tool by name on the main thread (which holds the WS
|
|
77
|
+
* connection + governs). Answers the worker's tool-request. */
|
|
78
|
+
runRemoteTool?: (name: string, args: Record<string, unknown>) => Promise<string>;
|
|
79
|
+
}
|
|
80
|
+
export declare function createWorkerAgent(clientOpts: WorkerAgentOpts): WorkerAgent;
|
|
81
|
+
//# sourceMappingURL=workerClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerClient.d.ts","sourceRoot":"","sources":["../workerClient.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,KAAK,EAAE,MAAM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AAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAClF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,eAAe,GAAG,WAAW,CAsK1E"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { isAgentLogging, alog } from '@corenel/harness/log';
|
|
2
|
+
/** Re-phrase a file-mutation permission prompt from the live workspace, so the
|
|
3
|
+
* stated risk reflects the CURRENT source. Returns null for non-file tools. */
|
|
4
|
+
function fileWriteSummary(tool, input, svc) {
|
|
5
|
+
const o = (input && typeof input === 'object' ? input : {});
|
|
6
|
+
const s = (k) => (typeof o[k] === 'string' ? o[k] : '');
|
|
7
|
+
const where = svc?.isLocalDisk ? `LOCAL DISK${svc.label ? ` (${svc.label})` : ''}` : 'the virtual workspace';
|
|
8
|
+
switch (tool) {
|
|
9
|
+
case 'write_file':
|
|
10
|
+
case 'create_file':
|
|
11
|
+
return `Write "${s('path')}" to ${where}`;
|
|
12
|
+
case 'delete_file':
|
|
13
|
+
return `Delete "${s('path')}" from ${where}`;
|
|
14
|
+
case 'rename_file':
|
|
15
|
+
return `Rename "${s('from')}" -> "${s('to')}" in ${where}`;
|
|
16
|
+
default:
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function createWorkerAgent(clientOpts) {
|
|
21
|
+
let worker = null;
|
|
22
|
+
const getToken = clientOpts.getToken ?? (async () => null);
|
|
23
|
+
const getScope = clientOpts.getScope ?? (() => 'anon');
|
|
24
|
+
// Active runs, so a worker-level failure can reject the in-flight promise(s)
|
|
25
|
+
// instead of leaving the UI stuck on "thinking…".
|
|
26
|
+
const active = new Map();
|
|
27
|
+
const failAll = (message) => {
|
|
28
|
+
for (const { fail } of active.values())
|
|
29
|
+
fail(message);
|
|
30
|
+
active.clear();
|
|
31
|
+
};
|
|
32
|
+
/** Build + wire a worker. The token/file bridges and error surfacing are bound
|
|
33
|
+
* to THIS instance; on error we null `worker` so the next run recreates it. */
|
|
34
|
+
function make() {
|
|
35
|
+
alog('worker:create');
|
|
36
|
+
// The host builds the worker (app-owned entry) so this client holds no
|
|
37
|
+
// reference to the app's worker module.
|
|
38
|
+
const w = clientOpts.createWorker();
|
|
39
|
+
const send = (msg) => w.postMessage(msg);
|
|
40
|
+
// Answer the worker's token + file requests (the worker can't read Clerk, and
|
|
41
|
+
// the active file workspace lives here on the main thread).
|
|
42
|
+
w.addEventListener('message', async (ev) => {
|
|
43
|
+
const m = ev.data;
|
|
44
|
+
if (m.kind === 'token-request') {
|
|
45
|
+
const token = await Promise.race([
|
|
46
|
+
getToken().catch(() => null),
|
|
47
|
+
new Promise((r) => setTimeout(() => r(null), 7000)),
|
|
48
|
+
]);
|
|
49
|
+
send({ kind: 'token-response', id: m.id, token });
|
|
50
|
+
}
|
|
51
|
+
else if (m.kind === 'file-request') {
|
|
52
|
+
const svc = clientOpts.getFileService?.() || null;
|
|
53
|
+
if (!svc) {
|
|
54
|
+
send({ kind: 'file-response', id: m.id, ok: false, error: 'No file workspace is connected.' });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const fn = svc[m.op];
|
|
59
|
+
if (typeof fn !== 'function')
|
|
60
|
+
throw new Error(`Unsupported file op: ${m.op}`);
|
|
61
|
+
const data = await fn.apply(svc, m.args);
|
|
62
|
+
send({ kind: 'file-response', id: m.id, ok: true, data });
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
send({ kind: 'file-response', id: m.id, ok: false, error: String(e?.message || e) });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else if (m.kind === 'tool-request') {
|
|
69
|
+
// A sidecar tool the worker's agent called — run it here (the main thread
|
|
70
|
+
// holds the WS connection and already gated it via the permission flow).
|
|
71
|
+
const exec = clientOpts.runRemoteTool;
|
|
72
|
+
if (!exec) {
|
|
73
|
+
send({ kind: 'tool-response', id: m.id, ok: false, error: 'No sidecar is connected.' });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const result = await exec(m.name, m.args);
|
|
78
|
+
send({ kind: 'tool-response', id: m.id, ok: true, result });
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
send({ kind: 'tool-response', id: m.id, ok: false, error: String(e?.message || e) });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
w.addEventListener('error', (e) => {
|
|
86
|
+
console.error('[agent] WORKER ERROR', e.message, e.filename ? `${e.filename}:${e.lineno}:${e.colno}` : '', e.error);
|
|
87
|
+
failAll(`Agent worker error: ${e.message || 'failed to load'}${e.filename ? ` (${e.filename}:${e.lineno})` : ''}`);
|
|
88
|
+
if (worker === w)
|
|
89
|
+
worker = null; // recreate on the next run
|
|
90
|
+
});
|
|
91
|
+
w.addEventListener('messageerror', (e) => { console.error('[agent] WORKER MESSAGEERROR', e); failAll('Agent worker received an unreadable message.'); });
|
|
92
|
+
return w;
|
|
93
|
+
}
|
|
94
|
+
/** A live worker, recreated if it was disposed/errored. */
|
|
95
|
+
function ensure() {
|
|
96
|
+
if (!worker)
|
|
97
|
+
worker = make();
|
|
98
|
+
return worker;
|
|
99
|
+
}
|
|
100
|
+
let runSeq = 0;
|
|
101
|
+
/** Snapshot the LIVE workspace's risk metadata for a run/permission prompt. */
|
|
102
|
+
function currentFileMeta() {
|
|
103
|
+
const svc = clientOpts.getFileService?.() || null;
|
|
104
|
+
return svc ? { kind: svc.kind, label: svc.label, isLocalDisk: svc.isLocalDisk, writable: svc.writable } : undefined;
|
|
105
|
+
}
|
|
106
|
+
/** Shared driver for a worker run. Wires the per-run event / node-event /
|
|
107
|
+
* permission / ask / abort bridges, posts the start message, and settles on the
|
|
108
|
+
* terminal reply. `run` and `runNode` differ only in the start message and which
|
|
109
|
+
* terminal kind carries the result (selected by `terminal`). */
|
|
110
|
+
function begin(opts, start, terminal) {
|
|
111
|
+
const w = ensure();
|
|
112
|
+
const send = (msg) => w.postMessage(msg);
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const runId = ++runSeq;
|
|
115
|
+
const cleanup = () => {
|
|
116
|
+
active.delete(runId);
|
|
117
|
+
w.removeEventListener('message', onMessage);
|
|
118
|
+
opts.signal?.removeEventListener('abort', onAbort);
|
|
119
|
+
};
|
|
120
|
+
const done = (v) => { cleanup(); resolve(v); };
|
|
121
|
+
const failWith = (e) => { cleanup(); reject(e); };
|
|
122
|
+
const fail = (message) => { opts.onEvent?.({ type: 'error', message }); failWith(new Error(message)); };
|
|
123
|
+
active.set(runId, { fail });
|
|
124
|
+
const onMessage = async (ev) => {
|
|
125
|
+
const m = ev.data;
|
|
126
|
+
if (!('runId' in m) || m.runId !== runId)
|
|
127
|
+
return;
|
|
128
|
+
if (m.kind === 'event') {
|
|
129
|
+
opts.onEvent?.(m.event);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (m.kind === 'node-event') {
|
|
133
|
+
opts.onNodeEvent?.(m.event);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (m.kind === 'permission-request') {
|
|
137
|
+
// For file-mutating tools, re-build the summary from the LIVE workspace
|
|
138
|
+
// so the risk (LOCAL DISK vs virtual) is current, not frozen at run start.
|
|
139
|
+
const svc = clientOpts.getFileService?.() || null;
|
|
140
|
+
const summary = fileWriteSummary(m.tool, m.input, svc) ?? m.summary;
|
|
141
|
+
const allow = opts.onPermission ? await opts.onPermission({ tool: m.tool, summary }) : true;
|
|
142
|
+
send({ kind: 'permission-response', id: m.id, allow });
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (m.kind === 'ask-request') {
|
|
146
|
+
const answers = opts.onAsk ? await opts.onAsk(m.questions) : null;
|
|
147
|
+
send({ kind: 'ask-response', id: m.id, answers });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (m.kind === 'edit-review-request') {
|
|
151
|
+
// Without a reviewer wired, answer null immediately — the tool then
|
|
152
|
+
// reports "not reviewed" instead of suspending the run forever.
|
|
153
|
+
const outcome = opts.onEditReview ? await opts.onEditReview(m.callId) : null;
|
|
154
|
+
send({ kind: 'edit-review-response', id: m.id, outcome });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (m.kind === 'error') {
|
|
158
|
+
failWith(new Error(m.message));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
terminal(m, done);
|
|
162
|
+
};
|
|
163
|
+
const onAbort = () => send({ kind: 'abort', runId });
|
|
164
|
+
w.addEventListener('message', onMessage);
|
|
165
|
+
opts.signal?.addEventListener('abort', onAbort, { once: true });
|
|
166
|
+
start(runId, send);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
run(messages, opts = {}) {
|
|
171
|
+
return begin(opts, (runId, send) => {
|
|
172
|
+
alog('client:post-run', runId, { debug: isAgentLogging() });
|
|
173
|
+
send({ kind: 'run', runId, messages, model: opts.model, system: opts.system, policy: opts.policy, ceiling: opts.ceiling, compression: opts.compression, debug: isAgentLogging(), fileMeta: currentFileMeta(), scope: getScope(), reviewEdits: !!opts.onEditReview, remoteTools: clientOpts.getRemoteTools?.() ?? [] });
|
|
174
|
+
}, (m, done) => { if (m.kind === 'result')
|
|
175
|
+
done(m.result); });
|
|
176
|
+
},
|
|
177
|
+
runNode(node, inputs, opts = {}) {
|
|
178
|
+
return begin(opts, (runId, send) => {
|
|
179
|
+
alog('client:post-run-node', runId, node.id, { debug: isAgentLogging() });
|
|
180
|
+
send({ kind: 'run-node', runId, node, inputs, model: opts.model, policy: opts.policy, ceiling: opts.ceiling, compression: opts.compression, debug: isAgentLogging(), fileMeta: currentFileMeta(), scope: getScope(), remoteTools: clientOpts.getRemoteTools?.() ?? [] });
|
|
181
|
+
}, (m, done) => { if (m.kind === 'node-result')
|
|
182
|
+
done(m.result); });
|
|
183
|
+
},
|
|
184
|
+
dispose() {
|
|
185
|
+
if (worker) {
|
|
186
|
+
worker.terminate();
|
|
187
|
+
worker = null;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=workerClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerClient.js","sourceRoot":"","sources":["../workerClient.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AA8C5D;+EAC+E;AAC/E,SAAS,gBAAgB,CAAC,IAAY,EAAE,KAAc,EAAE,GAAuB;IAC7E,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAC;IACvF,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAC7G,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,YAAY,CAAC;QAClB,KAAK,aAAa;YAChB,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC;QAC5C,KAAK,aAAa;YAChB,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,UAAU,KAAK,EAAE,CAAC;QAC/C,KAAK,aAAa;YAChB,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,EAAE,CAAC;QAC7D;YACE,OAAO,IAAI,CAAC;I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AAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAC/D,CAAC;QACJ,CAAC;QACD,OAAO;YACL,IAAI,MAAM,EAAE,CAAC;gBAAC,MAAM,CAAC,SAAS,EAAE,CAAC;gBAAC,MAAM,GAAG,IAAI,CAAC;YAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WorkerTransport } from './core/protocol';
|
|
2
|
+
/** Start the kernel worker against a host transport. The app-owned entry binds
|
|
3
|
+
* the transport to its runtime (browser `self`, Node `parentPort`) and registers
|
|
4
|
+
* any product tools BEFORE calling this. */
|
|
5
|
+
export declare function startWorker(transport: WorkerTransport): void;
|
|
6
|
+
//# sourceMappingURL=workerHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerHandler.d.ts","sourceRoot":"","sources":["../workerHandler.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAwC,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAuc7F;;4CAE4C;AAC5C,wBAAgB,WAAW,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAG5D"}
|