@isomorph.ai/app-sdk 2.1.0 → 2.2.0

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.
@@ -91,14 +91,17 @@ export interface ComputerUseLiveConnection {
91
91
  };
92
92
  viewerPath: string;
93
93
  }
94
+ export type ComputerUseTakeover = ComputerUsePause & {
95
+ connection?: ComputerUseLiveConnection;
96
+ };
94
97
  export interface ComputerUseHandoffOptions extends ComputerUseTransport {
95
98
  runKey: string;
96
99
  authorize(): Promise<boolean> | boolean;
97
100
  }
98
101
  export declare function createComputerUseHandoff(options: ComputerUseHandoffOptions): {
99
- requestTakeover(reason: string, requiredInput?: "login" | "human"): Promise<ComputerUsePause>;
102
+ requestTakeover(reason: string, requiredInput?: "login" | "human", pauseId?: string): Promise<ComputerUseTakeover>;
100
103
  view(pauseId: string): Promise<ComputerUsePage>;
101
- live(pauseId: string): Promise<ComputerUseLiveConnection>;
104
+ live(_pauseId?: string): Promise<ComputerUseLiveConnection>;
102
105
  input(pauseId: string, action: ComputerUseInputAction): Promise<ComputerUseInputResult>;
103
106
  completeLogin(pauseId: string, input: ComputerUseLoginInput): Promise<{
104
107
  status: "login_queued";
@@ -32,7 +32,7 @@ export function waitingInput(answer) {
32
32
  }
33
33
  export function createComputerUseHandoff(options) {
34
34
  if (typeof options.runKey !== 'string' || !options.runKey || typeof options.authorize !== 'function')
35
- throw new Error('Computer use handoff needs runKey and an authorize check for the current user.');
35
+ throw new Error('Computer use handoff needs runKey and an authorize check for the current app task.');
36
36
  const api = computerUseApi(options);
37
37
  const post = async (path, body = {}, privateInput = false) => {
38
38
  if (await options.authorize() !== true)
@@ -61,10 +61,10 @@ export function createComputerUseHandoff(options) {
61
61
  return { pauseId };
62
62
  };
63
63
  return {
64
- requestTakeover(reason, requiredInput = 'human') {
64
+ requestTakeover(reason, requiredInput = 'human', pauseId) {
65
65
  if (!reason.trim() || !['login', 'human'].includes(requiredInput))
66
66
  throw new Error('Takeover needs a reason and login or human input.');
67
- return post('/tasks/takeover', { reason, requiredInput }).then(pauseOf);
67
+ return post('/tasks/takeover', { reason, requiredInput, ...(pauseId ? paused(pauseId) : {}) }).then(answer => ({ ...pauseOf(answer), ...(answer.connection ? { connection: answer.connection } : {}) }));
68
68
  },
69
69
  // The API answers 409 while the task is still pausing or after it resumed; `ready` is the only 200.
70
70
  async view(pauseId) {
@@ -73,8 +73,8 @@ export function createComputerUseHandoff(options) {
73
73
  throw new Error('The computer use API returned an incomplete screen.');
74
74
  return { status: 'ready', screenshot: page.screenshot, url: page.url };
75
75
  },
76
- live(pauseId) {
77
- return post('/tasks/live', paused(pauseId));
76
+ live(_pauseId) {
77
+ return post('/tasks/live');
78
78
  },
79
79
  input(pauseId, action) {
80
80
  return post('/tasks/input', { ...paused(pauseId), action });
package/dist/index.d.ts CHANGED
@@ -2018,7 +2018,9 @@ export declare function createClient(options?: ClientOptions): {
2018
2018
  watch: <T = Record<string, unknown>>(build: () => QueryBuilder<T, any>, onResult: (result: WatchResult) => void, options?: WatchOptions) => (() => void);
2019
2019
  };
2020
2020
  computerView: {
2021
- url(action: string, taskId: string): string;
2021
+ url(action: string, taskId: string, options?: {
2022
+ mode?: "watch" | "control";
2023
+ }): string;
2022
2024
  };
2023
2025
  files: {
2024
2026
  createUpload: (input: {
package/dist/index.js CHANGED
@@ -774,10 +774,13 @@ export function createClient(options = {}) {
774
774
  },
775
775
  },
776
776
  computerView: {
777
- url(action, taskId) {
777
+ url(action, taskId, options = {}) {
778
778
  if (!/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(action) || !/^[A-Za-z0-9_-]{1,128}$/.test(taskId))
779
779
  throw new IsomorphError('VALIDATION_FAILED', 'Computer view needs an action and task ID.');
780
- return `${transport.baseUrl}/_harbour/computer-view/${encodeURIComponent(action)}/${encodeURIComponent(taskId)}/`;
780
+ const mode = options.mode ?? 'watch';
781
+ if (!['watch', 'control'].includes(mode))
782
+ throw new IsomorphError('VALIDATION_FAILED', 'Computer view needs watch or control mode.');
783
+ return `${transport.baseUrl}/_harbour/computer-view/${encodeURIComponent(action)}/${encodeURIComponent(taskId)}/${mode}/`;
781
784
  },
782
785
  },
783
786
  files: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isomorph.ai/app-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",