@effect-agent/ai-typesafe 0.1.0-beta.102 → 0.1.0-beta.103

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TypeSafeSchema.mjs","names":[],"sources":["../src/TypeSafeSchema.ts"],"sourcesContent":["/**\n * Request and response schemas for TypeSafe's System One HTTP API.\n *\n * @since 0.1.0\n */\nimport * as Schema from \"effect/Schema\";\n\n/**\n * Text or JSON objects and arrays used as state and question instructions.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Content = Schema.Union([Schema.String, Schema.JsonObject, Schema.Array(Schema.Json)]);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Content = typeof Content.Type;\n\n/**\n * A choice between named options. A null rubric uses the option name alone.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ChoiceQuestion = Schema.Struct({\n type: Schema.Literal(\"choice\"),\n instructions: Content,\n criteria: Schema.Record(Schema.String, Schema.NullOr(Schema.String)).check(\n Schema.isMinProperties(1),\n ),\n});\n\n/** @category models\n * @since 0.1.0\n */\nexport type ChoiceQuestion = typeof ChoiceQuestion.Type;\n\n/**\n * A rating along at least two ordered, zero-indexed level descriptions.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ScoreQuestion = Schema.Struct({\n type: Schema.Literal(\"score\"),\n instructions: Content,\n criteria: Schema.Array(Schema.String).check(Schema.isMinLength(2)),\n});\n\n/** @category models\n * @since 0.1.0\n */\nexport type ScoreQuestion = typeof ScoreQuestion.Type;\n\n/**\n * A yes/no judgment, with optional descriptions of either outcome.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const NoulQuestion = Schema.Struct({\n type: Schema.Literal(\"noul\"),\n instructions: Content,\n criteria: Schema.optionalKey(\n Schema.Struct({\n true: Schema.optionalKey(Schema.String),\n false: Schema.optionalKey(Schema.String),\n }),\n ),\n});\n\n/** @category models\n * @since 0.1.0\n */\nexport type NoulQuestion = typeof NoulQuestion.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Question = Schema.Union([ChoiceQuestion, ScoreQuestion, NoulQuestion]);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Question = typeof Question.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Questions = Schema.Record(Schema.String, Question);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Questions = typeof Questions.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const EvaluateRequest = Schema.Struct({\n model: Schema.String,\n state: Content,\n questions: Questions,\n});\n\n/**\n * Evaluation input. Keep question literals with `satisfies Questions` when\n * storing questions separately from the call to `evaluate`.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EvaluateRequest<Q extends Questions = Questions> = Omit<\n typeof EvaluateRequest.Type,\n \"questions\"\n> & { readonly questions: Q };\n\n/**\n * A finite probability or confidence in the inclusive range [0, 1].\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));\n\n/**\n * A selected option and its full distribution. Confidence summarizes the\n * distribution; it does not guarantee correctness.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ChoiceAnswer = Schema.Struct({\n type: Schema.Literal(\"choice\"),\n choice: Schema.String,\n probabilities: Schema.Record(Schema.String, Probability),\n confidence: Probability,\n});\n\n/**\n * Known option unions infer literal choices and required probability keys.\n * Open string or template-pattern option types allow absent dictionary entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ChoiceAnswer<Choice extends string = string> = Omit<\n typeof ChoiceAnswer.Type,\n \"choice\" | \"probabilities\"\n> & {\n readonly choice: Choice;\n readonly probabilities: {\n readonly [K in Choice]: {} extends Pick<Record<Choice, unknown>, K>\n ? number | undefined\n : number;\n };\n};\n\n/**\n * A fractional, probability-weighted level, with the supplied rubric as legend.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ScoreAnswer = Schema.Struct({\n type: Schema.Literal(\"score\"),\n score: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)),\n legend: Schema.Record(Schema.String, Schema.String),\n probabilities: Schema.Record(Schema.String, Probability),\n confidence: Probability,\n});\n\n/**\n * Score levels are keyed at runtime; an arbitrary legend or probability lookup\n * may be absent.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ScoreAnswer = Omit<typeof ScoreAnswer.Type, \"legend\" | \"probabilities\"> & {\n readonly legend: { readonly [level: string]: string | undefined };\n readonly probabilities: { readonly [level: string]: number | undefined };\n};\n\n/**\n * The probability of yes. Noul has no separate confidence field.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const NoulAnswer = Schema.Struct({ type: Schema.Literal(\"noul\"), noul: Probability });\n\n/** @category models\n * @since 0.1.0\n */\nexport type NoulAnswer = typeof NoulAnswer.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Answer = Schema.Union([ChoiceAnswer, ScoreAnswer, NoulAnswer]);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Answer = ChoiceAnswer | ScoreAnswer | NoulAnswer;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Usage = Schema.Struct({ input_tokens: Schema.Natural, output_tokens: Schema.Natural });\n\n/** @category models\n * @since 0.1.0\n */\nexport type Usage = typeof Usage.Type;\n\n/**\n * The wire response shape. `TypeSafeClient.evaluate` additionally validates\n * answer IDs, question kinds, criteria, distributions, and score correlations.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const EvaluateResponse = Schema.Struct({\n model: Schema.String,\n answers: Schema.Record(Schema.String, Answer),\n usage: Usage,\n});\n\ntype ChoiceAnswerFor<Criteria> = Criteria extends unknown\n ? Omit<typeof ChoiceAnswer.Type, \"choice\" | \"probabilities\"> & {\n readonly choice: `${Extract<keyof Criteria, string | number>}`;\n readonly probabilities: {\n readonly [\n K in keyof Criteria as K extends string | number ? `${K}` : never\n ]: {} extends Pick<Criteria, K> ? number | undefined : number;\n };\n }\n : never;\n\n/**\n * Infer a question's answer, preserving optional choice criteria in its probabilities.\n *\n * @category models\n * @since 0.1.0\n */\nexport type AnswerFor<Q extends Question> = Q extends ChoiceQuestion\n ? ChoiceAnswerFor<Q[\"criteria\"]>\n : Q extends ScoreQuestion\n ? ScoreAnswer\n : NoulAnswer;\n\n/**\n * One answer for each required question. Optional properties and open string,\n * numeric, or template-pattern indexes require checking an entry for absence.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Answers<Q extends Questions> = {\n readonly [K in keyof Q as K extends string | number ? `${K}` : never]: {} extends Pick<Q, K>\n ? AnswerFor<NonNullable<Q[K]>> | undefined\n : AnswerFor<Q[K]>;\n};\n\n/** @category models\n * @since 0.1.0\n */\nexport type EvaluateResponse<Q extends Questions = Questions> = Omit<\n typeof EvaluateResponse.Type,\n \"answers\"\n> & { readonly answers: Answers<Q> };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAa,UAAU,OAAO,MAAM;CAAC,OAAO;CAAQ,OAAO;CAAY,OAAO,MAAM,OAAO,IAAI;AAAC,CAAC;;;;;;;AAajG,MAAa,iBAAiB,OAAO,OAAO;CAC1C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,cAAc;CACd,UAAU,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,MACnE,OAAO,gBAAgB,CAAC,CAC1B;AACF,CAAC;;;;;;;AAaD,MAAa,gBAAgB,OAAO,OAAO;CACzC,MAAM,OAAO,QAAQ,OAAO;CAC5B,cAAc;CACd,UAAU,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AACnE,CAAC;;;;;;;AAaD,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,MAAM;CAC3B,cAAc;CACd,UAAU,OAAO,YACf,OAAO,OAAO;EACZ,MAAM,OAAO,YAAY,OAAO,MAAM;EACtC,OAAO,OAAO,YAAY,OAAO,MAAM;CACzC,CAAC,CACH;AACF,CAAC;;;;AAUD,MAAa,WAAW,OAAO,MAAM;CAAC;CAAgB;CAAe;AAAY,CAAC;;;;AAUlF,MAAa,YAAY,OAAO,OAAO,OAAO,QAAQ,QAAQ;;;;AAU9D,MAAa,kBAAkB,OAAO,OAAO;CAC3C,OAAO,OAAO;CACd,OAAO;CACP,WAAW;AACb,CAAC;;;;;;;AAoBD,MAAa,cAAc,OAAO,OAAO,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAAE,CAAC,CAAC;;;;;;;;AAS3F,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,QAAQ;CAC7B,QAAQ,OAAO;CACf,eAAe,OAAO,OAAO,OAAO,QAAQ,WAAW;CACvD,YAAY;AACd,CAAC;;;;;;;AA2BD,MAAa,cAAc,OAAO,OAAO;CACvC,MAAM,OAAO,QAAQ,OAAO;CAC5B,OAAO,OAAO,OAAO,MAAM,OAAO,uBAAuB,CAAC,CAAC;CAC3D,QAAQ,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM;CAClD,eAAe,OAAO,OAAO,OAAO,QAAQ,WAAW;CACvD,YAAY;AACd,CAAC;;;;;;;AAoBD,MAAa,aAAa,OAAO,OAAO;CAAE,MAAM,OAAO,QAAQ,MAAM;CAAG,MAAM;AAAY,CAAC;;;;AAU3F,MAAa,SAAS,OAAO,MAAM;CAAC;CAAc;CAAa;AAAU,CAAC;;;;AAU1E,MAAa,QAAQ,OAAO,OAAO;CAAE,cAAc,OAAO;CAAS,eAAe,OAAO;AAAQ,CAAC;;;;;;;;AAclG,MAAa,mBAAmB,OAAO,OAAO;CAC5C,OAAO,OAAO;CACd,SAAS,OAAO,OAAO,OAAO,QAAQ,MAAM;CAC5C,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"TypeSafeSchema.mjs","names":[],"sources":["../src/TypeSafeSchema.ts"],"sourcesContent":["/**\n * Request and response schemas for TypeSafe's System One HTTP API.\n *\n * @since 0.1.0\n */\nimport { DecisionSchema } from \"@effect-agent/ai-decision\";\nimport * as Schema from \"effect/Schema\";\n\n/**\n * Text or JSON objects and arrays used as state and question instructions.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Content = DecisionSchema.Content;\n\n/** @category models\n * @since 0.1.0\n */\nexport type Content = typeof Content.Type;\n\n/**\n * A choice between named options. A null rubric uses the option name alone.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ChoiceQuestion = DecisionSchema.ChoiceQuestion;\n\n/** @category models\n * @since 0.1.0\n */\nexport type ChoiceQuestion = typeof ChoiceQuestion.Type;\n\n/**\n * A rating along at least two ordered, zero-indexed level descriptions.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ScoreQuestion = DecisionSchema.ScoreQuestion;\n\n/** @category models\n * @since 0.1.0\n */\nexport type ScoreQuestion = typeof ScoreQuestion.Type;\n\n/**\n * A yes/no judgment, with optional descriptions of either outcome.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const NoulQuestion = Schema.Struct({\n type: Schema.Literal(\"noul\"),\n instructions: Content,\n criteria: Schema.optionalKey(\n Schema.Struct({\n true: Schema.optionalKey(Schema.String),\n false: Schema.optionalKey(Schema.String),\n }),\n ),\n});\n\n/** @category models\n * @since 0.1.0\n */\nexport type NoulQuestion = typeof NoulQuestion.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Question = Schema.Union([ChoiceQuestion, ScoreQuestion, NoulQuestion]);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Question = typeof Question.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Questions = Schema.Record(Schema.String, Question);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Questions = typeof Questions.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const EvaluateRequest = Schema.Struct({\n model: Schema.String,\n state: Content,\n questions: Questions,\n});\n\n/**\n * Evaluation input. Keep question literals with `satisfies Questions` when\n * storing questions separately from the call to `evaluate`.\n *\n * @category models\n * @since 0.1.0\n */\nexport type EvaluateRequest<Q extends Questions = Questions> = Omit<\n typeof EvaluateRequest.Type,\n \"questions\"\n> & { readonly questions: Q };\n\n/**\n * A finite probability or confidence in the inclusive range [0, 1].\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const Probability = DecisionSchema.Probability;\n\n/**\n * A selected option and its full distribution. Confidence summarizes the\n * distribution; it does not guarantee correctness.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ChoiceAnswer = Schema.Struct({\n ...DecisionSchema.ChoiceAnswer.fields,\n confidence: Probability,\n});\n\n/**\n * Known option unions infer literal choices and required probability keys.\n * Open string or template-pattern option types allow absent dictionary entries.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ChoiceAnswer<Choice extends string = string> = Omit<\n typeof ChoiceAnswer.Type,\n \"choice\" | \"probabilities\"\n> & {\n readonly choice: Choice;\n readonly probabilities: {\n readonly [K in Choice]: {} extends Pick<Record<Choice, unknown>, K>\n ? number | undefined\n : number;\n };\n};\n\n/**\n * A fractional, probability-weighted level, with the supplied rubric as legend.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const ScoreAnswer = Schema.Struct({\n ...DecisionSchema.ScoreAnswer.fields,\n confidence: Probability,\n});\n\n/**\n * Score levels are keyed at runtime; an arbitrary legend or probability lookup\n * may be absent.\n *\n * @category models\n * @since 0.1.0\n */\nexport type ScoreAnswer = Omit<typeof ScoreAnswer.Type, \"legend\" | \"probabilities\"> & {\n readonly legend: { readonly [level: string]: string | undefined };\n readonly probabilities: { readonly [level: string]: number | undefined };\n};\n\n/**\n * The probability of yes. Noul has no separate confidence field.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const NoulAnswer = Schema.Struct({ type: Schema.Literal(\"noul\"), noul: Probability });\n\n/** @category models\n * @since 0.1.0\n */\nexport type NoulAnswer = typeof NoulAnswer.Type;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Answer = Schema.Union([ChoiceAnswer, ScoreAnswer, NoulAnswer]);\n\n/** @category models\n * @since 0.1.0\n */\nexport type Answer = ChoiceAnswer | ScoreAnswer | NoulAnswer;\n\n/** @category schemas\n * @since 0.1.0\n */\nexport const Usage = Schema.Struct({ input_tokens: Schema.Natural, output_tokens: Schema.Natural });\n\n/** @category models\n * @since 0.1.0\n */\nexport type Usage = typeof Usage.Type;\n\n/**\n * The wire response shape. `TypeSafeClient.evaluate` additionally validates\n * answer IDs, question kinds, criteria, distributions, and score correlations.\n *\n * @category schemas\n * @since 0.1.0\n */\nexport const EvaluateResponse = Schema.Struct({\n model: Schema.String,\n answers: Schema.Record(Schema.String, Answer),\n usage: Usage,\n});\n\ntype ChoiceAnswerFor<Criteria> = Criteria extends unknown\n ? Omit<typeof ChoiceAnswer.Type, \"choice\" | \"probabilities\"> & {\n readonly choice: `${Extract<keyof Criteria, string | number>}`;\n readonly probabilities: {\n readonly [\n K in keyof Criteria as K extends string | number ? `${K}` : never\n ]: {} extends Pick<Criteria, K> ? number | undefined : number;\n };\n }\n : never;\n\n/**\n * Infer a question's answer, preserving optional choice criteria in its probabilities.\n *\n * @category models\n * @since 0.1.0\n */\nexport type AnswerFor<Q extends Question> = Q extends ChoiceQuestion\n ? ChoiceAnswerFor<Q[\"criteria\"]>\n : Q extends ScoreQuestion\n ? ScoreAnswer\n : NoulAnswer;\n\n/**\n * One answer for each required question. Optional properties and open string,\n * numeric, or template-pattern indexes require checking an entry for absence.\n *\n * @category models\n * @since 0.1.0\n */\nexport type Answers<Q extends Questions> = {\n readonly [K in keyof Q as K extends string | number ? `${K}` : never]: {} extends Pick<Q, K>\n ? AnswerFor<NonNullable<Q[K]>> | undefined\n : AnswerFor<Q[K]>;\n};\n\n/** @category models\n * @since 0.1.0\n */\nexport type EvaluateResponse<Q extends Questions = Questions> = Omit<\n typeof EvaluateResponse.Type,\n \"answers\"\n> & { readonly answers: Answers<Q> };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,UAAU,eAAe;;;;;;;AAatC,MAAa,iBAAiB,eAAe;;;;;;;AAa7C,MAAa,gBAAgB,eAAe;;;;;;;AAa5C,MAAa,eAAe,OAAO,OAAO;CACxC,MAAM,OAAO,QAAQ,MAAM;CAC3B,cAAc;CACd,UAAU,OAAO,YACf,OAAO,OAAO;EACZ,MAAM,OAAO,YAAY,OAAO,MAAM;EACtC,OAAO,OAAO,YAAY,OAAO,MAAM;CACzC,CAAC,CACH;AACF,CAAC;;;;AAUD,MAAa,WAAW,OAAO,MAAM;CAAC;CAAgB;CAAe;AAAY,CAAC;;;;AAUlF,MAAa,YAAY,OAAO,OAAO,OAAO,QAAQ,QAAQ;;;;AAU9D,MAAa,kBAAkB,OAAO,OAAO;CAC3C,OAAO,OAAO;CACd,OAAO;CACP,WAAW;AACb,CAAC;;;;;;;AAoBD,MAAa,cAAc,eAAe;;;;;;;;AAS1C,MAAa,eAAe,OAAO,OAAO;CACxC,GAAG,eAAe,aAAa;CAC/B,YAAY;AACd,CAAC;;;;;;;AA2BD,MAAa,cAAc,OAAO,OAAO;CACvC,GAAG,eAAe,YAAY;CAC9B,YAAY;AACd,CAAC;;;;;;;AAoBD,MAAa,aAAa,OAAO,OAAO;CAAE,MAAM,OAAO,QAAQ,MAAM;CAAG,MAAM;AAAY,CAAC;;;;AAU3F,MAAa,SAAS,OAAO,MAAM;CAAC;CAAc;CAAa;AAAU,CAAC;;;;AAU1E,MAAa,QAAQ,OAAO,OAAO;CAAE,cAAc,OAAO;CAAS,eAAe,OAAO;AAAQ,CAAC;;;;;;;;AAclG,MAAa,mBAAmB,OAAO,OAAO;CAC5C,OAAO,OAAO;CACd,SAAS,OAAO,OAAO,OAAO,QAAQ,MAAM;CAC5C,OAAO;AACT,CAAC"}
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
- import { t as TypeSafeSchema_d_exports } from "./TypeSafeSchema.mjs";
1
+ import { g as TypeSafeSchema_d_exports } from "./TypeSafeSchema-Dn4_Tptf.mjs";
2
2
  import { t as TypeSafeClient_d_exports } from "./TypeSafeClient.mjs";
