@0xmaxma/claude-gateway 2.1.9 → 2.1.11

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 (271) hide show
  1. package/config.template.json +4 -0
  2. package/dist/agent/runner.d.ts +93 -6
  3. package/dist/agent/runner.d.ts.map +1 -1
  4. package/dist/agent/runner.js +342 -108
  5. package/dist/agent/runner.js.map +1 -1
  6. package/dist/api/async-guard.d.ts +13 -0
  7. package/dist/api/async-guard.d.ts.map +1 -0
  8. package/dist/api/async-guard.js +38 -0
  9. package/dist/api/async-guard.js.map +1 -0
  10. package/dist/api/auth.d.ts +5 -0
  11. package/dist/api/auth.d.ts.map +1 -1
  12. package/dist/api/auth.js +3 -0
  13. package/dist/api/auth.js.map +1 -1
  14. package/dist/api/browser-bindings-router.d.ts.map +1 -1
  15. package/dist/api/browser-bindings-router.js +2 -0
  16. package/dist/api/browser-bindings-router.js.map +1 -1
  17. package/dist/api/capabilities.d.ts +47 -2
  18. package/dist/api/capabilities.d.ts.map +1 -1
  19. package/dist/api/capabilities.js +51 -8
  20. package/dist/api/capabilities.js.map +1 -1
  21. package/dist/api/files-router.d.ts +23 -0
  22. package/dist/api/files-router.d.ts.map +1 -0
  23. package/dist/api/files-router.js +102 -0
  24. package/dist/api/files-router.js.map +1 -0
  25. package/dist/api/gateway-router.d.ts +4 -2
  26. package/dist/api/gateway-router.d.ts.map +1 -1
  27. package/dist/api/gateway-router.js +20 -2
  28. package/dist/api/gateway-router.js.map +1 -1
  29. package/dist/api/git-router.d.ts +4 -0
  30. package/dist/api/git-router.d.ts.map +1 -0
  31. package/dist/api/git-router.js +51 -0
  32. package/dist/api/git-router.js.map +1 -0
  33. package/dist/api/manifest-sources.d.ts.map +1 -1
  34. package/dist/api/manifest-sources.js +6 -0
  35. package/dist/api/manifest-sources.js.map +1 -1
  36. package/dist/api/processes-router.d.ts +28 -0
  37. package/dist/api/processes-router.d.ts.map +1 -0
  38. package/dist/api/processes-router.js +179 -0
  39. package/dist/api/processes-router.js.map +1 -0
  40. package/dist/api/router.d.ts +41 -1
  41. package/dist/api/router.d.ts.map +1 -1
  42. package/dist/api/router.js +112 -25
  43. package/dist/api/router.js.map +1 -1
  44. package/dist/api/voice-router.d.ts.map +1 -1
  45. package/dist/api/voice-router.js +2 -0
  46. package/dist/api/voice-router.js.map +1 -1
  47. package/dist/automation/browser-outcome.d.ts +3 -1
  48. package/dist/automation/browser-outcome.d.ts.map +1 -1
  49. package/dist/automation/browser-outcome.js +2 -2
  50. package/dist/automation/browser-outcome.js.map +1 -1
  51. package/dist/automation/command-speech.d.ts +9 -1
  52. package/dist/automation/command-speech.d.ts.map +1 -1
  53. package/dist/automation/command-speech.js +18 -0
  54. package/dist/automation/command-speech.js.map +1 -1
  55. package/dist/automation/command-steps.d.ts +2 -0
  56. package/dist/automation/command-steps.d.ts.map +1 -1
  57. package/dist/automation/command-steps.js +34 -2
  58. package/dist/automation/command-steps.js.map +1 -1
  59. package/dist/automation/computer-command.d.ts +1 -0
  60. package/dist/automation/computer-command.d.ts.map +1 -1
  61. package/dist/automation/computer-command.js +31 -5
  62. package/dist/automation/computer-command.js.map +1 -1
  63. package/dist/automation/computer-outcome.d.ts +26 -3
  64. package/dist/automation/computer-outcome.d.ts.map +1 -1
  65. package/dist/automation/computer-outcome.js +183 -13
  66. package/dist/automation/computer-outcome.js.map +1 -1
  67. package/dist/automation/computer-policy.d.ts +10 -1
  68. package/dist/automation/computer-policy.d.ts.map +1 -1
  69. package/dist/automation/computer-policy.js +20 -6
  70. package/dist/automation/computer-policy.js.map +1 -1
  71. package/dist/automation/computer-use.d.ts +34 -0
  72. package/dist/automation/computer-use.d.ts.map +1 -1
  73. package/dist/automation/computer-use.js +211 -17
  74. package/dist/automation/computer-use.js.map +1 -1
  75. package/dist/automation/direct-command.d.ts +8 -0
  76. package/dist/automation/direct-command.d.ts.map +1 -1
  77. package/dist/automation/direct-command.js +12 -0
  78. package/dist/automation/direct-command.js.map +1 -1
  79. package/dist/automation/model-choice-evaluator.d.ts +3 -0
  80. package/dist/automation/model-choice-evaluator.d.ts.map +1 -1
  81. package/dist/automation/model-choice-evaluator.js +3 -1
  82. package/dist/automation/model-choice-evaluator.js.map +1 -1
  83. package/dist/automation/vision-decider.d.ts +4 -2
  84. package/dist/automation/vision-decider.d.ts.map +1 -1
  85. package/dist/automation/vision-decider.js +69 -15
  86. package/dist/automation/vision-decider.js.map +1 -1
  87. package/dist/build-provenance.json +4 -4
  88. package/dist/cli/redact.d.ts +1 -0
  89. package/dist/cli/redact.d.ts.map +1 -1
  90. package/dist/cli/redact.js +12 -0
  91. package/dist/cli/redact.js.map +1 -1
  92. package/dist/config/loader.d.ts +5 -0
  93. package/dist/config/loader.d.ts.map +1 -1
  94. package/dist/config/loader.js +121 -0
  95. package/dist/config/loader.js.map +1 -1
  96. package/dist/config/reload-policy.d.ts.map +1 -1
  97. package/dist/config/reload-policy.js +1 -0
  98. package/dist/config/reload-policy.js.map +1 -1
  99. package/dist/config/watcher.d.ts.map +1 -1
  100. package/dist/config/watcher.js +1 -0
  101. package/dist/config/watcher.js.map +1 -1
  102. package/dist/files/config.d.ts +6 -0
  103. package/dist/files/config.d.ts.map +1 -0
  104. package/dist/files/config.js +15 -0
  105. package/dist/files/config.js.map +1 -0
  106. package/dist/files/delete.d.ts +27 -0
  107. package/dist/files/delete.d.ts.map +1 -0
  108. package/dist/files/delete.js +143 -0
  109. package/dist/files/delete.js.map +1 -0
  110. package/dist/files/fs.d.ts +70 -0
  111. package/dist/files/fs.d.ts.map +1 -0
  112. package/dist/files/fs.js +319 -0
  113. package/dist/files/fs.js.map +1 -0
  114. package/dist/files/holds.d.ts +11 -0
  115. package/dist/files/holds.d.ts.map +1 -0
  116. package/dist/files/holds.js +20 -0
  117. package/dist/files/holds.js.map +1 -0
  118. package/dist/files/paths.d.ts +26 -0
  119. package/dist/files/paths.d.ts.map +1 -0
  120. package/dist/files/paths.js +112 -0
  121. package/dist/files/paths.js.map +1 -0
  122. package/dist/files/session-cwd.d.ts +8 -0
  123. package/dist/files/session-cwd.d.ts.map +1 -0
  124. package/dist/files/session-cwd.js +139 -0
  125. package/dist/files/session-cwd.js.map +1 -0
  126. package/dist/git/read.d.ts +25 -0
  127. package/dist/git/read.d.ts.map +1 -0
  128. package/dist/git/read.js +166 -0
  129. package/dist/git/read.js.map +1 -0
  130. package/dist/git/runner.d.ts +46 -0
  131. package/dist/git/runner.d.ts.map +1 -0
  132. package/dist/git/runner.js +176 -0
  133. package/dist/git/runner.js.map +1 -0
  134. package/dist/git/status.d.ts +119 -0
  135. package/dist/git/status.d.ts.map +1 -0
  136. package/dist/git/status.js +273 -0
  137. package/dist/git/status.js.map +1 -0
  138. package/dist/index.js +7 -2
  139. package/dist/index.js.map +1 -1
  140. package/dist/jev/browser-contract.d.ts +3 -0
  141. package/dist/jev/browser-contract.d.ts.map +1 -1
  142. package/dist/jev/browser-contract.js +6 -0
  143. package/dist/jev/browser-contract.js.map +1 -1
  144. package/dist/orchestration/agent-tool-schemas.d.ts +18 -0
  145. package/dist/orchestration/agent-tool-schemas.d.ts.map +1 -1
  146. package/dist/orchestration/agent-tool-schemas.js +11 -3
  147. package/dist/orchestration/agent-tool-schemas.js.map +1 -1
  148. package/dist/orchestration/bridge.d.ts.map +1 -1
  149. package/dist/orchestration/bridge.js +26 -5
  150. package/dist/orchestration/bridge.js.map +1 -1
  151. package/dist/orchestration/browser-routing.d.ts.map +1 -1
  152. package/dist/orchestration/browser-routing.js +2 -1
  153. package/dist/orchestration/browser-routing.js.map +1 -1
  154. package/dist/orchestration/computer-decisions.d.ts +1 -1
  155. package/dist/orchestration/computer-decisions.d.ts.map +1 -1
  156. package/dist/orchestration/computer-decisions.js +21 -7
  157. package/dist/orchestration/computer-decisions.js.map +1 -1
  158. package/dist/orchestration/computer-live.d.ts +62 -0
  159. package/dist/orchestration/computer-live.d.ts.map +1 -0
  160. package/dist/orchestration/computer-live.js +126 -0
  161. package/dist/orchestration/computer-live.js.map +1 -0
  162. package/dist/orchestration/container-tool-schemas.d.ts.map +1 -1
  163. package/dist/orchestration/container-tool-schemas.js +3 -0
  164. package/dist/orchestration/container-tool-schemas.js.map +1 -1
  165. package/dist/orchestration/decisions.d.ts +3 -1
  166. package/dist/orchestration/decisions.d.ts.map +1 -1
  167. package/dist/orchestration/decisions.js +4 -2
  168. package/dist/orchestration/decisions.js.map +1 -1
  169. package/dist/orchestration/gateway-tasks/browser.d.ts +1 -1
  170. package/dist/orchestration/gateway-tasks/browser.d.ts.map +1 -1
  171. package/dist/orchestration/gateway-tasks/browser.js +4 -3
  172. package/dist/orchestration/gateway-tasks/browser.js.map +1 -1
  173. package/dist/orchestration/gateway-tasks/computer-context.d.ts +4 -1
  174. package/dist/orchestration/gateway-tasks/computer-context.d.ts.map +1 -1
  175. package/dist/orchestration/gateway-tasks/computer-context.js +3 -1
  176. package/dist/orchestration/gateway-tasks/computer-context.js.map +1 -1
  177. package/dist/orchestration/gateway-tasks/computer.d.ts +78 -15
  178. package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -1
  179. package/dist/orchestration/gateway-tasks/computer.js +298 -31
  180. package/dist/orchestration/gateway-tasks/computer.js.map +1 -1
  181. package/dist/orchestration/gateway-tasks/controller.d.ts +14 -2
  182. package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -1
  183. package/dist/orchestration/gateway-tasks/controller.js +63 -2
  184. package/dist/orchestration/gateway-tasks/controller.js.map +1 -1
  185. package/dist/orchestration/notification-mailbox.js +3 -3
  186. package/dist/orchestration/notification-mailbox.js.map +1 -1
  187. package/dist/orchestration/process-turn.d.ts.map +1 -1
  188. package/dist/orchestration/process-turn.js +4 -1
  189. package/dist/orchestration/process-turn.js.map +1 -1
  190. package/dist/orchestration/response-errors.d.ts.map +1 -1
  191. package/dist/orchestration/response-errors.js +2 -0
  192. package/dist/orchestration/response-errors.js.map +1 -1
  193. package/dist/orchestration/runtime.d.ts +32 -2
  194. package/dist/orchestration/runtime.d.ts.map +1 -1
  195. package/dist/orchestration/runtime.js +106 -10
  196. package/dist/orchestration/runtime.js.map +1 -1
  197. package/dist/orchestration/task-controls.d.ts +8 -0
  198. package/dist/orchestration/task-controls.d.ts.map +1 -1
  199. package/dist/orchestration/task-controls.js +3 -2
  200. package/dist/orchestration/task-controls.js.map +1 -1
  201. package/dist/orchestration/tasks/automation-session.d.ts +42 -11
  202. package/dist/orchestration/tasks/automation-session.d.ts.map +1 -1
  203. package/dist/orchestration/tasks/automation-session.js +101 -21
  204. package/dist/orchestration/tasks/automation-session.js.map +1 -1
  205. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  206. package/dist/orchestration/tasks/driver.js +19 -1
  207. package/dist/orchestration/tasks/driver.js.map +1 -1
  208. package/dist/orchestration/tasks/service.d.ts +48 -2
  209. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  210. package/dist/orchestration/tasks/service.js +165 -16
  211. package/dist/orchestration/tasks/service.js.map +1 -1
  212. package/dist/orchestration/telegram-tool-status.d.ts.map +1 -1
  213. package/dist/orchestration/telegram-tool-status.js +2 -0
  214. package/dist/orchestration/telegram-tool-status.js.map +1 -1
  215. package/dist/orchestration/types.d.ts +21 -0
  216. package/dist/orchestration/types.d.ts.map +1 -1
  217. package/dist/orchestration/types.js.map +1 -1
  218. package/dist/processes/listeners.d.ts +41 -0
  219. package/dist/processes/listeners.d.ts.map +1 -0
  220. package/dist/processes/listeners.js +140 -0
  221. package/dist/processes/listeners.js.map +1 -0
  222. package/dist/processes/start.d.ts +39 -0
  223. package/dist/processes/start.d.ts.map +1 -0
  224. package/dist/processes/start.js +208 -0
  225. package/dist/processes/start.js.map +1 -0
  226. package/dist/processes/stop.d.ts +37 -0
  227. package/dist/processes/stop.d.ts.map +1 -0
  228. package/dist/processes/stop.js +94 -0
  229. package/dist/processes/stop.js.map +1 -0
  230. package/dist/session/cwd.d.ts +65 -0
  231. package/dist/session/cwd.d.ts.map +1 -0
  232. package/dist/session/cwd.js +24 -0
  233. package/dist/session/cwd.js.map +1 -0
  234. package/dist/session/process.d.ts +17 -0
  235. package/dist/session/process.d.ts.map +1 -1
  236. package/dist/session/process.js +58 -3
  237. package/dist/session/process.js.map +1 -1
  238. package/dist/session/runtime-profile.d.ts +4 -0
  239. package/dist/session/runtime-profile.d.ts.map +1 -1
  240. package/dist/session/runtime-profile.js +1 -0
  241. package/dist/session/runtime-profile.js.map +1 -1
  242. package/dist/session/store.d.ts +13 -1
  243. package/dist/session/store.d.ts.map +1 -1
  244. package/dist/session/store.js +50 -4
  245. package/dist/session/store.js.map +1 -1
  246. package/dist/types.d.ts +19 -0
  247. package/dist/types.d.ts.map +1 -1
  248. package/dist/ui/voice-call-client.d.ts +3 -0
  249. package/dist/ui/voice-call-client.d.ts.map +1 -1
  250. package/dist/ui/voice-call-client.js +10 -1
  251. package/dist/ui/voice-call-client.js.map +1 -1
  252. package/dist/utils/paths.d.ts +5 -0
  253. package/dist/utils/paths.d.ts.map +1 -1
  254. package/dist/utils/paths.js +15 -0
  255. package/dist/utils/paths.js.map +1 -1
  256. package/dist/utils/result.d.ts +16 -0
  257. package/dist/utils/result.d.ts.map +1 -0
  258. package/dist/utils/result.js +8 -0
  259. package/dist/utils/result.js.map +1 -0
  260. package/dist/voice/errors.js +1 -1
  261. package/dist/voice/errors.js.map +1 -1
  262. package/dist/voice/providers/elevenlabs-tts.d.ts.map +1 -1
  263. package/dist/voice/providers/elevenlabs-tts.js +17 -1
  264. package/dist/voice/providers/elevenlabs-tts.js.map +1 -1
  265. package/dist/voice/providers/socket.js +25 -6
  266. package/dist/voice/providers/socket.js.map +1 -1
  267. package/dist/voice/session.js +3 -2
  268. package/dist/voice/session.js.map +1 -1
  269. package/mcp/server.ts +1 -1
  270. package/mcp/tools/tasks/module.ts +2 -1
  271. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ export type GitHost = 'github' | 'gitlab' | 'bitbucket' | 'other';
