-
Notifications
You must be signed in to change notification settings - Fork 9
Fix launch checks and JavaScript package #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
effdc90
Fix launch checks and JavaScript package
snellingio ef48708
Merge latest main into launch fixes
snellingio 861bedf
Fix README wording
snellingio 746f241
Update GitHub Actions runtimes
snellingio 1e80d4f
Pin the setup-uv release
snellingio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { Content, QuestionBuilder, SystemOneResponse } from "./types.ts"; | ||
| export interface SystemClientOptions { | ||
| baseUrl?: string; | ||
| } | ||
| export interface SystemOneRequest<QS extends Record<string, QuestionBuilder>> { | ||
| state: Content; | ||
| questions: QS; | ||
| } | ||
| export declare class SystemClient { | ||
| private readonly baseUrl; | ||
| constructor(options?: SystemClientOptions); | ||
| systemOne<QS extends Record<string, QuestionBuilder>>(request: SystemOneRequest<QS>): Promise<SystemOneResponse<QS>>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| export class SystemClient { | ||
| baseUrl; | ||
| constructor(options = {}) { | ||
| this.baseUrl = (options.baseUrl ?? process.env.SYSTEM_BASE_URL ?? "http://127.0.0.1:8010").replace(/\/+$/, ""); | ||
| } | ||
| async systemOne(request) { | ||
| const response = await fetch(`${this.baseUrl}/evaluate`, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ | ||
| state: request.state, | ||
| questions: Object.fromEntries(Object.entries(request.questions).map(([name, builder]) => [name, builder.question])), | ||
| }), | ||
| signal: AbortSignal.timeout(30_000), | ||
| }); | ||
| if (!response.ok) { | ||
| throw new Error(`systemOne failed: HTTP ${response.status} ${(await response.text()).slice(0, 200)}`); | ||
| } | ||
| return (await response.json()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export { SystemClient } from "./client.ts"; | ||
| export type { SystemOneRequest, SystemClientOptions } from "./client.ts"; | ||
| export { choice, noul, score } from "./types.ts"; | ||
| export type { Answers, ChoiceAnswer, ChoiceBuilder, ChoiceQuestion, Content, NoulAnswer, NoulBuilder, NoulQuestion, QuestionBuilder, ScoreAnswer, ScoreBuilder, ScoreQuestion, SystemOneResponse, Usage, } from "./types.ts"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { SystemClient } from "./client.js"; | ||
| export { choice, noul, score } from "./types.js"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| export type Content = string | Record<string, unknown> | unknown[]; | ||
| export interface NoulQuestion { | ||
| type: "noul"; | ||
| instructions: Content; | ||
| criteria?: { | ||
| true?: string; | ||
| false?: string; | ||
| }; | ||
| } | ||
| export interface ChoiceQuestion<K extends string = string> { | ||
| type: "choice"; | ||
| instructions: Content; | ||
| criteria: Record<K, Content | null>; | ||
| } | ||
| export interface ScoreQuestion { | ||
| type: "score"; | ||
| instructions: Content; | ||
| criteria: Content[]; | ||
| } | ||
| export interface NoulBuilder { | ||
| readonly kind: "noul"; | ||
| readonly question: NoulQuestion; | ||
| } | ||
| export interface ChoiceBuilder<K extends string> { | ||
| readonly kind: "choice"; | ||
| readonly question: ChoiceQuestion<K>; | ||
| } | ||
| export interface ScoreBuilder { | ||
| readonly kind: "score"; | ||
| readonly question: ScoreQuestion; | ||
| } | ||
| export type QuestionBuilder = NoulBuilder | ChoiceBuilder<string> | ScoreBuilder; | ||
| export declare function noul(instructions: Content, criteria?: { | ||
| true?: string; | ||
| false?: string; | ||
| }): NoulBuilder; | ||
| export declare function choice<K extends string>(instructions: Content, options: { | ||
| [key in K]: Content | null; | ||
| }): ChoiceBuilder<K>; | ||
| export declare function score(instructions: Content, levels: Content[]): ScoreBuilder; | ||
| export interface NoulAnswer { | ||
| type: "noul"; | ||
| noul: number; | ||
| } | ||
| export interface ChoiceAnswer<K extends string = string> { | ||
| type: "choice"; | ||
| choice: K; | ||
| probabilities: Record<K, number>; | ||
| confidence: number; | ||
| } | ||
| export interface ScoreAnswer { | ||
| type: "score"; | ||
| score: number; | ||
| legend: Record<string, Content>; | ||
| probabilities: Record<string, number>; | ||
| confidence: number; | ||
| } | ||
| export type AnswerFor<Q> = Q extends { | ||
| question: ChoiceQuestion<infer K>; | ||
| } ? ChoiceAnswer<K> : Q extends { | ||
| question: NoulQuestion; | ||
| } ? NoulAnswer : Q extends { | ||
| question: ScoreQuestion; | ||
| } ? ScoreAnswer : never; | ||
| export type Answers<QS extends Record<string, QuestionBuilder>> = { | ||
| [K in keyof QS]: AnswerFor<QS[K]>; | ||
| }; | ||
| export interface Usage { | ||
| input_tokens: number; | ||
| output_tokens: number; | ||
| } | ||
| export interface SystemOneResponse<QS extends Record<string, QuestionBuilder>> { | ||
| model: string; | ||
| answers: Answers<QS>; | ||
| usage: Usage; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Question and answer types. Builders carry their option keys so the | ||
| // response's answers map is fully inferred from the questions you send. | ||
| export function noul(instructions, criteria) { | ||
| const question = criteria | ||
| ? { type: "noul", instructions, criteria } | ||
| : { type: "noul", instructions }; | ||
| return { kind: "noul", question }; | ||
| } | ||
| export function choice(instructions, options) { | ||
| return { kind: "choice", question: { type: "choice", instructions, criteria: options } }; | ||
| } | ||
| export function score(instructions, levels) { | ||
| return { kind: "score", question: { type: "score", instructions, criteria: levels } }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
|
|
||
| import { choice, noul, score, SystemClient } from "system-sdk"; | ||
|
|
||
| test("the built package exports its public API", () => { | ||
| assert.equal(choice("pick", { yes: null }).question.type, "choice"); | ||
| assert.equal(noul("check").question.type, "noul"); | ||
| assert.equal(score("rate", ["low", "high"]).question.type, "score"); | ||
| assert.equal(typeof SystemClient, "function"); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "declaration": true, | ||
| "noEmit": false, | ||
| "outDir": "dist", | ||
| "rewriteRelativeImportExtensions": true, | ||
| "rootDir": "src" | ||
| }, | ||
| "include": ["src/**/*.ts"] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Emit package-resolvable declaration imports.
sdks/javascript/dist/index.d.tsimports./client.tsand./types.ts, butfiles: ["dist"]publishes no.tsfiles. A TypeScript consumer of the packed SDK therefore cannot resolve the exported declarations. Use.jsrelative specifiers in the source so NodeNext emits declaration imports that resolve withindist, and add a package type-consumer check.🤖 Prompt for AI Agents