3
- export { TypeSafeClient_d_exports as TypeSafeClient, TypeSafeSchema_d_exports as TypeSafeSchema };
3
+ import { t as TypeSafeDecisionModel_d_exports } from "./TypeSafeDecisionModel.mjs";
4
+ export { TypeSafeClient_d_exports as TypeSafeClient, TypeSafeDecisionModel_d_exports as TypeSafeDecisionModel, TypeSafeSchema_d_exports as TypeSafeSchema };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
- import { n as TypeSafeClient_exports } from "./TypeSafeClient-OS5hTVMz.mjs";
1
+ import { n as TypeSafeClient_exports } from "./TypeSafeClient-SjzPX2Gl.mjs";
2
2
  import { t as TypeSafeSchema_exports } from "./TypeSafeSchema.mjs";
3
- export { TypeSafeClient_exports as TypeSafeClient, TypeSafeSchema_exports as TypeSafeSchema };
3
+ import { t as TypeSafeDecisionModel_exports } from "./TypeSafeDecisionModel.mjs";
4
+ export { TypeSafeClient_exports as TypeSafeClient, TypeSafeDecisionModel_exports as TypeSafeDecisionModel, TypeSafeSchema_exports as TypeSafeSchema };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@effect-agent/ai-typesafe","version":"0.1.0-beta.102","devDependencies":{"@effect/vitest":"4.0.0-rc.115","effect":"4.0.0-rc.115","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.115"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./type-safe-client":{"types":"./dist/TypeSafeClient.d.mts","default":"./dist/TypeSafeClient.mjs"},"./type-safe-schema":{"types":"./dist/TypeSafeSchema.d.mts","default":"./dist/TypeSafeSchema.mjs"}},"description":"TypeSafe AI evaluation with Effect HttpClient and request-derived answer types.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/ai-typesafe"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test"}}
1
+ {"name":"@effect-agent/ai-typesafe","version":"0.1.0-beta.103","dependencies":{"@effect-agent/ai-decision":"0.1.0-beta.103"},"devDependencies":{"@effect/vitest":"4.0.0-rc.115","effect":"4.0.0-rc.115","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.115"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./type-safe-client":{"types":"./dist/TypeSafeClient.d.mts","default":"./dist/TypeSafeClient.mjs"},"./type-safe-schema":{"types":"./dist/TypeSafeSchema.d.mts","default":"./dist/TypeSafeSchema.mjs"},"./type-safe-decision-model":{"types":"./dist/TypeSafeDecisionModel.d.mts","default":"./dist/TypeSafeDecisionModel.mjs"}},"description":"TypeSafe AI evaluation with Effect HttpClient and request-derived answer types.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/ai-typesafe"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test"}}
@@ -0,0 +1,77 @@
1
+ import { DecisionModel, type DecisionSchema } from "@effect-agent/ai-decision";
2
+ import { Effect, Layer, Schema } from "effect";
3
+
4
+ import { choiceProbabilitySum } from "./internal/schema.ts";
5
+ import { TypeSafeClient } from "./TypeSafeClient.ts";
6
+ import * as TypeSafeSchema from "./TypeSafeSchema.ts";
7
+
8
+ /**
9
+ * TypeSafe's distribution statistics, under result.providerMetadata.typesafe.
10
+ * Noul questions have no confidence entry.
11
+ *
12
+ * @category schemas
13
+ * @since 0.1.0
14
+ */
15
+ export const ProviderMetadata = Schema.Struct({
16
+ confidence: Schema.Record(Schema.String, TypeSafeSchema.Probability),
17
+ });
18
+
19
+ /**
20
+ * Supply a TypeSafe model as a provider-neutral decision model. The client retains HTTP policy;
21
+ * this adapter translates probability questions to noul and preserves returned evidence/usage.
22
+ * Capture TypeSafeClient at Layer construction. This Layer does not supply LanguageModel.
23
+ */
24
+ export const model = (
25
+ model: string,
26
+ ): Layer.Layer<DecisionModel.DecisionModel, never, TypeSafeClient> =>
27
+ Layer.effect(
28
+ DecisionModel.DecisionModel,
29
+ Effect.gen(function* () {
30
+ const client = yield* TypeSafeClient;
31
+
32
+ return yield* DecisionModel.make({
33
+ choiceProbabilitySum,
34
+ evaluate: Effect.fnUntraced(function* (request) {
35
+ const questions: TypeSafeSchema.Questions = Object.fromEntries(
36
+ Object.entries(request.questions).map(([id, question]) => [
37
+ id,
38
+ question.type === "probability" ? { ...question, type: "noul" } : question,
39
+ ]),
40
+ );
41
+
42
+ const response = yield* client.evaluate({ model, state: request.state, questions });
43
+
44
+ const answers: Array<readonly [string, DecisionSchema.Answer]> = [];
45
+
46
+ const confidence: Array<readonly [string, number]> = [];
47
+
48
+ for (const [id, answer] of Object.entries(response.answers)) {
49
+ if (answer === undefined) continue;
50
+ if (answer.type === "noul") {
51
+ answers.push([id, { type: "probability", probability: answer.noul }]);
52
+ } else {
53
+ const { confidence: statistic, ...evidence } = answer;
54
+
55
+ answers.push([id, evidence]);
56
+ confidence.push([id, statistic]);
57
+ }
58
+ }
59
+
60
+ return {
61
+ provider: "typesafe",
62
+ model: response.model,
63
+ answers: Object.fromEntries(answers),
64
+ usage: {
65
+ inputTokens: response.usage.input_tokens,
66
+ outputTokens: response.usage.output_tokens,
67
+ },
68
+ providerMetadata: {
69
+ typesafe: {
70
+ confidence: Object.fromEntries(confidence),
71
+ },
72
+ },
73
+ };
74
+ }),
75
+ });
76
+ }),
77
+ );
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * @since 0.1.0
5
5
  */
