@rollikey/sdk 0.1.0 → 0.1.1

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/dist/index.d.ts CHANGED
@@ -44,14 +44,19 @@ export interface HeldEmail {
44
44
  runId: string;
45
45
  releaseAt: string;
46
46
  }
47
+ /** What revert does when a target changed after the agent touched it. Default 'halt'. */
48
+ export type OnDrift = 'halt' | 'overwrite';
49
+ export interface RevertOptions {
50
+ onDrift?: OnDrift;
51
+ }
47
52
  export interface RevertReport {
48
53
  status: 'reverted' | 'partial';
49
54
  runId: string;
50
55
  complete: boolean;
51
- emails: {
52
- cancelled: string[];
53
- alreadySent: string[];
54
- };
56
+ /** The run is fenced after a revert: new actions in it are refused (code run_fenced). */
57
+ fenced?: boolean;
58
+ onDrift?: OnDrift;
59
+ emails: RevertSlackReport;
55
60
  slack: RevertSlackReport;
56
61
  steps: {
57
62
  seq: number;
@@ -61,12 +66,17 @@ export interface RevertReport {
61
66
  status: 'reverted' | 'revert_failed';
62
67
  compensation?: Record<string, unknown>;
63
68
  error?: string;
69
+ code?: string;
70
+ drifted?: unknown[];
64
71
  }[];
65
72
  remaining: number[];
66
73
  }
67
74
  export interface RevertSlackReport {
68
75
  cancelled: string[];
76
+ /** Released or being released (includes inFlight). */
69
77
  alreadySent: string[];
78
+ /** Delivery attempted, outcome not yet known. */
79
+ inFlight?: string[];
70
80
  }
71
81
  export interface RunInfo {
72
82
  runId: string;
@@ -201,7 +211,10 @@ export declare class RollikeyToolError extends Error {
201
211
  constructor(code: string, message: string);
202
212
  }
203
213
  export interface RollikeyClientOptions {
204
- /** When true (default), gated calls throw RollikeyBlockedError instead of returning the blocked result. */
214
+ /**
215
+ * Low-level RollikeyClient.call() only: when true (default), gated calls throw RollikeyBlockedError.
216
+ * RollikeyRun methods (run.call, run.updateRows, run.refund, ...) always return { status: 'blocked' } instead.
217
+ */
205
218
  throwOnBlocked?: boolean;
206
219
  }
207
220
  export declare class RollikeyClient {
@@ -257,7 +270,7 @@ export declare class RollikeyRun {
257
270
  * Returns the structured result as-is, including `status: 'blocked'`, so the model can adapt.
258
271
  * Gate blocks do NOT throw here: the agent should see them as a normal tool result.
259
272
  */
260
- call(name: string, args?: Record<string, unknown>): Promise<Record<string, unknown>>;
273
+ call<T = Record<string, unknown>>(name: string, args?: Record<string, unknown>): Promise<T>;
261
274
  updateRows(table: string, where: Where, set: Record<string, Scalar>): Promise<AppliedMutation | BlockedAction>;
262
275
  deleteRows(table: string, where: Where): Promise<AppliedMutation | BlockedAction>;
263
276
  refund(input: RefundInput): Promise<AppliedRefund | BlockedAction>;
@@ -265,7 +278,7 @@ export declare class RollikeyRun {
265
278
  authorizeHold(input: HoldInput): Promise<AppliedHold | BlockedAction>;
266
279
  /** Capture the run's holds once the multi-step run verified cleanly. */
267
280
  captureHolds(): Promise<CaptureResult>;
268
- sendEmail(input: EmailInput): Promise<HeldEmail>;
281
+ sendEmail(input: EmailInput): Promise<BlockedAction | HeldEmail>;
269
282
  s3PutObject(input: S3PutInput): Promise<BlockedAction | S3Result>;
270
283
  s3DeleteObjects(input: S3DeleteInput): Promise<BlockedAction | S3Result>;
271
284
  s3SetBucketAcl(acl: 'private' | 'public-read' | 'public-read-write' | 'authenticated-read', bucket?: string): Promise<BlockedAction | S3Result>;
@@ -297,8 +310,9 @@ export declare class RollikeyRun {
297
310
  get slack(): {
298
311
  post: (input: SlackPostInput) => Promise<BlockedAction | SlackResult>;
299
312
  archiveChannel: (channel: string) => Promise<BlockedAction>;
300
- email: (input: EmailInput) => Promise<HeldEmail>;
313
+ email: (input: EmailInput) => Promise<BlockedAction | HeldEmail>;
301
314
  };
302
- revert(): Promise<RevertReport>;
315
+ /** Undo the run (LIFO). Default onDrift 'halt' stops for review on drift; { onDrift: 'overwrite' } restores anyway. */
316
+ revert(opts?: RevertOptions): Promise<RevertReport>;
303
317
  inspect(): Promise<RunInfo>;
304
318
  }
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ export class RollikeyClient {
31
31
  this.opts = opts;
32
32
  }
33
33
  static async connect(transport, opts = {}) {
34
- const client = new Client({ name: 'rollikey-sdk', version: '0.1.0' });
34
+ const client = new Client({ name: 'rollikey-sdk', version: '0.1.1' });
35
35
  await client.connect(transport);
36
36
  return new RollikeyClient(client, { throwOnBlocked: opts.throwOnBlocked ?? true });
37
37
  }
@@ -95,6 +95,7 @@ export class RollikeyRun {
95
95
  */
96
96
  async call(name, args = {}) {
97
97
  try {
98
+ // runId goes last so nothing in args can move the call into another run.
98
99
  return await this.sp.call(name, { ...args, runId: this.runId });
99
100
  }
100
101
  catch (err) {
@@ -104,51 +105,51 @@ export class RollikeyRun {
104
105
  }
105
106
  }
106
107
  updateRows(table, where, set) {
107
- return this.sp.call('rollikey_db_update', { runId: this.runId, table, where, set });
108
+ return this.call('rollikey_db_update', { table, where, set });
108
109
  }
109
110
  deleteRows(table, where) {
110
- return this.sp.call('rollikey_db_delete', { runId: this.runId, table, where });
111
+ return this.call('rollikey_db_delete', { table, where });
111
112
  }
112
113
  refund(input) {
113
- return this.sp.call('rollikey_stripe_refund', { runId: this.runId, ...input });
114
+ return this.call('rollikey_stripe_refund', { ...input });
114
115
  }
115
116
  /** Authorize (hold) funds with manual capture. Nothing is charged until captureHolds(). */
116
117
  authorizeHold(input) {
117
- return this.sp.call('rollikey_stripe_authorize_hold', { runId: this.runId, ...input });
118
+ return this.call('rollikey_stripe_authorize_hold', { ...input });
118
119
  }
119
120
  /** Capture the run's holds once the multi-step run verified cleanly. */
120
121
  captureHolds() {
121
- return this.sp.call('rollikey_stripe_capture_holds', { runId: this.runId });
122
+ return this.call('rollikey_stripe_capture_holds', {});
122
123
  }
123
124
  sendEmail(input) {
124
- return this.sp.call('rollikey_send_email', { runId: this.runId, ...input });
125
+ return this.call('rollikey_send_email', { ...input });
125
126
  }
126
127
  // ---- AWS S3 ----
127
128
  s3PutObject(input) {
128
- return this.sp.call('rollikey_s3_put_object', { runId: this.runId, ...input });
129
+ return this.call('rollikey_s3_put_object', { ...input });
129
130
  }
130
131
  s3DeleteObjects(input) {
131
- return this.sp.call('rollikey_s3_delete_objects', { runId: this.runId, ...input });
132
+ return this.call('rollikey_s3_delete_objects', { ...input });
132
133
  }
133
134
  s3SetBucketAcl(acl, bucket) {
134
- return this.sp.call('rollikey_s3_set_bucket_acl', { runId: this.runId, acl, ...(bucket ? { bucket } : {}) });
135
+ return this.call('rollikey_s3_set_bucket_acl', { acl, ...(bucket ? { bucket } : {}) });
135
136
  }
136
137
  // ---- GitHub ----
137
138
  githubUpdateIssues(numbers, patch, target = {}) {
138
- return this.sp.call('rollikey_github_update_issues', { runId: this.runId, numbers, patch, ...target });
139
+ return this.call('rollikey_github_update_issues', { ...target, numbers, patch });
139
140
  }
140
141
  githubUpdatePulls(numbers, patch, target = {}) {
141
- return this.sp.call('rollikey_github_update_pulls', { runId: this.runId, numbers, patch, ...target });
142
+ return this.call('rollikey_github_update_pulls', { ...target, numbers, patch });
142
143
  }
143
144
  githubDeleteBranches(branches, target = {}) {
144
- return this.sp.call('rollikey_github_delete_branches', { runId: this.runId, branches, ...target });
145
+ return this.call('rollikey_github_delete_branches', { ...target, branches });
145
146
  }
146
147
  // ---- Slack ----
147
148
  slackPost(input) {
148
- return this.sp.call('rollikey_slack_post', { runId: this.runId, ...input });
149
+ return this.call('rollikey_slack_post', { ...input });
149
150
  }
150
151
  slackArchiveChannel(channel) {
151
- return this.sp.call('rollikey_slack_archive_channel', { runId: this.runId, channel });
152
+ return this.call('rollikey_slack_archive_channel', { channel });
152
153
  }
153
154
  /** The five connectors grouped by system, e.g. `run.s3.put(...)`, `run.github.deleteBranches(...)`. */
154
155
  get postgres() {
@@ -166,11 +167,12 @@ export class RollikeyRun {
166
167
  get slack() {
167
168
  return { post: this.slackPost.bind(this), archiveChannel: this.slackArchiveChannel.bind(this), email: this.sendEmail.bind(this) };
168
169
  }
169
- revert() {
170
- return this.sp.call('rollikey_revert', { runId: this.runId });
170
+ /** Undo the run (LIFO). Default onDrift 'halt' stops for review on drift; { onDrift: 'overwrite' } restores anyway. */
171
+ revert(opts = {}) {
172
+ return this.call('rollikey_revert', opts.onDrift ? { onDrift: opts.onDrift } : {});
171
173
  }
172
174
  inspect() {
173
- return this.sp.call('rollikey_get_run', { runId: this.runId });
175
+ return this.call('rollikey_get_run', {});
174
176
  }
175
177
  }
176
178
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollikey/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Typed client for Rollikey: blast-radius gate, airlock and one-call revert for AI agent actions",
5
5
  "license": "MIT",
6
6
  "repository": {