@oddington/sdk 0.1.35 → 0.1.37

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.
@@ -4,13 +4,15 @@ 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';
10
12
  export type { FileAddOptions } from '../../../shared/inbox-files.js';
11
13
  export { AirtableOperationError } from '../../../shared/airtable-contract.js';
12
14
  export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient } from '../../../shared/airtable-contract.js';
13
- export type { GmailRuntimeConnection, AirtableRuntimeConnection, DropboxRuntimeConnection, RuntimeConnection } from '../../../shared/connection-runtime.js';
15
+ export type { GmailRuntimeConnection, AirtableRuntimeConnection, DropboxRuntimeConnection, OutlookRuntimeConnection, SharePointRuntimeConnection, RuntimeConnection, RuntimeConnectionFor } from '../../../shared/connection-runtime.js';
14
16
  export type { Connections } from '../../../shared/airtable-contract.js';
15
17
  export declare const connections: import('../../../shared/airtable-contract.js').Connections;
16
18
  export { DataOperationError } from '../../../shared/data-contract.js';
@@ -30,7 +32,7 @@ export declare const data: {
30
32
  };
31
33
  export { FileOperationError } from '../../../shared/files-contract.js';
32
34
  export { source } from './source.js';
33
- export type { SourceLocation, OsSourceLocation, GmailSourceLocation, DropboxSourceLocation } from './source.js';
35
+ export type { SourceLocation, OsSourceLocation, GmailSourceLocation, DropboxSourceLocation, OutlookSourceLocation, SharePointSourceLocation } from './source.js';
34
36
  export { InboxOperationError } from '../../../shared/inbox-member-contract.js';
35
37
  export type { InboxMember, InboxCurrent, InboxItem, AnswerableQuestion, QuestionSnapshot, ResponseConsequence, LinkedAskSnapshot, AskUpdate, DigestReadConfirmation, RecipientCandidate, RecipientAddition, ResponseAcceptance, InboxAnswerInput, InboxSearchInput } from '../../../shared/inbox-member-types.js';
36
38
  export type { RecordSelectionResult } from '../../../shared/record-selection.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;
@@ -23,6 +23,23 @@ export type DropboxSourceLocation = {
23
23
  path?: string;
24
24
  url?: string;
25
25
  };
26
+ export type OutlookSourceLocation = {
27
+ provider: 'outlook';
28
+ connection: `outlook/${string}`;
29
+ message: string;
30
+ attachment?: string;
31
+ url?: string;
32
+ };
33
+ export type SharePointSourceLocation = {
34
+ provider: 'sharepoint';
35
+ connection: `sharepoint/${string}`;
36
+ site: string;
37
+ drive: string;
38
+ item: string;
39
+ version?: string;
40
+ path?: string;
41
+ url?: string;
42
+ };
26
43
  /** Pure authoring conveniences; ordinary Data validation and publication own writes. */
27
44
  export declare const source: {
28
45
  file(input: {
@@ -46,6 +63,8 @@ export declare const source: {
46
63
  os(file: Pick<File, 'id'>): OsSourceLocation;
47
64
  gmail(input: Omit<GmailSourceLocation, 'provider'>): GmailSourceLocation;
48
65
  dropbox(input: Omit<DropboxSourceLocation, 'provider'>): DropboxSourceLocation;
66
+ outlook(input: Omit<OutlookSourceLocation, 'provider'>): OutlookSourceLocation;
67
+ sharepoint(input: Omit<SharePointSourceLocation, 'provider'>): SharePointSourceLocation;
49
68
  };
50
69
  locations: {
51
70
  merge(existing: readonly SourceLocation[], incoming: readonly SourceLocation[]): SourceLocation[];
@@ -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 declare function validateRoutineSchemaValue(schema: AppValueSchema, value: unknown): void;
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;
@@ -27,5 +27,22 @@ export type DropboxRuntimeConnection = {
27
27
  accessToken: string;
28
28
  expiresAt: string;
29
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;
30
+ export type OutlookRuntimeConnection = {
31
+ id: `outlook/${string}`;
32
+ provider: 'outlook';
33
+ name: string;
34
+ mailboxEmail: string;
35
+ accessToken: string;
36
+ expiresAt: string;
37
+ };
38
+ export type SharePointRuntimeConnection = {
39
+ id: `sharepoint/${string}`;
40
+ provider: 'sharepoint';
41
+ name: string;
42
+ siteId: string;
43
+ siteUrl: string;
44
+ accessToken: string;
45
+ expiresAt: string;
46
+ };
47
+ export type RuntimeConnection = GmailRuntimeConnection | AirtableRuntimeConnection | DropboxRuntimeConnection | OutlookRuntimeConnection | SharePointRuntimeConnection;
48
+ 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 : Name extends `outlook/${string}` ? OutlookRuntimeConnection : Name extends `sharepoint/${string}` ? SharePointRuntimeConnection : never;
@@ -11,12 +11,7 @@ export interface RepositoryTarget {
11
11
  createdAt: string;
12
12
  updatedAt: string;
13
13
  }
14
- /** Managed Git-tree data boundaries. */
15
- export interface RepositoryDataTarget extends RepositoryTarget {
16
- dataRoots: string[];
17
- }
18
14
  export declare function validDataRoots(value: unknown): value is string[];
19
- export declare function parseRepositoryDataTarget(value: unknown): RepositoryDataTarget;
20
15
  export declare function validRepositoryAlias(value: unknown): value is string;
21
16
  export declare function validTargetRef(value: unknown): value is string;
22
17
  export declare function parseRepositoryTarget(value: unknown): RepositoryTarget;
@@ -1,19 +1,32 @@
1
1
  import { type AppValueSchema } from './app-routine-contract.js';
2
2
  import { type File } from './files-contract.js';
3
- /** Control values, explicit text and accepted output share the Run value bound.
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
- /** Safe failures contain only an allowlisted code, never provider payloads. */
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
- constructor(code: RoutineAIErrorCode);
17
+ readonly detail?: RoutineAIOutputIssue;
18
+ readonly text?: string;
19
+ constructor(code: RoutineAIErrorCode, options?: {
20
+ detail?: RoutineAIOutputIssue;
21
+ text?: string;
22
+ });
15
23
  }
16
- /** Private transports carry only the bounded failure code. */
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
- /** Validate results again at delivery; provider text is never implicitly repaired. */
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 pass only the final text here. */
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "OS routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",