6
+ import { DecisionSchema } from "@effect-agent/ai-decision";
6
7
  import * as Schema from "effect/Schema";
7
8
 
8
9
  /**
@@ -11,7 +12,7 @@ import * as Schema from "effect/Schema";
11
12
  * @category schemas
12
13
  * @since 0.1.0
13
14
  */
14
- export const Content = Schema.Union([Schema.String, Schema.JsonObject, Schema.Array(Schema.Json)]);
15
+ export const Content = DecisionSchema.Content;
15
16
 
16
17
  /** @category models
17
18
  * @since 0.1.0
@@ -24,13 +25,7 @@ export type Content = typeof Content.Type;
24
25
  * @category schemas
25
26
  * @since 0.1.0
26
27
  */
27
- export const ChoiceQuestion = Schema.Struct({
28
- type: Schema.Literal("choice"),
29
- instructions: Content,
30
- criteria: Schema.Record(Schema.String, Schema.NullOr(Schema.String)).check(
31
- Schema.isMinProperties(1),
32
- ),
33
- });
28
+ export const ChoiceQuestion = DecisionSchema.ChoiceQuestion;
34
29
 
35
30
  /** @category models
36
31
  * @since 0.1.0
@@ -43,11 +38,7 @@ export type ChoiceQuestion = typeof ChoiceQuestion.Type;
43
38
  * @category schemas
44
39
  * @since 0.1.0
45
40
  */
