osborn 0.9.280 → 0.9.282
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/agent-store.d.ts +164 -0
- package/dist/agent-store.js +302 -0
- package/dist/claude-llm.d.ts +7 -8
- package/dist/claude-llm.js +75 -171
- package/dist/content/compaction-lens-worker.js +2 -1
- package/dist/content/content-run.js +9 -9
- package/dist/content/lens-clip-window.js +7 -6
- package/dist/content/lens-launch.d.ts +11 -0
- package/dist/content/lens-launch.js +11 -0
- package/dist/content/lens-library-select.d.ts +7 -5
- package/dist/content/lens-library-select.js +7 -6
- package/dist/content/lens-library.d.ts +7 -1
- package/dist/content/lens-library.js +29 -6
- package/dist/data-sender-auth.d.ts +3 -2
- package/dist/data-sender-auth.js +10 -3
- package/dist/index.js +376 -190
- package/dist/pipeline-direct-llm.d.ts +1 -1
- package/dist/pipeline-direct-llm.js +1 -1
- package/dist/prompts/chain-after-planner.md +1 -0
- package/dist/prompts/chain-after-researcher.md +1 -0
- package/dist/prompts/chain-after-writer.md +1 -0
- package/dist/prompts/direct-mode-research.md +2 -2
- package/dist/prompts/steward.md +131 -0
- package/dist/prompts.d.ts +6 -0
- package/dist/prompts.js +18 -1
- package/dist/pushover.d.ts +7 -0
- package/dist/pushover.js +45 -42
- package/dist/steward-gate.d.ts +6 -5
- package/dist/steward-gate.js +256 -32
- package/dist/steward-verdict.d.ts +23 -0
- package/dist/steward-verdict.js +97 -0
- package/dist/stopwords.d.ts +1 -0
- package/dist/stopwords.js +6 -0
- package/dist/store-catalog.d.ts +106 -0
- package/dist/store-catalog.js +356 -0
- package/dist/store-name.d.ts +1 -0
- package/dist/store-name.js +7 -0
- package/package.json +1 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lens-library-select.ts — which PERIOD
|
|
2
|
+
* lens-library-select.ts — which PERIOD just ended. Pure + deterministic.
|
|
3
3
|
*
|
|
4
|
-
* A period runs from one
|
|
5
|
-
*
|
|
4
|
+
* A period runs from one seam to the row before the next. Seams are compactions
|
|
5
|
+
* (lens-period-boundaries) and the end of each page already written
|
|
6
|
+
* (librarySegments), so a session that never compacts still gets new periods. Seams come in clusters (several re-compactions within
|
|
6
7
|
* minutes), so short periods are merged FORWARD: walking the seams in order, a
|
|
7
8
|
* group only closes at a seam once it spans >= minSpanMs of conversation. The
|
|
8
9
|
* walk depends only on earlier rows, so a later seam never re-numbers an earlier
|
|
9
10
|
* group. That makes the group's OPENING boundary row (startRowId) a stable key:
|
|
10
11
|
* the same period always gets the same key, index and file name.
|
|
11
12
|
*
|
|
12
|
-
* Timing: the worker runs at PostCompact
|
|
13
|
+
* Timing: the worker runs at PostCompact (and when a session ends); at PostCompact it is usually BEFORE the recall store has
|
|
13
14
|
* ingested the seam this compaction will produce. So the db's TAIL (last seam →
|
|
14
15
|
* last row) is the period that just ended; it is treated as closed by "this
|
|
15
16
|
* compaction" when it spans >= minSpanMs, else it is deferred (merged into the
|
|
16
17
|
* next one). If the new seam is already ingested, the tail is tiny and the last
|
|
17
18
|
* seam-closed group is the one that just ended.
|
|
18
19
|
*/
|
|
19
|
-
export const DEFAULT_MIN_SPAN_MS =
|
|
20
|
+
export const DEFAULT_MIN_SPAN_MS = 3_600_000;
|
|
20
21
|
function span(recs) {
|
|
21
22
|
if (recs.length < 2)
|
|
22
23
|
return 0;
|
|
@@ -24,7 +25,7 @@ function span(recs) {
|
|
|
24
25
|
const b = Date.parse(recs[recs.length - 1].timestamp);
|
|
25
26
|
return Number.isFinite(a) && Number.isFinite(b) ? Math.max(0, b - a) : 0;
|
|
26
27
|
}
|
|
27
|
-
function period(index, start, end, closedBy, recs) {
|
|
28
|
+
export function period(index, start, end, closedBy, recs) {
|
|
28
29
|
return {
|
|
29
30
|
index, startRowId: start, endRowId: end, closedBy, rows: recs.length,
|
|
30
31
|
fromTs: recs[0]?.timestamp ?? '', toTs: recs[recs.length - 1]?.timestamp ?? '', spanMs: span(recs),
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* is retried next time. Fail-open: never throws; the caller just logs the result.
|
|
15
15
|
* Opt-out: OSBORN_CONTENT_LENS=0 (same switch as the launcher).
|
|
16
16
|
*/
|
|
17
|
-
import { type LibraryPeriod } from './lens-library-select.js';
|
|
17
|
+
import { type LibraryPeriod, type Segmentation } from './lens-library-select.js';
|
|
18
18
|
import { type IngestOptions, type IngestState } from './lens-ingest.js';
|
|
19
19
|
export declare const MANIFEST_FILE = ".library-manifest.json";
|
|
20
20
|
export interface ManifestEntry {
|
|
@@ -88,5 +88,11 @@ export declare function ingestPendingPages(dir: string, m: Manifest, o?: IngestO
|
|
|
88
88
|
export declare function libraryDirFor(dbPath: string, sessionId: string): string;
|
|
89
89
|
export declare function readManifest(dir: string, sessionId: string): Manifest;
|
|
90
90
|
export declare function writeManifest(dir: string, m: Manifest): void;
|
|
91
|
+
/**
|
|
92
|
+
* The session's periods as the library writes them (shared with the content step): compaction
|
|
93
|
+
* seams plus the end of every written page, so without a compaction the tail moves on past a
|
|
94
|
+
* written page instead of keeping its start row forever.
|
|
95
|
+
*/
|
|
96
|
+
export declare function librarySegments(db: string, manifest: Manifest, minSpanMs?: number): Segmentation;
|
|
91
97
|
/** Run the library step once. Never throws. */
|
|
92
98
|
export declare function runLibraryStep(o: LibraryStepOptions): Promise<LibraryStepResult>;
|
|
@@ -22,7 +22,7 @@ import { readCompactionBoundaries } from './lens-period-boundaries.js';
|
|
|
22
22
|
import { loadClientRedactor } from './lens-redact.js';
|
|
23
23
|
import { redactSecrets } from './transcript-sanitizer.js';
|
|
24
24
|
import { runPeriodMap } from './period-run.js';
|
|
25
|
-
import { DEFAULT_MIN_SPAN_MS, pageFileName, pickLibraryPeriod, segmentPeriods } from './lens-library-select.js';
|
|
25
|
+
import { DEFAULT_MIN_SPAN_MS, pageFileName, period, pickLibraryPeriod, segmentPeriods } from './lens-library-select.js';
|
|
26
26
|
import { rebuildIndex } from './lens-library-index.js';
|
|
27
27
|
import { contentHashFor, ingestPage, needsIngest, resolveIngestConfig } from './lens-ingest.js';
|
|
28
28
|
export const MANIFEST_FILE = '.library-manifest.json';
|
|
@@ -96,6 +96,27 @@ const envNum = (k) => {
|
|
|
96
96
|
const n = Number(process.env[k]);
|
|
97
97
|
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
98
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* The session's periods as the library writes them (shared with the content step): compaction
|
|
101
|
+
* seams plus the end of every written page, so without a compaction the tail moves on past a
|
|
102
|
+
* written page instead of keeping its start row forever.
|
|
103
|
+
*/
|
|
104
|
+
export function librarySegments(db, manifest, minSpanMs = libraryMinSpanMs()) {
|
|
105
|
+
const rows = loadConversationRows(db, 0).records.map(r => ({ id: r.id, timestamp: r.timestamp }));
|
|
106
|
+
// Written pages are frozen: they keep their rows, index and file whatever the period
|
|
107
|
+
// length is now. Only rows after the last written page are segmented, numbered on.
|
|
108
|
+
const written = Object.values(manifest.periods).filter(e => e.status === 'ok').sort((a, b) => a.startRowId - b.startRowId);
|
|
109
|
+
const lastEnd = written.length ? Math.max(...written.map(e => e.endRowId)) : 0;
|
|
110
|
+
const lastIndex = written.length ? Math.max(...written.map(e => e.index)) : 0;
|
|
111
|
+
const frozen = written.map(e => period(e.index, e.startRowId, e.endRowId, typeof e.closedBy === 'number' ? e.closedBy : null, rows.filter(r => r.id >= e.startRowId && r.id <= e.endRowId)));
|
|
112
|
+
const rest = segmentPeriods(rows.filter(r => r.id > lastEnd), readCompactionBoundaries(db), minSpanMs);
|
|
113
|
+
const renumber = (p) => ({ ...p, index: p.index + lastIndex });
|
|
114
|
+
return { closed: [...frozen, ...rest.closed.map(renumber)], tail: rest.tail ? renumber(rest.tail) : null };
|
|
115
|
+
}
|
|
116
|
+
function libraryMinSpanMs() {
|
|
117
|
+
const envH = envNum('OSBORN_LIBRARY_MIN_PERIOD_H');
|
|
118
|
+
return envH ? envH * 3_600_000 : DEFAULT_MIN_SPAN_MS;
|
|
119
|
+
}
|
|
99
120
|
/** Run the library step once. Never throws. */
|
|
100
121
|
export async function runLibraryStep(o) {
|
|
101
122
|
const log = o.log ?? (() => { });
|
|
@@ -111,13 +132,10 @@ export async function runLibraryStep(o) {
|
|
|
111
132
|
if (!db)
|
|
112
133
|
return { ...res, status: 'no-db' };
|
|
113
134
|
const projectDir = dirname(dirname(dirname(db)));
|
|
114
|
-
const envH = envNum('OSBORN_LIBRARY_MIN_PERIOD_H');
|
|
115
|
-
const minSpan = o.minSpanMs ?? (envH ? envH * 3_600_000 : DEFAULT_MIN_SPAN_MS);
|
|
116
135
|
const dir = (res.libraryDir = o.outDir ?? libraryDirFor(db, o.sessionId));
|
|
117
|
-
// Segment the whole session at its compaction seams (ids + timestamps only).
|
|
118
|
-
const rows = loadConversationRows(db, 0).records.map(r => ({ id: r.id, timestamp: r.timestamp }));
|
|
119
|
-
const seg = segmentPeriods(rows, readCompactionBoundaries(db), minSpan);
|
|
120
136
|
const manifest = readManifest(dir, o.sessionId);
|
|
137
|
+
const minSpan = o.minSpanMs ?? libraryMinSpanMs();
|
|
138
|
+
const seg = librarySegments(db, manifest, minSpan);
|
|
121
139
|
const pick = pickLibraryPeriod(seg, start => manifest.periods[String(start)]?.status === 'ok', minSpan);
|
|
122
140
|
log(`library: ${seg.closed.length} closed period(s), tail ${seg.tail ? `#${seg.tail.startRowId}–#${seg.tail.endRowId} (${(seg.tail.spanMs / 3_600_000).toFixed(1)}h)` : 'none'} → ${pick.reason}`);
|
|
123
141
|
const red = loadClientRedactor(projectDir);
|
|
@@ -131,6 +149,11 @@ export async function runLibraryStep(o) {
|
|
|
131
149
|
const p = (res.period = pick.period);
|
|
132
150
|
const key = String(p.startRowId);
|
|
133
151
|
const file = pageFileName(p);
|
|
152
|
+
// Never overwrite a page this manifest did not write (e.g. a manual backfill page).
|
|
153
|
+
if (!o.outDir && existsSync(join(dir, file)) && !Object.values(manifest.periods).some(e => e.file === file)) {
|
|
154
|
+
log(`library: ${file} exists and is not ours — not overwritten`);
|
|
155
|
+
return { ...res, status: 'already-written' };
|
|
156
|
+
}
|
|
134
157
|
// Period map on exactly this row range, staged first; published only when a map came back.
|
|
135
158
|
mkdirSync(join(dir, STAGING_DIR), { recursive: true });
|
|
136
159
|
const staged = join(dir, STAGING_DIR, file);
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
* user_text, claude_auth_code, permission_response, list_sessions,
|
|
16
16
|
* resume_session, continue_session, switch_session, session_selected,
|
|
17
17
|
* cancel_session_switch,
|
|
18
|
-
* mcp_toggle, set_agents, skill_add,
|
|
18
|
+
* mcp_toggle, set_agents, skill_add, skill_fork, skill_remove,
|
|
19
|
+
* get_agent_prompt, noise_cancel,
|
|
19
20
|
* gate_send_anyway, stop_dispatch, join_meeting, leave_meeting,
|
|
20
21
|
* mute_participant, start_ide, stop_ide, spawn_background_session,
|
|
21
22
|
* dispatch_background, stop_background_session, list_slots, list_processes,
|
|
22
23
|
* favorite_changed
|
|
23
24
|
* Open (read-only, listed in READ_ONLY_MESSAGE_TYPES):
|
|
24
25
|
* get_current_session, get_session_artifacts, get_plan_file,
|
|
25
|
-
* get_research_artifact, get_mcp_status, get_skills,
|
|
26
|
+
* get_research_artifact, get_mcp_status, get_skills, skill_get, get_busy
|
|
26
27
|
* list_sessions / list_slots / list_processes are read-only but return session
|
|
27
28
|
* and process ids that the gated commands (dispatch_background etc.) take as
|
|
28
29
|
* targets, so they are gated too.
|
package/dist/data-sender-auth.js
CHANGED
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
* user_text, claude_auth_code, permission_response, list_sessions,
|
|
16
16
|
* resume_session, continue_session, switch_session, session_selected,
|
|
17
17
|
* cancel_session_switch,
|
|
18
|
-
* mcp_toggle, set_agents, skill_add,
|
|
18
|
+
* mcp_toggle, set_agents, skill_add, skill_fork, skill_remove,
|
|
19
|
+
* get_agent_prompt, noise_cancel,
|
|
19
20
|
* gate_send_anyway, stop_dispatch, join_meeting, leave_meeting,
|
|
20
21
|
* mute_participant, start_ide, stop_ide, spawn_background_session,
|
|
21
22
|
* dispatch_background, stop_background_session, list_slots, list_processes,
|
|
22
23
|
* favorite_changed
|
|
23
24
|
* Open (read-only, listed in READ_ONLY_MESSAGE_TYPES):
|
|
24
25
|
* get_current_session, get_session_artifacts, get_plan_file,
|
|
25
|
-
* get_research_artifact, get_mcp_status, get_skills,
|
|
26
|
+
* get_research_artifact, get_mcp_status, get_skills, skill_get, get_busy
|
|
26
27
|
* list_sessions / list_slots / list_processes are read-only but return session
|
|
27
28
|
* and process ids that the gated commands (dispatch_background etc.) take as
|
|
28
29
|
* targets, so they are gated too.
|
|
@@ -48,11 +49,16 @@ export const CONTROL_MESSAGE_TYPES = new Set([
|
|
|
48
49
|
'switch_session',
|
|
49
50
|
// Cancels a deferred switch (#74) — state-changing, controller-only.
|
|
50
51
|
'cancel_session_switch',
|
|
52
|
+
// Keeps the agent working after the hang-up — state-changing, controller-only.
|
|
53
|
+
'keep_working',
|
|
51
54
|
'session_selected',
|
|
52
55
|
'mcp_toggle',
|
|
53
56
|
'set_agents',
|
|
54
57
|
'skill_add',
|
|
58
|
+
'skill_fork',
|
|
55
59
|
'skill_remove',
|
|
60
|
+
// The built-in agents' prompts, for Fork (the same data GET /agents keeps behind the token).
|
|
61
|
+
'get_agent_prompt',
|
|
56
62
|
'noise_cancel',
|
|
57
63
|
'gate_send_anyway',
|
|
58
64
|
'stop_dispatch',
|
|
@@ -77,8 +83,9 @@ export const READ_ONLY_MESSAGE_TYPES = new Set([
|
|
|
77
83
|
'get_research_artifact',
|
|
78
84
|
'get_mcp_status',
|
|
79
85
|
'get_skills',
|
|
80
|
-
'get_agents',
|
|
81
86
|
'skill_get',
|
|
87
|
+
// End asks whether the agent is mid-task before offering keep-working.
|
|
88
|
+
'get_busy',
|
|
82
89
|
]);
|
|
83
90
|
/** Identity prefix /api/token gives every user participant. */
|
|
84
91
|
export const USER_IDENTITY_PREFIX = 'user-';
|