@guildai/cli 0.11.0 → 0.12.1

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 (203) hide show
  1. package/dist/auth-67G3BIAW.js +29 -0
  2. package/dist/auth-67G3BIAW.js.map +7 -0
  3. package/dist/chat-ALOJ22JR.js +303 -0
  4. package/dist/chat-ALOJ22JR.js.map +7 -0
  5. package/dist/chat-SG2I727J.js +33 -0
  6. package/dist/chat-SG2I727J.js.map +7 -0
  7. package/dist/chunk-56YCMGL3.js +522 -0
  8. package/dist/chunk-56YCMGL3.js.map +7 -0
  9. package/dist/chunk-6EX6E7WP.js +7042 -0
  10. package/dist/chunk-6EX6E7WP.js.map +7 -0
  11. package/dist/chunk-7JJT3RNI.js +97272 -0
  12. package/dist/chunk-7JJT3RNI.js.map +7 -0
  13. package/dist/chunk-ENKEEJ45.js +17 -0
  14. package/dist/chunk-ENKEEJ45.js.map +7 -0
  15. package/dist/chunk-EQUW4M5A.js +532 -0
  16. package/dist/chunk-EQUW4M5A.js.map +7 -0
  17. package/dist/chunk-F3F5CUO3.js +841 -0
  18. package/dist/chunk-F3F5CUO3.js.map +7 -0
  19. package/dist/chunk-JQRJ4A4S.js +19778 -0
  20. package/dist/chunk-JQRJ4A4S.js.map +7 -0
  21. package/dist/chunk-M347HP6M.js +22896 -0
  22. package/dist/chunk-M347HP6M.js.map +7 -0
  23. package/dist/chunk-OYQ476FQ.js +44 -0
  24. package/dist/chunk-OYQ476FQ.js.map +7 -0
  25. package/dist/chunk-PNCUR4OB.js +257 -0
  26. package/dist/chunk-PNCUR4OB.js.map +7 -0
  27. package/dist/chunk-RJHD6XTV.js +317 -0
  28. package/dist/chunk-RJHD6XTV.js.map +7 -0
  29. package/dist/chunk-VVSOU6ON.js +53 -0
  30. package/dist/chunk-VVSOU6ON.js.map +7 -0
  31. package/dist/chunk-X3ADGWOF.js +3643 -0
  32. package/dist/chunk-X3ADGWOF.js.map +7 -0
  33. package/dist/chunk-YQWI6SUV.js +3057 -0
  34. package/dist/chunk-YQWI6SUV.js.map +7 -0
  35. package/dist/commands/chat.d.ts +21 -0
  36. package/dist/commands/skill/create.d.ts +3 -0
  37. package/dist/commands/skill/get.d.ts +3 -0
  38. package/dist/commands/skill/list.d.ts +3 -0
  39. package/dist/commands/skill/update.d.ts +3 -0
  40. package/dist/commands/skill/version/create.d.ts +3 -0
  41. package/dist/commands/skill/version/get.d.ts +3 -0
  42. package/dist/commands/skill/version/list.d.ts +3 -0
  43. package/dist/devtools-AO7YSDOD.js +67 -0
  44. package/dist/devtools-AO7YSDOD.js.map +7 -0
  45. package/dist/dist-4CBK6X5H.js +1566 -0
  46. package/dist/dist-4CBK6X5H.js.map +7 -0
  47. package/dist/esm-FRAVZP4J.js +13 -0
  48. package/dist/esm-FRAVZP4J.js.map +7 -0
  49. package/dist/execa-XQMWSABC.js +35 -0
  50. package/dist/execa-XQMWSABC.js.map +7 -0
  51. package/dist/index.js +8230 -263
  52. package/dist/index.js.map +7 -0
  53. package/dist/lib/api-types.d.ts +44 -0
  54. package/dist/lib/config.d.ts +9 -0
  55. package/dist/lib/display-message.d.ts +11 -0
  56. package/dist/lib/errors.d.ts +1 -1
  57. package/dist/lib/markdown.d.ts +2 -9
  58. package/dist/lib/output.d.ts +11 -1
  59. package/dist/lib/response-stream-display-state.d.ts +51 -0
  60. package/dist/lib/session-events.d.ts +5 -1
  61. package/dist/lib/session-polling.d.ts +24 -1
  62. package/dist/lib/session-resume.d.ts +2 -6
  63. package/dist/lib/websocket-client.d.ts +46 -0
  64. package/dist/open-RF4X5MOP.js +13 -0
  65. package/dist/open-RF4X5MOP.js.map +7 -0
  66. package/dist/server-CKXFV2JC.js +27659 -0
  67. package/dist/server-CKXFV2JC.js.map +7 -0
  68. package/dist/test-VEA4ENOR.js +692 -0
  69. package/dist/test-VEA4ENOR.js.map +7 -0
  70. package/docs/skills/codex-agent-dev.md +2 -2
  71. package/package.json +8 -12
  72. package/dist/commands/agent/chat.js +0 -281
  73. package/dist/commands/agent/clone.js +0 -118
  74. package/dist/commands/agent/code.js +0 -87
  75. package/dist/commands/agent/fork.js +0 -220
  76. package/dist/commands/agent/get.js +0 -37
  77. package/dist/commands/agent/grep.js +0 -107
  78. package/dist/commands/agent/init.js +0 -403
  79. package/dist/commands/agent/list.js +0 -110
  80. package/dist/commands/agent/logs.js +0 -62
  81. package/dist/commands/agent/owners.js +0 -74
  82. package/dist/commands/agent/publish.js +0 -91
  83. package/dist/commands/agent/pull.js +0 -194
  84. package/dist/commands/agent/revalidate.js +0 -56
  85. package/dist/commands/agent/save.js +0 -345
  86. package/dist/commands/agent/search.js +0 -61
  87. package/dist/commands/agent/tags/add.js +0 -73
  88. package/dist/commands/agent/tags/list.js +0 -43
  89. package/dist/commands/agent/tags/remove.js +0 -84
  90. package/dist/commands/agent/tags/set.js +0 -71
  91. package/dist/commands/agent/test.js +0 -489
  92. package/dist/commands/agent/unpublish.js +0 -64
  93. package/dist/commands/agent/update.js +0 -118
  94. package/dist/commands/agent/versions.js +0 -55
  95. package/dist/commands/agent/workspaces.js +0 -54
  96. package/dist/commands/auth/login.js +0 -31
  97. package/dist/commands/auth/logout.js +0 -24
  98. package/dist/commands/auth/status.js +0 -38
  99. package/dist/commands/auth/token.js +0 -19
  100. package/dist/commands/chat.js +0 -1416
  101. package/dist/commands/config/get.js +0 -64
  102. package/dist/commands/config/list.js +0 -46
  103. package/dist/commands/config/path.js +0 -37
  104. package/dist/commands/config/set.js +0 -132
  105. package/dist/commands/credentials/endpoint-list.js +0 -88
  106. package/dist/commands/credentials/list.js +0 -50
  107. package/dist/commands/credentials/policy-create.js +0 -66
  108. package/dist/commands/credentials/policy-delete.js +0 -33
  109. package/dist/commands/credentials/policy-list.js +0 -45
  110. package/dist/commands/credentials/policy-update.js +0 -66
  111. package/dist/commands/doctor.js +0 -233
  112. package/dist/commands/integration/connect.js +0 -76
  113. package/dist/commands/integration/create.js +0 -298
  114. package/dist/commands/integration/get.js +0 -95
  115. package/dist/commands/integration/list.js +0 -62
  116. package/dist/commands/integration/operation/create.js +0 -164
  117. package/dist/commands/integration/operation/list.js +0 -92
  118. package/dist/commands/integration/update.js +0 -139
  119. package/dist/commands/integration/version/build.js +0 -86
  120. package/dist/commands/integration/version/create.js +0 -45
  121. package/dist/commands/integration/version/get.js +0 -72
  122. package/dist/commands/integration/version/list.js +0 -45
  123. package/dist/commands/integration/version/publish.js +0 -79
  124. package/dist/commands/integration/version/test.js +0 -104
  125. package/dist/commands/job/get-step.js +0 -40
  126. package/dist/commands/job/get.js +0 -44
  127. package/dist/commands/mcp.js +0 -34
  128. package/dist/commands/session/create.js +0 -59
  129. package/dist/commands/session/events.js +0 -56
  130. package/dist/commands/session/get.js +0 -33
  131. package/dist/commands/session/interrupt.js +0 -33
  132. package/dist/commands/session/list.js +0 -59
  133. package/dist/commands/session/send.js +0 -54
  134. package/dist/commands/session/tasks.js +0 -45
  135. package/dist/commands/setup.js +0 -260
  136. package/dist/commands/trigger/activate.js +0 -41
  137. package/dist/commands/trigger/create.js +0 -197
  138. package/dist/commands/trigger/deactivate.js +0 -41
  139. package/dist/commands/trigger/get.js +0 -33
  140. package/dist/commands/trigger/list.js +0 -57
  141. package/dist/commands/trigger/sessions.js +0 -48
  142. package/dist/commands/trigger/update.js +0 -128
  143. package/dist/commands/version.js +0 -24
  144. package/dist/commands/workspace/agent/add.js +0 -114
  145. package/dist/commands/workspace/agent/list.js +0 -78
  146. package/dist/commands/workspace/agent/remove.js +0 -78
  147. package/dist/commands/workspace/clear.js +0 -45
  148. package/dist/commands/workspace/context/edit.js +0 -107
  149. package/dist/commands/workspace/context/get.js +0 -47
  150. package/dist/commands/workspace/context/list.js +0 -51
  151. package/dist/commands/workspace/context/publish.js +0 -42
  152. package/dist/commands/workspace/create.js +0 -51
  153. package/dist/commands/workspace/current.js +0 -63
  154. package/dist/commands/workspace/get.js +0 -39
  155. package/dist/commands/workspace/list.js +0 -70
  156. package/dist/commands/workspace/select.js +0 -184
  157. package/dist/components/AgentInstallPrompt.js +0 -97
  158. package/dist/components/SplashAnimation.js +0 -321
  159. package/dist/components/TaskView.js +0 -268
  160. package/dist/lib/agent-helpers.js +0 -306
  161. package/dist/lib/alternate-screen.js +0 -59
  162. package/dist/lib/api-client.js +0 -154
  163. package/dist/lib/api-types.js +0 -10
  164. package/dist/lib/auth.js +0 -284
  165. package/dist/lib/braille-canvas.js +0 -321
  166. package/dist/lib/colors.js +0 -46
  167. package/dist/lib/config-cache.js +0 -45
  168. package/dist/lib/config.js +0 -153
  169. package/dist/lib/did-you-mean.js +0 -144
  170. package/dist/lib/errors.js +0 -375
  171. package/dist/lib/event-filter.js +0 -91
  172. package/dist/lib/generated-types.js +0 -56
  173. package/dist/lib/git.js +0 -176
  174. package/dist/lib/gk.js +0 -91
  175. package/dist/lib/guild-config.js +0 -178
  176. package/dist/lib/iap.js +0 -117
  177. package/dist/lib/integration-helpers.js +0 -38
  178. package/dist/lib/loading-messages.js +0 -72
  179. package/dist/lib/logo.js +0 -141
  180. package/dist/lib/lottie-serverside.js +0 -181
  181. package/dist/lib/markdown.js +0 -38
  182. package/dist/lib/npmrc.js +0 -59
  183. package/dist/lib/output-mode.js +0 -54
  184. package/dist/lib/output.js +0 -622
  185. package/dist/lib/owner-helpers.js +0 -112
  186. package/dist/lib/polling.js +0 -76
  187. package/dist/lib/progress.js +0 -324
  188. package/dist/lib/session-events-fetch.js +0 -25
  189. package/dist/lib/session-events.js +0 -126
  190. package/dist/lib/session-polling.js +0 -166
  191. package/dist/lib/session-resume.js +0 -229
  192. package/dist/lib/spinners.js +0 -770
  193. package/dist/lib/splash.js +0 -42
  194. package/dist/lib/stdin.js +0 -91
  195. package/dist/lib/svg-to-braille.js +0 -76
  196. package/dist/lib/table.js +0 -59
  197. package/dist/lib/update-check.js +0 -65
  198. package/dist/lib/validate-input-schema.js +0 -208
  199. package/dist/lib/version-helpers.js +0 -137
  200. package/dist/lib/workspace-helpers.js +0 -49
  201. package/dist/mcp/resources.js +0 -67
  202. package/dist/mcp/server.js +0 -64
  203. package/dist/mcp/tools.js +0 -753
