@deepraxis/sdk 0.1.1-dev.73a8792 → 0.1.1-dev.75a3bb2

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.
@@ -376,7 +376,7 @@ export declare const browserViewerHeartbeat: <ThrowOnError extends boolean = fal
376
376
  /**
377
377
  * 列出浏览器上下文
378
378
  *
379
- * 分页列出当前账户保存的登录态,按登录态 ID 升序排列。每项返回名称、标签及保存内容的统计信息;将 nextCursor 原样传入读取下一页,直到其为 null。
379
+ * 分页列出当前账户保存的登录态,按登录态 ID 升序排列。每项返回名称、标签及保存内容的统计信息;将 nextCursor 原样传入读取下一页,直到其为 null。传 name 时只返回该名称的登录态;名称在当前账户内唯一,所以最多一条。
380
380
  */
381
381
  export declare const browserListContexts: <ThrowOnError extends boolean = false>(options?: Options<BrowserListContextsData, ThrowOnError>) => RequestResult<BrowserListContextsResponses, BrowserListContextsErrors, ThrowOnError>;
382
382
  /**
@@ -2308,6 +2308,7 @@ export declare const cutUndeleteProject: <ThrowOnError extends boolean = false>(
2308
2308
  * - `TOO_MANY_EFFECTS` — More than 8 effects on one clip.
2309
2309
  * - `PROJECT_NOT_FOUND` — No visible project has this id.
2310
2310
  * - `EXPORT_NOT_FOUND` — No such export in this project.
2311
+ * - `DRAFT_RENDER_NOT_FOUND` — No such draft render.
2311
2312
  * - `VERSION_NOT_FOUND` — No saved version has this revision.
2312
2313
  * - `LIBRARY_NOT_FOUND` — The library is missing or invisible.
2313
2314
  * - `BINDING_INVALID` — The binding request is malformed.
@@ -2356,9 +2357,9 @@ export declare const cutRetrieveTimeline: <ThrowOnError extends boolean = false>
2356
2357
  */
2357
2358
  export declare const cutListFrames: <ThrowOnError extends boolean = false>(options: Options<CutListFramesData, ThrowOnError>) => RequestResult<CutListFramesResponses, CutListFramesErrors, ThrowOnError>;
2358
2359
  /**
2359
- * Analyze project media
2360
+ * Analyze project media or measure the project mix
2360
2361
  *
2361
- * Request silence, filler-word or scene analysis for selected bound assets before editing. Omit media to select project sources; ranges returned in segments use source seconds. A pending result is not completion: use retry_after_sec before checking again, and inspect failed or unsupported asset results before deciding which edits are possible. Silence measures transcript-based speech pauses, not music or loudness. A completed transcript without words returns ready with empty segments and reason no_speech; no completed transcript returns unsupported with reason no_transcript. A failed transcription remains failed.
2362
+ * Request silence, filler-word or scene analysis for selected bound assets before editing, or measure the mix the timeline itself renders with kind mix. That kind is a render job, not a read: it answers pending with retry_after_sec and is polled by the id it returned, because the answer only exists once the audio has been rendered and measured. Omit media to select project sources; ranges returned in segments use source seconds. A pending result is not completion: use retry_after_sec before checking again, and inspect failed or unsupported asset results before deciding which edits are possible. Silence measures transcript-based speech pauses, not music or loudness. A completed transcript without words returns ready with empty segments and reason no_speech; no completed transcript returns unsupported with reason no_transcript. A failed transcription remains failed. kind mix is separate: it reports the project mix loudness, the loudness of each role and where music masks speech, so an editor can fix the mix rather than guess at it.
2362
2363
  */
2363
2364
  export declare const cutCreateAnalysis: <ThrowOnError extends boolean = false>(options: Options<CutCreateAnalysisData, ThrowOnError>) => RequestResult<CutCreateAnalysisResponses, CutCreateAnalysisErrors, ThrowOnError>;
2364
2365
  /**
@@ -2648,7 +2649,7 @@ export declare const devopsTestRunsList: <ThrowOnError extends boolean = false>(
2648
2649
  /**
2649
2650
  * Create a test run
2650
2651
  *
2651
- * Start a run of the project's tests at one commit. Name a plan to use its selector, or pass a selector directly for this run alone; the ref says which commit to test and is required, because a run without a commit has nothing to report against. waitUntil decides how far the call waits before answering — queued returns as soon as the run exists, finished waits for a verdict and may take minutes. A retry of an earlier run is a new run: pass its commit and selector, and read the earlier run to compare.
2652
+ * Start a run of the project's tests at one commit. Name a plan to use its selector, or pass a selector directly for this run alone; the ref says which commit to test and is required, because a run without a commit has nothing to report against. waitUntil decides how far the call waits before answering — queued, the default, returns as soon as the run exists; started waits until the run has begun, except for an external run, which is answered at once because it leaves queued only when your own CI uploads; finished waits for a verdict. The wait is bounded at about 25 seconds, and a wait that reaches that bound returns the run as it stands rather than failing — read state to see whether it finished. A retry of an earlier run is a new run: pass its commit and selector, and read the earlier run to compare.
2652
2653
  */
