@yaklabs-ai/plugin-sdk 0.13.7 → 0.13.9
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 +10 -5
- package/THIRD-PARTY-INVENTORY.json +1 -1
- package/dist/disclosure.d.ts +303 -0
- package/dist/disclosure.js +64 -0
- package/dist/kay-agent-testing.d.ts +304 -1
- package/dist/kay-agent-testing.js +65 -0
- package/dist/kay-agent.d.ts +303 -0
- package/dist/kay-app.d.ts +330 -7
- package/dist/kay-app.js +13 -11
- package/dist/system-one.d.ts +326 -0
- package/dist/system-one.js +69 -0
- package/dist/zod.d.ts +5 -0
- package/dist/zod.js +5 -0
- package/package.json +9 -1
- package/skills/directory-plugin-authoring/SKILL.md +2 -1
|
@@ -203,6 +203,12 @@ declare interface AuthAccount {
|
|
|
203
203
|
readonly needsReconnect?: boolean;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
declare interface Availability {
|
|
207
|
+
readonly available: boolean;
|
|
208
|
+
readonly reason?: string;
|
|
209
|
+
readonly cause?: SystemOneFailureCause;
|
|
210
|
+
}
|
|
211
|
+
|
|
206
212
|
declare interface BackgroundTaskAdoptOptions {
|
|
207
213
|
readonly preferredId?: string;
|
|
208
214
|
readonly toolCallId?: string;
|
|
@@ -504,6 +510,85 @@ declare function CyclicOptions(type: TCyclic): TSchemaOptions;
|
|
|
504
510
|
|
|
505
511
|
declare type CyclicStackLength<Stack extends unknown[], MaxLength extends number, Buffer extends unknown[] = []> = (Stack extends [infer Left, ...infer Right] ? Buffer['length'] extends MaxLength ? false : CyclicStackLength<Right, MaxLength, [...Buffer, Left]> : true);
|
|
506
512
|
|
|
513
|
+
declare type DecideAnswerFor<Q> = Q extends DecideBoolQuestion ? DecideBoolAnswer : Q extends DecideChoiceQuestion<infer L> ? DecideChoiceAnswer<L> : Q extends DecideScoreQuestion ? DecideScoreAnswer : never;
|
|
514
|
+
|
|
515
|
+
declare interface DecideBoolAnswer {
|
|
516
|
+
readonly type: "bool";
|
|
517
|
+
/** P(yes), from 0 to 1. */
|
|
518
|
+
readonly probability: number;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/** A yes/no question. `criteria` says what yes and what no mean; omit it to leave both open. */
|
|
522
|
+
declare interface DecideBoolQuestion {
|
|
523
|
+
readonly type: "bool";
|
|
524
|
+
readonly instructions: DecideInstructions;
|
|
525
|
+
readonly criteria?: {
|
|
526
|
+
readonly true: string;
|
|
527
|
+
readonly false: string;
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
declare interface DecideChoiceAnswer<L extends string = string> {
|
|
532
|
+
readonly type: "choice";
|
|
533
|
+
readonly choice: L;
|
|
534
|
+
readonly confidence: number;
|
|
535
|
+
/** P(label) for every offered label. */
|
|
536
|
+
readonly probabilities: Readonly<Record<L, number>>;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** A choice among labels. Each label maps to what it means; an empty string leaves it open. */
|
|
540
|
+
declare interface DecideChoiceQuestion<L extends string = string> {
|
|
541
|
+
readonly type: "choice";
|
|
542
|
+
readonly instructions: DecideInstructions;
|
|
543
|
+
readonly criteria: Readonly<Record<L, string>>;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/** What a question asks: text, or a JSON object the client sends as its JSON text. */
|
|
547
|
+
declare type DecideInstructions = string | object;
|
|
548
|
+
|
|
549
|
+
declare type DecideModelId = "jev" | "clef" | "clef-flash";
|
|
550
|
+
|
|
551
|
+
declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | DecideScoreQuestion;
|
|
552
|
+
|
|
553
|
+
/** Questions keyed by the name each answer comes back under. */
|
|
554
|
+
declare type DecideQuestions = Readonly<Record<string, DecideQuestion>>;
|
|
555
|
+
|
|
556
|
+
declare interface DecideRequest<Q extends DecideQuestions = DecideQuestions> {
|
|
557
|
+
/** Defaults to `jev`. */
|
|
558
|
+
readonly model?: DecideModelId;
|
|
559
|
+
readonly state: DecideState;
|
|
560
|
+
readonly questions: Q;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
declare interface DecideScoreAnswer {
|
|
564
|
+
readonly type: "score";
|
|
565
|
+
/** The expected level, from 0 to the number of levels minus one. */
|
|
566
|
+
readonly score: number;
|
|
567
|
+
readonly confidence: number;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/** A score over ordered levels: the first criterion scores 0, the next 1, and so on. */
|
|
571
|
+
declare interface DecideScoreQuestion {
|
|
572
|
+
readonly type: "score";
|
|
573
|
+
readonly instructions: DecideInstructions;
|
|
574
|
+
readonly criteria: readonly string[];
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* What a decide call reads. A JSON value is sent as JSON; every value must survive
|
|
579
|
+
* `JSON.stringify` unchanged.
|
|
580
|
+
*/
|
|
581
|
+
declare type DecideState = string | object;
|
|
582
|
+
|
|
583
|
+
/** Every asked question has an answer of its own kind. */
|
|
584
|
+
declare interface Decision<Q extends DecideQuestions = DecideQuestions> {
|
|
585
|
+
readonly model: DecideModelId;
|
|
586
|
+
readonly answers: {
|
|
587
|
+
readonly [K in keyof Q]: DecideAnswerFor<Q[K]>;
|
|
588
|
+
};
|
|
589
|
+
readonly usage?: SystemOneTokenUsage;
|
|
590
|
+
}
|
|
591
|
+
|
|
507
592
|
/** Createsa uni-directional Codec with Decode only. The Decode function is called on Value.Decode */
|
|
508
593
|
declare function Decode<Type extends TSchema, Callback extends TDecodeCallback<StaticDecode<Type>, unknown>>(type: Type, callback: Callback): TCodec<Type, ReturnType<Callback>>;
|
|
509
594
|
|
|
@@ -597,6 +682,8 @@ declare const DollarSign = "$";
|
|
|
597
682
|
|
|
598
683
|
declare const Dot = ".";
|
|
599
684
|
|
|
685
|
+
declare type DurationUnit = "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years";
|
|
686
|
+
|
|
600
687
|
declare const Element: (input: string) => [unknown, string] | [];
|
|
601
688
|
|
|
602
689
|
declare const ElementBase: (input: string) => [unknown, string] | [];
|
|
@@ -631,6 +718,18 @@ declare function Enum<Values extends TEnumValue[]>(values: readonly [...Values],
|
|
|
631
718
|
/** Creates an Enum type from a TypeScript enum declaration. */
|
|
632
719
|
declare function Enum<Enum extends TTypeScriptEnumLike>(value: Enum, options?: TSchemaOptions): TEnum<TTypeScriptEnumToEnumValues<Enum>>;
|
|
633
720
|
|
|
721
|
+
declare interface EstimateDistribution<V> {
|
|
722
|
+
readonly value: V | null;
|
|
723
|
+
readonly mean?: V;
|
|
724
|
+
readonly median?: V;
|
|
725
|
+
readonly p10?: V;
|
|
726
|
+
readonly p90?: V;
|
|
727
|
+
/** P(value < min). */
|
|
728
|
+
readonly pBelow?: number;
|
|
729
|
+
/** P(value > max). */
|
|
730
|
+
readonly pAbove?: number;
|
|
731
|
+
}
|
|
732
|
+
|
|
634
733
|
/** Applies an Evaluate action to a type. */
|
|
635
734
|
declare function Evaluate<Type extends TSchema>(type: Type, options?: TSchemaOptions): TEvaluate<Type>;
|
|
636
735
|
|
|
@@ -808,9 +907,129 @@ declare interface ExtensionPaths {
|
|
|
808
907
|
/** Applies an Extract action using the given types. */
|
|
809
908
|
declare function Extract_2<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options?: TSchemaOptions): TExtract<Left, Right>;
|
|
810
909
|
|
|
910
|
+
declare type ExtractAnswerFor<F> = F extends ExtractTextField ? ExtractValueAnswer<"text", string> : F extends ExtractNumberField ? ExtractValueAnswer<"number", number> : F extends ExtractDateTimeField ? ExtractValueAnswer<F["type"], string> : F extends ExtractDurationField ? ExtractValueAnswer<"duration", number> : F extends ExtractListField ? ExtractListAnswer<F["items"] extends "number" ? number : string> : F extends ExtractEstimateField ? ExtractEstimateAnswer<F["min"] extends string ? string : number> : F extends ExtractForecastField ? ExtractForecastAnswer : never;
|
|
911
|
+
|
|
912
|
+
/** `date` answers are ISO dates, `time` ISO times, `datetime` ISO date-times. */
|
|
913
|
+
declare interface ExtractDateTimeField extends ExtractFieldBase {
|
|
914
|
+
readonly type: "date" | "time" | "datetime";
|
|
915
|
+
}
|
|
916
|
+
|
|
811
917
|
/** Creates a deferred Extract action. */
|
|
812
918
|
declare function ExtractDeferred<Left extends TSchema, Right extends TSchema>(left: Left, right: Right, options?: TSchemaOptions): TExtractDeferred<Left, Right>;
|
|
813
919
|
|
|
920
|
+
declare interface ExtractDurationField extends ExtractFieldBase {
|
|
921
|
+
readonly type: "duration";
|
|
922
|
+
/** Seconds when omitted. */
|
|
923
|
+
readonly unit?: DurationUnit;
|
|
924
|
+
readonly integer?: boolean;
|
|
925
|
+
readonly decimals?: number;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
declare interface ExtractEstimateAnswer<V = number | string> extends EstimateDistribution<V> {
|
|
929
|
+
readonly type: "estimate";
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/** A distribution over one value. `min`/`max` are numbers, or ISO dates for a date estimate. */
|
|
933
|
+
declare interface ExtractEstimateField extends ExtractFieldBase {
|
|
934
|
+
readonly type: "estimate";
|
|
935
|
+
readonly min: number | string;
|
|
936
|
+
readonly max: number | string;
|
|
937
|
+
/** Grid step: a positive number (days for a date estimate), `month` or `year`. */
|
|
938
|
+
readonly step?: number | "month" | "year";
|
|
939
|
+
readonly scale?: "linear" | "log";
|
|
940
|
+
readonly unit?: string;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
declare type ExtractField = ExtractTextField | ExtractNumberField | ExtractDateTimeField | ExtractDurationField | ExtractListField | ExtractEstimateField | ExtractForecastField;
|
|
944
|
+
|
|
945
|
+
declare interface ExtractFieldBase {
|
|
946
|
+
readonly instructions?: string;
|
|
947
|
+
/** P(null) above which the value is null. Clairic's default is 0.5. */
|
|
948
|
+
readonly nullThreshold?: number;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/** Fields keyed by name. A name matches `^[A-Za-z_][A-Za-z0-9_.\-]{0,63}$`. */
|
|
952
|
+
declare type ExtractFields = Readonly<Record<string, ExtractField>>;
|
|
953
|
+
|
|
954
|
+
declare interface ExtractForecastAnswer {
|
|
955
|
+
readonly type: "forecast";
|
|
956
|
+
/** One value per step; `null` when the state does not determine the forecast. */
|
|
957
|
+
readonly value: readonly number[] | null;
|
|
958
|
+
readonly steps: readonly EstimateDistribution<number>[];
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/** One distribution per future step. */
|
|
962
|
+
declare interface ExtractForecastField extends ExtractFieldBase {
|
|
963
|
+
readonly type: "forecast";
|
|
964
|
+
readonly min: number;
|
|
965
|
+
readonly max: number;
|
|
966
|
+
/** Number of steps, 1 to 64. */
|
|
967
|
+
readonly horizon: number;
|
|
968
|
+
readonly interval?: ForecastInterval;
|
|
969
|
+
readonly scale?: "linear" | "log";
|
|
970
|
+
readonly unit?: string;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
declare interface Extraction<F extends ExtractFields = ExtractFields> {
|
|
974
|
+
readonly model: ExtractModelId;
|
|
975
|
+
readonly answers: {
|
|
976
|
+
readonly [K in keyof F]: ExtractAnswerFor<F[K]>;
|
|
977
|
+
};
|
|
978
|
+
/** The state was cut to fit the model's context. */
|
|
979
|
+
readonly truncated: boolean;
|
|
980
|
+
readonly usage?: SystemOneTokenUsage;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
declare interface ExtractListAnswer<V> {
|
|
984
|
+
readonly type: "list";
|
|
985
|
+
readonly value: readonly V[] | null;
|
|
986
|
+
readonly confidence?: number;
|
|
987
|
+
/** One per item in `value`. */
|
|
988
|
+
readonly confidences?: readonly number[];
|
|
989
|
+
readonly spans?: readonly TextSpan[];
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
declare interface ExtractListField extends ExtractFieldBase {
|
|
993
|
+
readonly type: "list";
|
|
994
|
+
readonly items: "text" | "number" | "date";
|
|
995
|
+
readonly decimals?: number;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
declare type ExtractModelId = "clairic";
|
|
999
|
+
|
|
1000
|
+
declare interface ExtractNumberField extends ExtractFieldBase {
|
|
1001
|
+
readonly type: "number";
|
|
1002
|
+
readonly unit?: string;
|
|
1003
|
+
readonly integer?: boolean;
|
|
1004
|
+
/** 0 to 6. */
|
|
1005
|
+
readonly decimals?: number;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
declare interface ExtractRequest<F extends ExtractFields = ExtractFields> {
|
|
1009
|
+
readonly model: ExtractModelId;
|
|
1010
|
+
/** Text only; JSON is not accepted. */
|
|
1011
|
+
readonly state: string;
|
|
1012
|
+
readonly fields: F;
|
|
1013
|
+
/** ISO date that anchors dates written without a year. */
|
|
1014
|
+
readonly referenceDate?: string;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
declare interface ExtractTextField extends ExtractFieldBase {
|
|
1018
|
+
readonly type: "text";
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
declare interface ExtractValueAnswer<T extends "text" | "number" | "date" | "time" | "datetime" | "duration", V> {
|
|
1022
|
+
readonly type: T;
|
|
1023
|
+
/** `null` when the state does not determine the value. */
|
|
1024
|
+
readonly value: V | null;
|
|
1025
|
+
/** The best candidate even when `value` is null. */
|
|
1026
|
+
readonly guess?: V;
|
|
1027
|
+
readonly confidence?: number;
|
|
1028
|
+
readonly pNull?: number;
|
|
1029
|
+
readonly span?: TextSpan;
|
|
1030
|
+
readonly unit?: string;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
814
1033
|
declare const Factor: (input: string) => [unknown, string] | [];
|
|
815
1034
|
|
|
816
1035
|
declare function FactorMapping(input: [unknown, unknown, unknown, unknown, unknown]): unknown;
|
|
@@ -827,10 +1046,12 @@ declare function FactorMapping(input: [unknown, unknown, unknown, unknown, unkno
|
|
|
827
1046
|
export declare function fauxAuthContext(overrides?: Partial<ExtensionAuthContext>): ExtensionAuthContext;
|
|
828
1047
|
|
|
829
1048
|
/** The capability handles a `KayAgentPluginApi` always carries — authority is decided per call. */
|
|
830
|
-
export declare type FauxKayAgentCapabilities = Pick<KayAgentPluginApi, "network" | "webSession" | "process" | "whiteboard" | "interaction" | "interceptToolCall" | "withJev" | "events" | "time" | "userFiles" | "familyFolder">;
|
|
1049
|
+
export declare type FauxKayAgentCapabilities = Pick<KayAgentPluginApi, "network" | "webSession" | "process" | "whiteboard" | "interaction" | "interceptToolCall" | "withJev" | "systemOne" | "events" | "time" | "userFiles" | "familyFolder">;
|
|
831
1050
|
|
|
832
1051
|
export declare function fauxKayAgentCapabilities(): FauxKayAgentCapabilities;
|
|
833
1052
|
|
|
1053
|
+
declare type ForecastInterval = "step" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
|
|
1054
|
+
|
|
834
1055
|
/** Creates a Function type. */
|
|
835
1056
|
declare function _Function_<Parameters extends TSchema[], ReturnType extends TSchema>(parameters: [...Parameters], returnType: ReturnType, options?: TSchemaOptions): TFunction<Parameters, ReturnType>;
|
|
836
1057
|
|
|
@@ -1726,6 +1947,15 @@ declare interface KayAgentPluginApi {
|
|
|
1726
1947
|
* guard it with `if (api.withJev !== undefined)`.
|
|
1727
1948
|
*/
|
|
1728
1949
|
readonly withJev: WithJev;
|
|
1950
|
+
/**
|
|
1951
|
+
* System One: fast, cheap judgment calls (`decide`) and typed field extraction (`extract`) on
|
|
1952
|
+
* small models (Jev, Clef, Clef Flash, Clairic). Each call is checked against `jev.use`; a call
|
|
1953
|
+
* that cannot be served or is not permitted throws a `SystemOneError` whose `cause.kind` says
|
|
1954
|
+
* why, so put the feature's cheaper path in the call's own `catch`. Always present, on every
|
|
1955
|
+
* host; a host with no System One throws `not-served`. Types: `@bonsai/plugin-sdk/system-one`
|
|
1956
|
+
* (SDK 0.13.8).
|
|
1957
|
+
*/
|
|
1958
|
+
readonly systemOne: SystemOneClient;
|
|
1729
1959
|
/**
|
|
1730
1960
|
* The daemon's clock and the time zone the user is in, read together on each `snapshot()` call.
|
|
1731
1961
|
* Always present and ungated: it confers no authority, since a plugin runs in the daemon's
|
|
@@ -4284,6 +4514,76 @@ declare const StringPattern = ".*";
|
|
|
4284
4514
|
/** Creates a Symbol type. */
|
|
4285
4515
|
declare function Symbol_2(options?: TSchemaOptions): TSymbol;
|
|
4286
4516
|
|
|
4517
|
+
declare interface SystemOneCallOptions {
|
|
4518
|
+
readonly signal?: AbortSignal;
|
|
4519
|
+
/** Bounds the whole call, retries included. */
|
|
4520
|
+
readonly timeoutMs?: number;
|
|
4521
|
+
/** What the call is for, carried to the host's usage accounting. Never sent to a provider. */
|
|
4522
|
+
readonly purpose?: string;
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
declare interface SystemOneClient {
|
|
4526
|
+
decide<const Q extends DecideQuestions>(request: DecideRequest<Q>, options?: SystemOneCallOptions): Promise<Decision<Q>>;
|
|
4527
|
+
extract<const F extends ExtractFields>(request: ExtractRequest<F>, options?: SystemOneCallOptions): Promise<Extraction<F>>;
|
|
4528
|
+
/** Whether some provider in the current order can serve `(kind, model)`. Never rejects. */
|
|
4529
|
+
availability(kind: SystemOneKind, model?: SystemOneModelId): Promise<Availability>;
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
/**
|
|
4533
|
+
* Why a call failed or a provider can't serve, as a closed set. Never prose, and never the
|
|
4534
|
+
* vendor's body: bodies can echo the request's state.
|
|
4535
|
+
*/
|
|
4536
|
+
declare type SystemOneFailureCause = {
|
|
4537
|
+
readonly kind: "no-credential";
|
|
4538
|
+
} | {
|
|
4539
|
+
readonly kind: "credential-store";
|
|
4540
|
+
} | {
|
|
4541
|
+
readonly kind: "not-served";
|
|
4542
|
+
} | {
|
|
4543
|
+
readonly kind: "not-permitted";
|
|
4544
|
+
} | {
|
|
4545
|
+
readonly kind: "unknown-model";
|
|
4546
|
+
} | {
|
|
4547
|
+
readonly kind: "invalid-request";
|
|
4548
|
+
readonly detail: string;
|
|
4549
|
+
} | {
|
|
4550
|
+
readonly kind: "too-large";
|
|
4551
|
+
} | {
|
|
4552
|
+
readonly kind: "http";
|
|
4553
|
+
readonly status: number;
|
|
4554
|
+
} | {
|
|
4555
|
+
readonly kind: "transport";
|
|
4556
|
+
} | {
|
|
4557
|
+
readonly kind: "timeout";
|
|
4558
|
+
} | {
|
|
4559
|
+
readonly kind: "aborted";
|
|
4560
|
+
} | {
|
|
4561
|
+
readonly kind: "invalid-answer";
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4564
|
+
/**
|
|
4565
|
+
* ---
|
|
4566
|
+
* responsibility: The data shapes of the System One surface: models, the decide and extract
|
|
4567
|
+
* vocabularies, providers, and the failure causes.
|
|
4568
|
+
* owns:
|
|
4569
|
+
* - The caller-facing question, field, answer, and result types, in Bonsai's own words
|
|
4570
|
+
* (`bool` for yes/no, camelCase options). The vendors' words (`noul`, snake_case) appear
|
|
4571
|
+
* only in `wire.ts`.
|
|
4572
|
+
* - {@link SystemOneProvider}, the seam a transport implements.
|
|
4573
|
+
* does_not_own:
|
|
4574
|
+
* - Which models exist (`models.ts`), how answers are checked (`wire.ts`), or how a provider is
|
|
4575
|
+
* picked (`system-one-client.ts`).
|
|
4576
|
+
* ---
|
|
4577
|
+
*/
|
|
4578
|
+
declare type SystemOneKind = "decide" | "extract";
|
|
4579
|
+
|
|
4580
|
+
declare type SystemOneModelId = DecideModelId | ExtractModelId;
|
|
4581
|
+
|
|
4582
|
+
declare interface SystemOneTokenUsage {
|
|
4583
|
+
readonly inputTokens: number;
|
|
4584
|
+
readonly outputTokens: number;
|
|
4585
|
+
}
|
|
4586
|
+
|
|
4287
4587
|
declare namespace T {
|
|
4288
4588
|
export {
|
|
4289
4589
|
Codec,
|
|
@@ -5340,6 +5640,9 @@ declare type TExtractType<Left extends TSchema, Right extends TSchema, Check ext
|
|
|
5340
5640
|
|
|
5341
5641
|
declare type TExtractUnion<Left extends TSchema[], Right extends TSchema, Result extends TSchema[] = []> = (Left extends [infer Head extends TSchema, ...infer Tail extends TSchema[]] ? TExtractUnion<Tail, Right, [...Result, ...TExtractType<Head, Right>]> : Result);
|
|
5342
5642
|
|
|
5643
|
+
/** `[start, end)` character offsets into the state. */
|
|
5644
|
+
declare type TextSpan = readonly [number, number];
|
|
5645
|
+
|
|
5343
5646
|
declare type TFactor<Input extends string> = (TKeyOf<Input> extends [infer _0, infer Input extends string] ? (TBase<Input> extends [infer _1, infer Input extends string] ? (TIndexArray<Input> extends [infer _2, infer Input extends string] ? (TExtends_2<Input> extends [infer _3, infer Input extends string] ? (TWith<Input> extends [infer _4, infer Input extends string] ? [[_0, _1, _2, _3, _4], Input] : []) : []) : []) : []) : []) extends [infer _0 extends [unknown, unknown, unknown, unknown, unknown], infer Input extends string] ? [S.TFactorMapping<_0>, Input] : [];
|
|
5344
5647
|
|
|
5345
5648
|
declare type TFactorExtends<Type extends T.TSchema, Extends extends unknown[]> = (Extends extends [infer Right extends T.TSchema, infer True extends T.TSchema, infer False extends T.TSchema] ? S_2.TConditionalDeferred<Type, Right, True, False> : Type);
|
|
@@ -34,6 +34,68 @@ function readProducedResourceDeclarations(details) {
|
|
|
34
34
|
return { kind: "declared", resources: claimed };
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// packages/system-one/dist/errors.js
|
|
38
|
+
var SystemOneError = class extends Error {
|
|
39
|
+
cause;
|
|
40
|
+
kind;
|
|
41
|
+
model;
|
|
42
|
+
/** The provider that failed; absent when no provider was tried. */
|
|
43
|
+
providerId;
|
|
44
|
+
constructor(init) {
|
|
45
|
+
super(describe(init));
|
|
46
|
+
this.name = "SystemOneError";
|
|
47
|
+
this.cause = init.cause;
|
|
48
|
+
this.kind = init.kind;
|
|
49
|
+
this.model = init.model;
|
|
50
|
+
this.providerId = init.providerId;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
function describe(init) {
|
|
54
|
+
const where = init.providerId === void 0 ? "" : ` on provider ${init.providerId}`;
|
|
55
|
+
const detail = init.cause.kind === "http" ? ` (HTTP ${init.cause.status})` : init.cause.kind === "invalid-request" ? ` (${init.cause.detail})` : "";
|
|
56
|
+
return `System One ${init.kind} on ${init.model}${where} failed: ${init.cause.kind}${detail}.`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// packages/system-one/dist/models.js
|
|
60
|
+
var DEFAULT_DECIDE_MODEL = "jev";
|
|
61
|
+
var SYSTEM_ONE_LIMITS = {
|
|
62
|
+
/** The serialized request body, in bytes. */
|
|
63
|
+
maxBodyBytes: 64 * 1024,
|
|
64
|
+
maxQuestions: 64,
|
|
65
|
+
maxFields: 32,
|
|
66
|
+
minChoiceOptions: 2,
|
|
67
|
+
maxChoiceOptions: 255,
|
|
68
|
+
minScoreLevels: 2,
|
|
69
|
+
maxScoreLevels: 10,
|
|
70
|
+
maxForecastHorizon: 64
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// packages/system-one/dist/unavailable.js
|
|
74
|
+
var NOT_SERVED = {
|
|
75
|
+
available: false,
|
|
76
|
+
reason: "This host has no System One models.",
|
|
77
|
+
cause: { kind: "not-served" }
|
|
78
|
+
};
|
|
79
|
+
function createUnavailableSystemOneClient() {
|
|
80
|
+
return {
|
|
81
|
+
decide(request) {
|
|
82
|
+
return Promise.reject(new SystemOneError({
|
|
83
|
+
kind: "decide",
|
|
84
|
+
model: request.model ?? DEFAULT_DECIDE_MODEL,
|
|
85
|
+
cause: { kind: "not-served" }
|
|
86
|
+
}));
|
|
87
|
+
},
|
|
88
|
+
extract(request) {
|
|
89
|
+
return Promise.reject(new SystemOneError({
|
|
90
|
+
kind: "extract",
|
|
91
|
+
model: request.model,
|
|
92
|
+
cause: { kind: "not-served" }
|
|
93
|
+
}));
|
|
94
|
+
},
|
|
95
|
+
availability: () => Promise.resolve(NOT_SERVED)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
37
99
|
// packages/plugin-primitives/dist/is-object.js
|
|
38
100
|
function isObject(value) {
|
|
39
101
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -169,6 +231,9 @@ function fauxKayAgentCapabilities() {
|
|
|
169
231
|
// client, no key, and no network, which is all a double here has to guarantee. A test that
|
|
170
232
|
// wants a real Jev answer overrides this handle after the spread, like any other.
|
|
171
233
|
withJev: async (_use, fallback) => fallback(),
|
|
234
|
+
// Throws `not-served`, so the plugin's own `catch` runs. A test that wants answers overrides
|
|
235
|
+
// this handle after the spread.
|
|
236
|
+
systemOne: createUnavailableSystemOneClient(),
|
|
172
237
|
// Accepts and drops, like the registrations above: the real `publish` never throws, so a
|
|
173
238
|
// rejecting double would fail tests for a reason production never has. A test asserting what
|
|
174
239
|
// its plugin publishes overrides this handle after the spread.
|