@@ -0,0 +1,44 @@
1
+ import { createRequire as _cjsReq } from 'module'; if(typeof require === 'undefined') var require = _cjsReq(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+
38
+ export {
39
+ __require,
40
+ __commonJS,
41
+ __export,
42
+ __toESM
43
+ };
44
+ //# sourceMappingURL=chunk-OYQ476FQ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,257 @@
1
+ import { createRequire as _cjsReq } from 'module'; if(typeof require === 'undefined') var require = _cjsReq(import.meta.url);
2
+
3
+ // node_modules/signal-exit/dist/mjs/signals.js
4
+ var signals = [];
5
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
6
+ if (process.platform !== "win32") {
7
+ signals.push(
8
+ "SIGALRM",
9
+ "SIGABRT",
10
+ "SIGVTALRM",
11
+ "SIGXCPU",
12
+ "SIGXFSZ",
13
+ "SIGUSR2",
14
+ "SIGTRAP",
15
+ "SIGSYS",
16
+ "SIGQUIT",
17
+ "SIGIOT"
18
+ // should detect profiler and enable/disable accordingly.
19
+ // see #21
20
+ // 'SIGPROF'
21
+ );
22
+ }
23
+ if (process.platform === "linux") {
24
+ signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
25
+ }
26
+
27
+ // node_modules/signal-exit/dist/mjs/index.js
28
+ var processOk = (process3) => !!process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
29
+ var kExitEmitter = /* @__PURE__ */ Symbol.for("signal-exit emitter");
30
+ var global = globalThis;
31
+ var ObjectDefineProperty = Object.defineProperty.bind(Object);
32
+ var Emitter = class {
33
+ emitted = {
34
+ afterExit: false,
35
+ exit: false
36
+ };
37
+ listeners = {
38
+ afterExit: [],
39
+ exit: []
40
+ };
41
+ count = 0;
42
+ id = Math.random();
43
+ constructor() {
44
+ if (global[kExitEmitter]) {
45
+ return global[kExitEmitter];
46
+ }
47
+ ObjectDefineProperty(global, kExitEmitter, {
48
+ value: this,
49
+ writable: false,
50
+ enumerable: false,
51
+ configurable: false
52
+ });
53
+ }
54
+ on(ev, fn) {
55
+ this.listeners[ev].push(fn);
56
+ }
57
+ removeListener(ev, fn) {
58
+ const list = this.listeners[ev];
59
+ const i = list.indexOf(fn);
60
+ if (i === -1) {
61
+ return;
62
+ }
63
+ if (i === 0 && list.length === 1) {
64
+ list.length = 0;
65
+ } else {
66
+ list.splice(i, 1);
67
+ }
68
+ }
69
+ emit(ev, code, signal) {
70
+ if (this.emitted[ev]) {
71
+ return false;
72
+ }
73
+ this.emitted[ev] = true;
74
+ let ret = false;
75
+ for (const fn of this.listeners[ev]) {
76
+ ret = fn(code, signal) === true || ret;
77
+ }
78
+ if (ev === "exit") {
79
+ ret = this.emit("afterExit", code, signal) || ret;
80
+ }
81
+ return ret;
82
+ }
83
+ };
84
+ var SignalExitBase = class {
85
+ };
86
+ var signalExitWrap = (handler) => {
87
+ return {
88
+ onExit(cb, opts) {
89
+ return handler.onExit(cb, opts);
90
+ },
91
+ load() {
92
+ return handler.load();
93
+ },
94
+ unload() {
95
+ return handler.unload();
96
+ }
97
+ };
98
+ };
99
+ var SignalExitFallback = class extends SignalExitBase {
100
+ onExit() {
101
+ return () => {
102
+ };
103
+ }
104
+ load() {
105
+ }
106
+ unload() {
107
+ }
108
+ };
109
+ var SignalExit = class extends SignalExitBase {
110
+ // "SIGHUP" throws an `ENOSYS` error on Windows,
111
+ // so use a supported signal instead
112
+ /* c8 ignore start */
113
+ #hupSig = process2.platform === "win32" ? "SIGINT" : "SIGHUP";
114
+ /* c8 ignore stop */
115
+ #emitter = new Emitter();
116
+ #process;
117
+ #originalProcessEmit;
118
+ #originalProcessReallyExit;
119
+ #sigListeners = {};
120
+ #loaded = false;
121
+ constructor(process3) {
122
+ super();
123
+ this.#process = process3;
124
+ this.#sigListeners = {};
125
+ for (const sig of signals) {
126
+ this.#sigListeners[sig] = () => {
127
+ const listeners = this.#process.listeners(sig);
128
+ let { count } = this.#emitter;
129
+ const p = process3;
130
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
131
+ count += p.__signal_exit_emitter__.count;
132
+ }
133
+ if (listeners.length === count) {
134
+ this.unload();
135
+ const ret = this.#emitter.emit("exit", null, sig);
136
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
137
+ if (!ret)
138
+ process3.kill(process3.pid, s);
139
+ }
140
+ };
141
+ }
142
+ this.#originalProcessReallyExit = process3.reallyExit;
143
+ this.#originalProcessEmit = process3.emit;
144
+ }
145
+ onExit(cb, opts) {
146
+ if (!processOk(this.#process)) {
147
+ return () => {
148
+ };
149
+ }
150
+ if (this.#loaded === false) {
151
+ this.load();
152
+ }
153
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
154
+ this.#emitter.on(ev, cb);
155
+ return () => {
156
+ this.#emitter.removeListener(ev, cb);
157
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
158
+ this.unload();
159
+ }
160
+ };
161
+ }
162
+ load() {
163
+ if (this.#loaded) {
164
+ return;
165
+ }
166
+ this.#loaded = true;
167
+ this.#emitter.count += 1;
168
+ for (const sig of signals) {
169
+ try {
170
+ const fn = this.#sigListeners[sig];
171
+ if (fn)
172
+ this.#process.on(sig, fn);
173
+ } catch (_) {
174
+ }
175
+ }
176
+ this.#process.emit = (ev, ...a) => {
177
+ return this.#processEmit(ev, ...a);
178
+ };
179
+ this.#process.reallyExit = (code) => {
180
+ return this.#processReallyExit(code);
181
+ };
182
+ }
183
+ unload() {
184
+ if (!this.#loaded) {
185
+ return;
186
+ }
187
+ this.#loaded = false;
188
+ signals.forEach((sig) => {
189
+ const listener = this.#sigListeners[sig];
190
+ if (!listener) {
191
+ throw new Error("Listener not defined for signal: " + sig);
192
+ }
193
+ try {
194
+ this.#process.removeListener(sig, listener);
195
+ } catch (_) {
196
+ }
197
+ });
198
+ this.#process.emit = this.#originalProcessEmit;
199
+ this.#process.reallyExit = this.#originalProcessReallyExit;
200
+ this.#emitter.count -= 1;
201
+ }
202
+ #processReallyExit(code) {
203
+ if (!processOk(this.#process)) {
204
+ return 0;
205
+ }
206
+ this.#process.exitCode = code || 0;
207
+ this.#emitter.emit("exit", this.#process.exitCode, null);
208
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
209
+ }
210
+ #processEmit(ev, ...args) {
211
+ const og = this.#originalProcessEmit;
212
+ if (ev === "exit" && processOk(this.#process)) {
213
+ if (typeof args[0] === "number") {
214
+ this.#process.exitCode = args[0];
215
+ }
216
+ const ret = og.call(this.#process, ev, ...args);
217
+ this.#emitter.emit("exit", this.#process.exitCode, null);
218
+ return ret;
219
+ } else {
220
+ return og.call(this.#process, ev, ...args);
221
+ }
222
+ }
223
+ };
224
+ var process2 = globalThis.process;
225
+ var {
226
+ /**
227
+ * Called when the process is exiting, whether via signal, explicit
228
+ * exit, or running out of stuff to do.
229
+ *
230
+ * If the global process object is not suitable for instrumentation,
231
+ * then this will be a no-op.
232
+ *
233
+ * Returns a function that may be used to unload signal-exit.
234
+ */
235
+ onExit,
236
+ /**
237
+ * Load the listeners. Likely you never need to call this, unless
238
+ * doing a rather deep integration with signal-exit functionality.
239
+ * Mostly exposed for the benefit of testing.
240
+ *
241
+ * @internal
242
+ */
243
+ load,
244
+ /**
245
+ * Unload the listeners. Likely you never need to call this, unless
246
+ * doing a rather deep integration with signal-exit functionality.
247
+ * Mostly exposed for the benefit of testing.
248
+ *
249
+ * @internal
250
+ */
251
+ unload
252
+ } = signalExitWrap(processOk(process2) ? new SignalExit(process2) : new SignalExitFallback());
253
+
254
+ export {
255
+ onExit
256
+ };
257
+ //# sourceMappingURL=chunk-PNCUR4OB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/signal-exit/src/signals.ts", "../node_modules/signal-exit/src/index.ts"],
4
+ "sourcesContent": ["/**\n * This is not the set of all possible signals.\n *\n * It IS, however, the set of all signals that trigger\n * an exit on either Linux or BSD systems. Linux is a\n * superset of the signal names supported on BSD, and\n * the unknown signals just fail to register, so we can\n * catch that easily enough.\n *\n * Windows signals are a different set, since there are\n * signals that terminate Windows processes, but don't\n * terminate (or don't even exist) on Posix systems.\n *\n * Don't bother with SIGKILL. It's uncatchable, which\n * means that we can't fire any callbacks anyway.\n *\n * If a user does happen to register a handler on a non-\n * fatal signal like SIGWINCH or something, and then\n * exit, it'll end up firing `process.emit('exit')`, so\n * the handler will be fired anyway.\n *\n * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised\n * artificially, inherently leave the process in a\n * state from which it is not safe to try and enter JS\n * listeners.\n */\nexport const signals: NodeJS.Signals[] = []\nsignals.push('SIGHUP', 'SIGINT', 'SIGTERM')\n\nif (process.platform !== 'win32') {\n signals.push(\n 'SIGALRM',\n 'SIGABRT',\n 'SIGVTALRM',\n 'SIGXCPU',\n 'SIGXFSZ',\n 'SIGUSR2',\n 'SIGTRAP',\n 'SIGSYS',\n 'SIGQUIT',\n 'SIGIOT'\n // should detect profiler and enable/disable accordingly.\n // see #21\n // 'SIGPROF'\n )\n}\n\nif (process.platform === 'linux') {\n signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT')\n}\n", "// Note: since nyc uses this module to output coverage, any lines\n// that are in the direct sync flow of nyc's outputCoverage are\n// ignored, since we can never get coverage for them.\n// grab a reference to node's real process object right away\nimport { signals } from './signals.js'\nexport { signals }\n\n// just a loosened process type so we can do some evil things\ntype ProcessRE = NodeJS.Process & {\n reallyExit: (code?: number | undefined | null) => any\n emit: (ev: string, ...a: any[]) => any\n}\n\nconst processOk = (process: any): process is ProcessRE =>\n !!process &&\n typeof process === 'object' &&\n typeof process.removeListener === 'function' &&\n typeof process.emit === 'function' &&\n typeof process.reallyExit === 'function' &&\n typeof process.listeners === 'function' &&\n typeof process.kill === 'function' &&\n typeof process.pid === 'number' &&\n typeof process.on === 'function'\n\nconst kExitEmitter = Symbol.for('signal-exit emitter')\nconst global: typeof globalThis & { [kExitEmitter]?: Emitter } = globalThis\nconst ObjectDefineProperty = Object.defineProperty.bind(Object)\n\n/**\n * A function that takes an exit code and signal as arguments\n *\n * In the case of signal exits *only*, a return value of true\n * will indicate that the signal is being handled, and we should\n * not synthetically exit with the signal we received. Regardless\n * of the handler return value, the handler is unloaded when an\n * otherwise fatal signal is received, so you get exactly 1 shot\n * at it, unless you add another onExit handler at that point.\n *\n * In the case of numeric code exits, we may already have committed\n * to exiting the process, for example via a fatal exception or\n * unhandled promise rejection, so it is impossible to stop safely.\n */\nexport type Handler = (\n code: number | null | undefined,\n signal: NodeJS.Signals | null\n) => true | void\ntype ExitEvent = 'afterExit' | 'exit'\ntype Emitted = { [k in ExitEvent]: boolean }\ntype Listeners = { [k in ExitEvent]: Handler[] }\n\n// teeny special purpose ee\nclass Emitter {\n emitted: Emitted = {\n afterExit: false,\n exit: false,\n }\n\n listeners: Listeners = {\n afterExit: [],\n exit: [],\n }\n\n count: number = 0\n id: number = Math.random()\n\n constructor() {\n if (global[kExitEmitter]) {\n return global[kExitEmitter]\n }\n ObjectDefineProperty(global, kExitEmitter, {\n value: this,\n writable: false,\n enumerable: false,\n configurable: false,\n })\n }\n\n on(ev: ExitEvent, fn: Handler) {\n this.listeners[ev].push(fn)\n }\n\n removeListener(ev: ExitEvent, fn: Handler) {\n const list = this.listeners[ev]\n const i = list.indexOf(fn)\n /* c8 ignore start */\n if (i === -1) {\n return\n }\n /* c8 ignore stop */\n if (i === 0 && list.length === 1) {\n list.length = 0\n } else {\n list.splice(i, 1)\n }\n }\n\n emit(\n ev: ExitEvent,\n code: number | null | undefined,\n signal: NodeJS.Signals | null\n ): boolean {\n if (this.emitted[ev]) {\n return false\n }\n this.emitted[ev] = true\n let ret: boolean = false\n for (const fn of this.listeners[ev]) {\n ret = fn(code, signal) === true || ret\n }\n if (ev === 'exit') {\n ret = this.emit('afterExit', code, signal) || ret\n }\n return ret\n }\n}\n\nabstract class SignalExitBase {\n abstract onExit(cb: Handler, opts?: { alwaysLast?: boolean }): () => void\n abstract load(): void\n abstract unload(): void\n}\n\nconst signalExitWrap = <T extends SignalExitBase>(handler: T) => {\n return {\n onExit(cb: Handler, opts?: { alwaysLast?: boolean }) {\n return handler.onExit(cb, opts)\n },\n load() {\n return handler.load()\n },\n unload() {\n return handler.unload()\n },\n }\n}\n\nclass SignalExitFallback extends SignalExitBase {\n onExit() {\n return () => {}\n }\n load() {}\n unload() {}\n}\n\nclass SignalExit extends SignalExitBase {\n // \"SIGHUP\" throws an `ENOSYS` error on Windows,\n // so use a supported signal instead\n /* c8 ignore start */\n #hupSig = process.platform === 'win32' ? 'SIGINT' : 'SIGHUP'\n /* c8 ignore stop */\n #emitter = new Emitter()\n #process: ProcessRE\n #originalProcessEmit: ProcessRE['emit']\n #originalProcessReallyExit: ProcessRE['reallyExit']\n\n #sigListeners: { [k in NodeJS.Signals]?: () => void } = {}\n #loaded: boolean = false\n\n constructor(process: ProcessRE) {\n super()\n this.#process = process\n // { <signal>: <listener fn>, ... }\n this.#sigListeners = {}\n for (const sig of signals) {\n this.#sigListeners[sig] = () => {\n // If there are no other listeners, an exit is coming!\n // Simplest way: remove us and then re-send the signal.\n // We know that this will kill the process, so we can\n // safely emit now.\n const listeners = this.#process.listeners(sig)\n let { count } = this.#emitter\n // This is a workaround for the fact that signal-exit v3 and signal\n // exit v4 are not aware of each other, and each will attempt to let\n // the other handle it, so neither of them do. To correct this, we\n // detect if we're the only handler *except* for previous versions\n // of signal-exit, and increment by the count of listeners it has\n // created.\n /* c8 ignore start */\n const p = process as unknown as {\n __signal_exit_emitter__?: { count: number }\n }\n if (\n typeof p.__signal_exit_emitter__ === 'object' &&\n typeof p.__signal_exit_emitter__.count === 'number'\n ) {\n count += p.__signal_exit_emitter__.count\n }\n /* c8 ignore stop */\n if (listeners.length === count) {\n this.unload()\n const ret = this.#emitter.emit('exit', null, sig)\n /* c8 ignore start */\n const s = sig === 'SIGHUP' ? this.#hupSig : sig\n if (!ret) process.kill(process.pid, s)\n /* c8 ignore stop */\n }\n }\n }\n\n this.#originalProcessReallyExit = process.reallyExit\n this.#originalProcessEmit = process.emit\n }\n\n onExit(cb: Handler, opts?: { alwaysLast?: boolean }) {\n /* c8 ignore start */\n if (!processOk(this.#process)) {\n return () => {}\n }\n /* c8 ignore stop */\n\n if (this.#loaded === false) {\n this.load()\n }\n\n const ev = opts?.alwaysLast ? 'afterExit' : 'exit'\n this.#emitter.on(ev, cb)\n return () => {\n this.#emitter.removeListener(ev, cb)\n if (\n this.#emitter.listeners['exit'].length === 0 &&\n this.#emitter.listeners['afterExit'].length === 0\n ) {\n this.unload()\n }\n }\n }\n\n load() {\n if (this.#loaded) {\n return\n }\n this.#loaded = true\n\n // This is the number of onSignalExit's that are in play.\n // It's important so that we can count the correct number of\n // listeners on signals, and don't wait for the other one to\n // handle it instead of us.\n this.#emitter.count += 1\n\n for (const sig of signals) {\n try {\n const fn = this.#sigListeners[sig]\n if (fn) this.#process.on(sig, fn)\n } catch (_) {}\n }\n\n this.#process.emit = (ev: string, ...a: any[]) => {\n return this.#processEmit(ev, ...a)\n }\n this.#process.reallyExit = (code?: number | null | undefined) => {\n return this.#processReallyExit(code)\n }\n }\n\n unload() {\n if (!this.#loaded) {\n return\n }\n this.#loaded = false\n\n signals.forEach(sig => {\n const listener = this.#sigListeners[sig]\n /* c8 ignore start */\n if (!listener) {\n throw new Error('Listener not defined for signal: ' + sig)\n }\n /* c8 ignore stop */\n try {\n this.#process.removeListener(sig, listener)\n /* c8 ignore start */\n } catch (_) {}\n /* c8 ignore stop */\n })\n this.#process.emit = this.#originalProcessEmit\n this.#process.reallyExit = this.#originalProcessReallyExit\n this.#emitter.count -= 1\n }\n\n #processReallyExit(code?: number | null | undefined) {\n /* c8 ignore start */\n if (!processOk(this.#process)) {\n return 0\n }\n this.#process.exitCode = code || 0\n /* c8 ignore stop */\n\n this.#emitter.emit('exit', this.#process.exitCode, null)\n return this.#originalProcessReallyExit.call(\n this.#process,\n this.#process.exitCode\n )\n }\n\n #processEmit(ev: string, ...args: any[]): any {\n const og = this.#originalProcessEmit\n if (ev === 'exit' && processOk(this.#process)) {\n if (typeof args[0] === 'number') {\n this.#process.exitCode = args[0]\n /* c8 ignore start */\n }\n /* c8 ignore start */\n const ret = og.call(this.#process, ev, ...args)\n /* c8 ignore start */\n this.#emitter.emit('exit', this.#process.exitCode, null)\n /* c8 ignore stop */\n return ret\n } else {\n return og.call(this.#process, ev, ...args)\n }\n }\n}\n\nconst process = globalThis.process\n// wrap so that we call the method on the actual handler, without\n// exporting it directly.\nexport const {\n /**\n * Called when the process is exiting, whether via signal, explicit\n * exit, or running out of stuff to do.\n *\n * If the global process object is not suitable for instrumentation,\n * then this will be a no-op.\n *\n * Returns a function that may be used to unload signal-exit.\n */\n onExit,\n\n /**\n * Load the listeners. Likely you never need to call this, unless\n * doing a rather deep integration with signal-exit functionality.\n * Mostly exposed for the benefit of testing.\n *\n * @internal\n */\n load,\n\n /**\n * Unload the listeners. Likely you never need to call this, unless\n * doing a rather deep integration with signal-exit functionality.\n * Mostly exposed for the benefit of testing.\n *\n * @internal\n */\n unload,\n} = signalExitWrap(\n processOk(process) ? new SignalExit(process) : new SignalExitFallback()\n)\n"],
5
+ "mappings": ";;;AA0BO,IAAM,UAA4B,CAAA;AACzC,QAAQ,KAAK,UAAU,UAAU,SAAS;AAE1C,IAAI,QAAQ,aAAa,SAAS;AAChC,UAAQ;IACN;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;;;;AAOJ,IAAI,QAAQ,aAAa,SAAS;AAChC,UAAQ,KAAK,SAAS,WAAW,UAAU,WAAW;;;;ACnCxD,IAAM,YAAY,CAACA,aACjB,CAAC,CAACA,YACF,OAAOA,aAAY,YACnB,OAAOA,SAAQ,mBAAmB,cAClC,OAAOA,SAAQ,SAAS,cACxB,OAAOA,SAAQ,eAAe,cAC9B,OAAOA,SAAQ,cAAc,cAC7B,OAAOA,SAA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AQ,GAAG;AAC7C,UAAI,OAAO,KAAK,CAAC,MAAM,UAAU;AAC/B,aAAK,SAAS,WAAW,KAAK,CAAC;;AAIjC,YAAM,MAAM,GAAG,KAAK,KAAK,UAAU,IAAI,GAAG,IAAI;AAE9C,WAAK,SAAS,KAAK,QAAQ,KAAK,SAAS,UAAU,IAAI;AAEvD,aAAO;WACF;AACL,aAAO,GAAG,KAAK,KAAK,UAAU,IAAI,GAAG,IAAI;;EAE7C;;AAGF,IAAMA,WAAU,WAAW;AAGpB,IAAM;;;;;;;;;;EAUX;;;;;;;;EASA;;;;;;;;EASA;AAAM,IACJ,eACF,UAAUA,QAAO,IAAI,IAAI,WAAWA,QAAO,IAAI,IAAI,mBAAkB,CAAE;",
6
+ "names": ["process"]
7
+ }
@@ -0,0 +1,317 @@
1
+ import { createRequire as _cjsReq } from 'module'; if(typeof require === 'undefined') var require = _cjsReq(import.meta.url);
2
+ import {
3
+ ErrorCodes,
4
+ GuildCLIError,
5
+ axios_default,
6
+ clearAuthToken,
7
+ debug,
8
+ getAuthToken,
9
+ getGuildcoreUrl,
10
+ getIapHeaders,
11
+ getUserAgent,
12
+ retry,
13
+ shouldClearAuthToken
14
+ } from "./chunk-JQRJ4A4S.js";
15
+
16
+ // src/lib/api-client.ts
17
+ var GuildAPIClient = class {
18
+ client;
19
+ baseUrl;
20
+ enableRetry;
21
+ maxRetries;
22
+ constructor(options = {}) {
23
+ this.baseUrl = options.baseUrl || getGuildcoreUrl();
24
+ this.enableRetry = options.enableRetry !== false;
25
+ this.maxRetries = options.maxRetries || 3;
26
+ this.client = axios_default.create({
27
+ baseURL: this.baseUrl,
28
+ timeout: options.defaultTimeout || 3e4,
29
+ headers: {
30
+ "Content-Type": "application/json",
31
+ Accept: "application/json",
32
+ "User-Agent": getUserAgent()
33
+ }
34
+ });
35
+ debug(
36
+ `API Client initialized: ${this.baseUrl}, retry: ${this.enableRetry}, max retries: ${this.maxRetries}`
37
+ );
38
+ }
39
+ /**
40
+ * Make an HTTP request with automatic auth header injection
41
+ * @param method - HTTP method
42
+ * @param endpoint - API endpoint path
43
+ * @param config - Axios request configuration
44
+ * @returns Response data
45
+ * @throws Error with specific error codes for proper error handling
46
+ */
47
+ async request(method, endpoint, config = {}) {
48
+ const makeRequest = async () => {
49
+ const iapHeaders = await getIapHeaders(this.baseUrl);
50
+ config.headers = {
51
+ ...config.headers,
52
+ ...iapHeaders
53
+ };
54
+ const requiresAuth = !endpoint.startsWith("/oauth/") && !endpoint.startsWith("/hello");
55
+ if (requiresAuth) {
56
+ const token = await getAuthToken();
57
+ if (!token) {
58
+ throw new GuildCLIError(
59
+ ErrorCodes.AUTH_REQUIRED,
60
+ "Authentication required. Please run: guild auth login"
61
+ );
62
+ }
63
+ config.headers = {
64
+ ...config.headers,
65
+ Authorization: `Bearer ${token}`
66
+ };
67
+ }
68
+ debug(`Making ${method} request to ${endpoint}`);
69
+ try {
70
+ const response = await this.client.request({
71
+ method,
72
+ url: endpoint,
73
+ ...config
74
+ });
75
+ debug(`Request successful: ${method} ${endpoint}`);
76
+ return response.data;
77
+ } catch (error) {
78
+ if (error && typeof error === "object" && "response" in error && error.response?.status === 401) {
79
+ const resp = error.response;
80
+ const data = resp?.data;
81
+ const message = typeof data === "object" && data && "message" in data ? data.message : void 0;
82
+ if (shouldClearAuthToken(message)) {
83
+ debug("Guild auth failure (401), clearing token");
84
+ await clearAuthToken();
85
+ throw new GuildCLIError(
86
+ ErrorCodes.AUTH_TOKEN_INVALID,
87
+ "Your authentication token is invalid or expired. Please run: guild auth login"
88
+ );
89
+ }
90
+ debug(`Non-auth 401: ${message ?? "no message"}`);
91
+ }
92
+ throw error;
93
+ }
94
+ };
95
+ if (this.enableRetry) {
96
+ return await retry(makeRequest, {
97
+ maxAttempts: this.maxRetries
98
+ });
99
+ } else {
100
+ return await makeRequest();
101
+ }
102
+ }
103
+ /**
104
+ * Make a GET request
105
+ */
106
+ async get(endpoint, config) {
107
+ return this.request("GET", endpoint, config);
108
+ }
109
+ /**
110
+ * Make a POST request
111
+ */
112
+ async post(endpoint, data, config) {
113
+ return this.request("POST", endpoint, { ...config, data });
114
+ }
115
+ /**
116
+ * Make a PUT request
117
+ */
118
+ async put(endpoint, data, config) {
119
+ return this.request("PUT", endpoint, { ...config, data });
120
+ }
121
+ /**
122
+ * Make a PATCH request
123
+ */
124
+ async patch(endpoint, data, config) {
125
+ return this.request("PATCH", endpoint, { ...config, data });
126
+ }
127
+ /**
128
+ * Make a DELETE request
129
+ */
130
+ async delete(endpoint, config) {
131
+ return this.request("DELETE", endpoint, config);
132
+ }
133
+ /**
134
+ * Fetch all items from a paginated endpoint by paging through results.
135
+ * Use for display commands or ID-based lookups where you need the complete list.
136
+ *
137
+ * @param endpoint - API endpoint path (may include query params)
138
+ * @returns Flat array of all items across all pages
139
+ */
140
+ async fetchAll(endpoint) {
141
+ const PAGE_SIZE = 100;
142
+ const allItems = [];
143
+ let offset = 0;
144
+ while (true) {
145
+ const separator = endpoint.includes("?") ? "&" : "?";
146
+ const url = `${endpoint}${separator}limit=${PAGE_SIZE}&offset=${offset}`;
147
+ const response = await this.get(url);
148
+ allItems.push(...response.items);
149
+ offset += response.pagination.limit;
150
+ if (!response.pagination.has_more) break;
151
+ }
152
+ return allItems;
153
+ }
154
+ };
155
+
156
+ // src/lib/guild-config.ts
157
+ import * as fs from "fs/promises";
158
+ import * as path from "path";
159
+ import * as os from "os";
160
+ var GLOBAL_CONFIG_DIR = ".guild";
161
+ var GLOBAL_CONFIG_FILE = "config.json";
162
+ var LOCAL_CONFIG_FILE = "guild.json";
163
+ function getGlobalConfigDir() {
164
+ return path.join(os.homedir(), GLOBAL_CONFIG_DIR);
165
+ }
166
+ function getGlobalConfigPath() {
167
+ return path.join(getGlobalConfigDir(), GLOBAL_CONFIG_FILE);
168
+ }
169
+ function getLocalConfigPath(cwd = process.cwd()) {
170
+ return path.join(cwd, LOCAL_CONFIG_FILE);
171
+ }
172
+ async function fileExists(filePath) {
173
+ return fs.access(filePath).then(() => true).catch(() => false);
174
+ }
175
+ async function loadGlobalConfig() {
176
+ const configPath = getGlobalConfigPath();
177
+ if (!await fileExists(configPath)) {
178
+ debug("Global config not found at %s", configPath);
179
+ return void 0;
180
+ }
181
+ try {
182
+ const content = await fs.readFile(configPath, "utf-8");
183
+ const config = JSON.parse(content);
184
+ debug("Loaded global config: %O", config);
185
+ return config;
186
+ } catch (error) {
187
+ debug("Failed to parse global config: %s", error);
188
+ return void 0;
189
+ }
190
+ }
191
+ async function loadLocalConfig(cwd = process.cwd()) {
192
+ const configPath = getLocalConfigPath(cwd);
193
+ if (!await fileExists(configPath)) {
194
+ debug("Local config not found at %s", configPath);
195
+ return void 0;
196
+ }
197
+ try {
198
+ const content = await fs.readFile(configPath, "utf-8");
199
+ const config = JSON.parse(content);
200
+ debug("Loaded local config: %O", config);
201
+ return config;
202
+ } catch (error) {
203
+ debug("Failed to parse local config: %s", error);
204
+ return void 0;
205
+ }
206
+ }
207
+ async function loadConfig(cwd = process.cwd()) {
208
+ const [local, global] = await Promise.all([loadLocalConfig(cwd), loadGlobalConfig()]);
209
+ return { local, global };
210
+ }
211
+ async function saveGlobalConfig(config) {
212
+ const configDir = getGlobalConfigDir();
213
+ const configPath = getGlobalConfigPath();
214
+ await fs.mkdir(configDir, { recursive: true });
215
+ const existing = await loadGlobalConfig() || {};
216
+ const merged = { ...existing, ...config };
217
+ await fs.writeFile(configPath, JSON.stringify(merged, null, 2) + "\n");
218
+ debug("Saved global config: %O", merged);
219
+ }
220
+ async function getWorkspaceId(cwd = process.cwd()) {
221
+ if (process.env.GUILD_WORKSPACE_ID) {
222
+ debug(
223
+ "Using workspace from GUILD_WORKSPACE_ID env var: %s",
224
+ process.env.GUILD_WORKSPACE_ID
225
+ );
226
+ return { workspaceId: process.env.GUILD_WORKSPACE_ID, source: "env" };
227
+ }
228
+ const config = await loadConfig(cwd);
229
+ if (config.local?.workspace_id) {
230
+ debug("Using workspace from local config: %s", config.local.workspace_id);
231
+ return { workspaceId: config.local.workspace_id, source: "local" };
232
+ }
233
+ if (config.global?.default_workspace) {
234
+ debug("Using workspace from global config: %s", config.global.default_workspace);
235
+ return { workspaceId: config.global.default_workspace, source: "global" };
236
+ }
237
+ debug("No workspace configured in local or global config");
238
+ return void 0;
239
+ }
240
+ async function isAgentDirectory(cwd = process.cwd()) {
241
+ return fileExists(getLocalConfigPath(cwd));
242
+ }
243
+ function getWorkspaceSourceLabel(source) {
244
+ if (source === "local") return "guild.json";
245
+ if (source === "global") return "global config";
246
+ return void 0;
247
+ }
248
+
249
+ // src/lib/event-filter.ts
250
+ var USER_EVENT_TYPES = [
251
+ "user_message",
252
+ "agent_notification_message",
253
+ "agent_notification_progress",
254
+ "agent_notification_error",
255
+ "credentials_request",
256
+ "agent_install_request",
257
+ "trigger_message",
258
+ "system_error"
259
+ ];
260
+ var SYSTEM_EVENT_TYPES = [
261
+ "agent_console",
262
+ "runtime_start",
263
+ "runtime_running",
264
+ "runtime_waiting",
265
+ "runtime_error",
266
+ "runtime_done",
267
+ "llm_start",
268
+ "llm_done"
269
+ ];
270
+ var DEFAULT_EVENT_TYPES = new Set(USER_EVENT_TYPES);
271
+ function parseEventFilter(raw) {
272
+ const tokens = raw.split(",").map((t) => t.trim()).filter(Boolean);
273
+ if (tokens.length === 1 && tokens[0] === "none") {
274
+ return /* @__PURE__ */ new Set();
275
+ }
276
+ const result = /* @__PURE__ */ new Set();
277
+ for (const token of tokens) {
278
+ switch (token) {
279
+ case "all":
280
+ for (const t of USER_EVENT_TYPES) result.add(t);
281
+ for (const t of SYSTEM_EVENT_TYPES) result.add(t);
282
+ break;
283
+ case "user":
284
+ for (const t of USER_EVENT_TYPES) result.add(t);
285
+ break;
286
+ case "system":
287
+ for (const t of SYSTEM_EVENT_TYPES) result.add(t);
288
+ break;
289
+ default:
290
+ result.add(token);
291
+ }
292
+ }
293
+ return result;
294
+ }
295
+ function shouldShowEvent(type, filter) {
296
+ return filter.has(type);
297
+ }
298
+
299
+ export {
300
+ GuildAPIClient,
301
+ getGlobalConfigDir,
302
+ getGlobalConfigPath,
303
+ getLocalConfigPath,
304
+ loadGlobalConfig,
305
+ loadLocalConfig,
306
+ loadConfig,
307
+ saveGlobalConfig,
308
+ getWorkspaceId,
309
+ isAgentDirectory,
310
+ getWorkspaceSourceLabel,
311
+ USER_EVENT_TYPES,
312
+ SYSTEM_EVENT_TYPES,
313
+ DEFAULT_EVENT_TYPES,
314
+ parseEventFilter,
315
+ shouldShowEvent
316
+ };
317
+ //# sourceMappingURL=chunk-RJHD6XTV.js.map