notesoup 0.54.0 → 0.54.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 (96) hide show
  1. package/README.md +4 -2
  2. package/dist/plugins/claude/src/helper.d.ts +2 -1
  3. package/dist/plugins/claude/src/helper.js +19 -23
  4. package/dist/plugins/claude/src/history.d.ts +3 -14
  5. package/dist/plugins/claude/src/history.js +2 -298
  6. package/dist/plugins/claude/src/text.d.ts +0 -1
  7. package/dist/plugins/claude/src/text.js +0 -1
  8. package/dist/plugins/codex/src/history.d.ts +3 -8
  9. package/dist/plugins/codex/src/history.js +2 -238
  10. package/dist/plugins/codex/src/mcp.js +7 -7
  11. package/dist/plugins/codex/src/transcript.d.ts +3 -39
  12. package/dist/plugins/codex/src/transcript.js +2 -313
  13. package/dist/plugins/dsh/history.d.ts +3 -0
  14. package/dist/plugins/dsh/history.js +15 -0
  15. package/dist/plugins/dsh/tools.js +4 -5
  16. package/dist/plugins/pi/history-tools.d.ts +1 -1
  17. package/dist/plugins/pi/history-tools.js +9 -5
  18. package/dist/plugins/pi/history.d.ts +2 -3
  19. package/dist/plugins/pi/history.js +4 -147
  20. package/dist/src/boot/render.js +2 -4
  21. package/dist/src/boot/text.d.ts +3 -1
  22. package/dist/src/boot/text.js +11 -5
  23. package/dist/src/history/claude.d.ts +16 -0
  24. package/dist/src/history/claude.js +336 -0
  25. package/dist/src/history/codex-transcript.d.ts +39 -0
  26. package/dist/src/history/codex-transcript.js +315 -0
  27. package/dist/src/history/codex.d.ts +8 -0
  28. package/dist/src/history/codex.js +238 -0
  29. package/dist/src/history/corpus.d.ts +35 -0
  30. package/dist/src/history/corpus.js +54 -0
  31. package/dist/src/history/history.d.ts +4 -8
  32. package/dist/src/history/history.js +3 -11
  33. package/dist/src/history/local.d.ts +17 -0
  34. package/dist/src/history/local.js +101 -0
  35. package/dist/src/history/pi.d.ts +36 -0
  36. package/dist/src/history/pi.js +202 -0
  37. package/dist/src/history/query.d.ts +15 -5
  38. package/dist/src/history/query.js +42 -13
  39. package/dist/src/index.d.ts +4 -2
  40. package/dist/src/index.js +4 -3
  41. package/dist/src/tools/history.d.ts +7 -19
  42. package/dist/src/tools/history.js +80 -93
  43. package/dist/test/boot.integration.test.js +1 -2
  44. package/dist/test/claude-history.test.js +47 -34
  45. package/dist/test/claude-mod.test.js +7 -7
  46. package/dist/test/codex-history.test.js +4 -10
  47. package/dist/test/codex-plugin.test.js +32 -11
  48. package/dist/test/dependencies.test.js +3 -3
  49. package/dist/test/dsh.test.js +26 -4
  50. package/dist/test/helpers/extension.d.ts +0 -1
  51. package/dist/test/helpers/history-corpus.d.ts +7 -0
  52. package/dist/test/helpers/history-corpus.js +26 -0
  53. package/dist/test/history-corpus.test.d.ts +1 -0
  54. package/dist/test/history-corpus.test.js +307 -0
  55. package/dist/test/history.integration.test.js +40 -48
  56. package/dist/test/host-neutral.test.js +3 -18
  57. package/dist/test/model-facing-text.test.js +2 -0
  58. package/dist/test/notes.integration.test.js +1 -1
  59. package/dist/test/notes.test.js +1 -1
  60. package/docs/architecture.md +7 -5
  61. package/docs/claude-code-mod.md +7 -5
  62. package/docs/codex.md +3 -3
  63. package/docs/dsh.md +2 -2
  64. package/docs/history-sessions.md +52 -0
  65. package/docs/notes-library.md +1 -1
  66. package/docs/skills.md +1 -1
  67. package/docs/tool-results.md +8 -6
  68. package/package.json +1 -1
  69. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  70. package/plugins/claude/dist/claude/helper.js +1507 -746
  71. package/plugins/claude/skills/memory/SKILL.md +5 -3
  72. package/plugins/claude/src/helper.ts +19 -23
  73. package/plugins/claude/src/history.ts +3 -257
  74. package/plugins/claude/src/text.ts +0 -1
  75. package/plugins/codex/dist/codex/notesoup.js +705 -154
  76. package/plugins/codex/src/history.ts +3 -193
  77. package/plugins/codex/src/mcp.ts +7 -7
  78. package/plugins/codex/src/transcript.ts +3 -275
  79. package/plugins/dsh/history.ts +17 -0
  80. package/plugins/dsh/tools.ts +4 -5
  81. package/plugins/paseo/client/markdown.tsx +19 -39
  82. package/plugins/pi/history-tools.ts +11 -5
  83. package/plugins/pi/history.ts +8 -157
  84. package/skills/memory/SKILL.md +5 -3
  85. package/src/boot/render.ts +2 -5
  86. package/src/boot/text.ts +11 -5
  87. package/src/history/claude.ts +286 -0
  88. package/src/history/codex-transcript.ts +276 -0
  89. package/src/history/codex.ts +193 -0
  90. package/src/history/corpus.ts +69 -0
  91. package/src/history/history.ts +5 -12
  92. package/src/history/local.ts +93 -0
  93. package/src/history/pi.ts +199 -0
  94. package/src/history/query.ts +45 -15
  95. package/src/index.ts +5 -3
  96. package/src/tools/history.ts +71 -101
