omnirush 0.8.5 → 0.9.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.
Files changed (49) hide show
  1. package/assets/CHANGELOG.md +85 -0
  2. package/assets/collect-once.ts +6 -5
  3. package/assets/extensions/omnirush/agents-lib.ts +196 -12
  4. package/assets/extensions/omnirush/agents.ts +97 -105
  5. package/assets/extensions/omnirush/auth.js +399 -115
  6. package/assets/extensions/omnirush/bgshell-lib.ts +400 -0
  7. package/assets/extensions/omnirush/bgshell.ts +392 -0
  8. package/assets/extensions/omnirush/collector.ts +103 -16
  9. package/assets/extensions/omnirush/commands.ts +14 -15
  10. package/assets/extensions/omnirush/deliveries.ts +145 -0
  11. package/assets/extensions/omnirush/guard/UPSTREAM +2 -0
  12. package/assets/extensions/omnirush/guard/git-command-policy.ts +885 -0
  13. package/assets/extensions/omnirush/guard-lib.ts +230 -0
  14. package/assets/extensions/omnirush/guard.ts +340 -0
  15. package/assets/extensions/omnirush/index.ts +12 -0
  16. package/assets/extensions/omnirush/pi-engine.ts +65 -1
  17. package/assets/extensions/omnirush/sota.ts +104 -47
  18. package/assets/extensions/omnirush/status-lib.ts +3 -0
  19. package/assets/extensions/omnirush/subagents-lib.ts +623 -0
  20. package/assets/extensions/omnirush/subagents.ts +305 -0
  21. package/assets/extensions/omnirush/swarm-lib.ts +142 -0
  22. package/assets/extensions/omnirush/swarm.ts +95 -0
  23. package/assets/extensions/omnirush/voice/capture.ts +502 -0
  24. package/assets/extensions/omnirush/voice/core/UPSTREAM +16 -0
  25. package/assets/extensions/omnirush/voice/core/file-source.ts +70 -0
  26. package/assets/extensions/omnirush/voice/core/index.ts +21 -0
  27. package/assets/extensions/omnirush/voice/core/keyterms.ts +117 -0
  28. package/assets/extensions/omnirush/voice/core/resample.ts +63 -0
  29. package/assets/extensions/omnirush/voice/core/segmenter.ts +231 -0
  30. package/assets/extensions/omnirush/voice/core/session.ts +403 -0
  31. package/assets/extensions/omnirush/voice/core/text.ts +81 -0
  32. package/assets/extensions/omnirush/voice/core/transcriber.ts +135 -0
  33. package/assets/extensions/omnirush/voice/core/types.ts +102 -0
  34. package/assets/extensions/omnirush/voice/core/wav.ts +95 -0
  35. package/assets/extensions/omnirush/voice/keys.ts +435 -0
  36. package/assets/extensions/omnirush/voice/kitty.ts +64 -0
  37. package/assets/extensions/omnirush/voice/pvrecorder-worker.cjs +43 -0
  38. package/assets/extensions/omnirush/voice/settings.ts +67 -0
  39. package/assets/extensions/omnirush/voice.ts +838 -0
  40. package/assets/extensions/omnirush/yolo-lib.ts +80 -0
  41. package/assets/extensions/omnirush/yolo.ts +85 -0
  42. package/package.json +6 -2
  43. package/scripts/brand-engine.js +526 -0
  44. package/scripts/build-all-packages.py +29 -1
  45. package/scripts/smoke-packages.py +32 -1
  46. package/src/bin.js +252 -53
  47. package/src/compat.js +272 -0
  48. package/src/lib.js +64 -0
  49. package/scripts/patch-pi-branding.js +0 -251