46
- export const ScoreQuestion = Schema.Struct({
47
- type: Schema.Literal("score"),
48
- instructions: Content,
49
- criteria: Schema.Array(Schema.String).check(Schema.isMinLength(2)),
50
- });
41
+ export const ScoreQuestion = DecisionSchema.ScoreQuestion;
51
42
 
52
43
  /** @category models
53
44
  * @since 0.1.0
@@ -123,7 +114,7 @@ export type EvaluateRequest<Q extends Questions = Questions> = Omit<
123
114
  * @category schemas
124
115
  * @since 0.1.0
125
116
  */
126
- export const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));
117
+ export const Probability = DecisionSchema.Probability;
127
118
 
128
119
  /**
129
120
  * A selected option and its full distribution. Confidence summarizes the
@@ -133,9 +124,7 @@ export const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, ma
133
124
  * @since 0.1.0
134
125
  */
135
126
  export const ChoiceAnswer = Schema.Struct({
136
- type: Schema.Literal("choice"),
137
- choice: Schema.String,
138
- probabilities: Schema.Record(Schema.String, Probability),
127
+ ...DecisionSchema.ChoiceAnswer.fields,
139
128
  confidence: Probability,
140
129
  });
141
130
 
@@ -165,10 +154,7 @@ export type ChoiceAnswer<Choice extends string = string> = Omit<
165
154
  * @since 0.1.0
