@oddington/sdk 0.1.49 → 0.1.51

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.
@@ -1,5 +1,6 @@
1
1
  import type { AskInput, DigestInput, PublicationRequest, PublishedAsk, PublishedDigest, ResolutionInput } from '../../../shared/inbox-contract.js';
2
- export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineCapabilities, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
2
+ export type { RoutineSchema, RoutineSchemaValue, RoutineDefinition, RoutineInput, RoutineRuntime, RoutineAccess, RoutineCapabilities, SharedRoutineCapabilities, ResponseCapabilities, ResponseAction, RoutineStep, RoutineSteps, RoutineStepInput, RoutineStepResult, RoutineStepOutput, RoutineArtifactInput, RoutineArtifact, RoutineAI } from './routine-definition-types.js';
3
+ export declare const defineResponse: import('./routine-definition-types.js').DefineResponse;
3
4
  export declare const defineRoutine: import('./routine-definition-types.js').DefineRoutine;
4
5
  export declare const schema: import('./routine-definition-types.js').RoutineSchemaBuilders;
5
6
  export declare const file: import('./routine-definition-types.js').RoutineFileSchema;
@@ -3,7 +3,7 @@ import type { File } from '../../../shared/files-contract.js';
3
3
  import type { Connections } from '../../../shared/airtable-contract.js';
4
4
  import type { RuntimeConnectionFor } from '../../../shared/connection-runtime.js';
5
5
  import type { DataRepository } from '../../../shared/data-contract.js';
6
- import type { Handler } from '../../../shared/inbox-contract.js';
6
+ import type { Handler, HandlerRuntime, HandlerTransition, JsonValue } 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
9
  import type { RoutineAIInput } from '../../../shared/routine-ai-contract.js';
@@ -70,16 +70,8 @@ export type RoutineArtifact = Readonly<{
70
70
  sha256: string;
71
71
  }>;
72
72
  type RepositoryFor<Mode> = Mode extends 'write' ? DataRepository : Omit<DataRepository, 'changes'>;
73
- type ConnectionName<Access extends RoutineAccess> = Access['connections'] extends readonly (infer Name)[] ? Name extends `airtable/${infer Alias}` ? Alias : never : never;
74
- export type RoutineCapabilities<Access extends RoutineAccess> = {
75
- readonly run: {
76
- readonly id: string;
77
- /** Report completed work that OS capabilities and Step boundaries cannot observe. */
78
- progress(value: {
79
- completed: number;
80
- total: number;
81
- }): Promise<void>;
82
- };
73
+ type ConnectionName<Access extends RoutineAccess> = Access['connections'] extends readonly (infer Name)[] ? string extends Name ? string : Name extends `airtable/${infer Alias}` ? Alias : never : never;
74
+ export type SharedRoutineCapabilities<Access extends RoutineAccess> = {
83
75
  readonly ai: Access['ai'] extends true ? RoutineAI : {};
84
76
  readonly data: {
85
77
  repository<Name extends Extract<keyof Access['repositories'], string>>(name: Name): RepositoryFor<NonNullable<Access['repositories']>[Name]>;
@@ -91,6 +83,32 @@ export type RoutineCapabilities<Access extends RoutineAccess> = {
91
83
  };
92
84
  readonly inbox: Pick<RoutinePublicationClient, (Access['publish'] extends readonly string[] ? 'asks' extends Access['publish'][number] ? 'publishAsk' : never : never) | (Access['publish'] extends readonly string[] ? 'digests' extends Access['publish'][number] ? 'publishDigest' : never : never)>;
93
85
  };
86
+ export type RoutineCapabilities<Access extends RoutineAccess> = SharedRoutineCapabilities<Access> & {
87
+ readonly run: {
88
+ readonly id: string;
89
+ /** Report completed work that OS capabilities and Step boundaries cannot observe. */
90
+ progress(value: {
91
+ completed: number;
92
+ total: number;
93
+ }): Promise<void>;
94
+ };
95
+ };
96
+ /** Access is supplied by the owning routine at invocation, never by the action. */
97
+ export type ResponseCapabilities = SharedRoutineCapabilities<{
98
+ repositories: Record<string, 'write'>;
99
+ files: 'read-write';
100
+ connections: readonly string[];
101
+ ai: true;
102
+ publish: readonly ('asks' | 'digests')[];
103
+ }>;
104
+ export type ResponseAction<Input extends JsonValue = JsonValue> = Omit<Handler<Input>, 'run'> & {
105
+ run(context: HandlerRuntime<Input>, os: ResponseCapabilities): Promise<HandlerTransition>;
106
+ };
107
+ export type DefineResponse = <Input extends JsonValue, const Id extends string = string>(value: ResponseAction<Input> & {
108
+ id: Id;
109
+ }) => Handler<Input> & ResponseAction<Input> & {
110
+ id: Id;
111
+ };
94
112
  type RoutineStepCalls<Steps extends RoutineSteps> = {
95
113
  [Key in keyof Steps]: {
96
114
  input: Parameters<Steps[Key]['run']> extends [] ? [] : [input: RoutineStepInput<Steps[Key]> | RoutineInput<RoutineStepInput<Steps[Key]>>];
@@ -165,7 +165,7 @@ export type PublishedChanges = AppliedChanges & {
165
165
  };
166
166
  export interface DataChangeSet {
167
167
  create(record: RecordCreation): void;
168
- update(record: RecordIdentity, set: RecordUpdateSet): void;
168
+ update(ref: string, set: RecordUpdateSet): void;
169
169
  delete(record: RecordIdentity): void;
170
170
  validate(): Promise<void>;
171
171
  apply(): Promise<AppliedChanges>;
@@ -187,7 +187,7 @@ export type CapturedRecords = {
187
187
  };
188
188
  export type RecordUpdate = {
189
189
  ref: string;
190
- expectedVersion: string;
190
+ expectedVersion?: string;
191
191
  set: JsonObject;
192
192
  body?: string;
193
193
  };
@@ -232,6 +232,9 @@ export interface RepositoryCapabilities {
232
232
  }>;
233
233
  }
234
234
  export type HandlerRuntime<Input extends JsonValue = JsonValue> = {
235
+ data: {
236
+ repository(name: string): import('./data-contract.js').DataRepository;
237
+ };
235
238
  input: Input;
236
239
  response: QuestionResponse;
237
240
  ask: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oddington/sdk",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "OS routine and response-handler SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",