@oddington/sdk 0.1.38 → 0.1.40
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 +152 -39
- package/dist/browser.js +413 -106
- package/dist/index.js +9 -4
- package/dist/types/packages/sdk/src/public.d.ts +4 -2
- package/dist/types/shared/data-contract.d.ts +80 -8
- package/dist/types/shared/data-validation-message.d.ts +23 -0
- package/dist/types/shared/files-contract.d.ts +3 -0
- package/dist/types/shared/inbox-contract.d.ts +11 -0
- package/dist/types/shared/routine-ai-contract.d.ts +5 -3
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput
|
|
|
3
3
|
export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
|
|
4
4
|
export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
|
|
5
5
|
export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
|
|
6
|
-
export { RoutineAIError } from '../../../shared/routine-ai-contract.js';
|
|
6
|
+
export { AIError, RoutineAIError } from '../../../shared/routine-ai-contract.js';
|
|
7
7
|
export type { RoutineAIOutputIssue } from '../../../shared/routine-ai-output-detail.js';
|
|
8
8
|
export { InboxContractError, asksBlock, continueAsk, defineHandler, fileBlock, question, recordBlock, recordsBlock, resolveAsk, respond, richTextBlock, selection, } from '../../../shared/inbox-contract.js';
|
|
9
9
|
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';
|
|
@@ -14,7 +14,7 @@ export type { GmailRuntimeConnection, AirtableRuntimeConnection, DropboxRuntimeC
|
|
|
14
14
|
export type { Connections } from '../../../shared/airtable-contract.js';
|
|
15
15
|
export declare const connections: import('../../../shared/airtable-contract.js').Connections;
|
|
16
16
|
export { DataOperationError } from '../../../shared/data-contract.js';
|
|
17
|
-
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,
|
|
17
|
+
export type { DataRepository, DataErrorCode, DataValidationDetail, DataFieldExpectation, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsReadInput, RecordsReadResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, HistoryChangesOptions, HistoryChange, HistoryChangesResult, RecordIdentity, RecordCreation, RecordUpdateSet, AppliedChanges, DataChangeSet, DataEffect, DataFailureDetail, DataFailureCauseCode, LocalDataFileAction } from '../../../shared/data-contract.js';
|
|
18
18
|
declare global {
|
|
19
19
|
namespace __OddingtonOS {
|
|
20
20
|
/** Import-free OS-generated metadata; no runtime namespace is created. */
|
|
@@ -130,11 +130,13 @@ export type LocalRunActivity = {
|
|
|
130
130
|
updated: string[];
|
|
131
131
|
deleted: string[];
|
|
132
132
|
failures?: string[];
|
|
133
|
+
failure?: import('../../../shared/data-contract.js').DataFailureDetail;
|
|
133
134
|
}>;
|
|
134
135
|
effects: Array<{
|
|
135
136
|
capability: 'files' | 'inbox' | 'ai';
|
|
136
137
|
operation: string;
|
|
137
138
|
status: 'completed' | 'failed';
|
|
139
|
+
durationMs?: number;
|
|
138
140
|
reference?: string;
|
|
139
141
|
summary?: unknown;
|
|
140
142
|
}>;
|
|
@@ -138,15 +138,18 @@ export type RecordsSearchResult = {
|
|
|
138
138
|
record: SelectedRecord;
|
|
139
139
|
}>;
|
|
140
140
|
};
|
|
141
|
-
export type RecordUpdateSet = Record<string, DataValue
|
|
141
|
+
export type RecordUpdateSet = Record<string, DataValue> & {
|
|
142
|
+
$body?: string;
|
|
143
|
+
};
|
|
142
144
|
export type RecordCreation = {
|
|
143
145
|
$ref: string;
|
|
144
146
|
$filing?: Record<string, string>;
|
|
147
|
+
$body?: string;
|
|
145
148
|
$version?: never;
|
|
146
149
|
$path?: never;
|
|
147
150
|
[field: string]: DataValue | undefined;
|
|
148
151
|
};
|
|
149
|
-
export type
|
|
152
|
+
export type AppliedChanges = {
|
|
150
153
|
version: string;
|
|
151
154
|
created: RecordIdentity[];
|
|
152
155
|
updated: RecordIdentity[];
|
|
@@ -200,7 +203,7 @@ export interface DataChangeSet {
|
|
|
200
203
|
update(record: RecordIdentity, set: RecordUpdateSet): void;
|
|
201
204
|
delete(record: RecordIdentity): void;
|
|
202
205
|
validate(): Promise<void>;
|
|
203
|
-
|
|
206
|
+
apply(): Promise<AppliedChanges>;
|
|
204
207
|
}
|
|
205
208
|
export interface DataRepository {
|
|
206
209
|
collections: {
|
|
@@ -213,9 +216,27 @@ export interface DataRepository {
|
|
|
213
216
|
all<Query extends RecordsQuery>(query: Query, options: {
|
|
214
217
|
maxRecords: number;
|
|
215
218
|
}): Promise<RecordsResult<Query>>;
|
|
216
|
-
read(ref: string
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
read(ref: string, options: {
|
|
220
|
+
body: true;
|
|
221
|
+
}): Promise<(SelectedRecord & {
|
|
222
|
+
$body: string;
|
|
223
|
+
}) | null>;
|
|
224
|
+
read(refs: readonly string[], options: {
|
|
225
|
+
body: true;
|
|
226
|
+
}): Promise<Omit<RecordsReadResult, 'records'> & {
|
|
227
|
+
records: Array<(SelectedRecord & {
|
|
228
|
+
$body: string;
|
|
229
|
+
}) | null>;
|
|
230
|
+
}>;
|
|
231
|
+
read(ref: string, options?: {
|
|
232
|
+
body?: boolean;
|
|
233
|
+
}): Promise<SelectedRecord | null>;
|
|
234
|
+
read(refs: readonly string[], options?: {
|
|
235
|
+
body?: boolean;
|
|
236
|
+
}): Promise<RecordsReadResult>;
|
|
237
|
+
read(input: RecordsReadInput, options?: {
|
|
238
|
+
body?: boolean;
|
|
239
|
+
}): Promise<SelectedRecord | null | RecordsReadResult>;
|
|
219
240
|
search(query: string, options?: RecordsSearchOptions): Promise<RecordsSearchResult>;
|
|
220
241
|
};
|
|
221
242
|
history: {
|
|
@@ -225,13 +246,64 @@ export interface DataRepository {
|
|
|
225
246
|
};
|
|
226
247
|
changes(): DataChangeSet;
|
|
227
248
|
}
|
|
228
|
-
export type DataErrorCode = 'context_unavailable' | 'unauthenticated' | 'access_denied' | 'invalid_query' | 'request_too_large' | 'capacity' | 'unavailable' | 'invalid_change' | 'conflict' | '
|
|
249
|
+
export type DataErrorCode = 'context_unavailable' | 'unauthenticated' | 'access_denied' | 'invalid_query' | 'request_too_large' | 'capacity' | 'unavailable' | 'invalid_change' | 'conflict' | 'apply_pending';
|
|
229
250
|
export type DataEffect = 'unapplied' | 'uncertain' | 'applied';
|
|
251
|
+
export type DataFieldExpectation = {
|
|
252
|
+
type: DataValueDefinition['kind'];
|
|
253
|
+
many: boolean;
|
|
254
|
+
nullable: boolean;
|
|
255
|
+
decimalPlaces?: number;
|
|
256
|
+
format?: 'month';
|
|
257
|
+
};
|
|
258
|
+
export type DataValidationDetail = {
|
|
259
|
+
record: string;
|
|
260
|
+
field: string;
|
|
261
|
+
reason: 'unknown_field' | 'missing_field' | 'invalid_value' | 'source_schema_mismatch';
|
|
262
|
+
schemaFile?: string;
|
|
263
|
+
expected?: DataFieldExpectation;
|
|
264
|
+
};
|
|
265
|
+
export type LocalDataFileAction = 'created' | 'updated' | 'deleted';
|
|
266
|
+
export type DataFailureCauseCode = 'schema_validation_failed' | 'invalid_record' | 'unsafe_record' | 'stale_record' | 'path_conflict' | 'filesystem_unavailable';
|
|
267
|
+
export type DataFailurePath = {
|
|
268
|
+
action: LocalDataFileAction;
|
|
269
|
+
path: string;
|
|
270
|
+
};
|
|
271
|
+
export type DataFailureDetail = {
|
|
272
|
+
code: 'local_data_read_failed' | 'local_data_write_failed' | 'local_data_write_partial';
|
|
273
|
+
operation: 'read' | 'write';
|
|
274
|
+
repository: string;
|
|
275
|
+
cause: {
|
|
276
|
+
code: DataFailureCauseCode;
|
|
277
|
+
message: string;
|
|
278
|
+
path?: string;
|
|
279
|
+
};
|
|
280
|
+
files: {
|
|
281
|
+
state: 'none' | 'partial';
|
|
282
|
+
saved: DataFailurePath[];
|
|
283
|
+
failed?: DataFailurePath;
|
|
284
|
+
notAttempted: DataFailurePath[];
|
|
285
|
+
savedOmitted?: number;
|
|
286
|
+
notAttemptedOmitted?: number;
|
|
287
|
+
};
|
|
288
|
+
nextAction: 'fix_failed_file_then_rerun' | 'review_resolve_then_rerun';
|
|
289
|
+
};
|
|
290
|
+
export type DataRecordLimitDetail = {
|
|
291
|
+
code: 'record_limit_exceeded';
|
|
292
|
+
maxRecords: number;
|
|
293
|
+
collections: string[];
|
|
294
|
+
};
|
|
295
|
+
export type DataOperationDetail = DataFailureDetail | DataRecordLimitDetail | DataValidationDetail;
|
|
296
|
+
/** Parse the only local checkout detail allowed to cross the private SDK and
|
|
297
|
+
* retained-Run boundary. It contains no values, raw exceptions or host paths. */
|
|
298
|
+
export declare function parseDataFailureDetail(value: unknown): DataFailureDetail;
|
|
299
|
+
export declare function parseDataOperationDetail(value: unknown): DataOperationDetail;
|
|
300
|
+
export declare function dataRecordLimitMessage(detail: DataRecordLimitDetail): string;
|
|
230
301
|
export declare class DataOperationError extends Error {
|
|
231
302
|
readonly code: DataErrorCode;
|
|
232
303
|
readonly retryable: boolean;
|
|
233
304
|
readonly effect?: DataEffect | undefined;
|
|
234
305
|
readonly component?: string | undefined;
|
|
235
|
-
|
|
306
|
+
readonly detail?: DataOperationDetail | undefined;
|
|
307
|
+
constructor(code: DataErrorCode, retryable?: boolean, effect?: DataEffect | undefined, component?: string | undefined, detail?: DataOperationDetail | undefined);
|
|
236
308
|
}
|
|
237
309
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DataFieldExpectation, DataValidationDetail } from './data-contract.js';
|
|
2
|
+
type FieldProblem = 'unknown' | 'missing' | 'invalid' | 'source_schema';
|
|
3
|
+
export type FieldExpectation = DataFieldExpectation;
|
|
4
|
+
/** Detach and validate only the approved bounded facts at every trust boundary. */
|
|
5
|
+
export declare function parseDataValidationDetail(value: unknown): DataValidationDetail | undefined;
|
|
6
|
+
export declare function recordFieldDetail(record: string, field: string, problem: FieldProblem, schemaFile?: string, expectation?: FieldExpectation): DataValidationDetail | undefined;
|
|
7
|
+
/** Only bounded identifiers, relative schema locations and fixed advice enter
|
|
8
|
+
* public messages. Values and arbitrary upstream prose stay private. */
|
|
9
|
+
export declare function recordFieldMessage(record: string, field: string, problem: FieldProblem, schemaPath?: string, expected?: FieldExpectation): string | undefined;
|
|
10
|
+
export declare function safeRecordFieldMessage(value: unknown): string | undefined;
|
|
11
|
+
export declare function dataValidationMessageFacts(error: {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
detail?: unknown;
|
|
15
|
+
}): {
|
|
16
|
+
message?: string;
|
|
17
|
+
detail?: DataValidationDetail;
|
|
18
|
+
};
|
|
19
|
+
export declare function explainDataValidation<T extends {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}>(error: T, message: unknown, detail?: unknown): T;
|
|
23
|
+
export {};
|
|
@@ -48,6 +48,7 @@ declare const fileValidationReasons: {
|
|
|
48
48
|
invalid_enrichment_name: string;
|
|
49
49
|
invalid_replacement: string;
|
|
50
50
|
invalid_bytes: string;
|
|
51
|
+
original_changed: string;
|
|
51
52
|
};
|
|
52
53
|
export type FileErrorDetail = {
|
|
53
54
|
reason: keyof typeof fileValidationReasons | 'size_mismatch' | 'size_limit';
|
|
@@ -59,6 +60,8 @@ export type FileErrorDetail = {
|
|
|
59
60
|
/** Only inert, bounded facts cross Files and Run error boundaries. */
|
|
60
61
|
export declare function parseFileErrorDetail(value: unknown): FileErrorDetail | undefined;
|
|
61
62
|
export declare function fileErrorExplanation(detail: FileErrorDetail): string;
|
|
63
|
+
export declare const FILE_CAPACITY_MESSAGE: string;
|
|
64
|
+
export declare const FILE_INTEGRITY_MESSAGE: string;
|
|
62
65
|
export declare class FileOperationError extends Error {
|
|
63
66
|
readonly code: FileErrorCode;
|
|
64
67
|
readonly status: number;
|
|
@@ -208,11 +208,13 @@ export type RecordUpdate = {
|
|
|
208
208
|
ref: string;
|
|
209
209
|
expectedVersion: string;
|
|
210
210
|
set: JsonObject;
|
|
211
|
+
body?: string;
|
|
211
212
|
};
|
|
212
213
|
export type RecordCreate = {
|
|
213
214
|
ref: string;
|
|
214
215
|
path: string;
|
|
215
216
|
fields: JsonObject;
|
|
217
|
+
body?: string;
|
|
216
218
|
};
|
|
217
219
|
export type RecordDelete = {
|
|
218
220
|
ref: string;
|
|
@@ -269,6 +271,15 @@ export type Handler<Input extends JsonValue = JsonValue> = {
|
|
|
269
271
|
export declare class InboxContractError extends Error {
|
|
270
272
|
constructor(message: string);
|
|
271
273
|
}
|
|
274
|
+
export declare const INBOX_PUBLICATION_ITEM_BYTES: number;
|
|
275
|
+
export declare const INBOX_PUBLICATION_REQUEST_BYTES: number;
|
|
276
|
+
export declare const INBOX_PUBLICATION_TOO_LARGE = "Your Inbox item failed to publish. Its content exceeds the 1 MB limit. Trim the content, or attach long reports, data, and supporting materials as files instead. Then try again.";
|
|
277
|
+
export declare class InboxPublicationSizeError extends InboxContractError {
|
|
278
|
+
readonly kind: Publication['kind'];
|
|
279
|
+
readonly bytes: number;
|
|
280
|
+
constructor(kind: Publication['kind'], bytes: number);
|
|
281
|
+
}
|
|
282
|
+
export declare function enforcePublicationSize(value: Publication): Publication;
|
|
272
283
|
/** Copy only lossless JSON. In particular, JSON.stringify must not silently
|
|
273
284
|
* erase undefined/functions or convert dates, sparse arrays, or nonfinite numbers. */
|
|
274
285
|
export declare function serializable(value: unknown, ancestors?: Set<object>): JsonValue;
|
|
@@ -12,7 +12,7 @@ export declare const ROUTINE_AI_OPERATION_MS = 120000;
|
|
|
12
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'];
|
|
13
13
|
export type RoutineAIErrorCode = typeof ROUTINE_AI_ERROR_CODES[number];
|
|
14
14
|
/** The original answer is explicit recovery data, never part of the message or JSON logging. */
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class AIError extends Error {
|
|
16
16
|
readonly code: RoutineAIErrorCode;
|
|
17
17
|
readonly detail?: RoutineAIOutputIssue;
|
|
18
18
|
readonly text?: string;
|
|
@@ -21,13 +21,15 @@ export declare class RoutineAIError extends Error {
|
|
|
21
21
|
text?: string;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
+
/** Compatibility alias: both names identify the same error constructor. */
|
|
25
|
+
export { AIError as RoutineAIError };
|
|
24
26
|
/** Explicit private transport projection; ordinary error logging excludes answer text. */
|
|
25
|
-
export declare function routineAIErrorFacts(error:
|
|
27
|
+
export declare function routineAIErrorFacts(error: AIError): {
|
|
26
28
|
code: "access_denied" | "cancelled" | "capability_unavailable" | "file_unavailable" | "input_too_large" | "invalid_input" | "invalid_output" | "output_too_large" | "provider_failure" | "unsupported_file";
|
|
27
29
|
detail?: RoutineAIOutputIssue | undefined;
|
|
28
30
|
text?: string | undefined;
|
|
29
31
|
};
|
|
30
|
-
export declare function parseRoutineAIError(value: unknown):
|
|
32
|
+
export declare function parseRoutineAIError(value: unknown): AIError;
|
|
31
33
|
export type RoutineAIInput = string | File;
|
|
32
34
|
export type RoutineAIRequest = {
|
|
33
35
|
kind: 'generateText';
|