2653
2654
  export declare const devopsTestRunsCreate: <ThrowOnError extends boolean = false>(options: Options<DevopsTestRunsCreateData, ThrowOnError>) => RequestResult<DevopsTestRunsCreateResponses, DevopsTestRunsCreateErrors, ThrowOnError>;
2654
2655
  /**
@@ -956,7 +956,7 @@ export const browserViewerHeartbeat = (options) => (options.client ?? client).po
956
956
  /**
957
957
  * 列出浏览器上下文
958
958
  *
959
- * 分页列出当前账户保存的登录态,按登录态 ID 升序排列。每项返回名称、标签及保存内容的统计信息;将 nextCursor 原样传入读取下一页,直到其为 null。
959
+ * 分页列出当前账户保存的登录态,按登录态 ID 升序排列。每项返回名称、标签及保存内容的统计信息;将 nextCursor 原样传入读取下一页,直到其为 null。传 name 时只返回该名称的登录态;名称在当前账户内唯一,所以最多一条。
960
960
  */
961
961
  export const browserListContexts = (options) => (options?.client ?? client).get({
962
962
  security: [{
@@ -6532,6 +6532,7 @@ export const cutUndeleteProject = (options) => (options.client ?? client).post({
6532
6532
  * - `TOO_MANY_EFFECTS` — More than 8 effects on one clip.
6533
6533
  * - `PROJECT_NOT_FOUND` — No visible project has this id.
6534
6534
  * - `EXPORT_NOT_FOUND` — No such export in this project.
6535
+ * - `DRAFT_RENDER_NOT_FOUND` — No such draft render.
6535
6536
  * - `VERSION_NOT_FOUND` — No saved version has this revision.
6536
6537
  * - `LIBRARY_NOT_FOUND` — The library is missing or invisible.
6537
6538
  * - `BINDING_INVALID` — The binding request is malformed.
@@ -6632,9 +6633,9 @@ export const cutListFrames = (options) => (options.client ?? client).get({
6632
6633
  ...options
6633
6634
  });
6634
6635
  /**
6635
- * Analyze project media
6636
+ * Analyze project media or measure the project mix
6636
6637
  *
6637
- * Request silence, filler-word or scene analysis for selected bound assets before editing. Omit media to select project sources; ranges returned in segments use source seconds. A pending result is not completion: use retry_after_sec before checking again, and inspect failed or unsupported asset results before deciding which edits are possible. Silence measures transcript-based speech pauses, not music or loudness. A completed transcript without words returns ready with empty segments and reason no_speech; no completed transcript returns unsupported with reason no_transcript. A failed transcription remains failed.
6638
+ * Request silence, filler-word or scene analysis for selected bound assets before editing, or measure the mix the timeline itself renders with kind mix. That kind is a render job, not a read: it answers pending with retry_after_sec and is polled by the id it returned, because the answer only exists once the audio has been rendered and measured. Omit media to select project sources; ranges returned in segments use source seconds. A pending result is not completion: use retry_after_sec before checking again, and inspect failed or unsupported asset results before deciding which edits are possible. Silence measures transcript-based speech pauses, not music or loudness. A completed transcript without words returns ready with empty segments and reason no_speech; no completed transcript returns unsupported with reason no_transcript. A failed transcription remains failed. kind mix is separate: it reports the project mix loudness, the loudness of each role and where music masks speech, so an editor can fix the mix rather than guess at it.
6638
6639
  */
6639
6640
  export const cutCreateAnalysis = (options) => (options.client ?? client).post({
6640
6641
  security: [{
@@ -7432,7 +7433,7 @@ export const devopsTestRunsList = (options) => (options.client ?? client).get({
7432
7433
  /**
7433
7434
  * Create a test run
7434
7435
  *
7435
- * Start a run of the project's tests at one commit. Name a plan to use its selector, or pass a selector directly for this run alone; the ref says which commit to test and is required, because a run without a commit has nothing to report against. waitUntil decides how far the call waits before answering — queued returns as soon as the run exists, finished waits for a verdict and may take minutes. A retry of an earlier run is a new run: pass its commit and selector, and read the earlier run to compare.
7436
+ * Start a run of the project's tests at one commit. Name a plan to use its selector, or pass a selector directly for this run alone; the ref says which commit to test and is required, because a run without a commit has nothing to report against. waitUntil decides how far the call waits before answering — queued, the default, returns as soon as the run exists; started waits until the run has begun, except for an external run, which is answered at once because it leaves queued only when your own CI uploads; finished waits for a verdict. The wait is bounded at about 25 seconds, and a wait that reaches that bound returns the run as it stands rather than failing — read state to see whether it finished. A retry of an earlier run is a new run: pass its commit and selector, and read the earlier run to compare.
7436
7437
  */
7437
7438
  export const devopsTestRunsCreate = (options) => (options.client ?? client).post({
7438
7439
  security: [{
@@ -12602,6 +12602,10 @@ export type CutProject = {
12602
12602
  * ISO 8601 timestamp when this project was created.
12603
12603
  */
12604
12604
  create_time: string;
12605
+ /**
12606
+ * Link that opens this project in the Praxis Console, in the Console of the environment serving the request. Open this URL when telling a user where to edit the project, and use the value as given — do not build the link yourself, because the Console host differs per environment (develop and production are different hosts) and a composed address will not open.
12607
+ */
12608
+ console_url?: string;
12605
12609
  /**
12606
12610
  * ISO 8601 timestamp of the latest committed project update.
12607
12611
  */
@@ -12860,6 +12864,113 @@ export type CutAnalysisResult = {
12860
12864
  retry_after_sec?: number;
12861
12865
  }>;
12862
12866
  };
12867
+ /**
12868
+ * One mix measurement of the project's own rendered mix (kind mix). Seconds are relative to the measured range's start. A second nothing sounds in is measured at the -60 LUFS floor.
12869
+ */
12870
+ export type CutMixAnalysis = {
12871
+ /**
12872
+ * Always mix; distinguishes this reply from the per-asset analysis results.
12873
+ */
12874
+ kind: 'mix';
12875
+ /**
12876
+ * Range start on the project clock. In seconds, not frames or microseconds.
12877
+ */
12878
+ from: number;
12879
+ /**
12880
+ * Range end on the project clock, exclusive. In seconds, not frames or microseconds.
12881
+ */
12882
+ to: number;
12883
+ /**
12884
+ * Project revision measured.
12885
+ */
12886
+ revision: number;
12887
+ /**
12888
+ * pending means the measurement is still rendering, not that it is complete; ready means the mix is below; failed means it did not complete.
12889
+ */
12890
+ status: 'pending' | 'ready' | 'failed';
12891
+ /**
12892
+ * The measurement's own id. Pass it back with kind mix to poll; a measurement is never listed, so this is the only handle on it.
12893
+ */
12894
+ id?: string;
12895
+ /**
12896
+ * Suggested delay before polling again; present while status is pending. In seconds, not frames or microseconds.
12897
+ */
12898
+ retry_after_sec?: number;
12899
+ /**
12900
+ * Why a failed measurement did not complete.
12901
+ */
12902
+ error?: {
12903
+ /**
12904
+ * Machine-readable failure code.
12905
+ */
12906
+ code: string;
12907
+ /**
12908
+ * Bounded human-readable cause; provider text and capability URLs are stripped.
12909
+ */
12910
+ message: string;
12911
+ };
12912
+ /**
12913
+ * When the measurement was requested, RFC 3339.
12914
+ */
12915
+ created: string;
12916
+ /**
12917
+ * When it reached ready or failed, RFC 3339.
12918
+ */
12919
+ finished?: string;
12920
+ /**
12921
+ * The measurement, present once status is ready. loudness is the whole mix — what a listener hears — and roles is the same measurement per role, so a problem can be attributed to the voice or to the bed.
12922
+ */
12923
+ mix?: {
12924
+ loudness: CutMixLoudness;
12925
+ /**
12926
+ * Per-role loudness. A role the timeline carries no clip of is null, never a silent render.
12927
+ */
12928
+ roles: {
12929
+ /**
12930
+ * Loudness of the speech tracks — those declaring role voice, or carrying a transcript. Null when the timeline has no voice at all.
12931
+ */
12932
+ voice: CutMixLoudness;
12933
+ /**
12934
+ * Loudness of the bed — tracks declaring role music, plus every audio track that is neither speech nor a declared effect. Null when the timeline has no bed.
12935
+ */
12936
+ music: CutMixLoudness;
12937
+ /**
12938
+ * Loudness of tracks declaring role sfx. Never inferred, so it is null unless an editor declared one.
12939
+ */
12940
+ sfx: CutMixLoudness;
12941
+ };
12942
+ /**
12943
+ * Voice against music, second by second, merged into runs of one sign and empty when either role is absent. A run's value is the mean over its seconds.
12944
+ */
12945
+ dialogue_to_music_db: Array<{
12946
+ /**
12947
+ * Run start, in seconds relative to the measured range.
12948
+ */
12949
+ start: number;
12950
+ /**
12951
+ * Run length in whole seconds.
12952
+ */
12953
+ duration: number;
12954
+ /**
12955
+ * Mean voice-minus-music level over the run, in dB. Positive means the voice sits above the bed.
12956
+ */
12957
+ value: number;
12958
+ }>;
12959
+ /**
12960
+ * Where speech is masked — the voice is audible and sits less than 10 dB above the music. Music alone is never masked speech, and a silent voice is not speech.
12961
+ */
12962
+ masked_speech: Array<{
12963
+ /**
12964
+ * Interval start, in seconds relative to the measured range.
12965
+ */
12966
+ start: number;
12967
+ /**
12968
+ * Interval length in whole seconds.
12969
+ */
12970
+ duration: number;
12971
+ }>;
12972
+ };
12973
+ };
12863
12974
  /**
12864
12975
  * Select analysis kinds and optionally limit source assets.
12865
12976
  */
@@ -12869,9 +12980,25 @@ export type CutAnalysisInput = {
12869
12980
  */
12870
12981
  media?: Array<CutMediaRef>;
12871
12982
  /**
12872
- * Analysis types to request for the selected source assets.
12983
+ * Analysis types to request. silence, filler and scenes analyze the selected source assets and are read from the media library; mix measures the project's own rendered mix and is requested on its own.
12984
+ */
12985
+ kinds: Array<'silence' | 'filler' | 'scenes' | 'mix'>;
12986
+ /**
12987
+ * Range start for kind mix, in seconds on the project clock. Omitted with to, the whole timeline is measured, capped at 120 seconds. Ignored by the asset kinds.
12988
+ */
12989
+ from?: number;
12990
+ /**
12991
+ * Range end for kind mix, in seconds on the project clock, exclusive. A range longer than 120 seconds is refused; request several ranges instead.
12992
+ */
12993
+ to?: number;
12994
+ /**
12995
+ * Optional committed project revision to measure; omission uses the current revision. Mix only.
12996
+ */
12997
+ revision?: number;
12998
+ /**
12999
+ * Poll one running mix measurement by the id its first call returned. Sending id reads that measurement and renders nothing.
12873
13000
  */
12874
- kinds: Array<'silence' | 'filler' | 'scenes'>;
13001
+ id?: string;
12875
13002
  };
12876
13003
  /**
12877
13004
  * Current project media library bindings.
@@ -13097,6 +13224,10 @@ export type CutExport = {
13097
13224
  */
13098
13225
  detail: string;
13099
13226
  }>;
13227
+ /**
13228
+ * Timeline position in seconds the cover frame was taken at, frame-exact, and the moment written as the exported asset's cover. Present on exports frozen from this version onward: the requested poster.at, or the first frame with picture when poster was omitted.
13229
+ */
13230
+ poster_at?: number;
13100
13231
  /**
13101
13232
  * Output media reference, available after the export reaches done.
13102
13233
  */
@@ -13182,6 +13313,15 @@ export type CutExportInput = {
13182
13313
  */
13183
13314
  true_peak_dbtp: number;
13184
13315
  } | null;
13316
+ /**
13317
+ * Cover frame, in seconds on the project clock. Omitted, the cover is the first frame with picture that is not inside a fade-in or a transition — a black opening no longer makes the library thumbnail black. A frame inside a transition is skipped, and a timeline that is black throughout keeps its first frame (reported as BLACK_FIRST_FRAME). The frame actually used is reported as poster_at on the export.
13318
+ */
13319
+ poster?: {
13320
+ /**
13321
+ * Timeline position in seconds the cover is taken at; rounded to the nearest project frame.
13322
+ */
13323
+ at: number;
13324
+ };
13185
13325
  };
13186
13326
  /**
13187
13327
  * One page of organization-accessible exports.
@@ -13806,6 +13946,10 @@ export type DevopsSuitePage = {
13806
13946
  * The suites on this page, in the project's catalog file order.
13807
13947
  */
13808
13948
  items: Array<DevopsSuite>;
13949
+ /**
13950
+ * How many items match this list's project and filter across every page, so a dashboard can show a total without walking the pages. Returned on the first page only; a page reached by a pageToken omits it, so read it from the first request rather than expecting it on every page.
13951
+ */
13952
+ totalSize?: number;
13809
13953
  /**
13810
13954
  * Cursor for the next page; an empty string means this was the last page, which is the only signal a list is finished.
13811
13955
  */
@@ -13888,6 +14032,10 @@ export type DevopsTestCasePage = {
13888
14032
  * The cases on this page, in the project's catalog file order.
13889
14033
  */
13890
14034
  items: Array<DevopsTestCase>;
14035
+ /**
14036
+ * How many items match this list's project and filter across every page, so a dashboard can show a total without walking the pages. Returned on the first page only; a page reached by a pageToken omits it, so read it from the first request rather than expecting it on every page.
14037
+ */
14038
+ totalSize?: number;
13891
14039
  /**
13892
14040
  * Cursor for the next page; an empty string means this was the last page, which is the only signal a list is finished.
13893
14041
  */
@@ -13978,6 +14126,27 @@ export type DevopsTestCase = {
13978
14126
  */
13979
14127
  healthSince?: string;
13980
14128
  stats: DevopsCaseStats;
14129
+ /**
14130
+ * The case's own latest executions, at most the last 30, oldest first — the strip a test board draws per row. Absent when the case has not run yet, which is why it is not an empty list. Each entry is one execution; read state and health for the judgement drawn from the whole history.
14131
+ */
14132
+ recent?: Array<{
14133
+ /**
14134
+ * How this execution ended. failed counts against the run unless the case was quarantined; skipped neither passes nor fails it.
14135
+ */
14136
+ status?: 'passed' | 'failed' | 'skipped' | 'pending' | 'other' | 'timed_out' | 'cancelled';
14137
+ /**
14138
+ * True when this execution failed and then passed on a retry inside the same run — the per-execution fact behind the case's flaky health.
14139
+ */
14140
+ flaky?: boolean;
14141
+ /**
14142
+ * RFC 3339 UTC time the execution was recorded, which is what orders the strip; two executions of the same commit are told apart by it.
14143
+ */
14144
+ time?: string;
14145
+ /**
14146
+ * Full 40-hex commit sha this execution ran at; the commits the strip shows are the ones a bisect or a regression read compares.
14147
+ */
14148
+ commit?: string;
14149
+ }>;
13981
14150
  state: DevopsCaseState;
13982
14151
  /**
13983
14152
  * True when the case may never be quarantined — a safety or security check whose failure must always count; a quarantine attempt on it is refused.
@@ -14004,6 +14173,10 @@ export type DevopsPlanPage = {
14004
14173
  * The plans on this page, in creation order.
14005
14174
  */
14006
14175
  items: Array<DevopsPlan>;
14176
+ /**
14177
+ * How many items match this list's project and filter across every page, so a dashboard can show a total without walking the pages. Returned on the first page only; a page reached by a pageToken omits it, so read it from the first request rather than expecting it on every page.
14178
+ */
14179
+ totalSize?: number;
14007
14180
  /**
14008
14181
  * Cursor for the next page; an empty string means this was the last page, which is the only signal a list is finished.
14009
14182
  */
@@ -14191,6 +14364,10 @@ export type DevopsRunPage = {
14191
14364
  * The runs on this page, newest first.
14192
14365
  */
14193
14366
  items: Array<DevopsRun>;
14367
+ /**
14368
+ * How many items match this list's project and filter across every page, so a dashboard can show a total without walking the pages. Returned on the first page only; a page reached by a pageToken omits it, so read it from the first request rather than expecting it on every page.
14369
+ */
14370
+ totalSize?: number;
14194
14371
  /**
14195
14372
  * Cursor for the next page; an empty string means this was the last page, which is the only signal a list is finished.
14196
14373
  */
@@ -14235,7 +14412,7 @@ export type DevopsRunCreate = {
14235
14412
  */
14236
14413
  repeat?: number;
14237
14414
  /**
14238
- * How far the call waits before answering — queued returns at once, started waits for execution to begin, finished waits for a verdict and may take minutes.
14415
+ * How far the call waits before answering, bounded at about 25 seconds; omit it for queued, which returns at once. The wait reads the run's own state, so a wait that reaches the bound returns the run as it stands instead of failing — check state before assuming the request was honoured.
14239
14416
  */
14240
14417
  waitUntil?: 'queued' | 'started' | 'finished';
14241
14418
  /**
@@ -26772,6 +26949,40 @@ export type CutMediaRef = {
26772
26949
  */
26773
26950
  asset_id: string;
26774
26951
  };
26952
+ /**
26953
+ * Loudness of one rendered mix, measured with ffmpeg ebur128 over the range (ADR-071). The shape is the asset-side loudness shape (BS.1770-4); only the gating series it does not need is absent.
26954
+ */
26955
+ export type CutMixLoudness = {
26956
+ /**
26957
+ * Measurement standard the numbers follow. BS.1770-4 is ITU-R BS.1770-4, the loudness and true-peak standard every number here is measured to.
26958
+ */
26959
+ standard: 'BS.1770-4';
26960
+ /**
26961
+ * Integrated loudness over the range, in LUFS. Silence is measured at the -60 LUFS floor.
26962
+ */
26963
+ integrated_lufs: number;
26964
+ /**
26965
+ * Loudness range, in LU.
26966
+ */
26967
+ range_lu: number;
26968
+ /**
26969
+ * Loudest true peak over the range, in dBTP.
26970
+ */
26971
+ true_peak_dbtp: number;
26972
+ /**
26973
+ * The measurement over time, one point per whole second — the interval at which the asset-side series is fixed too.
26974
+ */
26975
+ series: {
26976
+ /**
26977
+ * Seconds between points. 1 is the only interval a measurement reports, the same one the asset-side loudness series is fixed at.
26978
+ */
26979
+ interval_sec: 1;
26980
+ /**
26981
+ * Momentary loudness (a 400 ms window) at the end of each whole second, in LUFS. The first whole second is the first measurable one; a second holding no signal reads the -60 floor.
26982
+ */
26983
+ momentary_lufs: Array<number>;
26984
+ };
26985
+ };
26775
26986
  /**
26776
26987
  * Rendering options for an exported video.
26777
26988
  */
@@ -33799,6 +34010,10 @@ export type CutItem = {
33799
34010
  * Time to recover the original level. In seconds, not frames or microseconds.
33800
34011
  */
33801
34012
  release?: number;
34013
+ /**
34014
+ * What triggers the duck. occupancy (the default, and what an omitted mode means) lowers this clip while a clip on the under track is audible, whatever its level; level lowers this clip only while the under track's measured level is above -40 dBFS, so a silent clip on the under track no longer ducks.
34015
+ */
34016
+ mode?: 'occupancy' | 'level';
33802
34017
  };
33803
34018
  /**
33804
34019
  * Transition at the incoming clip edge.
@@ -45604,6 +45819,10 @@ export type BrowserListContextsData = {
45604
45819
  body?: never;
45605
45820
  path?: never;
45606
45821
  query?: {
45822
+ /**
45823
+ * 按登录态名称精确匹配;名称在当前账户内唯一,所以最多返回一条。省略时列出全部登录态。
45824
+ */
45825
+ name?: string;
45607
45826
  /**
45608
45827
  * 登录态 ID;使用创建或列出登录态返回的 id,以 bsc_ 开头。
45609
45828
  */
@@ -72169,7 +72388,7 @@ export type CutListFramesResponses = {
72169
72388
  export type CutListFramesResponse = CutListFramesResponses[keyof CutListFramesResponses];
72170
72389
  export type CutCreateAnalysisData = {
72171
72390
  /**
72172
- * Select analysis kinds and optionally limit source assets.
72391
+ * Select analysis kinds and optionally limit source assets. kind mix measures the project's own mix over a range and answers a MixAnalysis, which is polled by the id it returns.
72173
72392
  */
72174
72393
  body: CutAnalysisInput;
72175
72394
  path: {
@@ -72212,7 +72431,11 @@ export type CutCreateAnalysisResponses = {
72212
72431
  /**
72213
72432
  * Requested resource or operation result; use its revision when preparing a guarded edit.
72214
72433
  */
72215
- 200: CutAnalysisResult;
72434
+ 200: ({
72435
+ kind: 'cut-AnalysisResult';
72436
+ } & CutAnalysisResult) | ({
72437
+ kind: 'cut-MixAnalysis';
72438
+ } & CutMixAnalysis);
72216
72439
  };
72217
72440
  export type CutCreateAnalysisResponse = CutCreateAnalysisResponses[keyof CutCreateAnalysisResponses];
72218
72441
  export type CutListBindingsData = {
@@ -47,6 +47,7 @@ interface ContextsApi {
47
47
  query?: {
48
48
  limit?: number;
49
49
  cursor?: string;
50
+ name?: string;
50
51
  };
51
52
  }): Promise<{
52
53
  data: (ContextLike & {
@@ -61,6 +62,15 @@ interface ContextsApi {
61
62
  };
62
63
  }): Promise<ContextLike>;
63
64
  }
65
+ /** The playwright-core module shape the helper uses. */
66
+ export interface PlaywrightModule {
67
+ chromium: {
68
+ connectOverCDP(url: string, options: {
69
+ headers: Record<string, string>;
70
+ timeout?: number;
71
+ }): Promise<unknown>;
72
+ };
73
+ }
64
74
  /** What connect() needs from the platform client and the process. All of it is injectable for tests. */
65
75
  export interface BrowserConnectDeps {
66
76
  contexts: ContextsApi;
@@ -68,6 +78,8 @@ export interface BrowserConnectDeps {
68
78
  /** process.getBuiltinModule; undefined on runtimes without it. */
69
79
  builtin: ((name: string) => unknown) | undefined;
70
80
  now?: () => number;
81
+ /** An already-loaded playwright-core; the real loader finds or installs one and imports it. */
82
+ playwright?: PlaywrightModule;
71
83
  }
72
84
  export declare const unavailable: (message: string) => PraxisError;
73
85
  /** Same signal the plugin installer and child_process use: the light machine asks to be upgraded and the program runs again. */
@@ -8,7 +8,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  };
9
9
  import { PraxisError } from "../core/errors.js";
10
10
  import { BROWSER_DOCUMENTATION } from "./browser-documentation.js";
11
- import { agentContextName, buildConnectUrl, decideTabReuse, pickAgentContext } from "./browser-decisions.js";
11
+ import { agentContextName, buildConnectUrl, decideTabReuse, isDuplicateNameError, matchTargetsToPages, pickAgentContext, pickContextByName } from "./browser-decisions.js";
12
12
  /** Version of the Playwright client library: preinstalled in the base image, installed on demand elsewhere. */
13
13
  export const PLAYWRIGHT_CORE_VERSION = '1.63.0';
14
14
  const GLOBAL_PLAYWRIGHT = '/usr/local/lib/node_modules/playwright-core';
@@ -33,6 +33,8 @@ function node(deps, name) {
33
33
  throw needsFullMachine();
34
34
  }
35
35
  async function loadPlaywright(deps, home) {
36
+ if (deps.playwright)
37
+ return deps.playwright;
36
38
  node(deps, 'node:child_process'); // fails fast on a light machine, before any network work
37
39
  const fs = node(deps, 'node:fs');
38
40
  const entry = (root) => `${root}/index.mjs`;
@@ -49,20 +51,49 @@ async function loadPlaywright(deps, home) {
49
51
  }
50
52
  return await import(__rewriteRelativeImportExtension(/* @vite-ignore */ `file://${entry(root)}`));
51
53
  }
54
+ /** The agent's own context, in one name-filtered request; the paged scan is only the pre-`name` server fallback. */
52
55
  async function ensureContext(deps, agentId) {
53
- const seen = [];
54
- let cursor;
55
- for (let page = 0; page < 20; page++) {
56
- const result = await deps.contexts.list({ query: { limit: 100, ...(cursor ? { cursor } : {}) } });
57
- seen.push(...result.data);
58
- const own = pickAgentContext(seen, agentId);
59
- if (own)
60
- return own.id;
61
- if (!result.nextCursor)
62
- break;
63
- cursor = result.nextCursor;
56
+ const name = agentContextName(agentId);
57
+ const byNameQuery = () => deps.contexts.list({ query: { name, limit: 1 } });
58
+ // A server that knows `name` answers with this agent's context or nothing; a non-empty answer of other rows means
59
+ // it ignored the filter, and only then is the paged scan worth its round trips.
60
+ const paged = async () => {
61
+ const seen = [];
62
+ let cursor;
63
+ for (let page = 0; page < 20; page++) {
64
+ const result = await deps.contexts.list({ query: { limit: 100, ...(cursor ? { cursor } : {}) } });
65
+ seen.push(...result.data);
66
+ const own = pickAgentContext(seen, agentId);
67
+ if (own)
68
+ return own.id;
69
+ if (!result.nextCursor)
70
+ break;
71
+ cursor = result.nextCursor;
72
+ }
73
+ return undefined;
74
+ };
75
+ const find = async () => {
76
+ const answer = (await byNameQuery()).data;
77
+ const byName = pickContextByName(answer, agentId);
78
+ if (byName)
79
+ return byName.id;
80
+ return answer.length > 0 ? paged() : undefined;
81
+ };
82
+ const existing = await find();
83
+ if (existing)
84
+ return existing;
85
+ try {
86
+ return (await deps.contexts.create({ body: { name, labels: { agent: agentId } } })).id;
87
+ }
88
+ catch (cause) {
89
+ // Names are unique per account, so this is a concurrent run winning the create: reuse what it made.
90
+ if (!isDuplicateNameError(cause))
91
+ throw cause;
92
+ const raced = await find();
93
+ if (raced)
94
+ return raced;
95
+ throw cause;
64
96
  }
65
- return (await deps.contexts.create({ body: { name: agentContextName(agentId), labels: { agent: agentId } } })).id;
66
97
  }
67
98
  const bounded = (work, ms) => Promise.race([work, new Promise((_, reject) => setTimeout(() => reject(new Error('timed out')), ms))]);
68
99
  export async function connectBrowser(deps, options = {}) {
@@ -86,6 +117,33 @@ export async function connectBrowser(deps, options = {}) {
86
117
  const now = deps.now ?? Date.now;
87
118
  const pages = () => browser.contexts().flatMap((c) => c.pages());
88
119
  const ids = new WeakMap();
120
+ /** One browser-level CDP session for the connection: `Target.getTargets` answers for every tab in one round trip. */
121
+ let cdp;
122
+ const browserSession = async () => {
123
+ if (!browser.newBrowserCDPSession)
124
+ return undefined; // older playwright-core: every page keeps the per-page lookup
125
+ if (!cdp) {
126
+ try {
127
+ cdp = await browser.newBrowserCDPSession();
128
+ }
129
+ catch {
130
+ return undefined;
131
+ } // a browser that refuses the session lists tabs the old way, it does not fail
132
+ }
133
+ return cdp;
134
+ };
135
+ /** CDP's page targets, or nothing when the browser session is unavailable — never a thrown listing. */
136
+ const pageTargets = async () => {
137
+ const session = await browserSession();
138
+ if (!session)
139
+ return undefined;
140
+ try {
141
+ return ((await session.send('Target.getTargets'))?.targetInfos ?? []);
142
+ }
143
+ catch {
144
+ return undefined;
145
+ }
146
+ };
89
147
  const idOf = async (page) => {
90
148
  const known = ids.get(page);
91
149
  if (known)
@@ -100,6 +158,25 @@ export async function connectBrowser(deps, options = {}) {
100
158
  await session.detach().catch(() => { });
101
159
  }
102
160
  };
161
+ /**
162
+ * Every page with its target id: the one `Target.getTargets` covers the pages it names unambiguously, and only
163
+ * the rest (another tab on the same url, a page it does not name) pay for their own `Target.getTargetInfo`.
164
+ * Matching itself makes no request, so `get` reads the map for free and only a miss asks the page again.
165
+ */
166
+ const observed = async () => {
167
+ const all = pages();
168
+ const urls = all.map(page => page.url());
169
+ const targets = await pageTargets();
170
+ const { matched } = matchTargetsToPages(targets ?? [], urls);
171
+ return all.map((page, index) => {
172
+ const target = matched.get(index);
173
+ if (target)
174
+ ids.set(page, target.targetId);
175
+ return { page, id: target?.targetId, url: target?.url ?? urls[index] ?? '', title: target?.title };
176
+ });
177
+ };
178
+ /** A page's target id, from the map when it named it or from its own CDP session otherwise. */
179
+ const idOfObserved = async (tab) => tab.id ?? await bounded(idOf(tab.page), 2000).catch(() => '');
103
180
  const wrap = async (page) => {
104
181
  const id = await idOf(page);
105
182
  return {
@@ -121,17 +198,20 @@ export async function connectBrowser(deps, options = {}) {
121
198
  },
122
199
  };
123
200
  };
124
- const list = async () => Promise.all(pages().map(async (page) => ({
125
- id: await idOf(page), url: page.url(),
126
- title: await bounded(page.title(), 2000).catch(() => ''),
127
- active: await bounded(page.evaluate(() => document.visibilityState === 'visible'), 2000).catch(() => false),
201
+ const list = async () => Promise.all((await observed()).map(async (tab) => ({
202
+ id: await idOfObserved(tab), url: tab.url,
203
+ // A matched target already carries the title; an unmapped page keeps asking its own page, as before.
204
+ title: tab.title ?? await bounded(tab.page.title(), 2000).catch(() => ''),
205
+ active: await bounded(tab.page.evaluate(() => document.visibilityState === 'visible'), 2000).catch(() => false),
128
206
  })));
129
207
  const get = async (id) => {
130
- for (const page of pages())
131
- if (await idOf(page) === id) {
132
- await page.bringToFront().catch(() => { });
133
- return wrap(page);
208
+ for (const tab of await observed()) {
209
+ const known = await idOfObserved(tab);
210
+ if (known === id && known) {
211
+ await tab.page.bringToFront().catch(() => { });
212
+ return wrap(tab.page);
134
213
  }
214
+ }
135
215
  throw new PraxisError({ status: 404, code: 'TAB_NOT_FOUND', message: `No tab with id ${id}; call browser.tabs.list() for the current tabs.` });
136
216
  };
137
217
  const create = async () => {
@@ -156,6 +236,11 @@ export async function connectBrowser(deps, options = {}) {
156
236
  return tab;
157
237
  },
158
238
  documentation: () => BROWSER_DOCUMENTATION,
159
- disconnect: async () => { await browser.close(); },
239
+ /** Drops this connection only; the cloud session and its tabs stay until it idles out. */
240
+ disconnect: async () => {
241
+ await cdp?.detach().catch(() => { });
242
+ cdp = undefined;
243
+ await browser.close();
244
+ },
160
245
  };
161
246
  }