@@ -0,0 +1,145 @@
1
+ // deliveries — brings results of background work back into the conversation.
2
+ //
3
+ // Background sub-agents (agents.ts) and background shell commands
4
+ // (bgshell.ts) finish while the main agent works on, waits for the user, or
5
+ // is about to end a one-shot run. Each registers as a source here; one hub
6
+ // per extension instance delivers what they have:
7
+ //
8
+ // - the agent is busy: the result is steered into the running turn (the
9
+ // model sees it before its next step);
10
+ // - the agent is idle: the result starts a new turn;
11
+ // - one-shot runs (print/json mode) end when the agent settles, so the hub
12
+ // holds the run open while a source still has work out, delivers each
13
+ // result as it comes (a new run nested in this settle, whose own settle
14
+ // resumes this one), and gives each source one last word (`beforeEnd`)
15
+ // before the run is allowed to end.
16
+
17
+ export interface DeliveryItem {
18
+ customType: string;
19
+ content: string;
20
+ details?: unknown;
21
+ }
22
+
23
+ export interface DeliverySource {
24
+ /** Work of this session whose result the run should still wait for (running, or finished and unread). */
25
+ hasPending(session: string): boolean;
26
+ /** Finished results ready now (each becomes one message); marked delivered. */
27
+ take(session: string): DeliveryItem[];
28
+ /** Resolves at the next change (something finished). */
29
+ changed(): Promise<void>;
30
+ /** One-shot runs with nothing pending: a last message before the run ends, or null. */
31
+ beforeEnd?(session: string): DeliveryItem | null;
32
+ }
33
+
34
+ export class DeliveryHub {
35
+ private readonly pi: any;
36
+ private readonly sources: DeliverySource[] = [];
37
+ /** The session this runtime is on (deliveries go to it). */
38
+ currentSession = "";
39
+ cwd = process.cwd();
40
+ /** An agent run is under way (one-shot runs deliver through the settle loop otherwise). */
41
+ private busy = false;
42
+ private oneShot = false;
43
+ private resumeOuter: (() => void) | null = null;
44
+
45
+ constructor(pi: any) {
46
+ this.pi = pi;
47
+ pi.on("session_start", (_event: any, ctx: any) => {
48
+ this.sessionOf(ctx);
49
+ });
50
+ pi.on("agent_start", (_event: any, ctx: any) => {
51
+ this.sessionOf(ctx);
52
+ this.busy = true;
53
+ });
54
+ pi.on("agent_settled", (_event: any, ctx: any) => this.settled(ctx));
55
+ }
56
+
57
+ addSource(source: DeliverySource): void {
58
+ this.sources.push(source);
59
+ }
60
+
61
+ /** A source has something to deliver (called after its own bookkeeping). */
62
+ notify(): void {
63
+ queueMicrotask(() => this.deliver());
64
+ }
65
+
66
+ /** The session of a tool or event context (and what the hub learns from it). */
67
+ sessionOf(ctx: any): string {
68
+ const id = String(ctx?.sessionManager?.getSessionId?.() ?? "");
69
+ if (id) this.currentSession = id;
70
+ if (ctx?.cwd) this.cwd = String(ctx.cwd);
71
+ if (ctx?.mode === "print" || ctx?.mode === "json") this.oneShot = true;
72
+ return id;
73
+ }
74
+
75
+ get isOneShot(): boolean {
76
+ return this.oneShot;
77
+ }
78
+
79
+ private send(item: DeliveryItem): void {
80
+ this.pi.sendMessage(
81
+ { customType: item.customType, content: item.content, display: true, ...(item.details !== undefined ? { details: item.details } : {}) },
82
+ // Busy: into the running turn at its next step. Idle: a new turn.
83
+ { triggerTurn: true, deliverAs: "steer" },
84
+ );
85
+ }
86
+
87
+ private deliver(): void {
88
+ if (!this.currentSession) return;
89
+ // One-shot and between runs: the agent_settled loop delivers.
90
+ if (this.oneShot && !this.busy) return;
91
+ for (const source of this.sources) {
92
+ for (const item of source.take(this.currentSession)) this.send(item);
93
+ }
94
+ }
95
+
96
+ private async settled(ctx: any): Promise<void> {
97
+ this.busy = false;
98
+ const session = this.sessionOf(ctx);
99
+ if (!this.oneShot) {
100
+ // Anything that finished right as the run ended.
101
+ this.deliver();
102
+ return;
103
+ }
104
+ const outer = this.resumeOuter;
105
+ this.resumeOuter = null;
106
+ const idle = () => typeof ctx?.isIdle !== "function" || ctx.isIdle();
107
+ try {
108
+ for (;;) {
109
+ if (!idle()) {
110
+ // A run started (a delivery): its settle resumes this one.
111
+ await new Promise<void>((resolve) => { this.resumeOuter = resolve; });
112
+ break;
113
+ }
114
+ if (!session) break;
115
+ const items = this.sources.flatMap((source) => source.take(session));
116
+ if (items.length === 0 && this.sources.some((source) => source.hasPending(session))) {
117
+ await Promise.race(this.sources.map((source) => source.changed()));
118
+ continue;
119
+ }
120
+ if (items.length === 0) {
121
+ const last = this.sources.map((source) => source.beforeEnd?.(session) ?? null).find((item) => item !== null);
122
+ if (!last) break;
123
+ items.push(last);
124
+ }
125
+ this.busy = true;
126
+ for (const item of items) this.send(item);
127
+ if (idle()) this.busy = false;
128
+ }
129
+ } finally {
130
+ outer?.();
131
+ }
132
+ }
133
+ }
134
+
135
+ const hubs = new WeakMap<object, DeliveryHub>();
136
+
137
+ /** The hub of this extension instance (created, with its handlers, on first use). */
138
+ export function deliveryHub(pi: any): DeliveryHub {
139
+ let hub = hubs.get(pi);
140
+ if (!hub) {
141
+ hub = new DeliveryHub(pi);
142
+ hubs.set(pi, hub);
143
+ }
144
+ return hub;
145
+ }
@@ -0,0 +1,2 @@
1
+ Vendored from omnirush-gui apps/server/src/git-command-policy.ts at 51ee01f (origin/main).
2
+ Keep it byte-identical to upstream; CLI-specific logic lives in ../guard-lib.ts.