@gajae-code/coding-agent 0.7.1 → 0.7.3

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 (135) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/types/cli/mcp-cli.d.ts +25 -0
  3. package/dist/types/cli/notify-cli.d.ts +2 -0
  4. package/dist/types/cli.d.ts +6 -0
  5. package/dist/types/commands/mcp.d.ts +70 -0
  6. package/dist/types/config/keybindings.d.ts +2 -2
  7. package/dist/types/config/settings-schema.d.ts +39 -2
  8. package/dist/types/deep-interview/plaintext-gate-guard.d.ts +11 -0
  9. package/dist/types/extensibility/shared-events.d.ts +1 -0
  10. package/dist/types/gjc-runtime/ralplan-runtime.d.ts +1 -1
  11. package/dist/types/lsp/types.d.ts +2 -0
  12. package/dist/types/modes/components/custom-editor.d.ts +1 -1
  13. package/dist/types/modes/components/model-selector.d.ts +2 -0
  14. package/dist/types/modes/components/status-line/git-utils.d.ts +6 -0
  15. package/dist/types/modes/theme/defaults/index.d.ts +99 -0
  16. package/dist/types/notifications/attachment-registry.d.ts +17 -0
  17. package/dist/types/notifications/chat-adapters.d.ts +9 -0
  18. package/dist/types/notifications/config.d.ts +9 -1
  19. package/dist/types/notifications/engine.d.ts +59 -0
  20. package/dist/types/notifications/managed-daemon.d.ts +48 -0
  21. package/dist/types/notifications/operator-runtime.d.ts +52 -0
  22. package/dist/types/notifications/telegram-daemon.d.ts +73 -16
  23. package/dist/types/notifications/threaded-inbound.d.ts +19 -0
  24. package/dist/types/notifications/threaded-render.d.ts +6 -1
  25. package/dist/types/notifications/topic-registry.d.ts +2 -0
  26. package/dist/types/session/agent-session.d.ts +2 -0
  27. package/dist/types/tools/composer-bash-policy.d.ts +14 -0
  28. package/dist/types/tools/fetch.d.ts +23 -0
  29. package/dist/types/tools/index.d.ts +1 -0
  30. package/dist/types/tools/telegram-send.d.ts +32 -0
  31. package/dist/types/web/insane/bridge.d.ts +103 -0
  32. package/dist/types/web/insane/url-guard.d.ts +25 -0
  33. package/dist/types/web/scrapers/types.d.ts +5 -0
  34. package/dist/types/web/scrapers/utils.d.ts +7 -1
  35. package/dist/types/web/search/provider.d.ts +18 -1
  36. package/dist/types/web/search/providers/insane.d.ts +53 -0
  37. package/dist/types/web/search/providers/text-citations.d.ts +23 -0
  38. package/dist/types/web/search/types.d.ts +12 -4
  39. package/package.json +10 -8
  40. package/scripts/verify-insane-vendor.ts +132 -0
  41. package/src/cli/args.ts +1 -1
  42. package/src/cli/fast-help.ts +1 -1
  43. package/src/cli/mcp-cli.ts +272 -0
  44. package/src/cli/notify-cli.ts +152 -5
  45. package/src/cli.ts +6 -2
  46. package/src/commands/mcp.ts +117 -0
  47. package/src/commands/team.ts +1 -1
  48. package/src/config/keybindings.ts +2 -2
  49. package/src/config/settings-schema.ts +30 -1
  50. package/src/deep-interview/plaintext-gate-guard.ts +94 -0
  51. package/src/defaults/gjc/skills/deep-interview/SKILL.md +4 -3
  52. package/src/defaults/gjc/skills/ralplan/SKILL.md +11 -4
  53. package/src/defaults/gjc/skills/team/SKILL.md +3 -2
  54. package/src/extensibility/extensions/runner.ts +1 -0
  55. package/src/extensibility/shared-events.ts +1 -0
  56. package/src/gjc-runtime/launch-tmux.ts +17 -3
  57. package/src/gjc-runtime/ledger-event-renderer.ts +1 -0
  58. package/src/gjc-runtime/ralplan-runtime.ts +2 -2
  59. package/src/gjc-runtime/tmux-common.ts +3 -1
  60. package/src/gjc-runtime/ultragoal-guard.ts +25 -8
  61. package/src/gjc-runtime/workflow-manifest.generated.json +29 -0
  62. package/src/gjc-runtime/workflow-manifest.ts +7 -2
  63. package/src/hooks/skill-state.ts +57 -0
  64. package/src/internal-urls/docs-index.generated.ts +14 -11
  65. package/src/lsp/config.ts +16 -3
  66. package/src/lsp/defaults.json +7 -0
  67. package/src/lsp/types.ts +2 -0
  68. package/src/modes/bridge/bridge-mode.ts +11 -0
  69. package/src/modes/components/custom-editor.ts +2 -0
  70. package/src/modes/components/footer.ts +2 -3
  71. package/src/modes/components/model-selector.ts +12 -0
  72. package/src/modes/components/status-line/git-utils.ts +25 -0
  73. package/src/modes/components/status-line.ts +10 -11
  74. package/src/modes/components/welcome.ts +2 -3
  75. package/src/modes/controllers/event-controller.ts +15 -0
  76. package/src/modes/controllers/selector-controller.ts +3 -0
  77. package/src/modes/interactive-mode.ts +48 -3
  78. package/src/modes/shared/agent-wire/scopes.ts +1 -1
  79. package/src/modes/theme/defaults/gruvbox-dark.json +99 -0
  80. package/src/modes/theme/defaults/index.ts +2 -0
  81. package/src/modes/utils/context-usage.ts +2 -2
  82. package/src/notifications/attachment-registry.ts +23 -0
  83. package/src/notifications/chat-adapters.ts +147 -0
  84. package/src/notifications/config.ts +23 -2
  85. package/src/notifications/engine.ts +100 -0
  86. package/src/notifications/index.ts +180 -38
  87. package/src/notifications/managed-daemon.ts +163 -0
  88. package/src/notifications/operator-runtime.ts +171 -0
  89. package/src/notifications/telegram-daemon.ts +553 -236
  90. package/src/notifications/threaded-inbound.ts +60 -4
  91. package/src/notifications/threaded-render.ts +20 -2
  92. package/src/notifications/topic-registry.ts +5 -0
  93. package/src/session/agent-session.ts +82 -51
  94. package/src/slash-commands/helpers/parse.ts +2 -1
  95. package/src/tools/bash.ts +9 -0
  96. package/src/tools/composer-bash-policy.ts +96 -0
  97. package/src/tools/fetch.ts +94 -1
  98. package/src/tools/index.ts +3 -0
  99. package/src/tools/telegram-send.ts +137 -0
  100. package/src/web/insane/bridge.ts +350 -0
  101. package/src/web/insane/url-guard.ts +159 -0
  102. package/src/web/scrapers/types.ts +143 -45
  103. package/src/web/scrapers/utils.ts +70 -19
  104. package/src/web/search/provider.ts +77 -18
  105. package/src/web/search/providers/anthropic.ts +70 -3
  106. package/src/web/search/providers/codex.ts +1 -119
  107. package/src/web/search/providers/gemini.ts +99 -0
  108. package/src/web/search/providers/insane.ts +551 -0
  109. package/src/web/search/providers/openai-compatible.ts +66 -32
  110. package/src/web/search/providers/text-citations.ts +111 -0
  111. package/src/web/search/types.ts +13 -2
  112. package/vendor/insane-search/LICENSE +21 -0
  113. package/vendor/insane-search/MANIFEST.json +24 -0
  114. package/vendor/insane-search/engine/__init__.py +23 -0
  115. package/vendor/insane-search/engine/__main__.py +128 -0
  116. package/vendor/insane-search/engine/bias_check.py +183 -0
  117. package/vendor/insane-search/engine/executor.py +254 -0
  118. package/vendor/insane-search/engine/fetch_chain.py +725 -0
  119. package/vendor/insane-search/engine/learning.py +175 -0
  120. package/vendor/insane-search/engine/phase0.py +214 -0
  121. package/vendor/insane-search/engine/safety.py +91 -0
  122. package/vendor/insane-search/engine/templates/package.json +11 -0
  123. package/vendor/insane-search/engine/templates/playwright_mobile_chrome.js +188 -0
  124. package/vendor/insane-search/engine/templates/playwright_real_chrome.js +243 -0
  125. package/vendor/insane-search/engine/tests/test_hardening.py +57 -0
  126. package/vendor/insane-search/engine/tests/test_smoke.py +152 -0
  127. package/vendor/insane-search/engine/tests/test_u1.py +200 -0
  128. package/vendor/insane-search/engine/tests/test_u4.py +131 -0
  129. package/vendor/insane-search/engine/tests/test_u5.py +163 -0
  130. package/vendor/insane-search/engine/tests/test_u7.py +124 -0
  131. package/vendor/insane-search/engine/transport.py +211 -0
  132. package/vendor/insane-search/engine/url_transforms.py +98 -0
  133. package/vendor/insane-search/engine/validators.py +331 -0
  134. package/vendor/insane-search/engine/waf_detector.py +214 -0
  135. package/vendor/insane-search/engine/waf_profiles.yaml +162 -0
