@alisio/sdk 0.1.0-alpha.19 → 0.1.0-alpha.20
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/dist/index.d.ts +50 -3
- package/dist/index.js +16 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -546,6 +546,17 @@ export interface RunTimeoutInfo {
|
|
|
546
546
|
*/
|
|
547
547
|
attempts?: number;
|
|
548
548
|
}
|
|
549
|
+
/** What a `run_failed` event with `code: "output_truncated"` says about the limit that cut it. */
|
|
550
|
+
export interface RunTruncationInfo {
|
|
551
|
+
/** How many responses were cut off (the first plus every recovery). */
|
|
552
|
+
attempts: number;
|
|
553
|
+
/** The output-token budget of the cut requests (the effective one, see `source`). */
|
|
554
|
+
maxOutputTokens: number;
|
|
555
|
+
/** Where that budget came from: the user, the model's catalog, or the default. */
|
|
556
|
+
source?: "user" | "model" | "default";
|
|
557
|
+
/** The model whose responses were cut. */
|
|
558
|
+
model?: string;
|
|
559
|
+
}
|
|
549
560
|
/**
|
|
550
561
|
* Payload of each event type the core emits today, keyed by `RunEvent.type`. Additive: new
|
|
551
562
|
* types and new optional fields may appear; existing fields keep their meaning.
|
|
@@ -627,9 +638,14 @@ export interface RunEventDataMap {
|
|
|
627
638
|
text: string;
|
|
628
639
|
truncated?: boolean;
|
|
629
640
|
};
|
|
641
|
+
/**
|
|
642
|
+
* `maxOutputTokens` is the effective budget of the cut request; `source` says whether it was
|
|
643
|
+
* set by the user, taken from the model's catalog, or the default.
|
|
644
|
+
*/
|
|
630
645
|
response_truncated: {
|
|
631
646
|
turn: number;
|
|
632
647
|
maxOutputTokens: number;
|
|
648
|
+
source?: "user" | "model" | "default";
|
|
633
649
|
};
|
|
634
650
|
/**
|
|
635
651
|
* A model request stayed completely silent for `limits.firstTokenTimeoutMs` and the same
|
|
@@ -643,19 +659,37 @@ export interface RunEventDataMap {
|
|
|
643
659
|
reason: "first_token_timeout";
|
|
644
660
|
afterMs: number;
|
|
645
661
|
};
|
|
662
|
+
/**
|
|
663
|
+
* A model response was cut off by the output-token limit before it was usable (no text and no
|
|
664
|
+
* tool call, or a tool call whose arguments are incomplete) and the same turn is requested
|
|
665
|
+
* again with a short continuation notice. The truncated tool calls were discarded, never
|
|
666
|
+
* executed or persisted, and the retry is not a turn. `attempt` is the recovery about to start
|
|
667
|
+
* (1-based), `of` the recoveries allowed (`limits.truncationRecoveries`), `reason` what was
|
|
668
|
+
* lost, and `effort` the lowered reasoning effort of that request, when one was applied.
|
|
669
|
+
*/
|
|
670
|
+
truncation_recovery: {
|
|
671
|
+
attempt: number;
|
|
672
|
+
of: number;
|
|
673
|
+
reason: "tool_call_cut" | "empty_response";
|
|
674
|
+
maxOutputTokens: number;
|
|
675
|
+
effort?: string;
|
|
676
|
+
};
|
|
646
677
|
run_turns_exceeded: {
|
|
647
678
|
turns: number;
|
|
648
679
|
maxTurns: number;
|
|
649
680
|
};
|
|
650
681
|
/**
|
|
651
682
|
* The run failed. `error` is always a human-readable message. `code: "timeout"` (with `timeout`)
|
|
652
|
-
* marks a run stopped by a time limit instead of a provider or tool error;
|
|
653
|
-
*
|
|
683
|
+
* marks a run stopped by a time limit instead of a provider or tool error;
|
|
684
|
+
* `code: "output_truncated"` (with `truncation`) a run whose responses kept being cut off by
|
|
685
|
+
* the output-token limit after the allowed recoveries. These fields are additive and absent
|
|
686
|
+
* for every other failure.
|
|
654
687
|
*/
|
|
655
688
|
run_failed: {
|
|
656
689
|
error: string;
|
|
657
|
-
code?: "timeout";
|
|
690
|
+
code?: "timeout" | "output_truncated";
|
|
658
691
|
timeout?: RunTimeoutInfo;
|
|
692
|
+
truncation?: RunTruncationInfo;
|
|
659
693
|
};
|
|
660
694
|
run_cancelled: {
|
|
661
695
|
error: string;
|
|
@@ -1945,6 +1979,19 @@ export interface ApiError {
|
|
|
1945
1979
|
correlationId: string;
|
|
1946
1980
|
}
|
|
1947
1981
|
export declare function definePlugin<T extends Plugin>(plugin: T): T;
|
|
1982
|
+
/** `OutputTruncatedError.code`: a provider's reply was cut off by the output-token limit. */
|
|
1983
|
+
export declare const OUTPUT_TRUNCATED_CODE = "output_truncated";
|
|
1984
|
+
/**
|
|
1985
|
+
* A provider that cannot yield a usable `completed` message because the output-token limit cut
|
|
1986
|
+
* the response before anything usable existed (no text and no complete tool call) throws this,
|
|
1987
|
+
* so the host can recover instead of failing the run. Hosts match on `code` (not `instanceof`),
|
|
1988
|
+
* because a plugin may bundle its own copy of this package. Prefer yielding `completed` with
|
|
1989
|
+
* `truncated: true` whenever the partial message is representable.
|
|
1990
|
+
*/
|
|
1991
|
+
export declare class OutputTruncatedError extends Error {
|
|
1992
|
+
readonly code = "output_truncated";
|
|
1993
|
+
constructor(message?: string);
|
|
1994
|
+
}
|
|
1948
1995
|
export declare const textResult: (text: string, isError?: boolean) => ToolResult;
|
|
1949
1996
|
/**
|
|
1950
1997
|
* Text-only view of a tool result: the content filtered to its text parts, order preserved.
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,22 @@ export function isEphemeralRunEventType(type) {
|
|
|
30
30
|
export function definePlugin(plugin) {
|
|
31
31
|
return plugin;
|
|
32
32
|
}
|
|
33
|
+
/** `OutputTruncatedError.code`: a provider's reply was cut off by the output-token limit. */
|
|
34
|
+
export const OUTPUT_TRUNCATED_CODE = "output_truncated";
|
|
35
|
+
/**
|
|
36
|
+
* A provider that cannot yield a usable `completed` message because the output-token limit cut
|
|
37
|
+
* the response before anything usable existed (no text and no complete tool call) throws this,
|
|
38
|
+
* so the host can recover instead of failing the run. Hosts match on `code` (not `instanceof`),
|
|
39
|
+
* because a plugin may bundle its own copy of this package. Prefer yielding `completed` with
|
|
40
|
+
* `truncated: true` whenever the partial message is representable.
|
|
41
|
+
*/
|
|
42
|
+
export class OutputTruncatedError extends Error {
|
|
43
|
+
code = OUTPUT_TRUNCATED_CODE;
|
|
44
|
+
constructor(message = "The response was cut off by the output-token limit.") {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "OutputTruncatedError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
33
49
|
export const textResult = (text, isError = false) => ({
|
|
34
50
|
content: [{ type: "text", text }],
|
|
35
51
|
...(isError ? { isError: true } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alisio/sdk",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
4
|
"description": "Typed plugin SDK for Alisio: the stable contract for tools, commands, context, compaction and session hooks, model completions and storage. Types only plus tiny helpers; zero runtime dependencies.",
|
|
5
5
|
"author": "Gustavo Gutiérrez",
|
|
6
6
|
"license": "MIT",
|