@oddington/sdk 0.1.24 → 0.1.26

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.
@@ -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,7 +15,7 @@ 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';
@@ -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
  };
@@ -108,4 +125,5 @@ export type RoutineSchemaBuilders = {
108
125
  };
109
126
  export type RoutineFileSchema = (options?: {
110
127
  storage?: 'local' | 'remote';
128
+ path?: string;
111
129
  }) => RoutineSchema<File, false>;
@@ -30,6 +30,7 @@ export type AppValueSchema = {
30
30
  } | {
31
31
  type: 'file';
32
32
  storage?: 'local' | 'remote';
33
+ path?: string;
33
34
  };
34
35
  export type AppRoutineContract = {
35
36
  routine: string;
@@ -16,5 +16,16 @@ export type AirtableRuntimeConnection = {
16
16
  accessToken: string;
17
17
  runExpiresAt: string;
18
18
  };
19
- export type RuntimeConnection = GmailRuntimeConnection | AirtableRuntimeConnection;
20
- export type RuntimeConnectionFor<Name extends string> = string extends Name ? RuntimeConnection : Name extends `gmail/${string}` ? GmailRuntimeConnection : Name extends `airtable/${string}` ? AirtableRuntimeConnection : never;
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;
@@ -76,21 +76,31 @@ export type FileEnrichMetadata = {
76
76
  export declare function parseFileEnrichMetadata(value: unknown, maxBytes: number): FileEnrichMetadata;
77
77
  export declare function safeFileName(value: unknown): value is string;
78
78
  export declare function safeFilePath(value: unknown): value is string;
79
+ export declare function safeManagedFilePath(value: unknown): value is string;
79
80
  /** Private transport metadata: normalized material options exclude the request key and size declaration. */
81
+ export declare const ORIGINAL_MEDIA_TYPES: readonly ['application/pdf', 'text/plain', 'text/markdown', 'application/json', 'image/png', 'image/jpeg'];
82
+ export type OriginalMediaType = typeof ORIGINAL_MEDIA_TYPES[number];
83
+ /** Normalize declarations only; no byte interpretation or filename inference. */
84
+ export declare function declaredOriginalMediaType(value: string): OriginalMediaType | undefined;
80
85
  export type FileCreateMetadata = {
81
86
  name: string;
82
87
  path: string;
83
88
  storage?: FileStorage;
84
89
  csv?: Required<FileCsvHints>;
85
- inputMediaType?: 'application/pdf';
90
+ inputMediaType?: OriginalMediaType;
86
91
  size: number;
87
92
  requestKey: string;
88
93
  };
89
- /** A declared PDF is descriptive metadata; this rule never reads original bytes. */
94
+ /** Declared types are descriptive metadata; this rule never reads original bytes. */
90
95
  export declare function declaredOriginalFormat(input: Pick<FileCreateMetadata, 'name' | 'inputMediaType'>): {
91
96
  mediaType: 'application/pdf';
92
97
  details: {
93
98
  kind: 'pdf';
94
99
  };
100
+ } | {
101
+ mediaType: "application/json" | "image/jpeg" | "image/png" | "text/markdown" | "text/plain";
102
+ details: {
103
+ kind: 'other';
104
+ };
95
105
  } | undefined;
96
106
  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 models?: readonly string[];
5
+ readonly ai?: true;
6
6
  readonly files?: 'read' | 'read-write';
7
7
  readonly publish?: readonly ('asks' | 'digests')[];
8
8
  };
@@ -11,7 +11,7 @@ export type RoutineDeclaration = {
11
11
  access: {
12
12
  repositories: Record<string, 'read' | 'write'>;
13
13
  connections: string[];
14
- models: string[];
14
+ ai?: true;
15
15
  files?: 'read' | 'read-write';
16
16
  publish: Array<'asks' | 'digests'>;
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "description": "OS routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",