166
155
  */
167
156
  export const ScoreAnswer = Schema.Struct({
168
- type: Schema.Literal("score"),
169
- score: Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0)),
170
- legend: Schema.Record(Schema.String, Schema.String),
171
- probabilities: Schema.Record(Schema.String, Probability),
157
+ ...DecisionSchema.ScoreAnswer.fields,
172
158
  confidence: Probability,
173
159
  });
174
160
 
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as TypeSafeClient from "./TypeSafeClient.ts";
2
2
  export * as TypeSafeSchema from "./TypeSafeSchema.ts";
3
+ export * as TypeSafeDecisionModel from "./TypeSafeDecisionModel.ts";
@@ -5,15 +5,31 @@ import * as TypeSafeSchema from "../TypeSafeSchema.ts";
5
5
  // Permit floating-point serialization error without changing provider values.
6
6
  const tolerance = 1e-6;
7
7
 
8
- const distribution = (keys: ReadonlyArray<string>) =>
9
- Schema.Record(Schema.Literals(keys), TypeSafeSchema.Probability).check(
10
- Schema.makeFilter(
11
- (probabilities) =>
12
- Math.abs(Object.values(probabilities).reduce((sum, value) => sum + value, 0) - 1) <=
13
- tolerance,
14
- { expected: "probabilities summing to 1 (within 1e-6)" },
15
- ),
16
- );
8
+ const probabilitySum = Schema.makeFilter(
9
+ (probabilities: Readonly<Record<string, number>>) =>
10
+ Math.abs(Object.values(probabilities).reduce((sum, value) => sum + value, 0) - 1) <= tolerance,
11
+ { expected: "probabilities summing to 1 (within 1e-6)" },
12
+ );
13
+
14
+ // Jev Choice responses have been observed with two-decimal probabilities totaling 0.99.
15
+ // Limit compatibility to one percentage point, even for very large option catalogues.
16
+ // Score sums/weighting retain their strict checks; no Score rounding contract is assumed.
17
+ export const choiceProbabilitySum = Schema.makeFilter(
18
+ (probabilities: Readonly<Record<string, number>>) => {
19
+ const values = Object.values(probabilities);
20
+ const error = Math.abs(values.reduce((sum, value) => sum + value, 0) - 1);
21
+
22
+ return (
23
+ error <= tolerance ||
24
+ (error <= Math.min(0.01, values.length * 0.005) + tolerance &&
25
+ values.every((value) => Math.abs(value * 100 - Math.round(value * 100)) < 1e-8))
26
+ );
27
+ },
28
+ { expected: "probabilities summing to 1 within bounded two-decimal Choice rounding" },
29
+ );
30
+
31
+ const distribution = (keys: ReadonlyArray<string>, sumCheck = probabilitySum) =>
32
+ Schema.Record(Schema.Literals(keys), TypeSafeSchema.Probability).check(sumCheck);
17
33
 
