agency-lang 0.7.1 → 0.7.2

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 (39) hide show
  1. package/dist/lib/agents/agency-agent/agent.agency +48 -2
  2. package/dist/lib/agents/agency-agent/agent.js +120 -20
  3. package/dist/lib/agents/agency-agent/shared.agency +22 -0
  4. package/dist/lib/agents/agency-agent/shared.js +158 -1
  5. package/dist/lib/agents/agency-agent/tests/oneShotRounds.agency +20 -0
  6. package/dist/lib/agents/agency-agent/tests/oneShotRounds.js +555 -0
  7. package/dist/lib/agents/agency-agent/tests/oneShotRounds.test.json +9 -0
  8. package/dist/lib/cli/doctor.d.ts +8 -0
  9. package/dist/lib/cli/doctor.js +21 -13
  10. package/dist/lib/cli/doctor.test.js +34 -0
  11. package/dist/lib/cli/help.js +1 -5
  12. package/dist/lib/cli/runBundledAgent.d.ts +17 -1
  13. package/dist/lib/cli/runBundledAgent.js +73 -2
  14. package/dist/lib/cli/runBundledAgent.test.d.ts +1 -0
  15. package/dist/lib/cli/runBundledAgent.test.js +96 -0
  16. package/dist/lib/config.d.ts +42 -33
  17. package/dist/lib/config.js +108 -6
  18. package/dist/lib/config.test.js +121 -2
  19. package/dist/lib/parseCache.js +8 -13
  20. package/dist/lib/parseCache.test.js +5 -8
  21. package/dist/lib/parser.js +5 -12
  22. package/dist/lib/preprocessors/typescriptPreprocessor.d.ts +0 -28
  23. package/dist/lib/preprocessors/typescriptPreprocessor.js +0 -245
  24. package/dist/lib/runtime/configOverrides.d.ts +17 -16
  25. package/dist/lib/runtime/configOverrides.js +27 -16
  26. package/dist/lib/runtime/configOverrides.test.js +116 -2
  27. package/dist/lib/runtime/prompt.js +7 -3
  28. package/dist/lib/runtime/state/context.js +9 -2
  29. package/dist/lib/stdlib/llm.d.ts +1 -0
  30. package/dist/lib/stdlib/version.d.ts +1 -1
  31. package/dist/lib/stdlib/version.js +1 -1
  32. package/dist/scripts/agency.d.ts +2 -0
  33. package/dist/scripts/agency.js +55 -12
  34. package/dist/scripts/agency.test.js +73 -1
  35. package/package.json +1 -1
  36. package/stdlib/llm.agency +2 -1
  37. package/stdlib/llm.js +2 -2
  38. package/dist/lib/preprocessors/typescriptPreprocessor.config.test.js +0 -327
  39. /package/dist/lib/{preprocessors/typescriptPreprocessor.config.test.d.ts → cli/doctor.test.d.ts} +0 -0
@@ -184,12 +184,14 @@ __registerTool(getModelSettings);
184
184
  __registerTool(loadSettings);
185
185
  __registerTool(slotKind);
186
186
  let __staticInitPromise = null;
187
+ let ONE_SHOT_MAX_TOOL_CALL_ROUNDS = __UNINIT_STATIC;
187
188
  let AGENCY_AGENT_DIR = __UNINIT_STATIC;
