osborn 0.9.280 → 0.9.281

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.
Files changed (38) hide show
  1. package/dist/agent-store.d.ts +162 -0
  2. package/dist/agent-store.js +300 -0
  3. package/dist/claude-llm.d.ts +7 -8
  4. package/dist/claude-llm.js +65 -160
  5. package/dist/content/compaction-lens-worker.js +2 -1
  6. package/dist/content/content-run.js +9 -9
  7. package/dist/content/lens-clip-window.js +7 -6
  8. package/dist/content/lens-launch.d.ts +11 -0
  9. package/dist/content/lens-launch.js +11 -0
  10. package/dist/content/lens-library-select.d.ts +7 -5
  11. package/dist/content/lens-library-select.js +7 -6
  12. package/dist/content/lens-library.d.ts +7 -1
  13. package/dist/content/lens-library.js +29 -6
  14. package/dist/data-sender-auth.d.ts +3 -2
  15. package/dist/data-sender-auth.js +6 -3
  16. package/dist/index.js +241 -158
  17. package/dist/pipeline-direct-llm.d.ts +1 -1
  18. package/dist/pipeline-direct-llm.js +1 -1
  19. package/dist/prompts/chain-after-planner.md +1 -0
  20. package/dist/prompts/chain-after-researcher.md +1 -0
  21. package/dist/prompts/chain-after-writer.md +1 -0
  22. package/dist/prompts/direct-mode-research.md +2 -2
  23. package/dist/prompts/steward.md +131 -0
  24. package/dist/prompts.d.ts +6 -0
  25. package/dist/prompts.js +18 -1
  26. package/dist/pushover.d.ts +2 -0
  27. package/dist/pushover.js +4 -2
  28. package/dist/steward-gate.d.ts +6 -5
  29. package/dist/steward-gate.js +256 -32
  30. package/dist/steward-verdict.d.ts +23 -0
  31. package/dist/steward-verdict.js +97 -0
  32. package/dist/stopwords.d.ts +1 -0
  33. package/dist/stopwords.js +6 -0
  34. package/dist/store-catalog.d.ts +101 -0
  35. package/dist/store-catalog.js +336 -0
  36. package/dist/store-name.d.ts +1 -0
  37. package/dist/store-name.js +3 -0
  38. package/package.json +1 -1
@@ -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, skill_remove, noise_cancel,
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, get_agents, skill_get
26
+ * get_research_artifact, get_mcp_status, get_skills, skill_get
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.
@@ -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, skill_remove, noise_cancel,
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, get_agents, skill_get
26
+ * get_research_artifact, get_mcp_status, get_skills, skill_get
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.
@@ -52,7 +53,10 @@ export const CONTROL_MESSAGE_TYPES = new Set([
52
53
  'mcp_toggle',
53
54
  'set_agents',
54
55
  'skill_add',
56
+ 'skill_fork',
55
57
  'skill_remove',
58
+ // The built-in agents' prompts, for Fork (the same data GET /agents keeps behind the token).
59
+ 'get_agent_prompt',
56
60
  'noise_cancel',
57
61
  'gate_send_anyway',
58
62
  'stop_dispatch',
@@ -77,7 +81,6 @@ export const READ_ONLY_MESSAGE_TYPES = new Set([
77
81
  'get_research_artifact',
78
82
  'get_mcp_status',
79
83
  'get_skills',
80
- 'get_agents',
81
84
  'skill_get',
82
85
  ]);
83
86
  /** Identity prefix /api/token gives every user participant. */