@opengeni/codemode 0.2.2 → 0.4.2
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/environment.d.ts +4 -1
- package/dist/index.js +344 -7
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +99 -1
- package/package.json +2 -2
- package/src/environment.ts +17 -5
- package/src/index.ts +47 -6
- package/src/interaction.ts +490 -0
package/dist/environment.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CodemodeClient, type CodemodeToolFunction } from "./index.js";
|
|
2
2
|
export declare const CODEMODE_ENVIRONMENT: {
|
|
3
3
|
readonly url: "OPENGENI_CODEMODE_URL";
|
|
4
|
+
readonly token: "OPENGENI_CODEMODE_TOKEN";
|
|
4
5
|
readonly tokenFile: "OPENGENI_CODEMODE_TOKEN_FILE";
|
|
5
6
|
};
|
|
7
|
+
/** Minimal environment shape; public declarations must not require `@types/node`. */
|
|
8
|
+
export type CodemodeEnvironment = Readonly<Record<string, string | undefined>>;
|
|
6
9
|
export type CodemodeClientProvider = () => CodemodeClient | Promise<CodemodeClient>;
|
|
7
10
|
/** A lazy catalog path. Every nested property remains callable at runtime. */
|
|
8
11
|
export type CodemodeDynamicTool = CodemodeToolFunction & {
|
|
@@ -19,7 +22,7 @@ export type CodemodeToolsNamespace = CodemodeDynamicTools & CodemodeGeneratedToo
|
|
|
19
22
|
* Build (or reuse) the persistent client for the exact sandbox attempt.
|
|
20
23
|
* The bearer file is reread for every HTTP request so worker renewal is live.
|
|
21
24
|
*/
|
|
22
|
-
export declare function environmentCodemodeClient(environment?:
|
|
25
|
+
export declare function environmentCodemodeClient(environment?: CodemodeEnvironment): CodemodeClient;
|
|
23
26
|
/**
|
|
24
27
|
* Lazy namespace used by ordinary sandbox programs:
|
|
25
28
|
* `await tools.slack.search({ query: "..." })`.
|
package/dist/index.js
CHANGED
|
@@ -20,19 +20,21 @@ import {
|
|
|
20
20
|
import { readFile } from "fs/promises";
|
|
21
21
|
var CODEMODE_ENVIRONMENT = {
|
|
22
22
|
url: "OPENGENI_CODEMODE_URL",
|
|
23
|
+
token: "OPENGENI_CODEMODE_TOKEN",
|
|
23
24
|
tokenFile: "OPENGENI_CODEMODE_TOKEN_FILE"
|
|
24
25
|
};
|
|
25
26
|
var cachedEnvironmentClient = null;
|
|
26
27
|
function environmentCodemodeClient(environment = process.env) {
|
|
27
28
|
const baseUrl = requiredEnvironment(environment, CODEMODE_ENVIRONMENT.url);
|
|
28
|
-
const
|
|
29
|
-
const
|
|
29
|
+
const directTokenConfigured = environment[CODEMODE_ENVIRONMENT.token] !== void 0;
|
|
30
|
+
const tokenFile = directTokenConfigured ? void 0 : requiredEnvironment(environment, CODEMODE_ENVIRONMENT.tokenFile);
|
|
31
|
+
const key = `${baseUrl}\0${directTokenConfigured ? "direct" : `file:${tokenFile}`}`;
|
|
30
32
|
if (environment === process.env && cachedEnvironmentClient?.key === key) {
|
|
31
33
|
return cachedEnvironmentClient.client;
|
|
32
34
|
}
|
|
33
35
|
const client = new CodemodeClient({
|
|
34
36
|
baseUrl,
|
|
35
|
-
token: async () => await readBearerFile(tokenFile)
|
|
37
|
+
token: directTokenConfigured ? async () => requiredEnvironment(environment, CODEMODE_ENVIRONMENT.token) : async () => await readBearerFile(tokenFile)
|
|
36
38
|
});
|
|
37
39
|
if (environment === process.env) cachedEnvironmentClient = { key, client };
|
|
38
40
|
return client;
|
|
@@ -294,13 +296,17 @@ var PATH2 = {
|
|
|
294
296
|
browserTabs: ["interaction", "browser", "tabs"],
|
|
295
297
|
browserObserve: ["interaction", "browser", "observe"],
|
|
296
298
|
browserAct: ["interaction", "browser", "act"],
|
|
299
|
+
browserClipboard: ["interaction", "browser", "clipboard"],
|
|
297
300
|
browserDebug: ["interaction", "browser", "debug"],
|
|
301
|
+
browserAuth: ["interaction", "browser", "auth"],
|
|
302
|
+
requestHuman: ["interaction", "requestHuman"],
|
|
298
303
|
browserIdentity: ["interaction", "browser", "identity"],
|
|
299
304
|
browserPublish: ["interaction", "browser", "publish"],
|
|
300
305
|
browserLifecycle: ["interaction", "browser", "lifecycle"],
|
|
301
306
|
computerOpen: ["interaction", "computer", "open"],
|
|
302
307
|
computerTargets: ["interaction", "computer", "targets"],
|
|
303
308
|
computerObserve: ["interaction", "computer", "observe"],
|
|
309
|
+
computerClipboard: ["interaction", "computer", "clipboard"],
|
|
304
310
|
computerAct: ["interaction", "computer", "act"],
|
|
305
311
|
computerLifecycle: ["interaction", "computer", "lifecycle"]
|
|
306
312
|
};
|
|
@@ -308,15 +314,20 @@ var OpenGeniCodemode = class {
|
|
|
308
314
|
browsers;
|
|
309
315
|
computers;
|
|
310
316
|
artifacts;
|
|
317
|
+
auth;
|
|
311
318
|
constructor(client = () => environmentCodemodeClient()) {
|
|
312
319
|
const provider = codemodeClientProvider(client);
|
|
313
320
|
this.browsers = new CodemodeBrowserCollection(provider);
|
|
314
321
|
this.computers = new CodemodeComputerCollection(provider);
|
|
315
322
|
this.artifacts = new CodemodeArtifactCollection(provider);
|
|
323
|
+
this.auth = new CodemodeAuth(provider);
|
|
316
324
|
}
|
|
317
325
|
async discover(options = {}, callOptions = {}) {
|
|
318
326
|
return await callStructured(this.browsers.client, PATH2.discover, options, callOptions);
|
|
319
327
|
}
|
|
328
|
+
async requestHuman(request, callOptions = {}) {
|
|
329
|
+
return await callStructured(this.browsers.client, PATH2.requestHuman, request, callOptions);
|
|
330
|
+
}
|
|
320
331
|
};
|
|
321
332
|
var CodemodeBrowserCollection = class {
|
|
322
333
|
constructor(client) {
|
|
@@ -365,14 +376,27 @@ var CodemodeBrowserIdentityCollection = class {
|
|
|
365
376
|
const response = await callStructured(this.client, PATH2.browserIdentity, { operation: "revisions", identityId }, callOptions);
|
|
366
377
|
return response.result;
|
|
367
378
|
}
|
|
379
|
+
async update(identityId, update, callOptions = {}) {
|
|
380
|
+
const response = await callStructured(
|
|
381
|
+
this.client,
|
|
382
|
+
PATH2.browserIdentity,
|
|
383
|
+
{ operation: "update", identityId, ...update },
|
|
384
|
+
callOptions
|
|
385
|
+
);
|
|
386
|
+
return response.result;
|
|
387
|
+
}
|
|
368
388
|
};
|
|
369
389
|
var CodemodeBrowser = class {
|
|
370
390
|
constructor(client, id) {
|
|
371
391
|
this.client = client;
|
|
372
392
|
this.id = id;
|
|
373
393
|
this.tabs = new CodemodeBrowserTabCollection(client, id);
|
|
394
|
+
this.auth = new CodemodeBrowserAuth(client, id);
|
|
395
|
+
this.clipboard = new CodemodeBrowserClipboard(client, id, this.tabs);
|
|
374
396
|
}
|
|
375
397
|
tabs;
|
|
398
|
+
auth;
|
|
399
|
+
clipboard;
|
|
376
400
|
async refresh(callOptions = {}) {
|
|
377
401
|
const result = await callStructured(
|
|
378
402
|
this.client,
|
|
@@ -427,6 +451,69 @@ var CodemodeBrowser = class {
|
|
|
427
451
|
);
|
|
428
452
|
}
|
|
429
453
|
};
|
|
454
|
+
var CodemodeBrowserClipboard = class {
|
|
455
|
+
constructor(client, browserSessionId, tabs) {
|
|
456
|
+
this.client = client;
|
|
457
|
+
this.browserSessionId = browserSessionId;
|
|
458
|
+
this.tabs = tabs;
|
|
459
|
+
}
|
|
460
|
+
async read(callOptions = {}) {
|
|
461
|
+
return await callStructured(
|
|
462
|
+
this.client,
|
|
463
|
+
PATH2.browserClipboard,
|
|
464
|
+
{ browserSessionId: this.browserSessionId },
|
|
465
|
+
callOptions
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
async write(text, options = {}, callOptions = {}) {
|
|
469
|
+
return await this.act({ type: "clipboard", operation: "write", text }, options, callOptions);
|
|
470
|
+
}
|
|
471
|
+
async clear(options = {}, callOptions = {}) {
|
|
472
|
+
return await this.act({ type: "clipboard", operation: "clear" }, options, callOptions);
|
|
473
|
+
}
|
|
474
|
+
async copy(options = {}, callOptions = {}) {
|
|
475
|
+
const {
|
|
476
|
+
targetId,
|
|
477
|
+
expectedTargetGeneration,
|
|
478
|
+
expectedDocumentGeneration,
|
|
479
|
+
expectedFrameId,
|
|
480
|
+
...copy
|
|
481
|
+
} = options;
|
|
482
|
+
return await this.act(
|
|
483
|
+
{ type: "clipboard", operation: "copy", ...copy },
|
|
484
|
+
{
|
|
485
|
+
targetId,
|
|
486
|
+
expectedTargetGeneration,
|
|
487
|
+
expectedDocumentGeneration,
|
|
488
|
+
expectedFrameId
|
|
489
|
+
},
|
|
490
|
+
callOptions
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
async paste(options = {}, callOptions = {}) {
|
|
494
|
+
const {
|
|
495
|
+
targetId,
|
|
496
|
+
expectedTargetGeneration,
|
|
497
|
+
expectedDocumentGeneration,
|
|
498
|
+
expectedFrameId,
|
|
499
|
+
...paste
|
|
500
|
+
} = options;
|
|
501
|
+
return await this.act(
|
|
502
|
+
{ type: "clipboard", operation: "paste", ...paste },
|
|
503
|
+
{
|
|
504
|
+
targetId,
|
|
505
|
+
expectedTargetGeneration,
|
|
506
|
+
expectedDocumentGeneration,
|
|
507
|
+
expectedFrameId
|
|
508
|
+
},
|
|
509
|
+
callOptions
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
async act(action, options, callOptions) {
|
|
513
|
+
const { targetId, ...fences } = options;
|
|
514
|
+
return await this.tabs.use(await this.tabs.resolveId(targetId, callOptions)).act(action, fences, callOptions);
|
|
515
|
+
}
|
|
516
|
+
};
|
|
430
517
|
var CodemodeBrowserTabCollection = class {
|
|
431
518
|
constructor(client, browserSessionId) {
|
|
432
519
|
this.client = client;
|
|
@@ -523,6 +610,30 @@ var CodemodeBrowserTab = class {
|
|
|
523
610
|
async navigate(url, callOptions = {}) {
|
|
524
611
|
return await this.act({ type: "navigate", url }, {}, callOptions);
|
|
525
612
|
}
|
|
613
|
+
async setPermission(permission, setting, fences = {}, callOptions = {}) {
|
|
614
|
+
return await this.act({ type: "permission", permission, setting }, fences, callOptions);
|
|
615
|
+
}
|
|
616
|
+
async requestHuman(reason, options = {}, callOptions = {}) {
|
|
617
|
+
const observation = await this.observe(callOptions);
|
|
618
|
+
return await callStructured(
|
|
619
|
+
this.client,
|
|
620
|
+
PATH2.requestHuman,
|
|
621
|
+
{
|
|
622
|
+
operation: "request",
|
|
623
|
+
resourceKind: "browser_session",
|
|
624
|
+
resourceId: this.browserSessionId,
|
|
625
|
+
targetId: this.id,
|
|
626
|
+
expectedControllerGeneration: observation.target.controllerGeneration,
|
|
627
|
+
expectedTargetGeneration: observation.target.targetGeneration,
|
|
628
|
+
expectedDocumentGeneration: observation.target.documentGeneration,
|
|
629
|
+
kind: options.kind ?? "other",
|
|
630
|
+
reason,
|
|
631
|
+
...options.authRunId ? { authRunId: options.authRunId } : {},
|
|
632
|
+
...options.expiresInSeconds === void 0 ? {} : { expiresInSeconds: options.expiresInSeconds }
|
|
633
|
+
},
|
|
634
|
+
callOptions
|
|
635
|
+
);
|
|
636
|
+
}
|
|
526
637
|
getByRole(role, options = {}) {
|
|
527
638
|
return new CodemodeBrowserLocator(this, { kind: "role", role, ...options });
|
|
528
639
|
}
|
|
@@ -579,6 +690,147 @@ var CodemodeBrowserLocator = class {
|
|
|
579
690
|
return await this.tab.act({ type: "check", locator: this.locator, checked }, {}, callOptions);
|
|
580
691
|
}
|
|
581
692
|
};
|
|
693
|
+
var CodemodeAuth = class {
|
|
694
|
+
constructor(client) {
|
|
695
|
+
this.client = client;
|
|
696
|
+
}
|
|
697
|
+
async listConnections(options = {}, callOptions = {}) {
|
|
698
|
+
const response = await callStructured(this.client, PATH2.browserAuth, { operation: "list_connections", ...options }, callOptions);
|
|
699
|
+
return response.result;
|
|
700
|
+
}
|
|
701
|
+
async getConnection(siteAuthConnectionId, callOptions = {}) {
|
|
702
|
+
const response = await callStructured(
|
|
703
|
+
this.client,
|
|
704
|
+
PATH2.browserAuth,
|
|
705
|
+
{ operation: "get_connection", siteAuthConnectionId },
|
|
706
|
+
callOptions
|
|
707
|
+
);
|
|
708
|
+
return response.result;
|
|
709
|
+
}
|
|
710
|
+
async listRuns(options = {}, callOptions = {}) {
|
|
711
|
+
const response = await callStructured(
|
|
712
|
+
this.client,
|
|
713
|
+
PATH2.browserAuth,
|
|
714
|
+
{ operation: "list_runs", ...options },
|
|
715
|
+
callOptions
|
|
716
|
+
);
|
|
717
|
+
return response.result;
|
|
718
|
+
}
|
|
719
|
+
async getRun(authRunId, callOptions = {}) {
|
|
720
|
+
const response = await callStructured(
|
|
721
|
+
this.client,
|
|
722
|
+
PATH2.browserAuth,
|
|
723
|
+
{ operation: "get_run", authRunId },
|
|
724
|
+
callOptions
|
|
725
|
+
);
|
|
726
|
+
return response.result;
|
|
727
|
+
}
|
|
728
|
+
use(browserSessionId, authRunId) {
|
|
729
|
+
return new CodemodeAuthRun(this.client, browserSessionId, authRunId);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
var CodemodeBrowserAuth = class {
|
|
733
|
+
constructor(client, browserSessionId) {
|
|
734
|
+
this.client = client;
|
|
735
|
+
this.browserSessionId = browserSessionId;
|
|
736
|
+
}
|
|
737
|
+
async listRuns(options = {}, callOptions = {}) {
|
|
738
|
+
const response = await callStructured(
|
|
739
|
+
this.client,
|
|
740
|
+
PATH2.browserAuth,
|
|
741
|
+
{ operation: "list_runs", browserSessionId: this.browserSessionId, ...options },
|
|
742
|
+
callOptions
|
|
743
|
+
);
|
|
744
|
+
return response.result;
|
|
745
|
+
}
|
|
746
|
+
async start(request, callOptions = {}) {
|
|
747
|
+
const response = await callStructured(
|
|
748
|
+
this.client,
|
|
749
|
+
PATH2.browserAuth,
|
|
750
|
+
{ operation: "start", browserSessionId: this.browserSessionId, ...request },
|
|
751
|
+
callOptions
|
|
752
|
+
);
|
|
753
|
+
return this.use(response.result.run.id);
|
|
754
|
+
}
|
|
755
|
+
use(authRunId) {
|
|
756
|
+
return new CodemodeAuthRun(this.client, this.browserSessionId, authRunId);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
var CodemodeAuthRun = class {
|
|
760
|
+
constructor(client, browserSessionId, id) {
|
|
761
|
+
this.client = client;
|
|
762
|
+
this.browserSessionId = browserSessionId;
|
|
763
|
+
this.id = id;
|
|
764
|
+
}
|
|
765
|
+
async get(callOptions = {}) {
|
|
766
|
+
const response = await callStructured(
|
|
767
|
+
this.client,
|
|
768
|
+
PATH2.browserAuth,
|
|
769
|
+
{ operation: "get_run", authRunId: this.id },
|
|
770
|
+
callOptions
|
|
771
|
+
);
|
|
772
|
+
if (response.result.browserSessionId !== this.browserSessionId) {
|
|
773
|
+
throw new Error("Auth run belongs to another BrowserSession");
|
|
774
|
+
}
|
|
775
|
+
return response.result;
|
|
776
|
+
}
|
|
777
|
+
async report(request, callOptions = {}) {
|
|
778
|
+
const response = await callStructured(
|
|
779
|
+
this.client,
|
|
780
|
+
PATH2.browserAuth,
|
|
781
|
+
{
|
|
782
|
+
operation: "report",
|
|
783
|
+
browserSessionId: this.browserSessionId,
|
|
784
|
+
authRunId: this.id,
|
|
785
|
+
...request
|
|
786
|
+
},
|
|
787
|
+
callOptions
|
|
788
|
+
);
|
|
789
|
+
return response.result;
|
|
790
|
+
}
|
|
791
|
+
async protectedFill(request, callOptions = {}) {
|
|
792
|
+
const response = await callStructured(
|
|
793
|
+
this.client,
|
|
794
|
+
PATH2.browserAuth,
|
|
795
|
+
{
|
|
796
|
+
operation: "protected_fill",
|
|
797
|
+
browserSessionId: this.browserSessionId,
|
|
798
|
+
authRunId: this.id,
|
|
799
|
+
...request
|
|
800
|
+
},
|
|
801
|
+
callOptions
|
|
802
|
+
);
|
|
803
|
+
return response.result;
|
|
804
|
+
}
|
|
805
|
+
async advanceExternal(request, callOptions = {}) {
|
|
806
|
+
const response = await callStructured(
|
|
807
|
+
this.client,
|
|
808
|
+
PATH2.browserAuth,
|
|
809
|
+
{
|
|
810
|
+
operation: "advance_external",
|
|
811
|
+
browserSessionId: this.browserSessionId,
|
|
812
|
+
authRunId: this.id,
|
|
813
|
+
...request
|
|
814
|
+
},
|
|
815
|
+
callOptions
|
|
816
|
+
);
|
|
817
|
+
return response.result;
|
|
818
|
+
}
|
|
819
|
+
async verify(request, callOptions = {}) {
|
|
820
|
+
const response = await callStructured(
|
|
821
|
+
this.client,
|
|
822
|
+
PATH2.browserAuth,
|
|
823
|
+
{
|
|
824
|
+
operation: "verify",
|
|
825
|
+
browserSessionId: this.browserSessionId,
|
|
826
|
+
authRunId: this.id,
|
|
827
|
+
...request
|
|
828
|
+
},
|
|
829
|
+
callOptions
|
|
830
|
+
);
|
|
831
|
+
return response.result;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
582
834
|
var CodemodeComputerCollection = class {
|
|
583
835
|
constructor(client) {
|
|
584
836
|
this.client = client;
|
|
@@ -605,9 +857,11 @@ var CodemodeComputer = class {
|
|
|
605
857
|
this.id = id;
|
|
606
858
|
this.targets = new CodemodeComputerTargetCollection(client, id);
|
|
607
859
|
this.apps = this.targets;
|
|
860
|
+
this.clipboard = new CodemodeComputerClipboard(client, id, this.targets);
|
|
608
861
|
}
|
|
609
862
|
targets;
|
|
610
863
|
apps;
|
|
864
|
+
clipboard;
|
|
611
865
|
async refresh(callOptions = {}) {
|
|
612
866
|
const result = await callStructured(
|
|
613
867
|
this.client,
|
|
@@ -637,6 +891,37 @@ var CodemodeComputer = class {
|
|
|
637
891
|
);
|
|
638
892
|
}
|
|
639
893
|
};
|
|
894
|
+
var CodemodeComputerClipboard = class {
|
|
895
|
+
constructor(client, computerSessionId, targets) {
|
|
896
|
+
this.client = client;
|
|
897
|
+
this.computerSessionId = computerSessionId;
|
|
898
|
+
this.targets = targets;
|
|
899
|
+
}
|
|
900
|
+
async read(callOptions = {}) {
|
|
901
|
+
return await callStructured(
|
|
902
|
+
this.client,
|
|
903
|
+
PATH2.computerClipboard,
|
|
904
|
+
{ computerSessionId: this.computerSessionId },
|
|
905
|
+
callOptions
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
async write(text, options = {}, callOptions = {}) {
|
|
909
|
+
return await this.mutate({ type: "clipboard", operation: "write", text }, options, callOptions);
|
|
910
|
+
}
|
|
911
|
+
async clear(options = {}, callOptions = {}) {
|
|
912
|
+
return await this.mutate({ type: "clipboard", operation: "clear" }, options, callOptions);
|
|
913
|
+
}
|
|
914
|
+
async copy(options = {}, callOptions = {}) {
|
|
915
|
+
return await this.mutate({ type: "clipboard", operation: "copy" }, options, callOptions);
|
|
916
|
+
}
|
|
917
|
+
async paste(options = {}, callOptions = {}) {
|
|
918
|
+
return await this.mutate({ type: "clipboard", operation: "paste" }, options, callOptions);
|
|
919
|
+
}
|
|
920
|
+
async mutate(action, options, callOptions) {
|
|
921
|
+
const targetId = await this.targets.resolveSeatId(options.targetId, callOptions);
|
|
922
|
+
return await this.targets.use(targetId).act(action, {}, callOptions);
|
|
923
|
+
}
|
|
924
|
+
};
|
|
640
925
|
var CodemodeComputerTargetCollection = class {
|
|
641
926
|
constructor(client, computerSessionId) {
|
|
642
927
|
this.client = client;
|
|
@@ -671,6 +956,13 @@ var CodemodeComputerTargetCollection = class {
|
|
|
671
956
|
throw new Error("Computer has no app, window, or screen targets");
|
|
672
957
|
throw new Error("Computer target is ambiguous; select an exact app or window");
|
|
673
958
|
}
|
|
959
|
+
async resolveSeatId(targetId, callOptions) {
|
|
960
|
+
if (targetId) return await this.resolveId(targetId, callOptions);
|
|
961
|
+
const listed = await this.list(callOptions);
|
|
962
|
+
const screens = listed.targets.filter((target) => target.kind === "screen");
|
|
963
|
+
if (screens.length === 1) return screens[0].id;
|
|
964
|
+
return await this.resolveId(void 0, callOptions);
|
|
965
|
+
}
|
|
674
966
|
};
|
|
675
967
|
var CodemodeComputerTarget = class {
|
|
676
968
|
constructor(client, computerSessionId, id) {
|
|
@@ -694,6 +986,26 @@ var CodemodeComputerTarget = class {
|
|
|
694
986
|
callOptions
|
|
695
987
|
);
|
|
696
988
|
}
|
|
989
|
+
async requestHuman(reason, options = {}, callOptions = {}) {
|
|
990
|
+
const observation = await this.observe(callOptions);
|
|
991
|
+
return await callStructured(
|
|
992
|
+
this.client,
|
|
993
|
+
PATH2.requestHuman,
|
|
994
|
+
{
|
|
995
|
+
operation: "request",
|
|
996
|
+
resourceKind: "computer_session",
|
|
997
|
+
resourceId: this.computerSessionId,
|
|
998
|
+
targetId: this.id,
|
|
999
|
+
expectedControllerGeneration: observation.target.controllerGeneration,
|
|
1000
|
+
expectedTargetGeneration: observation.target.targetGeneration,
|
|
1001
|
+
expectedDocumentGeneration: null,
|
|
1002
|
+
kind: options.kind ?? "other",
|
|
1003
|
+
reason,
|
|
1004
|
+
...options.expiresInSeconds === void 0 ? {} : { expiresInSeconds: options.expiresInSeconds }
|
|
1005
|
+
},
|
|
1006
|
+
callOptions
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
697
1009
|
getByRole(role, options = {}) {
|
|
698
1010
|
return new CodemodeComputerLocator(this, { kind: "role", role, ...options });
|
|
699
1011
|
}
|
|
@@ -1206,7 +1518,12 @@ var CodemodeClient = class {
|
|
|
1206
1518
|
method: "POST",
|
|
1207
1519
|
...signal ? { signal } : {},
|
|
1208
1520
|
headers: { "content-type": "application/json" },
|
|
1209
|
-
body: JSON.stringify({
|
|
1521
|
+
body: JSON.stringify({
|
|
1522
|
+
operationId,
|
|
1523
|
+
catalogDigest,
|
|
1524
|
+
identity,
|
|
1525
|
+
arguments: argumentsValue
|
|
1526
|
+
})
|
|
1210
1527
|
});
|
|
1211
1528
|
return CodemodeCallSubmission.parse(await response.json()).operation;
|
|
1212
1529
|
}
|
|
@@ -1390,6 +1707,8 @@ function assertCatalogSize(catalog) {
|
|
|
1390
1707
|
throw new AttemptToolCatalogTooLargeError();
|
|
1391
1708
|
}
|
|
1392
1709
|
}
|
|
1710
|
+
var COMPILED_CATALOG_SCHEMA_CACHE_MAX_ENTRIES = 512;
|
|
1711
|
+
var compiledCatalogSchemaCache = /* @__PURE__ */ new Map();
|
|
1393
1712
|
function createSchemaValidators() {
|
|
1394
1713
|
const options = {
|
|
1395
1714
|
allErrors: false,
|
|
@@ -1406,9 +1725,22 @@ function createSchemaValidators() {
|
|
|
1406
1725
|
}
|
|
1407
1726
|
function compileCatalogSchema(validators, schema) {
|
|
1408
1727
|
const dialect = typeof schema.$schema === "string" ? schema.$schema : "";
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1728
|
+
const family = dialect.includes("2020-12") ? "2020-12" : dialect.includes("2019-09") ? "2019-09" : "draft7";
|
|
1729
|
+
const cacheKey = `${family}:${digestCanonicalJson(schema)}`;
|
|
1730
|
+
const cached = compiledCatalogSchemaCache.get(cacheKey);
|
|
1731
|
+
if (cached) {
|
|
1732
|
+
compiledCatalogSchemaCache.delete(cacheKey);
|
|
1733
|
+
compiledCatalogSchemaCache.set(cacheKey, cached);
|
|
1734
|
+
return cached;
|
|
1735
|
+
}
|
|
1736
|
+
const compiled = family === "2020-12" ? validators.draft2020.compile(schema) : family === "2019-09" ? validators.draft2019.compile(schema) : validators.draft7.compile(schema);
|
|
1737
|
+
while (compiledCatalogSchemaCache.size >= COMPILED_CATALOG_SCHEMA_CACHE_MAX_ENTRIES) {
|
|
1738
|
+
const oldest = compiledCatalogSchemaCache.keys().next().value;
|
|
1739
|
+
if (oldest === void 0) break;
|
|
1740
|
+
compiledCatalogSchemaCache.delete(oldest);
|
|
1741
|
+
}
|
|
1742
|
+
compiledCatalogSchemaCache.set(cacheKey, compiled);
|
|
1743
|
+
return compiled;
|
|
1412
1744
|
}
|
|
1413
1745
|
function allocateCodemodePaths(definitions) {
|
|
1414
1746
|
const bases = definitions.map(
|
|
@@ -1501,7 +1833,11 @@ export {
|
|
|
1501
1833
|
CodemodeArtifact,
|
|
1502
1834
|
CodemodeArtifactCollection,
|
|
1503
1835
|
CodemodeArtifactExport,
|
|
1836
|
+
CodemodeAuth,
|
|
1837
|
+
CodemodeAuthRun,
|
|
1504
1838
|
CodemodeBrowser,
|
|
1839
|
+
CodemodeBrowserAuth,
|
|
1840
|
+
CodemodeBrowserClipboard,
|
|
1505
1841
|
CodemodeBrowserCollection,
|
|
1506
1842
|
CodemodeBrowserIdentityCollection,
|
|
1507
1843
|
CodemodeBrowserLocator,
|
|
@@ -1509,6 +1845,7 @@ export {
|
|
|
1509
1845
|
CodemodeBrowserTabCollection,
|
|
1510
1846
|
CodemodeClient,
|
|
1511
1847
|
CodemodeComputer,
|
|
1848
|
+
CodemodeComputerClipboard,
|
|
1512
1849
|
CodemodeComputerCollection,
|
|
1513
1850
|
CodemodeComputerLocator,
|
|
1514
1851
|
CodemodeComputerTarget,
|