liminal 0.5.1 → 0.5.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 (196) hide show
  1. package/Agent.ts +10 -0
  2. package/CHANGELOG.md +6 -0
  3. package/Exec.ts +19 -31
  4. package/L.ts +4 -7
  5. package/LiminalConfig.ts +1 -1
  6. package/Model.ts +8 -2
  7. package/PathLike.ts +8 -10
  8. package/Scope.ts +33 -14
  9. package/Tool.ts +3 -3
  10. package/actions/actions_derived/clear.ts +2 -2
  11. package/actions/actions_derived/declareModel.test.ts +10 -7
  12. package/actions/actions_derived/declareModel.ts +3 -3
  13. package/actions/actions_derived/messages.ts +0 -1
  14. package/actions/actions_derived/readers_derived.ts +15 -0
  15. package/actions/appendMessage.ts +27 -3
  16. package/actions/branch.ts +31 -33
  17. package/actions/catch.ts +3 -3
  18. package/actions/embed.ts +2 -1
  19. package/actions/enableTool.ts +2 -2
  20. package/actions/enableTool.type-test.ts +7 -7
  21. package/actions/infer.ts +15 -3
  22. package/actions/messages.ts +62 -0
  23. package/actions/pushModel.ts +22 -2
  24. package/actions/scope.ts +13 -0
  25. package/actions/section.ts +105 -0
  26. package/cli/cli_common.ts +1 -0
  27. package/cli/main.ts +6 -1
  28. package/cli/runExec.ts +20 -16
  29. package/dist/Agent.d.ts +7 -0
  30. package/dist/Agent.js +2 -0
  31. package/dist/Agent.js.map +1 -0
  32. package/dist/Exec.d.ts +5 -7
  33. package/dist/Exec.js +14 -17
  34. package/dist/Exec.js.map +1 -1
  35. package/dist/L.d.ts +4 -7
  36. package/dist/L.js +4 -7
  37. package/dist/L.js.map +1 -1
  38. package/dist/LiminalConfig.d.ts +1 -1
  39. package/dist/Model.d.ts +7 -2
  40. package/dist/PathLike.d.ts +4 -7
  41. package/dist/Scope.d.ts +11 -5
  42. package/dist/Scope.js +8 -5
  43. package/dist/Scope.js.map +1 -1
  44. package/dist/Tool.d.ts +2 -2
  45. package/dist/actions/actions_derived/clear.js +2 -2
  46. package/dist/actions/actions_derived/clear.js.map +1 -1
  47. package/dist/actions/actions_derived/declareModel.d.ts +2 -2
  48. package/dist/actions/actions_derived/declareModel.js +1 -1
  49. package/dist/actions/actions_derived/declareModel.js.map +1 -1
  50. package/dist/actions/actions_derived/declareModel.test.js +10 -7
  51. package/dist/actions/actions_derived/declareModel.test.js.map +1 -1
  52. package/dist/actions/actions_derived/messages.d.ts +3 -3
  53. package/dist/actions/actions_derived/messages.js.map +1 -1
  54. package/dist/actions/actions_derived/readers_derived.d.ts +6 -0
  55. package/dist/actions/actions_derived/readers_derived.js +14 -0
  56. package/dist/actions/actions_derived/readers_derived.js.map +1 -0
  57. package/dist/actions/appendMessage.d.ts +6 -2
  58. package/dist/actions/appendMessage.js +23 -2
  59. package/dist/actions/appendMessage.js.map +1 -1
  60. package/dist/actions/branch.d.ts +18 -14
  61. package/dist/actions/branch.js +10 -10
  62. package/dist/actions/branch.js.map +1 -1
  63. package/dist/actions/catch.d.ts +2 -2
  64. package/dist/actions/catch.js +2 -2
  65. package/dist/actions/embed.js +2 -1
  66. package/dist/actions/embed.js.map +1 -1
  67. package/dist/actions/enableTool.d.ts +2 -2
  68. package/dist/actions/enableTool.type-test.js +5 -5
  69. package/dist/actions/infer.d.ts +3 -1
  70. package/dist/actions/infer.js +11 -3
  71. package/dist/actions/infer.js.map +1 -1
  72. package/dist/actions/messages.d.ts +24 -0
  73. package/dist/actions/{setMessages.js → messages.js} +14 -10
  74. package/dist/actions/messages.js.map +1 -0
  75. package/dist/actions/pushModel.d.ts +5 -1
  76. package/dist/actions/pushModel.js +17 -2
  77. package/dist/actions/pushModel.js.map +1 -1
  78. package/dist/actions/{getScope.d.ts → scope.d.ts} +3 -1
  79. package/dist/actions/scope.js +10 -0
  80. package/dist/actions/scope.js.map +1 -0
  81. package/dist/actions/section.d.ts +23 -0
  82. package/dist/actions/section.js +64 -0
  83. package/dist/actions/section.js.map +1 -0
  84. package/dist/cli/cli_common.d.ts +1 -0
  85. package/dist/cli/main.js +6 -1
  86. package/dist/cli/main.js.map +1 -1
  87. package/dist/cli/runExec.js +21 -16
  88. package/dist/cli/runExec.js.map +1 -1
  89. package/dist/events/LEvent.d.ts +3 -1
  90. package/dist/events/SectionCleared.d.ts +5 -0
  91. package/dist/events/SectionCleared.js +2 -0
  92. package/dist/events/SectionCleared.js.map +1 -0
  93. package/dist/events/Sectioned.d.ts +5 -0
  94. package/dist/events/Sectioned.js +2 -0
  95. package/dist/events/Sectioned.js.map +1 -0
  96. package/dist/index.d.ts +1 -1
  97. package/dist/index.js +1 -1
  98. package/dist/testing/{ActorAssertions.d.ts → AgentAssertions.d.ts} +3 -3
  99. package/dist/testing/AgentAssertions.js +6 -0
  100. package/dist/testing/AgentAssertions.js.map +1 -0
  101. package/dist/testing/TestEmbeddingModel.js +1 -0
  102. package/dist/testing/TestEmbeddingModel.js.map +1 -1
  103. package/dist/testing/TestLanguageModel.js +1 -0
  104. package/dist/testing/TestLanguageModel.js.map +1 -1
  105. package/dist/testing/index.d.ts +1 -1
  106. package/dist/testing/index.js +1 -1
  107. package/dist/testing/takeFirstAction.d.ts +2 -2
  108. package/dist/tsconfig.tsbuildinfo +1 -1
  109. package/dist/types/Type.d.ts +1 -0
  110. package/dist/types/Type.js.map +1 -1
  111. package/dist/types/array.js +2 -2
  112. package/dist/types/array.js.map +1 -1
  113. package/dist/types/boolean.js +2 -2
  114. package/dist/types/boolean.js.map +1 -1
  115. package/dist/types/const.js +2 -2
  116. package/dist/types/const.js.map +1 -1
  117. package/dist/types/enum.js +2 -2
  118. package/dist/types/enum.js.map +1 -1
  119. package/dist/types/integer.js +2 -2
  120. package/dist/types/integer.js.map +1 -1
  121. package/dist/types/makeType.d.ts +2 -0
  122. package/dist/types/{declareType.js → makeType.js} +4 -3
  123. package/dist/types/makeType.js.map +1 -0
  124. package/dist/types/null.js +2 -2
  125. package/dist/types/null.js.map +1 -1
  126. package/dist/types/number.js +2 -2
  127. package/dist/types/number.js.map +1 -1
  128. package/dist/types/object.js +2 -2
  129. package/dist/types/object.js.map +1 -1
  130. package/dist/types/ref.js +2 -2
  131. package/dist/types/ref.js.map +1 -1
  132. package/dist/types/string.js +2 -2
  133. package/dist/types/string.js.map +1 -1
  134. package/dist/types/union.js +2 -2
  135. package/dist/types/union.js.map +1 -1
  136. package/dist/util/peekLast.d.ts +1 -0
  137. package/dist/util/peekLast.js +4 -0
  138. package/dist/util/peekLast.js.map +1 -0
  139. package/events/LEvent.ts +4 -0
  140. package/events/SectionCleared.ts +6 -0
  141. package/events/Sectioned.ts +6 -0
  142. package/index.ts +1 -1
  143. package/package.json +1 -1
  144. package/testing/{ActorAssertions.ts → AgentAssertions.ts} +3 -5
  145. package/testing/TestEmbeddingModel.ts +1 -0
  146. package/testing/TestLanguageModel.ts +1 -0
  147. package/testing/index.ts +1 -1
  148. package/testing/takeFirstAction.ts +2 -2
  149. package/types/Type.ts +1 -0
  150. package/types/array.ts +2 -2
  151. package/types/boolean.ts +2 -2
  152. package/types/const.ts +2 -2
  153. package/types/enum.ts +2 -2
  154. package/types/integer.ts +2 -2
  155. package/types/{declareType.ts → makeType.ts} +3 -2
  156. package/types/null.ts +2 -2
  157. package/types/number.ts +2 -2
  158. package/types/object.ts +2 -2
  159. package/types/ref.ts +2 -2
  160. package/types/string.ts +2 -2
  161. package/types/union.ts +2 -2
  162. package/util/peekLast.ts +3 -0
  163. package/Actor.ts +0 -20
  164. package/actions/actions_derived/getMessages.ts +0 -9
  165. package/actions/getScope.ts +0 -11
  166. package/actions/getSignal.ts +0 -10
  167. package/actions/getTools.ts +0 -11
  168. package/actions/removeMessage.ts +0 -22
  169. package/actions/removeModel.ts +0 -31
  170. package/actions/setMessages.ts +0 -66
  171. package/dist/Actor.d.ts +0 -14
  172. package/dist/Actor.js +0 -2
  173. package/dist/Actor.js.map +0 -1
  174. package/dist/actions/actions_derived/getMessages.d.ts +0 -3
  175. package/dist/actions/actions_derived/getMessages.js +0 -8
  176. package/dist/actions/actions_derived/getMessages.js.map +0 -1
  177. package/dist/actions/getScope.js +0 -8
  178. package/dist/actions/getScope.js.map +0 -1
  179. package/dist/actions/getSignal.d.ts +0 -4
  180. package/dist/actions/getSignal.js +0 -8
  181. package/dist/actions/getSignal.js.map +0 -1
  182. package/dist/actions/getTools.d.ts +0 -5
  183. package/dist/actions/getTools.js +0 -8
  184. package/dist/actions/getTools.js.map +0 -1
  185. package/dist/actions/removeMessage.d.ts +0 -9
  186. package/dist/actions/removeMessage.js +0 -17
  187. package/dist/actions/removeMessage.js.map +0 -1
  188. package/dist/actions/removeModel.d.ts +0 -10
  189. package/dist/actions/removeModel.js +0 -20
  190. package/dist/actions/removeModel.js.map +0 -1
  191. package/dist/actions/setMessages.d.ts +0 -16
  192. package/dist/actions/setMessages.js.map +0 -1
  193. package/dist/testing/ActorAssertions.js +0 -6
  194. package/dist/testing/ActorAssertions.js.map +0 -1
  195. package/dist/types/declareType.d.ts +0 -2
  196. package/dist/types/declareType.js.map +0 -1