@@ -0,0 +1,163 @@
1
+ import * as path from "node:path";
2
+ import type { Settings } from "../config/settings";
3
+ import { RateLimitPool } from "./rate-limit-pool";
4
+ import {
5
+ CLIENT_PING_PONG_CAPABILITY,
6
+ HEARTBEAT_INTERVAL_MS,
7
+ HEARTBEAT_TTL_MS,
8
+ NOTIFICATION_PROTOCOL_VERSION,
9
+ } from "./telegram-daemon";
10
+ import { readEndpoint } from "./telegram-reference";
11
+ import { renderThreadedFrame, type ThreadedSend } from "./threaded-render";
12
+
13
+ export interface ManagedNotificationDaemonFs {
14
+ readdir(path: string): Promise<string[]>;
15
+ }
16
+
17
+ export interface ManagedSessionSocket {
18
+ sessionId: string;
19
+ token: string;
20
+ ws: WebSocket;
21
+ pending: Map<string, { sessionId: string; actionId: string }>;
22
+ capable: boolean;
23
+ lastPongAt: number;
24
+ awaitingNonce: string | undefined;
25
+ pingTimer: ReturnType<typeof setInterval> | undefined;
26
+ }
27
+
28
+ export interface ManagedNotificationDaemonOptions {
29
+ settings: Settings;
30
+ fs: ManagedNotificationDaemonFs;
31
+ WebSocketImpl?: typeof WebSocket;
32
+ now?: () => number;
33
+ setIntervalImpl?: typeof setInterval;
34
+ clearIntervalImpl?: typeof clearInterval;
35
+ rateLimitPool?: RateLimitPool<{ send: ThreadedSend; topicId?: string }>;
36
+ }
37
+
38
+ export abstract class ManagedNotificationDaemon {
39
+ readonly sessions = new Map<string, ManagedSessionSocket>();
40
+ readonly pool: RateLimitPool<{ send: ThreadedSend; topicId?: string }>;
41
+
42
+ protected constructor(protected readonly opts: ManagedNotificationDaemonOptions) {
43
+ this.pool = opts.rateLimitPool ?? new RateLimitPool<{ send: ThreadedSend; topicId?: string }>({ now: opts.now });
44
+ }
45
+
46
+ async scanRoots(): Promise<void> {
47
+ const rootState = await this.readRoots();
48
+ for (const root of rootState) {
49
+ const dir = path.join(root, "notifications");
50
+ let files: string[];
51
+ try {
52
+ files = await this.opts.fs.readdir(dir);
53
+ } catch {
54
+ continue;
55
+ }
56
+ for (const file of files.filter(item => item.endsWith(".json"))) {
57
+ const sessionId = path.basename(file, ".json");
58
+ if (this.sessions.has(sessionId)) continue;
59
+ try {
60
+ const endpoint = readEndpoint(path.join(dir, file));
61
+ this.connectSession(sessionId, endpoint.url, endpoint.token);
62
+ } catch {}
63
+ }
64
+ }
65
+ }
66
+
67
+ connectSession(sessionId: string, url: string, token: string): ManagedSessionSocket {
68
+ const WS = this.opts.WebSocketImpl ?? WebSocket;
69
+ const ws = new WS(`${url}/?token=${encodeURIComponent(token)}`);
70
+ const session: ManagedSessionSocket = {
71
+ sessionId,
72
+ token,
73
+ ws,
74
+ pending: new Map(),
75
+ capable: false,
76
+ lastPongAt: 0,
77
+ awaitingNonce: undefined,
78
+ pingTimer: undefined,
79
+ };
80
+ this.sessions.set(sessionId, session);
81
+ ws.addEventListener("open", () => this.sendHello(session));
82
+ ws.addEventListener("message", ev => {
83
+ if (this.sessions.get(sessionId) !== session) return;
84
+ void this.handleSessionMessage(session, JSON.parse(String(ev.data))).catch(() => undefined);
85
+ });
86
+ ws.addEventListener("close", () => this.dropSession(session));
87
+ return session;
88
+ }
89
+
90
+ protected async handleSessionMessage(session: ManagedSessionSocket, msg: Record<string, unknown>): Promise<boolean> {
91
+ if (msg.type === "hello") {
92
+ const caps = Array.isArray(msg.capabilities) ? msg.capabilities : [];
93
+ if (caps.includes(CLIENT_PING_PONG_CAPABILITY)) {
94
+ session.capable = true;
95
+ this.startLiveness(session);
96
+ }
97
+ return true;
98
+ }
99
+ if (msg.type === "pong") {
100
+ if (typeof msg.nonce === "string" && msg.nonce === session.awaitingNonce) {
101
+ session.awaitingNonce = undefined;
102
+ session.lastPongAt = (this.opts.now ?? Date.now)();
103
+ }
104
+ return true;
105
+ }
106
+ return false;
107
+ }
108
+
109
+ protected renderFrame(frame: Record<string, unknown>): ThreadedSend | undefined {
110
+ return renderThreadedFrame(frame);
111
+ }
112
+
113
+ protected dropSession(session: ManagedSessionSocket): void {
114
+ const clearIntervalImpl = this.opts.clearIntervalImpl ?? clearInterval;
115
+ if (session.pingTimer) {
116
+ clearIntervalImpl(session.pingTimer);
117
+ session.pingTimer = undefined;
118
+ }
119
+ if (this.sessions.get(session.sessionId) === session) this.sessions.delete(session.sessionId);
120
+ if (session.ws.readyState !== WebSocket.CLOSED) {
121
+ try {
122
+ session.ws.close();
123
+ } catch {}
124
+ }
125
+ }
126
+
127
+ protected abstract readRoots(): Promise<string[]>;
128
+
129
+ private sendHello(session: ManagedSessionSocket): void {
130
+ if (session.ws.readyState !== WebSocket.OPEN) return;
131
+ try {
132
+ session.ws.send(
133
+ JSON.stringify({
134
+ type: "hello",
135
+ protocolVersion: NOTIFICATION_PROTOCOL_VERSION,
136
+ capabilities: [CLIENT_PING_PONG_CAPABILITY],
137
+ }),
138
+ );
139
+ } catch {}
140
+ }
141
+
142
+ private startLiveness(session: ManagedSessionSocket): void {
143
+ if (session.pingTimer) return;
144
+ const setIntervalImpl = this.opts.setIntervalImpl ?? setInterval;
145
+ const now = () => (this.opts.now ?? Date.now)();
146
+ session.lastPongAt = now();
147
+ session.pingTimer = setIntervalImpl(() => {
148
+ if (this.sessions.get(session.sessionId) !== session) return;
149
+ const t = now();
150
+ if (t - session.lastPongAt >= HEARTBEAT_TTL_MS) {
151
+ this.dropSession(session);
152
+ return;
153
+ }
154
+ if (session.ws.readyState === WebSocket.OPEN) {
155
+ const nonce = `${session.sessionId}:${t}:${Math.random().toString(36).slice(2)}`;
156
+ session.awaitingNonce = nonce;
157
+ try {
158
+ session.ws.send(JSON.stringify({ type: "ping", nonce }));
159
+ } catch {}
160
+ }
161
+ }, HEARTBEAT_INTERVAL_MS);
162
+ }
163
+ }
@@ -0,0 +1,171 @@
1
+ export interface NotificationOperatorTimerDeps {
2
+ now?: () => number;
3
+ setTimeoutImpl?: typeof setTimeout;
4
+ clearTimeoutImpl?: typeof clearTimeout;
5
+ setIntervalImpl?: typeof setInterval;
6
+ clearIntervalImpl?: typeof clearInterval;
7
+ }
8
+
9
+ export interface NotificationOperatorRuntimeState {
10
+ running: boolean;
11
+ stopRequested: boolean;
12
+ activeAbort: boolean;
13
+ }
14
+
15
+ export interface OperatorBackoffOptions {
16
+ initialMs: number;
17
+ maxMs: number;
18
+ factor?: number;
19
+ }
20
+
21
+ type OperatorIntervalHandle = number | NodeJS.Timeout;
22
+
23
+ export class OperatorBackoffPolicy {
24
+ #currentMs = 0;
25
+ #opts: OperatorBackoffOptions;
26
+
27
+ constructor(opts: OperatorBackoffOptions) {
28
+ this.#opts = opts;
29
+ }
30
+
31
+ next(): number {
32
+ this.#currentMs =
33
+ this.#currentMs === 0
34
+ ? this.#opts.initialMs
35
+ : Math.min(this.#currentMs * (this.#opts.factor ?? 2), this.#opts.maxMs);
36
+ return this.#currentMs;
37
+ }
38
+
39
+ reset(): void {
40
+ this.#currentMs = 0;
41
+ }
42
+
43
+ get currentMs(): number {
44
+ return this.#currentMs;
45
+ }
46
+ }
47
+
48
+ export interface OperatorRoute<TContext> {
49
+ name: string;
50
+ matches(event: Record<string, unknown>): boolean;
51
+ handle(context: TContext, event: Record<string, unknown>): Promise<void> | void;
52
+ }
53
+
54
+ export class OperatorEventRouter<TContext> {
55
+ readonly routes: OperatorRoute<TContext>[] = [];
56
+
57
+ add(input: OperatorRoute<TContext>): this {
58
+ this.routes.push(input);
59
+ return this;
60
+ }
61
+
62
+ async dispatch(context: TContext, event: Record<string, unknown>): Promise<boolean> {
63
+ for (const route of this.routes) {
64
+ if (!route.matches(event)) continue;
65
+ await route.handle(context, event);
66
+ return true;
67
+ }
68
+ return false;
69
+ }
70
+ }
71
+
72
+ export class NotificationOperatorRuntime {
73
+ #running = false;
74
+ #stopRequested = false;
75
+ #activeAbort: AbortController | undefined;
76
+ #intervals = new Map<string, OperatorIntervalHandle>();
77
+ #exclusive = new Set<string>();
78
+
79
+ #deps: NotificationOperatorTimerDeps;
80
+
81
+ constructor(deps: NotificationOperatorTimerDeps = {}) {
82
+ this.#deps = deps;
83
+ }
84
+
85
+ get state(): NotificationOperatorRuntimeState {
86
+ return {
87
+ running: this.#running,
88
+ stopRequested: this.#stopRequested,
89
+ activeAbort: this.#activeAbort !== undefined,
90
+ };
91
+ }
92
+
93
+ start(): void {
94
+ this.#running = true;
95
+ this.#stopRequested = false;
96
+ }
97
+
98
+ stop(): void {
99
+ this.#running = false;
100
+ }
101
+
102
+ requestStop(): void {
103
+ this.#stopRequested = true;
104
+ this.#running = false;
105
+ this.#activeAbort?.abort();
106
+ }
107
+
108
+ get running(): boolean {
109
+ return this.#running;
110
+ }
111
+
112
+ get stopRequested(): boolean {
113
+ return this.#stopRequested;
114
+ }
115
+
116
+ createAbortController(): AbortController {
117
+ this.#activeAbort = new AbortController();
118
+ return this.#activeAbort;
119
+ }
120
+
121
+ clearAbortController(controller: AbortController): void {
122
+ if (this.#activeAbort === controller) this.#activeAbort = undefined;
123
+ }
124
+
125
+ startInterval(name: string, intervalMs: number, tick: () => void): void {
126
+ if (this.#intervals.has(name)) return;
127
+ const setIntervalImpl = this.#deps.setIntervalImpl ?? setInterval;
128
+ this.#intervals.set(name, setIntervalImpl(tick, intervalMs) as OperatorIntervalHandle);
129
+ }
130
+
131
+ stopInterval(name: string): void {
132
+ const timer = this.#intervals.get(name);
133
+ if (!timer) return;
134
+ const clearIntervalImpl = this.#deps.clearIntervalImpl ?? clearInterval;
135
+ clearIntervalImpl(timer);
136
+ this.#intervals.delete(name);
137
+ }
138
+
139
+ stopAllIntervals(): void {
140
+ for (const name of [...this.#intervals.keys()]) this.stopInterval(name);
141
+ }
142
+
143
+ async runExclusive(name: string, fn: () => Promise<void>): Promise<void> {
144
+ if (this.#exclusive.has(name)) return;
145
+ this.#exclusive.add(name);
146
+ try {
147
+ await fn();
148
+ } finally {
149
+ this.#exclusive.delete(name);
150
+ }
151
+ }
152
+
153
+ sleep(ms: number, signal?: AbortSignal): Promise<void> {
154
+ return new Promise<void>(resolve => {
155
+ if (signal?.aborted) return resolve();
156
+ const timer = (this.#deps.setTimeoutImpl ?? setTimeout)(() => resolve(), ms);
157
+ signal?.addEventListener(
158
+ "abort",
159
+ () => {
160
+ (this.#deps.clearTimeoutImpl ?? clearTimeout)(timer);
161
+ resolve();
162
+ },
163
+ { once: true },
164
+ );
165
+ });
166
+ }
167
+
168
+ now(): number {
169
+ return (this.#deps.now ?? Date.now)();
170
+ }
171
+ }