ropetide-runner 0.0.0-stage → 0.3.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/README.md +145 -2
- package/dist/apps/runner/src/agents.js +36 -0
- package/dist/apps/runner/src/browser.js +386 -0
- package/dist/apps/runner/src/browserProxy.js +120 -0
- package/dist/apps/runner/src/cli.js +449 -0
- package/dist/apps/runner/src/commands/redact.js +45 -0
- package/dist/apps/runner/src/commands/sandbox.js +61 -0
- package/dist/apps/runner/src/commands/shell.js +279 -0
- package/dist/apps/runner/src/extension.js +159 -0
- package/dist/apps/runner/src/files.js +163 -0
- package/dist/apps/runner/src/folderChoice.js +40 -0
- package/dist/apps/runner/src/main.js +351 -0
- package/dist/apps/runner/src/mcp/connectors.js +161 -0
- package/dist/apps/runner/src/pairCrypto.js +80 -0
- package/dist/apps/runner/src/planUsage.js +189 -0
- package/dist/apps/runner/src/power.js +11 -0
- package/dist/apps/runner/src/projects/access.js +337 -0
- package/dist/apps/runner/src/projects/http.js +74 -0
- package/dist/apps/runner/src/projects/prompt.js +19 -0
- package/dist/apps/runner/src/projects/rules.js +45 -0
- package/dist/apps/runner/src/projects/shares.js +192 -0
- package/dist/apps/runner/src/room.js +154 -0
- package/dist/apps/runner/src/run.js +182 -0
- package/dist/apps/runner/src/server.js +627 -0
- package/dist/apps/runner/src/skills.js +94 -0
- package/dist/apps/runner/src/tui.js +189 -0
- package/dist/apps/runner/src/video/analyse.js +95 -0
- package/dist/apps/runner/src/video/exec.js +32 -0
- package/dist/apps/runner/src/video/http.js +60 -0
- package/dist/apps/runner/src/video/probe.js +52 -0
- package/dist/apps/runner/src/video/render.js +322 -0
- package/dist/apps/runner/src/video/studio.js +329 -0
- package/dist/apps/runner/src/video/tools.js +24 -0
- package/dist/apps/runner/src/video.js +444 -0
- package/dist/supabase/functions/_shared/effort.js +16 -0
- package/dist/supabase/functions/_shared/folder-rules.js +129 -0
- package/dist/supabase/functions/_shared/github.js +319 -0
- package/dist/supabase/functions/_shared/localVideo.js +24 -0
- package/dist/supabase/functions/_shared/modelLimits.js +47 -0
- package/dist/supabase/functions/_shared/modelPrices.js +28 -0
- package/dist/supabase/functions/_shared/roles.js +18 -0
- package/dist/supabase/functions/_shared/room-command.js +70 -0
- package/dist/supabase/functions/_shared/roomBudget.js +60 -0
- package/dist/supabase/functions/_shared/video-plan.js +567 -0
- package/dist/supabase/functions/_shared/workspace.js +21 -0
- package/dist/supabase/functions/_shared/workspaceMeter.js +40 -0
- package/dist/supabase/functions/room-turn/context.js +154 -0
- package/dist/supabase/functions/room-turn/turn.js +750 -0
- package/package.json +36 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { FULL_LINES } from "../_shared/modelLimits.js";
|
|
2
|
+
export const CONTEXT_CHARS = 6000;
|
|
3
|
+
export const CONTEXT_ITEMS = 8;
|
|
4
|
+
export const CONTEXT_ITEM_CHARS = 750;
|
|
5
|
+
export const CONTEXT_RECENT = 8;
|
|
6
|
+
/** The longest one message sent as a line of the thread may be. */
|
|
7
|
+
export const LINE_CHARS = 4000;
|
|
8
|
+
export const PIN_ITEMS = 20;
|
|
9
|
+
export const PIN_CHARS = 8000;
|
|
10
|
+
export const PINS_CHARS = 40_000;
|
|
11
|
+
export const SUMMARY_CHARS = 3600;
|
|
12
|
+
/** Without the new turn fields, pins and the summary travel as room lines among the newest ones, which are never cut. */
|
|
13
|
+
const BOUNDED_PIN_LINES = 3;
|
|
14
|
+
/** Lines left free in a full-history turn for notes added after it is built (a folder, commands). */
|
|
15
|
+
const SPARE_LINES = 20;
|
|
16
|
+
export const turnKey = (id) => `turn:${id}`;
|
|
17
|
+
const words = (text) => new Set(text.toLowerCase().match(/[\p{L}\p{N}_./-]{3,}/gu) ?? []);
|
|
18
|
+
const STOP = new Set(['the', 'and', 'for', 'with', 'this', 'that', 'from', 'your', 'you', 'are', 'room', 'please']);
|
|
19
|
+
export class RoomContextStore {
|
|
20
|
+
source = [];
|
|
21
|
+
entries = [];
|
|
22
|
+
/** Append only new material. Edited/replaced histories rebuild so stale facts cannot survive. */
|
|
23
|
+
sync(thread) {
|
|
24
|
+
if (thread.length < this.source.length || this.source.some((l, i) => l.from !== thread[i]?.from || l.text !== thread[i]?.text || l.id !== thread[i]?.id)) {
|
|
25
|
+
this.source = [];
|
|
26
|
+
this.entries = [];
|
|
27
|
+
}
|
|
28
|
+
for (let i = this.source.length; i < thread.length; i++) {
|
|
29
|
+
const line = thread[i];
|
|
30
|
+
if (!line)
|
|
31
|
+
continue;
|
|
32
|
+
this.source.push({ ...line });
|
|
33
|
+
for (let start = 0; start < line.text.length; start += CONTEXT_ITEM_CHARS) {
|
|
34
|
+
const value = { from: line.from, text: line.text.slice(start, start + CONTEXT_ITEM_CHARS) };
|
|
35
|
+
if (value.text.trim())
|
|
36
|
+
this.entries.push({ line: i, value, terms: words(value.text) });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** The newest messages, and excerpts of older ones that bear on this turn. */
|
|
41
|
+
fetch(query) {
|
|
42
|
+
const cut = Math.max(0, this.source.length - CONTEXT_RECENT);
|
|
43
|
+
return { context: this.excerpts(query, cut), thread: this.source.slice(cut).map(bare) };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What one turn carries. With full history, every message the summary doesn't cover goes whole,
|
|
47
|
+
* newest first until the transport's limit; older ones that don't fit are searched for excerpts.
|
|
48
|
+
* Without it, the turn is the one `fetch` builds, with pins and the summary as room lines.
|
|
49
|
+
*/
|
|
50
|
+
assemble(query, options) {
|
|
51
|
+
const { summary } = options;
|
|
52
|
+
const live = summary ? this.source.filter((l) => l.id === undefined || l.id > summary.toId) : this.source;
|
|
53
|
+
const view = summary ? new RoomContextStore() : this;
|
|
54
|
+
if (summary)
|
|
55
|
+
view.sync(live);
|
|
56
|
+
let start = Math.max(0, live.length - CONTEXT_RECENT);
|
|
57
|
+
if (options.full) {
|
|
58
|
+
start = live.length;
|
|
59
|
+
let chars = 0;
|
|
60
|
+
while (start > 0 && live.length - start < FULL_LINES - SPARE_LINES) {
|
|
61
|
+
const size = Math.min(live[start - 1]?.text.length ?? 0, LINE_CHARS);
|
|
62
|
+
if (chars + size > options.maxChars)
|
|
63
|
+
break;
|
|
64
|
+
chars += size;
|
|
65
|
+
start--;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const sent = live.slice(start);
|
|
69
|
+
const thread = sent.map(bare);
|
|
70
|
+
const lineKeys = sent.map((l) => (l.id === undefined ? null : turnKey(l.id)));
|
|
71
|
+
const context = view.excerpts(query, start);
|
|
72
|
+
const inThread = new Set(lineKeys);
|
|
73
|
+
const wanted = options.pins.filter((p) => p.kind === 'turn' && !inThread.has(p.key));
|
|
74
|
+
const pinnedFiles = options.pins.filter((p) => p.kind === 'file').map((p) => p.key.slice('file:'.length));
|
|
75
|
+
const notSent = [];
|
|
76
|
+
const shared = { ...(context.length ? { context } : {}), ...(pinnedFiles.length ? { pinnedFiles } : {}) };
|
|
77
|
+
if (options.full) {
|
|
78
|
+
const pinned = [];
|
|
79
|
+
let chars = 0;
|
|
80
|
+
for (const pin of wanted) {
|
|
81
|
+
const text = pin.text.slice(0, PIN_CHARS);
|
|
82
|
+
if (!text.trim() || pinned.length === PIN_ITEMS || chars + text.length > PINS_CHARS) {
|
|
83
|
+
notSent.push(pin.key);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
chars += text.length;
|
|
87
|
+
pinned.push({ label: pin.label.slice(0, 200) || 'Pinned', text });
|
|
88
|
+
}
|
|
89
|
+
return { thread, ...shared, history: 'full', ...(pinned.length ? { pinned } : {}), ...(summary ? { summary: summary.text.slice(0, SUMMARY_CHARS) } : {}), lineKeys, notSent };
|
|
90
|
+
}
|
|
91
|
+
const extra = [];
|
|
92
|
+
const extraKeys = [];
|
|
93
|
+
if (summary) {
|
|
94
|
+
extra.push({ from: 'room', text: `[Summary of ${summary.count} earlier messages, written by an AI. Not verified; newer messages supersede it.]\n${summary.text.slice(0, SUMMARY_CHARS)}` });
|
|
95
|
+
extraKeys.push('summary');
|
|
96
|
+
}
|
|
97
|
+
const room = BOUNDED_PIN_LINES - (pinnedFiles.length ? 1 : 0);
|
|
98
|
+
let used = 0;
|
|
99
|
+
for (const pin of wanted) {
|
|
100
|
+
const head = `[Pinned by the person, from ${pin.label.slice(0, 80)}. Keep it in mind.]\n`;
|
|
101
|
+
const parts = [];
|
|
102
|
+
for (let at = 0; at < pin.text.length; at += LINE_CHARS - head.length)
|
|
103
|
+
parts.push(head + pin.text.slice(at, at + LINE_CHARS - head.length));
|
|
104
|
+
if (!pin.text.trim() || used + parts.length > room) {
|
|
105
|
+
notSent.push(pin.key);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
used += parts.length;
|
|
109
|
+
for (const text of parts) {
|
|
110
|
+
extra.push({ from: 'room', text });
|
|
111
|
+
extraKeys.push(`pin:${pin.key}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Naming a file in a recent line puts it first in what a large room shows. A room nobody has
|
|
115
|
+
// answered in keeps its thread as it is: the server names the room from its first reply.
|
|
116
|
+
const note = pinnedFiles.length && this.source.some((l) => l.from !== 'you')
|
|
117
|
+
? [{ from: 'room', text: `[Files the person pinned: ${pinnedFiles.join(', ')}]`.slice(0, LINE_CHARS) }]
|
|
118
|
+
: [];
|
|
119
|
+
return { thread: [...extra, ...thread, ...note], ...shared, lineKeys: [...extraKeys, ...lineKeys, ...note.map(() => null)], notSent };
|
|
120
|
+
}
|
|
121
|
+
excerpts(query, cut) {
|
|
122
|
+
const latestHuman = [...this.source].reverse().find((l) => l.from === 'you')?.text ?? '';
|
|
123
|
+
const terms = words(`${query.goal} ${query.instructions ?? ''} ${latestHuman} ${this.source.slice(-2).map((l) => l.text).join(' ')}`);
|
|
124
|
+
const all = query.stage === 'review' || query.stage === 'final';
|
|
125
|
+
const ranked = this.entries.filter((e) => e.line < cut).map((e) => {
|
|
126
|
+
let score = e.value.from === 'you' ? 8 : 0;
|
|
127
|
+
if (e.value.text.includes(`@${query.name}`) || e.value.from === query.speaker)
|
|
128
|
+
score += 6;
|
|
129
|
+
for (const word of terms)
|
|
130
|
+
if (!STOP.has(word) && e.terms.has(word))
|
|
131
|
+
score++;
|
|
132
|
+
if (all && e.value.from !== 'room')
|
|
133
|
+
score += 3;
|
|
134
|
+
return { ...e, score };
|
|
135
|
+
}).filter((e) => e.score > 0).sort((a, b) => b.score - a.score || b.line - a.line);
|
|
136
|
+
const selected = [];
|
|
137
|
+
const seen = new Set();
|
|
138
|
+
let chars = 0;
|
|
139
|
+
for (const e of ranked) {
|
|
140
|
+
const key = `${e.value.from}\n${e.value.text}`;
|
|
141
|
+
if (seen.has(key) || chars + e.value.text.length > CONTEXT_CHARS)
|
|
142
|
+
continue;
|
|
143
|
+
selected.push(e);
|
|
144
|
+
seen.add(key);
|
|
145
|
+
chars += e.value.text.length;
|
|
146
|
+
if (selected.length === CONTEXT_ITEMS)
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
selected.sort((a, b) => a.line - b.line);
|
|
150
|
+
return selected.map((e) => ({ ...e.value }));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** A line as it is sent: without the id, and inside the length every transport accepts. */
|
|
154
|
+
const bare = (l) => ({ from: l.from, text: l.text.slice(0, LINE_CHARS) });
|