@oddington/sdk 0.1.23 → 0.1.25
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 +55 -6
- package/dist/browser.js +401 -180
- package/dist/index.js +9 -9
- package/dist/types/packages/sdk/src/public.d.ts +11 -3
- package/dist/types/packages/sdk/src/routine-definition-types.d.ts +18 -1
- package/dist/types/shared/connection-runtime.d.ts +13 -2
- package/dist/types/shared/data-contract.d.ts +24 -2
- package/dist/types/shared/files-contract.d.ts +11 -2
- package/dist/types/shared/inbox-member-types.d.ts +2 -0
- package/dist/types/shared/routine-ai-contract.d.ts +40 -0
- package/dist/types/shared/routine-definition-contract.d.ts +1 -1
- package/dist/types/shared/routine-deployment-contract.d.ts +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import type { AskInput, CapturedRecords, DigestInput, InboxFile, PublicationRequ
|
|
|
2
2
|
import type { FileAddOptions } from '../../../shared/inbox-files.js';
|
|
3
3
|
import type { RecordReadInput } from '../../../shared/record-capture.js';
|
|
4
4
|
import type { RecordDeleteRequest, RecordUpdateRequest, RecordWriteRequest } from '../../../shared/record-write.js';
|
|
5
|
-
export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineCapabilities, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact } from './routine-definition-types.js';
|
|
5
|
+
export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineCapabilities, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
|
|
6
6
|
export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
|
|
7
7
|
export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
|
|
8
8
|
export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
|
|
@@ -15,11 +15,11 @@ export type { RecordDeleteRequest, RecordUpdateRequest, RecordWriteRequest } fro
|
|
|
15
15
|
export { RoutineRecordWriteError } from '../../../shared/record-write.js';
|
|
16
16
|
export { AirtableOperationError } from '../../../shared/airtable-contract.js';
|
|
17
17
|
export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient } from '../../../shared/airtable-contract.js';
|
|
18
|
-
export type { GmailRuntimeConnection, AirtableRuntimeConnection, RuntimeConnection } from '../../../shared/connection-runtime.js';
|
|
18
|
+
export type { GmailRuntimeConnection, AirtableRuntimeConnection, DropboxRuntimeConnection, RuntimeConnection } from '../../../shared/connection-runtime.js';
|
|
19
19
|
export type { Connections } from '../../../shared/airtable-contract.js';
|
|
20
20
|
export declare const connections: import('../../../shared/airtable-contract.js').Connections;
|
|
21
21
|
export { DataOperationError } from '../../../shared/data-contract.js';
|
|
22
|
-
export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, HistoryChangesOptions, HistoryChange, HistoryChangesResult, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
|
|
22
|
+
export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsReadInput, RecordsReadResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, HistoryChangesOptions, HistoryChange, HistoryChangesResult, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
|
|
23
23
|
export declare const data: {
|
|
24
24
|
repository(name: string): import('../../../shared/data-contract.js').DataRepository;
|
|
25
25
|
};
|
|
@@ -185,6 +185,14 @@ export type AppRoutineBinding<Input, Result, Steps> = {
|
|
|
185
185
|
};
|
|
186
186
|
export declare const app: {
|
|
187
187
|
listRoutines(): Promise<RoutineDescription[]>;
|
|
188
|
+
routine(id: string): {
|
|
189
|
+
describe(): Promise<RoutineDescription>;
|
|
190
|
+
run(input?: unknown): Promise<RunHandle>;
|
|
191
|
+
runs: {
|
|
192
|
+
list(): Promise<RunSummary[]>;
|
|
193
|
+
get(id: string): Promise<RunHandle>;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
188
196
|
routines: AppRoutineTypes;
|
|
189
197
|
};
|
|
190
198
|
/** A declared stage without a summary takes no second argument. */
|
|
@@ -6,6 +6,7 @@ import type { DataRepository } from '../../../shared/data-contract.js';
|
|
|
6
6
|
import type { Handler } from '../../../shared/inbox-contract.js';
|
|
7
7
|
import type { files, RoutinePublicationClient } from './public.js';
|
|
8
8
|
import type { RoutineAccess } from '../../../shared/routine-definition-contract.js';
|
|
9
|
+
import type { RoutineAIInput } from '../../../shared/routine-ai-contract.js';
|
|
9
10
|
export type { RoutineAccess } from '../../../shared/routine-definition-contract.js';
|
|
10
11
|
declare const valueType: unique symbol;
|
|
11
12
|
/** Serializable declaration; the phantom type never carries authority. */
|
|
@@ -15,6 +16,21 @@ export type RoutineSchema<Value, Defaulted extends boolean = boolean> = AppValue
|
|
|
15
16
|
readonly hasDefault?: Defaulted;
|
|
16
17
|
};
|
|
17
18
|
export type RoutineSchemaValue<Schema> = Schema extends RoutineSchema<infer Value> ? Value : undefined;
|
|
19
|
+
export type RoutineAI = {
|
|
20
|
+
generateText(input: {
|
|
21
|
+
instructions: string;
|
|
22
|
+
input: RoutineAIInput;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
text: string;
|
|
25
|
+
}>;
|
|
26
|
+
generateObject<Schema extends RoutineSchema<unknown>>(input: {
|
|
27
|
+
instructions: string;
|
|
28
|
+
input: RoutineAIInput;
|
|
29
|
+
schema: Schema;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
object: RoutineSchemaValue<Schema>;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
18
34
|
export type RoutineStepOutput = {
|
|
19
35
|
summary: unknown;
|
|
20
36
|
data: unknown;
|
|
@@ -54,6 +70,7 @@ export type RoutineCapabilities<Access extends RoutineAccess> = {
|
|
|
54
70
|
readonly run: {
|
|
55
71
|
readonly id: string;
|
|
56
72
|
};
|
|
73
|
+
readonly ai: Access['ai'] extends true ? RoutineAI : {};
|
|
57
74
|
readonly data: {
|
|
58
75
|
repository<Name extends Extract<keyof Access['repositories'], string>>(name: Name): RepositoryFor<NonNullable<Access['repositories']>[Name]>;
|
|
59
76
|
};
|
|
@@ -66,7 +83,7 @@ export type RoutineCapabilities<Access extends RoutineAccess> = {
|
|
|
66
83
|
};
|
|
67
84
|
type RoutineStepCalls<Steps extends RoutineSteps> = {
|
|
68
85
|
[Key in keyof Steps]: {
|
|
69
|
-
input: Parameters<Steps[Key]['run']> extends [] ? [] : [input: RoutineInput<RoutineStepInput<Steps[Key]>>];
|
|
86
|
+
input: Parameters<Steps[Key]['run']> extends [] ? [] : [input: RoutineStepInput<Steps[Key]> | RoutineInput<RoutineStepInput<Steps[Key]>>];
|
|
70
87
|
result: RoutineStepResult<Steps[Key]>;
|
|
71
88
|
};
|
|
72
89
|
};
|
|
@@ -16,5 +16,16 @@ export type AirtableRuntimeConnection = {
|
|
|
16
16
|
accessToken: string;
|
|
17
17
|
runExpiresAt: string;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
20
|
-
|
|
19
|
+
export type DropboxRuntimeConnection = {
|
|
20
|
+
id: `dropbox/${string}`;
|
|
21
|
+
provider: 'dropbox';
|
|
22
|
+
name: string;
|
|
23
|
+
accountId: string;
|
|
24
|
+
access: 'full_dropbox';
|
|
25
|
+
rootPath: string;
|
|
26
|
+
scopes: string[];
|
|
27
|
+
accessToken: string;
|
|
28
|
+
expiresAt: string;
|
|
29
|
+
};
|
|
30
|
+
export type RuntimeConnection = GmailRuntimeConnection | AirtableRuntimeConnection | DropboxRuntimeConnection;
|
|
31
|
+
export type RuntimeConnectionFor<Name extends string> = string extends Name ? RuntimeConnection : Name extends `gmail/${string}` ? GmailRuntimeConnection : Name extends `airtable/${string}` ? AirtableRuntimeConnection : Name extends `dropbox/${string}` ? DropboxRuntimeConnection : never;
|
|
@@ -102,11 +102,26 @@ export type SelectionMetadata = {
|
|
|
102
102
|
next?: string;
|
|
103
103
|
}>;
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
type SelectedRecordFor<Selection extends RecordSelection> = string extends keyof Selection ? SelectedRecord : SelectedRecord & {
|
|
106
|
+
[Link in Exclude<keyof Selection, '$'>]?: SelectedLinkFor<Selection[Link]>;
|
|
107
|
+
};
|
|
108
|
+
type SelectedLinkFor<Selection> = Selection extends RecordSelection ? SelectedRecordFor<Selection> | SelectedRecordFor<Selection>[] | null : never;
|
|
109
|
+
export type RecordsResult<Query extends RecordsQuery = RecordsQuery> = string extends keyof Query ? {
|
|
106
110
|
$meta: SelectionMetadata;
|
|
107
111
|
[collection: string]: SelectedRecord[] | SelectionMetadata;
|
|
112
|
+
} : {
|
|
113
|
+
$meta: SelectionMetadata;
|
|
114
|
+
} & {
|
|
115
|
+
[Collection in keyof Query]: SelectedRecordFor<Query[Collection]>[];
|
|
108
116
|
};
|
|
109
117
|
export type RecordIdentity = Pick<SelectedRecord, '$ref' | '$version'>;
|
|
118
|
+
export type RecordsReadInput = string | readonly string[];
|
|
119
|
+
export type RecordsReadResult = {
|
|
120
|
+
$meta: {
|
|
121
|
+
version: string;
|
|
122
|
+
};
|
|
123
|
+
records: Array<SelectedRecord | null>;
|
|
124
|
+
};
|
|
110
125
|
export type RecordsSearchOptions = {
|
|
111
126
|
collections?: string[];
|
|
112
127
|
limit?: number;
|
|
@@ -190,7 +205,14 @@ export interface DataRepository {
|
|
|
190
205
|
schema(name: string): Promise<CollectionSchema>;
|
|
191
206
|
};
|
|
192
207
|
records: {
|
|
193
|
-
select(query:
|
|
208
|
+
select<Query extends RecordsQuery>(query: Query): Promise<RecordsResult<Query>>;
|
|
209
|
+
pages<Query extends RecordsQuery>(query: Query): AsyncIterable<RecordsResult<Query>>;
|
|
210
|
+
all<Query extends RecordsQuery>(query: Query, options: {
|
|
211
|
+
maxRecords: number;
|
|
212
|
+
}): Promise<RecordsResult<Query>>;
|
|
213
|
+
read(ref: string): Promise<SelectedRecord | null>;
|
|
214
|
+
read(refs: readonly string[]): Promise<RecordsReadResult>;
|
|
215
|
+
read(input: RecordsReadInput): Promise<SelectedRecord | null | RecordsReadResult>;
|
|
194
216
|
search(query: string, options?: RecordsSearchOptions): Promise<RecordsSearchResult>;
|
|
195
217
|
};
|
|
196
218
|
history: {
|
|
@@ -77,20 +77,29 @@ export declare function parseFileEnrichMetadata(value: unknown, maxBytes: number
|
|
|
77
77
|
export declare function safeFileName(value: unknown): value is string;
|
|
78
78
|
export declare function safeFilePath(value: unknown): value is string;
|
|
79
79
|
/** Private transport metadata: normalized material options exclude the request key and size declaration. */
|
|
80
|
+
export declare const ORIGINAL_MEDIA_TYPES: readonly ['application/pdf', 'text/plain', 'text/markdown', 'application/json', 'image/png', 'image/jpeg'];
|
|
81
|
+
export type OriginalMediaType = typeof ORIGINAL_MEDIA_TYPES[number];
|
|
82
|
+
/** Normalize declarations only; no byte interpretation or filename inference. */
|
|
83
|
+
export declare function declaredOriginalMediaType(value: string): OriginalMediaType | undefined;
|
|
80
84
|
export type FileCreateMetadata = {
|
|
81
85
|
name: string;
|
|
82
86
|
path: string;
|
|
83
87
|
storage?: FileStorage;
|
|
84
88
|
csv?: Required<FileCsvHints>;
|
|
85
|
-
inputMediaType?:
|
|
89
|
+
inputMediaType?: OriginalMediaType;
|
|
86
90
|
size: number;
|
|
87
91
|
requestKey: string;
|
|
88
92
|
};
|
|
89
|
-
/**
|
|
93
|
+
/** Declared types are descriptive metadata; this rule never reads original bytes. */
|
|
90
94
|
export declare function declaredOriginalFormat(input: Pick<FileCreateMetadata, 'name' | 'inputMediaType'>): {
|
|
91
95
|
mediaType: 'application/pdf';
|
|
92
96
|
details: {
|
|
93
97
|
kind: 'pdf';
|
|
94
98
|
};
|
|
99
|
+
} | {
|
|
100
|
+
mediaType: "application/json" | "image/jpeg" | "image/png" | "text/markdown" | "text/plain";
|
|
101
|
+
details: {
|
|
102
|
+
kind: 'other';
|
|
103
|
+
};
|
|
95
104
|
} | undefined;
|
|
96
105
|
export declare function parseFileCreateMetadata(value: unknown, maxBytes: number): FileCreateMetadata;
|
|
@@ -129,6 +129,8 @@ export interface ResponseAcceptance {
|
|
|
129
129
|
}
|
|
130
130
|
export interface AnswerableQuestion {
|
|
131
131
|
itemId: string;
|
|
132
|
+
/** Parent Ask's workspace-scoped Inbox number, stable across revisions. */
|
|
133
|
+
number: number;
|
|
132
134
|
revision: number;
|
|
133
135
|
title: string;
|
|
134
136
|
inboxUrl: string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AppValueSchema } from './app-routine-contract.js';
|
|
2
|
+
import { type File } from './files-contract.js';
|
|
3
|
+
/** Control values, explicit text and accepted output share the Run value bound.
|
|
4
|
+
* Raw Files have no universal AI byte cap: adapters must measure their final
|
|
5
|
+
* encoded request against their own transport limit before dispatch. */
|
|
6
|
+
export declare const ROUTINE_AI_VALUE_BYTES: number;
|
|
7
|
+
export declare const ROUTINE_AI_EVIDENCE_BYTES: number;
|
|
8
|
+
export declare const ROUTINE_AI_OPERATION_MS = 120000;
|
|
9
|
+
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
|
+
export type RoutineAIErrorCode = typeof ROUTINE_AI_ERROR_CODES[number];
|
|
11
|
+
/** Safe failures contain only an allowlisted code, never provider payloads. */
|
|
12
|
+
export declare class RoutineAIError extends Error {
|
|
13
|
+
readonly code: RoutineAIErrorCode;
|
|
14
|
+
constructor(code: RoutineAIErrorCode);
|
|
15
|
+
}
|
|
16
|
+
/** Private transports carry only the bounded failure code. */
|
|
17
|
+
export declare function parseRoutineAIError(value: unknown): RoutineAIError;
|
|
18
|
+
export type RoutineAIInput = string | File;
|
|
19
|
+
export type RoutineAIRequest = {
|
|
20
|
+
kind: 'generateText';
|
|
21
|
+
instructions: string;
|
|
22
|
+
input: RoutineAIInput;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'generateObject';
|
|
25
|
+
instructions: string;
|
|
26
|
+
input: RoutineAIInput;
|
|
27
|
+
schema: AppValueSchema;
|
|
28
|
+
};
|
|
29
|
+
export type RoutineAIResult = {
|
|
30
|
+
text: string;
|
|
31
|
+
} | {
|
|
32
|
+
object: unknown;
|
|
33
|
+
};
|
|
34
|
+
export type RoutineAITransport = (request: RoutineAIRequest) => Promise<RoutineAIResult>;
|
|
35
|
+
/** Inert schema grammar only. SDK builders must be resolved before transport. */
|
|
36
|
+
export declare function parseRoutineAIRequest(value: unknown): RoutineAIRequest;
|
|
37
|
+
/** Validate results again at delivery; provider text is never implicitly repaired. */
|
|
38
|
+
export declare function parseRoutineAIResult(request: RoutineAIRequest, value: unknown): RoutineAIResult;
|
|
39
|
+
/** Native adapters discard reasoning and pass only the final text here. */
|
|
40
|
+
export declare function acceptRoutineAIOutput(request: RoutineAIRequest, text: unknown): RoutineAIResult;
|
|
@@ -2,7 +2,7 @@ import { type AppValueSchema } from './app-routine-contract.js';
|
|
|
2
2
|
export type RoutineAccess = {
|
|
3
3
|
readonly repositories?: Readonly<Record<string, 'read' | 'write'>>;
|
|
4
4
|
readonly connections?: readonly string[];
|
|
5
|
-
readonly
|
|
5
|
+
readonly ai?: true;
|
|
6
6
|
readonly files?: 'read' | 'read-write';
|
|
7
7
|
readonly publish?: readonly ('asks' | 'digests')[];
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oddington/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.25",
|
|
4
|
+
"description": "OS routine and response-handler SDK",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": ["dist", "LICENSE", "README.md"],
|