188
189
  async function __initializeStatic(__ctx) {
189
190
  if (__staticInitPromise) {
190
191
  return __staticInitPromise;
191
192
  }
192
193
  __staticInitPromise = (async () => {
194
+ ONE_SHOT_MAX_TOOL_CALL_ROUNDS = __deepFreeze(50);
193
195
  AGENCY_AGENT_DIR = __deepFreeze(await __call(computeAgentDir, {
194
196
  type: "positional",
195
197
  args: []
@@ -199,6 +201,7 @@ async function __initializeStatic(__ctx) {
199
201
  }
200
202
  function __getStaticVars() {
201
203
  return {
204
+ ONE_SHOT_MAX_TOOL_CALL_ROUNDS,
202
205
  AGENCY_AGENT_DIR
203
206
  };
204
207
  }
@@ -220,6 +223,158 @@ async function __registerTopLevelCallbacks(__ctx) {
220
223
  __ctx.topLevelCallbacks = [];
221
224
  }
222
225
  __functionRefReviver.registry = __toolRegistry;
226
+ async function __resolveMaxToolCallRounds_impl(explicit, oneShot) {
227
+ const __setupData = setupFunction();
228
+ const __stack = __setupData.stack;
229
+ const __step = __setupData.step;
230
+ const __self = __setupData.self;
231
+ const __ctx = getRuntimeContext().ctx;
232
+ let __forked;
233
+ let __functionCompleted = false;
234
+ if (!__globals().isInitialized("dist/lib/agents/agency-agent/shared.agency")) {
235
+ await __initializeGlobals(__ctx);
236
+ }
237
+ let __funcStartTime = performance.now();
238
+ __stack.args["explicit"] = explicit;
239
+ __stack.args["oneShot"] = oneShot;
240
+ __self.__retryable = __self.__retryable ?? true;
241
+ const runner = new Runner(__ctx, __stack, { state: __stack, moduleId: "dist/lib/agents/agency-agent/shared.agency", scopeName: "resolveMaxToolCallRounds", threads: __setupData.threads });
242
+ let __resultCheckpointId = -1;
243
+ if (__ctx._pendingArgOverrides) {
244
+ const __overrides = __ctx._pendingArgOverrides;
245
+ __ctx._pendingArgOverrides = void 0;
246
+ if ("explicit" in __overrides) {
247
+ explicit = __overrides["explicit"];
248
+ __stack.args["explicit"] = explicit;
249
+ }
250
+ if ("oneShot" in __overrides) {
251
+ oneShot = __overrides["oneShot"];
252
+ __stack.args["oneShot"] = oneShot;
253
+ }
254
+ }
255
+ try {
256
+ await agencyStore.run({
257
+ ...getRuntimeContext(),
258
+ ctx: __ctx,
259
+ stack: __setupData.stateStack,
260
+ threads: __setupData.threads
261
+ }, async () => {
262
+ await runner.hook(0, async () => {
263
+ await callHook({
264
+ name: "onFunctionStart",
265
+ data: {
266
+ functionName: "resolveMaxToolCallRounds",
267
+ args: {
268
+ explicit,
269
+ oneShot
270
+ },
271
+ moduleId: "dist/lib/agents/agency-agent/shared.agency"
272
+ }
273
+ });
274
+ });
275
+ await runner.ifElse(1, [
276
+ {
277
+ condition: async () => !__eq(__stack.args.explicit, null),
278
+ body: async (runner2) => {
279
+ await runner2.step(0, async (runner3) => {
280
+ __functionCompleted = true;
281
+ runner3.halt(__stack.args.explicit);
282
+ return;
283
+ });
284
+ }
285
+ }
286
+ ]);
287
+ await runner.ifElse(2, [
288
+ {
289
+ condition: async () => __stack.args.oneShot,
290
+ body: async (runner2) => {
291
+ await runner2.step(0, async (runner3) => {
292
+ __functionCompleted = true;
293
+ runner3.halt(__readStatic(ONE_SHOT_MAX_TOOL_CALL_ROUNDS, "ONE_SHOT_MAX_TOOL_CALL_ROUNDS", "dist/lib/agents/agency-agent/shared.agency"));
294
+ return;
295
+ });
296
+ }
297
+ }
298
+ ]);
299
+ await runner.step(3, async (runner2) => {
300
+ __functionCompleted = true;
301
+ runner2.halt(null);
302
+ return;
303
+ });
304
+ });
305
+ if (runner.halted) {
306
+ if (isFailure(runner.haltResult)) {
307
+ runner.haltResult.retryable = runner.haltResult.retryable && __self.__retryable;
308
+ }
309
+ return runner.haltResult;
310
+ }
311
+ } catch (__error) {
312
+ if (__error instanceof RestoreSignal) {
313
+ throw __error;
314
+ }
315
+ if (__error instanceof AgencyAbort) {
316
+ throw __error;
317
+ }
318
+ {
319
+ const __errMsg = __error instanceof Error ? __error.message : String(__error);
320
+ const __errStack = __error instanceof Error && __error.stack ? __error.stack : "";
321
+ const __log = __createLogger(__ctx.logLevel);
322
+ __log.error("Function resolveMaxToolCallRounds threw an exception (converted to Failure): " + __errMsg);
323
+ if (__errStack) __log.error(__errStack);
324
+ __ctx.statelogClient?.error?.({
325
+ errorType: "runtimeError",
326
+ message: __errMsg,
327
+ functionName: "resolveMaxToolCallRounds",
328
+ retryable: __self.__retryable
329
+ });
330
+ }
331
+ return failure(
332
+ __error instanceof Error ? __error.message : String(__error),
333
+ {
334
+ checkpoint: getRuntimeContext().ctx.getResultCheckpoint(),
335
+ retryable: __self.__retryable,
336
+ functionName: "resolveMaxToolCallRounds",
337
+ args: __stack.args
338
+ }
339
+ );
340
+ } finally {
341
+ __stateStack()?.pop();
342
+ if (__functionCompleted) {
343
+ await callHook({
344
+ name: "onFunctionEnd",
345
+ data: {
346
+ functionName: "resolveMaxToolCallRounds",
347
+ timeTaken: performance.now() - __funcStartTime
348
+ }
349
+ });
350
+ }
351
+ }
352
+ }
353
+ const resolveMaxToolCallRounds = __AgencyFunction.create({
354
+ name: "resolveMaxToolCallRounds",
355
+ module: "dist/lib/agents/agency-agent/shared.agency",
356
+ fn: __resolveMaxToolCallRounds_impl,
357
+ params: [{
358
+ name: "explicit",
359
+ hasDefault: false,
360
+ defaultValue: void 0,
361
+ variadic: false,
362
+ isFunctionTyped: false
363
+ }, {
364
+ name: "oneShot",
365
+ hasDefault: false,
366
+ defaultValue: void 0,
367
+ variadic: false,
368
+ isFunctionTyped: false
369
+ }],
370
+ toolDefinition: {
371
+ name: "resolveMaxToolCallRounds",
372
+ description: "No description provided.",
373
+ schema: z.object({ "explicit": z.union([z.number(), z.null()]), "oneShot": z.boolean() })
374
+ },
375
+ safe: false,
376
+ exported: true
377
+ }, __toolRegistry);
223
378
  async function __computeAgentDir_impl() {
224
379
  const __setupData = setupFunction();
225
380
  const __stack = __setupData.stack;
@@ -1993,9 +2148,10 @@ const configureLocalModel = __AgencyFunction.create({
1993
2148
  exported: true
1994
2149
  }, __toolRegistry);
1995
2150
  var stdin_default = graph;
1996
- const __sourceMap = { "dist/lib/agents/agency-agent/shared.agency:computeAgentDir": { "1": { "line": 34, "col": 2 }, "2": { "line": 35, "col": 2 }, "3": { "line": 38, "col": 2 }, "2.0": { "line": 36, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:enableAgentMemory": { "1": { "line": 59, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:getSlowModel": { "1": { "line": 72, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:getSlowProvider": { "1": { "line": 76, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:setSlowModel": { "1": { "line": 84, "col": 2 }, "2": { "line": 85, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:promoteProvider": { "1": { "line": 93, "col": 2 }, "2": { "line": 96, "col": 2 }, "1.0": { "line": 94, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:promoteAll": { "1": { "line": 102, "col": 2 }, "2": { "line": 103, "col": 2 }, "3": { "line": 114, "col": 2 }, "2.0": { "line": 104, "col": 4 }, "2.1": { "line": 105, "col": 4 }, "2.2": { "line": 108, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:applyResolved": { "1": { "line": 122, "col": 2 }, "2": { "line": 123, "col": 2 }, "2.0": { "line": 124, "col": 4 }, "2.1": { "line": 125, "col": 4 }, "2.2": { "line": 128, "col": 4 }, "2.3.0": { "line": 130, "col": 6 }, "2.3.1": { "line": 137, "col": 6 }, "2.3": { "line": 129, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:getResolvedSlots": { "1": { "line": 143, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:currentProvider": { "1": { "line": 147, "col": 2 }, "2": { "line": 148, "col": 2 }, "3": { "line": 151, "col": 2 }, "2.0": { "line": 149, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:configureModels": { "1": { "line": 170, "col": 2 }, "2": { "line": 175, "col": 2 }, "3": { "line": 176, "col": 2 }, "4": { "line": 180, "col": 2 }, "5": { "line": 181, "col": 2 }, "7": { "line": 190, "col": 2 }, "8": { "line": 194, "col": 2 }, "9": { "line": 195, "col": 2 }, "10": { "line": 198, "col": 2 }, "12": { "line": 204, "col": 2 }, "13": { "line": 205, "col": 2 }, "14": { "line": 214, "col": 2 }, "15": { "line": 215, "col": 2 }, "16": { "line": 220, "col": 2 }, "3.0": { "line": 177, "col": 4 }, "5.0": { "line": 182, "col": 4 }, "5.1": { "line": 183, "col": 4 }, "5.2": { "line": 184, "col": 4 }, "9.0": { "line": 196, "col": 4 }, "10.0": { "line": 199, "col": 4 }, "15.0": { "line": 216, "col": 4 }, "15.1": { "line": 217, "col": 4 }, "15.2": { "line": 218, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:configureLocalModel": { "2": { "line": 236, "col": 2 }, "3": { "line": 237, "col": 2 }, "4": { "line": 242, "col": 2 }, "5": { "line": 246, "col": 2 }, "6": { "line": 251, "col": 2 }, "3.0": { "line": 238, "col": 4 }, "3.1": { "line": 239, "col": 4 }, "3.2": { "line": 240, "col": 4 } } };
2151
+ const __sourceMap = { "dist/lib/agents/agency-agent/shared.agency:resolveMaxToolCallRounds": { "1": { "line": 35, "col": 2 }, "2": { "line": 38, "col": 2 }, "3": { "line": 41, "col": 2 }, "1.0": { "line": 36, "col": 4 }, "2.0": { "line": 39, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:computeAgentDir": { "1": { "line": 56, "col": 2 }, "2": { "line": 57, "col": 2 }, "3": { "line": 60, "col": 2 }, "2.0": { "line": 58, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:enableAgentMemory": { "1": { "line": 81, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:getSlowModel": { "1": { "line": 94, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:getSlowProvider": { "1": { "line": 98, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:setSlowModel": { "1": { "line": 106, "col": 2 }, "2": { "line": 107, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:promoteProvider": { "1": { "line": 115, "col": 2 }, "2": { "line": 118, "col": 2 }, "1.0": { "line": 116, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:promoteAll": { "1": { "line": 124, "col": 2 }, "2": { "line": 125, "col": 2 }, "3": { "line": 136, "col": 2 }, "2.0": { "line": 126, "col": 4 }, "2.1": { "line": 127, "col": 4 }, "2.2": { "line": 130, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:applyResolved": { "1": { "line": 144, "col": 2 }, "2": { "line": 145, "col": 2 }, "2.0": { "line": 146, "col": 4 }, "2.1": { "line": 147, "col": 4 }, "2.2": { "line": 150, "col": 4 }, "2.3.0": { "line": 152, "col": 6 }, "2.3.1": { "line": 159, "col": 6 }, "2.3": { "line": 151, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:getResolvedSlots": { "1": { "line": 165, "col": 2 } }, "dist/lib/agents/agency-agent/shared.agency:currentProvider": { "1": { "line": 169, "col": 2 }, "2": { "line": 170, "col": 2 }, "3": { "line": 173, "col": 2 }, "2.0": { "line": 171, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:configureModels": { "1": { "line": 192, "col": 2 }, "2": { "line": 197, "col": 2 }, "3": { "line": 198, "col": 2 }, "4": { "line": 202, "col": 2 }, "5": { "line": 203, "col": 2 }, "7": { "line": 212, "col": 2 }, "8": { "line": 216, "col": 2 }, "9": { "line": 217, "col": 2 }, "10": { "line": 220, "col": 2 }, "12": { "line": 226, "col": 2 }, "13": { "line": 227, "col": 2 }, "14": { "line": 236, "col": 2 }, "15": { "line": 237, "col": 2 }, "16": { "line": 242, "col": 2 }, "3.0": { "line": 199, "col": 4 }, "5.0": { "line": 204, "col": 4 }, "5.1": { "line": 205, "col": 4 }, "5.2": { "line": 206, "col": 4 }, "9.0": { "line": 218, "col": 4 }, "10.0": { "line": 221, "col": 4 }, "15.0": { "line": 238, "col": 4 }, "15.1": { "line": 239, "col": 4 }, "15.2": { "line": 240, "col": 4 } }, "dist/lib/agents/agency-agent/shared.agency:configureLocalModel": { "2": { "line": 258, "col": 2 }, "3": { "line": 259, "col": 2 }, "4": { "line": 264, "col": 2 }, "5": { "line": 268, "col": 2 }, "6": { "line": 273, "col": 2 }, "3.0": { "line": 260, "col": 4 }, "3.1": { "line": 261, "col": 4 }, "3.2": { "line": 262, "col": 4 } } };
1997
2152
  export {
1998
2153
  AGENCY_AGENT_DIR,
2154
+ ONE_SHOT_MAX_TOOL_CALL_ROUNDS,
1999
2155
  __getCheckpoints,
2000
2156
  __invokeFunction,
2001
2157
  __setDebugger,
@@ -2021,6 +2177,7 @@ export {
2021
2177
  promoteAll,
2022
2178
  promoteProvider,
2023
2179
  reject,
2180
+ resolveMaxToolCallRounds,
2024
2181
  respondToInterrupts,
2025
2182
  rewindFrom,
2026
2183
  setSlowModel
@@ -0,0 +1,20 @@
1
+ // resolveMaxToolCallRounds: an explicit --max-tool-call-rounds always wins;
2
+ // otherwise one-shot runs get the higher default and interactive runs keep the
3
+ // compiled default (null).
4
+ import { resolveMaxToolCallRounds } from "../shared.agency"
5
+
6
+ node explicitWinsOverOneShot(): boolean {
7
+ return resolveMaxToolCallRounds(7, true) == 7
8
+ }
9
+
10
+ node oneShotDefaults50(): boolean {
11
+ return resolveMaxToolCallRounds(null, true) == 50
12
+ }
13
+
14
+ node explicitWinsOverInteractive(): boolean {
15
+ return resolveMaxToolCallRounds(3, false) == 3
16
+ }
17
+
18
+ node interactiveKeepsBaked(): boolean {
19
+ return resolveMaxToolCallRounds(null, false) == null
20
+ }