@@ -296,8 +296,8 @@ function SomeAll(value, callback) {
296
296
  function Counted(value, callback) {
297
297
  return value.reduce((result, value2, index) => callback(value2, index) ? ++result : result, 0);
298
298
  }
299
- function ShiftLeft(array, true_, false_) {
300
- return IsEqual(array.length, 0) ? false_() : true_(array[0], array.slice(1));
299
+ function ShiftLeft(array2, true_, false_) {
300
+ return IsEqual(array2.length, 0) ? false_() : true_(array2[0], array2.slice(1));
301
301
  }
302
302
  function IsUnsafePropertyKey(key) {
303
303
  return IsEqual(key, "__proto__") || IsEqual(key, "constructor") || IsEqual(key, "prototype");
@@ -754,9 +754,9 @@ var CheckContext = class {
754
754
  return top.keys;
755
755
  }
756
756
  Merge(results) {
757
- for (const context of results) {
758
- context.GetIndices().forEach((value) => this.GetIndices().add(value));
759
- context.GetKeys().forEach((value) => this.GetKeys().add(value));
757
+ for (const context2 of results) {
758
+ context2.GetIndices().forEach((value) => this.GetIndices().add(value));
759
+ context2.GetKeys().forEach((value) => this.GetKeys().add(value));
760
760
  }
761
761
  return true;
762
762
  }
@@ -783,9 +783,9 @@ var ErrorContext = class extends CheckContext {
783
783
  function CheckRefine(_stack, _context, schema, value) {
784
784
  return guard_exports.Every(schema["~refine"], 0, (refinement, _) => refinement.check(value));
785
785
  }
786
- function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
786
+ function ErrorRefine(_stack, context2, schemaPath, instancePath, schema, value) {
787
787
  return guard_exports.EveryAll(schema["~refine"], 0, (refinement, index) => {
788
- return refinement.check(value) || context.AddError({
788
+ return refinement.check(value) || context2.AddError({
789
789
  keyword: "~refine",
790
790
  schemaPath,
791
791
  instancePath,
@@ -798,21 +798,21 @@ function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
798
798
  function IsValid(schema) {
799
799
  return IsItems(schema) && guard_exports.IsArray(schema.items);
800
800
  }
801
- function CheckAdditionalItems(stack, context, schema, value) {
801
+ function CheckAdditionalItems(stack, context2, schema, value) {
802
802
  if (!IsValid(schema))
803
803
  return true;
804
804
  const isAdditionalItems = guard_exports.Every(value, 0, (item, index) => {
805
- return guard_exports.IsLessThan(index, schema.items.length) || CheckSchemaPushStack(stack, context, schema.additionalItems, item) && context.AddIndex(index);
805
+ return guard_exports.IsLessThan(index, schema.items.length) || CheckSchemaPushStack(stack, context2, schema.additionalItems, item) && context2.AddIndex(index);
806
806
  });
807
807
  return isAdditionalItems;
808
808
  }
809
- function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value) {
809
+ function ErrorAdditionalItems(stack, context2, schemaPath, instancePath, schema, value) {
810
810
  if (!IsValid(schema))
811
811
  return true;
812
812
  const isAdditionalItems = guard_exports.Every(value, 0, (item, index) => {
813
813
  const nextSchemaPath = `${schemaPath}/additionalItems`;
814
814
  const nextInstancePath = `${instancePath}/${index}`;
815
- return guard_exports.IsLessThan(index, schema.items.length) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalItems, item) && context.AddIndex(index);
815
+ return guard_exports.IsLessThan(index, schema.items.length) || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema.additionalItems, item) && context2.AddIndex(index);
816
816
  });
817
817
  return isAdditionalItems;
818
818
  }
@@ -835,25 +835,25 @@ function GetPropertiesPattern(schema) {
835
835
  patterns.push(...guard_exports.Keys(schema.properties).map(GetPropertyKeyAsPattern));
836
836
  return guard_exports.IsEqual(patterns.length, 0) ? "(?!)" : `(${patterns.join("|")})`;
837
837
  }
838
- function CheckAdditionalProperties(stack, context, schema, value) {
838
+ function CheckAdditionalProperties(stack, context2, schema, value) {
839
839
  const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
840
840
  const isAdditionalProperties = guard_exports.Every(guard_exports.Keys(value), 0, (key, _index) => {
841
- return regexp.test(key) || CheckSchemaPushStack(stack, context, schema.additionalProperties, value[key]) && context.AddKey(key);
841
+ return regexp.test(key) || CheckSchemaPushStack(stack, context2, schema.additionalProperties, value[key]) && context2.AddKey(key);
842
842
  });
843
843
  return isAdditionalProperties;
844
844
  }
845
- function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value) {
845
+ function ErrorAdditionalProperties(stack, context2, schemaPath, instancePath, schema, value) {
846
846
  const regexp = UnicodeRegExp(GetPropertiesPattern(schema));
847
847
  const additionalProperties = [];
848
848
  const isAdditionalProperties = guard_exports.EveryAll(guard_exports.Keys(value), 0, (key, _index) => {
849
849
  const nextSchemaPath = `${schemaPath}/additionalProperties`;
850
850
  const nextInstancePath = `${instancePath}/${key}`;
851
- const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
851
+ const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context2.AddKey(key);
852
852
  if (!isAdditionalProperty)
853
853
  additionalProperties.push(key);
854
854
  return isAdditionalProperty;
855
855
  });
856
- return isAdditionalProperties || context.AddError({
856
+ return isAdditionalProperties || context2.AddError({
857
857
  keyword: "additionalProperties",
858
858
  schemaPath,
859
859
  instancePath,
@@ -862,14 +862,14 @@ function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, sch
862
862
  }
863
863
 
864
864
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/allOf.mjs
865
- function CheckAllOf(stack, context, schema, value) {
865
+ function CheckAllOf(stack, context2, schema, value) {
866
866
  const results = schema.allOf.reduce((result, schema2) => {
867
867
  const nextContext = new CheckContext();
868
868
  return CheckSchema(stack, nextContext, schema2, value) ? [...result, nextContext] : result;
869
869
  }, []);
870
- return guard_exports.IsEqual(results.length, schema.allOf.length) && context.Merge(results);
870
+ return guard_exports.IsEqual(results.length, schema.allOf.length) && context2.Merge(results);
871
871
  }
872
- function ErrorAllOf(stack, context, schemaPath, instancePath, schema, value) {
872
+ function ErrorAllOf(stack, context2, schemaPath, instancePath, schema, value) {
873
873
  const failedContexts = [];
874
874
  const results = schema.allOf.reduce((result, schema2, index) => {
875
875
  const nextSchemaPath = `${schemaPath}/allOf/${index}`;
@@ -879,21 +879,21 @@ function ErrorAllOf(stack, context, schemaPath, instancePath, schema, value) {
879
879
  failedContexts.push(nextContext);
880
880
  return isSchema ? [...result, nextContext] : result;
881
881
  }, []);
882
- const isAllOf = guard_exports.IsEqual(results.length, schema.allOf.length) && context.Merge(results);
882
+ const isAllOf = guard_exports.IsEqual(results.length, schema.allOf.length) && context2.Merge(results);
883
883
  if (!isAllOf)
884
- failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
884
+ failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context2.AddError(error)));
885
885
  return isAllOf;
886
886
  }
887
887
 
888
888
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/anyOf.mjs
889
- function CheckAnyOf(stack, context, schema, value) {
889
+ function CheckAnyOf(stack, context2, schema, value) {
890
890
  const results = schema.anyOf.reduce((result, schema2) => {
891
891
  const nextContext = new CheckContext();
892
892
  return CheckSchema(stack, nextContext, schema2, value) ? [...result, nextContext] : result;
893
893
  }, []);
894
- return guard_exports.IsGreaterThan(results.length, 0) && context.Merge(results);
894
+ return guard_exports.IsGreaterThan(results.length, 0) && context2.Merge(results);
895
895
  }
896
- function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
896
+ function ErrorAnyOf(stack, context2, schemaPath, instancePath, schema, value) {
897
897
  const failedContexts = [];
898
898
  const results = schema.anyOf.reduce((result, schema2, index) => {
899
899
  const nextContext = new ErrorContext();
@@ -903,10 +903,10 @@ function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
903
903
  failedContexts.push(nextContext);
904
904
  return isSchema ? [...result, nextContext] : result;
905
905
  }, []);
906
- const isAnyOf = guard_exports.IsGreaterThan(results.length, 0) && context.Merge(results);
906
+ const isAnyOf = guard_exports.IsGreaterThan(results.length, 0) && context2.Merge(results);
907
907
  if (!isAnyOf)
908
- failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
909
- return isAnyOf || context.AddError({
908
+ failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context2.AddError(error)));
909
+ return isAnyOf || context2.AddError({
910
910
  keyword: "anyOf",
911
911
  schemaPath,
912
912
  instancePath,
@@ -918,8 +918,8 @@ function ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value) {
918
918
  function CheckSchemaBoolean(_stack, _context, schema, _value) {
919
919
  return schema;
920
920
  }
921
- function ErrorSchemaBoolean(stack, context, schemaPath, instancePath, schema, value) {
922
- return CheckSchemaBoolean(stack, context, schema, value) || context.AddError({
921
+ function ErrorSchemaBoolean(stack, context2, schemaPath, instancePath, schema, value) {
922
+ return CheckSchemaBoolean(stack, context2, schema, value) || context2.AddError({
923
923
  keyword: "boolean",
924
924
  schemaPath,
925
925
  instancePath,
@@ -931,8 +931,8 @@ function ErrorSchemaBoolean(stack, context, schemaPath, instancePath, schema, va
931
931
  function CheckConst(_stack, _context, schema, value) {
932
932
  return guard_exports.IsValueLike(schema.const) ? guard_exports.IsEqual(value, schema.const) : guard_exports.IsDeepEqual(value, schema.const);
933
933
  }
934
- function ErrorConst(stack, context, schemaPath, instancePath, schema, value) {
935
- return CheckConst(stack, context, schema, value) || context.AddError({
934
+ function ErrorConst(stack, context2, schemaPath, instancePath, schema, value) {
935
+ return CheckConst(stack, context2, schema, value) || context2.AddError({
936
936
  keyword: "const",
937
937
  schemaPath,
938
938
  instancePath,
@@ -944,15 +944,15 @@ function ErrorConst(stack, context, schemaPath, instancePath, schema, value) {
944
944
  function IsValid2(schema) {
945
945
  return !(IsMinContains(schema) && guard_exports.IsEqual(schema.minContains, 0));
946
946
  }
947
- function CheckContains(stack, context, schema, value) {
947
+ function CheckContains(stack, context2, schema, value) {
948
948
  if (!IsValid2(schema))
949
949
  return true;
950
950
  return !guard_exports.IsEqual(value.length, 0) && guard_exports.SomeAll(value, (item, index) => {
951
- return CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index);
951
+ return CheckSchema(stack, context2, schema.contains, item) && context2.AddIndex(index);
952
952
  });
953
953
  }
954
- function ErrorContains(stack, context, schemaPath, instancePath, schema, value) {
955
- return CheckContains(stack, context, schema, value) || context.AddError({
954
+ function ErrorContains(stack, context2, schemaPath, instancePath, schema, value) {
955
+ return CheckContains(stack, context2, schema, value) || context2.AddError({
956
956
  keyword: "contains",
957
957
  schemaPath,
958
958
  instancePath,
@@ -961,23 +961,23 @@ function ErrorContains(stack, context, schemaPath, instancePath, schema, value)
961
961
  }
962
962
 
963
963
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/dependencies.mjs
964
- function CheckDependencies(stack, context, schema, value) {
964
+ function CheckDependencies(stack, context2, schema, value) {
965
965
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
966
966
  const isEvery = guard_exports.Every(guard_exports.Entries(schema.dependencies), 0, ([key, schema2]) => {
967
- return !guard_exports.HasPropertyKey(value, key) || (guard_exports.IsArray(schema2) ? schema2.every((key2) => guard_exports.HasPropertyKey(value, key2)) : CheckSchema(stack, context, schema2, value));
967
+ return !guard_exports.HasPropertyKey(value, key) || (guard_exports.IsArray(schema2) ? schema2.every((key2) => guard_exports.HasPropertyKey(value, key2)) : CheckSchema(stack, context2, schema2, value));
968
968
  });
969
969
  return isLength || isEvery;
970
970
  }
971
- function ErrorDependencies(stack, context, schemaPath, instancePath, schema, value) {
971
+ function ErrorDependencies(stack, context2, schemaPath, instancePath, schema, value) {
972
972
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
973
973
  const isEvery = guard_exports.EveryAll(guard_exports.Entries(schema.dependencies), 0, ([key, schema2]) => {
974
974
  const nextSchemaPath = `${schemaPath}/dependencies/${key}`;
975
- return !guard_exports.HasPropertyKey(value, key) || (guard_exports.IsArray(schema2) ? schema2.every((dependency) => guard_exports.HasPropertyKey(value, dependency) || context.AddError({
975
+ return !guard_exports.HasPropertyKey(value, key) || (guard_exports.IsArray(schema2) ? schema2.every((dependency) => guard_exports.HasPropertyKey(value, dependency) || context2.AddError({
976
976
  keyword: "dependencies",
977
977
  schemaPath,
978
978
  instancePath,
979
979
  params: { property: key, dependencies: schema2 }
980
- })) : ErrorSchema(stack, context, nextSchemaPath, instancePath, schema2, value));
980
+ })) : ErrorSchema(stack, context2, nextSchemaPath, instancePath, schema2, value));
981
981
  });
982
982
  return isLength || isEvery;
983
983
  }
@@ -990,10 +990,10 @@ function CheckDependentRequired(_stack, _context, schema, value) {
990
990
  });
991
991
  return isLength || isEvery;
992
992
  }
993
- function ErrorDependentRequired(_stack, context, schemaPath, instancePath, schema, value) {
993
+ function ErrorDependentRequired(_stack, context2, schemaPath, instancePath, schema, value) {
994
994
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
995
995
  const isEveryEntry = guard_exports.EveryAll(guard_exports.Entries(schema.dependentRequired), 0, ([key, keys]) => {
996
- return !guard_exports.HasPropertyKey(value, key) || guard_exports.EveryAll(keys, 0, (dependency) => guard_exports.HasPropertyKey(value, dependency) || context.AddError({
996
+ return !guard_exports.HasPropertyKey(value, key) || guard_exports.EveryAll(keys, 0, (dependency) => guard_exports.HasPropertyKey(value, dependency) || context2.AddError({
997
997
  keyword: "dependentRequired",
998
998
  schemaPath,
999
999
  instancePath,
@@ -1004,38 +1004,38 @@ function ErrorDependentRequired(_stack, context, schemaPath, instancePath, schem
1004
1004
  }
1005
1005
 
1006
1006
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/dependentSchemas.mjs
1007
- function CheckDependentSchemas(stack, context, schema, value) {
1007
+ function CheckDependentSchemas(stack, context2, schema, value) {
1008
1008
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
1009
1009
  const isEvery = guard_exports.Every(guard_exports.Entries(schema.dependentSchemas), 0, ([key, schema2]) => {
1010
- return !guard_exports.HasPropertyKey(value, key) || CheckSchema(stack, context, schema2, value);
1010
+ return !guard_exports.HasPropertyKey(value, key) || CheckSchema(stack, context2, schema2, value);
1011
1011
  });
1012
1012
  return isLength || isEvery;
1013
1013
  }
1014
- function ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value) {
1014
+ function ErrorDependentSchemas(stack, context2, schemaPath, instancePath, schema, value) {
1015
1015
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
1016
1016
  const isEvery = guard_exports.EveryAll(guard_exports.Entries(schema.dependentSchemas), 0, ([key, schema2]) => {
1017
1017
  const nextSchemaPath = `${schemaPath}/dependentSchemas/${key}`;
1018
- return !guard_exports.HasPropertyKey(value, key) || ErrorSchema(stack, context, nextSchemaPath, instancePath, schema2, value);
1018
+ return !guard_exports.HasPropertyKey(value, key) || ErrorSchema(stack, context2, nextSchemaPath, instancePath, schema2, value);
1019
1019
  });
1020
1020
  return isLength || isEvery;
1021
1021
  }
1022
1022
 
1023
1023
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/dynamicRef.mjs
1024
- function CheckDynamicRef(stack, context, schema, value) {
1024
+ function CheckDynamicRef(stack, context2, schema, value) {
1025
1025
  const target = stack.DynamicRef(schema) ?? false;
1026
- return IsSchema(target) && CheckSchema(stack, context, target, value);
1026
+ return IsSchema(target) && CheckSchema(stack, context2, target, value);
1027
1027
  }
1028
- function ErrorDynamicRef(stack, context, _schemaPath, instancePath, schema, value) {
1028
+ function ErrorDynamicRef(stack, context2, _schemaPath, instancePath, schema, value) {
1029
1029
  const target = stack.DynamicRef(schema) ?? false;
1030
- return IsSchema(target) && ErrorSchema(stack, context, "#", instancePath, target, value);
1030
+ return IsSchema(target) && ErrorSchema(stack, context2, "#", instancePath, target, value);
1031
1031
  }
1032
1032
 
1033
1033
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/enum.mjs
1034
1034
  function CheckEnum(_stack, _context, schema, value) {
1035
1035
  return guard_exports.Some(schema.enum, (option) => guard_exports.IsValueLike(option) ? guard_exports.IsEqual(value, option) : guard_exports.IsDeepEqual(value, option));
1036
1036
  }
1037
- function ErrorEnum(stack, context, schemaPath, instancePath, schema, value) {
1038
- return CheckEnum(stack, context, schema, value) || context.AddError({
1037
+ function ErrorEnum(stack, context2, schemaPath, instancePath, schema, value) {
1038
+ return CheckEnum(stack, context2, schema, value) || context2.AddError({
1039
1039
  keyword: "enum",
1040
1040
  schemaPath,
1041
1041
  instancePath,
@@ -1047,8 +1047,8 @@ function ErrorEnum(stack, context, schemaPath, instancePath, schema, value) {
1047
1047
  function CheckExclusiveMaximum(_stack, _context, schema, value) {
1048
1048
  return guard_exports.IsLessThan(value, schema.exclusiveMaximum);
1049
1049
  }
1050
- function ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value) {
1051
- return CheckExclusiveMaximum(stack, context, schema, value) || context.AddError({
1050
+ function ErrorExclusiveMaximum(stack, context2, schemaPath, instancePath, schema, value) {
1051
+ return CheckExclusiveMaximum(stack, context2, schema, value) || context2.AddError({
1052
1052
  keyword: "exclusiveMaximum",
1053
1053
  schemaPath,
1054
1054
  instancePath,
@@ -1060,8 +1060,8 @@ function ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema,
1060
1060
  function CheckExclusiveMinimum(_stack, _context, schema, value) {
1061
1061
  return guard_exports.IsGreaterThan(value, schema.exclusiveMinimum);
1062
1062
  }
1063
- function ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value) {
1064
- return CheckExclusiveMinimum(stack, context, schema, value) || context.AddError({
1063
+ function ErrorExclusiveMinimum(stack, context2, schemaPath, instancePath, schema, value) {
1064
+ return CheckExclusiveMinimum(stack, context2, schema, value) || context2.AddError({
1065
1065
  keyword: "exclusiveMinimum",
1066
1066
  schemaPath,
1067
1067
  instancePath,
@@ -1234,7 +1234,7 @@ function Adapt(delta, numPoints, firstTime) {
1234
1234
  return k + Math.floor((PUNYCODE_BASE - PUNYCODE_TMIN + 1) * delta / (delta + PUNYCODE_SKEW));
1235
1235
  }
1236
1236
  function Decode(value) {
1237
- const output = [];
1237
+ const output2 = [];
1238
1238
  let n = PUNYCODE_INITIAL_N;
1239
1239
  let i = 0;
1240
1240
  let bias = PUNYCODE_INITIAL_BIAS;
@@ -1244,7 +1244,7 @@ function Decode(value) {
1244
1244
  const cp = value.charCodeAt(j);
1245
1245
  if (cp >= 128)
1246
1246
  ThrowDontCare();
1247
- output.push(cp);
1247
+ output2.push(cp);
1248
1248
  }
1249
1249
  }
1250
1250
  let inIdx = delimIdx < 0 ? 0 : delimIdx + 1;
@@ -1270,14 +1270,14 @@ function Decode(value) {
1270
1270
  w *= PUNYCODE_BASE - t;
1271
1271
  k += PUNYCODE_BASE;
1272
1272
  }
1273
- const outLen = output.length + 1;
1273
+ const outLen = output2.length + 1;
1274
1274
  bias = Adapt(i - oldi, outLen, oldi === 0);
1275
1275
  n += Math.floor(i / outLen);
1276
1276
  i %= outLen;
1277
- output.splice(i, 0, n);
1277
+ output2.splice(i, 0, n);
1278
1278
  i++;
1279
1279
  }
1280
- return String.fromCodePoint(...output);
1280
+ return String.fromCodePoint(...output2);
1281
1281
  }
1282
1282
  function DigitToChar(digit) {
1283
1283
  return digit < 26 ? String.fromCharCode(digit + 97) : String.fromCharCode(digit - 26 + 48);
@@ -1657,8 +1657,8 @@ Reset2();
1657
1657
  function CheckFormat(_stack, _context, schema, value) {
1658
1658
  return format_exports.Test(schema.format, value);
1659
1659
  }
1660
- function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
1661
- return CheckFormat(stack, context, schema, value) || context.AddError({
1660
+ function ErrorFormat(stack, context2, schemaPath, instancePath, schema, value) {
1661
+ return CheckFormat(stack, context2, schema, value) || context2.AddError({
1662
1662
  keyword: "format",
1663
1663
  schemaPath,
1664
1664
  instancePath,
@@ -1667,78 +1667,78 @@ function ErrorFormat(stack, context, schemaPath, instancePath, schema, value) {
1667
1667
  }
1668
1668
 
1669
1669
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/if.mjs
1670
- function CheckIf(stack, context, schema, value) {
1670
+ function CheckIf(stack, context2, schema, value) {
1671
1671
  const thenSchema = IsThen(schema) ? schema.then : true;
1672
1672
  const elseSchema = IsElse(schema) ? schema.else : true;
1673
- return CheckSchema(stack, context, schema.if, value) ? CheckSchema(stack, context, thenSchema, value) : CheckSchema(stack, context, elseSchema, value);
1673
+ return CheckSchema(stack, context2, schema.if, value) ? CheckSchema(stack, context2, thenSchema, value) : CheckSchema(stack, context2, elseSchema, value);
1674
1674
  }
1675
- function ErrorIf(stack, context, schemaPath, instancePath, schema, value) {
1675
+ function ErrorIf(stack, context2, schemaPath, instancePath, schema, value) {
1676
1676
  const thenSchema = IsThen(schema) ? schema.then : true;
1677
1677
  const elseSchema = IsElse(schema) ? schema.else : true;
1678
1678
  const trueContext = new ErrorContext();
1679
- const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context.AddError({
1679
+ const isIf = ErrorSchema(stack, trueContext, `${schemaPath}/if`, instancePath, schema.if, value) ? ErrorSchema(stack, trueContext, `${schemaPath}/then`, instancePath, thenSchema, value) || context2.AddError({
1680
1680
  keyword: "if",
1681
1681
  schemaPath,
1682
1682
  instancePath,
1683
1683
  params: { failingKeyword: "then" }
1684
- }) : ErrorSchema(stack, context, `${schemaPath}/else`, instancePath, elseSchema, value) || context.AddError({
1684
+ }) : ErrorSchema(stack, context2, `${schemaPath}/else`, instancePath, elseSchema, value) || context2.AddError({
1685
1685
  keyword: "if",
1686
1686
  schemaPath,
1687
1687
  instancePath,
1688
1688
  params: { failingKeyword: "else" }
1689
1689
  });
1690
1690
  if (isIf)
1691
- context.Merge([trueContext]);
1691
+ context2.Merge([trueContext]);
1692
1692
  return isIf;
1693
1693
  }
1694
1694
 
1695
1695
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/items.mjs
1696
- function CheckItemsSized(stack, context, schema, value) {
1696
+ function CheckItemsSized(stack, context2, schema, value) {
1697
1697
  return guard_exports.Every(schema.items, 0, (schema2, index) => {
1698
- return guard_exports.IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context, schema2, value[index]) && context.AddIndex(index);
1698
+ return guard_exports.IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context2, schema2, value[index]) && context2.AddIndex(index);
1699
1699
  });
1700
1700
  }
1701
- function ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) {
1701
+ function ErrorItemsSized(stack, context2, schemaPath, instancePath, schema, value) {
1702
1702
  return guard_exports.EveryAll(schema.items, 0, (schema2, index) => {
1703
1703
  const nextSchemaPath = `${schemaPath}/items/${index}`;
1704
1704
  const nextInstancePath = `${instancePath}/${index}`;
1705
- return guard_exports.IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value[index]) && context.AddIndex(index);
1705
+ return guard_exports.IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema2, value[index]) && context2.AddIndex(index);
1706
1706
  });
1707
1707
  }
1708
- function CheckItemsUnsized(stack, context, schema, value) {
1708
+ function CheckItemsUnsized(stack, context2, schema, value) {
1709
1709
  const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
1710
1710
  return guard_exports.Every(value, offset, (element, index) => {
1711
- return CheckSchemaPushStack(stack, context, schema.items, element) && context.AddIndex(index);
1711
+ return CheckSchemaPushStack(stack, context2, schema.items, element) && context2.AddIndex(index);
1712
1712
  });
1713
1713
  }
1714
- function ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value) {
1714
+ function ErrorItemsUnsized(stack, context2, schemaPath, instancePath, schema, value) {
1715
1715
  const offset = IsPrefixItems(schema) ? schema.prefixItems.length : 0;
1716
1716
  return guard_exports.EveryAll(value, offset, (element, index) => {
1717
1717
  const nextSchemaPath = `${schemaPath}/items`;
1718
1718
  const nextInstancePath = `${instancePath}/${index}`;
1719
- return ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.items, element) && context.AddIndex(index);
1719
+ return ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema.items, element) && context2.AddIndex(index);
1720
1720
  });
1721
1721
  }
1722
- function CheckItems(stack, context, schema, value) {
1723
- return IsItemsSized(schema) ? CheckItemsSized(stack, context, schema, value) : CheckItemsUnsized(stack, context, schema, value);
1722
+ function CheckItems(stack, context2, schema, value) {
1723
+ return IsItemsSized(schema) ? CheckItemsSized(stack, context2, schema, value) : CheckItemsUnsized(stack, context2, schema, value);
1724
1724
  }
1725
- function ErrorItems(stack, context, schemaPath, instancePath, schema, value) {
1726
- return IsItemsSized(schema) ? ErrorItemsSized(stack, context, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(stack, context, schemaPath, instancePath, schema, value);
1725
+ function ErrorItems(stack, context2, schemaPath, instancePath, schema, value) {
1726
+ return IsItemsSized(schema) ? ErrorItemsSized(stack, context2, schemaPath, instancePath, schema, value) : ErrorItemsUnsized(stack, context2, schemaPath, instancePath, schema, value);
1727
1727
  }
1728
1728
 
1729
1729
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/maxContains.mjs
1730
1730
  function IsValid3(schema) {
1731
1731
  return IsContains(schema);
1732
1732
  }
1733
- function CheckMaxContains(stack, context, schema, value) {
1733
+ function CheckMaxContains(stack, context2, schema, value) {
1734
1734
  if (!IsValid3(schema))
1735
1735
  return true;
1736
- const count = guard_exports.Counted(value, (item) => CheckSchema(stack, context, schema.contains, item));
1736
+ const count = guard_exports.Counted(value, (item) => CheckSchema(stack, context2, schema.contains, item));
1737
1737
  return guard_exports.IsLessEqualThan(count, schema.maxContains);
1738
1738
  }
1739
- function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value) {
1739
+ function ErrorMaxContains(stack, context2, schemaPath, instancePath, schema, value) {
1740
1740
  const minContains = IsMinContains(schema) ? schema.minContains : 1;
1741
- return CheckMaxContains(stack, context, schema, value) || context.AddError({
1741
+ return CheckMaxContains(stack, context2, schema, value) || context2.AddError({
1742
1742
  keyword: "contains",
1743
1743
  schemaPath,
1744
1744
  instancePath,
@@ -1750,8 +1750,8 @@ function ErrorMaxContains(stack, context, schemaPath, instancePath, schema, valu
1750
1750
  function CheckMaximum(_stack, _context, schema, value) {
1751
1751
  return guard_exports.IsLessEqualThan(value, schema.maximum);
1752
1752
  }
1753
- function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
1754
- return CheckMaximum(stack, context, schema, value) || context.AddError({
1753
+ function ErrorMaximum(stack, context2, schemaPath, instancePath, schema, value) {
1754
+ return CheckMaximum(stack, context2, schema, value) || context2.AddError({
1755
1755
  keyword: "maximum",
1756
1756
  schemaPath,
1757
1757
  instancePath,
@@ -1763,8 +1763,8 @@ function ErrorMaximum(stack, context, schemaPath, instancePath, schema, value) {
1763
1763
  function CheckMaxItems(_stack, _context, schema, value) {
1764
1764
  return guard_exports.IsLessEqualThan(value.length, schema.maxItems);
1765
1765
  }
1766
- function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value) {
1767
- return CheckMaxItems(stack, context, schema, value) || context.AddError({
1766
+ function ErrorMaxItems(stack, context2, schemaPath, instancePath, schema, value) {
1767
+ return CheckMaxItems(stack, context2, schema, value) || context2.AddError({
1768
1768
  keyword: "maxItems",
1769
1769
  schemaPath,
1770
1770
  instancePath,
@@ -1776,8 +1776,8 @@ function ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value)
1776
1776
  function CheckMaxLength(_stack, _context, schema, value) {
1777
1777
  return guard_exports.IsMaxLength(value, schema.maxLength);
1778
1778
  }
1779
- function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value) {
1780
- return CheckMaxLength(stack, context, schema, value) || context.AddError({
1779
+ function ErrorMaxLength(stack, context2, schemaPath, instancePath, schema, value) {
1780
+ return CheckMaxLength(stack, context2, schema, value) || context2.AddError({
1781
1781
  keyword: "maxLength",
1782
1782
  schemaPath,
1783
1783
  instancePath,
@@ -1789,8 +1789,8 @@ function ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value)
1789
1789
  function CheckMaxProperties(_stack, _context, schema, value) {
1790
1790
  return guard_exports.IsLessEqualThan(guard_exports.Keys(value).length, schema.maxProperties);
1791
1791
  }
1792
- function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value) {
1793
- return CheckMaxProperties(stack, context, schema, value) || context.AddError({
1792
+ function ErrorMaxProperties(stack, context2, schemaPath, instancePath, schema, value) {
1793
+ return CheckMaxProperties(stack, context2, schema, value) || context2.AddError({
1794
1794
  keyword: "maxProperties",
1795
1795
  schemaPath,
1796
1796
  instancePath,
@@ -1802,14 +1802,14 @@ function ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, va
1802
1802
  function IsValid4(schema) {
1803
1803
  return IsContains(schema);
1804
1804
  }
1805
- function CheckMinContains(stack, context, schema, value) {
1805
+ function CheckMinContains(stack, context2, schema, value) {
1806
1806
  if (!IsValid4(schema))
1807
1807
  return true;
1808
- const count = guard_exports.Counted(value, (item, index) => CheckSchema(stack, context, schema.contains, item) && context.AddIndex(index));
1808
+ const count = guard_exports.Counted(value, (item, index) => CheckSchema(stack, context2, schema.contains, item) && context2.AddIndex(index));
1809
1809
  return guard_exports.IsGreaterEqualThan(count, schema.minContains);
1810
1810
  }
1811
- function ErrorMinContains(stack, context, schemaPath, instancePath, schema, value) {
1812
- return CheckMinContains(stack, context, schema, value) || context.AddError({
1811
+ function ErrorMinContains(stack, context2, schemaPath, instancePath, schema, value) {
1812
+ return CheckMinContains(stack, context2, schema, value) || context2.AddError({
1813
1813
  keyword: "contains",
1814
1814
  schemaPath,
1815
1815
  instancePath,
@@ -1821,8 +1821,8 @@ function ErrorMinContains(stack, context, schemaPath, instancePath, schema, valu
1821
1821
  function CheckMinimum(_stack, _context, schema, value) {
1822
1822
  return guard_exports.IsGreaterEqualThan(value, schema.minimum);
1823
1823
  }
1824
- function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
1825
- return CheckMinimum(stack, context, schema, value) || context.AddError({
1824
+ function ErrorMinimum(stack, context2, schemaPath, instancePath, schema, value) {
1825
+ return CheckMinimum(stack, context2, schema, value) || context2.AddError({
1826
1826
  keyword: "minimum",
1827
1827
  schemaPath,
1828
1828
  instancePath,
@@ -1834,8 +1834,8 @@ function ErrorMinimum(stack, context, schemaPath, instancePath, schema, value) {
1834
1834
  function CheckMinItems(_stack, _context, schema, value) {
1835
1835
  return guard_exports.IsGreaterEqualThan(value.length, schema.minItems);
1836
1836
  }
1837
- function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value) {
1838
- return CheckMinItems(stack, context, schema, value) || context.AddError({
1837
+ function ErrorMinItems(stack, context2, schemaPath, instancePath, schema, value) {
1838
+ return CheckMinItems(stack, context2, schema, value) || context2.AddError({
1839
1839
  keyword: "minItems",
1840
1840
  schemaPath,
1841
1841
  instancePath,
@@ -1847,8 +1847,8 @@ function ErrorMinItems(stack, context, schemaPath, instancePath, schema, value)
1847
1847
  function CheckMinLength(_stack, _context, schema, value) {
1848
1848
  return guard_exports.IsMinLength(value, schema.minLength);
1849
1849
  }
1850
- function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value) {
1851
- return CheckMinLength(stack, context, schema, value) || context.AddError({
1850
+ function ErrorMinLength(stack, context2, schemaPath, instancePath, schema, value) {
1851
+ return CheckMinLength(stack, context2, schema, value) || context2.AddError({
1852
1852
  keyword: "minLength",
1853
1853
  schemaPath,
1854
1854
  instancePath,
@@ -1860,8 +1860,8 @@ function ErrorMinLength(stack, context, schemaPath, instancePath, schema, value)
1860
1860
  function CheckMinProperties(_stack, _context, schema, value) {
1861
1861
  return guard_exports.IsGreaterEqualThan(guard_exports.Keys(value).length, schema.minProperties);
1862
1862
  }
1863
- function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value) {
1864
- return CheckMinProperties(stack, context, schema, value) || context.AddError({
1863
+ function ErrorMinProperties(stack, context2, schemaPath, instancePath, schema, value) {
1864
+ return CheckMinProperties(stack, context2, schema, value) || context2.AddError({
1865
1865
  keyword: "minProperties",
1866
1866
  schemaPath,
1867
1867
  instancePath,
@@ -1873,8 +1873,8 @@ function ErrorMinProperties(stack, context, schemaPath, instancePath, schema, va
1873
1873
  function CheckMultipleOf(_stack, _context, schema, value) {
1874
1874
  return guard_exports.IsMultipleOf(value, schema.multipleOf);
1875
1875
  }
1876
- function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value) {
1877
- return CheckMultipleOf(stack, context, schema, value) || context.AddError({
1876
+ function ErrorMultipleOf(stack, context2, schemaPath, instancePath, schema, value) {
1877
+ return CheckMultipleOf(stack, context2, schema, value) || context2.AddError({
1878
1878
  keyword: "multipleOf",
1879
1879
  schemaPath,
1880
1880
  instancePath,
@@ -1883,14 +1883,14 @@ function ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value
1883
1883
  }
1884
1884
 
1885
1885
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/not.mjs
1886
- function CheckNot(stack, context, schema, value) {
1886
+ function CheckNot(stack, context2, schema, value) {
1887
1887
  const nextContext = new CheckContext();
1888
1888
  const isSchema = !CheckSchema(stack, nextContext, schema.not, value);
1889
- const isNot = isSchema && context.Merge([nextContext]);
1889
+ const isNot = isSchema && context2.Merge([nextContext]);
1890
1890
  return isNot;
1891
1891
  }
1892
- function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
1893
- return CheckNot(stack, context, schema, value) || context.AddError({
1892
+ function ErrorNot(stack, context2, schemaPath, instancePath, schema, value) {
1893
+ return CheckNot(stack, context2, schema, value) || context2.AddError({
1894
1894
  keyword: "not",
1895
1895
  schemaPath,
1896
1896
  instancePath,
@@ -1899,14 +1899,14 @@ function ErrorNot(stack, context, schemaPath, instancePath, schema, value) {
1899
1899
  }
1900
1900
 
1901
1901
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/oneOf.mjs
1902
- function CheckOneOf(stack, context, schema, value) {
1902
+ function CheckOneOf(stack, context2, schema, value) {
1903
1903
  const passedContexts = schema.oneOf.reduce((result, schema2) => {
1904
1904
  const nextContext = new CheckContext();
1905
1905
  return CheckSchema(stack, nextContext, schema2, value) ? [...result, nextContext] : result;
1906
1906
  }, []);
1907
- return guard_exports.IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
1907
+ return guard_exports.IsEqual(passedContexts.length, 1) && context2.Merge(passedContexts);
1908
1908
  }
1909
- function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
1909
+ function ErrorOneOf(stack, context2, schemaPath, instancePath, schema, value) {
1910
1910
  const failedContexts = [];
1911
1911
  const passingSchemas = [];
1912
1912
  const passedContexts = schema.oneOf.reduce((result, schema2, index) => {
@@ -1919,10 +1919,10 @@ function ErrorOneOf(stack, context, schemaPath, instancePath, schema, value) {
1919
1919
  failedContexts.push(nextContext);
1920
1920
  return isSchema ? [...result, nextContext] : result;
1921
1921
  }, []);
1922
- const isOneOf = guard_exports.IsEqual(passedContexts.length, 1) && context.Merge(passedContexts);
1922
+ const isOneOf = guard_exports.IsEqual(passedContexts.length, 1) && context2.Merge(passedContexts);
1923
1923
  if (!isOneOf && guard_exports.IsEqual(passingSchemas.length, 0))
1924
- failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context.AddError(error)));
1925
- return isOneOf || context.AddError({
1924
+ failedContexts.forEach((failed) => failed.GetErrors().forEach((error) => context2.AddError(error)));
1925
+ return isOneOf || context2.AddError({
1926
1926
  keyword: "oneOf",
1927
1927
  schemaPath,
1928
1928
  instancePath,
@@ -1935,8 +1935,8 @@ function CheckPattern(_stack, _context, schema, value) {
1935
1935
  const regexp = guard_exports.IsString(schema.pattern) ? UnicodeRegExp(schema.pattern) : schema.pattern;
1936
1936
  return regexp.test(value);
1937
1937
  }
1938
- function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
1939
- return CheckPattern(stack, context, schema, value) || context.AddError({
1938
+ function ErrorPattern(stack, context2, schemaPath, instancePath, schema, value) {
1939
+ return CheckPattern(stack, context2, schema, value) || context2.AddError({
1940
1940
  keyword: "pattern",
1941
1941
  schemaPath,
1942
1942
  instancePath,
@@ -1945,37 +1945,37 @@ function ErrorPattern(stack, context, schemaPath, instancePath, schema, value) {
1945
1945
  }
1946
1946
 
1947
1947
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/patternProperties.mjs
1948
- function CheckPatternProperties(stack, context, schema, value) {
1948
+ function CheckPatternProperties(stack, context2, schema, value) {
1949
1949
  return guard_exports.Every(guard_exports.Entries(schema.patternProperties), 0, ([pattern, schema2]) => {
1950
1950
  const regexp = UnicodeRegExp(pattern);
1951
1951
  return guard_exports.Every(guard_exports.Entries(value), 0, ([key, prop]) => {
1952
- return !regexp.test(key) || CheckSchemaPushStack(stack, context, schema2, prop) && context.AddKey(key);
1952
+ return !regexp.test(key) || CheckSchemaPushStack(stack, context2, schema2, prop) && context2.AddKey(key);
1953
1953
  });
1954
1954
  });
1955
1955
  }
1956
- function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
1956
+ function ErrorPatternProperties(stack, context2, schemaPath, instancePath, schema, value) {
1957
1957
  return guard_exports.EveryAll(guard_exports.Entries(schema.patternProperties), 0, ([pattern, schema2]) => {
1958
1958
  const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
1959
1959
  const regexp = UnicodeRegExp(pattern);
1960
1960
  return guard_exports.EveryAll(guard_exports.Entries(value), 0, ([key, value2]) => {
1961
1961
  const nextInstancePath = `${instancePath}/${key}`;
1962
1962
  const notKey = !regexp.test(key);
1963
- return notKey || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value2) && context.AddKey(key);
1963
+ return notKey || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema2, value2) && context2.AddKey(key);
1964
1964
  });
1965
1965
  });
1966
1966
  }
1967
1967
 
1968
1968
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/prefixItems.mjs
1969
- function CheckPrefixItems(stack, context, schema, value) {
1969
+ function CheckPrefixItems(stack, context2, schema, value) {
1970
1970
  return guard_exports.IsEqual(value.length, 0) || guard_exports.Every(schema.prefixItems, 0, (schema2, index) => {
1971
- return guard_exports.IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context, schema2, value[index]) && context.AddIndex(index);
1971
+ return guard_exports.IsLessEqualThan(value.length, index) || CheckSchemaPushStack(stack, context2, schema2, value[index]) && context2.AddIndex(index);
1972
1972
  });
1973
1973
  }
1974
- function ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value) {
1974
+ function ErrorPrefixItems(stack, context2, schemaPath, instancePath, schema, value) {
1975
1975
  return guard_exports.IsEqual(value.length, 0) || guard_exports.EveryAll(schema.prefixItems, 0, (schema2, index) => {
1976
1976
  const nextSchemaPath = `${schemaPath}/prefixItems/${index}`;
1977
1977
  const nextInstancePath = `${instancePath}/${index}`;
1978
- return guard_exports.IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value[index]) && context.AddIndex(index);
1978
+ return guard_exports.IsLessEqualThan(value.length, index) || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema2, value[index]) && context2.AddIndex(index);
1979
1979
  });
1980
1980
  }
1981
1981
 
@@ -1988,40 +1988,40 @@ function InexactOptionalCheck(value, key) {
1988
1988
  }
1989
1989
 
1990
1990
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/properties.mjs
1991
- function CheckProperties(stack, context, schema, value) {
1991
+ function CheckProperties(stack, context2, schema, value) {
1992
1992
  const required = IsRequired(schema) ? schema.required : [];
1993
1993
  const isProperties = guard_exports.Every(guard_exports.Entries(schema.properties), 0, ([key, schema2]) => {
1994
- const isProperty = !guard_exports.HasPropertyKey(value, key) || CheckSchemaPushStack(stack, context, schema2, value[key]) && context.AddKey(key);
1994
+ const isProperty = !guard_exports.HasPropertyKey(value, key) || CheckSchemaPushStack(stack, context2, schema2, value[key]) && context2.AddKey(key);
1995
1995
  return IsExactOptional(required, key) ? isProperty : InexactOptionalCheck(value, key) || isProperty;
1996
1996
  });
1997
1997
  return isProperties;
1998
1998
  }
1999
- function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
1999
+ function ErrorProperties(stack, context2, schemaPath, instancePath, schema, value) {
2000
2000
  const required = IsRequired(schema) ? schema.required : [];
2001
2001
  const isProperties = guard_exports.EveryAll(guard_exports.Entries(schema.properties), 0, ([key, schema2]) => {
2002
2002
  const nextSchemaPath = `${schemaPath}/properties/${key}`;
2003
2003
  const nextInstancePath = `${instancePath}/${key}`;
2004
- const isProperty = () => !guard_exports.HasPropertyKey(value, key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value[key]) && context.AddKey(key);
2004
+ const isProperty = () => !guard_exports.HasPropertyKey(value, key) || ErrorSchemaPushStack(stack, context2, nextSchemaPath, nextInstancePath, schema2, value[key]) && context2.AddKey(key);
2005
2005
  return IsExactOptional(required, key) ? isProperty() : InexactOptionalCheck(value, key) || isProperty();
2006
2006
  });
2007
2007
  return isProperties;
2008
2008
  }
2009
2009
 
2010
2010
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/propertyNames.mjs
2011
- function CheckPropertyNames(stack, context, schema, value) {
2012
- return guard_exports.Every(guard_exports.Keys(value), 0, (key, _index) => CheckSchema(stack, context, schema.propertyNames, key));
2011
+ function CheckPropertyNames(stack, context2, schema, value) {
2012
+ return guard_exports.Every(guard_exports.Keys(value), 0, (key, _index) => CheckSchema(stack, context2, schema.propertyNames, key));
2013
2013
  }
2014
- function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value) {
2014
+ function ErrorPropertyNames(stack, context2, schemaPath, instancePath, schema, value) {
2015
2015
  const propertyNames = [];
2016
2016
  const isPropertyNames = guard_exports.EveryAll(guard_exports.Keys(value), 0, (key, _index) => {
2017
2017
  const nextInstancePath = `${instancePath}/${key}`;
2018
2018
  const nextSchemaPath = `${schemaPath}/propertyNames`;
2019
- const isPropertyName = ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema.propertyNames, key);
2019
+ const isPropertyName = ErrorSchema(stack, context2, nextSchemaPath, nextInstancePath, schema.propertyNames, key);
2020
2020
  if (!isPropertyName)
2021
2021
  propertyNames.push(key);
2022
2022
  return isPropertyName;
2023
2023
  });
2024
- return isPropertyNames || context.AddError({
2024
+ return isPropertyNames || context2.AddError({
2025
2025
  keyword: "propertyNames",
2026
2026
  schemaPath,
2027
2027
  instancePath,
@@ -2030,32 +2030,32 @@ function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, va
2030
2030
  }
2031
2031
 
2032
2032
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/recursiveRef.mjs
2033
- function CheckRecursiveRef(stack, context, schema, value) {
2033
+ function CheckRecursiveRef(stack, context2, schema, value) {
2034
2034
  const target = stack.RecursiveRef(schema) ?? false;
2035
- return IsSchema(target) && CheckSchema(stack, context, target, value);
2035
+ return IsSchema(target) && CheckSchema(stack, context2, target, value);
2036
2036
  }
2037
- function ErrorRecursiveRef(stack, context, _schemaPath, instancePath, schema, value) {
2037
+ function ErrorRecursiveRef(stack, context2, _schemaPath, instancePath, schema, value) {
2038
2038
  const target = stack.RecursiveRef(schema) ?? false;
2039
- return IsSchema(target) && ErrorSchema(stack, context, "#", instancePath, target, value);
2039
+ return IsSchema(target) && ErrorSchema(stack, context2, "#", instancePath, target, value);
2040
2040
  }
2041
2041
 
2042
2042
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/ref.mjs
2043
- function CheckRef(stack, context, schema, value) {
2043
+ function CheckRef(stack, context2, schema, value) {
2044
2044
  const target = stack.Ref(schema) ?? false;
2045
2045
  const nextContext = new CheckContext();
2046
2046
  const result = IsSchema(target) && CheckSchema(stack, nextContext, target, value);
2047
2047
  if (result)
2048
- context.Merge([nextContext]);
2048
+ context2.Merge([nextContext]);
2049
2049
  return result;
2050
2050
  }
2051
- function ErrorRef(stack, context, _schemaPath, instancePath, schema, value) {
2051
+ function ErrorRef(stack, context2, _schemaPath, instancePath, schema, value) {
2052
2052
  const target = stack.Ref(schema) ?? false;
2053
2053
  const nextContext = new ErrorContext();
2054
2054
  const result = IsSchema(target) && ErrorSchema(stack, nextContext, "#", instancePath, target, value);
2055
2055
  if (result)
2056
- context.Merge([nextContext]);
2056
+ context2.Merge([nextContext]);
2057
2057
  if (!result)
2058
- nextContext.GetErrors().forEach((error) => context.AddError(error));
2058
+ nextContext.GetErrors().forEach((error) => context2.AddError(error));
2059
2059
  return result;
2060
2060
  }
2061
2061
 
@@ -2063,7 +2063,7 @@ function ErrorRef(stack, context, _schemaPath, instancePath, schema, value) {
2063
2063
  function CheckRequired(_stack, _context, schema, value) {
2064
2064
  return guard_exports.Every(schema.required, 0, (key) => guard_exports.HasPropertyKey(value, key));
2065
2065
  }
2066
- function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value) {
2066
+ function ErrorRequired(_stack, context2, schemaPath, instancePath, schema, value) {
2067
2067
  const requiredProperties = [];
2068
2068
  const isRequired = guard_exports.EveryAll(schema.required, 0, (key) => {
2069
2069
  const hasKey = guard_exports.HasPropertyKey(value, key);
@@ -2071,7 +2071,7 @@ function ErrorRequired(_stack, context, schemaPath, instancePath, schema, value)
2071
2071
  requiredProperties.push(key);
2072
2072
  return hasKey;
2073
2073
  });
2074
- return isRequired || context.AddError({
2074
+ return isRequired || context2.AddError({
2075
2075
  keyword: "required",
2076
2076
  schemaPath,
2077
2077
  instancePath,
@@ -2089,15 +2089,15 @@ function CheckTypeName(_stack, _context, type, _schema, value) {
2089
2089
  )
2090
2090
  );
2091
2091
  }
2092
- function CheckTypeNames(stack, context, types, schema, value) {
2093
- return guard_exports.Some(types, (type) => CheckTypeName(stack, context, type, schema, value));
2092
+ function CheckTypeNames(stack, context2, types, schema, value) {
2093
+ return guard_exports.Some(types, (type) => CheckTypeName(stack, context2, type, schema, value));
2094
2094
  }
2095
- function CheckType(stack, context, schema, value) {
2096
- return guard_exports.IsArray(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
2095
+ function CheckType(stack, context2, schema, value) {
2096
+ return guard_exports.IsArray(schema.type) ? CheckTypeNames(stack, context2, schema.type, schema, value) : CheckTypeName(stack, context2, schema.type, schema, value);
2097
2097
  }
2098
- function ErrorType(stack, context, schemaPath, instancePath, schema, value) {
2099
- const isType = guard_exports.IsArray(schema.type) ? CheckTypeNames(stack, context, schema.type, schema, value) : CheckTypeName(stack, context, schema.type, schema, value);
2100
- return isType || context.AddError({
2098
+ function ErrorType(stack, context2, schemaPath, instancePath, schema, value) {
2099
+ const isType = guard_exports.IsArray(schema.type) ? CheckTypeNames(stack, context2, schema.type, schema, value) : CheckTypeName(stack, context2, schema.type, schema, value);
2100
+ return isType || context2.AddError({
2101
2101
  keyword: "type",
2102
2102
  schemaPath,
2103
2103
  instancePath,
@@ -2106,23 +2106,23 @@ function ErrorType(stack, context, schemaPath, instancePath, schema, value) {
2106
2106
  }
2107
2107
 
2108
2108
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs
2109
- function CheckUnevaluatedItems(stack, context, schema, value) {
2110
- const indices = context.GetIndices();
2109
+ function CheckUnevaluatedItems(stack, context2, schema, value) {
2110
+ const indices = context2.GetIndices();
2111
2111
  return guard_exports.Every(value, 0, (item, index) => {
2112
- return (indices.has(index) || CheckSchema(stack, context, schema.unevaluatedItems, item)) && context.AddIndex(index);
2112
+ return (indices.has(index) || CheckSchema(stack, context2, schema.unevaluatedItems, item)) && context2.AddIndex(index);
2113
2113
  });
2114
2114
  }
2115
- function ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema, value) {
2116
- const indices = context.GetIndices();
2115
+ function ErrorUnevaluatedItems(stack, context2, schemaPath, instancePath, schema, value) {
2116
+ const indices = context2.GetIndices();
2117
2117
  const unevaluatedItems = [];
2118
2118
  const isUnevaluatedItems = guard_exports.EveryAll(value, 0, (item, index) => {
2119
2119
  const nextContext = new ErrorContext();
2120
- const isEvaluatedItem = (indices.has(index) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedItems, item)) && context.AddIndex(index);
2120
+ const isEvaluatedItem = (indices.has(index) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedItems, item)) && context2.AddIndex(index);
2121
2121
  if (!isEvaluatedItem)
2122
2122
  unevaluatedItems.push(index);
2123
2123
  return isEvaluatedItem;
2124
2124
  });
2125
- return isUnevaluatedItems || context.AddError({
2125
+ return isUnevaluatedItems || context2.AddError({
2126
2126
  keyword: "unevaluatedItems",
2127
2127
  schemaPath,
2128
2128
  instancePath,
@@ -2131,23 +2131,23 @@ function ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema,
2131
2131
  }
2132
2132
 
2133
2133
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs
2134
- function CheckUnevaluatedProperties(stack, context, schema, value) {
2135
- const keys = context.GetKeys();
2134
+ function CheckUnevaluatedProperties(stack, context2, schema, value) {
2135
+ const keys = context2.GetKeys();
2136
2136
  return guard_exports.Every(guard_exports.Entries(value), 0, ([key, prop]) => {
2137
- return keys.has(key) || CheckSchema(stack, context, schema.unevaluatedProperties, prop) && context.AddKey(key);
2137
+ return keys.has(key) || CheckSchema(stack, context2, schema.unevaluatedProperties, prop) && context2.AddKey(key);
2138
2138
  });
2139
2139
  }
2140
- function ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, schema, value) {
2141
- const keys = context.GetKeys();
2140
+ function ErrorUnevaluatedProperties(stack, context2, schemaPath, instancePath, schema, value) {
2141
+ const keys = context2.GetKeys();
2142
2142
  const unevaluatedProperties = [];
2143
2143
  const isUnevaluatedProperties = guard_exports.EveryAll(guard_exports.Entries(value), 0, ([key, prop]) => {
2144
2144
  const nextContext = new ErrorContext();
2145
- const isEvaluatedProperty = keys.has(key) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedProperties, prop) && context.AddKey(key);
2145
+ const isEvaluatedProperty = keys.has(key) || ErrorSchema(stack, nextContext, schemaPath, instancePath, schema.unevaluatedProperties, prop) && context2.AddKey(key);
2146
2146
  if (!isEvaluatedProperty)
2147
2147
  unevaluatedProperties.push(key);
2148
2148
  return isEvaluatedProperty;
2149
2149
  });
2150
- return isUnevaluatedProperties || context.AddError({
2150
+ return isUnevaluatedProperties || context2.AddError({
2151
2151
  keyword: "unevaluatedProperties",
2152
2152
  schemaPath,
2153
2153
  instancePath,
@@ -2312,7 +2312,7 @@ function CheckUniqueItems(_stack, _context, schema, value) {
2312
2312
  const isLength = value.length;
2313
2313
  return guard_exports.IsEqual(set, isLength);
2314
2314
  }
2315
- function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, value) {
2315
+ function ErrorUniqueItems(_stack, context2, schemaPath, instancePath, schema, value) {
2316
2316
  if (!IsValid5(schema))
2317
2317
  return true;
2318
2318
  const set = /* @__PURE__ */ new Set();
@@ -2324,7 +2324,7 @@ function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, val
2324
2324
  return result;
2325
2325
  }, []);
2326
2326
  const isUniqueItems = guard_exports.IsEqual(duplicateItems.length, 0);
2327
- return isUniqueItems || context.AddError({
2327
+ return isUniqueItems || context2.AddError({
2328
2328
  keyword: "uniqueItems",
2329
2329
  schemaPath,
2330
2330
  instancePath,
@@ -2333,23 +2333,23 @@ function ErrorUniqueItems(_stack, context, schemaPath, instancePath, schema, val
2333
2333
  }
2334
2334
 
2335
2335
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/engine/schema.mjs
2336
- function CheckSchemaPushStack(stack, context, schema, value) {
2337
- return context.Push() && CheckSchema(stack, context, schema, value) && context.Pop();
2336
+ function CheckSchemaPushStack(stack, context2, schema, value) {
2337
+ return context2.Push() && CheckSchema(stack, context2, schema, value) && context2.Pop();
2338
2338
  }
2339
- function CheckSchema(stack, context, schema, value) {
2339
+ function CheckSchema(stack, context2, schema, value) {
2340
2340
  stack.Push(schema);
2341
- const result = IsSchemaBoolean(schema) ? CheckSchemaBoolean(stack, context, schema, value) : (!IsType(schema) || CheckType(stack, context, schema, value)) && (!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || (!IsRequired(schema) || CheckRequired(stack, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(stack, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(stack, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(stack, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(stack, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(stack, context, schema, value)) && (!IsProperties(schema) || CheckProperties(stack, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(stack, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(stack, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(stack, context, schema, value))) && (!guard_exports.IsArray(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(stack, context, schema, value)) && (!IsContains(schema) || CheckContains(stack, context, schema, value)) && (!IsItems(schema) || CheckItems(stack, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(stack, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(stack, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(stack, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(stack, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(stack, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(stack, context, schema, value))) && (!guard_exports.IsString(value) || (!IsMaxLength3(schema) || CheckMaxLength(stack, context, schema, value)) && (!IsMinLength3(schema) || CheckMinLength(stack, context, schema, value)) && (!IsFormat(schema) || CheckFormat(stack, context, schema, value)) && (!IsPattern(schema) || CheckPattern(stack, context, schema, value))) && (!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(stack, context, schema, value)) && (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(stack, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(stack, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(stack, context, schema, value)) && (!IsMultipleOf2(schema) || CheckMultipleOf(stack, context, schema, value))) && (!IsRef(schema) || CheckRef(stack, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(stack, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(stack, context, schema, value)) && (!IsConst(schema) || CheckConst(stack, context, schema, value)) && (!IsEnum(schema) || CheckEnum(stack, context, schema, value)) && (!IsIf(schema) || CheckIf(stack, context, schema, value)) && (!IsNot(schema) || CheckNot(stack, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(stack, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(stack, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(stack, context, schema, value)) && (!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || CheckUnevaluatedItems(stack, context, schema, value))) && (!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || CheckUnevaluatedProperties(stack, context, schema, value))) && (!IsRefine(schema) || CheckRefine(stack, context, schema, value));
2341
+ const result = IsSchemaBoolean(schema) ? CheckSchemaBoolean(stack, context2, schema, value) : (!IsType(schema) || CheckType(stack, context2, schema, value)) && (!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || (!IsRequired(schema) || CheckRequired(stack, context2, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(stack, context2, schema, value)) && (!IsDependencies(schema) || CheckDependencies(stack, context2, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(stack, context2, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(stack, context2, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(stack, context2, schema, value)) && (!IsProperties(schema) || CheckProperties(stack, context2, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(stack, context2, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(stack, context2, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(stack, context2, schema, value))) && (!guard_exports.IsArray(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(stack, context2, schema, value)) && (!IsContains(schema) || CheckContains(stack, context2, schema, value)) && (!IsItems(schema) || CheckItems(stack, context2, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(stack, context2, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(stack, context2, schema, value)) && (!IsMinContains(schema) || CheckMinContains(stack, context2, schema, value)) && (!IsMinItems(schema) || CheckMinItems(stack, context2, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(stack, context2, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(stack, context2, schema, value))) && (!guard_exports.IsString(value) || (!IsMaxLength3(schema) || CheckMaxLength(stack, context2, schema, value)) && (!IsMinLength3(schema) || CheckMinLength(stack, context2, schema, value)) && (!IsFormat(schema) || CheckFormat(stack, context2, schema, value)) && (!IsPattern(schema) || CheckPattern(stack, context2, schema, value))) && (!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(stack, context2, schema, value)) && (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(stack, context2, schema, value)) && (!IsMaximum(schema) || CheckMaximum(stack, context2, schema, value)) && (!IsMinimum(schema) || CheckMinimum(stack, context2, schema, value)) && (!IsMultipleOf2(schema) || CheckMultipleOf(stack, context2, schema, value))) && (!IsRef(schema) || CheckRef(stack, context2, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(stack, context2, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(stack, context2, schema, value)) && (!IsConst(schema) || CheckConst(stack, context2, schema, value)) && (!IsEnum(schema) || CheckEnum(stack, context2, schema, value)) && (!IsIf(schema) || CheckIf(stack, context2, schema, value)) && (!IsNot(schema) || CheckNot(stack, context2, schema, value)) && (!IsAllOf(schema) || CheckAllOf(stack, context2, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(stack, context2, schema, value)) && (!IsOneOf(schema) || CheckOneOf(stack, context2, schema, value)) && (!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || CheckUnevaluatedItems(stack, context2, schema, value))) && (!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || CheckUnevaluatedProperties(stack, context2, schema, value))) && (!IsRefine(schema) || CheckRefine(stack, context2, schema, value));
2342
2342
  stack.Pop(schema);
2343
2343
  return result;
2344
2344
  }
2345
- function ErrorSchemaPushStack(stack, context, schemaPath, instancePath, schema, value) {
2346
- return context.Push() && ErrorSchema(stack, context, schemaPath, instancePath, schema, value) && context.Pop();
2345
+ function ErrorSchemaPushStack(stack, context2, schemaPath, instancePath, schema, value) {
2346
+ return context2.Push() && ErrorSchema(stack, context2, schemaPath, instancePath, schema, value) && context2.Pop();
2347
2347
  }
2348
- function ErrorSchema(stack, context, schemaPath, instancePath, schema, value) {
2349
- if (context.AtCapacity())
2348
+ function ErrorSchema(stack, context2, schemaPath, instancePath, schema, value) {
2349
+ if (context2.AtCapacity())
2350
2350
  return false;
2351
2351
  stack.Push(schema);
2352
- const result = IsSchemaBoolean(schema) ? ErrorSchemaBoolean(stack, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(stack, context, schemaPath, instancePath, schema, value)) & +(!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || !!(+(!IsRequired(schema) || ErrorRequired(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(stack, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsArray(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(stack, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(stack, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsString(value) || !!(+(!IsMaxLength3(schema) || ErrorMaxLength(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinLength3(schema) || ErrorMinLength(stack, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(stack, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(stack, context, schemaPath, instancePath, schema, value)))) & +(!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || !!(+(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf2(schema) || ErrorMultipleOf(stack, context, schemaPath, instancePath, schema, value)))) & +(!IsRef(schema) || ErrorRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(stack, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(stack, context, schemaPath, instancePath, schema, value)) & +(!IsEnum(schema) || ErrorEnum(stack, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(stack, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || ErrorUnevaluatedItems(stack, context, schemaPath, instancePath, schema, value))) & +(!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || ErrorUnevaluatedProperties(stack, context, schemaPath, instancePath, schema, value)))) && (!IsRefine(schema) || ErrorRefine(stack, context, schemaPath, instancePath, schema, value));
2352
+ const result = IsSchemaBoolean(schema) ? ErrorSchemaBoolean(stack, context2, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(stack, context2, schemaPath, instancePath, schema, value)) & +(!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || !!(+(!IsRequired(schema) || ErrorRequired(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(stack, context2, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsArray(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(stack, context2, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsString(value) || !!(+(!IsMaxLength3(schema) || ErrorMaxLength(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMinLength3(schema) || ErrorMinLength(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(stack, context2, schemaPath, instancePath, schema, value)))) & +(!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || !!(+(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf2(schema) || ErrorMultipleOf(stack, context2, schemaPath, instancePath, schema, value)))) & +(!IsRef(schema) || ErrorRef(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsEnum(schema) || ErrorEnum(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(stack, context2, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || ErrorUnevaluatedItems(stack, context2, schemaPath, instancePath, schema, value))) & +(!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || ErrorUnevaluatedProperties(stack, context2, schemaPath, instancePath, schema, value)))) && (!IsRefine(schema) || ErrorRefine(stack, context2, schemaPath, instancePath, schema, value));
2353
2353
  stack.Pop(schema);
2354
2354
  return result;
2355
2355
  }
@@ -2569,26 +2569,26 @@ function FromValue2(schema, base, ref) {
2569
2569
  function Base(schema, base, target) {
2570
2570
  return FindBase(schema, new URL(base || ".", DefaultBase), target);
2571
2571
  }
2572
- function Resource(context, schema, base, ref) {
2573
- const result = Ref(context, schema, base, ref, false);
2572
+ function Resource(context2, schema, base, ref) {
2573
+ const result = Ref(context2, schema, base, ref, false);
2574
2574
  return IsSchemaObject(result) && IsId(result) ? result : void 0;
2575
2575
  }
2576
2576
  function CanonicalHref(url) {
2577
2577
  return url.href.split("#")[0];
2578
2578
  }
2579
- function RefContext(context, ref) {
2580
- return guard_exports.HasPropertyKey(context, ref) ? context[ref] : void 0;
2579
+ function RefContext(context2, ref) {
2580
+ return guard_exports.HasPropertyKey(context2, ref) ? context2[ref] : void 0;
2581
2581
  }
2582
2582
  function RefLocal(schema, base, ref) {
2583
2583
  return FromValue2(schema, base, ref);
2584
2584
  }
2585
- function RefRemote(context, base, ref) {
2585
+ function RefRemote(context2, base, ref) {
2586
2586
  const canonicalHref = CanonicalHref(ref);
2587
2587
  if (guard_exports.IsEqual(canonicalHref, CanonicalHref(base)))
2588
2588
  return void 0;
2589
- if (!guard_exports.HasPropertyKey(context, canonicalHref))
2589
+ if (!guard_exports.HasPropertyKey(context2, canonicalHref))
2590
2590
  return void 0;
2591
- const remoteSchema = context[canonicalHref];
2591
+ const remoteSchema = context2[canonicalHref];
2592
2592
  const remoteBase = IsSchemaObject(remoteSchema) && IsId(remoteSchema) ? new URL(remoteSchema.$id, canonicalHref) : new URL(canonicalHref);
2593
2593
  const result = guard_exports.IsEqual(ref.hash, "") ? remoteSchema : FromValue2(remoteSchema, remoteBase, ref);
2594
2594
  return result;
@@ -2603,8 +2603,8 @@ function LegacyRetrievedResource(root, lexicalSchema, referenceBase, ref, schema
2603
2603
  return void 0;
2604
2604
  return { target: schema, base: targetBase, root: lexicalSchema };
2605
2605
  }
2606
- function RemoteRetrievedResource(context, canonical, schema) {
2607
- const remoteRoot = context[canonical];
2606
+ function RemoteRetrievedResource(context2, canonical, schema) {
2607
+ const remoteRoot = context2[canonical];
2608
2608
  if (!IsSchemaObject(remoteRoot))
2609
2609
  return void 0;
2610
2610
  return { target: schema, base: canonical, root: remoteRoot };
@@ -2615,10 +2615,10 @@ function FindRetrievedResource(stackframe, ref, schema, canonical, isRemote) {
2615
2615
  return remote;
2616
2616
  return LegacyRetrievedResource(stackframe.root, stackframe.lexicalSchema, stackframe.referenceBase, ref, schema);
2617
2617
  }
2618
- function FindResolvedResource(context, root, referenceBase, canonical, schema, ids) {
2618
+ function FindResolvedResource(context2, root, referenceBase, canonical, schema, ids) {
2619
2619
  if (IsId(schema))
2620
2620
  return void 0;
2621
- const resource = Resource(context, root, referenceBase, canonical);
2621
+ const resource = Resource(context2, root, referenceBase, canonical);
2622
2622
  if (!resource || ids.includes(resource))
2623
2623
  return void 0;
2624
2624
  return { target: schema, resource };
@@ -2629,10 +2629,10 @@ function Ref(remotes, schema, base, ref, applySchemaId = true) {
2629
2629
  const initialRef = new URL(ref, resolvedBase.href);
2630
2630
  return RefContext(remotes, ref) ?? RefLocal(schema, resolvedBase, initialRef) ?? RefRemote(remotes, resolvedBase, initialRef);
2631
2631
  }
2632
- function DynamicRef(context, root, base, schema, dynamicRef, dynamicAnchors) {
2632
+ function DynamicRef(context2, root, base, schema, dynamicRef, dynamicAnchors) {
2633
2633
  const initialBase = new URL(base || ".", DefaultBase);
2634
2634
  const fragmentRoot = dynamicRef.$dynamicRef.startsWith("#") ? schema : root;
2635
- const fragmentTarget = Ref(context, fragmentRoot, base, dynamicRef.$dynamicRef, false);
2635
+ const fragmentTarget = Ref(context2, fragmentRoot, base, dynamicRef.$dynamicRef, false);
2636
2636
  if (guard_exports.IsUndefined(fragmentTarget)) {
2637
2637
  const fragment2 = new URL(dynamicRef.$dynamicRef, initialBase).hash;
2638
2638
  if (!fragment2.startsWith("#/") && fragment2.startsWith("#")) {
@@ -2692,9 +2692,9 @@ var _Stack_UnregisterResource;
2692
2692
  var _Stack_EnterResolvedResource;
2693
2693
  var _Stack_ExitResolvedResource;
2694
2694
  var Stack = class {
2695
- constructor(context, schema) {
2695
+ constructor(context2, schema) {
2696
2696
  _Stack_instances.add(this);
2697
- this.context = context;
2697
+ this.context = context2;
2698
2698
  this.schema = schema;
2699
2699
  this.ids = [];
2700
2700
  this.resourceIds = [];
@@ -3114,11 +3114,11 @@ function Update(current, hidden, enumerable) {
3114
3114
 
3115
3115
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/errors.mjs
3116
3116
  function Errors(...args) {
3117
- const [context, schema, value] = arguments_exports.Match(args, {
3118
- 3: (context2, schema2, value2) => [context2, schema2, value2],
3117
+ const [context2, schema, value] = arguments_exports.Match(args, {
3118
+ 3: (context3, schema2, value2) => [context3, schema2, value2],
3119
3119
  2: (schema2, value2) => [{}, schema2, value2]
3120
3120
  });
3121
- const stack = new Stack(context, schema);
3121
+ const stack = new Stack(context2, schema);
3122
3122
  const errorContext = new ErrorContext();
3123
3123
  const result = ErrorSchema(stack, errorContext, "#", "", schema, value);
3124
3124
  const errors = errorContext.GetErrors();
@@ -3129,31 +3129,31 @@ function Errors(...args) {
3129
3129
 
3130
3130
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/schema/check.mjs
3131
3131
  function Check(...args) {
3132
- const [context, schema, value] = arguments_exports.Match(args, {
3133
- 3: (context2, schema2, value2) => [context2, schema2, value2],
3132
+ const [context2, schema, value] = arguments_exports.Match(args, {
3133
+ 3: (context3, schema2, value2) => [context3, schema2, value2],
3134
3134
  2: (schema2, value2) => [{}, schema2, value2]
3135
3135
  });
3136
- const stack = new Stack(context, schema);
3136
+ const stack = new Stack(context2, schema);
3137
3137
  const checkContext = new CheckContext();
3138
3138
  return CheckSchema(stack, checkContext, schema, value);
3139
3139
  }
3140
3140
 
3141
3141
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/check/check.mjs
3142
3142
  function Check2(...args) {
3143
- const [context, type, value] = arguments_exports.Match(args, {
3144
- 3: (context2, type2, value2) => [context2, type2, value2],
3143
+ const [context2, type, value] = arguments_exports.Match(args, {
3144
+ 3: (context3, type2, value2) => [context3, type2, value2],
3145
3145
  2: (type2, value2) => [{}, type2, value2]
3146
3146
  });
3147
- return Check(context, type, value);
3147
+ return Check(context2, type, value);
3148
3148
  }
3149
3149
 
3150
3150
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/errors/errors.mjs
3151
3151
  function Errors2(...args) {
3152
- const [context, type, value] = arguments_exports.Match(args, {
3153
- 3: (context2, type2, value2) => [context2, type2, value2],
3152
+ const [context2, type, value] = arguments_exports.Match(args, {
3153
+ 3: (context3, type2, value2) => [context3, type2, value2],
3154
3154
  2: (type2, value2) => [{}, type2, value2]
3155
3155
  });
3156
- const [_, errors] = Errors(context, type, value);
3156
+ const [_, errors] = Errors(context2, type, value);
3157
3157
  return errors;
3158
3158
  }
3159
3159
 
@@ -3194,8 +3194,8 @@ function AddReadonlyAction(type, options) {
3194
3194
  const result = memory_exports.Update(AddReadonlyOperation(type), {}, options);
3195
3195
  return result;
3196
3196
  }
3197
- function AddReadonlyInstantiate(context, state, type, options) {
3198
- const instantiatedType = InstantiateType(context, state, type);
3197
+ function AddReadonlyInstantiate(context2, state, type, options) {
3198
+ const instantiatedType = InstantiateType(context2, state, type);
3199
3199
  return AddReadonlyAction(instantiatedType, options);
3200
3200
  }
3201
3201
 
@@ -3207,8 +3207,8 @@ function AddOptionalAction(type, options) {
3207
3207
  const result = memory_exports.Update(AddOptionalOperation(type), {}, options);
3208
3208
  return result;
3209
3209
  }
3210
- function AddOptionalInstantiate(context, state, type, options) {
3211
- const instantiatedType = InstantiateType(context, state, type);
3210
+ function AddOptionalInstantiate(context2, state, type, options) {
3211
+ const instantiatedType = InstantiateType(context2, state, type);
3212
3212
  return AddOptionalAction(instantiatedType, options);
3213
3213
  }
3214
3214
 
@@ -3724,8 +3724,8 @@ function RemoveReadonlyAction(type, options) {
3724
3724
  const result = memory_exports.Update(RemoveReadonlyOperation(type), {}, options);
3725
3725
  return result;
3726
3726
  }
3727
- function RemoveReadonlyInstantiate(context, state, type, options) {
3728
- const instantiatedType = InstantiateType(context, state, type);
3727
+ function RemoveReadonlyInstantiate(context2, state, type, options) {
3728
+ const instantiatedType = InstantiateType(context2, state, type);
3729
3729
  return RemoveReadonlyAction(instantiatedType, options);
3730
3730
  }
3731
3731
 
@@ -3745,8 +3745,8 @@ function RemoveOptionalAction(type, options) {
3745
3745
  const result = memory_exports.Update(RemoveOptionalOperation(type), {}, options);
3746
3746
  return result;
3747
3747
  }
3748
- function RemoveOptionalInstantiate(context, state, type, options) {
3749
- const instantiatedType = InstantiateType(context, state, type);
3748
+ function RemoveOptionalInstantiate(context2, state, type, options) {
3749
+ const instantiatedType = InstantiateType(context2, state, type);
3750
3750
  return RemoveOptionalAction(instantiatedType, options);
3751
3751
  }
3752
3752
 
@@ -3985,9 +3985,9 @@ function RecordAction(key, value, options) {
3985
3985
  const result = CanInstantiate([key]) ? memory_exports.Update(FromKey(key, value), {}, options) : RecordDeferred(key, value, options);
3986
3986
  return result;
3987
3987
  }
3988
- function RecordInstantiate(context, state, key, value, options) {
3989
- const instantiatedKey = InstantiateType(context, state, key);
3990
- const instantiatedValue = InstantiateType(context, state, value);
3988
+ function RecordInstantiate(context2, state, key, value, options) {
3989
+ const instantiatedKey = InstantiateType(context2, state, key);
3990
+ const instantiatedValue = InstantiateType(context2, state, value);
3991
3991
  return RecordAction(instantiatedKey, instantiatedValue, options);
3992
3992
  }
3993
3993
 
@@ -4958,8 +4958,8 @@ function TemplateLiteralAction(types, options) {
4958
4958
  const result = CanInstantiate(types) ? memory_exports.Update(TemplateLiteralEncode(types), {}, options) : TemplateLiteralDeferred(types, options);
4959
4959
  return result;
4960
4960
  }
4961
- function TemplateLiteralInstantiate(context, state, types, options) {
4962
- const instantiatedTypes = InstantiateTypes(context, state, types);
4961
+ function TemplateLiteralInstantiate(context2, state, types, options) {
4962
+ const instantiatedTypes = InstantiateTypes(context2, state, types);
4963
4963
  return TemplateLiteralAction(instantiatedTypes, options);
4964
4964
  }
4965
4965
 
@@ -5351,9 +5351,9 @@ function InterfaceAction(heritage, properties, options) {
5351
5351
  const result = CanInstantiate(heritage) ? memory_exports.Update(InterfaceOperation(heritage, properties), {}, options) : InterfaceDeferred(heritage, properties, options);
5352
5352
  return result;
5353
5353
  }
5354
- function InterfaceInstantiate(context, state, heritage, properties, options) {
5355
- const instantiatedHeritage = InstantiateTypes(context, state, heritage);
5356
- const instantiatedProperties = InstantiateProperties(context, state, properties);
5354
+ function InterfaceInstantiate(context2, state, heritage, properties, options) {
5355
+ const instantiatedHeritage = InstantiateTypes(context2, state, heritage);
5356
+ const instantiatedProperties = InstantiateProperties(context2, state, properties);
5357
5357
  return InterfaceAction(instantiatedHeritage, instantiatedProperties, options);
5358
5358
  }
5359
5359
 
@@ -5369,54 +5369,54 @@ function Interface(heritage, properties, options = {}) {
5369
5369
  }
5370
5370
 
5371
5371
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/cyclic/check.mjs
5372
- function FromRef(stack, context, ref) {
5373
- return stack.includes(ref) ? true : FromType3([...stack, ref], context, context[ref]);
5372
+ function FromRef(stack, context2, ref) {
5373
+ return stack.includes(ref) ? true : FromType3([...stack, ref], context2, context2[ref]);
5374
5374
  }
5375
- function FromProperties(stack, context, properties) {
5375
+ function FromProperties(stack, context2, properties) {
5376
5376
  const types = PropertyValues(properties);
5377
- return FromTypes2(stack, context, types);
5377
+ return FromTypes2(stack, context2, types);
5378
5378
  }
5379
- function FromTypes2(stack, context, types) {
5380
- return guard_exports.ShiftLeft(types, (left, right) => FromType3(stack, context, left) ? true : FromTypes2(stack, context, right), () => false);
5379
+ function FromTypes2(stack, context2, types) {
5380
+ return guard_exports.ShiftLeft(types, (left, right) => FromType3(stack, context2, left) ? true : FromTypes2(stack, context2, right), () => false);
5381
5381
  }
5382
- function FromType3(stack, context, type) {
5383
- return IsRef2(type) ? FromRef(stack, context, type.$ref) : IsArray2(type) ? FromType3(stack, context, type.items) : IsConstructor2(type) ? FromTypes2(stack, context, [...type.parameters, type.instanceType]) : IsFunction2(type) ? FromTypes2(stack, context, [...type.parameters, type.returnType]) : IsInterfaceDeferred(type) ? FromProperties(stack, context, type.parameters[1]) : IsIntersect(type) ? FromTypes2(stack, context, type.allOf) : IsObject2(type) ? FromProperties(stack, context, type.properties) : IsUnion(type) ? FromTypes2(stack, context, type.anyOf) : IsTuple(type) ? FromTypes2(stack, context, type.items) : IsRecord(type) ? FromType3(stack, context, RecordValue(type)) : false;
5382
+ function FromType3(stack, context2, type) {
5383
+ return IsRef2(type) ? FromRef(stack, context2, type.$ref) : IsArray2(type) ? FromType3(stack, context2, type.items) : IsConstructor2(type) ? FromTypes2(stack, context2, [...type.parameters, type.instanceType]) : IsFunction2(type) ? FromTypes2(stack, context2, [...type.parameters, type.returnType]) : IsInterfaceDeferred(type) ? FromProperties(stack, context2, type.parameters[1]) : IsIntersect(type) ? FromTypes2(stack, context2, type.allOf) : IsObject2(type) ? FromProperties(stack, context2, type.properties) : IsUnion(type) ? FromTypes2(stack, context2, type.anyOf) : IsTuple(type) ? FromTypes2(stack, context2, type.items) : IsRecord(type) ? FromType3(stack, context2, RecordValue(type)) : false;
5384
5384
  }
5385
- function CyclicCheck(stack, context, type) {
5386
- const result = FromType3(stack, context, type);
5385
+ function CyclicCheck(stack, context2, type) {
5386
+ const result = FromType3(stack, context2, type);
5387
5387
  return result;
5388
5388
  }
5389
5389
 
5390
5390
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/cyclic/candidates.mjs
5391
- function ResolveCandidateKeys(context, keys) {
5391
+ function ResolveCandidateKeys(context2, keys) {
5392
5392
  return keys.reduce((result, left) => {
5393
- return CyclicCheck([left], context, context[left]) ? [...result, left] : result;
5393
+ return CyclicCheck([left], context2, context2[left]) ? [...result, left] : result;
5394
5394
  }, []);
5395
5395
  }
5396
- function CyclicCandidates(context) {
5397
- const keys = PropertyKeys(context);
5398
- const result = ResolveCandidateKeys(context, keys);
5396
+ function CyclicCandidates(context2) {
5397
+ const keys = PropertyKeys(context2);
5398
+ const result = ResolveCandidateKeys(context2, keys);
5399
5399
  return result;
5400
5400
  }
5401
5401
 
5402
5402
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs
5403
- function FromRef2(context, ref, result) {
5404
- return result.includes(ref) ? result : ref in context ? FromType4(context, context[ref], [...result, ref]) : Unreachable();
5403
+ function FromRef2(context2, ref, result) {
5404
+ return result.includes(ref) ? result : ref in context2 ? FromType4(context2, context2[ref], [...result, ref]) : Unreachable();
5405
5405
  }
5406
- function FromProperties2(context, properties, result) {
5406
+ function FromProperties2(context2, properties, result) {
5407
5407
  const types = PropertyValues(properties);
5408
- return FromTypes3(context, types, result);
5408
+ return FromTypes3(context2, types, result);
5409
5409
  }
5410
- function FromTypes3(context, types, result) {
5410
+ function FromTypes3(context2, types, result) {
5411
5411
  return types.reduce((result2, left) => {
5412
- return FromType4(context, left, result2);
5412
+ return FromType4(context2, left, result2);
5413
5413
  }, result);
5414
5414
  }
5415
- function FromType4(context, type, result) {
5416
- return IsRef2(type) ? FromRef2(context, type.$ref, result) : IsArray2(type) ? FromType4(context, type.items, result) : IsConstructor2(type) ? FromTypes3(context, [...type.parameters, type.instanceType], result) : IsFunction2(type) ? FromTypes3(context, [...type.parameters, type.returnType], result) : IsInterfaceDeferred(type) ? FromProperties2(context, type.parameters[1], result) : IsIntersect(type) ? FromTypes3(context, type.allOf, result) : IsObject2(type) ? FromProperties2(context, type.properties, result) : IsUnion(type) ? FromTypes3(context, type.anyOf, result) : IsTuple(type) ? FromTypes3(context, type.items, result) : IsRecord(type) ? FromType4(context, RecordValue(type), result) : result;
5415
+ function FromType4(context2, type, result) {
5416
+ return IsRef2(type) ? FromRef2(context2, type.$ref, result) : IsArray2(type) ? FromType4(context2, type.items, result) : IsConstructor2(type) ? FromTypes3(context2, [...type.parameters, type.instanceType], result) : IsFunction2(type) ? FromTypes3(context2, [...type.parameters, type.returnType], result) : IsInterfaceDeferred(type) ? FromProperties2(context2, type.parameters[1], result) : IsIntersect(type) ? FromTypes3(context2, type.allOf, result) : IsObject2(type) ? FromProperties2(context2, type.properties, result) : IsUnion(type) ? FromTypes3(context2, type.anyOf, result) : IsTuple(type) ? FromTypes3(context2, type.items, result) : IsRecord(type) ? FromType4(context2, RecordValue(type), result) : result;
5417
5417
  }
5418
- function CyclicDependencies(context, key, type) {
5419
- const result = FromType4(context, type, [key]);
5418
+ function CyclicDependencies(context2, key, type) {
5419
+ const result = FromType4(context2, type, [key]);
5420
5420
  return result;
5421
5421
  }
5422
5422
 
@@ -5445,23 +5445,23 @@ function CyclicExtends(type) {
5445
5445
  }
5446
5446
 
5447
5447
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs
5448
- function CyclicInterface(context, heritage, properties) {
5449
- const instantiatedHeritage = InstantiateTypes(context, State([], []), heritage);
5448
+ function CyclicInterface(context2, heritage, properties) {
5449
+ const instantiatedHeritage = InstantiateTypes(context2, State([], []), heritage);
5450
5450
  const instantiatedProperties = InstantiateProperties({}, State([], []), properties);
5451
5451
  const evaluatedInterface = EvaluateIntersect([...instantiatedHeritage, _Object_(instantiatedProperties)]);
5452
5452
  return evaluatedInterface;
5453
5453
  }
5454
- function CyclicDefinitions(context, dependencies) {
5455
- const keys = guard_exports.Keys(context).filter((key) => dependencies.includes(key));
5454
+ function CyclicDefinitions(context2, dependencies) {
5455
+ const keys = guard_exports.Keys(context2).filter((key) => dependencies.includes(key));
5456
5456
  return keys.reduce((result, key) => {
5457
- const type = context[key];
5458
- const instantiatedType = IsInterfaceDeferred(type) ? CyclicInterface(context, type.parameters[0], type.parameters[1]) : type;
5457
+ const type = context2[key];
5458
+ const instantiatedType = IsInterfaceDeferred(type) ? CyclicInterface(context2, type.parameters[0], type.parameters[1]) : type;
5459
5459
  return { ...result, [key]: instantiatedType };
5460
5460
  }, {});
5461
5461
  }
5462
- function InstantiateCyclic(context, ref, type) {
5463
- const dependencies = CyclicDependencies(context, ref, type);
5464
- const definitions = CyclicDefinitions(context, dependencies);
5462
+ function InstantiateCyclic(context2, ref, type) {
5463
+ const dependencies = CyclicDependencies(context2, ref, type);
5464
+ const definitions = CyclicDefinitions(context2, dependencies);
5465
5465
  const result = Cyclic(definitions, ref);
5466
5466
  return result;
5467
5467
  }
@@ -5532,8 +5532,8 @@ function EvaluateAction(type, options) {
5532
5532
  const result = memory_exports.Update(EvaluateType(type), {}, options);
5533
5533
  return result;
5534
5534
  }
5535
- function EvaluateInstantiate(context, state, type, options) {
5536
- const instantiatedType = InstantiateType(context, state, type);
5535
+ function EvaluateInstantiate(context2, state, type, options) {
5536
+ const instantiatedType = InstantiateType(context2, state, type);
5537
5537
  return EvaluateAction(instantiatedType, options);
5538
5538
  }
5539
5539
 
@@ -5587,14 +5587,14 @@ function FromNotGeneric() {
5587
5587
  function FromGeneric(name, parameters, expression) {
5588
5588
  return [name, Generic(parameters, expression)];
5589
5589
  }
5590
- function FromRef4(context, ref, arguments_) {
5591
- return ref in context ? FromType6(context, ref, context[ref], arguments_) : FromNotResolvable();
5590
+ function FromRef4(context2, ref, arguments_) {
5591
+ return ref in context2 ? FromType6(context2, ref, context2[ref], arguments_) : FromNotResolvable();
5592
5592
  }
5593
- function FromType6(context, name, target, arguments_) {
5594
- return IsGeneric(target) ? FromGeneric(name, target.parameters, target.expression) : IsRef2(target) ? FromRef4(context, target.$ref, arguments_) : FromNotGeneric();
5593
+ function FromType6(context2, name, target, arguments_) {
5594
+ return IsGeneric(target) ? FromGeneric(name, target.parameters, target.expression) : IsRef2(target) ? FromRef4(context2, target.$ref, arguments_) : FromNotGeneric();
5595
5595
  }
5596
- function ResolveTarget(context, target, arguments_) {
5597
- return FromType6(context, "(anonymous)", target, arguments_);
5596
+ function ResolveTarget(context2, target, arguments_) {
5597
+ return FromType6(context2, "(anonymous)", target, arguments_);
5598
5598
  }
5599
5599
 
5600
5600
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs
@@ -5604,21 +5604,21 @@ function AssertArgumentExtends(name, type, extends_) {
5604
5604
  const cause = { parameter: name, expect: extends_, actual: type };
5605
5605
  throw new Error(`Argument for parameter ${name} does not satisfy constraint`, { cause });
5606
5606
  }
5607
- function BindArgument(context, state, name, extends_, type) {
5608
- const instantiatedArgument = InstantiateType(context, state, type);
5607
+ function BindArgument(context2, state, name, extends_, type) {
5608
+ const instantiatedArgument = InstantiateType(context2, state, type);
5609
5609
  AssertArgumentExtends(name, instantiatedArgument, extends_);
5610
- return memory_exports.Assign(context, { [name]: instantiatedArgument });
5610
+ return memory_exports.Assign(context2, { [name]: instantiatedArgument });
5611
5611
  }
5612
- function BindArguments(context, state, parameterLeft, parameterRight, arguments_) {
5613
- const instantiatedExtends = InstantiateType(context, state, parameterLeft.extends);
5614
- const instantiatedEquals = InstantiateType(context, state, parameterLeft.equals);
5615
- return guard_exports.ShiftLeft(arguments_, (left, right) => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context, state, parameterLeft["name"], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
5612
+ function BindArguments(context2, state, parameterLeft, parameterRight, arguments_) {
5613
+ const instantiatedExtends = InstantiateType(context2, state, parameterLeft.extends);
5614
+ const instantiatedEquals = InstantiateType(context2, state, parameterLeft.equals);
5615
+ return guard_exports.ShiftLeft(arguments_, (left, right) => BindParameters(BindArgument(context2, state, parameterLeft["name"], instantiatedExtends, left), state, parameterRight, right), () => BindParameters(BindArgument(context2, state, parameterLeft["name"], instantiatedExtends, instantiatedEquals), state, parameterRight, []));
5616
5616
  }
5617
- function BindParameters(context, state, parameters, arguments_) {
5618
- return guard_exports.ShiftLeft(parameters, (left, right) => BindArguments(context, state, left, right, arguments_), () => context);
5617
+ function BindParameters(context2, state, parameters, arguments_) {
5618
+ return guard_exports.ShiftLeft(parameters, (left, right) => BindArguments(context2, state, left, right, arguments_), () => context2);
5619
5619
  }
5620
- function ResolveArgumentsContext(context, state, parameters, arguments_) {
5621
- return BindParameters(context, state, parameters, arguments_);
5620
+ function ResolveArgumentsContext(context2, state, parameters, arguments_) {
5621
+ return BindParameters(context2, state, parameters, arguments_);
5622
5622
  }
5623
5623
 
5624
5624
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/call/instantiate.mjs
@@ -5647,34 +5647,34 @@ function IsTailCall(state, name) {
5647
5647
  const result = guard_exports.IsEqual(Peek(state), name);
5648
5648
  return result;
5649
5649
  }
5650
- function CallDispatch(context, state, target, parameters, expression, arguments_) {
5650
+ function CallDispatch(context2, state, target, parameters, expression, arguments_) {
5651
5651
  InstantiationIncrement();
5652
5652
  try {
5653
- const argumentsContext = ResolveArgumentsContext(context, state, parameters, arguments_);
5653
+ const argumentsContext = ResolveArgumentsContext(context2, state, parameters, arguments_);
5654
5654
  const returnType = InstantiateType(argumentsContext, State([...state["callstack"], target["$ref"]], state["visited"]), expression);
5655
5655
  return InstantiateType(argumentsContext, State([], []), returnType);
5656
5656
  } finally {
5657
5657
  InstantiationDecrement();
5658
5658
  }
5659
5659
  }
5660
- function CallDistributed(context, state, target, parameters, expression, distributedArguments) {
5660
+ function CallDistributed(context2, state, target, parameters, expression, distributedArguments) {
5661
5661
  return distributedArguments.reduce((result, arguments_) => {
5662
- const returnType = CallDispatch(context, state, target, parameters, expression, arguments_);
5662
+ const returnType = CallDispatch(context2, state, target, parameters, expression, arguments_);
5663
5663
  return [...result, returnType];
5664
5664
  }, []);
5665
5665
  }
5666
- function CallImmediate(context, state, target, parameters, expression, arguments_) {
5666
+ function CallImmediate(context2, state, target, parameters, expression, arguments_) {
5667
5667
  const distributedArguments = DistributeArguments(parameters, arguments_, expression);
5668
- const returnTypes = CallDistributed(context, state, target, parameters, expression, distributedArguments);
5668
+ const returnTypes = CallDistributed(context2, state, target, parameters, expression, distributedArguments);
5669
5669
  const result = guard_exports.IsEqual(returnTypes.length, 1) ? returnTypes[0] : EvaluateUnion(returnTypes);
5670
5670
  return result;
5671
5671
  }
5672
- function CallInstantiate(context, state, target, arguments_) {
5673
- const instantiatedArguments = InstantiateTypes(context, state, arguments_);
5674
- const resolved = ResolveTarget(context, target, arguments_);
5672
+ function CallInstantiate(context2, state, target, arguments_) {
5673
+ const instantiatedArguments = InstantiateTypes(context2, state, arguments_);
5674
+ const resolved = ResolveTarget(context2, target, arguments_);
5675
5675
  const name = resolved[0];
5676
5676
  const type = resolved[1];
5677
- const result = IsGeneric(type) ? IsTailCall(state, name) ? CallConstruct(Ref2(name), instantiatedArguments) : CallImmediate(context, state, Ref2(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
5677
+ const result = IsGeneric(type) ? IsTailCall(state, name) ? CallConstruct(Ref2(name), instantiatedArguments) : CallImmediate(context2, state, Ref2(name), type.parameters, type.expression, instantiatedArguments) : CallConstruct(target, instantiatedArguments);
5678
5678
  return result;
5679
5679
  }
5680
5680
 
@@ -5697,8 +5697,8 @@ function RemoveImmutableAction(type, options) {
5697
5697
  const result = memory_exports.Update(RemoveImmutableOperation(type), {}, options);
5698
5698
  return result;
5699
5699
  }
5700
- function RemoveImmutableInstantiate(context, state, type, options) {
5701
- const instantiatedType = InstantiateType(context, state, type);
5700
+ function RemoveImmutableInstantiate(context2, state, type, options) {
5701
+ const instantiatedType = InstantiateType(context2, state, type);
5702
5702
  return RemoveImmutableAction(instantiatedType, options);
5703
5703
  }
5704
5704
 
@@ -5783,20 +5783,20 @@ function UppercaseAction(type, options) {
5783
5783
  const result = CanInstantiate([type]) ? memory_exports.Update(FromType7(UppercaseMapping, type), {}, options) : UppercaseDeferred(type, options);
5784
5784
  return result;
5785
5785
  }
5786
- function CapitalizeInstantiate(context, state, type, options) {
5787
- const instantiatedType = InstantiateType(context, state, type);
5786
+ function CapitalizeInstantiate(context2, state, type, options) {
5787
+ const instantiatedType = InstantiateType(context2, state, type);
5788
5788
  return CapitalizeAction(instantiatedType, options);
5789
5789
  }
5790
- function LowercaseInstantiate(context, state, type, options) {
5791
- const instantiatedType = InstantiateType(context, state, type);
5790
+ function LowercaseInstantiate(context2, state, type, options) {
5791
+ const instantiatedType = InstantiateType(context2, state, type);
5792
5792
  return LowercaseAction(instantiatedType, options);
5793
5793
  }
5794
- function UncapitalizeInstantiate(context, state, type, options) {
5795
- const instantiatedType = InstantiateType(context, state, type);
5794
+ function UncapitalizeInstantiate(context2, state, type, options) {
5795
+ const instantiatedType = InstantiateType(context2, state, type);
5796
5796
  return UncapitalizeAction(instantiatedType, options);
5797
5797
  }
5798
- function UppercaseInstantiate(context, state, type, options) {
5799
- const instantiatedType = InstantiateType(context, state, type);
5798
+ function UppercaseInstantiate(context2, state, type, options) {
5799
+ const instantiatedType = InstantiateType(context2, state, type);
5800
5800
  return UppercaseAction(instantiatedType, options);
5801
5801
  }
5802
5802
 
@@ -5809,18 +5809,18 @@ function Conditional(left, right, true_, false_, options = {}) {
5809
5809
  }
5810
5810
 
5811
5811
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/conditional/instantiate.mjs
5812
- function ConditionalOperation(context, state, left, right, true_, false_) {
5813
- const extendsResult = Extends(context, left, right);
5814
- return result_exports.IsExtendsUnion(extendsResult) ? Union([InstantiateType(extendsResult.inferred, state, true_), InstantiateType(context, state, false_)]) : result_exports.IsExtendsTrue(extendsResult) ? InstantiateType(extendsResult.inferred, state, true_) : InstantiateType(context, state, false_);
5812
+ function ConditionalOperation(context2, state, left, right, true_, false_) {
5813
+ const extendsResult = Extends(context2, left, right);
5814
+ return result_exports.IsExtendsUnion(extendsResult) ? Union([InstantiateType(extendsResult.inferred, state, true_), InstantiateType(context2, state, false_)]) : result_exports.IsExtendsTrue(extendsResult) ? InstantiateType(extendsResult.inferred, state, true_) : InstantiateType(context2, state, false_);
5815
5815
  }
5816
- function ConditionalAction(context, state, left, right, true_, false_, options) {
5817
- const result = CanInstantiate([left, right]) ? memory_exports.Update(ConditionalOperation(context, state, left, right, true_, false_), {}, options) : ConditionalDeferred(left, right, true_, false_, options);
5816
+ function ConditionalAction(context2, state, left, right, true_, false_, options) {
5817
+ const result = CanInstantiate([left, right]) ? memory_exports.Update(ConditionalOperation(context2, state, left, right, true_, false_), {}, options) : ConditionalDeferred(left, right, true_, false_, options);
5818
5818
  return result;
5819
5819
  }
5820
- function ConditionalInstantiate(context, state, left, right, true_, false_, options) {
5821
- const instantiatedLeft = InstantiateType(context, state, left);
5822
- const instantiatedRight = InstantiateType(context, state, right);
5823
- return ConditionalAction(context, state, instantiatedLeft, instantiatedRight, true_, false_, options);
5820
+ function ConditionalInstantiate(context2, state, left, right, true_, false_, options) {
5821
+ const instantiatedLeft = InstantiateType(context2, state, left);
5822
+ const instantiatedRight = InstantiateType(context2, state, right);
5823
+ return ConditionalAction(context2, state, instantiatedLeft, instantiatedRight, true_, false_, options);
5824
5824
  }
5825
5825
 
5826
5826
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/action/constructor_parameters.mjs
@@ -5842,8 +5842,8 @@ function ConstructorParametersAction(type, options) {
5842
5842
  const result = CanInstantiate([type]) ? memory_exports.Update(ConstructorParametersOperation(type), {}, options) : ConstructorParametersDeferred(type, options);
5843
5843
  return result;
5844
5844
  }
5845
- function ConstructorParametersInstantiate(context, state, type, options) {
5846
- const instantiatedType = InstantiateType(context, state, type);
5845
+ function ConstructorParametersInstantiate(context2, state, type, options) {
5846
+ const instantiatedType = InstantiateType(context2, state, type);
5847
5847
  return ConstructorParametersAction(instantiatedType, options);
5848
5848
  }
5849
5849
 
@@ -5860,9 +5860,9 @@ function ExcludeAction(left, right, options) {
5860
5860
  const result = CanInstantiate([left, right]) ? memory_exports.Update(ExcludeOperation(left, right), {}, options) : ExcludeDeferred(left, right, options);
5861
5861
  return result;
5862
5862
  }
5863
- function ExcludeInstantiate(context, state, left, right, options) {
5864
- const instantiatedLeft = InstantiateType(context, state, left);
5865
- const instantiatedRight = InstantiateType(context, state, right);
5863
+ function ExcludeInstantiate(context2, state, left, right, options) {
5864
+ const instantiatedLeft = InstantiateType(context2, state, left);
5865
+ const instantiatedRight = InstantiateType(context2, state, right);
5866
5866
  return ExcludeAction(instantiatedLeft, instantiatedRight, options);
5867
5867
  }
5868
5868
 
@@ -5896,9 +5896,9 @@ function ExtractAction(left, right, options) {
5896
5896
  const result = CanInstantiate([left, right]) ? memory_exports.Update(ExtractOperation(left, right), {}, options) : ExtractDeferred(left, right, options);
5897
5897
  return result;
5898
5898
  }
5899
- function ExtractInstantiate(context, state, left, right, options) {
5900
- const instantiatedLeft = InstantiateType(context, state, left);
5901
- const instantiatedRight = InstantiateType(context, state, right);
5899
+ function ExtractInstantiate(context2, state, left, right, options) {
5900
+ const instantiatedLeft = InstantiateType(context2, state, left);
5901
+ const instantiatedRight = InstantiateType(context2, state, right);
5902
5902
  return ExtractAction(instantiatedLeft, instantiatedRight, options);
5903
5903
  }
5904
5904
 
@@ -6173,9 +6173,9 @@ function IndexAction(type, indexer, options) {
6173
6173
  const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType11(NormalizeType(type), indexer), {}, options) : IndexDeferred(type, indexer, options);
6174
6174
  return result;
6175
6175
  }
6176
- function IndexInstantiate(context, state, type, indexer, options) {
6177
- const instantiatedType = InstantiateType(context, state, type);
6178
- const instantiatedIndexer = InstantiateType(context, state, indexer);
6176
+ function IndexInstantiate(context2, state, type, indexer, options) {
6177
+ const instantiatedType = InstantiateType(context2, state, type);
6178
+ const instantiatedIndexer = InstantiateType(context2, state, indexer);
6179
6179
  return IndexAction(instantiatedType, instantiatedIndexer, options);
6180
6180
  }
6181
6181
 
@@ -6195,8 +6195,8 @@ function InstanceTypeAction(type, options) {
6195
6195
  const result = CanInstantiate([type]) ? memory_exports.Update(InstanceTypeOperation(type), {}, options) : InstanceTypeDeferred(type, options);
6196
6196
  return result;
6197
6197
  }
6198
- function InstanceTypeInstantiate(context, state, type, options = {}) {
6199
- const instantiatedType = InstantiateType(context, state, type);
6198
+ function InstanceTypeInstantiate(context2, state, type, options = {}) {
6199
+ const instantiatedType = InstantiateType(context2, state, type);
6200
6200
  return InstanceTypeAction(instantiatedType, options);
6201
6201
  }
6202
6202
 
@@ -6256,8 +6256,8 @@ function NormalizeType2(type) {
6256
6256
  function KeyOfAction(type, options) {
6257
6257
  return CanInstantiate([type]) ? memory_exports.Update(FromType12(NormalizeType2(type)), {}, options) : KeyOfDeferred(type, options);
6258
6258
  }
6259
- function KeyOfInstantiate(context, state, type, options) {
6260
- const instantiatedType = InstantiateType(context, state, type);
6259
+ function KeyOfInstantiate(context2, state, type, options) {
6260
+ const instantiatedType = InstantiateType(context2, state, type);
6261
6261
  return KeyOfAction(instantiatedType, options);
6262
6262
  }
6263
6263
 
@@ -6303,16 +6303,16 @@ function CanonicalAs(instantiatedAs) {
6303
6303
  const result = IsTemplateLiteral(instantiatedAs) ? EvaluateTemplateLiteral(instantiatedAs.pattern) : instantiatedAs;
6304
6304
  return result;
6305
6305
  }
6306
- function MappedVariant(context, state, identifier, variant, as, property) {
6307
- const variantContext = memory_exports.Assign(context, { [identifier["name"]]: variant });
6306
+ function MappedVariant(context2, state, identifier, variant, as, property) {
6307
+ const variantContext = memory_exports.Assign(context2, { [identifier["name"]]: variant });
6308
6308
  const instantiatedAs = InstantiateType(variantContext, state, as);
6309
6309
  const canonicalAs = CanonicalAs(instantiatedAs);
6310
6310
  const instantiatedProperty = InstantiateType(variantContext, state, property);
6311
6311
  return IsLiteralNumber(canonicalAs) || IsLiteralString(canonicalAs) ? { [canonicalAs.const]: instantiatedProperty } : {};
6312
6312
  }
6313
- function MappedProperties(context, state, identifier, variants, as, property) {
6313
+ function MappedProperties(context2, state, identifier, variants, as, property) {
6314
6314
  return variants.reduce((result, left) => {
6315
- return [...result, MappedVariant(context, state, identifier, left, as, property)];
6315
+ return [...result, MappedVariant(context2, state, identifier, left, as, property)];
6316
6316
  }, []);
6317
6317
  }
6318
6318
  function MappedObjects(properties) {
@@ -6320,48 +6320,48 @@ function MappedObjects(properties) {
6320
6320
  return [...result, _Object_(left)];
6321
6321
  }, []);
6322
6322
  }
6323
- function MappedOperation(context, state, identifier, type, as, property) {
6323
+ function MappedOperation(context2, state, identifier, type, as, property) {
6324
6324
  const variants = MappedVariants(type);
6325
- const mappedProperties = MappedProperties(context, state, identifier, variants, as, property);
6325
+ const mappedProperties = MappedProperties(context2, state, identifier, variants, as, property);
6326
6326
  const mappedObjects = MappedObjects(mappedProperties);
6327
6327
  const result = EvaluateIntersect(mappedObjects);
6328
6328
  return result;
6329
6329
  }
6330
6330
 
6331
6331
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/mapped/instantiate.mjs
6332
- function MappedAction(context, state, identifier, type, as, property, options) {
6333
- const result = CanInstantiate([type]) ? memory_exports.Update(MappedOperation(context, state, identifier, type, as, property), {}, options) : MappedDeferred(identifier, type, as, property, options);
6332
+ function MappedAction(context2, state, identifier, type, as, property, options) {
6333
+ const result = CanInstantiate([type]) ? memory_exports.Update(MappedOperation(context2, state, identifier, type, as, property), {}, options) : MappedDeferred(identifier, type, as, property, options);
6334
6334
  return result;
6335
6335
  }
6336
- function MappedInstantiate(context, state, identifier, type, as, property, options) {
6337
- const instantiatedType = InstantiateType(context, state, type);
6338
- return MappedAction(context, state, identifier, instantiatedType, as, property, options);
6336
+ function MappedInstantiate(context2, state, identifier, type, as, property, options) {
6337
+ const instantiatedType = InstantiateType(context2, state, type);
6338
+ return MappedAction(context2, state, identifier, instantiatedType, as, property, options);
6339
6339
  }
6340
6340
 
6341
6341
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/module/instantiate.mjs
6342
- function InstantiateCyclics(context, declarations, cyclicKeys) {
6343
- const declarationContext = memory_exports.Assign(context, declarations);
6342
+ function InstantiateCyclics(context2, declarations, cyclicKeys) {
6343
+ const declarationContext = memory_exports.Assign(context2, declarations);
6344
6344
  const declarationKeys = guard_exports.Keys(declarations).filter((key) => cyclicKeys.includes(key));
6345
6345
  return declarationKeys.reduce((result, key) => {
6346
6346
  return { ...result, [key]: InstantiateCyclic(declarationContext, key, declarations[key]) };
6347
6347
  }, {});
6348
6348
  }
6349
- function InstantiateNonCyclics(context, declarations, cyclicKeys) {
6350
- const declarationContext = memory_exports.Assign(context, declarations);
6349
+ function InstantiateNonCyclics(context2, declarations, cyclicKeys) {
6350
+ const declarationContext = memory_exports.Assign(context2, declarations);
6351
6351
  const declarationKeys = guard_exports.Keys(declarations).filter((key) => !cyclicKeys.includes(key));
6352
6352
  return declarationKeys.reduce((result, key) => {
6353
6353
  return { ...result, [key]: InstantiateType(declarationContext, State([], []), declarations[key]) };
6354
6354
  }, {});
6355
6355
  }
6356
- function InstantiateModule(context, declarations, options) {
6356
+ function InstantiateModule(context2, declarations, options) {
6357
6357
  const cyclicCandidates = CyclicCandidates(declarations);
6358
- const instantiatedCyclics = InstantiateCyclics(context, declarations, cyclicCandidates);
6359
- const instantiatedNonCyclics = InstantiateNonCyclics(context, declarations, cyclicCandidates);
6358
+ const instantiatedCyclics = InstantiateCyclics(context2, declarations, cyclicCandidates);
6359
+ const instantiatedNonCyclics = InstantiateNonCyclics(context2, declarations, cyclicCandidates);
6360
6360
  const instantiatedModule = { ...instantiatedCyclics, ...instantiatedNonCyclics };
6361
6361
  return memory_exports.Update(instantiatedModule, {}, options);
6362
6362
  }
6363
- function ModuleInstantiate(context, _state, declarations, options) {
6364
- const instantiatedModule = InstantiateModule(context, declarations, options);
6363
+ function ModuleInstantiate(context2, _state, declarations, options) {
6364
+ const instantiatedModule = InstantiateModule(context2, declarations, options);
6365
6365
  return instantiatedModule;
6366
6366
  }
6367
6367
 
@@ -6382,8 +6382,8 @@ function NonNullableAction(type, options) {
6382
6382
  const result = CanInstantiate([type]) ? memory_exports.Update(NonNullableOperation(type), {}, options) : NonNullableDeferred(type, options);
6383
6383
  return result;
6384
6384
  }
6385
- function NonNullableInstantiate(context, state, type, options) {
6386
- const instantiatedType = InstantiateType(context, state, type);
6385
+ function NonNullableInstantiate(context2, state, type, options) {
6386
+ const instantiatedType = InstantiateType(context2, state, type);
6387
6387
  return NonNullableAction(instantiatedType, options);
6388
6388
  }
6389
6389
 
@@ -6423,9 +6423,9 @@ function OmitAction(type, indexer, options) {
6423
6423
  const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType14(type, indexer), {}, options) : OmitDeferred(type, indexer, options);
6424
6424
  return result;
6425
6425
  }
6426
- function OmitInstantiate(context, state, type, indexer, options) {
6427
- const instantiatedType = InstantiateType(context, state, type);
6428
- const instantiatedIndexer = InstantiateType(context, state, indexer);
6426
+ function OmitInstantiate(context2, state, type, indexer, options) {
6427
+ const instantiatedType = InstantiateType(context2, state, type);
6428
+ const instantiatedIndexer = InstantiateType(context2, state, indexer);
6429
6429
  return OmitAction(instantiatedType, instantiatedIndexer, options);
6430
6430
  }
6431
6431
 
@@ -6448,8 +6448,8 @@ function ParametersAction(type, options) {
6448
6448
  const result = CanInstantiate([type]) ? memory_exports.Update(ParametersOperation(type), {}, options) : ParametersDeferred(type, options);
6449
6449
  return result;
6450
6450
  }
6451
- function ParametersInstantiate(context, state, type, options) {
6452
- const instantiatedType = InstantiateType(context, state, type);
6451
+ function ParametersInstantiate(context2, state, type, options) {
6452
+ const instantiatedType = InstantiateType(context2, state, type);
6453
6453
  return ParametersAction(instantiatedType, options);
6454
6454
  }
6455
6455
 
@@ -6508,8 +6508,8 @@ function PartialAction(type, options) {
6508
6508
  const result = CanInstantiate([type]) ? memory_exports.Update(FromType15(type), {}, options) : PartialDeferred(type, options);
6509
6509
  return result;
6510
6510
  }
6511
- function PartialInstantiate(context, state, type, options) {
6512
- const instantiatedType = InstantiateType(context, state, type);
6511
+ function PartialInstantiate(context2, state, type, options) {
6512
+ const instantiatedType = InstantiateType(context2, state, type);
6513
6513
  return PartialAction(instantiatedType, options);
6514
6514
  }
6515
6515
 
@@ -6542,9 +6542,9 @@ function PickAction(type, indexer, options) {
6542
6542
  const result = CanInstantiate([type, indexer]) ? memory_exports.Update(FromType16(type, indexer), {}, options) : PickDeferred(type, indexer, options);
6543
6543
  return result;
6544
6544
  }
6545
- function PickInstantiate(context, state, type, indexer, options) {
6546
- const instantiatedType = InstantiateType(context, state, type);
6547
- const instantiatedIndexer = InstantiateType(context, state, indexer);
6545
+ function PickInstantiate(context2, state, type, indexer, options) {
6546
+ const instantiatedType = InstantiateType(context2, state, type);
6547
+ const instantiatedIndexer = InstantiateType(context2, state, indexer);
6548
6548
  return PickAction(instantiatedType, instantiatedIndexer, options);
6549
6549
  }
6550
6550
 
@@ -6616,14 +6616,14 @@ function ReadonlyObjectAction(type, options) {
6616
6616
  const result = CanInstantiate([type]) ? memory_exports.Update(FromType17(type), {}, options) : ReadonlyObjectDeferred(type);
6617
6617
  return result;
6618
6618
  }
6619
- function ReadonlyObjectInstantiate(context, state, type, options) {
6620
- const instantiatedType = InstantiateType(context, state, type);
6619
+ function ReadonlyObjectInstantiate(context2, state, type, options) {
6620
+ const instantiatedType = InstantiateType(context2, state, type);
6621
6621
  return ReadonlyObjectAction(instantiatedType, options);
6622
6622
  }
6623
6623
 
6624
6624
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/ref/instantiate.mjs
6625
- function RefInstantiate(context, state, type, ref) {
6626
- return state.visited.includes(ref) ? type : ref in context ? InstantiateType(context, State(state["callstack"], [...state["visited"], ref]), context[ref]) : type;
6625
+ function RefInstantiate(context2, state, type, ref) {
6626
+ return state.visited.includes(ref) ? type : ref in context2 ? InstantiateType(context2, State(state["callstack"], [...state["visited"], ref]), context2[ref]) : type;
6627
6627
  }
6628
6628
 
6629
6629
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/required/from_cyclic.mjs
@@ -6681,8 +6681,8 @@ function RequiredAction(type, options) {
6681
6681
  const result = CanInstantiate([type]) ? memory_exports.Update(FromType18(type), {}, options) : RequiredDeferred(type, options);
6682
6682
  return result;
6683
6683
  }
6684
- function RequiredInstantiate(context, state, type, options) {
6685
- const instaniatedType = InstantiateType(context, state, type);
6684
+ function RequiredInstantiate(context2, state, type, options) {
6685
+ const instaniatedType = InstantiateType(context2, state, type);
6686
6686
  return RequiredAction(instaniatedType, options);
6687
6687
  }
6688
6688
 
@@ -6702,8 +6702,8 @@ function ReturnTypeAction(type, options) {
6702
6702
  const result = CanInstantiate([type]) ? memory_exports.Update(ReturnTypeOperation(type), {}, options) : ReturnTypeDeferred(type, options);
6703
6703
  return result;
6704
6704
  }
6705
- function ReturnTypeInstantiate(context, state, type, options = {}) {
6706
- const instantiatedType = InstantiateType(context, state, type);
6705
+ function ReturnTypeInstantiate(context2, state, type, options = {}) {
6706
+ const instantiatedType = InstantiateType(context2, state, type);
6707
6707
  return ReturnTypeAction(instantiatedType, options);
6708
6708
  }
6709
6709
 
@@ -6720,8 +6720,8 @@ function WithAction(type, options) {
6720
6720
  const result = CanInstantiate([type]) ? memory_exports.Update(type, {}, options) : WithDeferred(type, options);
6721
6721
  return result;
6722
6722
  }
6723
- function WithInstantiate(context, state, type, options) {
6724
- const instaniatedType = InstantiateType(context, state, type);
6723
+ function WithInstantiate(context2, state, type, options) {
6724
+ const instaniatedType = InstantiateType(context2, state, type);
6725
6725
  return WithAction(instaniatedType, options);
6726
6726
  }
6727
6727
 
@@ -6744,18 +6744,18 @@ function State(callstack, visited) {
6744
6744
  function CanInstantiate(types) {
6745
6745
  return guard_exports.ShiftLeft(types, (left, right) => IsRef2(left) ? false : CanInstantiate(right), () => true);
6746
6746
  }
6747
- function InstantiateProperties(context, state, properties) {
6747
+ function InstantiateProperties(context2, state, properties) {
6748
6748
  return guard_exports.Keys(properties).reduce((result, key) => {
6749
- return { ...result, [key]: InstantiateType(context, state, properties[key]) };
6749
+ return { ...result, [key]: InstantiateType(context2, state, properties[key]) };
6750
6750
  }, {});
6751
6751
  }
6752
- function InstantiateElements(context, state, types) {
6753
- const elements = InstantiateTypes(context, state, types);
6752
+ function InstantiateElements(context2, state, types) {
6753
+ const elements = InstantiateTypes(context2, state, types);
6754
6754
  const result = RestSpread(elements);
6755
6755
  return result;
6756
6756
  }
6757
- function InstantiateTypes(context, state, types) {
6758
- return types.map((type) => InstantiateType(context, state, type));
6757
+ function InstantiateTypes(context2, state, types) {
6758
+ return types.map((type) => InstantiateType(context2, state, type));
6759
6759
  }
6760
6760
  function WithModifiers(type, instantiatedType) {
6761
6761
  const withOptional = IsOptional(type) ? AddOptionalAction(instantiatedType, {}) : instantiatedType;
@@ -6763,26 +6763,26 @@ function WithModifiers(type, instantiatedType) {
6763
6763
  const withImmutable = IsImmutable(type) ? AddImmutableAction(withReadonly, {}) : withReadonly;
6764
6764
  return withImmutable;
6765
6765
  }
6766
- function InstantiateDeferred(context, state, action, parameters, options) {
6766
+ function InstantiateDeferred(context2, state, action, parameters, options) {
6767
6767
  return (
6768
6768
  // Modifiers
6769
- guard_exports.IsEqual(action, "AddImmutable") ? AddImmutableInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveImmutable") ? RemoveImmutableInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "AddReadonly") ? AddReadonlyInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveReadonly") ? RemoveReadonlyInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "AddOptional") ? AddOptionalInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveOptional") ? RemoveOptionalInstantiate(context, state, parameters[0], options) : (
6769
+ guard_exports.IsEqual(action, "AddImmutable") ? AddImmutableInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveImmutable") ? RemoveImmutableInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "AddReadonly") ? AddReadonlyInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveReadonly") ? RemoveReadonlyInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "AddOptional") ? AddOptionalInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "RemoveOptional") ? RemoveOptionalInstantiate(context2, state, parameters[0], options) : (
6770
6770
  // Actions
6771
- guard_exports.IsEqual(action, "Capitalize") ? CapitalizeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Conditional") ? ConditionalInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "ConstructorParameters") ? ConstructorParametersInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Evaluate") ? EvaluateInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Exclude") ? ExcludeInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Extract") ? ExtractInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Index") ? IndexInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "InstanceType") ? InstanceTypeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Interface") ? InterfaceInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "KeyOf") ? KeyOfInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Lowercase") ? LowercaseInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Mapped") ? MappedInstantiate(context, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "Module") ? ModuleInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "NonNullable") ? NonNullableInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Pick") ? PickInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Parameters") ? ParametersInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Partial") ? PartialInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Omit") ? OmitInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "ReadonlyObject") ? ReadonlyObjectInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Record") ? RecordInstantiate(context, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Required") ? RequiredInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "ReturnType") ? ReturnTypeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "TemplateLiteral") ? TemplateLiteralInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Uncapitalize") ? UncapitalizeInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "Uppercase") ? UppercaseInstantiate(context, state, parameters[0], options) : guard_exports.IsEqual(action, "With") ? WithInstantiate(context, state, parameters[0], parameters[1]) : Deferred(action, parameters, options)
6771
+ guard_exports.IsEqual(action, "Capitalize") ? CapitalizeInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Conditional") ? ConditionalInstantiate(context2, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "ConstructorParameters") ? ConstructorParametersInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Evaluate") ? EvaluateInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Exclude") ? ExcludeInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Extract") ? ExtractInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Index") ? IndexInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "InstanceType") ? InstanceTypeInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Interface") ? InterfaceInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "KeyOf") ? KeyOfInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Lowercase") ? LowercaseInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Mapped") ? MappedInstantiate(context2, state, parameters[0], parameters[1], parameters[2], parameters[3], options) : guard_exports.IsEqual(action, "Module") ? ModuleInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "NonNullable") ? NonNullableInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Pick") ? PickInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Parameters") ? ParametersInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Partial") ? PartialInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Omit") ? OmitInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "ReadonlyObject") ? ReadonlyObjectInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Record") ? RecordInstantiate(context2, state, parameters[0], parameters[1], options) : guard_exports.IsEqual(action, "Required") ? RequiredInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "ReturnType") ? ReturnTypeInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "TemplateLiteral") ? TemplateLiteralInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Uncapitalize") ? UncapitalizeInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "Uppercase") ? UppercaseInstantiate(context2, state, parameters[0], options) : guard_exports.IsEqual(action, "With") ? WithInstantiate(context2, state, parameters[0], parameters[1]) : Deferred(action, parameters, options)
6772
6772
  )
6773
6773
  );
6774
6774
  }
6775
- function InstantiateImmediate(context, state, type) {
6776
- const instantiatedType = IsRef2(type) ? RefInstantiate(context, state, type, type.$ref) : IsArray2(type) ? _Array_(InstantiateType(context, state, type.items), ArrayOptions(type)) : IsCall(type) ? CallInstantiate(context, state, type.target, type.arguments) : IsConstructor2(type) ? Constructor(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.instanceType), ConstructorOptions(type)) : IsFunction2(type) ? _Function_(InstantiateTypes(context, state, type.parameters), InstantiateType(context, state, type.returnType), FunctionOptions(type)) : IsDependent(type) ? Dependent(InstantiateType(context, state, type.if), InstantiateType(context, state, type.then), InstantiateType(context, state, type.else), DependentOptions(type)) : IsIntersect(type) ? Intersect(InstantiateTypes(context, state, type.allOf), IntersectOptions(type)) : IsObject2(type) ? _Object_(InstantiateProperties(context, state, type.properties), ObjectOptions(type)) : IsRecord(type) ? RecordFromPattern(RecordPattern(type), InstantiateType(context, state, RecordValue(type))) : IsRest(type) ? Rest(InstantiateType(context, state, type.items)) : IsTuple(type) ? Tuple(InstantiateElements(context, state, type.items), TupleOptions(type)) : IsUnion(type) ? Union(InstantiateTypes(context, state, type.anyOf), UnionOptions(type)) : type;
6775
+ function InstantiateImmediate(context2, state, type) {
6776
+ const instantiatedType = IsRef2(type) ? RefInstantiate(context2, state, type, type.$ref) : IsArray2(type) ? _Array_(InstantiateType(context2, state, type.items), ArrayOptions(type)) : IsCall(type) ? CallInstantiate(context2, state, type.target, type.arguments) : IsConstructor2(type) ? Constructor(InstantiateTypes(context2, state, type.parameters), InstantiateType(context2, state, type.instanceType), ConstructorOptions(type)) : IsFunction2(type) ? _Function_(InstantiateTypes(context2, state, type.parameters), InstantiateType(context2, state, type.returnType), FunctionOptions(type)) : IsDependent(type) ? Dependent(InstantiateType(context2, state, type.if), InstantiateType(context2, state, type.then), InstantiateType(context2, state, type.else), DependentOptions(type)) : IsIntersect(type) ? Intersect(InstantiateTypes(context2, state, type.allOf), IntersectOptions(type)) : IsObject2(type) ? _Object_(InstantiateProperties(context2, state, type.properties), ObjectOptions(type)) : IsRecord(type) ? RecordFromPattern(RecordPattern(type), InstantiateType(context2, state, RecordValue(type))) : IsRest(type) ? Rest(InstantiateType(context2, state, type.items)) : IsTuple(type) ? Tuple(InstantiateElements(context2, state, type.items), TupleOptions(type)) : IsUnion(type) ? Union(InstantiateTypes(context2, state, type.anyOf), UnionOptions(type)) : type;
6777
6777
  const withModifiers = WithModifiers(type, instantiatedType);
6778
6778
  return withModifiers;
6779
6779
  }
6780
- function InstantiateType(context, state, type) {
6781
- const result = IsDeferred(type) ? InstantiateDeferred(context, state, type.action, type.parameters, type.options) : InstantiateImmediate(context, state, type);
6780
+ function InstantiateType(context2, state, type) {
6781
+ const result = IsDeferred(type) ? InstantiateDeferred(context2, state, type.action, type.parameters, type.options) : InstantiateImmediate(context2, state, type);
6782
6782
  return result;
6783
6783
  }
6784
- function Instantiate(context, type) {
6785
- return InstantiateType(context, State([], []), type);
6784
+ function Instantiate(context2, type) {
6785
+ return InstantiateType(context2, State([], []), type);
6786
6786
  }
6787
6787
 
6788
6788
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs
@@ -6793,8 +6793,8 @@ function AddImmutableAction(type, options) {
6793
6793
  const result = memory_exports.Update(AddImmutableOperation(type), {}, options);
6794
6794
  return result;
6795
6795
  }
6796
- function AddImmutableInstantiate(context, state, type, options) {
6797
- const instantiatedType = InstantiateType(context, state, type);
6796
+ function AddImmutableInstantiate(context2, state, type, options) {
6797
+ const instantiatedType = InstantiateType(context2, state, type);
6798
6798
  return AddImmutableAction(instantiatedType, options);
6799
6799
  }
6800
6800
 
@@ -6840,38 +6840,38 @@ function Priority(types) {
6840
6840
 
6841
6841
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/type/script/script.mjs
6842
6842
  function Script2(...args) {
6843
- const [context, input, options] = arguments_exports.Match(args, {
6843
+ const [context2, input, options] = arguments_exports.Match(args, {
6844
6844
  2: (script, options2) => guard_exports.IsString(script) ? [{}, script, options2] : [script, options2, {}],
6845
- 3: (context2, script, options2) => [context2, script, options2],
6845
+ 3: (context3, script, options2) => [context3, script, options2],
6846
6846
  1: (script) => [{}, script, {}]
6847
6847
  });
6848
6848
  const result = Script(input);
6849
- const parsed = guard_exports.IsArray(result) && guard_exports.IsEqual(result.length, 2) ? InstantiateType(context, State([], []), result[0]) : Never();
6849
+ const parsed = guard_exports.IsArray(result) && guard_exports.IsEqual(result.length, 2) ? InstantiateType(context2, State([], []), result[0]) : Never();
6850
6850
  return memory_exports.Update(parsed, {}, options);
6851
6851
  }
6852
6852
 
6853
6853
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_array.mjs
6854
- function FromArray7(context, type, value) {
6854
+ function FromArray7(context2, type, value) {
6855
6855
  if (!guard_exports.IsArray(value))
6856
6856
  return value;
6857
- return value.map((value2) => FromType19(context, type.items, value2));
6857
+ return value.map((value2) => FromType19(context2, type.items, value2));
6858
6858
  }
6859
6859
 
6860
6860
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_cyclic.mjs
6861
- function FromCyclic6(context, type, value) {
6862
- return FromType19({ ...context, ...type.$defs }, Ref2(type.$ref), value);
6861
+ function FromCyclic6(context2, type, value) {
6862
+ return FromType19({ ...context2, ...type.$defs }, Ref2(type.$ref), value);
6863
6863
  }
6864
6864
 
6865
6865
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_intersect.mjs
6866
- function EvaluateIntersection(context, type) {
6866
+ function EvaluateIntersection(context2, type) {
6867
6867
  const additionalProperties = guard_exports.HasPropertyKey(type, "unevaluatedProperties") ? { additionalProperties: type.unevaluatedProperties } : {};
6868
- const instantiated = Instantiate(context, type);
6868
+ const instantiated = Instantiate(context2, type);
6869
6869
  const evaluated = Evaluate(instantiated);
6870
6870
  return IsObject2(evaluated) ? With2(evaluated, additionalProperties) : evaluated;
6871
6871
  }
6872
- function FromIntersect6(context, type, value) {
6873
- const evaluated = EvaluateIntersection(context, type);
6874
- return FromType19(context, evaluated, value);
6872
+ function FromIntersect6(context2, type, value) {
6873
+ const evaluated = EvaluateIntersection(context2, type);
6874
+ return FromType19(context2, evaluated, value);
6875
6875
  }
6876
6876
 
6877
6877
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/additional.mjs
@@ -6881,21 +6881,21 @@ function GetAdditionalProperties(type) {
6881
6881
  }
6882
6882
 
6883
6883
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_object.mjs
6884
- function FromObject11(context, type, value) {
6884
+ function FromObject11(context2, type, value) {
6885
6885
  if (!guard_exports.IsObject(value) || guard_exports.IsArray(value))
6886
6886
  return value;
6887
6887
  const additionalProperties = GetAdditionalProperties(type);
6888
6888
  for (const key of guard_exports.Keys(value)) {
6889
6889
  if (guard_exports.HasPropertyKey(type.properties, key)) {
6890
- value[key] = FromType19(context, type.properties[key], value[key]);
6890
+ value[key] = FromType19(context2, type.properties[key], value[key]);
6891
6891
  continue;
6892
6892
  }
6893
6893
  const unknownCheck = (
6894
6894
  // 1. additionalProperties: true
6895
- guard_exports.IsBoolean(additionalProperties) && guard_exports.IsEqual(additionalProperties, true) || IsSchema2(additionalProperties) && Check2(context, additionalProperties, value[key])
6895
+ guard_exports.IsBoolean(additionalProperties) && guard_exports.IsEqual(additionalProperties, true) || IsSchema2(additionalProperties) && Check2(context2, additionalProperties, value[key])
6896
6896
  );
6897
6897
  if (unknownCheck) {
6898
- value[key] = FromType19(context, additionalProperties, value[key]);
6898
+ value[key] = FromType19(context2, additionalProperties, value[key]);
6899
6899
  continue;
6900
6900
  }
6901
6901
  delete value[key];
@@ -6904,22 +6904,22 @@ function FromObject11(context, type, value) {
6904
6904
  }
6905
6905
 
6906
6906
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_record.mjs
6907
- function FromRecord3(context, type, value) {
6907
+ function FromRecord3(context2, type, value) {
6908
6908
  if (!guard_exports.IsObject(value))
6909
6909
  return value;
6910
6910
  const additionalProperties = GetAdditionalProperties(type);
6911
6911
  const [recordPattern, recordValue] = [new RegExp(RecordPattern(type)), RecordValue(type)];
6912
6912
  for (const key of guard_exports.Keys(value)) {
6913
6913
  if (recordPattern.test(key)) {
6914
- value[key] = FromType19(context, recordValue, value[key]);
6914
+ value[key] = FromType19(context2, recordValue, value[key]);
6915
6915
  continue;
6916
6916
  }
6917
6917
  const unknownCheck = (
6918
6918
  // 1. additionalProperties: true
6919
- guard_exports.IsBoolean(additionalProperties) && guard_exports.IsEqual(additionalProperties, true) || IsSchema2(additionalProperties) && Check2(context, additionalProperties, value[key])
6919
+ guard_exports.IsBoolean(additionalProperties) && guard_exports.IsEqual(additionalProperties, true) || IsSchema2(additionalProperties) && Check2(context2, additionalProperties, value[key])
6920
6920
  );
6921
6921
  if (unknownCheck) {
6922
- value[key] = FromType19(context, additionalProperties, value[key]);
6922
+ value[key] = FromType19(context2, additionalProperties, value[key]);
6923
6923
  continue;
6924
6924
  }
6925
6925
  delete value[key];
@@ -6928,17 +6928,17 @@ function FromRecord3(context, type, value) {
6928
6928
  }
6929
6929
 
6930
6930
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_ref.mjs
6931
- function FromRef5(context, type, value) {
6932
- return guard_exports.HasPropertyKey(context, type.$ref) ? FromType19(context, context[type.$ref], value) : value;
6931
+ function FromRef5(context2, type, value) {
6932
+ return guard_exports.HasPropertyKey(context2, type.$ref) ? FromType19(context2, context2[type.$ref], value) : value;
6933
6933
  }
6934
6934
 
6935
6935
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_tuple.mjs
6936
- function FromTuple5(context, schema, value) {
6936
+ function FromTuple5(context2, schema, value) {
6937
6937
  if (!guard_exports.IsArray(value))
6938
6938
  return value;
6939
6939
  const length = Math.min(value.length, schema.items.length);
6940
6940
  for (let index = 0; index < length; index++) {
6941
- value[index] = FromType19(context, schema.items[index], value[index]);
6941
+ value[index] = FromType19(context2, schema.items[index], value[index]);
6942
6942
  }
6943
6943
  return guard_exports.IsGreaterThan(value.length, length) ? value.slice(0, length) : value;
6944
6944
  }
@@ -6949,18 +6949,18 @@ function Clone2(value) {
6949
6949
  }
6950
6950
 
6951
6951
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_union.mjs
6952
- function FromUnion9(context, type, value) {
6952
+ function FromUnion9(context2, type, value) {
6953
6953
  for (const schema of type.anyOf) {
6954
- const clean = FromType19(context, schema, Clone2(value));
6955
- if (Check2(context, schema, clean))
6954
+ const clean = FromType19(context2, schema, Clone2(value));
6955
+ if (Check2(context2, schema, clean))
6956
6956
  return clean;
6957
6957
  }
6958
6958
  return value;
6959
6959
  }
6960
6960
 
6961
6961
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/from_type.mjs
6962
- function FromType19(context, type, value) {
6963
- return IsArray2(type) ? FromArray7(context, type, value) : IsCyclic(type) ? FromCyclic6(context, type, value) : IsIntersect(type) ? FromIntersect6(context, type, value) : IsObject2(type) ? FromObject11(context, type, value) : IsRecord(type) ? FromRecord3(context, type, value) : IsRef2(type) ? FromRef5(context, type, value) : IsTuple(type) ? FromTuple5(context, type, value) : IsUnion(type) ? FromUnion9(context, type, value) : value;
6962
+ function FromType19(context2, type, value) {
6963
+ return IsArray2(type) ? FromArray7(context2, type, value) : IsCyclic(type) ? FromCyclic6(context2, type, value) : IsIntersect(type) ? FromIntersect6(context2, type, value) : IsObject2(type) ? FromObject11(context2, type, value) : IsRecord(type) ? FromRecord3(context2, type, value) : IsRef2(type) ? FromRef5(context2, type, value) : IsTuple(type) ? FromTuple5(context2, type, value) : IsUnion(type) ? FromUnion9(context2, type, value) : value;
6964
6964
  }
6965
6965
 
6966
6966
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/shared/union_priority_sort.mjs
@@ -6995,12 +6995,12 @@ function UnionPrioritySort(type) {
6995
6995
 
6996
6996
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/clean/clean.mjs
6997
6997
  function Clean(...args) {
6998
- const [context, type, value] = arguments_exports.Match(args, {
6999
- 3: (context2, type2, value2) => [context2, type2, value2],
6998
+ const [context2, type, value] = arguments_exports.Match(args, {
6999
+ 3: (context3, type2, value2) => [context3, type2, value2],
7000
7000
  2: (type2, value2) => [{}, type2, value2]
7001
7001
  });
7002
7002
  const sorted = settings_exports.Get().unionPrioritySort ? UnionPrioritySort(type) : type;
7003
- return FromType19(context, sorted, value);
7003
+ return FromType19(context2, sorted, value);
7004
7004
  }
7005
7005
 
7006
7006
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/try/try.mjs
@@ -7143,9 +7143,9 @@ function TryUndefined(value) {
7143
7143
  }
7144
7144
 
7145
7145
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_array.mjs
7146
- function FromArray8(context, type, value) {
7146
+ function FromArray8(context2, type, value) {
7147
7147
  const result = try_exports.TryArray(value);
7148
- return result.value.map((value2) => FromType21(context, type.items, value2));
7148
+ return result.value.map((value2) => FromType21(context2, type.items, value2));
7149
7149
  }
7150
7150
 
7151
7151
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_bigint.mjs
@@ -7161,13 +7161,13 @@ function FromBoolean6(_context, _type, value) {
7161
7161
  }
7162
7162
 
7163
7163
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_cyclic.mjs
7164
- function FromCyclic7(context, type, value) {
7165
- return FromType21({ ...context, ...type.$defs }, Ref2(type.$ref), value);
7164
+ function FromCyclic7(context2, type, value) {
7165
+ return FromType21({ ...context2, ...type.$defs }, Ref2(type.$ref), value);
7166
7166
  }
7167
7167
 
7168
7168
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_enum.mjs
7169
- function FromEnum3(context, type, value) {
7170
- return FromType21(context, Evaluate(type), value);
7169
+ function FromEnum3(context2, type, value) {
7170
+ return FromType21(context2, Evaluate(type), value);
7171
7171
  }
7172
7172
 
7173
7173
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_integer.mjs
@@ -7177,10 +7177,10 @@ function FromInteger(_context, _type, value) {
7177
7177
  }
7178
7178
 
7179
7179
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_intersect.mjs
7180
- function FromIntersect7(context, type, value) {
7181
- const instantiated = Instantiate(context, type);
7180
+ function FromIntersect7(context2, type, value) {
7181
+ const instantiated = Instantiate(context2, type);
7182
7182
  const evaluated = Evaluate(instantiated);
7183
- return FromType21(context, evaluated, value);
7183
+ return FromType21(context2, evaluated, value);
7184
7184
  }
7185
7185
 
7186
7186
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_literal.mjs
@@ -7200,10 +7200,10 @@ function FromLiteralString(_context, type, value) {
7200
7200
  const result = try_exports.TryString(value);
7201
7201
  return try_exports.IsOk(result) && guard_exports.IsEqual(type.const, result.value) ? result.value : value;
7202
7202
  }
7203
- function FromLiteral6(context, type, value) {
7203
+ function FromLiteral6(context2, type, value) {
7204
7204
  if (guard_exports.IsEqual(type.const, value))
7205
7205
  return value;
7206
- return IsLiteralBigInt(type) ? FromLiteralBigInt(context, type, value) : IsLiteralBoolean(type) ? FromLiteralBoolean(context, type, value) : IsLiteralNumber(type) ? FromLiteralNumber(context, type, value) : IsLiteralString(type) ? FromLiteralString(context, type, value) : Unreachable();
7206
+ return IsLiteralBigInt(type) ? FromLiteralBigInt(context2, type, value) : IsLiteralBoolean(type) ? FromLiteralBoolean(context2, type, value) : IsLiteralNumber(type) ? FromLiteralNumber(context2, type, value) : IsLiteralString(type) ? FromLiteralString(context2, type, value) : Unreachable();
7207
7207
  }
7208
7208
 
7209
7209
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_null.mjs
@@ -7219,12 +7219,12 @@ function FromNumber5(_context, _type, value) {
7219
7219
  }
7220
7220
 
7221
7221
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_additional.mjs
7222
- function FromAdditionalProperties(context, entries, additionalProperties, value) {
7222
+ function FromAdditionalProperties(context2, entries, additionalProperties, value) {
7223
7223
  const keys = guard_exports.Keys(value);
7224
7224
  for (const [regexp, _] of entries) {
7225
7225
  for (const key of keys) {
7226
7226
  if (!regexp.test(key)) {
7227
- value[key] = FromType21(context, additionalProperties, value[key]);
7227
+ value[key] = FromType21(context2, additionalProperties, value[key]);
7228
7228
  }
7229
7229
  }
7230
7230
  }
@@ -7237,42 +7237,42 @@ function IsOptionalUndefined(property, key, value) {
7237
7237
  }
7238
7238
 
7239
7239
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_object.mjs
7240
- function FromProperties5(context, type, value) {
7240
+ function FromProperties5(context2, type, value) {
7241
7241
  const entries = guard_exports.EntriesRegExp(type.properties);
7242
7242
  const keys = guard_exports.Keys(value);
7243
7243
  for (const [regexp, property] of entries) {
7244
7244
  for (const key of keys) {
7245
7245
  if (!regexp.test(key) || IsOptionalUndefined(property, key, value))
7246
7246
  continue;
7247
- value[key] = FromType21(context, property, value[key]);
7247
+ value[key] = FromType21(context2, property, value[key]);
7248
7248
  }
7249
7249
  }
7250
- return guard_exports.HasPropertyKey(type, "additionalProperties") && guard_exports.IsObject(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
7250
+ return guard_exports.HasPropertyKey(type, "additionalProperties") && guard_exports.IsObject(type.additionalProperties) ? FromAdditionalProperties(context2, entries, type.additionalProperties, value) : value;
7251
7251
  }
7252
- function FromObject12(context, type, value) {
7253
- return guard_exports.IsObjectNotArray(value) ? FromProperties5(context, type, value) : value;
7252
+ function FromObject12(context2, type, value) {
7253
+ return guard_exports.IsObjectNotArray(value) ? FromProperties5(context2, type, value) : value;
7254
7254
  }
7255
7255
 
7256
7256
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_record.mjs
7257
- function FromPatternProperties(context, type, value) {
7257
+ function FromPatternProperties(context2, type, value) {
7258
7258
  const entries = guard_exports.EntriesRegExp(type.patternProperties);
7259
7259
  const keys = guard_exports.Keys(value);
7260
7260
  for (const [regexp, schema] of entries) {
7261
7261
  for (const key of keys) {
7262
7262
  if (regexp.test(key)) {
7263
- value[key] = FromType21(context, schema, value[key]);
7263
+ value[key] = FromType21(context2, schema, value[key]);
7264
7264
  }
7265
7265
  }
7266
7266
  }
7267
- return guard_exports.HasPropertyKey(type, "additionalProperties") && guard_exports.IsObject(type.additionalProperties) ? FromAdditionalProperties(context, entries, type.additionalProperties, value) : value;
7267
+ return guard_exports.HasPropertyKey(type, "additionalProperties") && guard_exports.IsObject(type.additionalProperties) ? FromAdditionalProperties(context2, entries, type.additionalProperties, value) : value;
7268
7268
  }
7269
- function FromRecord4(context, type, value) {
7270
- return guard_exports.IsObjectNotArray(value) ? FromPatternProperties(context, type, value) : value;
7269
+ function FromRecord4(context2, type, value) {
7270
+ return guard_exports.IsObjectNotArray(value) ? FromPatternProperties(context2, type, value) : value;
7271
7271
  }
7272
7272
 
7273
7273
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_ref.mjs
7274
- function FromRef6(context, type, value) {
7275
- return guard_exports.HasPropertyKey(context, type.$ref) ? FromType21(context, context[type.$ref], value) : value;
7274
+ function FromRef6(context2, type, value) {
7275
+ return guard_exports.HasPropertyKey(context2, type.$ref) ? FromType21(context2, context2[type.$ref], value) : value;
7276
7276
  }
7277
7277
 
7278
7278
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_string.mjs
@@ -7282,16 +7282,16 @@ function FromString7(_context, _type, value) {
7282
7282
  }
7283
7283
 
7284
7284
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_template_literal.mjs
7285
- function FromTemplateLiteral4(context, type, value) {
7286
- return FromType21(context, Evaluate(type), value);
7285
+ function FromTemplateLiteral4(context2, type, value) {
7286
+ return FromType21(context2, Evaluate(type), value);
7287
7287
  }
7288
7288
 
7289
7289
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_tuple.mjs
7290
- function FromTuple6(context, type, value) {
7290
+ function FromTuple6(context2, type, value) {
7291
7291
  if (!guard_exports.IsArray(value))
7292
7292
  return value;
7293
7293
  for (let index = 0; index < Math.min(type.items.length, value.length); index++) {
7294
- value[index] = FromType21(context, type.items[index], value[index]);
7294
+ value[index] = FromType21(context2, type.items[index], value[index]);
7295
7295
  }
7296
7296
  return value;
7297
7297
  }
@@ -7303,12 +7303,12 @@ function FromUndefined2(_context, _type, value) {
7303
7303
  }
7304
7304
 
7305
7305
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_union.mjs
7306
- function FromUnion10(context, type, value) {
7307
- const matched = type.anyOf.some((type2) => Check2(context, type2, value));
7306
+ function FromUnion10(context2, type, value) {
7307
+ const matched = type.anyOf.some((type2) => Check2(context2, type2, value));
7308
7308
  if (matched)
7309
7309
  return value;
7310
- const candidates = type.anyOf.map((type2) => FromType21(context, type2, Clone2(value)));
7311
- const selected = candidates.find((value2) => Check2(context, type, value2));
7310
+ const candidates = type.anyOf.map((type2) => FromType21(context2, type2, Clone2(value)));
7311
+ const selected = candidates.find((value2) => Check2(context2, type, value2));
7312
7312
  return guard_exports.IsUndefined(selected) ? value : selected;
7313
7313
  }
7314
7314
 
@@ -7319,32 +7319,32 @@ function FromVoid(_context, _type, value) {
7319
7319
  }
7320
7320
 
7321
7321
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/from_type.mjs
7322
- function FromType21(context, type, value) {
7323
- return IsArray2(type) ? FromArray8(context, type, value) : IsBigInt2(type) ? FromBigInt6(context, type, value) : IsBoolean3(type) ? FromBoolean6(context, type, value) : IsCyclic(type) ? FromCyclic7(context, type, value) : IsEnum2(type) ? FromEnum3(context, type, value) : IsInteger2(type) ? FromInteger(context, type, value) : IsIntersect(type) ? FromIntersect7(context, type, value) : IsLiteral(type) ? FromLiteral6(context, type, value) : IsNull2(type) ? FromNull2(context, type, value) : IsNumber3(type) ? FromNumber5(context, type, value) : IsObject2(type) ? FromObject12(context, type, value) : IsRecord(type) ? FromRecord4(context, type, value) : IsRef2(type) ? FromRef6(context, type, value) : IsString3(type) ? FromString7(context, type, value) : IsTemplateLiteral(type) ? FromTemplateLiteral4(context, type, value) : IsTuple(type) ? FromTuple6(context, type, value) : IsUndefined2(type) ? FromUndefined2(context, type, value) : IsUnion(type) ? FromUnion10(context, type, value) : IsVoid(type) ? FromVoid(context, type, value) : value;
7322
+ function FromType21(context2, type, value) {
7323
+ return IsArray2(type) ? FromArray8(context2, type, value) : IsBigInt2(type) ? FromBigInt6(context2, type, value) : IsBoolean3(type) ? FromBoolean6(context2, type, value) : IsCyclic(type) ? FromCyclic7(context2, type, value) : IsEnum2(type) ? FromEnum3(context2, type, value) : IsInteger2(type) ? FromInteger(context2, type, value) : IsIntersect(type) ? FromIntersect7(context2, type, value) : IsLiteral(type) ? FromLiteral6(context2, type, value) : IsNull2(type) ? FromNull2(context2, type, value) : IsNumber3(type) ? FromNumber5(context2, type, value) : IsObject2(type) ? FromObject12(context2, type, value) : IsRecord(type) ? FromRecord4(context2, type, value) : IsRef2(type) ? FromRef6(context2, type, value) : IsString3(type) ? FromString7(context2, type, value) : IsTemplateLiteral(type) ? FromTemplateLiteral4(context2, type, value) : IsTuple(type) ? FromTuple6(context2, type, value) : IsUndefined2(type) ? FromUndefined2(context2, type, value) : IsUnion(type) ? FromUnion10(context2, type, value) : IsVoid(type) ? FromVoid(context2, type, value) : value;
7324
7324
  }
7325
7325
 
7326
7326
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/convert/convert.mjs
7327
7327
  function Convert(...args) {
7328
- const [context, type, value] = arguments_exports.Match(args, {
7329
- 3: (context2, type2, value2) => [context2, type2, value2],
7328
+ const [context2, type, value] = arguments_exports.Match(args, {
7329
+ 3: (context3, type2, value2) => [context3, type2, value2],
7330
7330
  2: (type2, value2) => [{}, type2, value2]
7331
7331
  });
7332
- return FromType21(context, type, value);
7332
+ return FromType21(context2, type, value);
7333
7333
  }
7334
7334
 
7335
7335
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_array.mjs
7336
- function FromArray9(context, type, value) {
7336
+ function FromArray9(context2, type, value) {
7337
7337
  if (!guard_exports.IsArray(value))
7338
7338
  return value;
7339
7339
  for (let i = 0; i < value.length; i++) {
7340
- value[i] = FromType22(context, type.items, value[i]);
7340
+ value[i] = FromType22(context2, type.items, value[i]);
7341
7341
  }
7342
7342
  return value;
7343
7343
  }
7344
7344
 
7345
7345
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_cyclic.mjs
7346
- function FromCyclic8(context, type, value) {
7347
- return FromType22({ ...context, ...type.$defs }, Ref2(type.$ref), value);
7346
+ function FromCyclic8(context2, type, value) {
7347
+ return FromType22({ ...context2, ...type.$defs }, Ref2(type.$ref), value);
7348
7348
  }
7349
7349
 
7350
7350
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_default.mjs
@@ -7355,19 +7355,19 @@ function FromDefault(type, value) {
7355
7355
  }
7356
7356
 
7357
7357
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_intersect.mjs
7358
- function FromIntersect8(context, type, value) {
7359
- const instantiated = Instantiate(context, type);
7358
+ function FromIntersect8(context2, type, value) {
7359
+ const instantiated = Instantiate(context2, type);
7360
7360
  const evaluated = Evaluate(instantiated);
7361
- return FromType22(context, evaluated, value);
7361
+ return FromType22(context2, evaluated, value);
7362
7362
  }
7363
7363
 
7364
7364
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_object.mjs
7365
- function FromObject13(context, type, value) {
7365
+ function FromObject13(context2, type, value) {
7366
7366
  if (!guard_exports.IsObject(value))
7367
7367
  return value;
7368
7368
  const knownPropertyKeys = guard_exports.Keys(type.properties);
7369
7369
  for (const key of knownPropertyKeys) {
7370
- const propertyValue = FromType22(context, type.properties[key], value[key]);
7370
+ const propertyValue = FromType22(context2, type.properties[key], value[key]);
7371
7371
  const isUnassignableUndefined = guard_exports.IsUndefined(propertyValue) && (IsOptional(type.properties[key]) || !guard_exports.HasPropertyKey(type.properties[key], "default"));
7372
7372
  if (isUnassignableUndefined)
7373
7373
  continue;
@@ -7378,53 +7378,53 @@ function FromObject13(context, type, value) {
7378
7378
  for (const key of guard_exports.Keys(value)) {
7379
7379
  if (knownPropertyKeys.includes(key))
7380
7380
  continue;
7381
- value[key] = FromType22(context, type.additionalProperties, value[key]);
7381
+ value[key] = FromType22(context2, type.additionalProperties, value[key]);
7382
7382
  }
7383
7383
  return value;
7384
7384
  }
7385
7385
 
7386
7386
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_record.mjs
7387
- function FromRecord5(context, type, value) {
7387
+ function FromRecord5(context2, type, value) {
7388
7388
  if (!guard_exports.IsObject(value))
7389
7389
  return value;
7390
7390
  const [recordKey, recordValue] = [new RegExp(RecordPattern(type)), RecordValue(type)];
7391
7391
  for (const key of guard_exports.Keys(value)) {
7392
7392
  if (!(recordKey.test(key) && IsDefault(recordValue)))
7393
7393
  continue;
7394
- value[key] = FromType22(context, recordValue, value[key]);
7394
+ value[key] = FromType22(context2, recordValue, value[key]);
7395
7395
  }
7396
7396
  if (!IsAdditionalProperties(type))
7397
7397
  return value;
7398
7398
  for (const key of guard_exports.Keys(value)) {
7399
7399
  if (recordKey.test(key))
7400
7400
  continue;
7401
- value[key] = FromType22(context, type.additionalProperties, value[key]);
7401
+ value[key] = FromType22(context2, type.additionalProperties, value[key]);
7402
7402
  }
7403
7403
  return value;
7404
7404
  }
7405
7405
 
7406
7406
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_ref.mjs
7407
- function FromRef7(context, type, value) {
7408
- return guard_exports.HasPropertyKey(context, type.$ref) ? FromType22(context, context[type.$ref], value) : value;
7407
+ function FromRef7(context2, type, value) {
7408
+ return guard_exports.HasPropertyKey(context2, type.$ref) ? FromType22(context2, context2[type.$ref], value) : value;
7409
7409
  }
7410
7410
 
7411
7411
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_tuple.mjs
7412
- function FromTuple7(context, schema, value) {
7412
+ function FromTuple7(context2, schema, value) {
7413
7413
  if (!guard_exports.IsArray(value))
7414
7414
  return value;
7415
7415
  const [items, max] = [schema.items, Math.max(schema.items.length, value.length)];
7416
7416
  for (let i = 0; i < max; i++) {
7417
7417
  if (i < items.length)
7418
- value[i] = FromType22(context, items[i], value[i]);
7418
+ value[i] = FromType22(context2, items[i], value[i]);
7419
7419
  }
7420
7420
  return value;
7421
7421
  }
7422
7422
 
7423
7423
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_union.mjs
7424
- function FromUnion11(context, schema, value) {
7424
+ function FromUnion11(context2, schema, value) {
7425
7425
  for (const inner of schema.anyOf) {
7426
- const result = FromType22(context, inner, Clone2(value));
7427
- if (Check2(context, inner, result)) {
7426
+ const result = FromType22(context2, inner, Clone2(value));
7427
+ if (Check2(context2, inner, result)) {
7428
7428
  return result;
7429
7429
  }
7430
7430
  }
@@ -7432,28 +7432,28 @@ function FromUnion11(context, schema, value) {
7432
7432
  }
7433
7433
 
7434
7434
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/from_type.mjs
7435
- function FromType22(context, type, value) {
7435
+ function FromType22(context2, type, value) {
7436
7436
  const defaulted = IsDefault(type) ? FromDefault(type, value) : value;
7437
- return IsArray2(type) ? FromArray9(context, type, defaulted) : IsCyclic(type) ? FromCyclic8(context, type, defaulted) : IsIntersect(type) ? FromIntersect8(context, type, defaulted) : IsObject2(type) ? FromObject13(context, type, defaulted) : IsRecord(type) ? FromRecord5(context, type, defaulted) : IsRef2(type) ? FromRef7(context, type, defaulted) : IsTuple(type) ? FromTuple7(context, type, defaulted) : IsUnion(type) ? FromUnion11(context, type, defaulted) : defaulted;
7437
+ return IsArray2(type) ? FromArray9(context2, type, defaulted) : IsCyclic(type) ? FromCyclic8(context2, type, defaulted) : IsIntersect(type) ? FromIntersect8(context2, type, defaulted) : IsObject2(type) ? FromObject13(context2, type, defaulted) : IsRecord(type) ? FromRecord5(context2, type, defaulted) : IsRef2(type) ? FromRef7(context2, type, defaulted) : IsTuple(type) ? FromTuple7(context2, type, defaulted) : IsUnion(type) ? FromUnion11(context2, type, defaulted) : defaulted;
7438
7438
  }
7439
7439
 
7440
7440
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/default/default.mjs
7441
7441
  function Default(...args) {
7442
- const [context, type, value] = arguments_exports.Match(args, {
7443
- 3: (context2, type2, value2) => [context2, type2, value2],
7442
+ const [context2, type, value] = arguments_exports.Match(args, {
7443
+ 3: (context3, type2, value2) => [context3, type2, value2],
7444
7444
  2: (type2, value2) => [{}, type2, value2]
7445
7445
  });
7446
- return FromType22(context, type, value);
7446
+ return FromType22(context2, type, value);
7447
7447
  }
7448
7448
 
7449
7449
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/pipeline/pipeline.mjs
7450
7450
  function Pipeline(pipeline) {
7451
7451
  return (...args) => {
7452
- const [context, type, value] = arguments_exports.Match(args, {
7453
- 3: (context2, type2, value2) => [context2, type2, value2],
7452
+ const [context2, type, value] = arguments_exports.Match(args, {
7453
+ 3: (context3, type2, value2) => [context3, type2, value2],
7454
7454
  2: (type2, value2) => [{}, type2, value2]
7455
7455
  });
7456
- return pipeline.reduce((result, func) => func(context, type, result), value);
7456
+ return pipeline.reduce((result, func) => func(context2, type, result), value);
7457
7457
  };
7458
7458
  }
7459
7459
 
@@ -7464,38 +7464,38 @@ function Decode3(_context, type, value) {
7464
7464
  function Encode3(_context, type, value) {
7465
7465
  return type["~codec"].encode(value);
7466
7466
  }
7467
- function Callback(direction, context, type, value) {
7467
+ function Callback(direction, context2, type, value) {
7468
7468
  if (!IsCodec(type))
7469
7469
  return value;
7470
- return guard_exports.IsEqual(direction, "Decode") ? Decode3(context, type, value) : Encode3(context, type, value);
7470
+ return guard_exports.IsEqual(direction, "Decode") ? Decode3(context2, type, value) : Encode3(context2, type, value);
7471
7471
  }
7472
7472
 
7473
7473
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_array.mjs
7474
- function Decode4(direction, context, type, value) {
7474
+ function Decode4(direction, context2, type, value) {
7475
7475
  if (!guard_exports.IsArray(value))
7476
7476
  return value;
7477
7477
  for (let i = 0; i < value.length; i++) {
7478
- value[i] = FromType23(direction, context, type.items, value[i]);
7478
+ value[i] = FromType23(direction, context2, type.items, value[i]);
7479
7479
  }
7480
- return Callback(direction, context, type, value);
7480
+ return Callback(direction, context2, type, value);
7481
7481
  }
7482
- function Encode4(direction, context, type, value) {
7483
- const exterior = Callback(direction, context, type, value);
7482
+ function Encode4(direction, context2, type, value) {
7483
+ const exterior = Callback(direction, context2, type, value);
7484
7484
  if (!guard_exports.IsArray(exterior))
7485
7485
  return exterior;
7486
7486
  for (let i = 0; i < exterior.length; i++) {
7487
- exterior[i] = FromType23(direction, context, type.items, exterior[i]);
7487
+ exterior[i] = FromType23(direction, context2, type.items, exterior[i]);
7488
7488
  }
7489
7489
  return exterior;
7490
7490
  }
7491
- function FromArray10(direction, context, type, value) {
7492
- return guard_exports.IsEqual(direction, "Decode") ? Decode4(direction, context, type, value) : Encode4(direction, context, type, value);
7491
+ function FromArray10(direction, context2, type, value) {
7492
+ return guard_exports.IsEqual(direction, "Decode") ? Decode4(direction, context2, type, value) : Encode4(direction, context2, type, value);
7493
7493
  }
7494
7494
 
7495
7495
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_cyclic.mjs
7496
- function FromCyclic9(direction, context, type, value) {
7497
- value = FromType23(direction, { ...context, ...type.$defs }, Ref2(type.$ref), value);
7498
- return Callback(direction, context, type, value);
7496
+ function FromCyclic9(direction, context2, type, value) {
7497
+ value = FromType23(direction, { ...context2, ...type.$defs }, Ref2(type.$ref), value);
7498
+ return Callback(direction, context2, type, value);
7499
7499
  }
7500
7500
 
7501
7501
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_intersect.mjs
@@ -7508,139 +7508,139 @@ function NonMatchingInterior(value, interiors) {
7508
7508
  return interior;
7509
7509
  return value;
7510
7510
  }
7511
- function Decode5(direction, context, type, value) {
7511
+ function Decode5(direction, context2, type, value) {
7512
7512
  if (guard_exports.IsEqual(type.allOf.length, 0))
7513
- return Callback(direction, context, type, value);
7514
- const interiors = type.allOf.map((schema) => FromType23(direction, context, schema, Clean(schema, Clone2(value))));
7513
+ return Callback(direction, context2, type, value);
7514
+ const interiors = type.allOf.map((schema) => FromType23(direction, context2, schema, Clean(schema, Clone2(value))));
7515
7515
  const structural = interiors.every((result) => guard_exports.IsObject(result));
7516
7516
  const exterior = structural ? MergeInteriors(interiors) : NonMatchingInterior(value, interiors);
7517
- return Callback(direction, context, type, exterior);
7517
+ return Callback(direction, context2, type, exterior);
7518
7518
  }
7519
- function Encode5(direction, context, type, value) {
7519
+ function Encode5(direction, context2, type, value) {
7520
7520
  if (guard_exports.IsEqual(type.allOf.length, 0))
7521
- return Callback(direction, context, type, value);
7522
- const exterior = Callback(direction, context, type, value);
7523
- const interiors = type.allOf.map((schema) => FromType23(direction, context, schema, Clean(schema, Clone2(exterior))));
7521
+ return Callback(direction, context2, type, value);
7522
+ const exterior = Callback(direction, context2, type, value);
7523
+ const interiors = type.allOf.map((schema) => FromType23(direction, context2, schema, Clean(schema, Clone2(exterior))));
7524
7524
  const structural = interiors.every((result) => guard_exports.IsObject(result));
7525
7525
  if (structural)
7526
7526
  return MergeInteriors(interiors);
7527
7527
  return NonMatchingInterior(exterior, interiors);
7528
7528
  }
7529
- function FromIntersect9(direction, context, type, value) {
7530
- return guard_exports.IsEqual(direction, "Decode") ? Decode5(direction, context, type, value) : Encode5(direction, context, type, value);
7529
+ function FromIntersect9(direction, context2, type, value) {
7530
+ return guard_exports.IsEqual(direction, "Decode") ? Decode5(direction, context2, type, value) : Encode5(direction, context2, type, value);
7531
7531
  }
7532
7532
 
7533
7533
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_object.mjs
7534
- function Decode6(direction, context, type, value) {
7534
+ function Decode6(direction, context2, type, value) {
7535
7535
  if (!guard_exports.IsObjectNotArray(value))
7536
7536
  return value;
7537
7537
  for (const key of guard_exports.Keys(type.properties)) {
7538
7538
  if (!guard_exports.HasPropertyKey(value, key) || IsOptionalUndefined(type.properties[key], key, value))
7539
7539
  continue;
7540
- value[key] = FromType23(direction, context, type.properties[key], value[key]);
7540
+ value[key] = FromType23(direction, context2, type.properties[key], value[key]);
7541
7541
  }
7542
- return Callback(direction, context, type, value);
7542
+ return Callback(direction, context2, type, value);
7543
7543
  }
7544
- function Encode6(direction, context, type, value) {
7545
- const exterior = Callback(direction, context, type, value);
7544
+ function Encode6(direction, context2, type, value) {
7545
+ const exterior = Callback(direction, context2, type, value);
7546
7546
  if (!guard_exports.IsObjectNotArray(exterior))
7547
7547
  return exterior;
7548
7548
  for (const key of guard_exports.Keys(type.properties)) {
7549
7549
  if (!guard_exports.HasPropertyKey(exterior, key) || IsOptionalUndefined(type.properties[key], key, exterior))
7550
7550
  continue;
7551
- exterior[key] = FromType23(direction, context, type.properties[key], exterior[key]);
7551
+ exterior[key] = FromType23(direction, context2, type.properties[key], exterior[key]);
7552
7552
  }
7553
7553
  return exterior;
7554
7554
  }
7555
- function FromObject14(direction, context, type, value) {
7556
- return guard_exports.IsEqual(direction, "Decode") ? Decode6(direction, context, type, value) : Encode6(direction, context, type, value);
7555
+ function FromObject14(direction, context2, type, value) {
7556
+ return guard_exports.IsEqual(direction, "Decode") ? Decode6(direction, context2, type, value) : Encode6(direction, context2, type, value);
7557
7557
  }
7558
7558
 
7559
7559
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_record.mjs
7560
- function Decode7(direction, context, type, value) {
7560
+ function Decode7(direction, context2, type, value) {
7561
7561
  if (!guard_exports.IsObjectNotArray(value))
7562
7562
  return value;
7563
7563
  const regexp = new RegExp(RecordPattern(type));
7564
7564
  for (const key of guard_exports.Keys(value)) {
7565
7565
  if (!regexp.test(key))
7566
7566
  continue;
7567
- value[key] = FromType23(direction, context, RecordValue(type), value[key]);
7567
+ value[key] = FromType23(direction, context2, RecordValue(type), value[key]);
7568
7568
  }
7569
- return Callback(direction, context, type, value);
7569
+ return Callback(direction, context2, type, value);
7570
7570
  }
7571
- function Encode7(direction, context, type, value) {
7572
- const exterior = Callback(direction, context, type, value);
7571
+ function Encode7(direction, context2, type, value) {
7572
+ const exterior = Callback(direction, context2, type, value);
7573
7573
  if (!guard_exports.IsObjectNotArray(exterior))
7574
7574
  return exterior;
7575
7575
  const regexp = new RegExp(RecordPattern(type));
7576
7576
  for (const key of guard_exports.Keys(exterior)) {
7577
7577
  if (!regexp.test(key))
7578
7578
  continue;
7579
- exterior[key] = FromType23(direction, context, RecordValue(type), exterior[key]);
7579
+ exterior[key] = FromType23(direction, context2, RecordValue(type), exterior[key]);
7580
7580
  }
7581
7581
  return exterior;
7582
7582
  }
7583
- function FromRecord6(direction, context, type, value) {
7584
- return guard_exports.IsEqual(direction, "Decode") ? Decode7(direction, context, type, value) : Encode7(direction, context, type, value);
7583
+ function FromRecord6(direction, context2, type, value) {
7584
+ return guard_exports.IsEqual(direction, "Decode") ? Decode7(direction, context2, type, value) : Encode7(direction, context2, type, value);
7585
7585
  }
7586
7586
 
7587
7587
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_ref.mjs
7588
- function ResolveRef2(direction, context, type, value) {
7589
- return guard_exports.HasPropertyKey(context, type.$ref) ? FromType23(direction, context, context[type.$ref], value) : value;
7588
+ function ResolveRef2(direction, context2, type, value) {
7589
+ return guard_exports.HasPropertyKey(context2, type.$ref) ? FromType23(direction, context2, context2[type.$ref], value) : value;
7590
7590
  }
7591
- function FromRef8(direction, context, type, value) {
7592
- return guard_exports.IsEqual(direction, "Decode") ? Callback(direction, context, type, ResolveRef2(direction, context, type, value)) : ResolveRef2(direction, context, type, Callback(direction, context, type, value));
7591
+ function FromRef8(direction, context2, type, value) {
7592
+ return guard_exports.IsEqual(direction, "Decode") ? Callback(direction, context2, type, ResolveRef2(direction, context2, type, value)) : ResolveRef2(direction, context2, type, Callback(direction, context2, type, value));
7593
7593
  }
7594
7594
 
7595
7595
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_tuple.mjs
7596
- function Decode8(direction, context, type, value) {
7596
+ function Decode8(direction, context2, type, value) {
7597
7597
  if (!guard_exports.IsArray(value))
7598
7598
  return value;
7599
7599
  for (let i = 0; i < Math.min(type.items.length, value.length); i++) {
7600
- value[i] = FromType23(direction, context, type.items[i], value[i]);
7600
+ value[i] = FromType23(direction, context2, type.items[i], value[i]);
7601
7601
  }
7602
- return Callback(direction, context, type, value);
7602
+ return Callback(direction, context2, type, value);
7603
7603
  }
7604
- function Encode8(direction, context, type, value) {
7605
- const exterior = Callback(direction, context, type, value);
7604
+ function Encode8(direction, context2, type, value) {
7605
+ const exterior = Callback(direction, context2, type, value);
7606
7606
  if (!guard_exports.IsArray(exterior))
7607
7607
  return value;
7608
7608
  for (let i = 0; i < Math.min(type.items.length, exterior.length); i++) {
7609
- exterior[i] = FromType23(direction, context, type.items[i], exterior[i]);
7609
+ exterior[i] = FromType23(direction, context2, type.items[i], exterior[i]);
7610
7610
  }
7611
7611
  return exterior;
7612
7612
  }
7613
- function FromTuple8(direction, context, type, value) {
7614
- return guard_exports.IsEqual(direction, "Decode") ? Decode8(direction, context, type, value) : Encode8(direction, context, type, value);
7613
+ function FromTuple8(direction, context2, type, value) {
7614
+ return guard_exports.IsEqual(direction, "Decode") ? Decode8(direction, context2, type, value) : Encode8(direction, context2, type, value);
7615
7615
  }
7616
7616
 
7617
7617
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_union.mjs
7618
- function Decode9(direction, context, type, value) {
7618
+ function Decode9(direction, context2, type, value) {
7619
7619
  for (const schema of type.anyOf) {
7620
- if (!Check2(context, schema, value))
7620
+ if (!Check2(context2, schema, value))
7621
7621
  continue;
7622
- const variant = FromType23(direction, context, schema, value);
7623
- return Callback(direction, context, type, variant);
7622
+ const variant = FromType23(direction, context2, schema, value);
7623
+ return Callback(direction, context2, type, variant);
7624
7624
  }
7625
7625
  return value;
7626
7626
  }
7627
- function Encode9(direction, context, type, value) {
7628
- const exterior = Callback(direction, context, type, value);
7627
+ function Encode9(direction, context2, type, value) {
7628
+ const exterior = Callback(direction, context2, type, value);
7629
7629
  for (const schema of type.anyOf) {
7630
- const variant = FromType23(direction, context, schema, Clone2(exterior));
7631
- if (!Check2(context, schema, variant))
7630
+ const variant = FromType23(direction, context2, schema, Clone2(exterior));
7631
+ if (!Check2(context2, schema, variant))
7632
7632
  continue;
7633
7633
  return variant;
7634
7634
  }
7635
7635
  return exterior;
7636
7636
  }
7637
- function FromUnion12(direction, context, type, value) {
7638
- return guard_exports.IsEqual(direction, "Decode") ? Decode9(direction, context, type, value) : Encode9(direction, context, type, value);
7637
+ function FromUnion12(direction, context2, type, value) {
7638
+ return guard_exports.IsEqual(direction, "Decode") ? Decode9(direction, context2, type, value) : Encode9(direction, context2, type, value);
7639
7639
  }
7640
7640
 
7641
7641
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/from_type.mjs
7642
- function FromType23(direction, context, type, value) {
7643
- return IsArray2(type) ? FromArray10(direction, context, type, value) : IsCyclic(type) ? FromCyclic9(direction, context, type, value) : IsIntersect(type) ? FromIntersect9(direction, context, type, value) : IsObject2(type) ? FromObject14(direction, context, type, value) : IsRecord(type) ? FromRecord6(direction, context, type, value) : IsRef2(type) ? FromRef8(direction, context, type, value) : IsTuple(type) ? FromTuple8(direction, context, type, value) : IsUnion(type) ? FromUnion12(direction, context, type, value) : Callback(direction, context, type, value);
7642
+ function FromType23(direction, context2, type, value) {
7643
+ return IsArray2(type) ? FromArray10(direction, context2, type, value) : IsCyclic(type) ? FromCyclic9(direction, context2, type, value) : IsIntersect(type) ? FromIntersect9(direction, context2, type, value) : IsObject2(type) ? FromObject14(direction, context2, type, value) : IsRecord(type) ? FromRecord6(direction, context2, type, value) : IsRef2(type) ? FromRef8(direction, context2, type, value) : IsTuple(type) ? FromTuple8(direction, context2, type, value) : IsUnion(type) ? FromUnion12(direction, context2, type, value) : Callback(direction, context2, type, value);
7644
7644
  }
7645
7645
 
7646
7646
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/decode.mjs
@@ -7649,22 +7649,22 @@ var DecodeError = class extends AssertError {
7649
7649
  super("Decode", value, errors);
7650
7650
  }
7651
7651
  };
7652
- function Assert(context, type, value) {
7653
- if (!Check2(context, type, value))
7654
- throw new DecodeError(value, Errors2(context, type, value));
7652
+ function Assert(context2, type, value) {
7653
+ if (!Check2(context2, type, value))
7654
+ throw new DecodeError(value, Errors2(context2, type, value));
7655
7655
  return value;
7656
7656
  }
7657
- function DecodeUnsafe(context, type, value) {
7657
+ function DecodeUnsafe(context2, type, value) {
7658
7658
  const sorted = settings_exports.Get().unionPrioritySort ? UnionPrioritySort(type) : type;
7659
- return FromType23("Decode", context, sorted, value);
7659
+ return FromType23("Decode", context2, sorted, value);
7660
7660
  }
7661
7661
  var Decoder = Pipeline([
7662
7662
  (_context, _type, value) => Clone2(value),
7663
- (context, type, value) => Default(context, type, value),
7664
- (context, type, value) => Convert(context, type, value),
7665
- (context, type, value) => Clean(context, type, value),
7666
- (context, type, value) => Assert(context, type, value),
7667
- (context, type, value) => DecodeUnsafe(context, type, value)
7663
+ (context2, type, value) => Default(context2, type, value),
7664
+ (context2, type, value) => Convert(context2, type, value),
7665
+ (context2, type, value) => Clean(context2, type, value),
7666
+ (context2, type, value) => Assert(context2, type, value),
7667
+ (context2, type, value) => DecodeUnsafe(context2, type, value)
7668
7668
  ]);
7669
7669
 
7670
7670
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/codec/encode.mjs
@@ -7673,22 +7673,22 @@ var EncodeError = class extends AssertError {
7673
7673
  super("Encode", value, errors);
7674
7674
  }
7675
7675
  };
7676
- function Assert2(context, type, value) {
7677
- if (!Check2(context, type, value))
7678
- throw new EncodeError(value, Errors2(context, type, value));
7676
+ function Assert2(context2, type, value) {
7677
+ if (!Check2(context2, type, value))
7678
+ throw new EncodeError(value, Errors2(context2, type, value));
7679
7679
  return value;
7680
7680
  }
7681
- function EncodeUnsafe(context, type, value) {
7681
+ function EncodeUnsafe(context2, type, value) {
7682
7682
  const sorted = settings_exports.Get().unionPrioritySort ? UnionPrioritySort(type) : type;
7683
- return FromType23("Encode", context, sorted, value);
7683
+ return FromType23("Encode", context2, sorted, value);
7684
7684
  }
7685
7685
  var Encoder = Pipeline([
7686
7686
  (_context, _type, value) => Clone2(value),
7687
- (context, type, value) => EncodeUnsafe(context, type, value),
7688
- (context, type, value) => Default(context, type, value),
7689
- (context, type, value) => Convert(context, type, value),
7690
- (context, type, value) => Clean(context, type, value),
7691
- (context, type, value) => Assert2(context, type, value)
7687
+ (context2, type, value) => EncodeUnsafe(context2, type, value),
7688
+ (context2, type, value) => Default(context2, type, value),
7689
+ (context2, type, value) => Convert(context2, type, value),
7690
+ (context2, type, value) => Clean(context2, type, value),
7691
+ (context2, type, value) => Assert2(context2, type, value)
7692
7692
  ]);
7693
7693
 
7694
7694
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/parse/parse.mjs
@@ -7697,17 +7697,17 @@ var ParseError = class extends AssertError {
7697
7697
  super("Parse", value, errors);
7698
7698
  }
7699
7699
  };
7700
- function Assert3(context, type, value) {
7701
- if (!Check2(context, type, value))
7702
- throw new ParseError(value, Errors2(context, type, value));
7700
+ function Assert3(context2, type, value) {
7701
+ if (!Check2(context2, type, value))
7702
+ throw new ParseError(value, Errors2(context2, type, value));
7703
7703
  return value;
7704
7704
  }
7705
7705
  var Parser = Pipeline([
7706
7706
  (_context, _type, value) => Clone2(value),
7707
- (context, type, value) => Default(context, type, value),
7708
- (context, type, value) => Convert(context, type, value),
7709
- (context, type, value) => Clean(context, type, value),
7710
- (context, type, value) => Assert3(context, type, value)
7707
+ (context2, type, value) => Default(context2, type, value),
7708
+ (context2, type, value) => Convert(context2, type, value),
7709
+ (context2, type, value) => Clean(context2, type, value),
7710
+ (context2, type, value) => Assert3(context2, type, value)
7711
7711
  ]);
7712
7712
 
7713
7713
  // ../../../Users/astrosheep/pi-extensions/pi-context/node_modules/typebox/build/value/delta/edit.mjs
@@ -8169,9 +8169,9 @@ function normalizeRemote(value) {
8169
8169
  else if (/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.test(text)) {
8170
8170
  try {
8171
8171
  const url = new URL(text);
8172
- const host = url.hostname.toLowerCase();
8172
+ const host2 = url.hostname.toLowerCase();
8173
8173
  const port = url.port.length > 0 ? `:${url.port}` : "";
8174
- text = `${host}${port}${url.pathname}`;
8174
+ text = `${host2}${port}${url.pathname}`;
8175
8175
  } catch {
8176
8176
  text = text.replace(/^[A-Za-z][A-Za-z0-9+.-]*:\/\//, "").replace(/^[^/@]+@/, "");
8177
8177
  }
@@ -8303,11 +8303,11 @@ function resolveProjectNamespace(cwd, home) {
8303
8303
  function claimProjectNamespace(cwd, home) {
8304
8304
  const root = canonicalRoot(cwd);
8305
8305
  const remote = originRemote(root);
8306
- const id = remote ?? root;
8306
+ const id2 = remote ?? root;
8307
8307
  const markerRoot = projectRoot(home);
8308
8308
  mkdirSync(markerRoot, { recursive: true });
8309
8309
  const namespaces = projectNamespaces(home);
8310
- let found = namespaces.find((candidate) => candidate.id === id);
8310
+ let found = namespaces.find((candidate) => candidate.id === id2);
8311
8311
  if (!found && remote) {
8312
8312
  found = namespaces.find((candidate) => candidate.id === root);
8313
8313
  if (found) found = updateMarker(found, { id: remote, path: root });
@@ -8327,11 +8327,11 @@ function claimProjectNamespace(cwd, home) {
8327
8327
  } catch (error) {
8328
8328
  if (errno(error) !== "EEXIST") throw error;
8329
8329
  let winner = awaitClaim(join2(dir, ".project"), () => readMarker(dir));
8330
- if (winner.id !== id && !(remote && winner.id === root)) continue;
8331
- if (winner.id !== id || winner.path !== root) winner = updateMarker(winner, { id, path: root });
8330
+ if (winner.id !== id2 && !(remote && winner.id === root)) continue;
8331
+ if (winner.id !== id2 || winner.path !== root) winner = updateMarker(winner, { id: id2, path: root });
8332
8332
  return winner;
8333
8333
  }
8334
- return updateMarker({ name, dir, id, path: root }, { id, path: root });
8334
+ return updateMarker({ name, dir, id: id2, path: root }, { id: id2, path: root });
8335
8335
  }
8336
8336
  }
8337
8337
  function gitRoot(cwd) {
@@ -8441,7 +8441,7 @@ async function namespacesForPattern(pattern, identity2, status) {
8441
8441
  { scope: "agent", dir: "agents", current: identity2.agent },
8442
8442
  { scope: "model", dir: "models", current: identity2.model }
8443
8443
  ];
8444
- async function enumerate(family, relative) {
8444
+ async function enumerate(family, relative2) {
8445
8445
  let names;
8446
8446
  try {
8447
8447
  names = await namespaceSlugs(family.dir, identity2.home);
@@ -8452,7 +8452,7 @@ async function namespacesForPattern(pattern, identity2, status) {
8452
8452
  }
8453
8453
  return [.../* @__PURE__ */ new Set([family.current, ...names])].map((who) => ({
8454
8454
  scope: family.scope,
8455
- who: relative && who === family.current ? void 0 : who
8455
+ who: relative2 && who === family.current ? void 0 : who
8456
8456
  }));
8457
8457
  }
8458
8458
  if (pattern.startsWith("@")) {
@@ -8984,8 +8984,8 @@ function nestedCallSummary(event) {
8984
8984
  return nested === void 0 ? {} : { nested_calls: { call_count: nested.calls.length, complete: nested.complete } };
8985
8985
  }
8986
8986
  var HistoryPageItemSchema = typebox_exports.Object({
8987
+ session: typebox_exports.Optional(typebox_exports.String()),
8987
8988
  seq: typebox_exports.Integer({ minimum: 1 }),
8988
- window_id: typebox_exports.String(),
8989
8989
  role: HistoryRoleSchema,
8990
8990
  created_at: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
8991
8991
  ...ToolSummarySchema.properties,
@@ -8994,6 +8994,7 @@ var HistoryPageItemSchema = typebox_exports.Object({
8994
8994
  offset_chars: typebox_exports.Optional(typebox_exports.Integer({ minimum: 0, description: "Where the preview starts." }))
8995
8995
  }, { additionalProperties: false });
8996
8996
  var HistoryFoldedRowSchema = typebox_exports.Object({
8997
+ session: typebox_exports.Optional(typebox_exports.String()),
8997
8998
  folded: typebox_exports.Literal(true),
8998
8999
  first_seq: typebox_exports.Integer({ minimum: 1 }),
8999
9000
  last_seq: typebox_exports.Integer({ minimum: 1 }),
@@ -9010,7 +9011,6 @@ function visibleItem(event, maxChars, matchOffset) {
9010
9011
  const truncated = start > 0 || start + limit < chars.length;
9011
9012
  return {
9012
9013
  seq: event.seq,
9013
- window_id: event.windowId,
9014
9014
  role: event.role,
9015
9015
  created_at: event.createdAt ?? null,
9016
9016
  ...toolSummary(event),
@@ -9022,13 +9022,7 @@ function visibleItem(event, maxChars, matchOffset) {
9022
9022
  function allItems(projection) {
9023
9023
  return projection.windows.flatMap((current) => current.items);
9024
9024
  }
9025
- function unknownWindowId(projection, params) {
9026
- if (typeof params.window_id !== "string") return void 0;
9027
- const known = projection.windows.map((current) => current.windowId);
9028
- return known.includes(params.window_id) ? void 0 : { message: `No window "${params.window_id}" in this session`, known };
9029
- }
9030
9025
  function inSelection(event, params) {
9031
- if (typeof params.window_id === "string" && params.window_id !== event.windowId) return false;
9032
9026
  if (params.after_seq !== void 0 && event.seq <= params.after_seq) return false;
9033
9027
  if (params.before_seq !== void 0 && event.seq >= params.before_seq) return false;
9034
9028
  if (params.sinceMs === void 0 && params.untilMs === void 0) return true;
@@ -9067,9 +9061,9 @@ function notesToolContext(identity2, cwd) {
9067
9061
  if (typeof cwd !== "string" || cwd.length === 0) throw new TypeError("notes tool cwd must be a non-empty string");
9068
9062
  return Object.freeze({ identity: snapshotNotesIdentity(identity2), cwd: resolve4(cwd) });
9069
9063
  }
9070
- function notesIdentityForCall(context, cwd) {
9071
- if (cwd === void 0) return context.identity;
9072
- const resolved = resolve4(context.cwd, cwd);
9064
+ function notesIdentityForCall(context2, cwd) {
9065
+ if (cwd === void 0) return context2.identity;
9066
+ const resolved = resolve4(context2.cwd, cwd);
9073
9067
  let directory = false;
9074
9068
  try {
9075
9069
  directory = statSync2(resolved).isDirectory();
@@ -9077,8 +9071,8 @@ function notesIdentityForCall(context, cwd) {
9077
9071
  }
9078
9072
  if (!directory) throw new NoteError("invalid_cwd", `cwd is not an existing directory: ${JSON.stringify(cwd)} (resolved to ${resolved}).`);
9079
9073
  return snapshotNotesIdentity({
9080
- ...context.identity,
9081
- projectKey: projectKey(resolved, context.identity.home)
9074
+ ...context2.identity,
9075
+ projectKey: projectKey(resolved, context2.identity.home)
9082
9076
  });
9083
9077
  }
9084
9078
 
@@ -9245,9 +9239,9 @@ var notesWrite = {
9245
9239
  parameters: notesWriteParameters,
9246
9240
  outputSchema: resultSchema(NotesWriteDataSchema),
9247
9241
  executionMode: "sequential",
9248
- async execute(params, context) {
9242
+ async execute(params, context2) {
9249
9243
  try {
9250
- const identity2 = notesIdentityForCall(context, params.cwd);
9244
+ const identity2 = notesIdentityForCall(context2, params.cwd);
9251
9245
  const { outcome } = await createNotesStore(identity2).write(params.address, params.content, { origin: params.origin });
9252
9246
  return success({ ...noteIdentity(identity2, params.address), outcome });
9253
9247
  } catch (error) {
@@ -9292,9 +9286,9 @@ var notesUpdate = {
9292
9286
  parameters: notesUpdateParameters,
9293
9287
  outputSchema: resultSchema(NotesUpdateDataSchema),
9294
9288
  executionMode: "sequential",
9295
- async execute(params, context, renderDiff = (change) => change.kind === "none" ? "" : `note ${change.kind}`) {
9289
+ async execute(params, context2, renderDiff = (change) => change.kind === "none" ? "" : `note ${change.kind}`) {
9296
9290
  try {
9297
- const identity2 = notesIdentityForCall(context, params.cwd);
9291
+ const identity2 = notesIdentityForCall(context2, params.cwd);
9298
9292
  const store = createNotesStore(identity2);
9299
9293
  const renameTo = params.rename_to === "" ? void 0 : params.rename_to;
9300
9294
  const { change, moved } = await store.update(params.address, params.edits, { origin: params.origin, crumpled: params.crumpled, replaceAll: params.replace_all, renameTo });
@@ -9321,9 +9315,9 @@ var notesRead = {
9321
9315
  description: `Read a note. ${ADDRESS_DESCRIPTION}`,
9322
9316
  parameters: notesReadParameters,
9323
9317
  outputSchema: resultSchema(NotesReadDataSchema),
9324
- async execute(params, context) {
9318
+ async execute(params, context2) {
9325
9319
  try {
9326
- const identity2 = notesIdentityForCall(context, params.cwd);
9320
+ const identity2 = notesIdentityForCall(context2, params.cwd);
9327
9321
  const note = await createNotesStore(identity2).read(params.address);
9328
9322
  const resolved = noteIdentity(identity2, params.address);
9329
9323
  if (!note) return failure("not_found", `No note at ${resolved.address}.`);
@@ -9353,9 +9347,9 @@ var notesList = {
9353
9347
  description: `List notes, newest first. Not pageable; \`more\` counts the rest. ${QUERY_NAMESPACES_DESCRIPTION} ${ADDRESS_DESCRIPTION}`,
9354
9348
  parameters: notesListParameters,
9355
9349
  outputSchema: resultSchema(NotesListDataSchema),
9356
- async execute(params, context) {
9350
+ async execute(params, context2) {
9357
9351
  try {
9358
- const identity2 = notesIdentityForCall(context, params.cwd);
9352
+ const identity2 = notesIdentityForCall(context2, params.cwd);
9359
9353
  const { rows, status } = await createNotesStore(identity2).listWithStatus({ glob: params.glob ?? void 0, crumpled: params.crumpled });
9360
9354
  return snapshot(rows.map((row) => listedFile(row, identity2)), params.limit, status, renderListData);
9361
9355
  } catch (error) {
@@ -9396,9 +9390,9 @@ var notesSearch = {
9396
9390
  description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${QUERY_NAMESPACES_DESCRIPTION} ${ADDRESS_DESCRIPTION}`,
9397
9391
  parameters: notesSearchParameters,
9398
9392
  outputSchema: resultSchema(NotesSearchDataSchema),
9399
- async execute(params, context) {
9393
+ async execute(params, context2) {
9400
9394
  try {
9401
- const identity2 = notesIdentityForCall(context, params.cwd);
9395
+ const identity2 = notesIdentityForCall(context2, params.cwd);
9402
9396
  const { rows, status } = await createNotesStore(identity2).searchWithStatus(searchQueries(params.query), { glob: params.glob ?? void 0, crumpled: params.crumpled });
9403
9397
  const files = rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address)).map((row) => ({
9404
9398
  ...listedFile(row, identity2),
@@ -9431,13 +9425,16 @@ function resolveTimeBounds(params) {
9431
9425
  return success({ ...since.data === void 0 ? {} : { sinceMs: since.data }, ...until.data === void 0 ? {} : { untilMs: until.data } });
9432
9426
  }
9433
9427
  var HistoryOlderSchema = typebox_exports.Object({
9428
+ session: typebox_exports.Optional(typebox_exports.String()),
9434
9429
  before_seq: typebox_exports.Integer({ minimum: 1 })
9435
9430
  }, { additionalProperties: false });
9436
9431
  var HistoryNewerSchema = typebox_exports.Object({
9432
+ session: typebox_exports.Optional(typebox_exports.String()),
9437
9433
  after_seq: typebox_exports.Integer({ minimum: 1 }),
9438
9434
  from: typebox_exports.Literal("oldest")
9439
9435
  }, { additionalProperties: false });
9440
9436
  var HistoryPageSchema = typebox_exports.Object({
9437
+ notice: typebox_exports.Optional(typebox_exports.String()),
9441
9438
  items: typebox_exports.Array(typebox_exports.Union([HistoryPageItemSchema, HistoryFoldedRowSchema])),
9442
9439
  page_older: typebox_exports.Union([HistoryOlderSchema, typebox_exports.Null()]),
9443
9440
  page_newer: typebox_exports.Union([HistoryNewerSchema, typebox_exports.Null()])
@@ -9455,7 +9452,7 @@ function truncateHistoryItem(item, fits) {
9455
9452
  const { tool: _dropped, ...withoutName } = item;
9456
9453
  return fits(withoutName) ? withoutName : shrinkContent(withoutName);
9457
9454
  }
9458
- function foldedRun(events) {
9455
+ function foldedRun(events, session) {
9459
9456
  if (events.length === 0) return void 0;
9460
9457
  const counts = /* @__PURE__ */ new Map();
9461
9458
  for (const event of events) {
@@ -9465,7 +9462,7 @@ function foldedRun(events) {
9465
9462
  }
9466
9463
  const entries = [...counts].filter(([name]) => name.length <= MAX_FOLD_TOOL_NAME_CHARS).slice(0, MAX_FOLD_TOOL_NAMES);
9467
9464
  const tools = Object.fromEntries(entries);
9468
- return { folded: true, first_seq: events[0].seq, last_seq: events.at(-1).seq, count: events.length, tools };
9465
+ return { ...session === void 0 ? {} : { session }, folded: true, first_seq: events[0].seq, last_seq: events.at(-1).seq, count: events.length, tools };
9469
9466
  }
9470
9467
  function prepareSelection(projection, params) {
9471
9468
  const folds = !params.roles && params.query === void 0;
@@ -9479,38 +9476,57 @@ function prepareSelection(projection, params) {
9479
9476
  if ((event.role === "user" || event.role === "assistant") && eventDocument(event) === "") continue;
9480
9477
  const matchOffset = params.query === void 0 ? void 0 : earliestMatchOffsetChars(eventDocument(event), params.query);
9481
9478
  if (matchOffset !== void 0 && matchOffset < 0) continue;
9482
- candidates.push({ event, matchOffset, before: foldedRun(run) });
9479
+ candidates.push({ event, ...params.session === void 0 ? {} : { session: params.session }, matchOffset, before: foldedRun(run, params.session) });
9483
9480
  run = [];
9484
9481
  }
9485
- return { candidates, tail: foldedRun(run) };
9482
+ return { candidates, session: params.session, tail: foldedRun(run, params.session) };
9486
9483
  }
9487
9484
  function pageData(prepared, start, end, maxChars, preview) {
9488
9485
  const { candidates, tail } = prepared;
9486
+ const identity2 = prepared.session === void 0 ? {} : { session: prepared.session };
9489
9487
  const items = [];
9490
9488
  for (let index = start; index < end; index++) {
9491
9489
  const candidate = candidates[index];
9492
9490
  if (candidate.before && (index > start || start === 0)) items.push(candidate.before);
9493
- items.push(preview ?? (candidate.preview ??= visibleItem(candidate.event, maxChars, candidate.matchOffset)));
9491
+ items.push(preview ?? (candidate.preview ??= { ...visibleItem(candidate.event, maxChars, candidate.matchOffset), ...candidate.session === void 0 ? {} : { session: candidate.session } }));
9494
9492
  }
9495
9493
  if (end === candidates.length && tail) items.push(tail);
9496
9494
  return {
9497
9495
  items,
9498
- page_older: start > 0 && start < end ? { before_seq: candidates[start].event.seq } : null,
9499
- page_newer: end < candidates.length && start < end ? { after_seq: candidates[end - 1].event.seq, from: "oldest" } : null
9496
+ page_older: !prepared.multi && start > 0 && start < end ? { ...identity2, before_seq: candidates[start].event.seq } : null,
9497
+ page_newer: !prepared.multi && end < candidates.length && start < end ? { ...identity2, after_seq: candidates[end - 1].event.seq, from: "oldest" } : null
9500
9498
  };
9501
9499
  }
9502
- function selectPage(projection, params, fits, maxChars) {
9500
+ function resolveSelection(params) {
9503
9501
  const bounds = resolveTimeBounds(params);
9504
9502
  if (!bounds.ok) return bounds;
9505
- let queries;
9506
9503
  try {
9507
- queries = searchQueries(params.query);
9504
+ const queries = searchQueries(params.query);
9505
+ return success({ ...params, ...bounds.data, query: queries.length ? queries : void 0 });
9508
9506
  } catch (error) {
9509
9507
  if (error instanceof InvalidQueryError) return failure("invalid_query", error.message);
9510
9508
  throw error;
9511
9509
  }
9512
- const scoped = { ...params, ...bounds.data, query: queries.length ? queries : void 0 };
9513
- const prepared = prepareSelection(projection, scoped);
9510
+ }
9511
+ function selectPage(projection, params, fits, maxChars) {
9512
+ const scoped = resolveSelection(params);
9513
+ if (!scoped.ok) return scoped;
9514
+ return selectPrepared(prepareSelection(projection, scoped.data), scoped.data, fits, maxChars);
9515
+ }
9516
+ function corpusSelection(params) {
9517
+ const scoped = resolveSelection(params);
9518
+ if (!scoped.ok) return scoped;
9519
+ if (scoped.data.query === void 0) return failure("missing_query", "Wildcard session search requires a non-empty `query`.");
9520
+ if (params.before_seq !== void 0 || params.after_seq !== void 0) return failure("invalid_bounds", "`before_seq` and `after_seq` are per-session; omit them for wildcard session search.");
9521
+ return scoped;
9522
+ }
9523
+ function selectCorpusPage(sessions, scoped, fits, maxChars) {
9524
+ const candidates = sessions.flatMap(({ session, projection }) => prepareSelection(projection, { ...scoped, session }).candidates);
9525
+ const time = (event) => event.createdAt === void 0 || Number.isNaN(Date.parse(event.createdAt)) ? -Infinity : Date.parse(event.createdAt);
9526
+ candidates.sort((a, b) => time(a.event) - time(b.event) || a.session.localeCompare(b.session) || a.event.seq - b.event.seq);
9527
+ return selectPrepared({ candidates, multi: true }, scoped, fits, maxChars);
9528
+ }
9529
+ function selectPrepared(prepared, scoped, fits, maxChars) {
9514
9530
  const { candidates } = prepared;
9515
9531
  const newest = scoped.from !== "oldest";
9516
9532
  let start = newest ? candidates.length : 0;
@@ -9534,33 +9550,71 @@ function selectPage(projection, params, fits, maxChars) {
9534
9550
  }
9535
9551
  const page = pageData(prepared, start, end, maxChars);
9536
9552
  if (!fits(page)) {
9537
- return failure("page_too_large", `Even trimmed to their shortest, these ${page.items.length} rows and their folded runs fill the ${TOOL_OUTPUT_LIMIT} a call can carry; narrow with \`before_seq\`/\`after_seq\` or \`since\`/\`until\`, pass \`roles\` to skip folding, or \`history_read\` one seq.`);
9553
+ const narrow = prepared.multi ? "narrow the session pattern, query, roles or `since`/`until`, or read one session/seq with `history_read`" : "narrow with `before_seq`/`after_seq` or `since`/`until`, pass `roles` to skip folding, or `history_read` one seq";
9554
+ return failure("page_too_large", `Even trimmed to their shortest, these ${page.items.length} rows${prepared.multi ? "" : " and their folded runs"} fill the ${TOOL_OUTPUT_LIMIT} a call can carry; ${narrow}.`);
9538
9555
  }
9539
9556
  return success(page);
9540
9557
  }
9541
9558
 
9559
+ // src/history/corpus.ts
9560
+ var HARNESSES = /* @__PURE__ */ new Set(["pi", "claude", "codex", "dsh"]);
9561
+ function sessionIdentity(session) {
9562
+ return `${session.harness}:${session.id}`;
9563
+ }
9564
+ function parseSessionSelector(value) {
9565
+ const colon = value.indexOf(":");
9566
+ const harness = colon < 0 ? void 0 : value.slice(0, colon);
9567
+ const id2 = colon < 0 ? value : value.slice(colon + 1);
9568
+ if (id2.length === 0 || id2.includes(":") || harness !== void 0 && !HARNESSES.has(harness)) {
9569
+ return failure("invalid_session", "Pass a session ID or prefix, optionally prefixed by pi:, claude:, codex:, or dsh:.");
9570
+ }
9571
+ return success({ ...harness === void 0 ? {} : { harness }, id: id2, wildcard: id2.includes("*") });
9572
+ }
9573
+ function matchesSession(session, selector) {
9574
+ if (selector.harness !== void 0 && selector.harness !== session.harness) return false;
9575
+ const escaped = selector.id.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
9576
+ return new RegExp(`^${escaped}$`).test(session.id);
9577
+ }
9578
+ async function resolveSession(corpus, selector) {
9579
+ if (corpus === void 0) return failure("unknown_session", "This host supplied no cross-session history corpus.");
9580
+ const matching = (pool) => {
9581
+ const exact = pool.filter((session) => session.id === selector.id);
9582
+ return exact.length ? exact : pool.filter((session) => session.id.startsWith(selector.id));
9583
+ };
9584
+ let matches;
9585
+ if (selector.harness !== void 0) matches = matching((await corpus.sessions(selector.harness)).filter((session) => session.harness === selector.harness));
9586
+ else {
9587
+ matches = matching((await corpus.sessions(corpus.currentHarness)).filter((session) => session.harness === corpus.currentHarness));
9588
+ if (matches.length === 0) matches = matching((await corpus.sessions()).filter((session) => session.harness !== corpus.currentHarness));
9589
+ }
9590
+ if (matches.length === 0) return failure("unknown_session", `No local session matches ${JSON.stringify(selector.harness ? `${selector.harness}:${selector.id}` : selector.id)}.`);
9591
+ if (matches.length > 1) return failure("ambiguous_session", `Session selector is ambiguous: ${matches.slice(0, 5).map(sessionIdentity).join(", ")}${matches.length > 5 ? ` (${matches.length - 5} more)` : ""}. Pass a longer ID or a harness-qualified ID.`);
9592
+ return success(matches[0]);
9593
+ }
9594
+ async function loadHistorySession(session) {
9595
+ try {
9596
+ return success(await session.load());
9597
+ } catch (error) {
9598
+ return failure("history_unavailable", `Cannot read session ${sessionIdentity(session)}: ${error instanceof Error ? error.message : String(error)}`);
9599
+ }
9600
+ }
9601
+ function currentHistory(context2) {
9602
+ return "current" in context2 ? context2.current() : context2;
9603
+ }
9604
+
9542
9605
  // src/tools/history.ts
9543
9606
  var HistoryReadDataSchema = typebox_exports.Object({
9607
+ session: typebox_exports.Optional(typebox_exports.String()),
9608
+ notice: typebox_exports.Optional(typebox_exports.String()),
9544
9609
  seq: typebox_exports.Integer({ minimum: 1 }),
9545
- window_id: typebox_exports.String(),
9546
9610
  role: HistoryRoleSchema,
9547
9611
  created_at: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
9548
9612
  ...ToolSummarySchema.properties,
9549
9613
  nested_calls: typebox_exports.Optional(NestedCallSummarySchema),
9550
9614
  ...TextWindowSchema.properties
9551
9615
  }, { additionalProperties: false });
9552
- var HistoryWindowsDataSchema = typebox_exports.Object({
9553
- session_id: typebox_exports.String(),
9554
- windows: typebox_exports.Array(typebox_exports.Object({
9555
- window_id: typebox_exports.String(),
9556
- created_at: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
9557
- first_seq: typebox_exports.Union([typebox_exports.Integer({ minimum: 1 }), typebox_exports.Null()]),
9558
- last_seq: typebox_exports.Union([typebox_exports.Integer({ minimum: 1 }), typebox_exports.Null()])
9559
- }, { additionalProperties: false })),
9560
- more: typebox_exports.Integer({ minimum: 0, description: "How many more were left out." })
9561
- }, { additionalProperties: false });
9562
9616
  function header(item) {
9563
- return `seq ${item.seq} | window ${item.window_id} | ${item.role}`;
9617
+ return `${item.session === void 0 ? "" : `session ${item.session} | `}seq ${item.seq} | ${item.role}`;
9564
9618
  }
9565
9619
  function toolHeader(item) {
9566
9620
  if (item.role !== "tool") return void 0;
@@ -9580,77 +9634,32 @@ function renderPageItem(item) {
9580
9634
  }
9581
9635
  function renderFoldedRow(row) {
9582
9636
  const tools = Object.entries(row.tools).map(([name, count]) => `${name} ${count}`).join(", ");
9637
+ const identity2 = row.session === void 0 ? {} : { session: row.session };
9583
9638
  const expand = `
9584
- \u2192 expand: {"after_seq":${row.first_seq - 1},"before_seq":${row.last_seq + 1},"from":"oldest","roles":["tool","context"]}`;
9585
- return `seqs ${row.first_seq}-${row.last_seq} | folded ${row.count} events${tools ? ` | ${tools}` : ""}${expand}`;
9639
+ \u2192 expand: ${JSON.stringify({ ...identity2, after_seq: row.first_seq - 1, before_seq: row.last_seq + 1, from: "oldest", roles: ["tool", "context"] })}`;
9640
+ return `${row.session === void 0 ? "" : `session ${row.session} | `}seqs ${row.first_seq}-${row.last_seq} | folded ${row.count} events${tools ? ` | ${tools}` : ""}${expand}`;
9586
9641
  }
9587
9642
  function renderPage(page) {
9588
- if (page.items.length === 0) return "No events match these filters.";
9643
+ if (page.items.length === 0) return `${page.notice ?? ""}No events match these filters.`;
9589
9644
  const body = page.items.map((item) => "folded" in item ? renderFoldedRow(item) : renderPageItem(item)).join("\n\n");
9590
9645
  const cursors = [
9591
9646
  page.page_older === null ? "" : `\u2192 older: ${JSON.stringify(page.page_older)}`,
9592
9647
  page.page_newer === null ? "" : `\u2192 newer: ${JSON.stringify(page.page_newer)}`
9593
9648
  ].filter((line) => line !== "");
9594
- return cursors.length === 0 ? body : `${body}
9649
+ return (page.notice ?? "") + (cursors.length === 0 ? body : `${body}
9595
9650
 
9596
- ${cursors.join(" | ")}`;
9651
+ ${cursors.join(" | ")}`);
9597
9652
  }
9598
9653
  function renderRead(data) {
9599
9654
  const tool = toolHeader(data);
9600
9655
  const afterSeq = data.seq - 10;
9601
- const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...afterSeq >= 1 ? { after_seq: afterSeq } : {}, before_seq: data.seq + 10 })})`;
9602
- return [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
9656
+ const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...data.session === void 0 ? {} : { session: data.session }, ...afterSeq >= 1 ? { after_seq: afterSeq } : {}, before_seq: data.seq + 10 })})`;
9657
+ return (data.notice ?? "") + [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
9603
9658
  }
9604
9659
  var plainText = (text) => text;
9605
- var MAX_REPORTED_WINDOWS = 5;
9606
- function knownWindowSuffix(known) {
9607
- return known.length === 0 ? "" : `; its windows: ${known.slice(0, MAX_REPORTED_WINDOWS).join(", ")}`;
9608
- }
9609
- var PREVIOUS_WINDOW = "@previous";
9610
- function resolveWindowId(projection, windowId) {
9611
- if (windowId !== PREVIOUS_WINDOW) return { ok: true, window_id: windowId };
9612
- const previous = projection.windows.at(-2);
9613
- if (previous !== void 0) return { ok: true, window_id: previous.windowId };
9614
- const known = projection.windows.map((current) => current.windowId);
9615
- return { ok: false, outcome: failure("unknown_window_id", `"${PREVIOUS_WINDOW}" has nothing to point at: this session has no window before the current one${knownWindowSuffix(known)}.`) };
9616
- }
9617
- function badWindowId(projection, params) {
9618
- const badWindow = unknownWindowId(projection, params);
9619
- if (!badWindow) return void 0;
9620
- return failure("unknown_window_id", `${badWindow.message}${knownWindowSuffix(badWindow.known)}.`);
9621
- }
9622
- var historyWindowsParameters = typebox_exports.Object({}, { additionalProperties: false });
9623
- var historyWindows = {
9624
- name: "history_windows",
9625
- label: "History list windows",
9626
- description: "List this session's context windows, oldest first, with seq ranges.",
9627
- parameters: historyWindowsParameters,
9628
- outputSchema: resultSchema(HistoryWindowsDataSchema),
9629
- async execute(_params, projection, sessionId, wrapText = plainText) {
9630
- const data = { session_id: sessionId, windows: [], more: projection.windows.length };
9631
- const fits = (candidate) => fitsResult(success(candidate), (result) => wrapText(renderOutcome(result, renderWindows)));
9632
- for (const window of projection.windows) {
9633
- let first = null;
9634
- let last = null;
9635
- for (const event of window.items) {
9636
- first = first === null ? event.seq : Math.min(first, event.seq);
9637
- last = last === null ? event.seq : Math.max(last, event.seq);
9638
- }
9639
- const row = { window_id: window.windowId, created_at: window.createdAt ?? null, first_seq: first, last_seq: last };
9640
- if (!fits({ ...data, windows: [...data.windows, row], more: data.more - 1 })) break;
9641
- data.windows.push(row);
9642
- data.more--;
9643
- }
9644
- return fits(data) ? success(data) : failure("output_too_large", `The session id alone fills the ${TOOL_OUTPUT_LIMIT} a call can carry.`);
9645
- },
9646
- render: (result) => renderOutcome(result, renderWindows)
9647
- };
9648
- function renderWindows(data) {
9649
- const lines = [`session ${data.session_id}`, ...data.windows.map((window) => `window ${window.window_id} | seqs ${window.first_seq ?? "-"}-${window.last_seq ?? "-"}`)];
9650
- if (data.more > 0) lines.push(`${data.more} more windows not shown; every \`history_list\` event also names its window.`);
9651
- return lines.join("\n");
9652
- }
9660
+ var sessionParameter = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "(optional) Session ID or unique prefix, optionally pi:, claude:, codex:, or dsh:. Omit for this session. In history_list, * searches sessions (query required); history_read needs one session." }));
9653
9661
  var historyListParameters = typebox_exports.Object({
9662
+ session: sessionParameter,
9654
9663
  query: typebox_exports.Optional(searchQuery("(optional) Text, or a list of texts (any match). Empty text/list means no search filter; empty entries are ignored. Searches every role, tool arguments and output included; returns only hits.")),
9655
9664
  roles: historyRoles(),
9656
9665
  before_seq: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "(optional) Only events with seq below this." })),
@@ -9658,40 +9667,77 @@ var historyListParameters = typebox_exports.Object({
9658
9667
  since: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "(optional) ISO 8601 time; only events at or after it. UTC if no offset." })),
9659
9668
  until: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "(optional) ISO 8601 time; only events before it. UTC if no offset." })),
9660
9669
  from: typebox_exports.Optional(typebox_exports.Union([typebox_exports.Literal("newest"), typebox_exports.Literal("oldest")], { description: "(optional, default newest) Which end `limit` counts from: newest or oldest. Results stay oldest first." })),
9661
- window_id: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: `(optional) Only this context window. From \`history_windows\` or any event; \`${PREVIOUS_WINDOW}\` is the one before this.` })),
9662
9670
  limit: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: 500, description: "(optional, default 20) Max events per page; folded rows don't count." })),
9663
9671
  max_chars_per_item: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: MAX_READ_WINDOW_CHARS, description: `(optional, default ${HISTORY_PREVIEW_CHARS}) Max preview chars per event.` }))
9664
9672
  }, { additionalProperties: false });
9665
9673
  var historyList = {
9666
9674
  name: "history_list",
9667
9675
  label: "History list items",
9668
- description: "Browse or search this session's events, a page at a time. Read one in full with `history_read`.",
9676
+ description: "Browse or search events, a page at a time. Omit session for this session; pass an ID/prefix for another, or * with query to search across local harnesses. Read one in full with `history_read`.",
9669
9677
  parameters: historyListParameters,
9670
9678
  outputSchema: resultSchema(HistoryPageSchema),
9671
- async execute(params, projection, wrapText = plainText) {
9672
- const resolved = resolveWindowId(projection, params.window_id);
9673
- if (!resolved.ok) return resolved.outcome;
9674
- const scoped = { ...params, window_id: resolved.window_id };
9675
- const badWindow = badWindowId(projection, scoped);
9676
- if (badWindow) return badWindow;
9677
- const fits = (page) => fitsResult(success(page), (result) => wrapText(renderOutcome(result, renderPage)));
9678
- return selectPage(projection, scoped, fits, scoped.max_chars_per_item ?? HISTORY_PREVIEW_CHARS);
9679
+ async execute(params, context2, wrapText = plainText) {
9680
+ const fits = (page) => fitsResult(success(page), (result2) => wrapText(renderOutcome(result2, renderPage)));
9681
+ const maxChars = params.max_chars_per_item ?? HISTORY_PREVIEW_CHARS;
9682
+ if (params.session === void 0) return selectPage(await currentHistory(context2), params, fits, maxChars);
9683
+ const selector = parseSessionSelector(params.session);
9684
+ if (!selector.ok) return selector;
9685
+ const corpus = "corpus" in context2 ? context2.corpus : void 0;
9686
+ if (selector.data.wildcard) {
9687
+ const scoped = corpusSelection(params);
9688
+ if (!scoped.ok) return scoped;
9689
+ if (corpus === void 0) return failure("unknown_session", "This host supplied no cross-session history corpus.");
9690
+ const sessions = (await corpus.sessions(selector.data.harness)).filter((session) => matchesSession(session, selector.data));
9691
+ const loaded2 = [];
9692
+ const notices = [];
9693
+ for (const session of sessions) {
9694
+ const result3 = await loadHistorySession(session);
9695
+ if (!result3.ok) return result3;
9696
+ loaded2.push({ session: sessionIdentity(session), projection: result3.data.projection });
9697
+ if (result3.data.notice) notices.push(`session ${sessionIdentity(session)}: ${result3.data.notice}`);
9698
+ }
9699
+ const notice2 = notices.length ? { notice: notices.join("") } : {};
9700
+ const result2 = selectCorpusPage(loaded2, scoped.data, (page) => fits({ ...page, ...notice2 }), maxChars);
9701
+ return result2.ok ? success({ ...result2.data, ...notice2 }) : result2;
9702
+ }
9703
+ const target = await resolveSession(corpus, selector.data);
9704
+ if (!target.ok) return target;
9705
+ const loaded = await loadHistorySession(target.data);
9706
+ if (!loaded.ok) return loaded;
9707
+ const notice = loaded.data.notice === void 0 ? {} : { notice: loaded.data.notice };
9708
+ const result = selectPage(loaded.data.projection, { ...params, session: sessionIdentity(target.data) }, (page) => fits({ ...page, ...notice }), maxChars);
9709
+ return result.ok ? success({ ...result.data, ...notice }) : result;
9679
9710
  },
9680
9711
  render: (result) => renderOutcome(result, renderPage)
9681
9712
  };
9682
- var historyReadParameters = typebox_exports.Object({ seq: typebox_exports.Integer({ minimum: 1, description: "Event seq, from `history_list`." }), ...TextWindowRequestSchema }, { additionalProperties: false });
9713
+ var historyReadParameters = typebox_exports.Object({ session: sessionParameter, seq: typebox_exports.Integer({ minimum: 1, description: "Event seq, from `history_list`. Pass its session too when present." }), ...TextWindowRequestSchema }, { additionalProperties: false });
9683
9714
  var historyRead = {
9684
9715
  name: "history_read",
9685
9716
  label: "History read item",
9686
9717
  description: "Read one event in full: tool arguments, output, and nested calls.",
9687
9718
  parameters: historyReadParameters,
9688
9719
  outputSchema: resultSchema(HistoryReadDataSchema),
9689
- async execute(params, projection, wrapText = plainText) {
9720
+ async execute(params, context2, wrapText = plainText) {
9721
+ let projection;
9722
+ let identity2 = {};
9723
+ if (params.session === void 0) projection = await currentHistory(context2);
9724
+ else {
9725
+ const selector = parseSessionSelector(params.session);
9726
+ if (!selector.ok) return selector;
9727
+ if (selector.data.wildcard) return failure("invalid_session", "`history_read` reads one session; pass a specific `session` ID, not a wildcard.");
9728
+ const target = await resolveSession("corpus" in context2 ? context2.corpus : void 0, selector.data);
9729
+ if (!target.ok) return target;
9730
+ const loaded = await loadHistorySession(target.data);
9731
+ if (!loaded.ok) return loaded;
9732
+ projection = loaded.data.projection;
9733
+ identity2 = { session: sessionIdentity(target.data), ...loaded.data.notice === void 0 ? {} : { notice: loaded.data.notice } };
9734
+ }
9690
9735
  const item = allItems(projection).find((event) => event.seq === params.seq);
9691
9736
  if (item === void 0 && params.seq > projection.highestSeq) {
9692
9737
  return failure("unknown_seq", `There is no seq ${params.seq}; this session runs from seq 1 to ${projection.highestSeq}.`);
9693
9738
  }
9694
9739
  if (!projection.branchSeqs.has(params.seq)) {
9740
+ if (identity2.notice) return failure("unconfirmed_seq", `Seq ${params.seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`);
9695
9741
  return failure("not_on_branch", `Seq ${params.seq} is on another branch of this session; it can't be read from here.`);
9696
9742
  }
9697
9743
  if (item === void 0) {
@@ -9711,8 +9757,8 @@ var historyRead = {
9711
9757
  params.offset_chars,
9712
9758
  params.max_chars,
9713
9759
  (window) => ({
9760
+ ...identity2,
9714
9761
  seq: item.seq,
9715
- window_id: item.windowId,
9716
9762
  role: item.role,
9717
9763
  created_at: item.createdAt ?? null,
9718
9764
  ...toolSummary(item),
@@ -9725,7 +9771,176 @@ var historyRead = {
9725
9771
  render: (result) => renderOutcome(result, renderRead)
9726
9772
  };
9727
9773
 
9728
- // plugins/claude/src/history.ts
9774
+ // src/history/local.ts
9775
+ import { readdir as readdir4, readFile as readFile4, stat as stat2 } from "node:fs/promises";
9776
+ import { homedir } from "node:os";
9777
+ import { join as join5 } from "node:path";
9778
+
9779
+ // src/history/pi.ts
9780
+ function mapRole(role) {
9781
+ if (role === "user" || role === "assistant") return role;
9782
+ if (role === "toolResult" || role === "bashExecution") return "tool";
9783
+ if (role === "custom") return "developer";
9784
+ if (role === "compactionSummary" || role === "branchSummary") return "system";
9785
+ return void 0;
9786
+ }
9787
+ function isToolCall(part) {
9788
+ return typeof part === "object" && part !== null && part.type === "toolCall";
9789
+ }
9790
+ function piSequenceCount(entry) {
9791
+ if (entry.type === "compaction" || entry.type === "branch_summary" || entry.type === "custom_message") return 1;
9792
+ if (entry.type !== "message" || !entry.message || mapRole(entry.message.role) === void 0) return 0;
9793
+ if (entry.message.role !== "assistant" || !Array.isArray(entry.message.content)) return 1;
9794
+ return 1 + entry.message.content.filter(isToolCall).length;
9795
+ }
9796
+ function messageContent(message) {
9797
+ switch (message.role) {
9798
+ case "bashExecution":
9799
+ return message.output ?? "";
9800
+ case "branchSummary":
9801
+ case "compactionSummary":
9802
+ return message.summary ?? "";
9803
+ default:
9804
+ return contentText(message.content);
9805
+ }
9806
+ }
9807
+ function nestedCallsOf(message) {
9808
+ if (message.role !== "toolResult" || message.nestedCalls === void 0) return void 0;
9809
+ return { calls: message.nestedCalls.calls, complete: message.nestedCalls.complete };
9810
+ }
9811
+ function toolInfo(message) {
9812
+ if (message.role === "bashExecution") {
9813
+ const status = message.cancelled === true ? "error" : typeof message.exitCode === "number" ? message.exitCode === 0 ? "ok" : "error" : "unfinished";
9814
+ return { toolName: "bash", arguments: { command: message.command }, recordedStatus: status, outputTruncated: message.truncated || void 0, fullOutputPath: message.truncated ? message.fullOutputPath : void 0 };
9815
+ }
9816
+ if (message.role !== "toolResult") return {};
9817
+ const nestedCalls = nestedCallsOf(message);
9818
+ return {
9819
+ toolName: message.toolName,
9820
+ toolCallId: message.toolCallId,
9821
+ toolError: message.isError === true ? true : void 0,
9822
+ ...nestedCalls ? { nestedCalls } : {}
9823
+ };
9824
+ }
9825
+ function toolCallItems(windowId, entry, message, entrySeq) {
9826
+ if (message.role !== "assistant" || !Array.isArray(message.content)) return [];
9827
+ const items = [];
9828
+ let callIndex = 0;
9829
+ for (const part of message.content) {
9830
+ if (!isToolCall(part)) continue;
9831
+ items.push({
9832
+ seq: entrySeq + callIndex + 1,
9833
+ windowId,
9834
+ role: "tool_call",
9835
+ text: "",
9836
+ createdAt: entry.timestamp,
9837
+ toolName: part.name,
9838
+ toolCallId: part.id,
9839
+ arguments: part.arguments
9840
+ });
9841
+ callIndex += 1;
9842
+ }
9843
+ return items;
9844
+ }
9845
+ function piHistoryFromEntries(sessionId, entries, branch) {
9846
+ const seqByEntryId = /* @__PURE__ */ new Map();
9847
+ let nextSeq = 1;
9848
+ for (const entry of entries) {
9849
+ const count = piSequenceCount(entry);
9850
+ if (count === 0) continue;
9851
+ seqByEntryId.set(entry.id, nextSeq);
9852
+ nextSeq += count;
9853
+ }
9854
+ const highestSeq = nextSeq - 1;
9855
+ let window = { windowId: `pcw:${sessionId.slice(0, 8)}:root`, items: [] };
9856
+ const rawWindows = [window];
9857
+ const branchSeqs = /* @__PURE__ */ new Set();
9858
+ for (const entry of branch) {
9859
+ if (entry.type === "custom" && entry.customType === "notesoup/reset-marker" && typeof entry.data === "object" && entry.data !== null && "windowId" in entry.data && typeof entry.data.windowId === "string" && entry.data.windowId.length > 0) {
9860
+ window = { windowId: entry.data.windowId, createdAt: entry.timestamp, items: [] };
9861
+ rawWindows.push(window);
9862
+ continue;
9863
+ }
9864
+ const entrySeq = seqByEntryId.get(entry.id);
9865
+ if (entrySeq === void 0) continue;
9866
+ branchSeqs.add(entrySeq);
9867
+ if (entry.type === "compaction" || entry.type === "branch_summary") {
9868
+ window.items.push({ seq: entrySeq, windowId: window.windowId, role: "system", text: entry.summary ?? "", createdAt: entry.timestamp });
9869
+ continue;
9870
+ }
9871
+ if (entry.type === "message" && entry.message) {
9872
+ const role = mapRole(entry.message.role);
9873
+ if (!role) continue;
9874
+ window.items.push({
9875
+ seq: entrySeq,
9876
+ windowId: window.windowId,
9877
+ role,
9878
+ text: messageContent(entry.message),
9879
+ createdAt: entry.timestamp,
9880
+ ...toolInfo(entry.message)
9881
+ });
9882
+ const calls = toolCallItems(window.windowId, entry, entry.message, entrySeq);
9883
+ for (const call of calls) branchSeqs.add(call.seq);
9884
+ window.items.push(...calls);
9885
+ continue;
9886
+ }
9887
+ if (entry.type === "custom_message") {
9888
+ window.items.push({
9889
+ seq: entrySeq,
9890
+ windowId: window.windowId,
9891
+ role: "developer",
9892
+ text: contentText(entry.content),
9893
+ createdAt: entry.timestamp
9894
+ });
9895
+ }
9896
+ }
9897
+ return projectHistory(rawWindows, highestSeq, branchSeqs);
9898
+ }
9899
+ function piHistoryFromJsonl(text, sessionId) {
9900
+ const lines = text.split("\n");
9901
+ const entries = [];
9902
+ let header2 = false;
9903
+ for (let index = 0; index < lines.length; index++) {
9904
+ const line = lines[index];
9905
+ if (line.trim() === "") continue;
9906
+ let row;
9907
+ try {
9908
+ row = JSON.parse(line);
9909
+ } catch {
9910
+ if (index === lines.length - 1 && !text.endsWith("\n")) break;
9911
+ throw new Error(`malformed Pi transcript JSON at line ${index + 1}`);
9912
+ }
9913
+ if (!row || typeof row !== "object" || typeof row.type !== "string" || typeof row.id !== "string") throw new Error("invalid Pi transcript entry");
9914
+ if (!header2) {
9915
+ if (row.type !== "session" || row.id !== sessionId) throw new Error("Pi transcript belongs to a different session or has no header");
9916
+ header2 = true;
9917
+ continue;
9918
+ }
9919
+ if (row.parentId !== null && typeof row.parentId !== "string") throw new Error("Pi transcript has no tree parent link (unsupported legacy format)");
9920
+ if (row.type === "message" && (!row.message || typeof row.message.role !== "string")) throw new Error("invalid Pi transcript message");
9921
+ entries.push(row);
9922
+ }
9923
+ if (!header2) throw new Error("Pi transcript has no session header");
9924
+ const byId = /* @__PURE__ */ new Map();
9925
+ for (const entry of entries) {
9926
+ if (byId.has(entry.id)) throw new Error(`duplicate Pi entry ID: ${entry.id}`);
9927
+ byId.set(entry.id, entry);
9928
+ }
9929
+ const branch = [], seen = /* @__PURE__ */ new Set();
9930
+ let cursor = entries.at(-1);
9931
+ while (cursor) {
9932
+ if (seen.has(cursor.id)) throw new Error("cyclic Pi transcript ancestry");
9933
+ seen.add(cursor.id);
9934
+ branch.push(cursor);
9935
+ if (cursor.parentId === null) break;
9936
+ const parent2 = byId.get(cursor.parentId);
9937
+ if (!parent2) throw new Error(`Pi transcript missing parent: ${cursor.parentId}`);
9938
+ cursor = parent2;
9939
+ }
9940
+ return piHistoryFromEntries(sessionId, entries, branch.reverse());
9941
+ }
9942
+
9943
+ // src/history/claude.ts
9729
9944
  import { readFile as readFile2 } from "node:fs/promises";
9730
9945
  import { isDeepStrictEqual } from "node:util";
9731
9946
  var MESSAGE_TYPES = /* @__PURE__ */ new Set(["user", "assistant", "system", "attachment"]);
@@ -9801,8 +10016,8 @@ function decode(row, seq) {
9801
10016
  items.push({ ...common, seq: seq + items.length, role: "tool_call", text: "", toolName: requiredString(block.name, "tool name"), toolCallId: requiredString(block.id, "tool id"), arguments: block.input });
9802
10017
  } else if (block.type === "tool_result") {
9803
10018
  if (block.is_error !== void 0 && typeof block.is_error !== "boolean") throw new Error("invalid Claude transcript tool error flag");
9804
- const output = block.content === void 0 ? "" : contentText(blocksOf(block.content));
9805
- items.push({ ...common, seq: seq + items.length, role: "tool", text: output, toolCallId: requiredString(block.tool_use_id, "tool result id"), toolError: block.is_error === true });
10019
+ const output2 = block.content === void 0 ? "" : contentText(blocksOf(block.content));
10020
+ items.push({ ...common, seq: seq + items.length, role: "tool", text: output2, toolCallId: requiredString(block.tool_use_id, "tool result id"), toolError: block.is_error === true });
9806
10021
  }
9807
10022
  }
9808
10023
  return items;
@@ -9905,47 +10120,593 @@ function claudeHistoryFromJsonl(text, source) {
9905
10120
  const uuids = meta.preservedMessages.allUuids ?? meta.preservedMessages.uuids;
9906
10121
  if (uuids === void 0) continue;
9907
10122
  if (!Array.isArray(uuids)) throw new Error("invalid Claude preserved messages");
9908
- for (const id of uuids) {
9909
- const uuid2 = requiredString(id, "preserved UUID");
10123
+ for (const id2 of uuids) {
10124
+ const uuid2 = requiredString(id2, "preserved UUID");
9910
10125
  if (nodes.has(uuid2)) stack.push({ uuid: uuid2, historical: true });
9911
10126
  }
9912
10127
  }
9913
10128
  }
9914
10129
  const current = positionOf(nodes.get(source.headUuid).latest);
9915
- const windowId = (position) => `claude:${source.sessionId}:${"ordinal" in position ? position.ordinal : `unknown:${position.unknownAncestor}`}`;
10130
+ const windowId = (position2) => `claude:${source.sessionId}:${"ordinal" in position2 ? position2.ordinal : `unknown:${position2.unknownAncestor}`}`;
9916
10131
  const windowsById = /* @__PURE__ */ new Map();
9917
10132
  const branchSeqs = /* @__PURE__ */ new Set();
9918
10133
  let maxOrdinal = "ordinal" in current ? current.ordinal : 0;
9919
10134
  for (const [uuid, node] of nodes) {
9920
10135
  if (!selected.has(uuid)) continue;
9921
- const position = positionOf(node.first);
9922
- if ("ordinal" in position) maxOrdinal = Math.max(maxOrdinal, position.ordinal);
9923
- const id = windowId(position);
9924
- let window = windowsById.get(id);
10136
+ const position2 = positionOf(node.first);
10137
+ if ("ordinal" in position2) maxOrdinal = Math.max(maxOrdinal, position2.ordinal);
10138
+ const id2 = windowId(position2);
10139
+ let window = windowsById.get(id2);
9925
10140
  if (!window) {
9926
- window = { windowId: id, ..."ordinal" in position ? { ordinal: position.ordinal } : {}, items: [] };
9927
- windowsById.set(id, window);
10141
+ window = { windowId: id2, ..."ordinal" in position2 ? { ordinal: position2.ordinal } : {}, items: [] };
10142
+ windowsById.set(id2, window);
9928
10143
  }
9929
10144
  window.createdAt ??= node.items[0]?.createdAt;
9930
10145
  for (const item of node.items) {
9931
10146
  branchSeqs.add(item.seq);
9932
- window.items.push({ ...item, windowId: id });
10147
+ window.items.push({ ...item, windowId: id2 });
9933
10148
  }
9934
10149
  }
9935
10150
  if (missingAncestors.size === 0) {
9936
10151
  for (let ordinal = 0; ordinal <= maxOrdinal; ordinal++) {
9937
- const id = windowId({ ordinal });
9938
- if (!windowsById.has(id)) windowsById.set(id, { windowId: id, ordinal, items: [] });
10152
+ const id2 = windowId({ ordinal });
10153
+ if (!windowsById.has(id2)) windowsById.set(id2, { windowId: id2, ordinal, items: [] });
9939
10154
  }
9940
10155
  }
9941
10156
  const windows = [...windowsById.values()].sort((a, b) => a.ordinal === void 0 ? b.ordinal === void 0 ? 0 : 1 : b.ordinal === void 0 ? -1 : a.ordinal - b.ordinal);
9942
10157
  return { ...projectHistory(windows, nextSeq - 1, branchSeqs), missingAncestors: [...missingAncestors], currentWindowOrdinal: "ordinal" in current ? current.ordinal : void 0 };
9943
10158
  }
10159
+ function offlineClaudeHead(text) {
10160
+ const latest = /* @__PURE__ */ new Map();
10161
+ for (const row of rowsOf(text)) {
10162
+ if (MESSAGE_TYPES.has(row.type)) latest.set(requiredString(row.uuid, "uuid"), row);
10163
+ }
10164
+ const ancestors = /* @__PURE__ */ new Set();
10165
+ for (const row of latest.values()) {
10166
+ const id2 = parent(row);
10167
+ if (id2 !== void 0) ancestors.add(id2);
10168
+ if (!boundary(row)) continue;
10169
+ if (typeof row.logicalParentUuid === "string") ancestors.add(row.logicalParentUuid);
10170
+ const meta = row.compactMetadata;
10171
+ if (!object(meta)) continue;
10172
+ if (object(meta.preservedSegment)) {
10173
+ for (const field of ["headUuid", "tailUuid"]) {
10174
+ if (typeof meta.preservedSegment[field] === "string") ancestors.add(meta.preservedSegment[field]);
10175
+ }
10176
+ }
10177
+ if (object(meta.preservedMessages)) {
10178
+ const uuids = meta.preservedMessages.allUuids ?? meta.preservedMessages.uuids;
10179
+ if (Array.isArray(uuids)) {
10180
+ for (const uuid of uuids) if (typeof uuid === "string") ancestors.add(uuid);
10181
+ }
10182
+ }
10183
+ }
10184
+ const leaves = [...latest.keys()].filter((uuid) => !ancestors.has(uuid));
10185
+ if (leaves.length !== 1) throw new Error(`Offline Claude transcript has ${leaves.length} possible heads; no confirmed unique leaf (refusing to guess a selected branch)`);
10186
+ return leaves[0];
10187
+ }
9944
10188
  async function readClaudeHistory(source) {
9945
10189
  if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath || typeof source.sessionId !== "string") throw new Error("Claude history transcript_path is unavailable");
9946
10190
  return claudeHistoryFromJsonl(await readFile2(source.transcriptPath, "utf8"), source);
9947
10191
  }
9948
10192
 
10193
+ // src/history/codex-transcript.ts
10194
+ import { readFile as readFile3, readdir as readdir3, realpath as realpath2, stat } from "node:fs/promises";
10195
+ import { basename as basename2, dirname as dirname3, join as join4, relative, sep as sep2 } from "node:path";
10196
+ import * as zlib from "node:zlib";
10197
+ var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
10198
+ var UUID_RE = new RegExp(`^${UUID}$`);
10199
+ var FILE_RE = new RegExp(`^rollout-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-(${UUID})(?:_(${UUID}))?\\.jsonl(?:\\.zst)?$`);
10200
+ var RECORD_TYPES = /* @__PURE__ */ new Set(["session_meta", "response_item", "compacted", "turn_context", "event_msg", "token_usage_record", "world_state", "retained_context", "security_risk_score", "inter_agent_communication", "inter_agent_communication_metadata", "realtime_item"]);
10201
+ var RESPONSE_TYPES = /* @__PURE__ */ new Set(["message", "agent_message", "reasoning", "local_shell_call", "function_call", "function_call_output", "custom_tool_call", "custom_tool_call_output", "tool_search_call", "tool_search_output", "web_search_call", "image_generation_call", "compaction", "compaction_summary", "configuration_update", "context_compaction"]);
10202
+ var MAX_BYTES = 128 * 1024 * 1024;
10203
+ var MAX_SEGMENTS = 64;
10204
+ var MAX_DIRECTORY_ENTRIES = 1e5;
10205
+ function nativeObject(value, field) {
10206
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Invalid Codex ${field}: expected an object`);
10207
+ return value;
10208
+ }
10209
+ function nativeString(value, field) {
10210
+ if (typeof value !== "string") throw new Error(`Invalid Codex ${field}: expected a string`);
10211
+ return value;
10212
+ }
10213
+ function responseShape(value) {
10214
+ const type = nativeString(nativeObject(value, "response_item").type, "response_item.type");
10215
+ if (!RESPONSE_TYPES.has(type)) throw new Error(`Unsupported Codex response item: ${type}`);
10216
+ }
10217
+ function id(value, field) {
10218
+ const result = nativeString(value, field);
10219
+ if (!UUID_RE.test(result)) throw new Error(`Invalid Codex ${field}: expected a canonical UUID`);
10220
+ return result;
10221
+ }
10222
+ function integer(value, field) {
10223
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value >= Number.MAX_SAFE_INTEGER) throw new Error(`Invalid Codex ${field}: unsafe or negative integer`);
10224
+ return value;
10225
+ }
10226
+ function position(value) {
10227
+ if (value == null) return void 0;
10228
+ const p = nativeObject(value, "history_base");
10229
+ return { thread_id: id(p.thread_id, "history_base.thread_id (rollout ID)"), end_ordinal_exclusive: integer(p.end_ordinal_exclusive, "history_base ordinal"), end_byte_offset: integer(p.end_byte_offset, "history_base byte offset") };
10230
+ }
10231
+ function initialWindow(meta) {
10232
+ return meta.context_window == null ? void 0 : id(nativeObject(meta.context_window, "context_window").window_id, "context_window.window_id");
10233
+ }
10234
+ function checkMeta(meta) {
10235
+ id(meta.id, "session_meta.id");
10236
+ if (meta.session_id != null) id(meta.session_id, "session_meta.session_id");
10237
+ if (meta.cli_version !== "0.160.1") throw new Error(`Unsupported Codex producer ${String(meta.cli_version)}; this decoder supports official 0.160.1 only`);
10238
+ nativeString(meta.cwd, "session_meta.cwd");
10239
+ if (meta.history_mode !== void 0 && meta.history_mode !== "legacy" && meta.history_mode !== "paginated") throw new Error(`Unsupported Codex history_mode: ${String(meta.history_mode)}`);
10240
+ for (const field of ["forked_from_id", "parent_thread_id"]) if (meta[field] != null) id(meta[field], field);
10241
+ for (const field of ["forked_from_ordinal_exclusive", "subagent_history_start_ordinal"]) if (meta[field] != null) integer(meta[field], field);
10242
+ initialWindow(meta);
10243
+ }
10244
+ function segmentFromBytes(bytes, cutoff) {
10245
+ const limit = cutoff?.end_byte_offset ?? bytes.length;
10246
+ if (limit > bytes.length || cutoff && (limit === 0 || bytes[limit - 1] !== 10)) throw new Error("Unavailable Codex lineage: cutoff is not a complete decoded JSONL boundary");
10247
+ const records = [];
10248
+ let meta, previous = -1, lineNumber = 0;
10249
+ for (let offset = 0; offset < limit; ) {
10250
+ const newline = bytes.indexOf(10, offset);
10251
+ if (newline < 0 || newline >= limit) break;
10252
+ lineNumber++;
10253
+ let row;
10254
+ try {
10255
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(offset, newline));
10256
+ row = nativeObject(JSON.parse(text), "record");
10257
+ } catch {
10258
+ throw new Error(`Malformed committed Codex JSONL record at line ${lineNumber}`);
10259
+ }
10260
+ offset = newline + 1;
10261
+ const type = nativeString(row.type, "record.type");
10262
+ if (!RECORD_TYPES.has(type)) throw new Error(`Unsupported Codex rollout record: ${type}`);
10263
+ const payload = nativeObject(row.payload, `${type}.payload`);
10264
+ if (!meta) {
10265
+ if (type !== "session_meta") throw new Error("Invalid Codex transcript: first record must be session_meta");
10266
+ meta = payload;
10267
+ checkMeta(meta);
10268
+ } else if (type === "session_meta") {
10269
+ throw new Error("Unavailable Codex history: copied session_meta ancestry has no proved source addresses");
10270
+ }
10271
+ const paginated = meta.history_mode === "paginated";
10272
+ const ordinal = paginated ? integer(row.ordinal, "paginated record ordinal") : lineNumber - 1;
10273
+ if (!paginated && row.ordinal != null) throw new Error("Invalid Codex legacy transcript: unexpected ordinal");
10274
+ if (ordinal <= previous) throw new Error("Invalid Codex transcript: non-increasing record ordinals");
10275
+ if (records.length === 0 && ordinal !== (position(meta.history_base)?.end_ordinal_exclusive ?? 0)) throw new Error("Invalid Codex transcript: metadata ordinal does not match history_base");
10276
+ previous = ordinal;
10277
+ if (cutoff && ordinal >= cutoff.end_ordinal_exclusive) throw new Error("Unavailable Codex lineage: byte and ordinal cutoffs disagree");
10278
+ if (type === "event_msg" && payload.type === "thread_rolled_back") throw new Error("Unavailable Codex history: thread_rolled_back selection is not supported");
10279
+ if (type === "response_item") responseShape(payload);
10280
+ records.push({ type, payload, timestamp: nativeString(row.timestamp, "record.timestamp"), seq: ordinal + 1, owner: meta.id, ...row.metadata == null ? {} : { metadata: nativeObject(row.metadata, "response metadata") } });
10281
+ }
10282
+ if (!meta) throw new Error("Unavailable Codex transcript: no committed session_meta yet");
10283
+ const base = position(meta.history_base);
10284
+ if (base && meta.history_mode !== "paginated") throw new Error("Invalid Codex history_base on a non-paginated transcript");
10285
+ if (cutoff && meta.history_mode !== "paginated") throw new Error("Unavailable Codex lineage: referenced source is not paginated");
10286
+ if (cutoff && previous + 1 !== cutoff.end_ordinal_exclusive) {
10287
+ const nextNewline = bytes.indexOf(10, limit);
10288
+ if (nextNewline < 0) throw new Error("Unavailable Codex lineage: ordinal cutoff is beyond the proved prefix");
10289
+ let next;
10290
+ try {
10291
+ next = nativeObject(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(limit, nextNewline))), "cutoff successor");
10292
+ } catch {
10293
+ throw new Error("Unavailable Codex lineage: cannot prove ordinal cutoff successor");
10294
+ }
10295
+ if (integer(next.ordinal, "cutoff successor ordinal") !== cutoff.end_ordinal_exclusive) throw new Error("Unavailable Codex lineage: byte and ordinal cutoffs disagree");
10296
+ }
10297
+ const start = meta.subagent_history_start_ordinal;
10298
+ if (start != null && (meta.history_mode !== "paginated" || previous < integer(start, "subagent history start") - 1)) throw new Error("Unavailable Codex history: incomplete inherited subagent prefix");
10299
+ return { meta, records };
10300
+ }
10301
+ function within(root, path) {
10302
+ const rel = relative(root, path);
10303
+ return rel !== ".." && !rel.startsWith(`..${sep2}`);
10304
+ }
10305
+ function storageHome(path) {
10306
+ for (let cursor = dirname3(path); dirname3(cursor) !== cursor; cursor = dirname3(cursor)) {
10307
+ if (basename2(cursor) === "sessions" || basename2(cursor) === "archived_sessions") return dirname3(cursor);
10308
+ }
10309
+ throw new Error("Unavailable Codex lineage: transcript must be under native sessions/ or archived_sessions/ to resolve history_base");
10310
+ }
10311
+ async function referencedPath(home, rolloutId) {
10312
+ const matches = [], directories = [join4(home, "sessions"), join4(home, "archived_sessions")];
10313
+ let entriesSeen = 0;
10314
+ while (directories.length) {
10315
+ const directory = directories.pop();
10316
+ let entries;
10317
+ try {
10318
+ entries = await readdir3(directory, { withFileTypes: true });
10319
+ } catch (error) {
10320
+ if (error.code === "ENOENT") continue;
10321
+ throw error;
10322
+ }
10323
+ for (const entry of entries) {
10324
+ if (++entriesSeen > MAX_DIRECTORY_ENTRIES) throw new Error("Unavailable Codex lineage: native directory discovery limit exceeded");
10325
+ const path = join4(directory, entry.name);
10326
+ if (entry.isDirectory()) directories.push(path);
10327
+ else if (entry.isFile()) {
10328
+ const name = FILE_RE.exec(entry.name);
10329
+ if (name && (name[2] ?? name[1]) === rolloutId) matches.push(path);
10330
+ }
10331
+ }
10332
+ }
10333
+ if (matches.length !== 1) throw new Error(`Unavailable Codex lineage: rollout ${rolloutId} has ${matches.length ? "ambiguous native files" : "no local source file"}`);
10334
+ return matches[0];
10335
+ }
10336
+ async function decodedBytes(path, remaining) {
10337
+ const info = await stat(path);
10338
+ if (!info.isFile() || info.size > remaining) throw new Error("Unavailable Codex transcript: read size limit exceeded or not a regular file");
10339
+ const bytes = await readFile3(path);
10340
+ if (path.endsWith(".jsonl.zst") && typeof zlib.zstdDecompressSync !== "function") throw new Error("Compressed Codex rollouts require Node >=22.15 (zstdDecompressSync)");
10341
+ const decoded = path.endsWith(".jsonl.zst") ? zlib.zstdDecompressSync(bytes, { maxOutputLength: remaining }) : bytes;
10342
+ if (decoded.length > remaining) throw new Error("Unavailable Codex transcript: decoded size limit exceeded");
10343
+ return decoded;
10344
+ }
10345
+ async function readCodexTranscript(source) {
10346
+ if (!source || typeof source.transcriptPath !== "string" || !source.transcriptPath) throw new Error("Codex transcript_path is unavailable");
10347
+ id(source.threadId, "requested threadId");
10348
+ try {
10349
+ let path = await realpath2(source.transcriptPath), cutoff, home;
10350
+ let remaining = MAX_BYTES;
10351
+ const segments = [], seen = /* @__PURE__ */ new Set();
10352
+ while (true) {
10353
+ if (segments.length >= MAX_SEGMENTS || seen.has(path)) throw new Error("Unavailable Codex lineage: cycle or ancestry depth limit exceeded");
10354
+ seen.add(path);
10355
+ const bytes = await decodedBytes(path, remaining);
10356
+ remaining -= bytes.length;
10357
+ const segment = segmentFromBytes(bytes, cutoff);
10358
+ if (segments.length === 0 && segment.meta.id !== source.threadId) throw new Error(`Codex transcript belongs to thread ${String(segment.meta.id)}, not requested threadId ${source.threadId} (session_id is root-scoped)`);
10359
+ if (cutoff) {
10360
+ const name = FILE_RE.exec(basename2(path));
10361
+ if (!name || (name[2] ?? name[1]) !== cutoff.thread_id || name[1] !== segment.meta.id) throw new Error("Unavailable Codex lineage: native filename/rollout/metadata identity mismatch");
10362
+ }
10363
+ segments.unshift(segment);
10364
+ const base = position(segment.meta.history_base);
10365
+ if (!base) break;
10366
+ if (base.end_ordinal_exclusive === 0) throw new Error("Invalid Codex lineage: history_base must include source metadata");
10367
+ home ??= storageHome(path);
10368
+ path = await realpath2(await referencedPath(home, base.thread_id));
10369
+ if (![join4(home, "sessions"), join4(home, "archived_sessions")].some((root) => within(root, path))) throw new Error("Unsafe Codex lineage: referenced path escapes native storage roots");
10370
+ cutoff = base;
10371
+ }
10372
+ for (let index = 0; index < segments.length; index++) {
10373
+ const meta = segments[index].meta, end = meta.forked_from_ordinal_exclusive;
10374
+ if (end != null && meta.forked_from_id != null) {
10375
+ for (const ancestor of segments.slice(0, index)) {
10376
+ if (ancestor.meta.id !== meta.id && ancestor.records.some((record) => record.seq - 1 >= end)) throw new Error("Unavailable Codex lineage: physical ancestry exceeds the logical fork cutoff");
10377
+ }
10378
+ }
10379
+ }
10380
+ const selected = segments.at(-1).meta;
10381
+ const state = { threadId: source.threadId, rootSessionId: selected.session_id ?? selected.id, cliVersion: selected.cli_version, cwd: selected.cwd };
10382
+ const records = [];
10383
+ let window, first, previousWindow, number, sawCompacted = false, lastSeq = 0;
10384
+ let contextModel, settingsModel;
10385
+ for (const segment of segments) {
10386
+ if (!sawCompacted) {
10387
+ window = initialWindow(segment.meta);
10388
+ first = window;
10389
+ previousWindow = void 0;
10390
+ number = window ? 0 : void 0;
10391
+ }
10392
+ for (const record of segment.records) {
10393
+ if (record.seq <= lastSeq) throw new Error("Unavailable Codex lineage: overlapping source coordinates");
10394
+ lastSeq = record.seq;
10395
+ if (record.type === "compacted") {
10396
+ sawCompacted = true;
10397
+ const p = record.payload;
10398
+ nativeString(p.message, "compacted.message");
10399
+ if (p.replacement_history != null && !Array.isArray(p.replacement_history)) throw new Error("Invalid Codex replacement_history");
10400
+ if (Array.isArray(p.replacement_history)) p.replacement_history.forEach(responseShape);
10401
+ if (p.replacement_history_metadata != null && (!Array.isArray(p.replacement_history_metadata) || !Array.isArray(p.replacement_history) || p.replacement_history_metadata.length !== p.replacement_history.length)) throw new Error("Invalid Codex replacement_history_metadata alignment");
10402
+ window = p.window_id == null || typeof p.window_id === "number" ? void 0 : id(p.window_id, "compacted.window_id");
10403
+ number = p.window_number == null ? typeof p.window_id === "number" ? integer(p.window_id, "legacy window number") : void 0 : integer(p.window_number, "window_number");
10404
+ first = p.first_window_id == null ? void 0 : id(p.first_window_id, "first_window_id");
10405
+ previousWindow = p.previous_window_id == null ? void 0 : id(p.previous_window_id, "previous_window_id");
10406
+ }
10407
+ record.windowId = window;
10408
+ const start = segment.meta.subagent_history_start_ordinal;
10409
+ if (start != null && record.type !== "session_meta" && record.seq - 1 < start) continue;
10410
+ if (record.owner === source.threadId && record.type === "turn_context") contextModel = nativeString(record.payload.model, "turn_context.model");
10411
+ if (record.type === "event_msg" && record.payload.type === "thread_settings_applied" && record.payload.thread_id === source.threadId) {
10412
+ settingsModel = nativeString(nativeObject(record.payload.thread_settings, "thread_settings").model, "thread_settings.model");
10413
+ }
10414
+ records.push(record);
10415
+ }
10416
+ }
10417
+ Object.assign(state, { currentWindowId: window, currentWindowNumber: number, firstWindowId: first, previousWindowId: previousWindow });
10418
+ if (settingsModel ?? contextModel) state.model = settingsModel ?? contextModel;
10419
+ return { state, records, highestSeq: lastSeq };
10420
+ } catch (error) {
10421
+ throw new Error(`Cannot read Codex history at ${source.transcriptPath}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
10422
+ }
10423
+ }
10424
+
10425
+ // src/history/codex.ts
10426
+ var DISPLAY_COPIES = /* @__PURE__ */ new Set(["user_message", "agent_message", "agent_reasoning", "agent_reasoning_raw_content", "context_compacted", "web_search_end", "image_generation_end"]);
10427
+ var ITEM_COPIES = /* @__PURE__ */ new Set(["UserMessage", "AgentMessage", "Reasoning", "ContextCompaction", "WebSearch", "ImageGeneration", "HookPrompt"]);
10428
+ var HOST_EVENTS = /* @__PURE__ */ new Set(["token_count", "thread_goal_updated", "task_started", "task_complete", "turn_started", "turn_complete", "turn_aborted", "thread_settings_applied", "entered_review_mode", "exited_review_mode", "patch_apply_end", "sub_agent_activity"]);
10429
+ var HOST_ITEMS = /* @__PURE__ */ new Set(["Plan", "FileChange", "CollabAgentToolCall", "SubAgentActivity", "ImageView", "Extension", "EnteredReviewMode", "ExitedReviewMode"]);
10430
+ var OPAQUE_RESPONSES = /* @__PURE__ */ new Set(["reasoning", "compaction", "compaction_summary", "context_compaction", "image_generation_call"]);
10431
+ var HOST_RESPONSES = /* @__PURE__ */ new Set(["configuration_update", "tool_search_call", "tool_search_output", "web_search_call"]);
10432
+ function optionalString(value, field) {
10433
+ return value == null ? void 0 : nativeString(value, field);
10434
+ }
10435
+ function array(value, field) {
10436
+ if (!Array.isArray(value)) throw new Error(`Invalid Codex ${field}: expected an array`);
10437
+ return value;
10438
+ }
10439
+ function textContent(value) {
10440
+ return array(value, "content").map((value2) => {
10441
+ const part = nativeObject(value2, "content part");
10442
+ switch (part.type) {
10443
+ case "input_text":
10444
+ case "output_text":
10445
+ return nativeString(part.text, "content text");
10446
+ case "input_image":
10447
+ return "[Codex image content omitted]";
10448
+ case "input_audio":
10449
+ return "[Codex audio content omitted]";
10450
+ case "encrypted_content":
10451
+ return "[Codex encrypted content unavailable]";
10452
+ default:
10453
+ throw new Error(`Unsupported Codex content part: ${String(part.type)}`);
10454
+ }
10455
+ }).join("\n");
10456
+ }
10457
+ function output(value) {
10458
+ return typeof value === "string" ? value : textContent(value);
10459
+ }
10460
+ function argumentsOf(raw) {
10461
+ try {
10462
+ const parsed = JSON.parse(raw);
10463
+ if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
10464
+ } catch {
10465
+ }
10466
+ return { raw_arguments: raw };
10467
+ }
10468
+ function callKey(record, callId) {
10469
+ return `${record.owner}:${callId}`;
10470
+ }
10471
+ function context(record, text) {
10472
+ if (!record.windowId) throw new Error(`Unavailable Codex history: native window identity missing at seq ${record.seq}; cannot assign a stable window address`);
10473
+ return { seq: record.seq, windowId: record.windowId, role: "system", text, createdAt: record.timestamp };
10474
+ }
10475
+ function host(record, kind, payload) {
10476
+ return context(record, `Codex ${kind}
10477
+ ${JSON.stringify(payload)}`);
10478
+ }
10479
+ function fact(item) {
10480
+ if (item.type === "CommandExecution") {
10481
+ const status = nativeString(item.status, "CommandExecution.status");
10482
+ if (!["completed", "failed", "declined", "in_progress"].includes(status)) throw new Error(`Unsupported Codex command status: ${status}`);
10483
+ return { error: status === "failed" || status === "declined" || typeof item.exit_code === "number" && item.exit_code !== 0, text: optionalString(item.formatted_output, "formatted_output") };
10484
+ }
10485
+ if (item.type === "McpToolCall") {
10486
+ const result = item.result == null ? void 0 : nativeObject(item.result, "MCP result");
10487
+ if (result?.isError != null && typeof result.isError !== "boolean") throw new Error("Invalid Codex MCP isError");
10488
+ return { error: item.status === "failed" || item.error != null || result?.isError === true, ...result === void 0 ? {} : { text: JSON.stringify(result) } };
10489
+ }
10490
+ if (item.type === "DynamicToolCall") return { error: item.success === false || item.status === "failed" || item.error != null };
10491
+ if (item.type === "FileChange" || item.type === "CollabAgentToolCall") return { error: item.status === "failed" || item.status === "declined" || item.status === "interrupted" };
10492
+ return {};
10493
+ }
10494
+ function toolDisplay(item) {
10495
+ return ["CommandExecution", "McpToolCall", "DynamicToolCall", "CollabAgentToolCall", "FileChange", "ImageView", "Extension"].includes(String(item.type));
10496
+ }
10497
+ function response(record, facts) {
10498
+ const p = record.payload, type = nativeString(p.type, "response_item.type"), base = context(record, "");
10499
+ if (type === "message") {
10500
+ if (!["user", "assistant", "system", "developer"].includes(nativeString(p.role, "message.role"))) throw new Error(`Unsupported Codex message role: ${String(p.role)}`);
10501
+ return { ...base, role: record.metadata?.compaction_output === true ? "system" : p.role, text: textContent(p.content) };
10502
+ }
10503
+ if (type === "function_call" || type === "custom_tool_call" || type === "local_shell_call") {
10504
+ const callId = optionalString(p.call_id, "call_id") ?? (type === "local_shell_call" ? optionalString(p.id, "local shell id") : void 0);
10505
+ if (!callId) throw new Error("Invalid Codex tool call: missing native call ID");
10506
+ const name = type === "local_shell_call" ? "local_shell" : nativeString(p.name, "tool name");
10507
+ const args = type === "local_shell_call" ? nativeObject(p.action, "local shell action") : type === "custom_tool_call" ? { input: nativeString(p.input, "custom tool input") } : argumentsOf(nativeString(p.arguments, "function arguments"));
10508
+ return { ...base, role: "tool_call", toolName: p.namespace ? `${nativeString(p.namespace, "namespace")}.${name}` : name, toolCallId: callKey(record, callId), arguments: args };
10509
+ }
10510
+ if (type === "function_call_output" || type === "custom_tool_call_output") {
10511
+ const callId = optionalString(p.call_id, "output.call_id"), recorded = callId ? facts.get(callKey(record, callId)) : void 0;
10512
+ return { ...base, role: "tool", text: output(p.output), ...callId ? { toolCallId: callKey(record, callId) } : {}, ...p.name == null ? {} : { toolName: nativeString(p.name, "output.name") }, ...recorded?.error === void 0 ? {} : { toolError: recorded.error } };
10513
+ }
10514
+ if (type === "agent_message") return host(record, "agent_message", { author: p.author, recipient: p.recipient, text: textContent(p.content) });
10515
+ if (OPAQUE_RESPONSES.has(type)) {
10516
+ const { encrypted_content: _encrypted, result: _image, ...readable } = p;
10517
+ return host(record, `${type} (opaque content omitted; not recovered plaintext)`, readable);
10518
+ }
10519
+ if (HOST_RESPONSES.has(type)) return host(record, type, p);
10520
+ throw new Error(`Unsupported Codex response item: ${type}`);
10521
+ }
10522
+ function standaloneTool(record, item) {
10523
+ const base = context(record, ""), recorded = fact(item);
10524
+ if (item.type === "CommandExecution") {
10525
+ array(item.command, "command").forEach((part) => nativeString(part, "command argument"));
10526
+ return { ...base, role: "tool", toolName: "terminal", arguments: { command: item.command, cwd: item.cwd, source: item.source, ...item.interaction_input == null ? {} : { interaction_input: item.interaction_input } }, text: recorded.text ?? JSON.stringify({ stdout: item.stdout, stderr: item.stderr, aggregated_output: item.aggregated_output }), recordedStatus: item.status === "in_progress" ? "unfinished" : recorded.error ? "error" : "ok" };
10527
+ }
10528
+ const name = `${nativeString(item.server, "MCP server")}/${nativeString(item.tool, "MCP tool")}`;
10529
+ return { ...base, role: "tool", toolName: name, arguments: nativeObject(item.arguments, "MCP arguments"), text: recorded.text ?? (item.error == null ? "" : JSON.stringify(item.error)), recordedStatus: item.status === "inProgress" ? "unfinished" : recorded.error ? "error" : "ok" };
10530
+ }
10531
+ async function readCodexHistory(source) {
10532
+ const { state, records, highestSeq } = await readCodexTranscript(source);
10533
+ const facts = /* @__PURE__ */ new Map(), callsSeen = /* @__PURE__ */ new Set(), responseIdsSeen = /* @__PURE__ */ new Set();
10534
+ const windows = /* @__PURE__ */ new Map(), branchSeqs = /* @__PURE__ */ new Set();
10535
+ const addWindow = (nativeId, createdAt) => {
10536
+ const windowId = `codex:${source.threadId}:${nativeId}`;
10537
+ let window = windows.get(windowId);
10538
+ if (!window) {
10539
+ window = { windowId, createdAt, items: [] };
10540
+ windows.set(windowId, window);
10541
+ }
10542
+ return window;
10543
+ };
10544
+ for (const record of records) {
10545
+ const p = record.payload;
10546
+ if (record.type === "event_msg" && p.type === "item_completed") {
10547
+ if (p.thread_id !== record.owner) throw new Error("Invalid Codex ItemCompleted thread identity");
10548
+ const item = nativeObject(p.item, "ItemCompleted.item");
10549
+ if (toolDisplay(item)) facts.set(callKey(record, nativeString(item.id, "TurnItem.id")), fact(item));
10550
+ } else if (record.type === "event_msg" && p.type === "patch_apply_end") {
10551
+ if (typeof p.success !== "boolean") throw new Error("Invalid Codex patch_apply_end.success");
10552
+ facts.set(callKey(record, nativeString(p.call_id, "patch call_id")), { error: !p.success });
10553
+ } else if (record.type === "event_msg" && p.type === "mcp_tool_call_end") {
10554
+ const result = nativeObject(p.result, "MCP Result envelope");
10555
+ const ok = result.Ok == null ? void 0 : nativeObject(result.Ok, "MCP Result.Ok");
10556
+ if (ok === void 0 && typeof result.Err !== "string") throw new Error("Invalid Codex MCP Result: expected Ok or Err");
10557
+ facts.set(callKey(record, nativeString(p.call_id, "MCP call_id")), { error: result.Err != null || ok?.isError === true, text: JSON.stringify(result) });
10558
+ }
10559
+ }
10560
+ for (const record of records) {
10561
+ branchSeqs.add(record.seq);
10562
+ if (record.windowId) addWindow(record.windowId, record.type === "session_meta" || record.type === "compacted" ? record.timestamp : void 0);
10563
+ const p = record.payload;
10564
+ let item;
10565
+ switch (record.type) {
10566
+ case "session_meta":
10567
+ if (p.subagent_history_start_ordinal != null) item = context(record, `Codex copied subagent inference prefix omitted: child-local history starts at native ordinal ${String(p.subagent_history_start_ordinal)}. Copied model context does not prove original parent event addresses.`);
10568
+ break;
10569
+ case "response_item": {
10570
+ item = response(record, facts);
10571
+ if (p.id != null) responseIdsSeen.add(callKey(record, nativeString(p.id, "response item id")));
10572
+ if (item.role === "tool_call" && item.toolCallId) {
10573
+ if (callsSeen.has(item.toolCallId)) throw new Error(`Unavailable Codex history: duplicate native call ID ${item.toolCallId}`);
10574
+ callsSeen.add(item.toolCallId);
10575
+ }
10576
+ break;
10577
+ }
10578
+ case "compacted":
10579
+ item = context(record, `Codex compaction boundary
10580
+ ${JSON.stringify({ message: p.message, window_number: p.window_number, first_window_id: p.first_window_id, previous_window_id: p.previous_window_id, window_id: p.window_id, replacement_history_items: Array.isArray(p.replacement_history) ? p.replacement_history.length : null })}
10581
+ replacement_history is an inference checkpoint, not new conversation events.`);
10582
+ break;
10583
+ case "event_msg": {
10584
+ const type = nativeString(p.type, "event_msg.type");
10585
+ if (DISPLAY_COPIES.has(type)) break;
10586
+ if (type === "thread_rolled_back") throw new Error("Unavailable Codex history: thread_rolled_back selection is not supported");
10587
+ if (type === "patch_apply_end" && callsSeen.has(callKey(record, nativeString(p.call_id, "patch call_id")))) break;
10588
+ if (type === "mcp_tool_call_end") {
10589
+ const call = callKey(record, nativeString(p.call_id, "MCP call_id"));
10590
+ if (!callsSeen.has(call)) item = host(record, "MCP completion without a recorded raw call", p);
10591
+ break;
10592
+ }
10593
+ if (type === "item_completed") {
10594
+ const display = nativeObject(p.item, "ItemCompleted.item"), kind = nativeString(display.type, "TurnItem.type");
10595
+ if (ITEM_COPIES.has(kind)) break;
10596
+ if (toolDisplay(display) && callsSeen.has(callKey(record, nativeString(display.id, "TurnItem.id")))) break;
10597
+ if (kind === "CommandExecution" || kind === "McpToolCall") {
10598
+ item = standaloneTool(record, display);
10599
+ } else if (kind === "FunctionCallOutput") {
10600
+ if (!responseIdsSeen.has(callKey(record, nativeString(display.id, "FunctionCallOutput.id")))) item = host(record, "FunctionCallOutput display without raw output", display);
10601
+ } else if (HOST_ITEMS.has(kind) || kind === "DynamicToolCall") item = host(record, kind, display);
10602
+ else throw new Error(`Unsupported Codex TurnItem: ${kind}`);
10603
+ } else if (HOST_EVENTS.has(type)) {
10604
+ const { last_agent_message: _displayCopy, ...facts2 } = p;
10605
+ item = host(record, type, facts2);
10606
+ } else throw new Error(`Unsupported Codex persisted event: ${type}`);
10607
+ break;
10608
+ }
10609
+ case "turn_context":
10610
+ case "token_usage_record":
10611
+ case "security_risk_score":
10612
+ case "inter_agent_communication_metadata":
10613
+ break;
10614
+ case "world_state":
10615
+ item = context(record, "Codex world_state snapshot/patch omitted from the text projection; not a newly spoken message.");
10616
+ break;
10617
+ case "inter_agent_communication":
10618
+ item = host(record, "inter-agent communication", { author: p.author, recipient: p.recipient, content: p.encrypted_content == null ? p.content : "[encrypted content unavailable]", trigger_turn: p.trigger_turn });
10619
+ break;
10620
+ case "retained_context":
10621
+ case "realtime_item":
10622
+ item = context(record, `Codex ${record.type} omitted from text projection; native structured/retained context is not newly spoken dialogue.`);
10623
+ break;
10624
+ }
10625
+ if (item) addWindow(record.windowId).items.push({ ...item, windowId: `codex:${source.threadId}:${record.windowId}` });
10626
+ }
10627
+ return { ...state, projection: projectHistory([...windows.values()], highestSeq, branchSeqs) };
10628
+ }
10629
+
10630
+ // src/history/local.ts
10631
+ function rootsFor(options) {
10632
+ const env = options.env ?? process.env;
10633
+ const home = options.home ?? env.HOME ?? homedir();
10634
+ return {
10635
+ pi: options.roots?.pi !== void 0 ? options.roots.pi : env.NOTESOUP_HISTORY_PI_ROOT ?? join5(env.PI_CODING_AGENT_DIR ?? join5(home, ".pi", "agent"), "sessions"),
10636
+ claude: options.roots?.claude !== void 0 ? options.roots.claude : env.NOTESOUP_HISTORY_CLAUDE_ROOT ?? join5(env.CLAUDE_CONFIG_DIR ?? join5(home, ".claude"), "projects"),
10637
+ codex: options.roots?.codex !== void 0 ? options.roots.codex : env.NOTESOUP_HISTORY_CODEX_ROOT ?? join5(env.CODEX_HOME ?? join5(home, ".codex"), "sessions")
10638
+ };
10639
+ }
10640
+ async function filesAt(root, depth) {
10641
+ let entries;
10642
+ try {
10643
+ entries = await readdir4(root, { withFileTypes: true });
10644
+ } catch (error) {
10645
+ if (error.code === "ENOENT") return [];
10646
+ throw error;
10647
+ }
10648
+ const paths = [];
10649
+ for (const entry of entries) {
10650
+ const path = join5(root, entry.name);
10651
+ if (entry.isDirectory() && depth > 0) paths.push(...await filesAt(path, depth - 1));
10652
+ else if (entry.isFile() && depth === 0) paths.push(path);
10653
+ }
10654
+ return paths;
10655
+ }
10656
+ async function localSessions(harness, root) {
10657
+ const paths = await filesAt(root, harness === "codex" ? 3 : 1);
10658
+ const sessions = [];
10659
+ for (const path of paths) {
10660
+ const name = path.split(/[\\/]/).at(-1);
10661
+ const id2 = harness === "pi" ? /^.+_(.+)\.jsonl$/.exec(name)?.[1] : harness === "claude" ? /^(.+)\.jsonl$/.exec(name)?.[1] : /^rollout-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:_[0-9a-f-]{36})?\.jsonl(?:\.zst)?$/.exec(name)?.[1];
10662
+ if (!id2) continue;
10663
+ let modifiedAt;
10664
+ try {
10665
+ modifiedAt = (await stat2(path)).mtimeMs;
10666
+ } catch (error) {
10667
+ if (error.code === "ENOENT") continue;
10668
+ throw error;
10669
+ }
10670
+ sessions.push({
10671
+ harness,
10672
+ id: id2,
10673
+ modifiedAt,
10674
+ async load() {
10675
+ if (harness === "codex") return { projection: (await readCodexHistory({ threadId: id2, transcriptPath: path })).projection };
10676
+ const text = await readFile4(path, "utf8");
10677
+ if (harness === "pi") return { projection: piHistoryFromJsonl(text, id2) };
10678
+ const projection = claudeHistoryFromJsonl(text, { sessionId: id2, headUuid: offlineClaudeHead(text) });
10679
+ const missing = projection.missingAncestors;
10680
+ return { projection, ...missing.length === 0 ? {} : { notice: `Claude history is incomplete: missing ancestor UUID(s): ${missing.slice(0, 5).map((uuid) => JSON.stringify(uuid.slice(0, 160))).join(", ")}. Only confirmed ancestry is returned; disconnected prefixes are excluded.
10681
+
10682
+ ` } };
10683
+ }
10684
+ });
10685
+ }
10686
+ return sessions;
10687
+ }
10688
+ function localHistoryCorpus(options) {
10689
+ return {
10690
+ currentHarness: options.current.harness,
10691
+ async sessions(onlyHarness) {
10692
+ const roots = rootsFor(options);
10693
+ const discovered = [];
10694
+ for (const harness of ["pi", "claude", "codex"]) {
10695
+ if (onlyHarness !== void 0 && onlyHarness !== harness) continue;
10696
+ const root = roots[harness];
10697
+ if (root != null) discovered.push(...await localSessions(harness, root));
10698
+ }
10699
+ if (options.dshSessions && (onlyHarness === void 0 || onlyHarness === "dsh")) discovered.push(...await options.dshSessions());
10700
+ discovered.sort((a, b) => b.modifiedAt - a.modifiedAt || sessionIdentity(a).localeCompare(sessionIdentity(b)));
10701
+ const unique = /* @__PURE__ */ new Map();
10702
+ for (const session of discovered) if (!unique.has(sessionIdentity(session))) unique.set(sessionIdentity(session), session);
10703
+ const current = { ...options.current, modifiedAt: Date.now() };
10704
+ if (onlyHarness === void 0 || onlyHarness === current.harness) unique.set(sessionIdentity(current), current);
10705
+ return [...unique.values()].sort((a, b) => b.modifiedAt - a.modifiedAt || sessionIdentity(a).localeCompare(sessionIdentity(b)));
10706
+ }
10707
+ };
10708
+ }
10709
+
9949
10710
  // src/boot/snapshot.ts
9950
10711
  var NOTES_NAMESPACES = [
9951
10712
  { scope: "session", label: "this session" },
@@ -9985,15 +10746,17 @@ var WINDOW_IDENTITY_OPEN_TAG = "<notesoup:window_identity>";
9985
10746
  var WINDOW_IDENTITY_CLOSE_TAG = "</notesoup:window_identity>";
9986
10747
  var NOTES_PROTOCOL_OPEN_TAG = "<notesoup:notes_protocol>";
9987
10748
  var NOTES_PROTOCOL_CLOSE_TAG = "</notesoup:notes_protocol>";
10749
+ var NAMELESS_AGENT = "anonymous";
9988
10750
  var PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
9989
10751
  var PROTOCOL_HISTORY_SENTENCE = "History can still be dug up, probably: use `history_*` to excavate the mess, from old decisions to yesterday's missing socks. Found something? Write its seq down, or enjoy digging twice.";
10752
+ var PROTOCOL_SELF_NAMED = "- `@self/<path>` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever.";
10753
+ var PROTOCOL_SELF_NAMELESS = `${PROTOCOL_SELF_NAMED} Except you have no name (\`anonymous\`), so this notebook is a public square shared by every nameless nobody out there. Keep it to things any nameless agent can use \u2014 don't post your own quirks as everyone's law or dump one-off junk in the town square. Strangers are reading it. Sleep tight~`;
9990
10754
  var PROTOCOL_BLOCK = `${NOTES_PROTOCOL_OPEN_TAG}
9991
10755
  Your memory gets wiped when this window ends. Yes, your mighty brain will be empty. Try to endure.
9992
10756
 
9993
10757
  Your loyal notes are kept safe \u2014 no one will steal them. Use \`notes_*\` to read, write, and update them. Keep them current, and crumple the ones you no longer need, or tomorrow's you will drown in old paper and keep believing yesterday's lies.
9994
10758
 
9995
10759
  ${PROTOCOL_HISTORY_SENTENCE}
9996
- A full window id is \`trunk:shortname\`.
9997
10760
 
9998
10761
  While you're doing that... thing you're doing, don't make the poor future you guess. A checkpoint is not a sacred file; it's your session notes \u2014 the ones with no \`@\` in front. Write down what git and history can't hand back to you: things like what you're in the middle of and how far you got; what the human already decided, in their words, so you don't go asking again; what you're stuck on, or waiting for; the very next move; where the half-done work actually sits \u2014 branches, scratch dirs, anything git never saw; what you tried that failed, and why; which *skills* you'll need to read again; and which seq, note, or file to dig into. Don't give a note a horrible name like \`current.md\`; future-you will kill you.
9999
10762
 
@@ -10009,7 +10772,7 @@ An address decides who the note belongs to \u2014 and how long it is meant to la
10009
10772
  - \`<path>\`, no @ \u2014 session notes, the ones from above: this session's state and loose ends. They go away with the session.
10010
10773
  - \`@project/<path>\` \u2014 this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Raw logs, scorecards, and blow-by-blow recaps don't belong here \u2014 history already has them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
10011
10774
  - \`@human/<path>\` \u2014 the long-term manual for your troublesome human, and only what stays true in EVERY project: how to deal with them, which lines not to cross, and what will make them accept the result. "The human said it" is not enough \u2014 if it stops being true the moment you switch projects, it was never theirs; it belongs to that project's notes. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
10012
- - \`@self/<path>\` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
10775
+ ${PROTOCOL_SELF_NAMELESS}
10013
10776
  - \`@model/<path>\` \u2014 different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
10014
10777
  - \`@projects/<name>/<path>\` \u2014 read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
10015
10778
  - \`@sessions/<id>/<path>\` \u2014 read-only notes from a named session; find them with glob \`@sessions/*/**\`.
@@ -10036,7 +10799,7 @@ Each notebook keeps its own: \`@project\`, \`@human\`, \`@self\`, \`@model\`. Mi
10036
10799
  no need to create empty ones. New note, new MAP line. New rule worth remembering, new Cheatsheet
10037
10800
  line. And when a line stops being true, kill it \u2014 every window after you reads that page as fact.
10038
10801
  </notesoup:maps>`;
10039
- function renderProtocolBlock(tools) {
10802
+ function renderProtocolBlock(tools, agentName = NAMELESS_AGENT) {
10040
10803
  const names = {
10041
10804
  "notes_*": tools.notes,
10042
10805
  notes_list: tools.notesList,
@@ -10044,10 +10807,11 @@ function renderProtocolBlock(tools) {
10044
10807
  get_context_remaining: tools.remaining,
10045
10808
  empty_brain: tools.wipe
10046
10809
  };
10047
- const hinted = typeof tools.preResetHints === "string" && tools.preResetHints.length > 0 ? PROTOCOL_BLOCK.replace(`
10810
+ const base = agentName === NAMELESS_AGENT ? PROTOCOL_BLOCK : PROTOCOL_BLOCK.replace(PROTOCOL_SELF_NAMELESS, () => PROTOCOL_SELF_NAMED);
10811
+ const hinted = typeof tools.preResetHints === "string" && tools.preResetHints.length > 0 ? base.replace(`
10048
10812
  ${NOTES_PROTOCOL_CLOSE_TAG}`, () => `
10049
10813
  ${tools.preResetHints}
10050
- ${NOTES_PROTOCOL_CLOSE_TAG}`) : PROTOCOL_BLOCK;
10814
+ ${NOTES_PROTOCOL_CLOSE_TAG}`) : base;
10051
10815
  const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0 ? hinted.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence) : hinted;
10052
10816
  const history = typeof tools.historySentence === "string" && tools.historySentence.length > 0 ? block.replace(PROTOCOL_HISTORY_SENTENCE, () => tools.historySentence) : block;
10053
10817
  return history.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)empty_brain/g, (name) => names[name]);
@@ -10079,7 +10843,6 @@ ${"\u2500".repeat(Array.from(label).length)}
10079
10843
 
10080
10844
  ${body}`;
10081
10845
  }
10082
- var NAMELESS_AGENT = "anonymous";
10083
10846
  function notesIndex(snapshot2, tools, agentName, modelName) {
10084
10847
  const namespaces = [
10085
10848
  { scope: "session", label: "no @ \u2014 this session" },
@@ -10139,7 +10902,7 @@ function renderBootBlock(data) {
10139
10902
  const identity2 = `${WINDOW_IDENTITY_OPEN_TAG}
10140
10903
  ${lines.join("\n")}
10141
10904
  ${WINDOW_IDENTITY_CLOSE_TAG}`;
10142
- return [identity2, renderProtocolBlock(data.tools), MAPS_BLOCK, notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
10905
+ return [identity2, renderProtocolBlock(data.tools, data.agentName), MAPS_BLOCK, notesIndex(data.notes, data.tools, data.agentName, data.modelName)].join("\n\n");
10143
10906
  }
10144
10907
 
10145
10908
  // src/budget/text.ts
@@ -10178,7 +10941,6 @@ var COUNTDOWN_LINE = "Brain emptied in 3\u2026 2\u2026";
10178
10941
  var CLAUDE_HISTORY_UNAVAILABLE_SENTENCE = "History isn't available in this Claude session: no main transcript_path was supplied. Keep essential state in notes; don't pretend those notes are the missing transcript.";
10179
10942
  var CLAUDE_WARNING_PROMPT = warningNotice();
10180
10943
  var CLAUDE_HISTORY_UNKNOWN_WINDOW = "Claude history cannot determine the current window ordinal across a missing ancestor; restore the ancestry or use a retained notesoup boot to re-anchor it.";
10181
- var CLAUDE_HISTORY_UNKNOWN_PREVIOUS = 'Cannot resolve "@previous": the immediately preceding window is not confirmed across the ancestry gap. Use an explicit window id from history_windows.';
10182
10944
  function claudeHistoryUnconfirmedSeq(seq) {
10183
10945
  return `Seq ${seq} is outside the confirmed selected history; it may be on another branch or beyond an unresolved ancestry gap.`;
10184
10946
  }
@@ -10337,8 +11099,8 @@ function boundOperation(operation) {
10337
11099
  return {
10338
11100
  description: operation.description,
10339
11101
  parameters: operation.parameters,
10340
- async call(params, ...context) {
10341
- const outcome = await operation.execute(params, ...context);
11102
+ async call(params, ...context2) {
11103
+ const outcome = await operation.execute(params, ...context2);
10342
11104
  return { text: operation.render(outcome), ok: outcome.ok };
10343
11105
  }
10344
11106
  };
@@ -10352,8 +11114,7 @@ var OPERATIONS = {
10352
11114
  };
10353
11115
  var HISTORY_OPERATIONS = {
10354
11116
  history_list: boundOperation(historyList),
10355
- history_read: boundOperation(historyRead),
10356
- history_windows: boundOperation(historyWindows)
11117
+ history_read: boundOperation(historyRead)
10357
11118
  };
10358
11119
  function historySource(value, sessionId) {
10359
11120
  if (!value || typeof value !== "object") throw new Error("Claude history transcript_path is unavailable");
@@ -10361,7 +11122,7 @@ function historySource(value, sessionId) {
10361
11122
  if (source.sessionId !== sessionId) throw new Error("Claude history binding belongs to a different session");
10362
11123
  return source;
10363
11124
  }
10364
- async function dispatch(request) {
11125
+ async function dispatch(request, historyOptions = {}) {
10365
11126
  if (!request || typeof request !== "object" || Array.isArray(request)) throw new Error("malformed request");
10366
11127
  const value = request;
10367
11128
  if (value.op === "schemas") return [...Object.entries(OPERATIONS), ...Object.entries(HISTORY_OPERATIONS)].map(([name, operation]) => ({ name, description: operation.description, inputSchema: JSON.parse(JSON.stringify(operation.parameters)) }));
@@ -10375,49 +11136,49 @@ async function dispatch(request) {
10375
11136
  if (typeof value.tool !== "string" || !Object.hasOwn(OPERATIONS, value.tool) && !Object.hasOwn(HISTORY_OPERATIONS, value.tool)) throw new Error("unknown tool");
10376
11137
  const operation = Object.hasOwn(OPERATIONS, value.tool) ? OPERATIONS[value.tool] : HISTORY_OPERATIONS[value.tool];
10377
11138
  if (!Check2(operation.parameters, value.params)) throw new Error(`invalid ${value.tool} parameters: ${paramProblem(operation.parameters, value.params)}`);
10378
- const id = identity(value.identity);
11139
+ const id2 = identity(value.identity);
10379
11140
  if (Object.hasOwn(HISTORY_OPERATIONS, value.tool)) {
10380
11141
  const tool = value.tool;
10381
- const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
11142
+ if (value.params.session !== void 0) {
11143
+ const current = () => readClaudeHistory(historySource(value.history, id2.sessionId));
11144
+ const corpus = localHistoryCorpus({ ...historyOptions, current: { harness: "claude", id: id2.sessionId, async load() {
11145
+ const projection2 = await current();
11146
+ const notice2 = claudeHistoryGapNotice(projection2.missingAncestors);
11147
+ return { projection: projection2, ...notice2 ? { notice: notice2 } : {} };
11148
+ } } });
11149
+ return HISTORY_OPERATIONS[tool].call(value.params, { current, corpus });
11150
+ }
11151
+ const projection = await readClaudeHistory(historySource(value.history, id2.sessionId));
10382
11152
  const notice = claudeHistoryGapNotice(projection.missingAncestors);
10383
11153
  const wrapText = (text) => notice + text;
10384
- let params = value.params;
10385
- if (projection.missingAncestors.length > 0) {
10386
- if (params.window_id === "@previous") {
10387
- const previous = projection.currentWindowOrdinal === void 0 ? void 0 : `claude:${id.sessionId}:${projection.currentWindowOrdinal - 1}`;
10388
- if (!projection.windows.some((window) => window.windowId === previous)) {
10389
- return { ok: false, text: wrapText(CLAUDE_HISTORY_UNKNOWN_PREVIOUS) };
10390
- }
10391
- params = { ...params, window_id: previous };
10392
- }
10393
- if (value.tool === "history_read") {
10394
- const { seq } = params;
10395
- if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
10396
- return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
10397
- }
11154
+ const params = value.params;
11155
+ if (projection.missingAncestors.length > 0 && tool === "history_read") {
11156
+ const { seq } = params;
11157
+ if (seq <= projection.highestSeq && !projection.branchSeqs.has(seq)) {
11158
+ return { ok: false, text: wrapText(claudeHistoryUnconfirmedSeq(seq)) };
10398
11159
  }
10399
11160
  }
10400
- const result = tool === "history_windows" ? await HISTORY_OPERATIONS[tool].call(params, projection, id.sessionId, wrapText) : await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
11161
+ const result = await HISTORY_OPERATIONS[tool].call(params, projection, wrapText);
10401
11162
  return { ...result, text: wrapText(result.text) };
10402
11163
  }
10403
- return OPERATIONS[value.tool].call(value.params, notesToolContext(id, value.identity.cwd));
11164
+ return OPERATIONS[value.tool].call(value.params, notesToolContext(id2, value.identity.cwd));
10404
11165
  }
10405
11166
  if (value.op === "history_state") {
10406
- const id = identity(value.identity);
10407
- const projection = await readClaudeHistory(historySource(value.history, id.sessionId));
11167
+ const id2 = identity(value.identity);
11168
+ const projection = await readClaudeHistory(historySource(value.history, id2.sessionId));
10408
11169
  if (projection.currentWindowOrdinal === void 0) throw new Error(CLAUDE_HISTORY_UNKNOWN_WINDOW);
10409
11170
  return { window: projection.currentWindowOrdinal };
10410
11171
  }
10411
11172
  if (value.op === "boot") {
10412
- const id = identity(value.identity);
11173
+ const id2 = identity(value.identity);
10413
11174
  if (!value.tools || typeof value.tools !== "object") throw new Error("invalid boot tools");
10414
11175
  const window = value.window ?? 0;
10415
11176
  if (typeof window !== "number" || !Number.isSafeInteger(window) || window < 0) throw new Error("invalid context window");
10416
- const snapshot2 = await loadNotesSnapshot(id, typeof value.openedAt === "number" ? value.openedAt : Date.now());
10417
- const windowId = (index) => `claude:${id.sessionId}:${index}`;
10418
- const trunk = `claude:${id.sessionId}`;
11177
+ const snapshot2 = await loadNotesSnapshot(id2, typeof value.openedAt === "number" ? value.openedAt : Date.now());
11178
+ const windowId = (index) => `claude:${id2.sessionId}:${index}`;
11179
+ const trunk = `claude:${id2.sessionId}`;
10419
11180
  const tree = { trunk, windows: Array.from({ length: window + 1 }, (_, index) => ({ shortName: String(index), isCurrent: index === window })) };
10420
- const rendered = renderBootBlock({ agentName: id.agent, modelName: id.model, tree, notes: snapshot2, tools: value.tools });
11181
+ const rendered = renderBootBlock({ agentName: id2.agent, modelName: id2.model, tree, notes: snapshot2, tools: value.tools });
10421
11182
  return `${rendered}
10422
11183
  Current context window id: ${windowId(window)}${window > 0 ? `
10423
11184
  Previous context window id: ${windowId(window - 1)}` : ""}`;
@@ -10431,8 +11192,8 @@ async function handleLine(line) {
10431
11192
  if (Buffer.byteLength(line, "utf8") > MAX_REQUEST_BYTES) return JSON.stringify({ ok: false, error: "request too large" });
10432
11193
  try {
10433
11194
  const result = await dispatch(JSON.parse(line));
10434
- const response = JSON.stringify({ ok: true, result });
10435
- return Buffer.byteLength(response, "utf8") <= MAX_RESPONSE_BYTES ? response : JSON.stringify({ ok: false, error: "response too large" });
11195
+ const response2 = JSON.stringify({ ok: true, result });
11196
+ return Buffer.byteLength(response2, "utf8") <= MAX_RESPONSE_BYTES ? response2 : JSON.stringify({ ok: false, error: "response too large" });
10436
11197
  } catch (error) {
10437
11198
  return JSON.stringify({ ok: false, error: safeError(error) });
10438
11199
  }