package/dist/Scope.js CHANGED
@@ -1,4 +1,4 @@
1
- export function RootScope(defaultLanguageModel, args, handler = () => { }, signal) {
1
+ export function RootScope({ signal, args, handler, default: defaultLanguageModel, }) {
2
2
  const controller = new AbortController();
3
3
  signal?.addEventListener("abort", () => {
4
4
  controller.abort();
@@ -14,6 +14,7 @@ export function RootScope(defaultLanguageModel, args, handler = () => { }, signa
14
14
  languageModels: new Set([defaultLanguageModel]),
15
15
  embeddingModels: new Set(),
16
16
  childForkCounts: {},
17
+ sections: new Set(),
17
18
  index: 0,
18
19
  reduce,
19
20
  fork,
@@ -21,14 +22,14 @@ export function RootScope(defaultLanguageModel, args, handler = () => { }, signa
21
22
  event,
22
23
  };
23
24
  }
24
- async function reduce(actor) {
25
+ async function reduce(agent) {
25
26
  const { signal } = this.controller;
26
27
  let scope = { ...this };
27
28
  if (signal.aborted)
28
29
  return scope;
29
30
  let value;
30
31
  try {
31
- let current = await actor.next();
32
+ let current = await agent.next();
32
33
  while (!current.done) {
33
34
  const { value } = current;
34
35
  if (signal.aborted)
@@ -36,7 +37,7 @@ async function reduce(actor) {
36
37
  scope = await value.reducer(scope);
37
38
  if (signal.aborted)
38
39
  return scope;
39
- current = await actor.next(scope.nextArg);
40
+ current = await agent.next(scope.nextArg);
40
41
  }
41
42
  value = current.value;
42
43
  }
@@ -49,7 +50,7 @@ async function reduce(actor) {
49
50
  nextArg: undefined,
50
51
  };
51
52
  }
52
- function fork(type, subpath) {
53
+ function fork(type, subpath, overrides) {
53
54
  const subpathStr = subpath.join(" ");
54
55
  let index = this.childForkCounts[subpathStr];
55
56
  if (typeof index === "number") {
@@ -73,9 +74,11 @@ function fork(type, subpath) {
73
74
  parent: this,
74
75
  value: undefined,
75
76
  index,
77
+ sections: new Set(this.sections),
76
78
  reduce,
77
79
  fork,
78
80
  event,
81
+ ...overrides ?? {},
79
82
  };
80
83
  f.event({ type: "forked" });
81
84
  return f;
package/dist/Scope.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Scope.js","sourceRoot":"","sources":["../Scope.ts"],"names":[],"mappings":"AAyCA,MAAM,UAAU,SAAS,CACvB,oBAAmC,EACnC,IAA2B,EAC3B,UAAwB,GAAG,EAAE,GAAE,CAAC,EAChC,MAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;QACrC,UAAU,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;IACF,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,IAAI;QACJ,UAAU;QACV,QAAQ,EAAE,IAAI,GAAG,EAAE;QACnB,KAAK,EAAE,IAAI,GAAG,EAAE;QAChB,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,EAAE;QACR,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC;QAC/C,eAAe,EAAE,IAAI,GAAG,EAAE;QAC1B,eAAe,EAAE,EAAE;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I,CAAC,QAAQ,CAAC;QAChC,MAAM;QACN,IAAI;QACJ,KAAK;QACL,GAAG,SAAS,IAAI,EAAE;KACnB,CAAA;IACD,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC3B,OAAO,CAAC,CAAA;AACV,CAAC;AAED,SAAS,KAAK,CAAmB,KAAa;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,KAAK,EAAE,IAAI,CAAC,IAAI;QAChB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,KAAK;KACT,CAAC,CAAA;AACJ,CAAC"}
package/dist/Tool.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { StandardSchemaV1 } from "@standard-schema/spec";
2
2
  import type { Action } from "./Action.ts";
3
- import type { Actor } from "./Actor.ts";
3
+ import type { Agent } from "./Agent.ts";
4
4
  import type { Scope } from "./Scope.ts";
5
5
  import type { JSONKey } from "./util/JSONKey.ts";
6
6
  import type { JSONObject } from "./util/JSONObject.ts";
@@ -16,6 +16,6 @@ export interface Tool<K extends JSONKey = JSONKey> extends ToolConfig<K> {
16
16
  executor: (scope: Scope) => ToolExecutor;
17
17
  }
18
18
  export declare function Tool<K extends JSONKey>(config: ToolConfig<K>): Tool<K>;
19
- export type ToolImplementation = (params: any) => Actor<Action, ToolResult> | PromiseOr<ToolResult>;
19
+ export type ToolImplementation = (params: any) => Agent<Action, ToolResult> | PromiseOr<ToolResult>;
20
20
  export type ToolExecutor = (args: any) => Promise<JSONValue>;
21
21
  export type ToolResult = JSONValue | void;
@@ -1,5 +1,5 @@
1
- import { setMessages } from "../../actions/setMessages.js";
1
+ import { messages } from "../messages.js";
2
2
  export function clear() {
3
- return setMessages(() => []);
3
+ return messages(() => []);
4
4
  }
5
5
  //# sourceMappingURL=clear.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../actions/actions_derived/clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG1D,MAAM,UAAU,KAAK;IACnB,OAAO,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;AAC9B,CAAC"}
1
+ {"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../actions/actions_derived/clear.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,UAAU,KAAK;IACnB,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;AAC3B,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Model } from "../../Model.ts";
1
+ import type { Models, ModelType } from "../../Model.ts";
2
2
  import type { JSONKey } from "../../util/JSONKey.ts";
3
3
  import { declareArg } from "../declareArg.ts";
4
4
  import { pushModel } from "../pushModel.ts";
5
- export declare function declareModel<K extends JSONKey>(key: K): Generator<declareArg<K, Model> | pushModel<K, "language" | "embedding">, Generator<import("../removeModel.ts").removeModel<K, "language" | "embedding">, void, any>, any>;
5
+ export declare function declareModel<K extends JSONKey, M extends ModelType>(key: K, _modelType: M): Generator<declareArg<K, Models[M]> | pushModel<K, Models[M]["type"]>, Generator<import("../pushModel.ts").removeModel<K, Models[M]["type"]>, void, any>, any>;
@@ -1,6 +1,6 @@
1
1
  import { declareArg } from "../declareArg.js";
2
2
  import { pushModel } from "../pushModel.js";
3
- export function* declareModel(key) {
3
+ export function* declareModel(key, _modelType) {
4
4
  const model = yield* declareArg(key)();
5
5
  return yield* pushModel(key, model);
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"declareModel.js","sourceRoot":"","sources":["../../../actions/actions_derived/declareModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,SAAS,CAAC,CAAC,YAAY,CAAoB,GAAM;IACrD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAS,CAAA;IAC7C,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC"}
1
+ {"version":3,"file":"declareModel.js","sourceRoot":"","sources":["../../../actions/actions_derived/declareModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,SAAS,CAAC,CAAC,YAAY,CAAyC,GAAM,EAAE,UAAa;IACzF,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAa,CAAA;IACjD,OAAO,KAAK,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC"}
@@ -1,20 +1,20 @@
1
1
  import { describe, expect, it } from "bun:test";
2
- import { Exec } from "../../Exec.js";
2
+ import { exec } from "../../Exec.js";
3
3
  import * as L from "../../L.js";
4
4
  import { TestEmbeddingModel } from "../../testing/TestEmbeddingModel.js";
5
5
  import { TestLanguageModel } from "../../testing/TestLanguageModel.js";
6
6
  describe("Model", () => {
7
7
  it("generates the expected event sequence", async () => {
8
8
  const events = [];
9
- await Exec(function* () {
10
- const a = yield* L.declareModel("secondary");
9
+ await exec(function* () {
10
+ const a = yield* L.declareModel("secondary", "language");
11
11
  yield* L.branch("fork-key", function* () {
12
- const b = yield* L.declareModel("child_a");
13
- const c = yield* L.declareModel("child_b");
12
+ const b = yield* L.declareModel("child_a", "language");
13
+ const c = yield* L.declareModel("child_b", "embedding");
14
14
  yield* b;
15
15
  yield* c;
16
16
  });
17
- const c = yield* L.declareModel("tertiary");
17
+ const c = yield* L.declareModel("tertiary", "embedding");
18
18
  yield* a;
19
19
  yield* c;
20
20
  }, {
@@ -25,7 +25,10 @@ describe("Model", () => {
25
25
  child_b: TestEmbeddingModel(),
26
26
  tertiary: TestEmbeddingModel(),
27
27
  },
28
- })((event) => events.push(event));
28
+ handler(event) {
29
+ events.push(event);
30
+ },
31
+ });
29
32
  expect(JSON.stringify(events, null, 2)).toMatchSnapshot();
30
33
  });
31
34
  });
@@ -1 +1 @@
1
- {"version":3,"file":"declareModel.test.js","sourceRoot":"","sources":["../../../actions/actions_derived/declareModel.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,KAAK,CAAC,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAEtE,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,MAAM,GAAkB,EAAE,CAAA;QAChC,MAAM,IAAI,CAAC,QAAQ,CAAC;YAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;YAC5C,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACnC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;gBAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;gBAC1C,KAAK,CAAC,CAAC,CAAC,CAAA;gBACR,KAAK,CAAC,CAAC,CAAC,CAAA;YACV,CAAC,CAAC,CAAA;YACF,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;YAC3C,KAAK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MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gBACtD,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;gBACvD,KAAK,CAAC,CAAC,CAAC,CAAA;gBACR,KAAK,CAAC,CAAC,CAAC,CAAA;YACV,CAAC,CAAC,CAAA;YACF,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;YACxD,KAAK,CAAC,CAAC,CAAC,CAAA;YACR,KAAK,CAAC,CAAC,CAAC,CAAA;QACV,CAAC,EAAE;YACD,OAAO,EAAE,iBAAiB,EAAE;YAC5B,IAAI,EAAE;gBACJ,SAAS,EAAE,iBAAiB,EAAE;gBAC9B,OAAO,EAAE,iBAAiB,EAAE;gBAC5B,OAAO,EAAE,kBAAkB,EAAE;gBAC7B,QAAQ,EAAE,kBAAkB,EAAE;aAC/B;YACD,OAAO,CAAC,KAAK;gBACX,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;SACF,CAAC,CAAA;QACF,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAA;IAC3D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import type { AssistantContent, UserContent } from "../../Message.ts";
2
2
  import { type TaggableArgs } from "../../util/Taggable.ts";
3
3
  import { appendMessage } from "../appendMessage.ts";
4
- export declare function user(...args: TaggableArgs<[content: UserContent]>): Generator<appendMessage<import("../../Message.ts").UserMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
5
- export declare function system(...args: TaggableArgs<[content: string]>): Generator<appendMessage<import("../../Message.ts").SystemMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
6
- export declare function assistant(...args: TaggableArgs<[content: AssistantContent]>): Generator<appendMessage<import("../../Message.ts").AssistantMessage>, Generator<import("../removeMessage.ts").removeMessage, void, any>, any>;
4
+ export declare function user(...args: TaggableArgs<[content: UserContent]>): Generator<appendMessage<import("../../Message.ts").UserMessage>, Generator<import("../appendMessage.ts").removeMessage, void, any>, any>;
5
+ export declare function system(...args: TaggableArgs<[content: string]>): Generator<appendMessage<import("../../Message.ts").SystemMessage>, Generator<import("../appendMessage.ts").removeMessage, void, any>, any>;
6
+ export declare function assistant(...args: TaggableArgs<[content: AssistantContent]>): Generator<appendMessage<import("../../Message.ts").AssistantMessage>, Generator<import("../appendMessage.ts").removeMessage, void, any>, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../actions/actions_derived/messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAqB,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,UAAU,IAAI,CAAC,GAAG,IAA0C;IAChE,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAG,IAAqC;IAC7D,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAG,IAA+C;IAC1E,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../actions/actions_derived/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAqB,MAAM,wBAAwB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,UAAU,IAAI,CAAC,GAAG,IAA0C;IAChE,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAG,IAAqC;IAC7D,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAG,IAA+C;IAC1E,MAAM,CAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const tools: {
2
+ [Symbol.iterator](): Generator<import("../scope.ts").getScope, Set<import("../../Tool.ts").Tool<import("../../index.ts").JSONKey>>, any>;
3
+ };
4
+ export declare const signal: {
5
+ [Symbol.iterator](): Generator<import("../scope.ts").getScope, AbortSignal, any>;
6
+ };
@@ -0,0 +1,14 @@
1
+ import { scope } from "../scope.js";
2
+ export const tools = {
3
+ *[Symbol.iterator]() {
4
+ const scope_ = yield* scope;
5
+ return scope_.tools;
6
+ },
7
+ };
8
+ export const signal = {
9
+ *[Symbol.iterator]() {
10
+ const scope_ = yield* scope;
11
+ return scope_.controller.signal;
12
+ },
13
+ };
14
+ //# sourceMappingURL=readers_derived.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readers_derived.js","sourceRoot":"","sources":["../../../actions/actions_derived/readers_derived.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAA;QAC3B,OAAO,MAAM,CAAC,KAAK,CAAA;IACrB,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAA;QAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAA;IACjC,CAAC;CACF,CAAA"}
@@ -1,10 +1,14 @@
1
1
  import { Action } from "../Action.ts";
2
2
  import type { MessageAppended } from "../events/MessageAppended.ts";
3
+ import type { MessageRemoved } from "../events/MessageRemoved.ts";
3
4
  import type { Message, MessageContents, MessageRole, Messages } from "../Message.ts";
4
5
  import type { Spec } from "../Spec.ts";
5
- import { removeMessage } from "./removeMessage.ts";
6
- export interface appendMessage<M extends Message> extends Action<"append_message", Spec.Make<{
6
+ export interface appendMessage<M extends Message = Message> extends Action<"append_message", Spec.Make<{
7
7
  Event: MessageAppended<M>;
8
8
  }>> {
9
9
  }
10
+ export interface removeMessage extends Action<"remove_message", Spec.Make<{
11
+ Event: MessageRemoved;
12
+ }>> {
13
+ }
10
14
  export declare function appendMessage<R extends MessageRole>(role: R, content: MessageContents[R]): Generator<appendMessage<Messages[R]>, Generator<removeMessage, void>>;
@@ -1,18 +1,39 @@
1
1
  import { Action } from "../Action.js";
2
- import { removeMessage } from "./removeMessage.js";
2
+ import { peekLast } from "../util/peekLast.js";
3
3
  export function* appendMessage(role, content) {
4
4
  return yield Action("append_message", (scope) => {
5
5
  const message = {
6
6
  role,
7
7
  content,
8
8
  }; // <-- why isn't this inferred?
9
+ const section = peekLast(scope.sections);
10
+ if (section) {
11
+ section.messages.add(message);
12
+ }
9
13
  scope.event({
10
14
  type: "message_appended",
11
15
  message,
12
16
  });
13
17
  return {
14
18
  ...scope,
15
- nextArg: removeMessage(message),
19
+ nextArg: (function* () {
20
+ return yield Action("remove_message", (scope) => {
21
+ scope.event({
22
+ type: "message_removed",
23
+ message,
24
+ });
25
+ const messages = new Set(scope.messages);
26
+ messages.delete(message);
27
+ if (section) {
28
+ section.messages.delete(message);
29
+ }
30
+ return {
31
+ ...scope,
32
+ nextArg: message,
33
+ messages,
34
+ };
35
+ });
36
+ })(),
16
37
  messages: new Set([...scope.messages, message]),
17
38
  };
18
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"appendMessage.js","sourceRoot":"","sources":["../../actions/appendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD,MAAM,SAAS,CAAC,CAAC,aAAa,CAC5B,IAAO,EACP,OAA2B;IAE3B,OAAO,MAAM,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG;YACd,IAAI;YACJ,OAAO;SACO,CAAA,CAAC,+BAA+B;QAChD,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,kBAAkB;YACxB,OAAO;SACR,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;YAC/B,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SAChD,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
1
+ {"version":3,"file":"appendMessage.js","sourceRoot":"","sources":["../../actions/appendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,OAAO,EAA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,35 +1,39 @@
1
1
  import { Action } from "../Action.ts";
2
- import type { ActorLike, ActorLikeArray, ActorLikeRecord, ActorLikesT, ActorLikeT, ActorLikeY } from "../Actor.ts";
2
+ import type { AgentLike, AgentLikeT, AgentLikeY } from "../Agent.ts";
3
3
  import type { Spec } from "../Spec.ts";
4
4
  import type { JSONKey } from "../util/JSONKey.ts";
5
- export declare function branch<K extends JSONKey, Y extends Action, T>(key: K, actorLike: ActorLike<Y, T>): Generator<Action<"branch", Spec.Make<{
5
+ export declare function branch<K extends JSONKey, Y extends Action, T>(key: K, agentLike: AgentLike<Y, T>): Generator<Action<"branch", Spec.Make<{
6
6
  Child: [Y[""]] extends [never] ? never : [K, Y[""]];
7
7
  Entry: Y[""]["Entry"];
8
8
  Value: T;
9
9
  }>>, T>;
10
- export declare function branch<K extends JSONKey, const A extends ActorLikeArray>(name: K, actorLikeArray: A): Generator<Action<"branch", Spec.Make<{
10
+ export declare function branch<K extends JSONKey, const A extends Array<AgentLike>>(name: K, agentLikes: A): Generator<Action<"branch", Spec.Make<{
11
11
  Child: [
12
12
  K,
13
13
  {
14
14
  [L in keyof A]: Spec.Make<{
15
- Child: [L, ActorLikeY<A[L]>[""]];
16
- Entry: ActorLikeY<A[L]>[""]["Entry"];
17
- Value: ActorLikeT<A[L]>;
15
+ Child: [L, AgentLikeY<A[L]>[""]];
16
+ Entry: AgentLikeY<A[L]>[""]["Entry"];
17
+ Value: AgentLikeT<A[L]>;
18
18
  }>;
19
19
  }[keyof A]
20
20
  ];
21
- Entry: ActorLikeY<A[number]>[""]["Entry"];
22
- }>>, ActorLikesT<A>>;
23
- export declare function branch<K extends JSONKey, A extends ActorLikeRecord>(name: K, actorLikeRecord: A): Generator<Action<"branch", Spec.Make<{
21
+ Entry: AgentLikeY<A[number]>[""]["Entry"];
22
+ }>>, AgentLikesT<A>>;
23
+ export declare function branch<K extends JSONKey, A extends Record<JSONKey, AgentLike>>(name: K, agentLikes: A): Generator<Action<"branch", Spec.Make<{
24
24
  Child: [
25
25
  K,
26
26
  {
27
27
  [L in Exclude<keyof A, symbol>]: Spec.Make<{
28
- Child: [L, ActorLikeY<A[L]>[""]];
29
- Entry: ActorLikeY<A[L]>[""]["Entry"];
30
- Value: ActorLikeT<A[L]>;
28
+ Child: [L, AgentLikeY<A[L]>[""]];
29
+ Entry: AgentLikeY<A[L]>[""]["Entry"];
30
+ Value: AgentLikeT<A[L]>;
31
31
  }>;
32
32
  }[Exclude<keyof A, symbol>]
33
33
  ];
34
- Entry: ActorLikeY<A[keyof A]>[""]["Entry"];
35
- }>>, ActorLikesT<A>>;
34
+ Entry: AgentLikeY<A[keyof A]>[""]["Entry"];
35
+ }>>, AgentLikesT<A>>;
36
+ export type AgentLikes = Array<AgentLike> | Record<JSONKey, AgentLike>;
37
+ export type AgentLikesT<A extends AgentLikes> = {
38
+ -readonly [K in keyof A]: A[K] extends AgentLike<Action, infer T> ? T : never;
39
+ } & {};
@@ -1,11 +1,11 @@
1
1
  import { Action } from "../Action.js";
2
2
  import { unwrapDeferred } from "../util/unwrapDeferred.js";
3
- export function* branch(key, implementation) {
3
+ export function* branch(key, a1) {
4
4
  return yield Action("branch", async (scope) => {
5
- if (typeof implementation === "function") {
5
+ if (typeof a1 === "function") {
6
6
  const branchScope = scope.fork("branch", [key]);
7
- const actor = unwrapDeferred(implementation);
8
- const { value } = await branchScope.reduce(actor);
7
+ const agent = unwrapDeferred(a1);
8
+ const { value } = await branchScope.reduce(agent);
9
9
  branchScope.event({
10
10
  type: "returned",
11
11
  value,
@@ -15,20 +15,20 @@ export function* branch(key, implementation) {
15
15
  nextArg: value,
16
16
  };
17
17
  }
18
- const armKeys = Array.isArray(implementation)
19
- ? Array.from({ length: implementation.length }, (_0, i) => i)
20
- : Reflect.ownKeys(implementation);
18
+ const armKeys = Array.isArray(a1)
19
+ ? Array.from({ length: a1.length }, (_0, i) => i)
20
+ : Reflect.ownKeys(a1);
21
21
  const values = await Promise.all(armKeys.map(async (armKey) => {
22
22
  const branchArmScope = scope.fork("branch_arm", [key, armKey]);
23
- const actor = unwrapDeferred(implementation[armKey]);
24
- const { value } = await branchArmScope.reduce(actor);
23
+ const agent = unwrapDeferred(a1[armKey]);
24
+ const { value } = await branchArmScope.reduce(agent);
25
25
  branchArmScope.event({
26
26
  type: "returned",
27
27
  value,
28
28
  });
29
29
  return value;
30
30
  }));
31
- const value = Array.isArray(implementation)
31
+ const value = Array.isArray(a1)
32
32
  ? values
33
33
  : Object.fromEntries(armKeys.map((key, i) => [key, values[i]]));
34
34
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"branch.js","sourceRoot":"","sources":["../../actions/branch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAarC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AA0D1D,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,GAAY,EAAE,cAAsC;IAC1E,OAAO,MAAM,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC5C,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAC/C,MAAM,KAAK,GAAG,cAAc,CAAC,cAA2B,CAAC,CAAA;YACzD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACjD,WAAW,CAAC,KAAK,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,KAAK;aACN,CAAC,CAAA;YACF,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,KAAK;aACf,CAAA;QACH,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;YAC3C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,MAAM,EAA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AO,KAAK,CAAA;QACd,CAAC,CAAC,CAAC,CAAA;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACjE,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK;SACf,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { Action } from "../Action.ts";
2
- import type { ActorLike } from "../Actor.ts";
2
+ import type { AgentLike } from "../Agent.ts";
3
3
  import type { Spec } from "../Spec.ts";
4
4
  import type { JSONKey } from "../util/JSONKey.ts";
5
5
  import type { Result } from "../util/Result.ts";
6
6
  export { catch_ as catch };
7
- declare function catch_<K extends JSONKey, Y extends Action, T>(key: K, actorLike: ActorLike<Y, T>): Generator<Action<"catch", Spec.Make<{
7
+ declare function catch_<K extends JSONKey, Y extends Action, T>(key: K, agentLike: AgentLike<Y, T>): Generator<Action<"catch", Spec.Make<{
8
8
  Child: [K, Y[""]];
9
9
  Value: T;
10
10
  }>>, Result<T, Y[""]["Throw"]>>;
@@ -1,11 +1,11 @@
1
1
  import { Action } from "../Action.js";
2
2
  import { unwrapDeferred } from "../util/unwrapDeferred.js";
3
3
  export { catch_ as catch };
4
- function* catch_(key, actorLike) {
4
+ function* catch_(key, agentLike) {
5
5
  return yield Action("catch", async (scope) => {
6
6
  const catchScope = scope.fork("catch", [key]);
7
7
  try {
8
- const { value } = await catchScope.reduce(unwrapDeferred(actorLike));
8
+ const { value } = await catchScope.reduce(unwrapDeferred(agentLike));
9
9
  catchScope.event({
10
10
  type: "returned",
11
11
  value,
@@ -1,8 +1,9 @@
1
1
  import { Action } from "../Action.js";
2
2
  import { assert } from "../util/assert.js";
3
+ import { peekLast } from "../util/peekLast.js";
3
4
  export function* embed(value) {
4
5
  return yield Action("embed", async (scope) => {
5
- const model = scope.embeddingModels.values().next().value;
6
+ const model = peekLast(scope.embeddingModels);
6
7
  assert(model);
7
8
  scope.event({
8
9
  type: "embedding_requested",
@@ -1 +1 @@
1
- {"version":3,"file":"embed.js","sourceRoot":"","sources":["../../actions/embed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAI1C,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,KAAa;IAClC,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;QACzD,MAAM,CAAC,KAAK,CAAC,CAAA;QACb,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,KAAK;SACN,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1C,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,UAAU;YAChB,KAAK;YACL,SAAS;SACV,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,KAAK;SACrB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
1
+ {"version":3,"file":"embed.js","sourceRoot":"","sources":["../../actions/embed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI9C,MAAM,SAAS,CAAC,CAAC,KAAK,CAAC,KAAa;IAClC,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;QAC7C,MAAM,CAAC,KAAK,CAAC,CAAA;QACb,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,qBAAqB;YAC3B,KAAK;SACN,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1C,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,UAAU;YAChB,KAAK;YACL,SAAS;SACV,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,KAAK;SACrB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { StandardSchemaV1 } from "@standard-schema/spec";
2
2
  import { Action } from "../Action.ts";
3
- import type { Actor } from "../Actor.ts";
3
+ import type { Agent } from "../Agent.ts";
4
4
  import type { ToolCalled } from "../events/ToolCalled.ts";
5
5
  import type { ToolEnabled } from "../events/ToolEnabled.ts";
6
6
  import type { Spec } from "../Spec.ts";
@@ -12,7 +12,7 @@ import { disableTool } from "./disableTool.ts";
12
12
  export declare function enableTool<K extends JSONKey, A>(key: K, description: string, params: StandardSchemaV1<JSONObject, A>, implementation: (params: A) => PromiseOr<ToolResult>): Generator<Action<"enable_tool", Spec.Make<{
13
13
  Event: ToolEnabled<K> | ToolCalled<K, A>;
14
14
  }>>, Generator<disableTool<K>, void>>;
15
- export declare function enableTool<K extends JSONKey, A, Y extends Action, T extends ToolResult>(key: K, description: string, params: StandardSchemaV1<JSONObject, A>, implementation: (params: A) => Actor<Y, T>): Generator<Action<"enable_tool", Spec.Make<{
15
+ export declare function enableTool<K extends JSONKey, A, Y extends Action, T extends ToolResult>(key: K, description: string, params: StandardSchemaV1<JSONObject, A>, implementation: (params: A) => Agent<Y, T>): Generator<Action<"enable_tool", Spec.Make<{
16
16
  Event: ToolEnabled<K> | ToolCalled<K, A>;
17
17
  Child: [K, Y[""]];
18
18
  Entry: Y[""]["Entry"];
@@ -1,5 +1,5 @@
1
1
  import * as L from "../L.js";
2
- import { ActorAssertions } from "../testing/ActorAssertions.js";
2
+ import { AgentAssertions } from "../testing/AgentAssertions.js";
3
3
  import { emit } from "./emit.js";
4
4
  import { enableTool } from "./enableTool.js";
5
5
  const P = L.object({
@@ -8,16 +8,16 @@ const P = L.object({
8
8
  });
9
9
  const arrowTool = L.enableTool("Tool", "", P, (params) => {
10
10
  });
11
- ActorAssertions(arrowTool).assertSpec();
11
+ AgentAssertions(arrowTool).assertSpec();
12
12
  function* _0() {
13
13
  const detach = yield* arrowTool;
14
- ActorAssertions(detach).assertSpec();
14
+ AgentAssertions(detach).assertSpec();
15
15
  }
16
16
  const genTool = enableTool("tool-key", "", P, function* (params) {
17
17
  yield* emit("Test");
18
18
  return "";
19
19
  });
20
- ActorAssertions(genTool).assertSpec();
20
+ AgentAssertions(genTool).assertSpec();
21
21
  function* parent() {
22
22
  yield* L.enableTool("parent-tool", "", P, () => { });
23
23
  yield* L.branch("fork-key", {
@@ -26,5 +26,5 @@ function* parent() {
26
26
  },
27
27
  });
28
28
  }
29
- ActorAssertions(parent).assertSpec();
29
+ AgentAssertions(parent).assertSpec();
30
30
  //# sourceMappingURL=enableTool.type-test.js.map
@@ -10,4 +10,6 @@ interface infer_<_T> extends Action<"infer", Spec.Make<{
10
10
  Event: InferenceRequested | Inferred;
11
11
  }>> {
12
12
  }
13
- declare function infer_<T extends JSONValue = string>(type?: StandardSchemaV1<JSONObject, T>): Generator<infer_<T>, T>;
13
+ declare const infer_: (<T extends JSONValue>(type: StandardSchemaV1<JSONObject, T>) => Generator<infer_<T>, T>) & {
14
+ [Symbol.iterator](): Iterator<infer_<string>, string>;
15
+ };
@@ -1,11 +1,20 @@
1
1
  import { Action } from "../Action.js";
2
+ import { peekLast } from "../util/peekLast.js";
2
3
  export { infer_ as infer };
3
- function* infer_(type) {
4
+ const infer_ = Object.assign(function* infer_(type) {
5
+ return yield* impl(type);
6
+ }, {
7
+ *[Symbol.iterator]() {
8
+ return yield* impl();
9
+ },
10
+ });
11
+ Object.defineProperty(infer_, "name", { value: "infer" });
12
+ function* impl(type) {
4
13
  return yield Action("infer", async (scope) => {
5
14
  scope.event({
6
15
  type: "inference_requested",
7
16
  });
8
- const model = scope.languageModels.values().next().value;
17
+ const model = peekLast(scope.languageModels);
9
18
  scope = await scope.reduce(model.infer(type));
10
19
  scope.event({
11
20
  type: "inferred",
@@ -17,5 +26,4 @@ function* infer_(type) {
17
26
  };
18
27
  });
19
28
  }
20
- Object.defineProperty(infer_, "name", { value: "infer" });
21
29
  //# sourceMappingURL=infer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"infer.js","sourceRoot":"","sources":["../../actions/infer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAOrC,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAA;AAW1B,QAAQ,CAAC,CAAC,MAAM,CAA+B,IAAsC;IACnF,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC3C,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,qBAAqB;SAC5B,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAM,CAAA;QACzD,KAAK,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC7C,KAAK,CAAC,KAAK,CAAC;YACV,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KA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,CAAC,CAAA;QACF,OAAO;YACL,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,KAAK;SACrB,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Action } from "../Action.ts";
2
+ import type { Agent } from "../Agent.ts";
3
+ import type { MessagesSet } from "../events/MessagesSet.ts";
4
+ import type { Message } from "../Message.ts";
5
+ import type { Spec } from "../Spec.ts";
6
+ import type { JSONKey } from "../util/JSONKey.ts";
7
+ import type { PromiseOr } from "../util/PromiseOr.ts";
8
+ import { type getScope } from "./scope.ts";
9
+ interface messages extends Iterable<getScope, Set<Message>> {
10
+ (messages: Array<Message>): Generator<Action<"set_messages", Spec.Make<{
11
+ Event: MessagesSet;
12
+ }>>, Array<Message>>;
13
+ (setter: (messages: Array<Message>) => PromiseOr<Array<Message>>): Generator<Action<"set_messages", Spec.Make<{
14
+ Event: MessagesSet;
15
+ }>>, Array<Message>>;
16
+ <K extends JSONKey, Y extends Action>(key: K, setter: (messages: Array<Message>) => Agent<Y, void>): Generator<Action<"set_messages", Spec.Make<{
17
+ Event: MessagesSet;
18
+ Child: [K, Y[""]];
19
+ Entry: Y[""]["Entry"];
20
+ Value: Array<Message>;
21
+ }>>, Array<Message>>;
22
+ }
23
+ export declare const messages: messages;
24
+ export {};