@oddington/sdk 0.1.78 → 0.1.80
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 +73 -2
- package/dist/browser.js +4502 -4163
- package/dist/index.js +10 -10
- package/dist/types/packages/sdk/src/public.d.ts +7 -0
- package/dist/types/packages/sdk/src/query-definition-types.d.ts +31 -0
- package/dist/types/packages/sdk/src/routine-reference-types.d.ts +90 -0
- package/dist/types/shared/inbox-records.d.ts +2 -1
- package/dist/types/shared/record-display.d.ts +2 -1
- package/dist/types/shared/record-link.d.ts +6 -0
- package/dist/types/shared/routine-ai-contract.d.ts +4 -0
- package/dist/types/shared/routine-ai-error-detail.d.ts +6 -0
- package/dist/types/shared/routine-definition-contract.d.ts +1 -0
- package/dist/types/shared/routine-deployment-contract.d.ts +2 -0
- package/dist/types/shared/routine-executable-contract.d.ts +2 -0
- package/dist/types/shared/routine-operation-error.d.ts +10 -0
- package/dist/types/shared/routine-query-contract.d.ts +16 -0
- package/dist/types/shared/routine-query-results.d.ts +41 -0
- package/dist/types/shared/routine-queue-contract.d.ts +30 -0
- package/package.json +1 -1
|
@@ -2,6 +2,13 @@ import type { AskInput, DigestInput, PublicationRequest, PublishedAsk, Published
|
|
|
2
2
|
export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineSchedule, RoutineCapabilities, SharedRoutineCapabilities, ResponseCapabilities, ResponseAction, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
|
|
3
3
|
export declare const defineResponse: import('./routine-definition-types.js').DefineResponse;
|
|
4
4
|
export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
|
|
5
|
+
export declare const defineQuery: import('./query-definition-types.js').DefineQuery;
|
|
6
|
+
export declare const routines: import('./routine-reference-types.js').Routines;
|
|
7
|
+
export { RoutineOperationError } from '../../../shared/routine-operation-error.js';
|
|
8
|
+
export type { RoutineOperationCode } from '../../../shared/routine-operation-error.js';
|
|
9
|
+
export type { QueueItem, QueueState, QueueSummary, QueryDescription, QueryExecution, QueryExecutionPage, RoutineListOptions, RoutineRunHandle, RoutineQueryReference, QueryExecutionHandle } from './routine-reference-types.js';
|
|
10
|
+
export type { QueryDefinition, QueryEntry, QueryRuntime, QueryTrigger, QueryTriggerContext } from './query-definition-types.js';
|
|
11
|
+
export type { RoutineReference, RoutineQueueReference } from './routine-reference-types.js';
|
|
5
12
|
export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
|
|
6
13
|
export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
|
|
7
14
|
export { AIError, RoutineAIError } from '../../../shared/routine-ai-contract.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RoutineAccess, RoutineInput, SharedRoutineCapabilities } from './routine-definition-types.js';
|
|
2
|
+
import type { RoutineSchedule } from '../../../shared/routine-schedule.js';
|
|
3
|
+
import type { RoutineQueueReference } from './routine-reference-types.js';
|
|
4
|
+
export type QueryTrigger = {
|
|
5
|
+
readonly schedule: RoutineSchedule;
|
|
6
|
+
};
|
|
7
|
+
export type QueryTriggerContext = {
|
|
8
|
+
readonly type: 'manual';
|
|
9
|
+
} | {
|
|
10
|
+
readonly type: 'schedule';
|
|
11
|
+
readonly scheduledAt: string;
|
|
12
|
+
};
|
|
13
|
+
export type QueryEntry<Input = unknown> = {
|
|
14
|
+
readonly idempotencyKey: string;
|
|
15
|
+
readonly input: RoutineInput<Input>;
|
|
16
|
+
};
|
|
17
|
+
export type QueryRuntime<Access extends RoutineAccess = RoutineAccess> = SharedRoutineCapabilities<Access> & {
|
|
18
|
+
readonly query: {
|
|
19
|
+
progress(value: {
|
|
20
|
+
total: number;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type QueryDefinition<Input = unknown, Access extends RoutineAccess = RoutineAccess, Id extends string = string> = {
|
|
25
|
+
readonly id: Id;
|
|
26
|
+
readonly queue: RoutineQueueReference<Input>;
|
|
27
|
+
readonly triggers: readonly QueryTrigger[];
|
|
28
|
+
readonly access?: Access;
|
|
29
|
+
readonly run: (trigger: QueryTriggerContext, os: QueryRuntime<Access>) => AsyncIterable<readonly QueryEntry<NoInfer<Input>>[]>;
|
|
30
|
+
};
|
|
31
|
+
export type DefineQuery = <Input, const Access extends RoutineAccess = {}, const Id extends string = string>(definition: QueryDefinition<Input, Access, Id>) => QueryDefinition<Input, Access, Id>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { RoutineSchema, RoutineSchemaValue } from './routine-definition-types.js';
|
|
2
|
+
import type { QueueItem, QueueState, QueueSummary } from '../../../shared/routine-queue-contract.js';
|
|
3
|
+
import type { QueryDescription, QueryExecution, QueryExecutionPage } from '../../../shared/routine-query-results.js';
|
|
4
|
+
import type { RunHandle, RunSummary, StepDetail } from './public.js';
|
|
5
|
+
export type { QueueItem, QueueState, QueueSummary } from '../../../shared/routine-queue-contract.js';
|
|
6
|
+
export type { QueryDescription, QueryExecution, QueryExecutionPage } from '../../../shared/routine-query-results.js';
|
|
7
|
+
export type RoutineListOptions = {
|
|
8
|
+
limit?: number;
|
|
9
|
+
after?: string;
|
|
10
|
+
};
|
|
11
|
+
export type RoutineRunHandle<Result = unknown> = {
|
|
12
|
+
current(): Promise<Omit<RunSummary, 'result'> & {
|
|
13
|
+
result?: Result;
|
|
14
|
+
}>;
|
|
15
|
+
watch(): AsyncIterable<Omit<RunSummary, 'result'> & {
|
|
16
|
+
result?: Result;
|
|
17
|
+
}>;
|
|
18
|
+
step(id: string): Promise<StepDetail>;
|
|
19
|
+
};
|
|
20
|
+
export type QueryExecutionHandle = {
|
|
21
|
+
current(): Promise<QueryExecution>;
|
|
22
|
+
watch(): AsyncIterable<QueryExecution>;
|
|
23
|
+
};
|
|
24
|
+
export type RoutineQueryReference = {
|
|
25
|
+
current(): Promise<QueryDescription>;
|
|
26
|
+
run(): Promise<QueryExecutionHandle>;
|
|
27
|
+
executions: {
|
|
28
|
+
list(options?: RoutineListOptions): Promise<QueryExecutionPage>;
|
|
29
|
+
get(id: string): QueryExecutionHandle;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
declare const queueInput: unique symbol;
|
|
33
|
+
declare const routineResult: unique symbol;
|
|
34
|
+
/** A destination identity, carrying types but no workspace or authority. */
|
|
35
|
+
export type RoutineQueueReference<Input = unknown, Id extends string = string> = {
|
|
36
|
+
readonly routineId: Id;
|
|
37
|
+
readonly [queueInput]: Input;
|
|
38
|
+
current(): Promise<QueueSummary>;
|
|
39
|
+
pause(): Promise<QueueSummary>;
|
|
40
|
+
resume(): Promise<QueueSummary>;
|
|
41
|
+
list(options?: RoutineListOptions & {
|
|
42
|
+
states?: readonly QueueState[];
|
|
43
|
+
}): Promise<{
|
|
44
|
+
items: QueueItem[];
|
|
45
|
+
next?: string;
|
|
46
|
+
}>;
|
|
47
|
+
get(id: string): Promise<QueueItem>;
|
|
48
|
+
add(input: Input, options?: {
|
|
49
|
+
idempotencyKey?: string;
|
|
50
|
+
}): Promise<QueueItem & {
|
|
51
|
+
input: Input;
|
|
52
|
+
}>;
|
|
53
|
+
remove(id: string): Promise<QueueItem>;
|
|
54
|
+
retry(id: string, options: {
|
|
55
|
+
failureId: string;
|
|
56
|
+
}): Promise<QueueItem>;
|
|
57
|
+
};
|
|
58
|
+
export type RoutineReference<Input = unknown, Result = unknown, Id extends string = string> = {
|
|
59
|
+
readonly id: Id;
|
|
60
|
+
readonly queue: RoutineQueueReference<Input, Id>;
|
|
61
|
+
readonly [routineResult]?: Result;
|
|
62
|
+
run(input?: Input): Promise<RoutineRunHandle<Result>>;
|
|
63
|
+
readonly queries: {
|
|
64
|
+
list(): Promise<QueryDescription[]>;
|
|
65
|
+
get(id: string): RoutineQueryReference;
|
|
66
|
+
};
|
|
67
|
+
readonly runs: {
|
|
68
|
+
list(): Promise<RunSummary[]>;
|
|
69
|
+
get(id: string): Promise<RunHandle>;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
type ReferenceDefinition = {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly input?: RoutineSchema<unknown>;
|
|
75
|
+
readonly result?: RoutineSchema<unknown>;
|
|
76
|
+
readonly run: (...args: any[]) => unknown;
|
|
77
|
+
};
|
|
78
|
+
type ReferenceFor<Definition extends ReferenceDefinition> = Omit<RoutineReference<[
|
|
79
|
+
NonNullable<Definition['input']>
|
|
80
|
+
] extends [never] ? Record<string, never> : RoutineSchemaValue<NonNullable<Definition['input']>>, [
|
|
81
|
+
NonNullable<Definition['result']>
|
|
82
|
+
] extends [never] ? undefined : RoutineSchemaValue<NonNullable<Definition['result']>>, Definition['id']>, 'run'> & {
|
|
83
|
+
run(...input: Definition['input'] extends undefined | RoutineSchema<unknown, true> ? [input?: [NonNullable<Definition['input']>] extends [never] ? Record<string, never> : RoutineSchemaValue<NonNullable<Definition['input']>>] : [input: RoutineSchemaValue<NonNullable<Definition['input']>>]): Promise<RoutineRunHandle<[
|
|
84
|
+
NonNullable<Definition['result']>
|
|
85
|
+
] extends [never] ? undefined : RoutineSchemaValue<NonNullable<Definition['result']>>>>;
|
|
86
|
+
};
|
|
87
|
+
export type Routines = {
|
|
88
|
+
get(id: string): RoutineReference;
|
|
89
|
+
get<Definition extends ReferenceDefinition>(id: Definition['id']): ReferenceFor<Definition>;
|
|
90
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type QualifiedRecordRef, type InboxBlock } from './inbox-contract.js';
|
|
2
2
|
import type { CollectionSchema, SelectedRecord } from './data-contract.js';
|
|
3
|
+
import { type RecordDisplayLinkTitle } from './record-display.js';
|
|
3
4
|
export type InboxRecord = QualifiedRecordRef & {
|
|
4
5
|
record: SelectedRecord | null;
|
|
5
6
|
schema: CollectionSchema | null;
|
|
@@ -26,5 +27,5 @@ export declare const recordKey: ({ repository, ref }: QualifiedRecordRef) => str
|
|
|
26
27
|
/** Only authored Record blocks disclose bootstrap hydration destinations. */
|
|
27
28
|
export declare function authoredInboxRecordRefs(body: InboxBlock[]): QualifiedRecordRef[];
|
|
28
29
|
/** Inbox's existing title policy, shared by full Records and immediate summaries. */
|
|
29
|
-
export declare function inboxRecordTitle(entry: InboxRecord): string;
|
|
30
|
+
export declare function inboxRecordTitle(entry: InboxRecord, linkedTitle?: RecordDisplayLinkTitle): string;
|
|
30
31
|
export declare function parseInboxRecords(value: unknown, maximumRecords?: number): InboxRecords;
|
|
@@ -4,8 +4,9 @@ type DisplayField = {
|
|
|
4
4
|
readonly kind: string;
|
|
5
5
|
readonly many: boolean;
|
|
6
6
|
};
|
|
7
|
+
export type RecordDisplayLinkTitle = (ref: string) => string | undefined;
|
|
7
8
|
type InvalidDisplay = (message: string) => never;
|
|
8
9
|
export declare function parseRecordDisplay(value: unknown, definitions: readonly DisplayField[], fail?: InvalidDisplay): RecordDisplay | undefined;
|
|
9
10
|
/** Resolve the schema-owned short presentation title without changing Record identity. */
|
|
10
|
-
export declare function recordDisplayTitle(record: Record<string, unknown>, display
|
|
11
|
+
export declare function recordDisplayTitle(record: Record<string, unknown>, display: Readonly<RecordDisplay> | undefined, definitions: readonly DisplayField[], linkedTitle?: RecordDisplayLinkTitle): string | undefined;
|
|
11
12
|
export {};
|
|
@@ -5,6 +5,10 @@ import { type RoutineAIErrorDetail } from './routine-ai-error-detail.js';
|
|
|
5
5
|
* Raw Files have no universal AI byte cap: adapters must measure their final
|
|
6
6
|
* encoded request against their own transport limit before dispatch. */
|
|
7
7
|
export declare const ROUTINE_AI_VALUE_BYTES: number;
|
|
8
|
+
/** The fixed Sonnet 5.5 model accepts up to 128K generated tokens. Keep local
|
|
9
|
+
* and hosted execution at the provider ceiling rather than imposing a smaller
|
|
10
|
+
* OS-only limit. Thinking tokens count toward this same provider budget. */
|
|
11
|
+
export declare const ROUTINE_AI_MAX_OUTPUT_TOKENS = 128000;
|
|
8
12
|
/** Worst-case JSON escaping is six bytes per UTF-8 answer byte, plus framing. */
|
|
9
13
|
export declare const ROUTINE_AI_RESULT_BYTES: number;
|
|
10
14
|
export declare const ROUTINE_AI_EVIDENCE_BYTES: number;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { RoutineAIErrorCode } from './routine-ai-contract.js';
|
|
2
2
|
import { type RoutineAIOutputIssue } from './routine-ai-output-detail.js';
|
|
3
3
|
export type RoutineAIErrorDetail = RoutineAIOutputIssue | {
|
|
4
|
+
reason: 'model_output_limit';
|
|
5
|
+
limit: number;
|
|
6
|
+
} | {
|
|
7
|
+
reason: 'response_transport_limit' | 'accepted_value_limit';
|
|
8
|
+
limitBytes: number;
|
|
9
|
+
} | {
|
|
4
10
|
reason: 'turn_limit';
|
|
5
11
|
limit: number;
|
|
6
12
|
} | {
|
|
@@ -30,6 +30,7 @@ export declare function assertRoutineJson(value: unknown, ancestors?: Set<object
|
|
|
30
30
|
/** Inspect property descriptors before reading authored metadata or functions. */
|
|
31
31
|
export declare function assertRoutineFields(value: unknown, allowed?: string[]): asserts value is Record<string, any>;
|
|
32
32
|
export declare function parseRoutineAccess(value: unknown): RoutineAccess;
|
|
33
|
+
export declare function parseRoutineSchedule(value: unknown): RoutineSchedule;
|
|
33
34
|
export declare function routineScheduleMetadata(value: unknown, input: AppValueSchema, hasDefault: boolean): RoutineSchedule;
|
|
34
35
|
/** Inert report/admission grammar shared with authoring; imports no runtime or
|
|
35
36
|
* capability modules and never constructs executable customer functions. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeployedRoutineQuery } from './routine-query-contract.js';
|
|
1
2
|
import type { RoutineSourceProvenance } from './routine-source-provenance.js';
|
|
2
3
|
import type { RoutineContract } from './routine-definition-contract.js';
|
|
3
4
|
export declare const ROUTINE_DECLARATION_SCHEMA = "https://schemas.oddington.ai/routine/v1.json";
|
|
@@ -31,6 +32,7 @@ export type RoutineDeploymentSource = {
|
|
|
31
32
|
definition: {
|
|
32
33
|
entry: string;
|
|
33
34
|
contract: RoutineContract;
|
|
35
|
+
queries?: DeployedRoutineQuery[];
|
|
34
36
|
};
|
|
35
37
|
files: Array<{
|
|
36
38
|
path: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { QueueItem } from './routine-queue-contract.js';
|
|
2
|
+
export type RoutineOperationCode = 'context_unavailable' | 'unauthenticated' | 'forbidden' | 'not_found' | 'invalid_input' | 'idempotency_conflict' | 'failure_changed' | 'invalid_state' | 'unavailable';
|
|
3
|
+
export declare const routineOperationMessages: Record<RoutineOperationCode, string>;
|
|
4
|
+
export declare class RoutineOperationError extends Error {
|
|
5
|
+
readonly code: RoutineOperationCode;
|
|
6
|
+
readonly item?: QueueItem | undefined;
|
|
7
|
+
readonly location?: string | undefined;
|
|
8
|
+
constructor(code: RoutineOperationCode, item?: QueueItem | undefined, location?: string | undefined);
|
|
9
|
+
}
|
|
10
|
+
export declare function routineOperationFailure(value: unknown): RoutineOperationError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RoutineAccess } from './routine-definition-contract.js';
|
|
2
|
+
import type { RoutineSchedule } from './routine-schedule.js';
|
|
3
|
+
export type RoutineQueryContract = {
|
|
4
|
+
id: string;
|
|
5
|
+
routineId: string;
|
|
6
|
+
access: RoutineAccess;
|
|
7
|
+
triggers: readonly {
|
|
8
|
+
schedule: RoutineSchedule;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export type DeployedRoutineQuery = RoutineQueryContract & {
|
|
12
|
+
entry: string;
|
|
13
|
+
exportName: string;
|
|
14
|
+
};
|
|
15
|
+
/** Shared admission/inspection metadata, never an executable or authority source. */
|
|
16
|
+
export declare function parseDeployedRoutineQueries(value: unknown, routineId: string): DeployedRoutineQuery[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type RoutineAccess } from './routine-definition-contract.js';
|
|
2
|
+
import type { RoutineSchedule } from './routine-schedule.js';
|
|
3
|
+
/** Safe retained member results; executable coordinates and authority stay private. */
|
|
4
|
+
export type QueryExecution = {
|
|
5
|
+
id: string;
|
|
6
|
+
queryId: string;
|
|
7
|
+
deploymentId: string;
|
|
8
|
+
trigger: {
|
|
9
|
+
type: 'manual';
|
|
10
|
+
} | {
|
|
11
|
+
type: 'schedule';
|
|
12
|
+
scheduledAt: string;
|
|
13
|
+
};
|
|
14
|
+
status: 'queued' | 'running' | 'succeeded' | 'failed';
|
|
15
|
+
acceptedAt: string;
|
|
16
|
+
startedAt?: string;
|
|
17
|
+
finishedAt?: string;
|
|
18
|
+
total?: number;
|
|
19
|
+
found: number;
|
|
20
|
+
added: number;
|
|
21
|
+
skipped: number;
|
|
22
|
+
failure?: {
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type QueryDescription = {
|
|
27
|
+
id: string;
|
|
28
|
+
routineId: string;
|
|
29
|
+
access: RoutineAccess;
|
|
30
|
+
triggers: {
|
|
31
|
+
schedule: RoutineSchedule;
|
|
32
|
+
}[];
|
|
33
|
+
latestExecution?: QueryExecution;
|
|
34
|
+
};
|
|
35
|
+
export type QueryExecutionPage = {
|
|
36
|
+
items: QueryExecution[];
|
|
37
|
+
next?: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function parseQueryExecution(value: unknown): QueryExecution;
|
|
40
|
+
export declare function parseQueryDescription(value: unknown): QueryDescription;
|
|
41
|
+
export declare function parseQueryExecutionPage(value: unknown): QueryExecutionPage;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Safe member queue results shared by HTTP and installed transports. */
|
|
2
|
+
export declare const queueStates: readonly ['pending', 'running', 'failed', 'succeeded', 'removed'];
|
|
3
|
+
export type QueueState = typeof queueStates[number];
|
|
4
|
+
export type QueueSummary = {
|
|
5
|
+
routineId: string;
|
|
6
|
+
paused: boolean;
|
|
7
|
+
counts: Record<QueueState, number>;
|
|
8
|
+
activeRunId?: string;
|
|
9
|
+
};
|
|
10
|
+
export type QueueItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
input: unknown;
|
|
13
|
+
idempotencyKey?: string;
|
|
14
|
+
state: QueueState;
|
|
15
|
+
currentRunId?: string;
|
|
16
|
+
associatedRunIds: string[];
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
failureId?: string;
|
|
20
|
+
failure?: {
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type QueuePage = {
|
|
25
|
+
items: QueueItem[];
|
|
26
|
+
next?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function parseQueueSummary(value: unknown): QueueSummary;
|
|
29
|
+
export declare function parseQueueItem(value: unknown): QueueItem;
|
|
30
|
+
export declare function parseQueuePage(value: unknown): QueuePage;
|