@dxos/assistant 0.8.2-main.f11618f → 0.8.2-staging.7ac8446

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 (77) hide show
  1. package/dist/lib/browser/{chunk-DEIGOD4U.mjs → chunk-PND5VR6D.mjs} +84 -91
  2. package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +153 -275
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +25 -25
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-7VH7NMIM.cjs → chunk-IBOBRBDF.cjs} +98 -106
  9. package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +183 -302
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +33 -33
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/{chunk-7JI4MDGL.mjs → chunk-DCQJOLSR.mjs} +84 -91
  16. package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +153 -275
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +25 -25
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/ai-service/edge-client.d.ts +5 -4
  23. package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/message-collector.d.ts +6 -0
  25. package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
  26. package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
  27. package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
  28. package/dist/types/src/ai-service/parser.d.ts +3 -0
  29. package/dist/types/src/ai-service/parser.d.ts.map +1 -1
  30. package/dist/types/src/ai-service/service.d.ts +2 -18
  31. package/dist/types/src/ai-service/service.d.ts.map +1 -1
  32. package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
  33. package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
  34. package/dist/types/src/ai-service/types.d.ts +9 -52
  35. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  36. package/dist/types/src/conversation/conversation.d.ts +3 -0
  37. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  38. package/dist/types/src/conversation/types.d.ts +3 -2
  39. package/dist/types/src/conversation/types.d.ts.map +1 -1
  40. package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
  41. package/dist/types/src/session/index.d.ts +0 -1
  42. package/dist/types/src/session/index.d.ts.map +1 -1
  43. package/dist/types/src/session/session.d.ts +10 -29
  44. package/dist/types/src/session/session.d.ts.map +1 -1
  45. package/dist/types/src/testing/test-schema.d.ts +2 -2
  46. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  47. package/package.json +13 -13
  48. package/src/ai-service/client.test.ts +68 -50
  49. package/src/ai-service/edge-client.ts +20 -13
  50. package/src/ai-service/ollama-client.ts +2 -9
  51. package/src/ai-service/parser.ts +2 -13
  52. package/src/ai-service/service.ts +3 -19
  53. package/src/ai-service/testing/mock.ts +1 -9
  54. package/src/ai-service/types.ts +6 -15
  55. package/src/bin/chat.ts +3 -3
  56. package/src/conversation/conversation.ts +11 -5
  57. package/src/conversation/types.ts +4 -1
  58. package/src/cypher/combinators.test.ts +4 -4
  59. package/src/cypher/echo-data-source.ts +2 -1
  60. package/src/cypher/execution-plan.test.ts +1 -1
  61. package/src/cypher/query-executor.test.ts +1 -1
  62. package/src/cypher/schema.test.ts +3 -3
  63. package/src/session/index.ts +0 -1
  64. package/src/session/session.test.ts +7 -8
  65. package/src/session/session.ts +148 -284
  66. package/src/testing/query.test.ts +19 -17
  67. package/src/testing/test-data.ts +22 -22
  68. package/src/testing/test-schema.ts +3 -3
  69. package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +0 -7
  70. package/dist/lib/node/chunk-7VH7NMIM.cjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +0 -7
  72. package/dist/types/src/session/version-pin.d.ts +0 -17
  73. package/dist/types/src/session/version-pin.d.ts.map +0 -1
  74. package/dist/types/src/session/version-pin.test.d.ts +0 -2
  75. package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
  76. package/src/session/version-pin.test.ts +0 -26
  77. package/src/session/version-pin.ts +0 -43
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_7VH7NMIM_exports = {};
30
- __export(chunk_7VH7NMIM_exports, {
29
+ var chunk_IBOBRBDF_exports = {};
30
+ __export(chunk_IBOBRBDF_exports, {
31
31
  AIServiceEdgeClient: () => AIServiceEdgeClient,
32
32
  DEFAULT_EDGE_MODEL: () => DEFAULT_EDGE_MODEL,
33
33
  DEFAULT_EDGE_MODELS: () => DEFAULT_EDGE_MODELS,
@@ -36,7 +36,6 @@ __export(chunk_7VH7NMIM_exports, {
36
36
  DEFAULT_OLLAMA_MODELS: () => DEFAULT_OLLAMA_MODELS,
37
37
  EchoDataSource: () => EchoDataSource,
38
38
  GenerateRequest: () => GenerateRequest,
39
- GenerateResponse: () => GenerateResponse,
40
39
  GenerationStreamImpl: () => GenerationStreamImpl,
41
40
  LLMModel: () => LLMModel,
42
41
  MessageCollector: () => MessageCollector,
@@ -60,26 +59,29 @@ __export(chunk_7VH7NMIM_exports, {
60
59
  runTools: () => runTools,
61
60
  trim: () => trim
62
61
  });
63
- module.exports = __toCommonJS(chunk_7VH7NMIM_exports);
62
+ module.exports = __toCommonJS(chunk_IBOBRBDF_exports);
64
63
  var import_async = require("@dxos/async");
65
64
  var import_log = require("@dxos/log");
66
- var import_invariant = require("@dxos/invariant");
67
- var import_log2 = require("@dxos/log");
68
65
  var import_effect = require("effect");
69
66
  var import_artifact = require("@dxos/artifact");
67
+ var import_invariant = require("@dxos/invariant");
68
+ var import_log2 = require("@dxos/log");
69
+ var import_effect2 = require("effect");
70
70
  var import_artifact2 = require("@dxos/artifact");
71
71
  var import_echo_schema = require("@dxos/echo-schema");
72
- var import_invariant2 = require("@dxos/invariant");
73
- var import_log3 = require("@dxos/log");
74
- var import_effect2 = require("effect");
75
72
  var import_artifact3 = require("@dxos/artifact");
76
73
  var import_echo_schema2 = require("@dxos/echo-schema");
74
+ var import_invariant2 = require("@dxos/invariant");
75
+ var import_log3 = require("@dxos/log");
76
+ var import_effect3 = require("effect");
77
+ var import_artifact4 = require("@dxos/artifact");
78
+ var import_echo_schema3 = require("@dxos/echo-schema");
77
79
  var import_invariant3 = require("@dxos/invariant");
78
80
  var import_log4 = require("@dxos/log");
79
81
  var P = __toESM(require("parsimmon"));
80
- var import_artifact4 = require("@dxos/artifact");
82
+ var import_artifact5 = require("@dxos/artifact");
81
83
  var import_async2 = require("@dxos/async");
82
- var import_echo_schema3 = require("@dxos/echo-schema");
84
+ var import_echo_schema4 = require("@dxos/echo-schema");
83
85
  var import_invariant4 = require("@dxos/invariant");
84
86
  var import_log5 = require("@dxos/log");
85
87
  var import_util = require("@dxos/util");
@@ -89,10 +91,11 @@ var import_util2 = require("@dxos/util");
89
91
  var import_invariant5 = require("@dxos/invariant");
90
92
  var import_log7 = require("@dxos/log");
91
93
  var import_debug = require("@dxos/debug");
92
- var import_echo_schema4 = require("@dxos/echo-schema");
94
+ var import_echo_schema5 = require("@dxos/echo-schema");
93
95
  var import_debug2 = require("@dxos/debug");
94
96
  var import_echo_db = require("@dxos/echo-db");
95
- var import_echo_schema5 = require("@dxos/echo-schema");
97
+ var import_echo_schema6 = require("@dxos/echo-schema");
98
+ var import_live_object = require("@dxos/live-object");
96
99
  var import_log8 = require("@dxos/log");
97
100
  var DEFAULT_EDGE_MODEL = "@anthropic/claude-3-5-sonnet-20241022";
98
101
  var DEFAULT_EDGE_MODELS = [
@@ -448,7 +451,7 @@ var AIServiceEdgeClient = class {
448
451
  constructor({ endpoint }) {
449
452
  (0, import_invariant.invariant)(endpoint, "endpoint is required", {
450
453
  F: __dxlog_file2,
451
- L: 20,
454
+ L: 23,
452
455
  S: this,
453
456
  A: [
454
457
  "endpoint",
@@ -458,21 +461,34 @@ var AIServiceEdgeClient = class {
458
461
  this._endpoint = endpoint;
459
462
  }
460
463
  /**
461
- * Generate non-streaming response.
464
+ * @deprecated
462
465
  */
463
- async exec(request) {
464
- throw new Error("Not implemented");
466
+ // TODO(burdon): Remove.
467
+ async appendMessages(messages) {
468
+ const url = `${this._endpoint}/message`;
469
+ const res = await fetch(url, {
470
+ method: "POST",
471
+ headers: {
472
+ "Content-Type": "application/json"
473
+ },
474
+ body: JSON.stringify({
475
+ messages: await import_effect.Schema.encodePromise(import_effect.Schema.Array(import_artifact.Message))(messages)
476
+ })
477
+ });
478
+ if (!res.ok) {
479
+ throw new Error(`${await res.text()} [${url}]`);
480
+ }
465
481
  }
466
482
  /**
467
483
  * Process request and open message stream.
468
484
  */
469
- async execStream(request) {
485
+ async exec(request) {
470
486
  (0, import_invariant.assertArgument)(typeof request.model === "string", "model is required");
471
487
  (0, import_log2.log)("requesting", {
472
488
  endpoint: this._endpoint
473
489
  }, {
474
490
  F: __dxlog_file2,
475
- L: 36,
491
+ L: 51,
476
492
  S: this,
477
493
  C: (f, a) => f(...a)
478
494
  });
@@ -489,12 +505,9 @@ var AIServiceEdgeClient = class {
489
505
  ...request
490
506
  })
491
507
  });
492
- if (!response.ok) {
493
- throw await parseErrorResponse(response);
494
- }
495
508
  (0, import_invariant.invariant)(response.body instanceof ReadableStream, void 0, {
496
509
  F: __dxlog_file2,
497
- L: 53,
510
+ L: 64,
498
511
  S: this,
499
512
  A: [
500
513
  "response.body instanceof ReadableStream",
@@ -504,9 +517,6 @@ var AIServiceEdgeClient = class {
504
517
  return createGenerationStream(response, controller);
505
518
  }
506
519
  };
507
- var parseErrorResponse = async (response) => {
508
- throw new Error(`AI Service error: ${response.status} ${response.statusText} ${await response.text()}`);
509
- };
510
520
  var MessageCollector = class {
511
521
  constructor() {
512
522
  this._messages = [];
@@ -572,41 +582,36 @@ function* emitMessageAsEvents(message) {
572
582
  };
573
583
  }
574
584
  var createArtifactElement = (id) => `<artifact id=${id} />`;
575
- var LLMModel = import_effect.Schema.Literal(...DEFAULT_EDGE_MODELS, ...DEFAULT_OLLAMA_MODELS);
585
+ var LLMModel = import_effect2.Schema.Literal(...DEFAULT_EDGE_MODELS, ...DEFAULT_OLLAMA_MODELS);
576
586
  var ToolTypes = Object.freeze({
577
587
  // TODO(dmaretskyi): Not implemented yet.
578
588
  // DatabaseQuery: 'database_query',
579
589
  TextToImage: "text_to_image"
580
590
  });
581
- var GenerateRequest = import_effect.Schema.Struct({
591
+ var GenerateRequest = import_effect2.Schema.Struct({
592
+ spaceId: import_effect2.Schema.optional(import_artifact2.SpaceIdSchema),
593
+ threadId: import_effect2.Schema.optional(import_echo_schema.ObjectId),
582
594
  /**
583
595
  * Preferred model or system default.
584
596
  */
585
- model: import_effect.Schema.optional(LLMModel),
597
+ model: import_effect2.Schema.optional(LLMModel),
586
598
  /**
587
599
  * Tools available for the LLM.
588
600
  */
589
- tools: import_effect.Schema.optional(import_effect.Schema.Array(import_artifact.Tool).pipe(import_effect.Schema.mutable)),
601
+ tools: import_effect2.Schema.optional(import_effect2.Schema.Array(import_artifact2.Tool).pipe(import_effect2.Schema.mutable)),
590
602
  /**
591
603
  * System instructions to the LLM.
592
604
  */
593
- systemPrompt: import_effect.Schema.optional(import_effect.Schema.String),
605
+ systemPrompt: import_effect2.Schema.optional(import_effect2.Schema.String),
594
606
  /**
595
607
  * History of messages to include in the context window.
596
608
  */
597
609
  // TODO(burdon): Rename messages.
598
- history: import_effect.Schema.optional(import_effect.Schema.Array(import_artifact.Message)),
610
+ history: import_effect2.Schema.optional(import_effect2.Schema.Array(import_artifact2.Message)),
599
611
  /**
600
612
  * Current request.
601
613
  */
602
- prompt: import_effect.Schema.optional(import_artifact.Message)
603
- });
604
- var GenerateResponse = import_effect.Schema.Struct({
605
- messages: import_effect.Schema.Array(import_artifact.Message),
606
- /**
607
- * Number of tokens used in the response.
608
- */
609
- tokenCount: import_effect.Schema.optional(import_effect.Schema.Number)
614
+ prompt: import_effect2.Schema.optional(import_artifact2.Message)
610
615
  });
611
616
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/experimental/assistant/src/conversation/conversation.ts";
612
617
  var runLLM = async (params) => {
@@ -622,8 +627,10 @@ var runLLM = async (params) => {
622
627
  C: (f, a) => f(...a)
623
628
  });
624
629
  const beginTs = Date.now();
625
- const stream = await params.client.execStream({
630
+ const stream = await params.client.exec({
626
631
  model: params.model,
632
+ spaceId: params.spaceId,
633
+ threadId: params.threadId,
627
634
  history,
628
635
  systemPrompt: params.system,
629
636
  tools: params.tools
@@ -636,7 +643,7 @@ var runLLM = async (params) => {
636
643
  const message = messages.at(-1);
637
644
  (0, import_invariant2.invariant)(message, void 0, {
638
645
  F: __dxlog_file3,
639
- L: 61,
646
+ L: 63,
640
647
  S: void 0,
641
648
  A: [
642
649
  "message",
@@ -648,13 +655,13 @@ var runLLM = async (params) => {
648
655
  message
649
656
  }, {
650
657
  F: __dxlog_file3,
651
- L: 63,
658
+ L: 65,
652
659
  S: void 0,
653
660
  C: (f, a) => f(...a)
654
661
  });
655
662
  (0, import_invariant2.invariant)(message, void 0, {
656
663
  F: __dxlog_file3,
657
- L: 64,
664
+ L: 66,
658
665
  S: void 0,
659
666
  A: [
660
667
  "message",
@@ -674,7 +681,7 @@ var runLLM = async (params) => {
674
681
  const toolCalls = message.content.filter((block) => block.type === "tool_use");
675
682
  (0, import_invariant2.invariant)(toolCalls.length === 1, void 0, {
676
683
  F: __dxlog_file3,
677
- L: 75,
684
+ L: 77,
678
685
  S: void 0,
679
686
  A: [
680
687
  "toolCalls.length === 1",
@@ -688,7 +695,7 @@ var runLLM = async (params) => {
688
695
  }
689
696
  (0, import_invariant2.invariant)(tool.execute, void 0, {
690
697
  F: __dxlog_file3,
691
- L: 82,
698
+ L: 84,
692
699
  S: void 0,
693
700
  A: [
694
701
  "tool.execute",
@@ -702,12 +709,14 @@ var runLLM = async (params) => {
702
709
  message: toolResult.message
703
710
  }, {
704
711
  F: __dxlog_file3,
705
- L: 86,
712
+ L: 88,
706
713
  S: void 0,
707
714
  C: (f, a) => f(...a)
708
715
  });
709
716
  const resultMessage = {
710
- id: import_echo_schema.ObjectId.random(),
717
+ id: import_echo_schema2.ObjectId.random(),
718
+ spaceId: params.spaceId,
719
+ threadId: params.threadId,
711
720
  role: "user",
712
721
  content: [
713
722
  {
@@ -730,12 +739,14 @@ var runLLM = async (params) => {
730
739
  result: toolResult.result
731
740
  }, {
732
741
  F: __dxlog_file3,
733
- L: 106,
742
+ L: 110,
734
743
  S: void 0,
735
744
  C: (f, a) => f(...a)
736
745
  });
737
746
  const resultMessage = {
738
- id: import_echo_schema.ObjectId.random(),
747
+ id: import_echo_schema2.ObjectId.random(),
748
+ spaceId: params.spaceId,
749
+ threadId: params.threadId,
739
750
  role: "user",
740
751
  content: [
741
752
  {
@@ -757,7 +768,7 @@ var runLLM = async (params) => {
757
768
  result: toolResult.result
758
769
  }, {
759
770
  F: __dxlog_file3,
760
- L: 125,
771
+ L: 131,
761
772
  S: void 0,
762
773
  C: (f, a) => f(...a)
763
774
  });
@@ -779,7 +790,7 @@ var isToolUse = (message, { onlyToolNames } = {}) => {
779
790
  const block = message.content.at(-1);
780
791
  (0, import_invariant2.invariant)(block, void 0, {
781
792
  F: __dxlog_file3,
782
- L: 146,
793
+ L: 152,
783
794
  S: void 0,
784
795
  A: [
785
796
  "block",
@@ -792,7 +803,7 @@ var runTools = async ({ message, tools, extensions }) => {
792
803
  const toolCalls = message.content.filter((block) => block.type === "tool_use");
793
804
  (0, import_invariant2.invariant)(toolCalls.length === 1, void 0, {
794
805
  F: __dxlog_file3,
795
- L: 168,
806
+ L: 174,
796
807
  S: void 0,
797
808
  A: [
798
809
  "toolCalls.length === 1",
@@ -802,7 +813,7 @@ var runTools = async ({ message, tools, extensions }) => {
802
813
  const toolCall = toolCalls[0];
803
814
  const tool = tools.find((tool2) => tool2.name === toolCall.name);
804
815
  if (!tool) {
805
- const resultMessage = (0, import_echo_schema.create)(import_artifact2.Message, {
816
+ const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
806
817
  role: "user",
807
818
  content: [
808
819
  {
@@ -822,7 +833,7 @@ var runTools = async ({ message, tools, extensions }) => {
822
833
  try {
823
834
  (0, import_invariant2.invariant)(tool.execute, void 0, {
824
835
  F: __dxlog_file3,
825
- L: 193,
836
+ L: 199,
826
837
  S: void 0,
827
838
  A: [
828
839
  "tool.execute",
@@ -837,11 +848,11 @@ var runTools = async ({ message, tools, extensions }) => {
837
848
  error
838
849
  }, {
839
850
  F: __dxlog_file3,
840
- L: 196,
851
+ L: 202,
841
852
  S: void 0,
842
853
  C: (f, a) => f(...a)
843
854
  });
844
- toolResult = import_artifact2.ToolResult.Error(error.message);
855
+ toolResult = import_artifact3.ToolResult.Error(error.message);
845
856
  }
846
857
  switch (toolResult.kind) {
847
858
  case "error": {
@@ -849,11 +860,11 @@ var runTools = async ({ message, tools, extensions }) => {
849
860
  message: toolResult.message
850
861
  }, {
851
862
  F: __dxlog_file3,
852
- L: 202,
863
+ L: 208,
853
864
  S: void 0,
854
865
  C: (f, a) => f(...a)
855
866
  });
856
- const resultMessage = (0, import_echo_schema.create)(import_artifact2.Message, {
867
+ const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
857
868
  role: "user",
858
869
  content: [
859
870
  {
@@ -874,11 +885,11 @@ var runTools = async ({ message, tools, extensions }) => {
874
885
  result: toolResult.result
875
886
  }, {
876
887
  F: __dxlog_file3,
877
- L: 223,
888
+ L: 229,
878
889
  S: void 0,
879
890
  C: (f, a) => f(...a)
880
891
  });
881
- const resultMessage = (0, import_echo_schema.create)(import_artifact2.Message, {
892
+ const resultMessage = (0, import_echo_schema2.createStatic)(import_artifact3.Message, {
882
893
  role: "user",
883
894
  content: [
884
895
  {
@@ -899,7 +910,7 @@ var runTools = async ({ message, tools, extensions }) => {
899
910
  result: toolResult.result
900
911
  }, {
901
912
  F: __dxlog_file3,
902
- L: 244,
913
+ L: 250,
903
914
  S: void 0,
904
915
  C: (f, a) => f(...a)
905
916
  });
@@ -1052,14 +1063,14 @@ var OllamaClient = class {
1052
1063
  signal
1053
1064
  });
1054
1065
  if (!response.ok) {
1055
- throw await parseErrorResponse2(response);
1066
+ throw await parseErrorResponse(response);
1056
1067
  }
1057
1068
  if (!response.body) {
1058
1069
  throw new Error("Ollama API returned no response body");
1059
1070
  }
1060
1071
  const reader = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new OllamaDecoderStream()).getReader();
1061
1072
  try {
1062
- const messageId = import_echo_schema2.ObjectId.random();
1073
+ const messageId = import_echo_schema3.ObjectId.random();
1063
1074
  yield {
1064
1075
  type: "message_start",
1065
1076
  message: {
@@ -1119,7 +1130,7 @@ var OllamaClient = class {
1119
1130
  index: currentBlockIndex,
1120
1131
  content: {
1121
1132
  type: "tool_use",
1122
- id: import_echo_schema2.ObjectId.random(),
1133
+ id: import_echo_schema3.ObjectId.random(),
1123
1134
  name: data.message.tool_calls[0].function.name,
1124
1135
  input: sanitizeToolArguments(data.message.tool_calls[0].function.arguments)
1125
1136
  }
@@ -1143,13 +1154,7 @@ var OllamaClient = class {
1143
1154
  reader.releaseLock();
1144
1155
  }
1145
1156
  }
1146
- /**
1147
- * Generate non-streaming response.
1148
- */
1149
1157
  async exec(request) {
1150
- throw new Error("Not implemented");
1151
- }
1152
- async execStream(request) {
1153
1158
  const controller = new AbortController();
1154
1159
  try {
1155
1160
  return new GenerationStreamImpl(controller, async function* () {
@@ -1208,19 +1213,19 @@ var sanitizeToolArguments = (args) => {
1208
1213
  };
1209
1214
  var SAMPLE_IMAGE_URL = "https://images.nightcafe.studio/jobs/BNmcRhHCM1JRKoUtqSei/BNmcRhHCM1JRKoUtqSei--1--5b9rv.jpg";
1210
1215
  var WELL_KNOWN_TOOLS = {
1211
- [ToolTypes.TextToImage]: (0, import_artifact3.defineTool)("system", {
1216
+ [ToolTypes.TextToImage]: (0, import_artifact4.defineTool)("system", {
1212
1217
  name: "text-to-image",
1213
1218
  description: "Generate an image from a text prompt",
1214
- schema: import_effect2.Schema.Struct({
1215
- prompt: import_effect2.Schema.String.annotations({
1219
+ schema: import_effect3.Schema.Struct({
1220
+ prompt: import_effect3.Schema.String.annotations({
1216
1221
  description: "The text prompt describing the image to generate"
1217
1222
  })
1218
1223
  }),
1219
1224
  execute: async ({ prompt }) => {
1220
1225
  const image = await fetch(SAMPLE_IMAGE_URL).then(async (res) => Buffer.from(await res.arrayBuffer()));
1221
1226
  const imageBase64 = image.toString("base64");
1222
- const id = import_echo_schema2.ObjectId.random();
1223
- return import_artifact3.ToolResult.Success(`The generation was successful. Image ID: ${id} Prompt: ${prompt}`, [
1227
+ const id = import_echo_schema3.ObjectId.random();
1228
+ return import_artifact4.ToolResult.Success(`The generation was successful. Image ID: ${id} Prompt: ${prompt}`, [
1224
1229
  {
1225
1230
  type: "image",
1226
1231
  id,
@@ -1255,12 +1260,12 @@ var OllamaDecoderStream = class extends TransformStream {
1255
1260
  this._buffer = "";
1256
1261
  }
1257
1262
  };
1258
- var ModelDoesNotSupportToolsError = class extends import_effect2.Schema.TaggedError()("ModelDoesNotSupportToolsError", {
1259
- model: import_effect2.Schema.String
1263
+ var ModelDoesNotSupportToolsError = class extends import_effect3.Schema.TaggedError()("ModelDoesNotSupportToolsError", {
1264
+ model: import_effect3.Schema.String
1260
1265
  }) {
1261
1266
  };
1262
- var ModelNotFoundError = class extends import_effect2.Schema.TaggedError()("ModelNotFoundError", {
1263
- model: import_effect2.Schema.String
1267
+ var ModelNotFoundError = class extends import_effect3.Schema.TaggedError()("ModelNotFoundError", {
1268
+ model: import_effect3.Schema.String
1264
1269
  }) {
1265
1270
  };
1266
1271
  var parseOllamaError = (error) => {
@@ -1282,7 +1287,7 @@ var parseOllamaError = (error) => {
1282
1287
  }
1283
1288
  throw new Error(`Ollama API error: ${error}`);
1284
1289
  };
1285
- var parseErrorResponse2 = async (response) => {
1290
+ var parseErrorResponse = async (response) => {
1286
1291
  if (response.headers.get("content-type")?.includes("application/json")) {
1287
1292
  const body = await response.json();
1288
1293
  return parseOllamaError(body.error);
@@ -1441,7 +1446,7 @@ var MixedStreamParser = class {
1441
1446
  C: (f, a) => f(...a)
1442
1447
  });
1443
1448
  }
1444
- this._message = (0, import_echo_schema3.create)(import_artifact4.Message, {
1449
+ this._message = (0, import_echo_schema4.createStatic)(import_artifact5.Message, {
1445
1450
  role: event.message.role,
1446
1451
  content: [
1447
1452
  ...event.message.content
@@ -1722,18 +1727,6 @@ var mergeMessageBlock = (contentBlock, streamBlock) => {
1722
1727
  }
1723
1728
  break;
1724
1729
  }
1725
- case "proposal": {
1726
- if (streamBlock.content.length === 1 && streamBlock.content[0].type === "text") {
1727
- return {
1728
- type: "json",
1729
- disposition: "proposal",
1730
- json: JSON.stringify({
1731
- text: streamBlock.content[0].content
1732
- })
1733
- };
1734
- }
1735
- break;
1736
- }
1737
1730
  case "select": {
1738
1731
  return {
1739
1732
  type: "json",
@@ -2201,7 +2194,7 @@ var formatInferredRelationshipLabel = (typename, property2) => {
2201
2194
  const nodeLabel = formatNodeLabel(typename);
2202
2195
  return `${nodeLabel}_${property2}`.toUpperCase();
2203
2196
  };
2204
- var isReference = (schema) => schema.$id === import_echo_schema4.JSON_SCHEMA_ECHO_REF_ID || schema.type === "array" && !Array.isArray(schema.items) && typeof schema.items === "object" && "$id" in schema.items && schema.items.$id === import_echo_schema4.JSON_SCHEMA_ECHO_REF_ID;
2197
+ var isReference = (schema) => schema.$id === import_echo_schema5.JSON_SCHEMA_ECHO_REF_ID || schema.type === "array" && !Array.isArray(schema.items) && typeof schema.items === "object" && "$id" in schema.items && schema.items.$id === import_echo_schema5.JSON_SCHEMA_ECHO_REF_ID;
2205
2198
  function _ts_decorate(decorators, target, key, desc) {
2206
2199
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2207
2200
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2218,7 +2211,7 @@ var EchoDataSource = class {
2218
2211
  const { objects: objects2 } = await this._db.query().run();
2219
2212
  return objects2.map(this._objectToNode);
2220
2213
  }
2221
- const schema = (await this._getAllSchema()).find((s) => (0, import_echo_schema5.getSchemaTypename)(s)?.endsWith(label2));
2214
+ const schema = (await this._getAllSchema()).find((s) => (0, import_echo_schema6.getSchemaTypename)(s)?.endsWith(label2));
2222
2215
  if (!schema) {
2223
2216
  return [];
2224
2217
  }
@@ -2226,8 +2219,8 @@ var EchoDataSource = class {
2226
2219
  return objects.map(this._objectToNode);
2227
2220
  }
2228
2221
  async getRelationships({ label: label2 }) {
2229
- const syntheticRefRelationships = (await this._getAllSchema()).filter((schema) => (0, import_echo_schema5.getSchemaTypename)(schema) !== import_echo_schema5.StoredSchema.typename).flatMap((schema) => {
2230
- const jsonSchema = (0, import_echo_schema5.toJsonSchema)(schema);
2222
+ const syntheticRefRelationships = (await this._getAllSchema()).filter((schema) => (0, import_echo_schema6.getSchemaTypename)(schema) !== import_echo_schema6.StoredSchema.typename).flatMap((schema) => {
2223
+ const jsonSchema = (0, import_echo_schema6.toJsonSchema)(schema);
2231
2224
  const relationships = Object.entries(jsonSchema.properties).filter(([key, prop]) => isReference(prop));
2232
2225
  return relationships.map(([key, value]) => {
2233
2226
  const relationshipLabel = formatInferredRelationshipLabel(jsonSchema.typename ?? (0, import_debug2.raise)(new Error("Schema must have typename")), key);
@@ -2249,15 +2242,15 @@ var EchoDataSource = class {
2249
2242
  return [
2250
2243
  ...await this._db.schemaRegistry.query().run(),
2251
2244
  // TODO(dmaretskyi): Remove once we can serialize recursive schema.
2252
- ...this._db.graph.schemaRegistry.schemas.filter((s) => (0, import_echo_schema5.getSchemaTypename)(s)?.startsWith("example.org"))
2253
- ].filter((schema) => (0, import_echo_schema5.getSchemaTypename)(schema) !== import_echo_schema5.StoredSchema.typename);
2245
+ ...this._db.graph.schemaRegistry.schemas.filter((s) => (0, import_echo_schema6.getSchemaTypename)(s)?.startsWith("example.org"))
2246
+ ].filter((schema) => (0, import_echo_schema6.getSchemaTypename)(schema) !== import_echo_schema6.StoredSchema.typename);
2254
2247
  }
2255
2248
  _objectToNode(object) {
2256
2249
  const { id, ...properties2 } = object;
2257
2250
  return {
2258
2251
  id,
2259
2252
  kind: "node",
2260
- label: formatNodeLabel((0, import_echo_schema5.getSchemaTypename)((0, import_echo_schema5.getSchema)(object))),
2253
+ label: formatNodeLabel((0, import_echo_schema6.getSchemaTypename)((0, import_live_object.getSchema)(object))),
2261
2254
  properties: properties2
2262
2255
  };
2263
2256
  }
@@ -2273,7 +2266,7 @@ var EchoDataSource = class {
2273
2266
  return {
2274
2267
  id: `${object.id}-${prop}-${target.id}`,
2275
2268
  kind: "relationship",
2276
- label: formatInferredRelationshipLabel((0, import_echo_schema5.getSchemaTypename)((0, import_echo_schema5.getSchema)(object)), prop),
2269
+ label: formatInferredRelationshipLabel((0, import_echo_schema6.getSchemaTypename)((0, import_live_object.getSchema)(object)), prop),
2277
2270
  properties: {},
2278
2271
  source: this._objectToNode(object),
2279
2272
  target: this._objectToNode(target)
@@ -2284,7 +2277,7 @@ var EchoDataSource = class {
2284
2277
  _ts_decorate([
2285
2278
  import_log8.log.method(void 0, void 0, {
2286
2279
  F: __dxlog_file8,
2287
- L: 16,
2280
+ L: 17,
2288
2281
  S: void 0,
2289
2282
  C: (f, a) => f(...a)
2290
2283
  })
@@ -2292,7 +2285,7 @@ _ts_decorate([
2292
2285
  _ts_decorate([
2293
2286
  import_log8.log.method(void 0, void 0, {
2294
2287
  F: __dxlog_file8,
2295
- L: 33,
2288
+ L: 34,
2296
2289
  S: void 0,
2297
2290
  C: (f, a) => f(...a)
2298
2291
  })
@@ -2307,7 +2300,6 @@ _ts_decorate([
2307
2300
  DEFAULT_OLLAMA_MODELS,
2308
2301
  EchoDataSource,
2309
2302
  GenerateRequest,
2310
- GenerateResponse,
2311
2303
  GenerationStreamImpl,
2312
2304
  LLMModel,
2313
2305
  MessageCollector,
@@ -2331,4 +2323,4 @@ _ts_decorate([
2331
2323
  runTools,
2332
2324
  trim
2333
2325
  });
2334
- //# sourceMappingURL=chunk-7VH7NMIM.cjs.map
2326
+ //# sourceMappingURL=chunk-IBOBRBDF.cjs.map