@oddington/sdk 0.1.35 → 0.1.36
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 +15 -0
- package/dist/browser.js +145 -43
- package/dist/index.js +7 -2
- package/dist/types/packages/sdk/src/public.d.ts +2 -0
- package/dist/types/packages/sdk/src/routine-definition-types.d.ts +1 -0
- package/dist/types/shared/app-routine-contract.d.ts +10 -1
- package/dist/types/shared/routine-ai-contract.d.ts +20 -6
- package/dist/types/shared/routine-ai-output-detail.d.ts +11 -0
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput
|
|
|
4
4
|
export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
|
|
5
5
|
export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
|
|
6
6
|
export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
|
|
7
|
+
export { RoutineAIError } from '../../../shared/routine-ai-contract.js';
|
|
8
|
+
export type { RoutineAIOutputIssue } from '../../../shared/routine-ai-output-detail.js';
|
|
7
9
|
export { InboxContractError, asksBlock, continueAsk, defineHandler, fileBlock, question, recordBlock, recordsBlock, resolveAsk, respond, richTextBlock, selection, } from '../../../shared/inbox-contract.js';
|
|
8
10
|
export type { AskInput, AuthoredSource, CapturedRecords, DigestInput, Handler, HandlerReference, HandlerRuntime, HandlerTransition, InboxBlock, InboxFile, JsonObject, JsonValue, PresentedField, PresentedRecord, PresentedRecordSummary, PublishedAsk, PublishedDigest, PublishedView, PublicationRequest, Question, QuestionInput, QuestionResponse, RecordCreate, RecordDelete, RecordReference, RecordSource, RecordUpdate, RepositoryCapabilities, RepositoryReceipt, Resolution, ResolutionInput, ResponseDefinition, } from '../../../shared/inbox-contract.js';
|
|
9
11
|
export type { CapturedRecordTableInput, RecordField, RecordTableInput, RecordValue, RecordViewInput, TableColumn, ViewRecord, } from '../../../shared/inbox-views.js';
|
|
@@ -23,6 +23,7 @@ export type RoutineAI = {
|
|
|
23
23
|
}): Promise<{
|
|
24
24
|
text: string;
|
|
25
25
|
}>;
|
|
26
|
+
/** Invalid output throws a catchable RoutineAIError with the original answer. */
|
|
26
27
|
generateObject<Schema extends RoutineSchema<unknown>>(input: {
|
|
27
28
|
instructions: string;
|
|
28
29
|
input: RoutineAIInput;
|
|
@@ -49,7 +49,16 @@ export declare class AppRoutineContractError extends Error {
|
|
|
49
49
|
export declare function isAppRoutineName(value: unknown): value is string;
|
|
50
50
|
/** One operation owns the property budget across input, result and all summaries. */
|
|
51
51
|
export declare function parseAppRoutineContract(value: unknown): AppRoutineContract;
|
|
52
|
-
export
|
|
52
|
+
export type RoutineSchemaIssue = {
|
|
53
|
+
reason: 'missing_field' | 'unexpected_field' | 'wrong_type' | 'out_of_bounds' | 'invalid_file';
|
|
54
|
+
path: string;
|
|
55
|
+
expected: AppValueSchema['type'];
|
|
56
|
+
received: 'missing' | 'null' | 'object' | 'array' | 'boolean' | 'string' | 'number' | 'other';
|
|
57
|
+
constraint?: 'maxLength' | 'maxItems' | 'minimum' | 'maximum';
|
|
58
|
+
limit?: number;
|
|
59
|
+
};
|
|
60
|
+
/** The optional observer explains the existing rejection; it never accepts or repairs a value. */
|
|
61
|
+
export declare function validateRoutineSchemaValue(schema: AppValueSchema, value: unknown, rejected?: (issue: RoutineSchemaIssue) => void): void;
|
|
53
62
|
/** Structural validation grants no execution or File-use authority. Values stay unchanged. */
|
|
54
63
|
export declare function validateAppRoutineInput(contract: AppRoutineContract, value: unknown): void;
|
|
55
64
|
export declare function validateAppRoutineResult(contract: AppRoutineContract, value?: unknown): void;
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { type AppValueSchema } from './app-routine-contract.js';
|
|
2
2
|
import { type File } from './files-contract.js';
|
|
3
|
-
|
|
3
|
+
import { type RoutineAIOutputIssue } from './routine-ai-output-detail.js';
|
|
4
|
+
/** Requests use the Run value bound; final answers use the same UTF-8 byte ceiling.
|
|
4
5
|
* Raw Files have no universal AI byte cap: adapters must measure their final
|
|
5
6
|
* encoded request against their own transport limit before dispatch. */
|
|
6
7
|
export declare const ROUTINE_AI_VALUE_BYTES: number;
|
|
8
|
+
/** Worst-case JSON escaping is six bytes per UTF-8 answer byte, plus framing. */
|
|
9
|
+
export declare const ROUTINE_AI_RESULT_BYTES: number;
|
|
7
10
|
export declare const ROUTINE_AI_EVIDENCE_BYTES: number;
|
|
8
11
|
export declare const ROUTINE_AI_OPERATION_MS = 120000;
|
|
9
12
|
export declare const ROUTINE_AI_ERROR_CODES: readonly ['access_denied', 'capability_unavailable', 'invalid_input', 'unsupported_file', 'file_unavailable', 'input_too_large', 'output_too_large', 'provider_failure', 'invalid_output', 'cancelled'];
|
|
10
13
|
export type RoutineAIErrorCode = typeof ROUTINE_AI_ERROR_CODES[number];
|
|
11
|
-
/**
|
|
14
|
+
/** The original answer is explicit recovery data, never part of the message or JSON logging. */
|
|
12
15
|
export declare class RoutineAIError extends Error {
|
|
13
16
|
readonly code: RoutineAIErrorCode;
|
|
14
|
-
|
|
17
|
+
readonly detail?: RoutineAIOutputIssue;
|
|
18
|
+
readonly text?: string;
|
|
19
|
+
constructor(code: RoutineAIErrorCode, options?: {
|
|
20
|
+
detail?: RoutineAIOutputIssue;
|
|
21
|
+
text?: string;
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
|
-
/**
|
|
24
|
+
/** Explicit private transport projection; ordinary error logging excludes answer text. */
|
|
25
|
+
export declare function routineAIErrorFacts(error: RoutineAIError): {
|
|
26
|
+
code: "access_denied" | "cancelled" | "capability_unavailable" | "file_unavailable" | "input_too_large" | "invalid_input" | "invalid_output" | "output_too_large" | "provider_failure" | "unsupported_file";
|
|
27
|
+
detail?: RoutineAIOutputIssue | undefined;
|
|
28
|
+
text?: string | undefined;
|
|
29
|
+
};
|
|
17
30
|
export declare function parseRoutineAIError(value: unknown): RoutineAIError;
|
|
18
31
|
export type RoutineAIInput = string | File;
|
|
19
32
|
export type RoutineAIRequest = {
|
|
@@ -26,6 +39,7 @@ export type RoutineAIRequest = {
|
|
|
26
39
|
input: RoutineAIInput;
|
|
27
40
|
schema: AppValueSchema;
|
|
28
41
|
};
|
|
42
|
+
/** Keep the existing successful transport shapes for deployed SDK compatibility. */
|
|
29
43
|
export type RoutineAIResult = {
|
|
30
44
|
text: string;
|
|
31
45
|
} | {
|
|
@@ -34,7 +48,7 @@ export type RoutineAIResult = {
|
|
|
34
48
|
export type RoutineAITransport = (request: RoutineAIRequest) => Promise<RoutineAIResult>;
|
|
35
49
|
/** Inert schema grammar only. SDK builders must be resolved before transport. */
|
|
36
50
|
export declare function parseRoutineAIRequest(value: unknown): RoutineAIRequest;
|
|
37
|
-
/**
|
|
51
|
+
/** Delivery revalidates the existing result envelope and caller-supplied schema. */
|
|
38
52
|
export declare function parseRoutineAIResult(request: RoutineAIRequest, value: unknown): RoutineAIResult;
|
|
39
|
-
/** Native adapters discard reasoning and
|
|
53
|
+
/** Native adapters discard reasoning and preserve the original final text on rejection. */
|
|
40
54
|
export declare function acceptRoutineAIOutput(request: RoutineAIRequest, text: unknown): RoutineAIResult;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RoutineSchemaIssue } from './app-routine-contract.js';
|
|
2
|
+
export type RoutineAIOutputIssue = RoutineSchemaIssue | {
|
|
3
|
+
reason: 'invalid_json';
|
|
4
|
+
} | {
|
|
5
|
+
reason: 'invalid_response';
|
|
6
|
+
} | {
|
|
7
|
+
reason: 'empty_text';
|
|
8
|
+
};
|
|
9
|
+
/** Public explanations carry schema facts and types, never model values or unknown field names. */
|
|
10
|
+
export declare function parseRoutineAIOutputIssue(value: unknown): RoutineAIOutputIssue | undefined;
|
|
11
|
+
export declare function routineAIOutputMessage(issue: RoutineAIOutputIssue): string;
|