2
+ export type GitSync = 'in_sync' | 'ahead' | 'behind' | 'diverged' | 'no_upstream' | 'upstream_gone' | 'upstream_mismatch' | 'no_remote' | 'detached';
3
+ export type GitChangeKind = 'added' | 'modified' | 'deleted' | 'renamed' | 'copied' | 'type_changed' | 'untracked' | 'conflicted';
4
+ export interface GitFileChange {
5
+ path: string;
6
+ orig_path?: string;
7
+ staged: GitChangeKind | null;
8
+ unstaged: GitChangeKind | null;
9
+ }
10
+ export interface GitRemote {
11
+ name: string;
12
+ url: string;
13
+ host: GitHost;
14
+ web_url: string | null;
15
+ }
16
+ export type GitOperation = 'none' | 'merge' | 'rebase' | 'cherry_pick' | 'revert' | 'bisect';
17
+ export interface GitCommitInfo {
18
+ sha: string;
19
+ subject: string;
20
+ author: string;
21
+ committed_at: string;
22
+ }
23
+ export interface GitStatus {
24
+ branch: string | null;
25
+ detached: boolean;
26
+ has_commits: boolean;
27
+ upstream: string | null;
28
+ ahead: number;
29
+ behind: number;
30
+ sync: GitSync;
31
+ remote: GitRemote | null;
32
+ changes: GitFileChange[];
33
+ change_count: number;
34
+ conflicted_count: number;
35
+ truncated: boolean;
36
+ last_commit: GitCommitInfo | null;
37
+ operation: GitOperation;
38
+ }
39
+ export interface GitSummary {
40
+ branch: string | null;
41
+ detached: boolean;
42
+ sync: GitSync;
43
+ ahead: number;
44
+ behind: number;
45
+ change_count: number;
46
+ conflicted_count: number;
47
+ remote_host: GitHost | null;
48
+ }
49
+ /** What `git status --porcelain=v2 --branch -z` says, before anything else is joined in. */
50
+ export interface ParsedStatus {
51
+ /** null for an unborn branch (`branch.oid (initial)`). */
52
+ oid: string | null;
53
+ /** null when detached. */
54
+ head: string | null;
55
+ upstream: string | null;
56
+ /**
57
+ * The branch has commits and an upstream setting, but no remote-tracking branch: deleted and pruned, or never
58
+ * fetched, which porcelain cannot tell apart. Never set on an unborn branch, where git prints no `branch.ab` either way.
59
+ */
60
+ upstreamGone: boolean;
61
+ ahead: number;
62
+ behind: number;
63
+ changes: GitFileChange[];
64
+ }
65
+ /** The repo config status needs: remotes and branch tracking. */
66
+ export interface RepoConfig {
67
+ remotes: Array<{
68
+ name: string;
69
+ url: string;
70
+ }>;
71
+ /** `branch.<name>.remote` and `branch.<name>.merge`, keyed by branch name. */
72
+ branches: Record<string, {
73
+ remote?: string;
74
+ merge?: string;
75
+ }>;
76
+ }
77
+ export declare const CHANGES_LIMIT = 200;
78
+ export declare function parseStatusV2(raw: string): ParsedStatus;
79
+ export interface ConfigList {
80
+ config: RepoConfig;
81
+ /** Every `filter.*` key the repository's own config defines, directly or through an include, as git printed it. */
82
+ filterKeys: string[];
83
+ }
84
+ /**
85
+ * True when a repository-scope `filter.*` key in the raw `git config -z` output is not valid UTF-8. Environment values
86
+ * are UTF-8 strings, so such a key cannot be passed back byte for byte, and a lossy copy would blank a different
87
+ * driver. The caller refuses the repository instead.
88
+ */
89
+ export declare function hasUndecodableFilterKey(raw: Buffer): boolean;
90
+ /** What `git config --list -z --show-scope` prints: `scope NUL key NL value NUL` per entry, a valueless key without the NL. */
91
+ export declare function parseConfigList(raw: string): ConfigList;
92
+ export declare function deriveSync(s: {
93
+ detached: boolean;
94
+ hasCommits: boolean;
95
+ upstream: string | null;
96
+ upstreamGone: boolean;
97
+ upstreamMismatch: boolean;
98
+ ahead: number;
99
+ behind: number;
100
+ hasRemote: boolean;
101
+ }): GitSync;
102
+ /** `https://user:token@host/x?token=s` becomes `https://host/x?token=[redacted]`, anywhere in `text`. */
103
+ export declare function redactCredentials(text: string): string;
104
+ /** The remote's hostname alone, or null when it is not a plain DNS name. */
105
+ export declare function remoteHostname(url: string): string | null;
106
+ export declare function describeRemote(name: string, rawUrl: string): GitRemote;
107
+ /** The upstream's remote, else "origin", else the only remote. */
108
+ export declare function pickRemote(cfg: RepoConfig, branch: string | null): {
109
+ name: string;
110
+ url: string;
111
+ } | null;
112
+ export declare function buildStatus(input: {
113
+ parsed: ParsedStatus;
114
+ config: RepoConfig;
115
+ lastCommit: GitCommitInfo | null;
116
+ operation: GitOperation;
117
+ }): GitStatus;
118
+ export declare function toSummary(s: GitStatus): GitSummary;
119
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/git/status.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAElE,MAAM,MAAM,OAAO,GACf,SAAS,GACT,OAAO,GACP,QAAQ,GACR,UAAU,GACV,aAAa,GACb,eAAe,GACf,mBAAmB,GACnB,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,UAAU,GACV,SAAS,GACT,SAAS,GACT,QAAQ,GACR,cAAc,GACd,WAAW,GACX,YAAY,CAAC;AAEjB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7F,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACx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E,YAAY,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,YAAY,CAAC;CACzB,GAAG,SAAS,CA8BZ;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,UAAU,CAWlD"}
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHANGES_LIMIT = void 0;
4
+ exports.parseStatusV2 = parseStatusV2;
5
+ exports.hasUndecodableFilterKey = hasUndecodableFilterKey;
6
+ exports.parseConfigList = parseConfigList;
7
+ exports.deriveSync = deriveSync;
8
+ exports.redactCredentials = redactCredentials;
9
+ exports.remoteHostname = remoteHostname;
10
+ exports.describeRemote = describeRemote;
11
+ exports.pickRemote = pickRemote;
12
+ exports.buildStatus = buildStatus;
13
+ exports.toSummary = toSummary;
14
+ exports.CHANGES_LIMIT = 200;
15
+ const KIND_BY_CODE = {
16
+ '.': null,
17
+ M: 'modified',
18
+ T: 'type_changed',
19
+ A: 'added',
20
+ D: 'deleted',
21
+ R: 'renamed',
22
+ C: 'copied',
23
+ U: 'conflicted',
24
+ };
25
+ function kindOf(code) {
26
+ return code in KIND_BY_CODE ? KIND_BY_CODE[code] : 'modified';
27
+ }
28
+ /** Splits off the first `n` space-separated fields; the remainder is the path, which may contain spaces. */
29
+ function fields(record, n) {
30
+ const parts = [];
31
+ let at = 0;
32
+ for (let i = 0; i < n; i++) {
33
+ const sp = record.indexOf(' ', at);
34
+ parts.push(record.slice(at, sp));
35
+ at = sp + 1;
36
+ }
37
+ return { parts, rest: record.slice(at) };
38
+ }
39
+ function parseStatusV2(raw) {
40
+ const out = { oid: null, head: null, upstream: null, upstreamGone: false, ahead: 0, behind: 0, changes: [] };
41
+ let sawAheadBehind = false;
42
+ const records = raw.split('\0');
43
+ for (let i = 0; i < records.length; i++) {
44
+ const rec = records[i];
45
+ if (rec === '')
46
+ continue;
47
+ switch (rec[0]) {
48
+ case '#': {
49
+ const { parts, rest } = fields(rec, 2);
50
+ const key = parts[1];
51
+ if (key === 'branch.oid')
52
+ out.oid = rest === '(initial)' ? null : rest;
53
+ else if (key === 'branch.head')
54
+ out.head = rest === '(detached)' ? null : rest;
55
+ else if (key === 'branch.upstream')
56
+ out.upstream = rest;
57
+ else if (key === 'branch.ab') {
58
+ const m = /^\+(\d+) -(\d+)$/.exec(rest);
59
+ sawAheadBehind = true;
60
+ if (m)
61
+ [out.ahead, out.behind] = [Number(m[1]), Number(m[2])];
62
+ }
63
+ break;
64
+ }
65
+ case '1': {
66
+ const { parts, rest } = fields(rec, 8);
67
+ out.changes.push({ path: rest, staged: kindOf(parts[1][0]), unstaged: kindOf(parts[1][1]) });
68
+ break;
69
+ }
70
+ case '2': {
71
+ const { parts, rest } = fields(rec, 9);
72
+ // The original path is the next NUL-separated record.
73
+ out.changes.push({ path: rest, orig_path: records[++i], staged: kindOf(parts[1][0]), unstaged: kindOf(parts[1][1]) });
74
+ break;
75
+ }
76
+ case 'u': {
77
+ const { rest } = fields(rec, 10);
78
+ out.changes.push({ path: rest, staged: 'conflicted', unstaged: 'conflicted' });
79
+ break;
80
+ }
81
+ case '?':
82
+ out.changes.push({ path: rec.slice(2), staged: null, unstaged: 'untracked' });
83
+ break;
84
+ // '!' (ignored) is never requested.
85
+ }
86
+ }
87
+ out.upstreamGone = out.oid !== null && out.upstream !== null && !sawAheadBehind;
88
+ return out;
89
+ }
90
+ /** Config scopes whose files the repository controls. Git reports an included file under the scope of the file that includes it. */
91
+ const REPO_SCOPES = new Set(['local', 'worktree']);
92
+ /**
93
+ * True when a repository-scope `filter.*` key in the raw `git config -z` output is not valid UTF-8. Environment values
94
+ * are UTF-8 strings, so such a key cannot be passed back byte for byte, and a lossy copy would blank a different
95
+ * driver. The caller refuses the repository instead.
96
+ */
97
+ function hasUndecodableFilterKey(raw) {
98
+ const strict = new TextDecoder('utf-8', { fatal: true });
99
+ const fields = [];
100
+ for (let start = 0; start <= raw.length;) {
101
+ const end = raw.indexOf(0, start);
102
+ fields.push(raw.subarray(start, end < 0 ? raw.length : end));
103
+ if (end < 0)
104
+ break;
105
+ start = end + 1;
106
+ }
107
+ for (let i = 0; i + 1 < fields.length; i += 2) {
108
+ if (!REPO_SCOPES.has(fields[i].toString('latin1')))
109
+ continue;
110
+ const entry = fields[i + 1];
111
+ const nl = entry.indexOf(10);
112
+ const key = nl < 0 ? entry : entry.subarray(0, nl);
113
+ if (!key.subarray(0, 7).equals(Buffer.from('filter.')))
114
+ continue;
115
+ try {
116
+ strict.decode(key);
117
+ }
118
+ catch {
119
+ return true;
120
+ }
121
+ }
122
+ return false;
123
+ }
124
+ /** What `git config --list -z --show-scope` prints: `scope NUL key NL value NUL` per entry, a valueless key without the NL. */
125
+ function parseConfigList(raw) {
126
+ var _a, _b;
127
+ const cfg = { remotes: [], branches: {} };
128
+ const filters = new Set();
129
+ const fields = raw.split('\0');
130
+ for (let i = 0; i + 1 < fields.length; i += 2) {
131
+ const scope = fields[i];
132
+ const entry = fields[i + 1];
133
+ const nl = entry.indexOf('\n');
134
+ const key = nl < 0 ? entry : entry.slice(0, nl);
135
+ const value = nl < 0 ? '' : entry.slice(nl + 1);
136
+ let m;
137
+ if ((m = /^remote\.(.+)\.url$/.exec(key))) {
138
+ if (!cfg.remotes.some((r) => r.name === m[1]))
139
+ cfg.remotes.push({ name: m[1], url: value });
140
+ }
141
+ else if ((m = /^branch\.(.+)\.(remote|merge)$/.exec(key))) {
142
+ ((_a = cfg.branches)[_b = m[1]] ?? (_a[_b] = {}))[m[2]] = value;
143
+ }
144
+ else if (REPO_SCOPES.has(scope) && key.startsWith('filter.')) {
145
+ filters.add(key);
146
+ }
147
+ }
148
+ return { config: cfg, filterKeys: [...filters] };
149
+ }
150
+ function deriveSync(s) {
151
+ if (s.detached)
152
+ return 'detached';
153
+ if (s.upstream === null)
154
+ return s.hasRemote ? 'no_upstream' : 'no_remote';
155
+ if (s.upstreamMismatch)
156
+ return 'upstream_mismatch';
157
+ if (s.upstreamGone)
158
+ return 'upstream_gone';
159
+ // Unborn and nothing online to pull: in sync would claim it is published.
160
+ if (!s.hasCommits && s.behind === 0)
161
+ return 'no_upstream';
162
+ if (s.ahead > 0 && s.behind > 0)
163
+ return 'diverged';
164
+ if (s.ahead > 0)
165
+ return 'ahead';
166
+ if (s.behind > 0)
167
+ return 'behind';
168
+ return 'in_sync';
169
+ }
170
+ const SECRET_PARAM = /([?&#;](?:[\w.-]*(?:token|password|passwd|secret|sig|signature|auth|credential)|api[_-]?key|key)=)[^&#\s'"]+/gi;
171
+ /** `https://user:token@host/x?token=s` becomes `https://host/x?token=[redacted]`, anywhere in `text`. */
172
+ function redactCredentials(text) {
173
+ return text.replace(/:\/\/[^\s/]*@/g, '://').replace(SECRET_PARAM, '$1[redacted]');
174
+ }
175
+ const KNOWN_HOSTS = {
176
+ 'github.com': 'github',
177
+ 'gitlab.com': 'gitlab',
178
+ 'bitbucket.org': 'bitbucket',
179
+ };
180
+ /** Host and `owner/repo` path from an https, ssh:// or scp-style (`git@host:owner/repo`) URL. */
181
+ function hostAndPath(url) {
182
+ const scheme = /^[a-z][a-z0-9+.-]*:\/\/(?:[^/@]*@)?([^/:]+)(?::\d+)?\/(.*)$/i.exec(url);
183
+ if (scheme)
184
+ return { host: scheme[1].toLowerCase(), repoPath: scheme[2] };
185
+ const scp = /^(?:[^@/]+@)?([^/:]+):(?!\/)(.*)$/.exec(url);
186
+ if (scp)
187
+ return { host: scp[1].toLowerCase(), repoPath: scp[2] };
188
+ return null;
189
+ }
190
+ /** The remote's hostname alone, or null when it is not a plain DNS name. */
191
+ function remoteHostname(url) {
192
+ const host = hostAndPath(redactCredentials(url))?.host;
193
+ return host && /^[a-z0-9.-]+$/.test(host) ? host : null;
194
+ }
195
+ function describeRemote(name, rawUrl) {
196
+ const url = redactCredentials(rawUrl);
197
+ const parsed = hostAndPath(url);
198
+ const host = (parsed && KNOWN_HOSTS[parsed.host]) ?? 'other';
199
+ const repoPath = parsed?.repoPath.replace(/[?#].*$/, '').replace(/\.git$/, '').replace(/\/+$/, '');
200
+ const web_url = host !== 'other' && repoPath ? `https://${parsed.host}/${repoPath}` : null;
201
+ return { name, url, host, web_url };
202
+ }
203
+ /** The upstream's remote, else "origin", else the only remote. */
204
+ function pickRemote(cfg, branch) {
205
+ const upstreamRemote = branch ? cfg.branches[branch]?.remote : undefined;
206
+ return (cfg.remotes.find((r) => r.name === upstreamRemote) ??
207
+ cfg.remotes.find((r) => r.name === 'origin') ??
208
+ (cfg.remotes.length === 1 ? cfg.remotes[0] : null));
209
+ }
210
+ /**
211
+ * The upstream is not a same-named branch on a configured remote: `checkout -b feature origin/main`, or a branch
212
+ * tracking a local one (remote "."). Publishing there would move someone else's branch.
213
+ */
214
+ function tracksAnotherBranch(config, head, upstream) {
215
+ if (head === null || upstream === null)
216
+ return false;
217
+ const tracking = config.branches[head];
218
+ return tracking?.merge !== `refs/heads/${head}` || !config.remotes.some((r) => r.name === tracking.remote);
219
+ }
220
+ /** Sort rank: conflicted, staged, unstaged, untracked. */
221
+ function rank(c) {
222
+ if (c.staged === 'conflicted')
223
+ return 0;
224
+ if (c.staged !== null)
225
+ return 1;
226
+ if (c.unstaged !== 'untracked')
227
+ return 2;
228
+ return 3;
229
+ }
230
+ function buildStatus(input) {
231
+ const { parsed, config } = input;
232
+ const detached = parsed.head === null;
233
+ const picked = pickRemote(config, parsed.head);
234
+ const sorted = [...parsed.changes].sort((a, b) => rank(a) - rank(b) || (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
235
+ return {
236
+ branch: parsed.head,
237
+ detached,
238
+ has_commits: parsed.oid !== null,
239
+ upstream: parsed.upstream,
240
+ ahead: parsed.ahead,
241
+ behind: parsed.behind,
242
+ sync: deriveSync({
243
+ detached,
244
+ hasCommits: parsed.oid !== null,
245
+ upstream: parsed.upstream,
246
+ upstreamGone: parsed.upstreamGone,
247
+ upstreamMismatch: tracksAnotherBranch(config, parsed.head, parsed.upstream),
248
+ ahead: parsed.ahead,
249
+ behind: parsed.behind,
250
+ hasRemote: config.remotes.length > 0,
251
+ }),
252
+ remote: picked ? describeRemote(picked.name, picked.url) : null,
253
+ changes: sorted.slice(0, exports.CHANGES_LIMIT),
254
+ change_count: sorted.length,
255
+ conflicted_count: sorted.filter((c) => c.staged === 'conflicted').length,
256
+ truncated: sorted.length > exports.CHANGES_LIMIT,
257
+ last_commit: input.lastCommit,
258
+ operation: input.operation,
259
+ };
260
+ }
261
+ function toSummary(s) {
262
+ return {
263
+ branch: s.branch,
264
+ detached: s.detached,
265
+ sync: s.sync,
266
+ ahead: s.ahead,
267
+ behind: s.behind,
268
+ change_count: s.change_count,
269
+ conflicted_count: s.conflicted_count,
270
+ remote_host: s.remote?.host ?? null,
271
+ };
272
+ }
273
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/git/status.ts"],"names":[],"mappings":";;;AA+HA,sCA6CC;AAgBD,0DAkBC;AAGD,0CAoBC;AAED,gCAoBC;AAKD,8CAEC;AAkBD,wCAGC;AAED,wCAOC;AAGD,gCAOC;AAoBD,kCAmCC;AAED,8BAWC;AA5QY,QAAA,aAAa,GAAG,GAAG,CAAC;AAEjC,MAAM,YAAY,GAAyC;IACzD,GAAG,EAAE,IAAI;IACT,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,cAAc;IACjB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,YAAY;CAChB,CAAC;AAEF,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AAChE,CAAC;AAED,4GAA4G;AAC5G,SAAS,MAAM,CAAC,MAAc,EAAE,CAAS;IACvC,MAAM,KAA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,MAAM;QAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,gBAAgB,EAAE,CAAC,CAAC,gBAAgB;QACpC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,IAAI,IAAI;KACpC,CAAC;AACJ,CAAC"}
package/dist/index.js CHANGED
@@ -58,6 +58,7 @@ const skills_1 = require("./skills");
58
58
  const sync_1 = require("./skills/sync");
59
59
  const factory_1 = require("./watch/factory");
60
60
  const runner_1 = require("./agent/runner");
61
+ const session_cwd_1 = require("./files/session-cwd");
61
62
  const skill_learning_1 = require("./agent/skill-learning");
62
63
  const config_1 = require("./agent/skill-learning/config");
63
64
  const db_1 = require("./history/db");
@@ -263,7 +264,7 @@ async function startAgent(agentConfig, gatewayConfig, ctx) {
263
264
  // Create runner
264
265
  let runner;
265
266
  try {
266
- runner = new runner_1.AgentRunner(agentConfig, gatewayConfig, logger);
267
+ runner = new runner_1.AgentRunner(agentConfig, gatewayConfig, logger, (0, session_cwd_1.createCwdResolver)(gatewayConfig, logger));
267
268
  if (workspace.skillRegistry) {
268
269
  runner.setSkillRegistry(workspace.skillRegistry);
269
270
  }
@@ -626,8 +627,10 @@ async function main() {
626
627
  // logs/gateway.log at startup too, not only on reload (#427).
627
628
  const startupSkips = [];
628
629
  let publicUrlUnsetAtStartup = false;
630
+ const startupWarnings = [];
629
631
  const config = (0, loader_1.loadConfig)(CONFIG_PATH, {
630
632
  onSkippedAgent: (s) => startupSkips.push(s),
633
+ onWarning: (m) => startupWarnings.push(m),
631
634
  onPublicUrlUnset: () => { publicUrlUnsetAtStartup = true; },
632
635
  });
633
636
  config.gateway.logDir = (0, paths_1.expandHome)(config.gateway.logDir);
@@ -649,6 +652,8 @@ async function main() {
649
652
  // went missing.
650
653
  const globalLogger = (0, logger_1.createLogger)('gateway', (0, paths_1.expandHome)(config.gateway.logDir));
651
654
  (0, loader_1.logSkippedAgents)(globalLogger, startupSkips, 'Agent skipped at startup');
655
+ for (const message of startupWarnings)
656
+ globalLogger.warn(message);
652
657
  // Same #427 rationale as skipped agents: the console.warn already happened
653
658
  // inside loadConfig (before logDir/globalLogger could exist), replay it here
654
659
  // so it also reaches logs/gateway.log under structured/JSON logging (#472).
@@ -848,7 +853,7 @@ async function main() {
848
853
  // stays in the background below; only this cheap registry read is awaited.
849
854
  const restorePending = await appInstaller.markRestorePending();
850
855
  // Start gateway router
851
- const router = new gateway_router_1.GatewayRouter(agentRunners, agentConfigs, undefined, config, cronManager, CONFIG_PATH, appsRegistry, appInstaller, registryClient);
856
+ const router = new gateway_router_1.GatewayRouter(agentRunners, agentConfigs, undefined, config, cronManager, CONFIG_PATH, appsRegistry, appInstaller, registryClient, globalLogger);
852
857
  await router.start(PORT);
853
858
  console.log(`[gateway] Listening on port ${PORT}`);
854
859
  // Write the pidfile so the CLI can detect a foreground gateway (and SIGTERM it