18
34
  const answerFor = (question: TypeSafeSchema.Question) => {
19
35
  switch (question.type) {
@@ -23,7 +39,7 @@ const answerFor = (question: TypeSafeSchema.Question) => {
23
39
  return Schema.Struct({
24
40
  ...TypeSafeSchema.ChoiceAnswer.fields,
25
41
  choice: Schema.Literals(keys),
26
- probabilities: distribution(keys),
42
+ probabilities: distribution(keys, choiceProbabilitySum),
27
43
  }).check(
28
44
  Schema.makeFilter(
29
45
  ({ choice, probabilities }) =>
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeSafeClient-OS5hTVMz.mjs","names":["make","TypeSafeSchema.Probability","TypeSafeSchema.NoulAnswer","TypeSafeSchema.EvaluateRequest","Errors.make","Errors.mapHttpClientError","Errors.mapSchemaError"],"sources":["../src/internal/errors.ts","../src/internal/schema.ts","../src/TypeSafeClient.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport * as Redacted from \"effect/Redacted\";\nimport type * as Schema from \"effect/Schema\";\nimport * as AiError from \"effect/unstable/ai/AiError\";\nimport * as Headers from \"effect/unstable/http/Headers\";\nimport type * as HttpClientError from \"effect/unstable/http/HttpClientError\";\n\nexport const make = (reason: AiError.AiErrorReason): AiError.AiError =>\n AiError.make({ module: \"TypeSafeClient\", method: \"evaluate\", reason });\n\nexport const mapSchemaError = (\n error: Schema.SchemaError,\n redact: (text: string) => string,\n): AiError.AiError => {\n const reason = AiError.InvalidOutputError.fromSchemaError(error);\n\n return make(\n new AiError.InvalidOutputError({ ...reason, description: redact(reason.description) }),\n );\n};\n\nconst redactRequest = (\n request: typeof AiError.HttpRequestDetails.Type,\n redact: (text: string) => string,\n): typeof AiError.HttpRequestDetails.Type => ({\n ...request,\n url: redact(request.url),\n urlParams: request.urlParams.map(([key, value]) => [key, redact(value)]),\n hash: request.hash === undefined ? undefined : redact(request.hash),\n headers: Record.map(request.headers, (value) =>\n Redacted.isRedacted(value) ? \"<redacted>\" : redact(value),\n ),\n});\n\nexport const mapHttpClientError = Effect.fnUntraced(function* (\n error: HttpClientError.HttpClientError,\n redact: (text: string) => string,\n): Effect.fn.Return<never, AiError.AiError> {\n const reason = error.reason;\n\n switch (reason._tag) {\n case \"TransportError\":\n case \"EncodeError\":\n case \"InvalidUrlError\": {\n const network = AiError.NetworkError.fromRequestError(reason);\n\n return yield* make(\n new AiError.NetworkError({\n ...network,\n request: redactRequest(network.request, redact),\n description: network.description === undefined ? undefined : redact(network.description),\n }),\n );\n }\n case \"DecodeError\":\n case \"EmptyBodyError\":\n return yield* make(\n new AiError.InvalidOutputError({\n description: redact(reason.description ?? \"Could not decode the TypeSafe response body\"),\n }),\n );\n case \"StatusCodeError\": {\n const { request, response } = reason;\n const redactedNames = yield* Headers.CurrentRedactedNames;\n\n const headers = (value: Headers.Headers) =>\n Record.map(Headers.redact(value, redactedNames), (value) =>\n Redacted.isRedacted(value) ? \"<redacted>\" : redact(value),\n );\n\n const text = yield* Effect.option(response.text);\n const body = Option.isSome(text) ? redact(text.value) : undefined;\n\n const http: typeof AiError.HttpContext.Type = {\n request: {\n method: request.method,\n url: redact(request.url),\n urlParams: Array.from(request.urlParams, ([key, value]) => [key, redact(value)]),\n hash: Option.getOrUndefined(Option.map(request.hash, redact)),\n headers: headers(request.headers),\n },\n response: { status: response.status, headers: headers(response.headers) },\n body,\n };\n\n const description = AiError.buildErrorDescription({\n status: response.status,\n method: request.method,\n url: http.request.url,\n message: undefined,\n body,\n });\n\n return yield* make(\n response.status === 422\n ? new AiError.InvalidRequestError({ description, http })\n : AiError.reasonFromHttpStatus({ status: response.status, description, http }),\n );\n }\n }\n});\n","import * as Schema from \"effect/Schema\";\n\nimport * as TypeSafeSchema from \"../TypeSafeSchema.ts\";\n\n// Permit floating-point serialization error without changing provider values.\nconst tolerance = 1e-6;\n\nconst distribution = (keys: ReadonlyArray<string>) =>\n Schema.Record(Schema.Literals(keys), TypeSafeSchema.Probability).check(\n Schema.makeFilter(\n (probabilities) =>\n Math.abs(Object.values(probabilities).reduce((sum, value) => sum + value, 0) - 1) <=\n tolerance,\n { expected: \"probabilities summing to 1 (within 1e-6)\" },\n ),\n );\n\nconst answerFor = (question: TypeSafeSchema.Question) => {\n switch (question.type) {\n case \"choice\": {\n const keys = Object.keys(question.criteria);\n\n return Schema.Struct({\n ...TypeSafeSchema.ChoiceAnswer.fields,\n choice: Schema.Literals(keys),\n probabilities: distribution(keys),\n }).check(\n Schema.makeFilter(\n ({ choice, probabilities }) =>\n Object.values(probabilities).every((value) => value <= probabilities[choice]),\n { expected: \"a highest-probability choice\" },\n ),\n );\n }\n case \"score\": {\n const maxLevel = question.criteria.length - 1;\n\n const levels = question.criteria.map(\n (description, index) => [String(index), description] as const,\n );\n\n return Schema.Struct({\n ...TypeSafeSchema.ScoreAnswer.fields,\n score: Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: maxLevel })),\n legend: Schema.Struct(\n Object.fromEntries(\n levels.map(([key, description]) => [key, Schema.Literal(description)]),\n ),\n ),\n probabilities: distribution(levels.map(([key]) => key)),\n }).check(\n Schema.makeFilter(\n ({ score, probabilities }) =>\n Math.abs(\n score -\n Object.entries(probabilities).reduce(\n (sum, [level, probability]) => sum + Number(level) * probability,\n 0,\n ),\n ) <=\n tolerance * Math.max(1, maxLevel),\n { expected: \"the probability-weighted score (within 1e-6 per level)\" },\n ),\n );\n }\n case \"noul\":\n return TypeSafeSchema.NoulAnswer;\n }\n};\n\n// The overload describes the dependent type enforced by the literal keys and\n// per-question schemas below. No JSON value is asserted to have that type.\nexport function responseFor<const Q extends TypeSafeSchema.Questions>(\n questions: Q,\n): Schema.Codec<TypeSafeSchema.EvaluateResponse<Q>>;\n\nexport function responseFor(questions: TypeSafeSchema.Questions): Schema.Top {\n return Schema.Struct({\n ...TypeSafeSchema.EvaluateResponse.fields,\n answers: Schema.Struct(\n Object.fromEntries(\n Object.entries(questions).map(([id, question]) => [id, answerFor(question)]),\n ),\n ),\n });\n}\n","/**\n * An Effect HttpClient integration for TypeSafe's System One evaluations.\n *\n * @since 0.1.0\n */\nimport * as Config from \"effect/Config\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport { flow, identity } from \"effect/Function\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Schema from \"effect/Schema\";\nimport * as AiError from \"effect/unstable/ai/AiError\";\nimport * as Headers from \"effect/unstable/http/Headers\";\nimport * as HttpClient from \"effect/unstable/http/HttpClient\";\nimport * as HttpClientRequest from \"effect/unstable/http/HttpClientRequest\";\nimport * as HttpClientResponse from \"effect/unstable/http/HttpClientResponse\";\n\nimport * as Errors from \"./internal/errors.ts\";\nimport { responseFor } from \"./internal/schema.ts\";\nimport * as TypeSafeSchema from \"./TypeSafeSchema.ts\";\n\n/** @category services\n * @since 0.1.0\n */\nexport interface Service {\n readonly client: HttpClient.HttpClient;\n\n /**\n * Evaluate mixed questions against one state. Answers are validated against\n * the submitted IDs, types, and criteria before receiving their inferred type.\n * There are no automatic retries or timeouts; compose those with Effect.\n */\n readonly evaluate: <const Q extends TypeSafeSchema.Questions>(\n options: TypeSafeSchema.EvaluateRequest<Q>,\n ) => Effect.Effect<TypeSafeSchema.EvaluateResponse<Q>, AiError.AiError>;\n}\n\n/** @category services\n * @since 0.1.0\n */\nexport class TypeSafeClient extends Context.Service<TypeSafeClient, Service>()(\n \"@effect-agent/ai-typesafe/TypeSafeClient\",\n) {}\n\n/** @category options\n * @since 0.1.0\n */\nexport interface Options {\n readonly apiKey: Redacted.Redacted<string>;\n /** Base URL, including the API version. Defaults to https://api.typesafe.ai/v1. */\n readonly apiUrl?: string | undefined;\n /** Applied after authentication and status filtering, for explicit HTTP policies. */\n readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;\n}\n\nconst encodeRequest = Schema.encodeEffect(Schema.fromJsonString(TypeSafeSchema.EvaluateRequest));\n\n/**\n * Construct the client using a supplied, platform-neutral HttpClient.\n * Acquiring the service does not send a request.\n *\n * @category constructors\n * @since 0.1.0\n */\nexport const make = Effect.fnUntraced(function* (\n options: Options,\n): Effect.fn.Return<Service, never, HttpClient.HttpClient> {\n const apiKey = Redacted.value(options.apiKey);\n\n const redact = (text: string) =>\n apiKey.length === 0 ? text : text.replaceAll(apiKey, \"<redacted>\");\n\n const client = (yield* HttpClient.HttpClient).pipe(\n HttpClient.mapRequest(\n flow(\n HttpClientRequest.prependUrl(options.apiUrl ?? \"https://api.typesafe.ai/v1\"),\n HttpClientRequest.bearerToken(options.apiKey),\n HttpClientRequest.acceptJson,\n ),\n ),\n HttpClient.filterStatusOk,\n options.transformClient ?? identity,\n );\n\n const evaluate = Effect.fnUntraced(function* <const Q extends TypeSafeSchema.Questions>(\n options: TypeSafeSchema.EvaluateRequest<Q>,\n ): Effect.fn.Return<TypeSafeSchema.EvaluateResponse<Q>, AiError.AiError> {\n const body = yield* encodeRequest(options).pipe(\n Effect.mapError((error) =>\n Errors.make(new AiError.InvalidRequestError({ description: redact(error.message) })),\n ),\n );\n\n const schema = responseFor(options.questions);\n\n return yield* client\n .execute(\n HttpClientRequest.post(\"/systemone\").pipe(\n HttpClientRequest.bodyText(body, \"application/json\"),\n ),\n )\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(schema, { onExcessProperty: \"error\" })),\n Effect.catchTags({\n HttpClientError: (error) => Errors.mapHttpClientError(error, redact),\n SchemaError: (error) => Effect.fail(Errors.mapSchemaError(error, redact)),\n }),\n Effect.updateService(Headers.CurrentRedactedNames, (names) => [...names, \"authorization\"]),\n );\n });\n\n return TypeSafeClient.of({ client, evaluate });\n});\n\n/** @category layers\n * @since 0.1.0\n */\nexport const layer = (\n options: Options,\n): Layer.Layer<TypeSafeClient, never, HttpClient.HttpClient> =>\n Layer.effect(TypeSafeClient, make(options));\n\n/**\n * Configure the client with Effect Config. The API key defaults to\n * `Config.Redacted(\"TYPESAFE_API_KEY\")`.\n *\n * @category layers\n * @since 0.1.0\n */\nexport const layerConfig = (options?: {\n readonly apiKey?: Config.Config<Redacted.Redacted<string>> | undefined;\n readonly apiUrl?: Config.Config<string> | undefined;\n readonly transformClient?: Options[\"transformClient\"];\n}): Layer.Layer<TypeSafeClient, Config.ConfigError, HttpClient.HttpClient> =>\n Layer.effect(\n TypeSafeClient,\n Effect.gen(function* () {\n return yield* make({\n apiKey: yield* options?.apiKey ?? Config.Redacted(\"TYPESAFE_API_KEY\"),\n apiUrl: options?.apiUrl === undefined ? undefined : yield* options.apiUrl,\n transformClient: options?.transformClient,\n });\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAaA,UAAQ,WACnB,QAAQ,KAAK;CAAE,QAAQ;CAAkB,QAAQ;CAAY;AAAO,CAAC;AAEvE,MAAa,kBACX,OACA,WACoB;CACpB,MAAM,SAAS,QAAQ,mBAAmB,gBAAgB,KAAK;CAE/D,OAAOA,OACL,IAAI,QAAQ,mBAAmB;EAAE,GAAG;EAAQ,aAAa,OAAO,OAAO,WAAW;CAAE,CAAC,CACvF;AACF;AAEA,MAAM,iBACJ,SACA,YAC4C;CAC5C,GAAG;CACH,KAAK,OAAO,QAAQ,GAAG;CACvB,WAAW,QAAQ,UAAU,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,OAAO,KAAK,CAAC,CAAC;CACvE,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAA,IAAY,OAAO,QAAQ,IAAI;CAClE,SAAS,OAAO,IAAI,QAAQ,UAAU,UACpC,SAAS,WAAW,KAAK,IAAI,eAAe,OAAO,KAAK,CAC1D;AACF;AAEA,MAAa,qBAAqB,OAAO,WAAW,WAClD,OACA,QAC0C;CAC1C,MAAM,SAAS,MAAM;CAErB,QAAQ,OAA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