anpord 0.1.11 → 0.1.13
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.
- package/README.md +56 -78
- package/dist/bin.cjs +211 -204
- package/dist/bin.mjs +211 -204
- package/dist/cli-runtime.cjs +2 -2
- package/dist/cli-runtime.d.cts +1 -1
- package/dist/cli-runtime.d.mts +1 -1
- package/dist/cli-runtime.mjs +2 -2
- package/dist/client-BfdjFtlV.mjs +305 -0
- package/dist/{client-C9m0uLCz.d.cts → client-BgRs8JvW.d.mts} +2150 -174
- package/dist/{client-TFCLuMv8.d.mts → client-BirFO3jz.d.cts} +2150 -174
- package/dist/client-C-P2I00z.cjs +346 -0
- package/dist/{compiler-DXlpU_In.mjs → compiler-D96wI7UP.mjs} +108 -75
- package/dist/{compiler-Ap8DM-JU.cjs → compiler-uwb1pkdK.cjs} +116 -83
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/{errors-C9bQUcA3.mjs → errors-B0YknR5V.mjs} +3 -19
- package/dist/{errors-Boum34f5.cjs → errors-BX1wry8K.cjs} +3 -19
- package/dist/{errors-BK3f7Rdr.d.cts → errors-aGrd21jy.d.cts} +0 -3
- package/dist/{errors-BK3f7Rdr.d.mts → errors-aGrd21jy.d.mts} +0 -3
- package/dist/eval-judges-BkmiVLLq.cjs +59 -0
- package/dist/eval-judges-CwTvTq7N.mjs +42 -0
- package/dist/eval-judges-DPPUftbh.d.cts +48 -0
- package/dist/eval-judges-DPPUftbh.d.mts +48 -0
- package/dist/eval-validations-BRdoZrTQ.mjs +113 -0
- package/dist/eval-validations-_MlnQ_uv.cjs +148 -0
- package/dist/eval.cjs +1 -1
- package/dist/eval.d.cts +60 -6
- package/dist/eval.d.mts +60 -6
- package/dist/eval.mjs +1 -1
- package/dist/evals-B6aT3xgH.d.cts +1364 -0
- package/dist/evals-B6aT3xgH.d.mts +1364 -0
- package/dist/evals-Dcc_x6jW.mjs +582 -0
- package/dist/evals-DouMsrsM.cjs +737 -0
- package/dist/index.cjs +23 -99
- package/dist/index.d.cts +138 -34
- package/dist/index.d.mts +138 -34
- package/dist/index.mjs +23 -99
- package/dist/source.d.cts +1 -1
- package/dist/source.d.mts +1 -1
- package/dist/{types-oaMF6-E1.d.mts → types-Codjaq-o.d.mts} +146 -45
- package/dist/{types-H9L450Iu.d.cts → types-ISsteq95.d.cts} +146 -45
- package/dist/validator-runtime.cjs +238 -0
- package/dist/validator-runtime.d.cts +9 -0
- package/dist/validator-runtime.d.mts +9 -0
- package/dist/validator-runtime.mjs +237 -0
- package/dist/validators.cjs +10 -0
- package/dist/validators.d.cts +8 -0
- package/dist/validators.d.mts +8 -0
- package/dist/validators.mjs +9 -0
- package/package.json +11 -1
- package/dist/client-5K3dMI5Q.mjs +0 -849
- package/dist/client-Ci0woWLW.cjs +0 -890
- package/dist/evals-BEgEmfiO.d.cts +0 -603
- package/dist/evals-BEgEmfiO.d.mts +0 -603
- package/dist/harness-profile-BMjsN460.mjs +0 -43
- package/dist/harness-profile-CDQpPLPd.cjs +0 -78
package/dist/cli-runtime.cjs
CHANGED
|
@@ -118,8 +118,8 @@ const executeCli = (definition, args, journal = JOURNAL) => effect.Effect.gen(fu
|
|
|
118
118
|
stdout: ""
|
|
119
119
|
}))));
|
|
120
120
|
}).pipe(effect.Effect.withSpan("CliMock.execute"), effect.Effect.runPromise);
|
|
121
|
-
const runCli = async (definition) => {
|
|
122
|
-
const result = await executeCli(definition, process.argv.slice(2));
|
|
121
|
+
const runCli = async (definition, journal) => {
|
|
122
|
+
const result = await executeCli(definition, process.argv.slice(2), journal);
|
|
123
123
|
process.stdout.write(result.stdout);
|
|
124
124
|
process.stderr.write(result.stderr);
|
|
125
125
|
process.exitCode = result.exitCode;
|
package/dist/cli-runtime.d.cts
CHANGED
|
@@ -6,6 +6,6 @@ interface CliExecution {
|
|
|
6
6
|
readonly stdout: string;
|
|
7
7
|
}
|
|
8
8
|
declare const executeCli: (definition: CliDefinition, args: readonly string[], journal?: string) => Promise<CliExecution>;
|
|
9
|
-
declare const runCli: (definition: CliDefinition) => Promise<void>;
|
|
9
|
+
declare const runCli: (definition: CliDefinition, journal?: string) => Promise<void>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { CliExecution, executeCli, runCli };
|
package/dist/cli-runtime.d.mts
CHANGED
|
@@ -6,6 +6,6 @@ interface CliExecution {
|
|
|
6
6
|
readonly stdout: string;
|
|
7
7
|
}
|
|
8
8
|
declare const executeCli: (definition: CliDefinition, args: readonly string[], journal?: string) => Promise<CliExecution>;
|
|
9
|
-
declare const runCli: (definition: CliDefinition) => Promise<void>;
|
|
9
|
+
declare const runCli: (definition: CliDefinition, journal?: string) => Promise<void>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { CliExecution, executeCli, runCli };
|
package/dist/cli-runtime.mjs
CHANGED
|
@@ -117,8 +117,8 @@ const executeCli = (definition, args, journal = JOURNAL) => Effect.gen(function*
|
|
|
117
117
|
stdout: ""
|
|
118
118
|
}))));
|
|
119
119
|
}).pipe(Effect.withSpan("CliMock.execute"), Effect.runPromise);
|
|
120
|
-
const runCli = async (definition) => {
|
|
121
|
-
const result = await executeCli(definition, process.argv.slice(2));
|
|
120
|
+
const runCli = async (definition, journal) => {
|
|
121
|
+
const result = await executeCli(definition, process.argv.slice(2), journal);
|
|
122
122
|
process.stdout.write(result.stdout);
|
|
123
123
|
process.stderr.write(result.stderr);
|
|
124
124
|
process.exitCode = result.exitCode;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { C as EvalTrigger, E as EvalVerify, T as EvalPrompt, _ as HarnessProfile, a as EvalPageCursor, c as EvalRunPage, d as EvalValidator, f as EvalVariables, h as StartedEval, i as EvalName, l as EvalSandbox, m as RerunCellRequest, n as EvalCellHistoryEntry, o as EvalPrepare, p as ModelCatalogue, r as EvalHarness, s as EvalRun, t as CaseCache, u as EvalSource, v as PROFILE_HARNESS_RULE, w as EvalCaseName, x as profileFitsHarness } from "./evals-Dcc_x6jW.mjs";
|
|
2
|
+
import { FetchHttpClient, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpClient, HttpClientRequest, OpenApi } from "@effect/platform";
|
|
3
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
4
|
+
//#region ../schema/src/domain/prompts.ts
|
|
5
|
+
const ChannelName = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(36), Schema.pattern(/^[a-z0-9][a-z0-9_-]*$/, { message: () => "Channel must be lowercase alphanumeric, optionally with - or _" }), Schema.brand("ChannelName")).annotations({ description: "Addresses a version. `latest` is derived from the highest version rather than stored, so it cannot drift from the version table." });
|
|
6
|
+
ChannelName.make("production");
|
|
7
|
+
ChannelName.make("latest");
|
|
8
|
+
const PromptId = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(255), Schema.pattern(/^[a-z0-9][a-z0-9/_-]*$/, { message: () => "Prompt id must be lowercase alphanumeric, optionally with / _ or -" }), Schema.brand("PromptId"));
|
|
9
|
+
const PromptName = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(255), Schema.brand("PromptName"));
|
|
10
|
+
const VersionNumber = Schema.Int.pipe(Schema.positive(), Schema.brand("VersionNumber"));
|
|
11
|
+
Schema.NumberFromString.pipe(Schema.int(), Schema.positive(), Schema.brand("VersionNumber"));
|
|
12
|
+
Schema.NumberFromString.pipe(Schema.int(), Schema.positive(), Schema.lessThanOrEqualTo(100));
|
|
13
|
+
const Timestamp = Schema.Union(Schema.DateFromSelf, Schema.Date);
|
|
14
|
+
const CommitMessage = Schema.String.pipe(Schema.maxLength(500));
|
|
15
|
+
const PromptContent = Schema.String.pipe(Schema.minLength(1), Schema.maxLength(262144, { message: () => "Prompt content is longer than 256 KB" }));
|
|
16
|
+
const PromptDescription = Schema.String.pipe(Schema.maxLength(2e3));
|
|
17
|
+
const PromptConfig = Schema.Record({
|
|
18
|
+
key: Schema.String,
|
|
19
|
+
value: Schema.Unknown
|
|
20
|
+
});
|
|
21
|
+
const Author = Schema.Struct({
|
|
22
|
+
image: Schema.NullOr(Schema.String),
|
|
23
|
+
name: Schema.String
|
|
24
|
+
});
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
author: Schema.NullOr(Author),
|
|
27
|
+
channel: Schema.NullOr(ChannelName),
|
|
28
|
+
commitMessage: Schema.NullOr(CommitMessage),
|
|
29
|
+
config: PromptConfig,
|
|
30
|
+
content: Schema.String,
|
|
31
|
+
createdAt: Timestamp,
|
|
32
|
+
id: PromptId,
|
|
33
|
+
name: PromptName,
|
|
34
|
+
version: VersionNumber,
|
|
35
|
+
versionId: Schema.String
|
|
36
|
+
});
|
|
37
|
+
Schema.Struct({
|
|
38
|
+
channel: ChannelName,
|
|
39
|
+
updatedAt: Timestamp,
|
|
40
|
+
updatedBy: Schema.NullOr(Author),
|
|
41
|
+
version: VersionNumber
|
|
42
|
+
});
|
|
43
|
+
const PromptSummary = Schema.Struct({
|
|
44
|
+
author: Schema.NullOr(Author),
|
|
45
|
+
description: Schema.NullOr(Schema.String),
|
|
46
|
+
id: PromptId,
|
|
47
|
+
latestVersion: Schema.NullOr(VersionNumber),
|
|
48
|
+
name: PromptName,
|
|
49
|
+
productionVersion: Schema.NullOr(VersionNumber),
|
|
50
|
+
updatedAt: Timestamp
|
|
51
|
+
});
|
|
52
|
+
Schema.Struct({
|
|
53
|
+
id: PromptId,
|
|
54
|
+
updatedAt: Timestamp
|
|
55
|
+
});
|
|
56
|
+
Schema.Literal("all", "draft", "live");
|
|
57
|
+
Schema.Literal("name", "updated");
|
|
58
|
+
Schema.Struct({
|
|
59
|
+
items: Schema.Array(PromptSummary),
|
|
60
|
+
nextCursor: Schema.NullOr(Schema.String)
|
|
61
|
+
});
|
|
62
|
+
Schema.Struct({
|
|
63
|
+
commitMessage: Schema.optional(CommitMessage),
|
|
64
|
+
config: Schema.optional(PromptConfig),
|
|
65
|
+
content: PromptContent,
|
|
66
|
+
description: Schema.optional(PromptDescription),
|
|
67
|
+
id: PromptId,
|
|
68
|
+
name: PromptName,
|
|
69
|
+
publish: Schema.optional(Schema.Boolean)
|
|
70
|
+
});
|
|
71
|
+
Schema.Struct({
|
|
72
|
+
commitMessage: Schema.optional(CommitMessage),
|
|
73
|
+
config: Schema.optional(PromptConfig),
|
|
74
|
+
content: PromptContent,
|
|
75
|
+
publish: Schema.optional(Schema.Boolean)
|
|
76
|
+
});
|
|
77
|
+
Schema.Struct({
|
|
78
|
+
commitMessage: Schema.optional(CommitMessage),
|
|
79
|
+
config: Schema.optional(PromptConfig),
|
|
80
|
+
content: PromptContent
|
|
81
|
+
});
|
|
82
|
+
Schema.Struct({
|
|
83
|
+
description: Schema.optional(PromptDescription),
|
|
84
|
+
id: Schema.optional(PromptId),
|
|
85
|
+
name: Schema.optional(PromptName)
|
|
86
|
+
});
|
|
87
|
+
Schema.Struct({
|
|
88
|
+
channel: ChannelName,
|
|
89
|
+
version: VersionNumber
|
|
90
|
+
});
|
|
91
|
+
Schema.Struct({
|
|
92
|
+
channel: Schema.optional(ChannelName),
|
|
93
|
+
version: Schema.optional(VersionNumber)
|
|
94
|
+
});
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../schema/src/domain/errors.ts
|
|
97
|
+
var NotFound = class extends Schema.TaggedError()("NotFound", { message: Schema.String }, HttpApiSchema.annotations({ status: 404 })) {};
|
|
98
|
+
var Conflict = class extends Schema.TaggedError()("Conflict", { message: Schema.String }, HttpApiSchema.annotations({ status: 409 })) {};
|
|
99
|
+
var BadRequest = class extends Schema.TaggedError()("BadRequest", { message: Schema.String }, HttpApiSchema.annotations({ status: 400 })) {};
|
|
100
|
+
var Unauthorized = class extends Schema.TaggedError()("Unauthorized", { message: Schema.String }, HttpApiSchema.annotations({ status: 401 })) {};
|
|
101
|
+
var Forbidden = class extends Schema.TaggedError()("Forbidden", { message: Schema.String }, HttpApiSchema.annotations({ status: 403 })) {};
|
|
102
|
+
Schema.TaggedError()("InternalError", { message: Schema.String }, HttpApiSchema.annotations({ status: 500 }));
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region ../schema/src/internal/authentication.ts
|
|
105
|
+
var CurrentActor = class extends Context.Tag("@anpord/schema/CurrentActor")() {};
|
|
106
|
+
HttpApiMiddleware.Tag()("@anpord/schema/Authentication", {
|
|
107
|
+
failure: Unauthorized,
|
|
108
|
+
provides: CurrentActor,
|
|
109
|
+
security: { session: HttpApiSecurity.apiKey({
|
|
110
|
+
in: "cookie",
|
|
111
|
+
key: "anpord.session_token"
|
|
112
|
+
}) }
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region ../schema/src/public/authentication.ts
|
|
116
|
+
var ApiKeyAuthentication = class extends HttpApiMiddleware.Tag()("@anpord/schema/ApiKeyAuthentication", {
|
|
117
|
+
failure: Unauthorized,
|
|
118
|
+
provides: CurrentActor,
|
|
119
|
+
security: { bearer: HttpApiSecurity.bearer }
|
|
120
|
+
}) {};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../schema/src/public/evals-api.ts
|
|
123
|
+
const EvalRunRequest = Schema.Struct({ id: Schema.String }).annotations({
|
|
124
|
+
description: "Select an eval run by id.",
|
|
125
|
+
identifier: "EvalRunRequest"
|
|
126
|
+
});
|
|
127
|
+
const EvalCellRequest = Schema.Struct({ cellKey: Schema.String }).annotations({
|
|
128
|
+
description: "Select an eval cell by its stable key.",
|
|
129
|
+
identifier: "EvalCellRequest"
|
|
130
|
+
});
|
|
131
|
+
const EvalModelsRequest = Schema.Struct({
|
|
132
|
+
harness: EvalHarness,
|
|
133
|
+
q: Schema.optional(Schema.String)
|
|
134
|
+
}).annotations({
|
|
135
|
+
description: "Select a harness whose available models should be listed.",
|
|
136
|
+
identifier: "EvalModelsRequest"
|
|
137
|
+
});
|
|
138
|
+
const PublicEvalSandbox = EvalSandbox.annotations({
|
|
139
|
+
description: "The hosted sandbox a task runs in.",
|
|
140
|
+
identifier: "PublicEvalSandbox"
|
|
141
|
+
});
|
|
142
|
+
const ListEvalsRequest = Schema.Struct({
|
|
143
|
+
cursor: Schema.optional(Schema.NullOr(EvalPageCursor)),
|
|
144
|
+
limit: Schema.optional(Schema.Int)
|
|
145
|
+
}).annotations({
|
|
146
|
+
description: "Where to read from, and how much.",
|
|
147
|
+
identifier: "ListEvalsRequest"
|
|
148
|
+
});
|
|
149
|
+
const PublicEvalCase = Schema.Struct({
|
|
150
|
+
cache: Schema.optional(CaseCache),
|
|
151
|
+
name: EvalCaseName,
|
|
152
|
+
prepare: Schema.optional(Schema.NullOr(EvalPrepare)),
|
|
153
|
+
source: Schema.optional(EvalSource),
|
|
154
|
+
validator: Schema.optional(Schema.NullOr(EvalValidator)),
|
|
155
|
+
variables: Schema.optional(EvalVariables),
|
|
156
|
+
verify: Schema.NullOr(EvalVerify)
|
|
157
|
+
}).pipe(Schema.filter(({ validator, verify }) => !(validator !== void 0 && validator !== null && verify !== null), { message: () => "Use either validator or verify, not both." })).annotations({
|
|
158
|
+
description: "A task, workspace source, setup command, and verifier.",
|
|
159
|
+
identifier: "StartEvalCase"
|
|
160
|
+
});
|
|
161
|
+
const PublicEvalTask = Schema.Struct({
|
|
162
|
+
harness: EvalHarness,
|
|
163
|
+
model: Schema.String.pipe(Schema.minLength(1)),
|
|
164
|
+
profile: Schema.optional(HarnessProfile),
|
|
165
|
+
sandbox: Schema.optional(PublicEvalSandbox)
|
|
166
|
+
}).pipe(Schema.filter(profileFitsHarness, { message: () => PROFILE_HARNESS_RULE })).annotations({
|
|
167
|
+
description: `A harness and model, with an optional sandbox and an optional profile layered on the harness. Omit the sandbox to use the default. ${PROFILE_HARNESS_RULE}`,
|
|
168
|
+
identifier: "StartEvalTask"
|
|
169
|
+
});
|
|
170
|
+
const PublicStartEvalRequest = Schema.Struct({
|
|
171
|
+
trigger: Schema.optional(EvalTrigger),
|
|
172
|
+
cases: Schema.Array(PublicEvalCase).pipe(Schema.minItems(1), Schema.maxItems(100)),
|
|
173
|
+
name: Schema.optional(EvalName),
|
|
174
|
+
prompt: EvalPrompt,
|
|
175
|
+
tasks: Schema.Array(PublicEvalTask).pipe(Schema.minItems(1), Schema.maxItems(20)),
|
|
176
|
+
trials: Schema.Int.pipe(Schema.between(1, 10))
|
|
177
|
+
}).annotations({
|
|
178
|
+
description: `Start a grid with at most 100 total case, task, and trial combinations.`,
|
|
179
|
+
identifier: "StartEvalRequest"
|
|
180
|
+
});
|
|
181
|
+
var PublicEvalsGroup = class extends HttpApiGroup.make("evals").add(HttpApiEndpoint.post("list", "/evals.list").setPayload(ListEvalsRequest).addSuccess(EvalRunPage).annotate(OpenApi.Summary, "List eval runs").annotate(OpenApi.Description, "Newest first. Pass the `next` cursor from a response to read the page after it; a null `next` means there are no more.")).add(HttpApiEndpoint.post("start", "/evals.start").setPayload(PublicStartEvalRequest).addSuccess(StartedEval).annotate(OpenApi.Summary, "Start an eval run").annotate(OpenApi.Description, `Starts the grid and returns its id while trials continue in the background. ${PROFILE_HARNESS_RULE}`)).add(HttpApiEndpoint.post("get", "/evals.get").setPayload(EvalRunRequest).addSuccess(EvalRun).annotate(OpenApi.Summary, "Get an eval run")).add(HttpApiEndpoint.post("cellHistory", "/evals.cellHistory").setPayload(EvalCellRequest).addSuccess(Schema.Array(EvalCellHistoryEntry)).annotate(OpenApi.Summary, "List a cell's history").annotate(OpenApi.Description, "Returns the 20 most recent results.")).add(HttpApiEndpoint.post("rerunCell", "/evals.rerunCell").setPayload(Schema.extend(EvalRunRequest, Schema.extend(EvalCellRequest, RerunCellRequest))).addSuccess(StartedEval).annotate(OpenApi.Summary, "Rerun one cell")).add(HttpApiEndpoint.post("models", "/evals.models").setPayload(EvalModelsRequest).addSuccess(ModelCatalogue).annotate(OpenApi.Summary, "List models available to the harness").annotate(OpenApi.Description, "The command harness has no catalogue of its own, so its list is empty: the model is whatever the profile's run command reads from ANPORD_MODEL.")).addError(BadRequest).addError(Conflict).addError(Forbidden).addError(NotFound).middleware(ApiKeyAuthentication).annotate(OpenApi.Title, "Evals").annotate(OpenApi.Description, "Run cases across harness, model, and sandbox combinations and compare the results with their baselines.") {};
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../schema/src/public/requests.ts
|
|
184
|
+
const GetPromptRequest = Schema.Struct({
|
|
185
|
+
channel: Schema.optional(ChannelName),
|
|
186
|
+
id: PromptId,
|
|
187
|
+
includeVersions: Schema.optional(Schema.Boolean),
|
|
188
|
+
version: Schema.optional(VersionNumber)
|
|
189
|
+
}).annotations({
|
|
190
|
+
description: "Resolve a prompt. Give a version to pin one, a channel to follow one, or neither for the organization's default channel.",
|
|
191
|
+
identifier: "GetPromptRequest"
|
|
192
|
+
});
|
|
193
|
+
Schema.Struct({ id: PromptId }).annotations({
|
|
194
|
+
description: "Show a prompt's version history.",
|
|
195
|
+
identifier: "ListVersionsRequest"
|
|
196
|
+
});
|
|
197
|
+
const ListPromptsRequest = Schema.Record({
|
|
198
|
+
key: Schema.String,
|
|
199
|
+
value: Schema.Never
|
|
200
|
+
}).annotations({
|
|
201
|
+
description: "No parameters; returns up to 100 prompts in the organization.",
|
|
202
|
+
identifier: "ListPromptsRequest"
|
|
203
|
+
});
|
|
204
|
+
const CreatePromptRequest = Schema.Struct({
|
|
205
|
+
config: Schema.optional(PromptConfig),
|
|
206
|
+
content: PromptContent,
|
|
207
|
+
description: Schema.optional(Schema.String),
|
|
208
|
+
id: PromptId,
|
|
209
|
+
message: Schema.optional(CommitMessage),
|
|
210
|
+
name: PromptName
|
|
211
|
+
}).annotations({
|
|
212
|
+
description: "Create a prompt and publish its first version to the default channel.",
|
|
213
|
+
identifier: "CreatePromptRequest"
|
|
214
|
+
});
|
|
215
|
+
const UpdatePromptRequest = Schema.Struct({
|
|
216
|
+
config: Schema.optional(PromptConfig),
|
|
217
|
+
content: PromptContent,
|
|
218
|
+
id: PromptId,
|
|
219
|
+
message: Schema.optional(CommitMessage)
|
|
220
|
+
}).annotations({
|
|
221
|
+
description: "Add a version to a prompt. The new version becomes latest, and omitted config is stored as an empty object.",
|
|
222
|
+
identifier: "UpdatePromptRequest"
|
|
223
|
+
});
|
|
224
|
+
const PromotePromptRequest = Schema.Struct({
|
|
225
|
+
channel: ChannelName,
|
|
226
|
+
id: PromptId,
|
|
227
|
+
version: VersionNumber
|
|
228
|
+
}).annotations({
|
|
229
|
+
description: "Point a channel at a version.",
|
|
230
|
+
identifier: "PromotePromptRequest"
|
|
231
|
+
});
|
|
232
|
+
Schema.Struct({ id: PromptId }).annotations({
|
|
233
|
+
description: "Archive a prompt. Existing selectors stay readable.",
|
|
234
|
+
identifier: "ArchivePromptRequest"
|
|
235
|
+
});
|
|
236
|
+
const Ok = Schema.Struct({ ok: Schema.Literal(true) }).annotations({
|
|
237
|
+
description: "The operation succeeded.",
|
|
238
|
+
identifier: "Ok"
|
|
239
|
+
});
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region ../schema/src/public/shapes.ts
|
|
242
|
+
const Instant = Schema.DateTimeUtc.annotations({
|
|
243
|
+
description: "An ISO-8601 timestamp in UTC.",
|
|
244
|
+
identifier: "Instant",
|
|
245
|
+
jsonSchema: { format: "date-time" }
|
|
246
|
+
});
|
|
247
|
+
const PublicPrompt = Schema.Struct({
|
|
248
|
+
channel: Schema.NullOr(ChannelName),
|
|
249
|
+
config: PromptConfig,
|
|
250
|
+
content: Schema.String,
|
|
251
|
+
createdAt: Instant,
|
|
252
|
+
id: PromptId,
|
|
253
|
+
message: Schema.NullOr(CommitMessage),
|
|
254
|
+
name: PromptName,
|
|
255
|
+
version: VersionNumber
|
|
256
|
+
}).annotations({
|
|
257
|
+
description: "A prompt resolved at a specific version.",
|
|
258
|
+
identifier: "ResolvedPrompt"
|
|
259
|
+
});
|
|
260
|
+
const PublicVersion = Schema.Struct({
|
|
261
|
+
createdAt: Instant,
|
|
262
|
+
message: Schema.NullOr(CommitMessage),
|
|
263
|
+
version: VersionNumber
|
|
264
|
+
}).annotations({
|
|
265
|
+
description: "One entry in a prompt's history.",
|
|
266
|
+
identifier: "Version"
|
|
267
|
+
});
|
|
268
|
+
const PublicPromptWithVersions = Schema.extend(PublicPrompt, Schema.Struct({ versions: Schema.optional(Schema.Array(PublicVersion)) })).annotations({
|
|
269
|
+
description: "A prompt, with its version history when `includeVersions` is set.",
|
|
270
|
+
identifier: "Prompt"
|
|
271
|
+
});
|
|
272
|
+
const PublicPromptSummary = Schema.Struct({
|
|
273
|
+
id: PromptId,
|
|
274
|
+
latestVersion: Schema.NullOr(VersionNumber),
|
|
275
|
+
name: PromptName,
|
|
276
|
+
productionVersion: Schema.NullOr(VersionNumber),
|
|
277
|
+
updatedAt: Instant
|
|
278
|
+
}).annotations({
|
|
279
|
+
description: "A prompt without its content.",
|
|
280
|
+
identifier: "PromptSummary"
|
|
281
|
+
});
|
|
282
|
+
const PromptList = Schema.Struct({ data: Schema.Array(PublicPromptSummary) }).annotations({
|
|
283
|
+
description: "Every prompt in the organization.",
|
|
284
|
+
identifier: "PromptList"
|
|
285
|
+
});
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region ../schema/src/public/prompts-api.ts
|
|
288
|
+
var PublicPromptsGroup = class extends HttpApiGroup.make("prompts").add(HttpApiEndpoint.post("get", "/prompts.get").setPayload(GetPromptRequest).addSuccess(PublicPromptWithVersions).annotate(OpenApi.Summary, "Resolve a prompt").annotate(OpenApi.Description, "Returns the content a caller should send to a model. With no selector this follows the organization's default channel.")).add(HttpApiEndpoint.post("list", "/prompts.list").setPayload(ListPromptsRequest).addSuccess(PromptList).annotate(OpenApi.Summary, "List prompts").annotate(OpenApi.Description, "Up to 100 prompts in the organization, without content.")).add(HttpApiEndpoint.post("create", "/prompts.create").setPayload(CreatePromptRequest).addSuccess(PublicPromptWithVersions).annotate(OpenApi.Summary, "Create a prompt").annotate(OpenApi.Description, "Creates the prompt and its first version in one call.")).add(HttpApiEndpoint.post("update", "/prompts.update").setPayload(UpdatePromptRequest).addSuccess(PublicPromptWithVersions).annotate(OpenApi.Summary, "Add a version").annotate(OpenApi.Description, "Content is versioned, so updating a prompt appends a version rather than overwriting one. Earlier versions stay readable.")).add(HttpApiEndpoint.post("promote", "/prompts.promote").setPayload(PromotePromptRequest).addSuccess(Ok).annotate(OpenApi.Summary, "Promote a version to a channel").annotate(OpenApi.Description, "Points a channel, such as production, at a version. This is how a version goes live without callers changing anything.")).addError(BadRequest).addError(Forbidden).addError(Conflict).addError(NotFound).middleware(ApiKeyAuthentication).annotate(OpenApi.Title, "Prompts").annotate(OpenApi.Description, "Read and write prompts. Content is versioned, so writes append rather than overwrite, and channels decide which version callers receive.") {};
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region ../schema/src/public/api.ts
|
|
291
|
+
var PublicApi = class extends HttpApi.make("anpord-public").add(PublicEvalsGroup).add(PublicPromptsGroup).prefix("/v1").annotate(OpenApi.Title, "Anpord API").annotate(OpenApi.Version, "1.0.0").annotate(OpenApi.Description, "Run agent evals and manage prompts. Every endpoint takes a JSON body over POST and authenticates with a bearer API key.").annotate(OpenApi.Servers, [{
|
|
292
|
+
description: "Production",
|
|
293
|
+
url: "https://api.anpord.com"
|
|
294
|
+
}]) {};
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region ../schema/src/public/client.ts
|
|
297
|
+
const DEFAULT_BASE_URL = "https://api.anpord.com";
|
|
298
|
+
const make = ({ apiKey, baseUrl = DEFAULT_BASE_URL }) => HttpApiClient.make(PublicApi, {
|
|
299
|
+
baseUrl,
|
|
300
|
+
transformClient: HttpClient.mapRequest(HttpClientRequest.bearerToken(Redacted.value(apiKey)))
|
|
301
|
+
});
|
|
302
|
+
var AnpordApi = class extends Effect.Tag("@anpord/sdk/AnpordApi")() {};
|
|
303
|
+
const layer = (options) => Layer.effect(AnpordApi, make(options)).pipe(Layer.provide(FetchHttpClient.layer));
|
|
304
|
+
//#endregion
|
|
305
|
+
export { ChannelName as a, make as i, DEFAULT_BASE_URL as n, PromptId as o, layer as r, VersionNumber as s, AnpordApi as t };
|