@vertesia/client 1.5.0-dev.20260717.131047Z → 1.5.0-dev.20260725.083715Z
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/lib/AppsApi.d.ts +41 -7
- package/lib/AppsApi.d.ts.map +1 -1
- package/lib/AppsApi.js +72 -7
- package/lib/AppsApi.js.map +1 -1
- package/lib/AuditTrailApi.d.ts +2 -1
- package/lib/AuditTrailApi.d.ts.map +1 -1
- package/lib/AuditTrailApi.js +3 -0
- package/lib/AuditTrailApi.js.map +1 -1
- package/lib/ProjectsApi.d.ts +3 -1
- package/lib/ProjectsApi.d.ts.map +1 -1
- package/lib/ProjectsApi.js +16 -8
- package/lib/ProjectsApi.js.map +1 -1
- package/lib/ViewsApi.d.ts +21 -0
- package/lib/ViewsApi.d.ts.map +1 -0
- package/lib/ViewsApi.js +41 -0
- package/lib/ViewsApi.js.map +1 -0
- package/lib/client.d.ts +3 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +4 -1
- package/lib/client.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/store/AgentsApi.d.ts +5 -1
- package/lib/store/AgentsApi.d.ts.map +1 -1
- package/lib/store/AgentsApi.js +8 -0
- package/lib/store/AgentsApi.js.map +1 -1
- package/lib/store/AnalyzeDocApi.d.ts +9 -11
- package/lib/store/AnalyzeDocApi.d.ts.map +1 -1
- package/lib/store/AnalyzeDocApi.js +12 -36
- package/lib/store/AnalyzeDocApi.js.map +1 -1
- package/lib/store/FilesApi.d.ts.map +1 -1
- package/lib/store/FilesApi.js +10 -4
- package/lib/store/FilesApi.js.map +1 -1
- package/lib/store/ObjectsApi.d.ts.map +1 -1
- package/lib/store/ObjectsApi.js +3 -2
- package/lib/store/ObjectsApi.js.map +1 -1
- package/lib/store/ViewsApi.d.ts +12 -0
- package/lib/store/ViewsApi.d.ts.map +1 -0
- package/lib/store/ViewsApi.js +17 -0
- package/lib/store/ViewsApi.js.map +1 -0
- package/lib/store/client.d.ts +2 -0
- package/lib/store/client.d.ts.map +1 -1
- package/lib/store/client.js +2 -0
- package/lib/store/client.js.map +1 -1
- package/lib/store/index.d.ts +1 -0
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +1 -0
- package/lib/store/index.js.map +1 -1
- package/lib/store/uploadMimeType.d.ts +3 -0
- package/lib/store/uploadMimeType.d.ts.map +1 -0
- package/lib/store/uploadMimeType.js +11 -0
- package/lib/store/uploadMimeType.js.map +1 -0
- package/lib/vertesia-client.js +5 -5
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +8 -8
- package/src/AppsApi.test.ts +132 -0
- package/src/AppsApi.ts +100 -9
- package/src/AuditTrailApi.ts +10 -1
- package/src/ProjectsApi.test.ts +33 -0
- package/src/ProjectsApi.ts +19 -8
- package/src/ViewsApi.test.ts +36 -0
- package/src/ViewsApi.ts +60 -0
- package/src/client.ts +4 -1
- package/src/index.ts +1 -0
- package/src/store/AgentsApi.ts +17 -0
- package/src/store/AnalyzeDocApi.ts +16 -54
- package/src/store/FilesApi.ts +10 -4
- package/src/store/ObjectsApi.ts +3 -2
- package/src/store/ViewsApi.test.ts +33 -0
- package/src/store/ViewsApi.ts +20 -0
- package/src/store/client.ts +2 -0
- package/src/store/index.ts +1 -0
- package/src/store/uploadMimeType.test.ts +22 -0
- package/src/store/uploadMimeType.ts +16 -0
package/lib/store/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/store/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,GAItB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAyD,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAajD,SAAS,aAAa,CAAC,SAA6B;IAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,OAAO,UAAW,SAAQ,mBAA+B;IAC3D,YAAY,OAAwB,EAAE;QAClC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,CAAC,GAAiB,EAAE,EAAE;YACtC,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,IAAI,uBAAuB,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,CAAC;YACf,CAAC;QACL,CAAC,CAAC;IACN,CAAC;IAED,cAAc,CAAC,OAA+B;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sGAAsG;IACtG,cAAc,CAAC,OAAkC;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAqB;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACjG,CAAC;IAED,YAAY,CAAC,OAA6B;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YACnC,OAAO;SACV,CAAC,CAAC;IACP,CAAC;IAED,IAAI,cAAc;QACd,OAAO;YACH,GAAG,KAAK,CAAC,cAAc;YACvB,CAAC,cAAc,CAAC,EAAE,OAAO;SAC5B,CAAC;IACN,CAAC;IAED,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,SAAS,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,WAAW,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,UAAU,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,4CAA4C;IAC5C,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IAC/C,WAAW,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,UAAU,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/store/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,GAItB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAyD,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAajD,SAAS,aAAa,CAAC,SAA6B;IAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,OAAO,UAAW,SAAQ,mBAA+B;IAC3D,YAAY,OAAwB,EAAE;QAClC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,CAAC,GAAiB,EAAE,EAAE;YACtC,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrB,OAAO,IAAI,uBAAuB,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,GAAG,CAAC;YACf,CAAC;QACL,CAAC,CAAC;IACN,CAAC;IAED,cAAc,CAAC,OAA+B;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,sGAAsG;IACtG,cAAc,CAAC,OAAkC;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,MAAqB;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACjG,CAAC;IAED,YAAY,CAAC,OAA6B;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YACnC,OAAO;SACV,CAAC,CAAC;IACP,CAAC;IAED,IAAI,cAAc;QACd,OAAO;YACH,GAAG,KAAK,CAAC,cAAc;YACvB,CAAC,cAAc,CAAC,EAAE,OAAO;SAC5B,CAAC;IACN,CAAC;IAED,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,SAAS,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,WAAW,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,UAAU,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7B,4CAA4C;IAC5C,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IAC/C,WAAW,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3B,UAAU,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,SAAS,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;CACnC"}
|
package/lib/store/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './signed-url.js';
|
|
|
20
20
|
export * from './TaskApi.js';
|
|
21
21
|
export * from './TypeCatalogApi.js';
|
|
22
22
|
export * from './TypesApi.js';
|
|
23
|
+
export * from './ViewsApi.js';
|
|
23
24
|
export { APP_VERSION_HEADER } from './version.js';
|
|
24
25
|
export * from './WorkflowsApi.js';
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/store/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,cAAc,mBAAmB,CAAC"}
|
package/lib/store/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from './signed-url.js';
|
|
|
20
20
|
export * from './TaskApi.js';
|
|
21
21
|
export * from './TypeCatalogApi.js';
|
|
22
22
|
export * from './TypesApi.js';
|
|
23
|
+
export * from './ViewsApi.js';
|
|
23
24
|
export { APP_VERSION_HEADER } from './version.js';
|
|
24
25
|
export * from './WorkflowsApi.js';
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/lib/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function getUploadMimeTypeHint(contentType: string | undefined): string | undefined;
|
|
2
|
+
export declare function resolveUploadMimeType(sourceContentType: string | undefined, inferredContentType: string | undefined): string | undefined;
|
|
3
|
+
//# sourceMappingURL=uploadMimeType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadMimeType.d.ts","sourceRoot":"","sources":["../../src/store/uploadMimeType.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzF;AAED,wBAAgB,qBAAqB,CACjC,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACxC,MAAM,GAAG,SAAS,CAEpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const GENERIC_BINARY_CONTENT_TYPE = 'application/octet-stream';
|
|
2
|
+
function normalizedContentType(contentType) {
|
|
3
|
+
return contentType?.split(';', 1)[0]?.trim().toLowerCase() || undefined;
|
|
4
|
+
}
|
|
5
|
+
export function getUploadMimeTypeHint(contentType) {
|
|
6
|
+
return normalizedContentType(contentType) === GENERIC_BINARY_CONTENT_TYPE ? undefined : contentType || undefined;
|
|
7
|
+
}
|
|
8
|
+
export function resolveUploadMimeType(sourceContentType, inferredContentType) {
|
|
9
|
+
return getUploadMimeTypeHint(sourceContentType) || inferredContentType || sourceContentType || undefined;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=uploadMimeType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadMimeType.js","sourceRoot":"","sources":["../../src/store/uploadMimeType.ts"],"names":[],"mappings":"AAAA,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAE/D,SAAS,qBAAqB,CAAC,WAA+B;IAC1D,OAAO,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,WAA+B;IACjE,OAAO,qBAAqB,CAAC,WAAW,CAAC,KAAK,2BAA2B,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,IAAI,SAAS,CAAC;AACrH,CAAC;AAED,MAAM,UAAU,qBAAqB,CACjC,iBAAqC,EACrC,mBAAuC;IAEvC,OAAO,qBAAqB,CAAC,iBAAiB,CAAC,IAAI,mBAAmB,IAAI,iBAAiB,IAAI,SAAS,CAAC;AAC7G,CAAC"}
|
package/lib/vertesia-client.js
CHANGED
|
@@ -4,11 +4,11 @@ Stack Trace: `}return a}var v=class extends Error{status;payload;request;request
|
|
|
4
4
|
`,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
|
|
5
5
|
`,n);continue}let i=e.charCodeAt(n);if(w(e,n,i)){let i=e.charCodeAt(n+5)===32?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===10){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
|
|
6
6
|
`,n);continue}u=d===0?a:`${u}
|
|
7
|
-
${a}`,d++}else
|
|
7
|
+
${a}`,d++}else T(e,n,i)?f=e.slice(e.charCodeAt(n+6)===32?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
|
|
8
8
|
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
9
9
|
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===13&&e.charCodeAt(n)===10&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(w(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
|
|
10
|
-
${i}`,d++;return}if(
|
|
11
|
-
${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new x(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new x(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function w(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function ee(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var te=class extends TransformStream{constructor(){let e;super({start(t){e=C({onEvent(e){let n={type:`event`,...e};t.enqueue(n)}})},transform(t){e.feed(t)}})}};let T;if(globalThis.TextDecoderStream&&typeof globalThis.TextDecoderStream==`function`)T=globalThis.TextDecoderStream;else{class e extends TransformStream{_options;constructor(e=`utf-8`,{fatal:n=!1,ignoreBOM:r=!1}={}){super(new t(new TextDecoder(e,{fatal:n,ignoreBOM:r}))),this._options={fatal:n,ignoreBOM:r,encoding:e}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class t{decoder;constructor(e){this.decoder=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw TypeError(`Input must be a compatible with: ArrayBuffer | Uint8Array`);let n=this.decoder.decode(e,{stream:!0});n.length!==0&&t.enqueue(n)}flush(e){let t=this.decoder.decode();t.length!==0&&e.enqueue(t)}}T=e}async function ne(e){if(!e.ok){let t=await e.text(),n=Error(`SSE error: ${e.status}. Content:\n${t}`);throw n.status=e.status,n}if(!e.body)throw Error(`No body in response`);return e.body.pipeThrough(new T).pipeThrough(new te)}function re(e){let t=[];for(let n of Object.keys(e)){let r=e[n];r!=null&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`)}return t.join(`&`)}function ie(e,t){return e.endsWith(`/`)?t.startsWith(`/`)?e+t.substring(1):e+t:t.startsWith(`/`)?e+t:`${e}/${t}`}function E(e){return e[e.length-1]===`/`?e.slice(0,-1):e}function ae(e){if(!(e===!1||e===null||e?.enabled===!1))return{maxWaitMs:Math.max(0,e?.maxWaitMs??3e3),attempts:Math.max(0,Math.floor(e?.attempts??2))}}const oe=[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`],se=[502,503,504];function D(e){return typeof e==`object`&&!!e}function ce(e){return e?Promise.resolve(e):typeof globalThis.fetch==`function`?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw Error(`No Fetch implementation found`)})}function le(e){return D(e)&&e.error===`Not a valid JSON payload`&&typeof e.text==`string`}function ue(e){return!e||typeof ReadableStream>`u`||!(e instanceof ReadableStream)}function de(e){return e.status<500?!1:!(e.headers.get(`content-type`)??``).toLowerCase().includes(`json`)}function fe(e){let t=Math.max(1,Math.floor(e.attempts??3)),n=Math.max(0,e.baseDelayMs??250),r=Math.max(n,e.maxDelayMs??4e3);return{attempts:t,methods:new Set((e.methods??oe).map(e=>e.toUpperCase())),statuses:new Set(e.statuses??se),retryNonJsonServerErrors:e.retryNonJsonServerErrors??!0,retryOnConnectionError:e.retryOnConnectionError??!0,baseDelayMs:n,maxDelayMs:r,jitter:e.jitter??!0}}function pe(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function me(e,t){if(e.status!==429||e.headers.get(`x-ratelimit-reason`)!==`pacing`)return;let n=e.headers.get(`x-ratelimit-retry-ms`),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:pe(e);if(!(i===void 0||i>t.maxWaitMs))return i}function he(e){return new Promise(t=>setTimeout(t,e))}function ge(e,t,n){let r=(n?pe(n):void 0)??Math.min(e.maxDelayMs,e.baseDelayMs*2**t);return e.jitter?Math.floor(Math.random()*r):r}function _e(e){return e instanceof Error?e:Error(String(e))}function ve(e){return typeof e==`object`&&!!e&&`name`in e&&(e.name===`TimeoutError`||e.name===`AbortError`)}function ye(e){let t=AbortSignal.timeout;if(typeof t==`function`)return t(e);let n=new AbortController;return setTimeout(()=>n.abort(new DOMException(`The operation timed out`,`TimeoutError`)),e),n.signal}function be(e){let t=e.filter(e=>!!e);if(t.length===0)return;if(t.length===1)return t[0];let n=AbortSignal.any;if(typeof n==`function`)return n(t);let r=new AbortController;for(let e of t){if(e.aborted){r.abort(e.reason);break}e.addEventListener(`abort`,()=>r.abort(e.reason),{once:!0})}return r.signal}async function xe(e){try{await e.body?.cancel()}catch{}}var O=class{_fetch;baseUrl;errorFactory=e=>e;verboseErrors=!0;retryPolicy;pacingRetry;defaultTimeoutMs;constructor(e,t){this.baseUrl=E(e),this._fetch=ce(t)}throwError(e){throw this.errorFactory(e)}withPacingRetry(e){return this.pacingRetry=e===null?void 0:e,this}withRetryPolicy(e){return this.retryPolicy=e||void 0,this}getRetryPolicy(){return this.retryPolicy}withTimeout(e){return this.defaultTimeoutMs=typeof e==`number`&&e>0?e:void 0,this}getTimeout(){return this.defaultTimeoutMs}resolveTimeout(e){if(e?.reader===`sse`)return;let t=e?.timeoutMs;if(t===!1||t===null)return;if(typeof t==`number`)return t>0?t:void 0;let n=this.getTimeout();return n&&n>0?n:void 0}getUrl(e){return e.startsWith(`http://`)||e.startsWith(`https://`)?E(e):E(ie(this.baseUrl,e))}get(e,t){return this.request(`GET`,e,t)}del(e,t){return this.request(`DELETE`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}jsonParse(e){return JSON.parse(e)}createRequest(e,t){return Promise.resolve(new Request(e,t))}handleFetchResponse(e,t){}createServerError(e,t,n){let r=`Server Error: ${t.status}`;return n&&(le(n)?(r+=t.statusText?` ${t.statusText}`:``,r+=`: non-JSON response`):D(n)&&n.message?r=String(n.message):D(n)&&n.error&&(typeof n.error==`string`?r=String(n.error):D(n.error)&&typeof n.error.message==`string`&&(r=n.error.message))),new y(r,e,t.status,n,this.verboseErrors)}async readJSONPayload(e){return e.text().then(t=>{if(t)try{return this.jsonParse(t)}catch(n){return{status:e.status,error:`Not a valid JSON payload`,message:n instanceof Error?n.message:String(n),text:t}}else return}).catch(t=>{if(ve(t))throw t;return{status:e.status,error:`Unable to load response content`,message:t instanceof Error?t.message:String(t)}})}handleResponse(e,t,n){return n?.reader?n.reader===`sse`?ne(t):n.reader.call(this,t):this.readJSONPayload(t).then(n=>{if(t.ok)return n;this.throwError(this.createServerError(e,t,n))})}async request(e,t,n){let r=this.getUrl(t);n?.query&&(r+=`?${re(n.query)}`);let i=this.headers?Object.assign({},this.headers):{},a=n?.headers;if(a)for(let e in a)i[e.toLowerCase()]=a[e];let o,s=n?.payload;s&&(n&&n.jsonPayload===!1?o=s:(o=typeof s==`string`?s:JSON.stringify(s),`content-type`in i||(i[`content-type`]=`application/json`))),n?.reader===`sse`&&(i.accept=`text/event-stream`);let c=e.toUpperCase(),l=this.resolveTimeout(n),u=()=>{let e=be([n?.signal,l?ye(l):void 0]),t={method:c,headers:Object.assign({},i),body:o};return e&&(t.signal=e),t},d=this.resolveRetryPolicy(n),f=n?.reader===`sse`?void 0:ae(n?.pacingRetry??this.pacingRetry),p=await this._fetch,m=ue(o),h=0,g=0,_;for(;;){let e=await this.createRequest(r,u());_=e;let t;try{t=await p(e)}catch(t){(!d||!this.shouldRetryConnectionError(d,c,h,m))&&(console.error(`Failed to connect to ${r}`,t),this.throwError(new b(e,_e(t)))),await this.waitBeforeRetry(d,h),h++;continue}if(this.handleFetchResponse(e,t),f&&g<f.attempts&&m){let e=me(t,f);if(e!==void 0){await xe(t),await he(e),g++;continue}}if(d&&this.shouldRetryResponse(d,c,h,m,t)){await xe(t),await this.waitBeforeRetry(d,h,t),h++;continue}if(d&&h>=d.attempts)break;return this.handleResponse(e,t,n)}throw _&&this.throwError(new b(_,Error(`Retry attempts exhausted for ${c} ${r}`))),Error(`Retry attempts exhausted for ${c} ${r}`)}resolveRetryPolicy(e){if(e?.reader===`sse`||e?.retryPolicy===!1||e?.retryPolicy===null)return;let t=e?.retryPolicy,n=this.getRetryPolicy();if(!t&&!n)return;let r=fe({...n,...t});return r.attempts>1?r:void 0}shouldRetryResponse(e,t,n,r,i){let a=e.statuses.has(i.status)||e.retryNonJsonServerErrors&&de(i);return n<e.attempts-1&&r&&e.methods.has(t)&&a}shouldRetryConnectionError(e,t,n,r){return n<e.attempts-1&&r&&e.retryOnConnectionError&&e.methods.has(t)}waitBeforeRetry(e,t,n){let r=ge(e,t,n);return new Promise(e=>setTimeout(e,r))}async sseRequest(e,t,n,r){let i=(await this.request(e,t,{...n,reader:`sse`})).getReader(),a;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;a=t,r(t)}}finally{i.releaseLock()}return a}fetch(e,t){return this._fetch.then(n=>n(e,t))}};function Se(e){return e?`authorization`in e:!1}function Ce(){let e=globalThis;return e.window===void 0&&(typeof e.process?.versions?.node==`string`||typeof e.process?.versions?.bun==`string`||e.Bun!==void 0)}var we=class extends O{headers;_auth;onRequest;onResponse;response;constructor(e,t){super(e,t),this.baseUrl=e[e.length-1]===`/`?e.substring(0,e.length-1):e,this.headers=this.initialHeaders}get initialHeaders(){let e={accept:`application/json`};return Ce()&&(e[`accept-encoding`]=`br, gzip, deflate`),e}withAuthCallback(e){return this._auth=e||void 0,this}withErrorFactory(e){return this.errorFactory=e,this}withLang(e){return e?this.headers[`accept-language`]=e:delete this.headers[`accept-language`],this}withHeaders(e){let t=this.headers;for(let n in e){let r=e[n];r!=null&&(t[n.toLowerCase()]=r)}return this}setHeader(e,t){t?this.headers[e.toLowerCase()]=t:delete this.headers[e.toLowerCase()]}async createRequest(e,t){if(this._auth&&!Se(t.headers)){t.headers=t.headers?t.headers:{};let e=await this._auth();e&&(t.headers.authorization=e)}this.response=void 0;let n=await super.createRequest(e,t);return this.onRequest?.(n),n}handleFetchResponse(e,t){this.response=t,this.onResponse?.(t,e)}},k=class extends O{client;constructor(e,t){super(e.getUrl(t),e._fetch),this.client=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}createRequest(e,t){return this.client.createRequest(e,t)}handleResponse(e,t,n){return this.client.handleResponse(e,t,n)}handleFetchResponse(e,t){this.client.handleFetchResponse(e,t)}getRetryPolicy(){return this.client.getRetryPolicy()}getTimeout(){return this.client.getTimeout()}get headers(){return this.client.headers}},Te=class extends k{constructor(e){super(e,`/api/v1/account`)}info(){return this.get(`/`)}update(e){return this.put(`/`,{payload:e})}projects(){return this.get(`/projects`).then(e=>e.data)}members(){return this.get(`/members`)}inviteUser(e){return this.post(`/invites`,{payload:e})}listInvites(){return this.get(`/invites`)}listInvitation(e=`project`){return this.get(`/invites/${e}`)}acceptInvite(e){return this.put(`/invites/${e}`)}rejectInvite(e){return this.del(`/invites/${e}`)}onboardingProgress(){return this.get(`/onboarding`)}getStripeBillingStatus(){return this.get(`/stripe-billing-status`)}},Ee=class extends k{constructor(e){super(e,`/api/v1/accounts`)}create(e){return this.post(`/`,{payload:{name:e}})}list(){return this.get(`/`)}},De=class extends k{constructor(e){super(e,`/api/v1/analytics`)}runsSummary(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/summary${r?`?${r}`:``}`)}runsTimeSeries(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/time-series${r?`?${r}`:``}`)}runsTokenUsage(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/token-usage${r?`?${r}`:``}`)}},Oe=class extends k{constructor(e){super(e,`/api/v1/apikeys`)}list(e=`account`){return this.get(`/`,{query:{level:e}})}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}retrieve(e,t=!1){return t?this.get(`/${e}`,{query:{withValue:!0}}):this.get(`/${e}`)}delete(e){return this.del(`/${e}`)}getToken(e){return this.get(`/${e}/token`)}requestPublicKey(e={}){return this.get(`/pk`,{query:e})}},ke=class extends k{constructor(e){super(e,`/api/v1/apps`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}previewDelete(e){return this.del(`/${e}`)}deleteApp(e){return this.del(`/${e}`,{query:{confirm:`true`}})}listVersions(e){return this.get(`/versions`,{query:{...e?.app_id&&{app_id:e.app_id},...e?.kind&&{kind:e.kind},...e?.include_expired!==void 0&&{include_expired:e.include_expired},...e?.limit!==void 0&&{limit:e.limit}}})}upsertVersion(e){return this.post(`/versions`,{payload:e})}getVersion(e){return this.get(`/versions/${e}`)}activateVersion(e){return this.post(`/versions/${e}/activate`)}startBuild(e,t){return this.post(`/${encodeURIComponent(e)}/builds`,{payload:t})}getBuildProgress(e,t,n){return this.get(`/${encodeURIComponent(e)}/builds/${encodeURIComponent(t)}/${encodeURIComponent(n)}/progress`)}listAppInstallationTools(e){return this.get(`/installations/${e}/tools`)}inspect(e){return this.get(`/${e}/inspect`)}getRepoTree(e,t){return this.get(`/${encodeURIComponent(e)}/repo/tree`,{query:{prefix:t?.prefix,ref:t?.ref}})}getRepoFile(e,t,n){return this.get(`/${encodeURIComponent(e)}/repo/file`,{query:{path:t,ref:n?.ref}})}getRepoRefs(e){return this.get(`/${encodeURIComponent(e)}/repo/refs`)}getAppPackage(e,t=`all`){return this.get(`/${encodeURIComponent(e)}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getAppInstallationPackage(e,t=`all`){return this.get(`/installations/${e}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getSystemToolsPackage(e=`tools`){return this.get(`/studio-tools/package`,{query:{scope:e}})}list(){return this.get(`/`)}install(e,t,n,r){return this.post(`/install`,{payload:{app_id:e,settings:t,oauth_params:n,oauth_provider_params:r}})}uninstall(e){return this.del(`/install/${e}`)}getAppInstallationByName(e){return this.get(`/installations/name/${e}`).catch(e=>{if(e.status===404)return null;throw e})}getAppInstallationProjects(e){if(!e.id&&!e.name)throw Error(`Invalid arguments: appId or appName must be specified`);let t=e.id?{id:e.id}:{name:e.name};return this.get(`/installations/projects`,{query:t})}getInstalledApps(e){return this.get(`/installations`,{query:{kind:e}})}getAllAppInstallations(){return this.get(`/installations/all`)}listInstallations(){return this.get(`/installations/refs`)}updateInstallationSettings(e){return this.put(`/installations/settings/${e.app_id}`,{payload:{app_id:e.app_id,settings:e.settings,...`access_control`in e?{access_control:e.access_control}:{}}})}updateToolAllowlist(e,t){return this.put(`/installations/${e}/tool-allowlist`,{payload:{tool_allowlist:t}})}validateUrl(e){return this.post(`/validate-url`,{payload:{url:e}})}},Ae=class extends k{constructor(e){super(e,`/api/v1/audit-trail`)}list(e){let t=new URLSearchParams;e?.actions?.length&&t.set(`actions`,e.actions.join(`,`)),e?.resourceTypes?.length&&t.set(`resourceTypes`,e.resourceTypes.join(`,`)),e?.resourceId&&t.set(`resourceId`,e.resourceId),e?.principalId&&t.set(`principalId`,e.principalId),e?.principalType&&t.set(`principalType`,e.principalType),e?.effectivePrincipalId&&t.set(`effectivePrincipalId`,e.effectivePrincipalId),e?.hasEffectivePrincipal!==void 0&&t.set(`hasEffectivePrincipal`,String(e.hasEffectivePrincipal)),e?.projectId&&t.set(`projectId`,e.projectId),e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(`/${n?`?${n}`:``}`)}},je=class extends k{constructor(e){super(e,`/api/v1/commands`)}async isNamespaceAvailable(e){return this.get(`/namespaces/${e}/is_available`).then(e=>e.available)}async initSamples(){return this.post(`/onboarding/init-samples`)}},Me=class extends k{constructor(e){super(e,`/api/v1/environments`)}list(e=!1){let t=e?{all:!0}:void 0;return this.get(`/`,{query:t})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}updateConfig(e,t){return this.put(`/${e}/config`,{payload:t})}listModels(e,t){return this.get(`/${e}/models`,{query:t?{...t}:void 0})}enableModel(e,t){return this.post(`/${e}/models/enabled`,{payload:t})}disableModel(e,t){return this.del(`/${e}/models/enabled/${encodeURIComponent(t)}`)}listTrainableModels(e){return this.get(`/${e}/trainable-models`)}embeddings(e,t){return this.post(`/${e}/embeddings`,{payload:t})}migrateInteractions(e){return this.post(`/migrate-interactions`,{payload:e})}},Ne=class extends k{constructor(e){super(e,`/groups`)}list(e){return this.get(`/`,{query:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}listMembers(e){return this.get(`/${e}/members`)}addMember(e,t){return this.post(`/${e}/members/${t}`)}removeMember(e,t){return this.del(`/${e}/members/${t}`)}syncMembers(){return this.post(`/sync-members`)}},Pe=class extends k{constructor(e){super(e,`/api/v1/iam`)}aces=new Ie(this);roles=new Fe(this);groups=new Ne(this);getPrincipalIdentity(){return this.get(`/users/identity`)}},Fe=class extends k{constructor(e){super(e,`/roles`)}list(){return this.get(`/`)}listSystem(){return this.get(`/system`)}},Ie=class extends k{constructor(e){super(e,`/aces`)}list(e){return this.get(`/`,{query:{...e}})}listProjectAces(){return this.get(`/project`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};const Le=(()=>{let e=typeof process<`u`?process.env?.VERTESIA_INTERACTION_TIMEOUT_MS:void 0,t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>0?t:1800*1e3})();async function A(){return typeof globalThis.EventSource==`function`?globalThis.EventSource:(await import(`eventsource`)).EventSource}async function j(e,t,n={},r){let i=!!r,o=await e.runs.create({...n,interaction:t,stream:i},{timeoutMs:i?void 0:Le});if(i){if(o.status===a.failed)return o;await ze(e,o.id,r)}return o}async function Re(e,t,n={},r){let i=!!r,o=await e.post(`/api/v1/execute`,{payload:{...n,interaction:t,stream:i},timeoutMs:i?void 0:Le});if(i){if(o.status===a.failed)return o;await ze(e,o.id,r)}return o}function ze(e,t,n){return new Promise((r,i)=>{(async()=>{try{let a=await A(),o=new URL(`${e.runs.baseUrl}/${t}/stream`),s=e._auth?await e._auth():void 0;if(s){let e=s.split(` `)[1];o.searchParams.set(`access_token`,e)}else throw Error(`No auth token available`);let c=new a(o.href);c.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);t&&n?.(t)}catch(e){i(e)}}),c.addEventListener(`close`,e=>{try{c.close(),r(JSON.parse(e.data))}catch(e){i(e)}})}catch(e){i(e)}})()})}async function Be(e,t){return await e.post(`/api/v1/execute/async`,{payload:t})}async function Ve(e,t){return await e.post(`/api/v1/execute/rate-limit/request`,{payload:t})}var He=class extends k{constructor(e){super(e,`/api/v1/interactions/catalog`)}list(e={}){return this.get(`/`,{query:e})}listStoredInteractions(e={}){return this.get(`/stored`,{query:e})}listSysInteractions(e){return this.get(`/sys`,{query:{tag:e}})}listAppInteractions(e,t){return this.get(`/apps/${e}`,{query:{tag:t}})}listAllAppInteractions(e){return this.get(`/apps`,{query:{tag:e}})}resolve(e){return this.get(`/resolve/${e}`)}};const M=Symbol(`InteractionOutput`);function N(e){return e.result=F.from(e.result),e}function P(e){return e.result=F.from(e.result),e}var F=class{results;constructor(e){this.results=e}static from(e){return e?Ue(e)?e:I(Array.isArray(e)?e:typeof e==`object`?[{type:`json`,value:e}]:[{type:`text`,value:String(e)}]):I([])}static isInteractionOutputArray(e){return Ue(e)}get isEmpty(){return this.results.length===0}hasObject(){return this.results.some(e=>e.type===`json`)}hasText(){return this.results.some(e=>e.type===`text`)}hasImage(){return this.results.some(e=>e.type===`image`)}text(e=`
|
|
12
|
-
`){return this.results.filter(e=>e.type===`text`).map(e=>e.value).join(e)}texts(){return this.results.filter(e=>e.type===`text`).map(e=>e.value)}object(){let e=this.results.find(e=>e.type===`json`);return e?e.value:
|
|
13
|
-
`,t=2){return this.results.map(e=>{switch(e.type){case`json`:return JSON.stringify(e.value,null,t);default:return String(e.value)}}).join(e)}toString(){return this.text()}toJSON(){return this.results}};function Ue(e){return!!e&&typeof e==`object`&&e[M]===!0}function I(e){let t=new F(e);return new Proxy(e,{get(e,n,r){if(n===M)return!0;if(n in t){let e=Reflect.get(t,n,t);return typeof e==`function`?e.bind(t):e}return Reflect.get(e,n,r)}})}function We(e){let t;for(let n of e)if(n.type===`text`){let e=n.value.trim();try{return JSON.parse(e)}catch(e){t=e instanceof Error?e:Error(String(e))}}throw t||=Error(`No JSON result found and no text available to parse`),t}function Ge(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var Ke=class extends k{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new He(e)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}listEndpoints(e){return this.post(`/endpoints`,{payload:e})}listVersionsByName(e){return this.get(`/versions/${e}`)}listTags(e){return this.get(`/tags`,{query:{...e}})}computeFacets(e){return this.post(`/facets`,{payload:e})}listNames(){return this.get(`/names`)}export(e){return this.post(`/export`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e,t){let{cascade:n,query:r,...i}=t??{},a=n?{...r??{},cascade:`true`}:r??void 0;return super.delete(`/${e}`,{...i,query:a})}async execute(e,t={},n){return N(await j(this.client,e,t,n).catch(e=>{throw e instanceof y&&Ge(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n){return N(await Re(this.client,e,t,n).catch(e=>{throw e instanceof y&&Ge(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return Be(this.client,e)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}generateInteraction(e,t){return this.post(`${e}/generate-interaction`,{payload:t})}generateTestData(e,t){return this.post(`${e}/generate-test-data`,{payload:t})}suggestImprovements(e,t){return this.post(`${e}/suggest-prompt-improvements`,{payload:t})}suggestPromptImprovements(e){return this.post(`/improve`,{payload:e})}listVersions(e){return this.get(`/${e}/versions`)}listForks(e){return this.get(`/${e}/forks`)}requestSlot(e){return Ve(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},qe=class extends k{constructor(e){super(e,`/internal/secrets`)}rotateEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/rotate`,{payload:t})}deleteEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/delete`,{payload:t})}signEventWebhook(e,t){return this.post(`/event-webhooks/${e}/sign`,{payload:t})}rotateEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/rotate`,{payload:t})}deleteEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/delete`,{payload:t})}verifyEventIngestSignature(e,t){return this.post(`/event-ingest-channels/${e}/verify`,{payload:t})}mintGithubInstallationToken(e){return this.post(`/github/installation-token`,{payload:e})}},Je=class extends k{constructor(e){super(e,`/api/v1/oauth-clients`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}scopeMetadata(){return this.get(`/scope-metadata`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}};function Ye(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var Xe=class extends k{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:Ye(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},L=class extends k{constructor(e){super(e,`/api/v1/oauth-providers`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}authorize(e){return this.get(`/${e}/authorize`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}getStatus(e){return this.get(`/${e}/status`)}connect(e){return this.post(`/${e}/connect`,{payload:{}})}getToken(e){return this.post(`/${e}/token`,{payload:{}})}disconnect(e){return this.del(`/${e}/disconnect`)}},R=class extends O{parent;constructor(e,t){super(new URL(`/oauth`,`${t||e.baseUrl}/`).toString(),e._fetch),this.parent=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}get headers(){return this.parent.headers}createRequest(e,t){return this.parent.createRequest(e,t)}handleResponse(e,t,n){return this.parent.handleResponse(e,t,n)}handleFetchResponse(e,t){this.parent.handleFetchResponse(e,t)}getRetryPolicy(){return this.parent.getRetryPolicy()}createAuthorizationRequest(e){return this.post(`/requests`,{payload:e})}createDeviceAuthorization(e){return this.post(`/device_authorization`,{payload:e})}retrieveDeviceRequest(e){return this.get(`/device/${encodeURIComponent(e)}`)}retrieveRequest(e){return this.get(`/requests/${e}`)}retrieveGrantableScopes(e,t){return this.get(`/requests/${e}/grantable-scopes`,{query:{project_id:t}})}approveRequest(e,t){return this.post(`/requests/${e}/approve`,{payload:t})}denyRequest(e){return this.post(`/requests/${e}/deny`,{payload:{}})}},Ze=class extends k{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new Qe(this)}list(e){return this.get(`/`,{query:{account:e}})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}updateConfiguration(e,t){return this.put(`/${e}/configuration`,{payload:t})}getTools(e){return this.get(`/${e}/tools`)}getToolByName(e,t){return this.get(`/${e}/tools/${t}`).catch(e=>{if(e.status===404)return null;throw e})}listAppContentTypes(e,t){return this.get(`/${e}/app-types`,{query:{tag:t}})}getAppContentType(e,t){return this.get(`/${e}/app-types/${t}`)}listAppProcesses(e,t){return this.get(`/${e}/app-processes`,{query:{tag:t}})}getAppProcess(e,t){return this.get(`/${e}/app-processes/${t}`)}listAppRenderingTemplates(e,t){return this.get(`/${e}/app-templates`,{query:{tag:t}})}getAppRenderingTemplate(e,t){return this.get(`/${e}/app-templates/${t}`)}getCompositeAppConfiguration(e){return this.get(`/${e}/composite-app`)}updateCompositeAppConfiguration(e,t){return this.put(`/${e}/composite-app`,{payload:t})}},Qe=class extends k{constructor(e){super(e,`/`)}list(e){return this.get(`/${e}/integrations`).then(e=>e.integrations)}retrieve(e,t){return this.get(`/${e}/integrations/${t}`).catch(e=>{if(e.status!==404)throw e})}update(e,t,n){return this.put(`/${e}/integrations/${t}`,{payload:n})}updatePlugins(e,t){return this.post(`/${e}/plugins`,{payload:{plugins:t}})}listPlugins(e){return this.get(`/${e}/plugins`)}},$e=class extends k{constructor(e){super(e,`/api/v1/prompts`)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}computeFacets(e){return this.post(`/facets`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}render(e,t){return this.post(`/${e}/render`,{payload:t})}options(e){return this.get(`/options/${e}`)}listVersions(e){return this.get(`/${e}/versions`)}listInteractions(e){return this.get(`/${e}/interactions`)}listForks(e){return this.get(`/${e}/forks`)}},et=class extends k{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},tt=class extends k{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},z=class extends k{constructor(e){super(e,`/api/v1/remote-mcp-connections`)}getStatus(e){return this.get(`/status/${e}`)}getCollectionStatus(e,t){return this.get(`/status/${e}/${t}`)}getMetadata(e,t){return this.get(`/metadata/${e}/${t}`)}authorize(e,t){return this.get(`/authorize/${e}/${t}`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}connect(e,t){return this.post(`/connect/${e}/${t}`,{})}disconnect(e,t){return this.del(`/disconnect/${e}/${t}`)}getCollectionToken(e,t){return this.post(`/token`,{payload:{app_install_id:e,collection_id:t}})}getToken(e){return this.post(`/token`,{payload:{mcp_server_url:e}})}},nt=class extends k{constructor(e){super(e,`/api/v1/runs`)}list({limit:e,offset:t,filters:n}){let r={limit:e,offset:t,...n};return this.get(`/`,{query:r})}find(e){return this.post(`/find`,{payload:e})}async retrieve(e){return P(await this.get(`/${e}`))}retrievePopulated(e){return this.get(`/${e}`,{query:{populate:`true`}})}filterOptions(e,t){let n={...t};return this.get(`/filter-options/${e}`,{query:n})}async create(e,t){let n=this.client.sessionTags;if(n){let t=Array.isArray(n)?n:[n];Array.isArray(e.tags)?t=t.concat(e.tags):e.tags&&(t=t.concat([e.tags])),e={...e,tags:t}}return P(await this.post(`/`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal}))}sendToolResults(e,t){return this.post(`/tool-results`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal})}sendUserMessage(e,t){return this.post(`/user-message`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal})}computeFacets(e){return this.post(`/facets`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}clone(e){return this.post(`/clone`,{payload:e})}},B=class extends k{constructor(e){super(e,`/api/v1/secrets`)}list(e,t){return this.get(`/`,{query:{...t,project_id:e}}).then(e=>e.secrets)}retrieve(e,t,n){return this.get(`/${t}`,{query:{...n,project_id:e}}).catch(e=>{if(e.status!==404)throw e})}create(e,t){return this.post(`/`,{query:{project_id:e},payload:t})}update(e,t,n,r){return this.put(`/${t}`,{query:{...r,project_id:e},payload:n})}remove(e,t,n){return this.del(`/${t}`,{query:{...n,project_id:e}})}fillWebsiteCredential(e,t,n){return this.post(`/${t}/actions/fill-browser`,{query:{project_id:e},payload:n})}},rt=class extends k{constructor(e){super(e,`/api/v1/skills`)}findRelevant(e,t){let n={context:e,limit:t};return this.post(`/find-relevant`,{payload:n})}findRelevantForTask(e,t){return this.findRelevant({task_description:e,tool_names:t})}};const it=new Set([429,500,502,503,504]);function V(e){return new Promise(t=>setTimeout(t,e))}function at(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function H(e,t,n,r){let i=r?at(r):void 0;if(i!==void 0)return Math.min(n,i);let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const ot=new TextEncoder;function st(e){if(typeof e==`string`)return ot.encode(e);if(e instanceof Blob)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Unsupported signed-URL upload chunk of type "${typeof e}"; body streams must yield string or binary (Uint8Array/ArrayBuffer/DataView/Blob) chunks.`)}async function ct(e){if(e!=null){if(typeof ReadableStream<`u`&&e instanceof ReadableStream){let t=e.getReader(),n=[];try{for(;;){let{done:e,value:r}=await t.read();if(e)break;n.push(st(r))}}catch(e){throw await t.cancel(e).catch(()=>void 0),e}finally{t.releaseLock()}return new Blob(n)}return e}}async function U(e,t={}){let{method:n=`GET`,headers:r,attempts:i=4,baseDelayMs:a=500,maxDelayMs:o=8e3,retryableStatuses:s=it}=t,c=await ct(t.body),l;for(let t=0;t<i;t++){let u=t===i-1;try{let i=await fetch(e,{method:n,headers:r,body:c});if(i.ok||!s.has(i.status)||u)return i;await i.body?.cancel().catch(()=>void 0),await V(H(t,a,o,i))}catch(e){if(l=e,u)throw e;await V(H(t,a,o))}}throw l instanceof Error?l:Error(`Failed to fetch signed URL: ${e}`)}function lt(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function W(e,t){let n=lt(e);return!n||n===t}function G(e,t){return e.type===n.TERMINATED||e.type===n.COMPLETE&&(e.workstream_id??`main`)===`main`?W(e.details,t):!1}function ut(e,t){return e.t===n.TERMINATED||e.t===n.COMPLETE&&(e.w??`main`)===`main`?W(e.d,t):!1}var dt=class extends k{constructor(e){super(e,`/api/v1/agents`)}start(e){return this.post(`/`,{payload:e})}recordRun(e){return this.post(`/record`,{payload:e})}createRecord(e){return this.recordRun(e)}retrieve(e){return this.get(`/${e}`)}retrieveRun(e){return this.get(`/${e}`)}retrieveProcess(e){return this.get(`/${e}`)}list(e){return this.get(`/`,{query:this.buildListQueryParams(e)})}async listProcessRuns(e){return(await this.get(`/`,{query:this.buildListQueryParams({...e,run_kind:`process`})})).items.filter(ft)}buildListQueryParams(e){let t={};return e?.id&&(t.id=e.id),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.since&&(t.since=e.since.toISOString()),e?.until&&(t.until=e.until.toISOString()),e?.schedule_id&&(t.schedule_id=e.schedule_id),e?.type&&(t.type=e.type),e?.run_type&&(t.run_type=Array.isArray(e.run_type)?e.run_type.join(`,`):e.run_type),e?.run_kind&&(t.run_kind=e.run_kind),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.cursor&&(t.cursor=e.cursor),e?.sort&&(t.sort=e.sort),e?.order&&(t.order=e.order),t}search(e){let t={};return e?.query&&(t.query=e.query),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.categories?.length&&(t.categories=e.categories.join(`,`)),e?.tags?.length&&(t.tags=e.tags.join(`,`)),e?.content_type_name&&(t.content_type_name=e.content_type_name),e?.since&&(t.since=e.since.toISOString()),e?.until&&(t.until=e.until.toISOString()),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.sort?.length&&(t.sort=e.sort.join(`,`)),this.get(`/search`,{query:t})}terminate(e,t){let n=t?{reason:t}:void 0;return this.del(`/${e}`,{query:n})}restart(e){return this.post(`/${e}/restart`,{})}fork(e){return this.post(`/${e}/fork`,{})}getContext(e){return this.get(`/${e}/context`)}getHistory(e){return this.get(`/${e}/history`)}advance(e,t){return this.post(`/${e}/advance`,{payload:t??{}})}retryNode(e,t){return this.post(`/${e}/retry-node`,{payload:t??{}})}answerTask(e,t,n){return this.post(`/${e}/answer-task`,{payload:{task_id:t,result:n}})}updateStatus(e,t){return this.post(`/${e}/status`,{payload:t})}bindWorkflowRun(e,t){return this.post(`/${e}/workflow`,{payload:t})}sendSignal(e,t,n){return this.post(`/${e}/signal/${t}`,{payload:n})}query(e,t){return this.get(`/${e}/query/${t}`)}getActiveWorkstreams(e){return this.query(e,`ActiveWorkstreams`)}async retrieveMessages(e,t){let n=t?{since:t}:void 0;return(await this.get(`/${e}/updates`,{query:n})).messages.map(t=>m(f(t),e))}postMessage(e,t){return this.post(`/${e}/updates`,{payload:t})}async streamMessages(e,t,n,r,i){let a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=0,l=n||0,u=Date.now(),d=!1,p=null,h=null,g=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{g&&=(clearTimeout(g),null),h&&=(clearInterval(h),null),p&&=(p.close(),null),r&&_&&(r.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),a(e))},x=e=>typeof e==`string`&&[`completed`,`failed`,`cancelled`].includes(e),S=n=>{if(d)return;y(),console.warn(`Agent stream ${e}: SSE unavailable after 10 attempts; falling back to /updates polling.`,n instanceof Error?n.message:n);let r=async()=>{if(!d){try{let n=await this.retrieveMessages(e,l||void 0);for(let r of n){if(d)return;if(!((r.timestamp||0)<=l)){if(l=r.timestamp||l,t&&t(r,b),d)return;if(G(r,e)){b(null);return}}}}catch{}if(!d){try{let t=await this.get(`/${e}`);if(x(t?.status)){b(null);return}}catch{}d||(g=setTimeout(()=>{g=null,r()},5e3))}}};r()};if(r){if(r.aborted)return d=!0,y(),a(null),s;_=()=>{b(null)},r.addEventListener(`abort`,_,{once:!0})}try{if(!d){let r=await this.retrieveMessages(e,n);i?.onHistoryLoaded?.(r);let a=!1;for(let n=0;n<r.length;n++){let i=r[n];if(d||(l=Math.max(l,i.timestamp||0),t&&t(i,b),d))break;a=n===r.length-1&&G(i,e)}if(a)return b(null),s}}catch(e){d||(i?.onHistoryError?.(e),console.warn(`Failed to fetch historical messages, continuing with SSE:`,e))}!d&&l<=0&&(l=Math.max(1,u-1));let C=async(n=!1)=>{if(!d)try{let r=await A();if(d)return;let i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/stream`);l>0&&a.searchParams.set(`since`,l.toString()),a.searchParams.set(`skipHistory`,`true`);let s=i._auth?await i._auth():void 0;if(d)return;if(!s){d=!0,y(),o(Error(`No auth token available`));return}let u=s.split(` `)[1];if(a.searchParams.set(`access_token`,u),n&&console.log(`Reconnecting to agent stream ${e} (attempt ${c+1}/10)`),d)return;let _=new r(a.href);p=_,h=setInterval(()=>{},1e3);let x=0;_.onopen=()=>{n&&console.log(`Reconnected to agent stream ${e}`),x=Date.now()},_.onmessage=n=>{if(!d&&!(!n.data||n.data.startsWith(`:`)))try{let r=f(n.data);l=r.ts?Math.max(l,r.ts):Date.now(),t&&t(m(r,e),b),ut(r,e)&&b(null)}catch(e){console.error(`Failed to parse SSE message:`,e,n.data)}},_.onerror=e=>{if(!d)if(y(),(x?Date.now()-x:0)>5e3&&(c=0),c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||C(!0)},e)}else S(Error(`SSE connection failed after 10 reconnection attempts`))}}catch(e){if(d)return;if(c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||C(!0)},e)}else S(e)}};return C(!1),s}getInternals(e){return this.get(`/${e}/internals`)}getRunDetails(e,t){let n={};return t?.includeHistory&&(n.include_history=`true`),t?.hydratePayloads&&(n.hydrate_payloads=`true`),this.get(`/${e}/details`,{query:n})}async streamRunDetails(e,t,n){let r=await A(),i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/details/stream`),o=i._auth?await i._auth():void 0;if(!o)throw Error(`No auth token available`);let s=o.split(` `)[1];return a.searchParams.set(`access_token`,s),new Promise((e,i)=>{let o=new r(a.href),s=null,c=()=>{o.close(),n&&s&&(n.removeEventListener(`abort`,s),s=null)};if(n){if(n.aborted){c(),e();return}s=()=>{c(),e()},n.addEventListener(`abort`,s,{once:!0})}o.addEventListener(`history`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`history`,data:n})}catch{}}),o.addEventListener(`control`,n=>{try{let r=JSON.parse(n.data);t&&t({type:`control`,data:r}),`type`in r&&r.type===`done`&&(c(),e())}catch{}}),o.addEventListener(`error`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`error`,data:n})}catch{}}),o.onerror=e=>{c(),i(Error(`SSE connection failed for details stream`))}})}listChildren(e){return this.get(`/${e}/children`)}getChildDetails(e,t,n){let r={};return n?.includeHistory&&(r.include_history=`true`),n?.hydratePayloads&&(r.hydrate_payloads=`true`),this.get(`/${e}/children/${t}/details`,{query:r})}listArtifacts(e,t){let n=t?.visibility?{visibility:t.visibility}:void 0;return this.get(`/${e}/artifacts`,{query:n})}getArtifactUrl(e,t,n,r){let i={url:`1`};return n&&(i.disposition=n),r&&(i.filename=r),this.get(`/${e}/artifacts/${t}`,{query:i})}async uploadArtifact(e,t,n,r){let i=r||`application/octet-stream`,a=await this.put(`/${e}/artifacts/${t}`,{headers:{"Content-Type":i}}),o=await U(a.url,{method:`PUT`,body:n,headers:{"Content-Type":i}});if(!o.ok)throw Error(`Failed to upload artifact: ${o.statusText}`);return a}async downloadArtifact(e,t){let{url:n}=await this.getArtifactUrl(e,t,`attachment`),r=await U(n);if(!r.ok)throw Error(`Failed to download artifact: ${r.statusText}`);if(!r.body)throw Error(`No body in artifact download response`);return r.body}ingestEvents(e,t){let n={events:t};return this.post(`/${e}/events`,{payload:n})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}};function ft(e){return e.run_kind===`process`}var pt=class extends k{constructor(e){super(e,`/api/v1/collections`)}search(e){return this.post(`/search`,{payload:e})}computeListFacets(e){return this.post(`/facets`,{payload:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}addMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`add`,members:t}})}listMembers(e,t){return this.get(`/${e}/members`,{query:{...t}})}computeFacets(e,t){return this.post(`/${e}/facets`,{payload:t})}searchMembers(e,t){return this.post(`/${e}/search`,{payload:t})}deleteMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`delete`,members:t}})}addChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`add`,children:t}})}deleteChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`delete`,children:t}})}searchChildren(e,t={}){return this.post(`/${e}/children/search`,{payload:t})}delete(e){return this.del(`/${e}`)}updatePermissions(e,t){return this.put(`/${e}/permissions`,{payload:t})}propagatePermissions(e){return this.post(`/${e}/propagate-permissions`)}propagateSharedProperties(e){return this.post(`/${e}/propagate-shared-props`)}},mt=class extends k{constructor(e){super(e,`/api/v1/cost`)}getAnalytics(e={}){return this.post(`/analytics`,{payload:e})}getGlobalAnalytics(e={}){return this.post(`/analytics/global`,{payload:e})}getModelPrices(e={}){return this.get(`/model-prices`,{query:{...e}})}getRunPrice(e){return this.post(`/run-price`,{payload:e})}getRunPriceComparison(e){return this.post(`/run-price`,{payload:{...e,include_comparison_pricing:!0}})}getExportUrl(e){let t=new URLSearchParams;e?.from&&t.set(`from`,typeof e.from==`number`?new Date(e.from).toISOString():e.from),e?.to&&t.set(`to`,typeof e.to==`number`?new Date(e.to).toISOString():e.to),e?.scope&&t.set(`scope`,e.scope),e?.project_id&&t.set(`project_id`,e.project_id),e?.workflow_id&&t.set(`workflow_id`,e.workflow_id);let n=t.toString();return`${this.baseUrl}/export${n?`?${n}`:``}`}},ht=class extends k{storeId;constructor(e,t){super(e,`/api/v1/data/${t}/dashboards`),this.storeId=t}storeHeaders(){return{[i.DATA_STORE_ID]:this.storeId}}list(e){let t=e?`?status=${e}`:``;return this.get(`/${t}`,{headers:this.storeHeaders()})}create(e){return this.post(`/`,{payload:e,headers:this.storeHeaders()})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders()})}update(e,t){return this.put(`/${e}`,{payload:t,headers:this.storeHeaders()})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders()})}bulkArchive(e){return this.post(`/bulk/archive`,{payload:{ids:e},headers:this.storeHeaders()})}bulkDelete(e){return this.post(`/bulk/delete`,{payload:{ids:e},headers:this.storeHeaders()})}listVersions(e,t){let n=new URLSearchParams;t?.snapshotsOnly&&n.set(`snapshots_only`,`true`),t?.limit&&n.set(`limit`,String(t.limit));let r=n.toString()?`?${n}`:``;return this.get(`/${e}/versions${r}`,{headers:this.storeHeaders()})}getVersion(e,t){return this.get(`/${e}/versions/${t}`,{headers:this.storeHeaders()})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders()})}promoteVersion(e,t,n){return this.post(`/${e}/versions/${t}/promote`,{payload:n||{},headers:this.storeHeaders()})}setVersioningEnabled(e,t){return this.put(`/${e}/versioning`,{payload:{enabled:t},headers:this.storeHeaders()})}},gt=class extends k{constructor(e){super(e,`/api/v1/data`)}storeHeaders(e){return{[i.DATA_STORE_ID]:e}}list(){return this.get(`/`)}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders(e)})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders(e)})}getSchema(e,t){let n=t?`?format=${t}`:``;return this.get(`/${e}/schema${n}`,{headers:this.storeHeaders(e)})}updateSchema(e,t){return this.put(`/${e}/schema`,{payload:t,headers:this.storeHeaders(e)})}getSchemaHistory(e){return this.get(`/${e}/schema/history`,{headers:this.storeHeaders(e)})}listTables(e){return this.get(`/${e}/tables`,{headers:this.storeHeaders(e)})}createTables(e,t){return this.post(`/${e}/tables`,{payload:t,headers:this.storeHeaders(e)})}getTable(e,t,n){let r=n?`?sample=true`:``;return this.get(`/${e}/tables/${t}${r}`,{headers:this.storeHeaders(e)})}alterTable(e,t,n){return this.put(`/${e}/tables/${t}`,{payload:n,headers:this.storeHeaders(e)})}dropTable(e,t){return this.del(`/${e}/tables/${t}`,{headers:this.storeHeaders(e)})}importData(e,t){return this.post(`/${e}/import`,{payload:t,headers:this.storeHeaders(e)})}getImportStatus(e,t){return this.get(`/${e}/import/${t}`,{headers:this.storeHeaders(e)})}listVersions(e,t){let n=t?`?snapshots_only=true`:``;return this.get(`/${e}/versions${n}`,{headers:this.storeHeaders(e)})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders(e)})}rollback(e,t){return this.post(`/${e}/versions/${t}/rollback`,{headers:this.storeHeaders(e)})}queryVersion(e,t,n){return this.post(`/${e}/versions/${t}/query`,{payload:n,headers:this.storeHeaders(e)})}query(e,t){return this.post(`/${e}/query`,{payload:t,headers:this.storeHeaders(e)})}queryBatch(e,t){return this.post(`/${e}/query/batch`,{payload:{queries:t},headers:this.storeHeaders(e)})}mutateRows(e,t){return this.post(`/${e}/mutate`,{payload:t,headers:this.storeHeaders(e)})}validateQueries(e,t){return this.post(`/${e}/query/validate`,{payload:{queries:t},headers:this.storeHeaders(e)})}getDownloadInfo(e,t){let n=t?`?version_id=${t}`:``;return this.get(`/${e}/download${n}`,{headers:this.storeHeaders(e)})}dashboards(e){return new ht(this.client,e)}},_t=class extends k{constructor(e){super(e,`/api/v1/email`)}send(e){return this.post(`/send`,{payload:e})}resolveRoute(e){return this.post(`/resolve-route`,{payload:{route_key:e}})}createRoute(e){return this.post(`/routes`,{payload:e})}getRoute(e){return this.get(`/routes/${e}`)}updateRoute(e,t){return this.put(`/routes/${e}`,{payload:t})}forwardEmail(e,t){return this.post(`/routes/${e}/forward`,{payload:t})}},vt=class extends k{constructor(e,t=`/api/v1/embeddings`){super(e,t)}async status(e){return this.get(`${e}/status`)}async activate(e,t){if(!t.environment)throw Error(`Invalid configuration: select environment`);return this.post(`${e}/enable`,{payload:t})}async disable(e){return this.post(`${e}/disable`)}async recalculate(e){return this.post(`${e}/recalculate`)}};function yt(e){return JSON.parse(e)}function bt(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function xt(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function St(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function Ct(e){let t=e.event_types?.length?e.event_types:[`message`],n=e.max_reconnect_attempts??10,r=e.base_reconnect_delay_ms??1e3,i=e.max_reconnect_delay_ms??3e4,a=e.parse??yt,o=!1,s=0,c=null,l=null,u=null,d=0,f,p=t=>{e.on_status?.(t)},m=()=>{c&&=(c.close(),null),l&&=(clearTimeout(l),null)},h=()=>{o||(o=!0,m(),e.signal&&u&&(e.signal.removeEventListener(`abort`,u),u=null),p(`closed`))},g=t=>{if(o)return;if(m(),(d?Date.now()-d:0)>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let a=bt(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},a)},_=(t,n)=>{if(!(o||!n.data||String(n.data).startsWith(`:`)))try{let r=a(String(n.data),t),i=e.get_cursor?.(r);f=n.lastEventId||i||f,e.on_event({data:r,event_type:t,event_id:n.lastEventId||i})}catch(t){e.on_error?.(t)}},v=async n=>{if(!o)try{p(n?`reconnecting`:`connecting`);let r=await A();if(o)return;let i=await St(e.url);if(f&&e.last_event_id_query_param&&!i.searchParams.has(e.last_event_id_query_param)&&i.searchParams.set(e.last_event_id_query_param,f),xt(i,await e.get_access_token?.()),o)return;let a=new r(i.href);c=a,d=0,a.onopen=()=>{d=Date.now(),p(`open`)};for(let e of t)a.addEventListener(e,t=>_(e,t));a.onerror=e=>{g(e)}}catch(e){g(e)}};if(e.signal){if(e.signal.aborted)return o=!0,p(`closed`),{get closed(){return o},close:h};u=h,e.signal.addEventListener(`abort`,u,{once:!0})}return v(!1),{get closed(){return o},close:h}}function wt(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r);return Object.keys(t).length?t:void 0}var Tt=class extends k{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:wt(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};function Et(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r);return Object.keys(t).length?t:void 0}var Dt=class extends k{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:Et(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},Ot=class extends k{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new Dt(e),this.channels=new Tt(e)}searchDeliveries(e={}){return this.post(`/deliveries/search`,{payload:e})}queueSummary(e={}){return this.post(`/deliveries/queue-summary`,{payload:e})}subscribeDeliveries(e){let{signal:t,max_reconnect_attempts:n,on_snapshot:r,on_delivery:i,on_envelope:a,on_error:o,on_status:s,...c}=e;return Ct({url:()=>this.buildStreamUrl(c),event_types:[`snapshot`,`event`,`heartbeat`,`error`],signal:t,max_reconnect_attempts:n,last_event_id_query_param:`since_event_id`,get_access_token:async()=>{let e=this.client;return e._auth?await e._auth():void 0},get_cursor:e=>e.cursor,on_status:s,on_error:o,on_event:({data:e})=>{a?.(e),e.type===`snapshot`?r?.(e.deliveries,e):e.type===`event`?i?.(e.item,e):e.type===`error`&&o?.(Error(e.error))}})}buildStreamUrl(e){let t=new URL(`${this.baseUrl}/stream`);return this.setStreamParam(t,`limit`,e.limit),this.setStreamParam(t,`event_id`,e.event_id),this.setStreamParam(t,`resource_id`,e.resource_id),this.setStreamListParam(t,`resource_type`,e.resource_type),this.setStreamListParam(t,`event_category`,e.event_category),this.setStreamListParam(t,`action`,e.action),this.setStreamListParam(t,`outbox_status`,e.outbox_status),this.setStreamParam(t,`since_event_id`,e.since_event_id),this.setStreamParam(t,`since_created_at`,e.since_created_at),this.setStreamParam(t,`include_event`,e.include_event),this.setStreamParam(t,`poll_interval_ms`,e.poll_interval_ms),t}setStreamParam(e,t,n){n==null||n===``||e.searchParams.set(t,String(n))}setStreamListParam(e,t,n){n?.length&&e.searchParams.set(t,n.join(`,`))}},kt=class extends v{constructor(e,t){super(`Resource not found: ${t.message}`,e,404,t.payload)}},K=class{stream;name;type;id;constructor(e,t,n,r){this.stream=e,this.name=t,this.type=n,this.id=r}};const At=`memories`,q=`agents`,jt={attempts:3,methods:[`POST`],statuses:[502,503,504]};function J(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${At}/${t}`}function Y(e,t){return`${q}/${e}/${t}`}var Mt=class extends k{constructor(e){super(e,`/api/v1/files`)}async deleteFile(e,t){return this.del(`/${e}`,{query:{prefix:t}})}getMetadata(e){return this.get(`/metadata`,{query:{file:e}})}setFileMetadata(e,t){let n={file:e,metadata:t};return this.put(`/metadata`,{payload:n})}getOrCreateBucket(){return this.post(`/bucket`)}ensureBucketReadAccess(e){let t={principal:e};return this.post(`/bucket/read-access`,{payload:t})}getBucketReadAccessStatus(e){return this.get(`/bucket/read-access`,{query:{principal:e}})}list(e){return this.get(`/list`,{query:{prefix:e}})}getUploadUrl(e){return this.post(`/upload-url`,{payload:e,retryPolicy:jt})}getDownloadUrl(e,t,n){let r={file:e,name:t,disposition:n};return this.post(`/download-url`,{payload:r})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}bulkGetUploadUrls(e){return this.post(`/bulk-upload-urls`,{payload:e})}async bulkUpload(e,t=10){let n=e.map(e=>({name:e.name,mime_type:e.type,id:e instanceof K?e.id:void 0})),{files:r}=await this.bulkGetUploadUrls({files:n}),i=Array(e.length);for(let n=0;n<e.length;n+=t){let a=e.slice(n,n+t);await Promise.all(a.map(async(e,t)=>{let a=n+t,{url:o,id:s,mime_type:c}=r[a],l=e instanceof K,u=e.type||c,d=await U(o,{method:`PUT`,body:l?e.stream:e,headers:u?{"Content-Type":u}:void 0});if(!d.ok)throw Error(`Failed to upload file ${e.name}: ${d.statusText}`);let f=d.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);i[a]={source:s,name:e.name,type:u,etag:f}}))}return i}async uploadFile(e){return(await this.uploadFileWithPath(e)).id}async uploadFileWithPath(e){let t=e instanceof K,{url:n,id:r,path:i}=await this.getUploadUrl(e),a=await U(n,{method:`PUT`,body:t?e.stream:e,headers:{"Content-Type":e.type||`application/gzip`}}).catch(e=>{throw console.error(`Failed to upload file`,{err:e,url:n,id:r,path:i}),e});if(!a.ok)throw console.log(a),Error(`Failed to upload file: ${a.statusText}`);return{id:r,path:i}}async downloadFile(e){let{url:t}=e.startsWith(`https:`)?{url:e}:await this.getDownloadUrl(e),n=await U(t,{method:`GET`}).then(n=>{if(n.ok)return n;throw n.status===404?Error(`File at ${t} not found`):n.status===403?Error(`File at ${t} is forbidden`):(console.log(n),Error(`Failed to download file ${e}: ${n.statusText}`))}).catch(t=>{throw console.error(`Failed to download file ${e}.`,t),t});if(!n.body)throw Error(`No body in response while downloading file ${e}`);return n.body}async copyFile(e,t){return(await this.post(`/copy`,{payload:{source:e,dest:t}})).dest}async uploadMemoryPack(e){let t=J(e.name),n=e.name.endsWith(`.tar.gz`)?e.name:`${e.name}.tar.gz`;if(e instanceof File){let r=e;return this.uploadFile(new K(r.stream(),n,r.type,t))}else return this.uploadFile(new K(e.stream,n,e.type,t))}async downloadMemoryPack(e,t=!1){let n=await this.downloadFile(J(e));if(t){let e=new DecompressionStream(`gzip`);n=n.pipeThrough(e)}return n}listByPrefix(e){return this.get(`/list`,{query:{prefix:e}})}async uploadArtifact(e,t,n){let r=Y(e,t);if(n instanceof File){let e=n;return this.uploadFile(new K(e.stream(),t,e.type,r))}else return this.uploadFile(new K(n.stream,t,n.type,r))}async downloadArtifact(e,t){let n=Y(e,t);return this.downloadFile(n)}getArtifactDownloadUrl(e,t,n){let r=Y(e,t);return this.getDownloadUrl(r,t,n)}async listArtifacts(e){let t=`${q}/${e}/`;return(await this.listByPrefix(t)).files}},Nt=class extends k{constructor(e){super(e,`/api/v1/hive-memory`)}list(e){let t=new URLSearchParams;e?.category&&t.set(`category`,e.category),e?.scope&&t.set(`scope`,e.scope),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(n?`/?${n}`:`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}search(e){return this.post(`/search`,{payload:e})}recall(e,t){return this.post(`/recall`,{payload:{task_description:e,tools:t?.tools,category:t?.category,max_results:t?.maxResults}})}getFormatted(e){return this.get(`/${e}/formatted`)}recordUsage(e){return this.post(`/${e}/usage`,{})}getByCategory(e,t){let n=new URLSearchParams;t?.limit&&n.set(`limit`,String(t.limit)),t?.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return this.get(`/category/${e}${r?`?${r}`:``}`)}getStats(){return this.get(`/stats`)}applyDecay(e){return this.post(`/admin/decay`,{payload:{days_threshold:e?.daysThreshold,decay_rate:e?.decayRate}})}archiveLowConfidence(e){return this.post(`/admin/archive`,{payload:{threshold:e}})}},Pt=class extends k{constructor(e,t=`/api/v1/indexing`){super(e,t)}async status(){return this.get(`/status`)}async reindex(e){return this.post(`/reindex`,{payload:e})}async reindexAgentRuns(e){return this.post(`/agent-runs/reindex`,{payload:e})}async analyzeDrift(){return this.post(`/analyze-drift`,{payload:{}})}async getDriftAnalysis(){return this.get(`/drift-analysis`)}async enableIndexing(){return this.post(`/enable-indexing`)}async disableIndexing(){return this.post(`/disable-indexing`)}async enableQueries(){return this.post(`/enable-queries`)}async disableQueries(){return this.post(`/disable-queries`)}index(e,t){return this.post(`/internal/index`,{payload:{object_id:e,document:t}})}delete(e){return this.post(`/internal/delete`,{payload:{object_id:e}})}bulkIndex(e,t){return this.post(`/internal/bulk-index`,{payload:{documents:e,target_index:t}})}ensureIndex(e){return this.post(`/internal/ensure-index`,{payload:{recreate:e}})}createReindexTarget(){return this.post(`/internal/create-reindex-target`,{payload:{}})}getStats(){return this.post(`/internal/stats`,{payload:{}})}fetchBatch(e,t){return this.post(`/internal/fetch-batch`,{payload:{cursor:e,limit:t}})}getNextIndexCursor(e,t,n){return this.post(`/internal/next-cursor`,{payload:{cursor:e,limit:t,count:n}})}analyzeDriftBatch(e,t){return this.post(`/internal/analyze-drift-batch`,{payload:{cursor:e,limit:t}})}triggerReindex(e){return this.post(`/internal/trigger-reindex`,{payload:e?{full_reindex:e.fullReindex,object_ids:e.objectIds,recreate_index:e.recreateIndex}:{}})}fetchDocumentsByIds(e){return this.post(`/internal/fetch-by-ids`,{payload:{object_ids:e}})}bulkDelete(e){return this.post(`/internal/bulk-delete`,{payload:{object_ids:e}})}getConfiguration(){return this.post(`/internal/configuration`,{payload:{}})}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t})}computeShards(e,t,n,r){return this.zenoBulkPost(`/reindex/compute-shards`,{tenant_id:e,shard_size:t??25e4,updated_since:n,backend:r})}indexShard(e){return this.zenoBulkPost(`/reindex/shard`,{params:e})}swapAlias(e,t,n,r){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r})}async reindexViaBulk(e,t,n,r,i,a){let o=`${this.zenoBulkBaseUrl}/reindex`,s={tenant_id:e,project_id:i,dry_run:n??!1,backend:r,shard_size:a?.shardSize,shards:a?.shards,bulk_concurrency:a?.bulkConcurrency,bulk_size_bytes:a?.bulkSizeBytes,bulk_max_docs:a?.bulkMaxDocs};if(!t)return this.client.post(o,{payload:{params:s}});let c;if(await this.client.sseRequest(`POST`,o,{payload:{params:s}},e=>{if(t(e),e.type===`event`&&e.event===`done`)try{c=JSON.parse(e.data)}catch{}}),!c)throw Error(`zeno-bulk SSE stream ended without a done event`);return c}},Ft=class extends k{objectId;constructor(e,t){super(e,`/${t}/analyze`),this.objectId=t}async start(e){return this.post(`/`,{payload:e})}async getStatus(){return this.get(`/status`)}async getResults(){return this.get(`/results`)}async adaptTables(e){return this.post(`/adapt_tables`,{payload:e})}async getAdaptedTables(e,t){let n=e?`/adapt_tables/${e}`:`/adapt_tables`,r={};t?.format&&(r.format=t.format),t?.raw!==void 0&&(r.raw=t.raw);let i={query:r};return t?.format===`csv`&&(i.responseType=`text`),this.get(n,i)}async getXml(){return this.get(`/xml`)}async getTables(e){let t={};return e&&(t.query={format:e}),this.get(`/tables`,t)}async getImages(){return this.get(`/images`)}async getAnnotated(){return this.get(`/annotated`)}},It=class extends k{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new Ft(this,e)}getUploadUrl(e){return this.post(`/upload-url`,{payload:e})}getDownloadUrl(e,t,n){return this.post(`/download-url`,{payload:{file:e,name:t,disposition:n}})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}getContentSource(e){return this.get(`/${e}/content-source`)}list(e={}){let t=e.limit||100,n=e.offset||0,r=e.query||{};return this.get(`/`,{query:{limit:t,offset:n,select:e.select,...r,all_revisions:e.all_revisions,from_root:e.from_root||void 0}})}computeFacets(e){return this.post(`/facets`,{payload:e})}startExport(e={}){return this.post(`/export/bulk`,{payload:e})}listExports(){return this.get(`/export/bulk/artifacts`)}deleteExport(e){return this.del(`/export/bulk/artifacts/${encodeURIComponent(e)}`)}getExportStatus(e,t){return this.get(`/export/bulk/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}getExportDownloadUrl(e,t){return this.get(`/export/bulk/artifacts/${encodeURIComponent(e)}/${t}/download-url`)}async downloadExportFile(e,t){let{url:n}=await this.getExportDownloadUrl(e,t),r=await U(n,{method:`GET`}).then(e=>{if(!e.ok)throw Error(`Failed to download export file: ${e.status} ${e.statusText}`);return e});if(!r.body)throw Error(`No response body received when downloading export file`);return r.body}exportToBucketViaBulk(e,t=!1){return this.zenoBulkPost(`/export`,e,t)}planContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/plan`,e,t)}exportContentObjectShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard`,e,t)}splitContentObjectExportShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard/split`,e,t)}composeContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/compose`,e,t)}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t,n){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t,timeoutMs:n})}listFolders(e=`/`){throw Error(`Not implemented yet`)}find(e){return this.post(`/find`,{payload:e})}count(e){return this.post(`/count`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}retrieve(e,t){return this.get(`/${e}`,{query:{select:t}})}getObjectText(e){return this.get(`/${e}/text`)}async upload(e){let t=e instanceof K,{url:n,id:r,mime_type:i}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:e.type}),a=e.type||i,o=await U(n,{method:`PUT`,body:t?e.stream:e,headers:a?{"Content-Type":a}:void 0}).catch(e=>{throw console.error(`Failed to upload file`,e),e});if(!o.ok)throw console.error(`Failed to upload file`,{status:o.status,statusText:o.statusText,url:n}),Error(`Failed to upload file: ${o.statusText}`);let s=o.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);return{source:r,name:e.name,type:a,etag:s}}async create(e,t){let{content:n,...i}=e,a={...i};n instanceof K||n instanceof File?a.content=await this.upload(n):a.content=n;let o={};return t?.processing_priority&&(o[r.PROCESSING_PRIORITY]=t.processing_priority),t?.collection_id&&(o[r.COLLECTION_ID]=t.collection_id),await this.post(`/`,{payload:a,headers:o})}async createFromExternalSource(e,t={},n){let i=await this.client.files.getMetadata(e),a={...t,content:{source:e,name:i.name,type:i.contentType,etag:i.etag}},o={};return n?.processing_priority&&(o[r.PROCESSING_PRIORITY]=n.processing_priority),n?.collection_id&&(o[r.COLLECTION_ID]=n.collection_id),await this.post(`/`,{payload:a,headers:o})}async update(e,t,n){let{content:i,...a}=t,o={...a};i instanceof K||i instanceof File?o.content=await this.upload(i):o.content=i;let s={};return n?.ifMatch&&(s[`if-match`]=n.ifMatch),n?.processing_priority&&(s[r.PROCESSING_PRIORITY]=n.processing_priority),n?.createRevision&&(s[r.CREATE_REVISION]=`true`,n.revisionLabel&&(s[r.REVISION_LABEL]=n.revisionLabel)),n?.suppressWorkflows&&(s[r.SUPPRESS_WORKFLOWS]=`true`),this.put(`/${e}`,{payload:o,headers:s})}getRevisions(e){return this.get(`/${e}/revisions`)}getCollections(e){return this.get(`/${e}/collections`)}delete(e){return Array.isArray(e)?this.client.runOperation({name:`delete`,ids:e,params:{}}):this.del(`/${e}`)}bulkUpdate(e){let t=Object.keys(e);return this.client.runOperation({name:`update`,ids:t,params:e})}bulkCreate(e,t){return this.client.runOperation({name:`create`,ids:[],params:{objects:e,...t}})}listWorkflowRuns(e){return this.get(`/${e}/workflow-runs`)}listRenditions(e){return this.get(`/${e}/renditions`)}getRendition(e,t){let n={max_hw:t.max_hw,generate_if_missing:t.generate_if_missing,sign_url:t.sign_url,block_on_generation:t.block_on_generation};return this.get(`/${e}/renditions/${t.format}`,{query:n})}getRenditionSafe(e,t,n){return c(t,n.format)?this.getRendition(e,n):Promise.resolve(null)}exportProperties(e){return this.post(`/export`,{payload:e})}setEmbedding(e,t,n){return this.put(`/${e}/embeddings/${t}`,{payload:n})}},Lt=class extends k{constructor(e){super(e,`/api/v1/pending-asks`)}register(e){return this.post(`/`,{payload:e})}resolve(e,t){return this.post(`/${e}/resolve`,{payload:t})}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}},Rt=class extends k{constructor(e){super(e,`/api/v1/processes`)}list(e){let t={};return e?.status&&(t.status=e.status),e?.process&&(t.process=e.process),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),e?.allVersions&&(t.all_versions=`true`),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}listVersions(e){return this.get(`/${e}/versions`)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}revert(e,t){return this.post(`/${e}/revert`,{payload:t})}delete(e){return this.del(`/${e}`)}},zt=class extends k{constructor(e,t=`/api/v1/query`){super(e,t)}async execute(e){return this.post(`/`,{payload:e})}async sql(e){return this.execute({sql:e})}async esql(e){return this.execute({esql:e})}async dsl(e){return this.execute({dsl:e})}},Bt=class extends k{constructor(e){super(e,`/api/v1/rendering`)}start(e){return this.post(`/jobs`,{payload:e})}getStatus(e,t){return this.get(`/jobs/status`,{query:{workflow_id:e,workflow_run_id:t}})}async render(e,t={}){let n=t.pollIntervalMs??1500,r=t.timeoutMs??600*1e3,i=await this.start(e);if(!i.workflow_id||!i.workflow_run_id)throw Error(`Failed to start rendering workflow`);let a=Date.now();for(;;){let t=await this.getStatus(i.workflow_id,i.workflow_run_id);if(t.status===s.COMPLETED){if(!t.download_url&&!t.file_uri)throw Error(t.error||`Rendering completed but no output file was produced`);return{status:`success`,format:e.format,download_url:t.download_url,file_uri:t.file_uri}}if(d(t.status)){let e=s[t.status]||String(t.status);throw Error(t.error||`Rendering failed with status: ${e}`)}if(Date.now()-a>=r)throw Error(`Rendering timed out after ${r}ms`);await Vt(n)}}};function Vt(e){return new Promise(t=>setTimeout(t,e))}var Ht=class extends k{constructor(e){super(e,`/api/v1/schedules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}trigger(e){return this.post(`/${e}/trigger`,{})}pause(e,t){return this.post(`/${e}/pause`,{payload:{note:t}})}resume(e,t){return this.post(`/${e}/resume`,{payload:{note:t}})}},Ut=class extends k{constructor(e){super(e,`/api/v1/tasks`)}list(e){let t={};return e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.assignee&&(t.assignee=e.assignee),e?.run_id&&(t.run_id=e.run_id),e?.source_type&&(t.source_type=e.source_type),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}complete(e,t){return this.post(`/${e}/complete`,{payload:t})}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},X=class extends k{constructor(e){super(e,`/api/v1/types/catalog`)}list(e={}){return this.get(`/`,{query:e})}listSysTypes(e){return this.get(`/sys`,{query:{tag:e}})}listAppTypes(e){return this.get(`/apps`,{query:{tag:e}})}listStoredTypes(e={}){return this.get(`/stored`,{query:e})}resolve(e){let t=typeof e==`string`?e:e.id;return this.get(`/resolve/${t}`)}},Wt=class extends k{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new X(e)}list(e={},t){let n=e.limit||2e3,r=e.offset||0,i=e.query||{};return this.get(`/`,{query:{limit:n,offset:r,layout:!!t?.layout,schema:!!t?.schema,...i}})}find(e){return this.post(`/find`,{payload:e})}retrieve(e){return this.get(`/${e}`)}getTypeByName(e){return this.get(`/name/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}};const Gt=`20260319`,Z=`x-api-version`;var Kt=class extends k{constructor(e){super(e,`/api/v1/workflows`)}getActivityCatalog(){return this.get(`/activity-catalog`)}listRuns(e,t,n){return this.post(`/runs`,{payload:{documentId:e,eventName:t,ruleId:n}})}listConversations(e){return this.post(`/conversations`,{payload:e})}searchRuns(e){return this.post(`/runs`,{payload:e})}sendSignal(e,t,n,r){return this.post(`/runs/${e}/${t}/signal/${n}`,{payload:r})}getRunDetails(e,t,n){let r={};return n?.includeHistory!==void 0&&(r.include_history=n.includeHistory),n?.historyFormat!==void 0&&(r.history_format=n.historyFormat),n?.hydratePayloads!==void 0&&(r.hydrate_payloads=n.hydratePayloads),this.get(`/runs/${t}/${e}`,{query:r})}getRunInteraction(e,t){return this.get(`/runs/${e}/${t}/interaction`)}terminate(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/terminate`,{payload:r})}cancel(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/cancel`,{payload:r})}query(e,t,n){return this.get(`/runs/${e}/${t}/query/${n}`)}execute(e,t={}){return this.post(`/execute/${e}`,{payload:t})}postMessage(e,t){if(!e)throw Error(`runId is required`);return this.post(`/runs/${e}/updates`,{payload:t})}async retrieveMessages(e,t,n){let r={since:n};return(await this.get(`/runs/${e}/${t}/updates`,{query:r})).messages.map(e=>m(f(e),t))}async streamMessages(e,t,r,i,a){return new Promise((o,s)=>{let c=0,l=i||0,u=Date.now(),d=!1,p=null,h=null,g=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{g&&=(clearTimeout(g),null),h&&=(clearInterval(h),null),p&&=(p.close(),null),a&&_&&(a.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),o(e))};if(a){if(a.aborted){b(null);return}_=()=>b(null),a.addEventListener(`abort`,_,{once:!0})}let x=async(i=!1)=>{if(!d)try{let a=await A(),u=this.client,_=new URL(`${u.workflows.baseUrl}/runs/${e}/${t}/stream`);l>0&&_.searchParams.set(`since`,l.toString()),_.searchParams.set(`skipHistory`,`true`);let S=u._auth?await u._auth():void 0;if(d)return;if(!S){d=!0,y(),s(Error(`No auth token available`));return}let C=S.split(` `)[1];_.searchParams.set(`access_token`,C),i&&console.log(`Reconnecting to SSE stream for run ${t} (attempt ${c+1}/10)`);let w=new a(_.href);p=w,h=setInterval(()=>{},1e3),w.onopen=()=>{i&&console.log(`Successfully reconnected to SSE stream for run ${t}`),c=0},w.onmessage=e=>{if(!e.data||e.data.startsWith(`:`)){console.log(`Received comment or heartbeat; ignoring it.: `,e.data);return}try{let i=f(e.data);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(m(i,t),b),ut(i,t)?(console.log(`Closing stream due to COMPLETE message from main workstream`),d||(d=!0,y(),o(null))):i.t===n.COMPLETE&&console.log(`Received COMPLETE message that does not close the root stream for run ${t}`)}catch(t){console.error(`Failed to parse SSE message:`,t,e.data)}},w.onerror=e=>{if(!d)if(console.warn(`SSE stream error for run ${t}:`,e),y(),c<10){let e=v(c);console.log(`Attempting to reconnect in ${e}ms (attempt ${c+1}/10)`),c++,g=setTimeout(()=>{g=null,d||x(!0)},e)}else console.error(`Failed to reconnect to SSE stream for run ${t} after 10 attempts`),d=!0,s(Error(`SSE connection failed after 10 reconnection attempts`))}}catch(e){if(console.error(`Error setting up SSE stream:`,e),c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||x(!0)},e)}else s(e)}};(async()=>{try{let n=await this.retrieveMessages(e,t,i),a=!1;for(let e=0;e<n.length;e++){let i=n[e];l=Math.max(l,i.timestamp||0),r&&r(i,b),a=e===n.length-1&&G(i,t)}if(a){b(null);return}}catch(e){console.warn(`Failed to fetch historical messages, continuing with SSE:`,e)}!d&&l<=0&&(l=Math.max(1,u-1)),x(!1)})().catch(s)})}async streamMessagesWS(e,t,r,i){return new Promise((a,o)=>{let s=0,c=null,l=i||0,u=!1,d=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},p=async()=>{if(!u)try{let i=this.client,m=new URL(`${i.workflows.baseUrl}/runs/${e}/${t}/ws`);m.protocol=m.protocol.replace(`http`,`ws`),l>0&&m.searchParams.set(`since`,l.toString());let h=i._auth?await i._auth():void 0;if(!h){o(Error(`No auth token available`));return}let g=h.split(` `)[1];m.searchParams.set(`access_token`,g),s>0&&console.log(`Reconnecting to WebSocket for run ${t} (attempt ${s+1}/10)`),c=new WebSocket(m.href),c.onopen=()=>{s>0&&console.log(`Successfully reconnected to WebSocket for run ${t}`),s=0,u||a({cleanup:()=>{u=!0,c&&=(c.close(),null)},sendSignal:(e,t)=>{if(c?.readyState===WebSocket.OPEN){let n={type:`signal`,signalName:e,data:t,requestId:Date.now()};c.send(JSON.stringify(n))}else console.warn(`WebSocket not open, cannot send signal`)}})},c.onmessage=e=>{try{let t=JSON.parse(e.data);if(`type`in t&&typeof t.type==`string`){if(t.type===`pong`){console.debug(`Received pong`);return}else if(t.type===`ack`){console.debug(`Signal acknowledged`,t);return}else if(t.type===`error`){console.error(`WebSocket error message`,t);return}}let i=f(t);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(i);let a=i.w||`main`;(i.t===n.TERMINATED||i.t===n.COMPLETE&&a===`main`)&&(console.log(`Closing WebSocket due to workflow completion`),u=!0,c&&=(c.close(),null))}catch(e){console.error(`Failed to parse WebSocket message`,e)}},c.onerror=e=>{console.error(`WebSocket error`,e)},c.onclose=()=>{if(!u&&s<10){let e=d(s);console.log(`WebSocket closed, reconnecting in ${e}ms (attempt ${s+1}/10)`),s++,setTimeout(p,e)}else s>=10&&o(Error(`WebSocket connection failed after 10 attempts`))}}catch(e){if(console.error(`Error setting up WebSocket`,e),s<10){let e=d(s);s++,setTimeout(p,e)}else o(e)}};p()})}ingestEvents(e,t,n){return this.post(`/runs/${e}/${t}/events`,{payload:{events:n}})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}rules=new qt(this);definitions=new Jt(this)},qt=class extends k{constructor(e){super(e,`/rules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}execute(e,t,n){let r={objectIds:t,vars:n};return this.post(`/${e}/execute`,{payload:r})}},Jt=class extends k{constructor(e){super(e,`/definitions`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}};function Yt(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var Xt=class extends we{constructor(e={}){super(Yt(e.serverUrl),e.fetch),e.apikey&&this.withApiKey(e.apikey),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.errorFactory=e=>e.status===404?new kt(e.request,e):e}withApiVersion(e){return e?this.headers[Z]=String(e):delete this.headers[Z],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withApiKey(e){return this.withAuthCallback(e?()=>Promise.resolve(`Bearer ${e}`):void 0)}runOperation(e){return this.post(`/api/v1/operations`,{payload:e})}get initialHeaders(){return{...super.initialHeaders,[Z]:Gt}}agents=new dt(this);cost=new mt(this);objects=new It(this);types=new Wt(this);workflows=new Kt(this);schedules=new Ht(this);processes=new Rt(this);tasks=new Ut(this);files=new Mt(this);collections=new pt(this);embeddings=new vt(this);email=new _t(this);events=new Ot(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new Lt(this);data=new gt(this);indexing=new Pt(this);query=new zt(this);hiveMemory=new Nt(this);rendering=new Bt(this)},Zt=class extends k{constructor(e){super(e,`/api/v1/tools`)}list(e){let t={};return e?.sources?.length&&(t.sources=e.sources.join(`,`)),e?.exclude?.length&&(t.exclude=e.exclude.join(`,`)),this.get(`/`,{query:Object.keys(t).length>0?t:void 0})}listBuiltins(){return this.list({sources:[`builtin`]})}validate(e){return this.post(`/validate`,{payload:{names:e}})}},Qt=class extends k{constructor(e){super(e,`/api/v1/training`)}listSessions(e={}){return this.get(`/`,{query:{...e}})}listSessionNames(e={}){return this.get(`/names`,{query:{...e}})}createSession(e){return this.post(`/`,{payload:e})}getSession(e){return this.get(`/${e}`)}addToSession(e,t){return this.post(`/${e}/add`,{payload:{runs:t}})}listSessionRuns(e,t=100,n=0){return this.get(`/${e}/runs`,{query:{limit:t,offset:n}})}buildSession(e){return this.post(`/${e}/build`)}getDataUrl(e){return this.get(`/${e}/url`)}getDataUploadUrl(e,t=!1){return this.get(`/${e}/upload-url`,t?{query:{resumable:`true`}}:{})}startTraining(e){return this.post(`/${e}/start`)}cancelTraining(e){return this.post(`/${e}/cancel`)}getTrainingJob(e){return this.get(`/job/${e}`)}getAndSyncTrainingJob(e){return this.get(`/job/${e}`,{query:{sync:`true`}})}setDataset(e,t=`default`){return this.post(`/${e}/dataset`,{payload:{dataset:t}})}},$t=class extends k{constructor(e){super(e,`/api/v1/users`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},Q=class e extends we{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;secrets;internalSecrets;static async fromAuthToken(t,n,r){n||=$(t);let i=r||on(n.endpoints);return await new e({serverUrl:i.studio,storeUrl:i.store,tokenServerUrl:i.token||n.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(e={site:`api.vertesia.io`}){let t,n;if(e.serverUrl)t=e.serverUrl;else if(e.site)t=`https://${e.site}`;else throw Error(`Parameter 'site' or 'serverUrl' is required for VertesiaClient`);if(e.storeUrl)n=e.storeUrl;else if(e.site)n=`https://${e.site}`;else throw Error(`Parameter 'site' or 'storeUrl' is required for VertesiaClient`);if(super(t,e.fetch),e.tokenServerUrl)this.tokenServerUrl=e.tokenServerUrl;else if(e.site){let t=e.site.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else if(e.serverUrl||e.storeUrl){let t=e.serverUrl||e.storeUrl||``;try{let e=new URL(t);if(e.hostname.startsWith(`api`)){let t=e.hostname.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`}catch{this.tokenServerUrl=`https://sts.dev1.vertesia.io`}}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`;this.store=new Xt({serverUrl:n,tokenServerUrl:this.tokenServerUrl,apikey:e.apikey,onRequest:e.onRequest,onResponse:e.onResponse,retryPolicy:e.retryPolicy,timeout:e.timeout,fetch:e.fetch}),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),e.apikey&&this.withApiKey(e.apikey),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.sessionTags=e.sessionTags,this.oauthClients=new Je(this),this.oauthGrants=new Xe(this),this.oauthServer=new R(this,this.tokenServerUrl),this.oauthProviders=new L(this),this.remoteMcpConnections=new z(this),this.secrets=new B(this),this.internalSecrets=new qe(this)}withApiVersion(e){return e?this.headers[Z]=String(e):delete this.headers[Z],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withAuthCallback(e){return this.store.withAuthCallback(e),super.withAuthCallback(e)}withRetryPolicy(e){return this.store.withRetryPolicy(e),super.withRetryPolicy(e)}withTimeout(e){return this.store.withTimeout(e),super.withTimeout(e)}async withApiKey(e){return this.withAuthCallback(e?async()=>{if(!en(e))return`Bearer ${e}`;if(tn(this._jwt)){let t=await this.getAuthToken(e);this._jwt=t.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){let e=await this._auth();this._jwt||=e.trim().split(` `)[1]}return this._jwt||null}async getDecodedJWT(){let e=await this.getRawJWT();return e?$(e):null}async getProject(){return(await this.getDecodedJWT())?.project||null}async getAccount(){return(await this.getDecodedJWT())?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get processes(){return this.store.processes}get tasks(){return this.store.tasks}get types(){return this.store.types}get data(){return this.store.data}get events(){return this.store.events}get storeUrl(){return this.store.baseUrl}async getAuthToken(e){return this.post(`${this.tokenServerUrl}/token/issue`,{headers:{"content-type":`application/json`,authorization:`Bearer ${e}`},retryPolicy:{attempts:4,methods:[`POST`],statuses:[429,500,502,503,504]}}).catch(e=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:e}),e})}get initialHeaders(){return{...super.initialHeaders,[Z]:Gt}}projects=new Ze(this);environments=new Me(this);interactions=new Ke(this);skills=new rt(this);prompts=new $e(this);runs=new nt(this);account=new Te(this);accounts=new Ee(this);apikeys=new Oe(this);analytics=new De(this);auditTrail=new Ae(this);training=new Qt(this);users=new $t(this);iam=new Pe(this);refs=new tt(this);commands=new je(this);apps=new ke(this);tools=new Zt(this);quota=new et(this)};function en(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function tn(e){if(!e)return!0;let t=$(e).exp;return Date.now()>=t*1e3-6e4}function $(e){let t=e.split(`.`)[1],n=an(t);return JSON.parse(n)}function nn(){return globalThis.Buffer}function rn(){return globalThis.process?.env?.STS_URL}function an(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=nn();if(n)return n.from(t,`base64`).toString(`utf-8`);if(typeof atob<`u`&&typeof TextDecoder<`u`){let e=atob(t),n=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(n)}else throw Error(`No base64 decoder available`)}function on(e){return e?typeof e==`string`?sn(e):e:sn(`api.vertesia.io`)}function sn(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:rn()??`https://sts.dev1.vertesia.io`,git:`https://git.dev1.vertesia.io`};{let t=`https://${e}`;return{studio:t,store:t,token:t.replace(`api`,`sts`),git:t.replace(`api`,`git`)}}}var cn=class{id;client;constructor(e,t){this.id=e,t instanceof Q?this.client=t:this.client=new Q(t)}retrieve(){return this.client.interactions.retrieve(this.id)}update(e){return this.client.interactions.update(this.id,e)}render(e){throw Error(`Not implemented`)}async execute(e={},t){return j(this.client,this.id,e,t)}};export{e as APP_VERSION_HEADER,q as ARTIFACTS_PREFIX,dt as AgentsApi,gt as DataApi,_t as EmailApi,vt as EmbeddingsApi,Tt as EventIngestChannelsApi,Dt as EventSubscriptionsApi,Ot as EventsApi,Mt as FilesApi,Nt as HiveMemoryApi,M as IS_INTERACTION_OUTPUT,Pt as IndexingApi,cn as InteractionBase,F as InteractionOutput,qe as InternalSecretsApi,At as MEMORIES_PREFIX,Je as OAuthClientsApi,Xe as OAuthGrantsApi,L as OAuthProvidersApi,R as OAuthServerApi,It as ObjectsApi,Lt as PendingAsksApi,o as Permission,Rt as ProcessApi,zt as QueryApi,z as RemoteMcpConnectionsApi,Bt as RenderingApi,Ht as SchedulesApi,B as SecretsApi,K as StreamSource,Ut as TaskApi,X as TypeCatalogApi,Wt as TypesApi,Q as VertesiaClient,Kt as WorkflowsApi,Jt as WorkflowsDefinitionApi,qt as WorkflowsRulesApi,Xt as ZenoClient,kt as ZenoClientNotFoundError,c as canGenerateRendition,I as createInteractionOutput,on as decodeEndpoints,$ as decodeJWT,P as enhanceExecutionRun,N as enhanceInteractionExecutionResult,U as fetchSignedUrl,Y as getAgentArtifactPath,J as getMemoryFilePath,l as getOAuthPermissionScopes,u as getSupportedRenditionFormats,tn as isTokenExpired,Ct as openManagedEventSource,p as supportsVisualRendition};
|
|
10
|
+
${i}`,d++;return}if(T(e,t,r)){f=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,n);l=r.includes(`\0`)?void 0:r;return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
|
|
11
|
+
${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new x(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new x(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function w(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function T(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var ee=class extends TransformStream{constructor(){let e;super({start(t){e=C({onEvent(e){let n={type:`event`,...e};t.enqueue(n)}})},transform(t){e.feed(t)}})}};let E;if(globalThis.TextDecoderStream&&typeof globalThis.TextDecoderStream==`function`)E=globalThis.TextDecoderStream;else{class e extends TransformStream{_options;constructor(e=`utf-8`,{fatal:n=!1,ignoreBOM:r=!1}={}){super(new t(new TextDecoder(e,{fatal:n,ignoreBOM:r}))),this._options={fatal:n,ignoreBOM:r,encoding:e}}get encoding(){return this._options.encoding}get fatal(){return this._options.fatal}get ignoreBOM(){return this._options.ignoreBOM}}class t{decoder;constructor(e){this.decoder=e}transform(e,t){if(!(e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw TypeError(`Input must be a compatible with: ArrayBuffer | Uint8Array`);let n=this.decoder.decode(e,{stream:!0});n.length!==0&&t.enqueue(n)}flush(e){let t=this.decoder.decode();t.length!==0&&e.enqueue(t)}}E=e}async function te(e){if(!e.ok){let t=await e.text(),n=Error(`SSE error: ${e.status}. Content:\n${t}`);throw n.status=e.status,n}if(!e.body)throw Error(`No body in response`);return e.body.pipeThrough(new E).pipeThrough(new ee)}function ne(e){let t=[];for(let n of Object.keys(e)){let r=e[n];r!=null&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`)}return t.join(`&`)}function re(e,t){return e.endsWith(`/`)?t.startsWith(`/`)?e+t.substring(1):e+t:t.startsWith(`/`)?e+t:`${e}/${t}`}function D(e){return e[e.length-1]===`/`?e.slice(0,-1):e}function ie(e){if(e!==!1&&e!==null&&e?.enabled!==!1)return{maxWaitMs:Math.max(0,e?.maxWaitMs??3e3),attempts:Math.max(0,Math.floor(e?.attempts??2))}}const ae=[`GET`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`],oe=[502,503,504];function O(e){return typeof e==`object`&&!!e}function se(e){return e?Promise.resolve(e):typeof globalThis.fetch==`function`?Promise.resolve(globalThis.fetch):Promise.resolve(()=>{throw Error(`No Fetch implementation found`)})}function ce(e){return O(e)&&e.error===`Not a valid JSON payload`&&typeof e.text==`string`}function le(e){return!e||typeof ReadableStream>`u`||!(e instanceof ReadableStream)}function ue(e){return e.status<500?!1:!(e.headers.get(`content-type`)??``).toLowerCase().includes(`json`)}function de(e){let t=Math.max(1,Math.floor(e.attempts??3)),n=Math.max(0,e.baseDelayMs??250),r=Math.max(n,e.maxDelayMs??4e3);return{attempts:t,methods:new Set((e.methods??ae).map(e=>e.toUpperCase())),statuses:new Set(e.statuses??oe),retryNonJsonServerErrors:e.retryNonJsonServerErrors??!0,retryOnConnectionError:e.retryOnConnectionError??!0,baseDelayMs:n,maxDelayMs:r,jitter:e.jitter??!0}}function fe(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function pe(e,t){if(e.status!==429||e.headers.get(`x-ratelimit-reason`)!==`pacing`)return;let n=e.headers.get(`x-ratelimit-retry-ms`),r=n?Number(n):NaN,i=Number.isFinite(r)&&r>=0?r:fe(e);if(!(i===void 0||i>t.maxWaitMs))return i}function me(e){return new Promise(t=>setTimeout(t,e))}function he(e,t,n){let r=(n?fe(n):void 0)??Math.min(e.maxDelayMs,e.baseDelayMs*2**t);return e.jitter?Math.floor(Math.random()*r):r}function ge(e){return e instanceof Error?e:Error(String(e))}function _e(e){return typeof e==`object`&&!!e&&`name`in e&&(e.name===`TimeoutError`||e.name===`AbortError`)}function ve(e){let t=AbortSignal.timeout;if(typeof t==`function`)return t(e);let n=new AbortController;return setTimeout(()=>n.abort(new DOMException(`The operation timed out`,`TimeoutError`)),e),n.signal}function ye(e){let t=e.filter(e=>!!e);if(t.length===0)return;if(t.length===1)return t[0];let n=AbortSignal.any;if(typeof n==`function`)return n(t);let r=new AbortController;for(let e of t){if(e.aborted){r.abort(e.reason);break}e.addEventListener(`abort`,()=>r.abort(e.reason),{once:!0})}return r.signal}async function be(e){try{await e.body?.cancel()}catch{}}var k=class{_fetch;baseUrl;errorFactory=e=>e;verboseErrors=!0;retryPolicy;pacingRetry;defaultTimeoutMs;constructor(e,t){this.baseUrl=D(e),this._fetch=se(t)}throwError(e){throw this.errorFactory(e)}withPacingRetry(e){return this.pacingRetry=e===null?void 0:e,this}withRetryPolicy(e){return this.retryPolicy=e||void 0,this}getRetryPolicy(){return this.retryPolicy}withTimeout(e){return this.defaultTimeoutMs=typeof e==`number`&&e>0?e:void 0,this}getTimeout(){return this.defaultTimeoutMs}resolveTimeout(e){if(e?.reader===`sse`)return;let t=e?.timeoutMs;if(t===!1||t===null)return;if(typeof t==`number`)return t>0?t:void 0;let n=this.getTimeout();return n&&n>0?n:void 0}getUrl(e){return e.startsWith(`http://`)||e.startsWith(`https://`)?D(e):D(re(this.baseUrl,e))}get(e,t){return this.request(`GET`,e,t)}del(e,t){return this.request(`DELETE`,e,t)}delete(e,t){return this.request(`DELETE`,e,t)}post(e,t){return this.request(`POST`,e,t)}put(e,t){return this.request(`PUT`,e,t)}jsonParse(e){return JSON.parse(e)}createRequest(e,t){return Promise.resolve(new Request(e,t))}handleFetchResponse(e,t){}createServerError(e,t,n){let r=`Server Error: ${t.status}`;return n&&(ce(n)?(r+=t.statusText?` ${t.statusText}`:``,r+=`: non-JSON response`):O(n)&&n.message?r=String(n.message):O(n)&&n.error&&(typeof n.error==`string`?r=String(n.error):O(n.error)&&typeof n.error.message==`string`&&(r=n.error.message))),new y(r,e,t.status,n,this.verboseErrors)}async readJSONPayload(e){return e.text().then(t=>{if(t)try{return this.jsonParse(t)}catch(n){return{status:e.status,error:`Not a valid JSON payload`,message:n instanceof Error?n.message:String(n),text:t}}else return}).catch(t=>{if(_e(t))throw t;return{status:e.status,error:`Unable to load response content`,message:t instanceof Error?t.message:String(t)}})}handleResponse(e,t,n){return n?.reader?n.reader===`sse`?te(t):n.reader.call(this,t):this.readJSONPayload(t).then(n=>{if(t.ok)return n;this.throwError(this.createServerError(e,t,n))})}async request(e,t,n){let r=this.getUrl(t);n?.query&&(r+=`?${ne(n.query)}`);let i=this.headers?Object.assign({},this.headers):{},a=n?.headers;if(a)for(let e in a)i[e.toLowerCase()]=a[e];let o,s=n?.payload;s&&(n&&n.jsonPayload===!1?o=s:(o=typeof s==`string`?s:JSON.stringify(s),`content-type`in i||(i[`content-type`]=`application/json`))),n?.reader===`sse`&&(i.accept=`text/event-stream`);let c=e.toUpperCase(),l=this.resolveTimeout(n),u=()=>{let e=ye([n?.signal,l?ve(l):void 0]),t={method:c,headers:Object.assign({},i),body:o};return e&&(t.signal=e),t},d=this.resolveRetryPolicy(n),f=n?.reader===`sse`?void 0:ie(n?.pacingRetry??this.pacingRetry),p=await this._fetch,m=le(o),h=0,g=0,_;for(;;){let e=await this.createRequest(r,u());_=e;let t;try{t=await p(e)}catch(t){(!d||!this.shouldRetryConnectionError(d,c,h,m))&&(console.error(`Failed to connect to ${r}`,t),this.throwError(new b(e,ge(t)))),await this.waitBeforeRetry(d,h),h++;continue}if(this.handleFetchResponse(e,t),f&&g<f.attempts&&m){let e=pe(t,f);if(e!==void 0){await be(t),await me(e),g++;continue}}if(d&&this.shouldRetryResponse(d,c,h,m,t)){await be(t),await this.waitBeforeRetry(d,h,t),h++;continue}if(d&&h>=d.attempts)break;return this.handleResponse(e,t,n)}throw _&&this.throwError(new b(_,Error(`Retry attempts exhausted for ${c} ${r}`))),Error(`Retry attempts exhausted for ${c} ${r}`)}resolveRetryPolicy(e){if(e?.reader===`sse`||e?.retryPolicy===!1||e?.retryPolicy===null)return;let t=e?.retryPolicy,n=this.getRetryPolicy();if(!t&&!n)return;let r=de({...n,...t});return r.attempts>1?r:void 0}shouldRetryResponse(e,t,n,r,i){let a=e.statuses.has(i.status)||e.retryNonJsonServerErrors&&ue(i);return n<e.attempts-1&&r&&e.methods.has(t)&&a}shouldRetryConnectionError(e,t,n,r){return n<e.attempts-1&&r&&e.retryOnConnectionError&&e.methods.has(t)}waitBeforeRetry(e,t,n){let r=he(e,t,n);return new Promise(e=>setTimeout(e,r))}async sseRequest(e,t,n,r){let i=(await this.request(e,t,{...n,reader:`sse`})).getReader(),a;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;a=t,r(t)}}finally{i.releaseLock()}return a}fetch(e,t){return this._fetch.then(n=>n(e,t))}};function xe(e){return e?`authorization`in e:!1}function Se(){let e=globalThis;return e.window===void 0&&(typeof e.process?.versions?.node==`string`||typeof e.process?.versions?.bun==`string`||e.Bun!==void 0)}var A=class extends k{headers;_auth;onRequest;onResponse;response;constructor(e,t){super(e,t),this.baseUrl=e[e.length-1]===`/`?e.substring(0,e.length-1):e,this.headers=this.initialHeaders}get initialHeaders(){let e={accept:`application/json`};return Se()&&(e[`accept-encoding`]=`br, gzip, deflate`),e}withAuthCallback(e){return this._auth=e||void 0,this}withErrorFactory(e){return this.errorFactory=e,this}withLang(e){return e?this.headers[`accept-language`]=e:delete this.headers[`accept-language`],this}withHeaders(e){let t=this.headers;for(let n in e){let r=e[n];r!=null&&(t[n.toLowerCase()]=r)}return this}setHeader(e,t){t?this.headers[e.toLowerCase()]=t:delete this.headers[e.toLowerCase()]}async createRequest(e,t){if(this._auth&&!xe(t.headers)){t.headers=t.headers?t.headers:{};let e=await this._auth();e&&(t.headers.authorization=e)}this.response=void 0;let n=await super.createRequest(e,t);return this.onRequest?.(n),n}handleFetchResponse(e,t){this.response=t,this.onResponse?.(t,e)}},j=class extends k{client;constructor(e,t){super(e.getUrl(t),e._fetch),this.client=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}createRequest(e,t){return this.client.createRequest(e,t)}handleResponse(e,t,n){return this.client.handleResponse(e,t,n)}handleFetchResponse(e,t){this.client.handleFetchResponse(e,t)}getRetryPolicy(){return this.client.getRetryPolicy()}getTimeout(){return this.client.getTimeout()}get headers(){return this.client.headers}},Ce=class extends j{constructor(e){super(e,`/api/v1/account`)}info(){return this.get(`/`)}update(e){return this.put(`/`,{payload:e})}projects(){return this.get(`/projects`).then(e=>e.data)}members(){return this.get(`/members`)}inviteUser(e){return this.post(`/invites`,{payload:e})}listInvites(){return this.get(`/invites`)}listInvitation(e=`project`){return this.get(`/invites/${e}`)}acceptInvite(e){return this.put(`/invites/${e}`)}rejectInvite(e){return this.del(`/invites/${e}`)}onboardingProgress(){return this.get(`/onboarding`)}getStripeBillingStatus(){return this.get(`/stripe-billing-status`)}},we=class extends j{constructor(e){super(e,`/api/v1/accounts`)}create(e){return this.post(`/`,{payload:{name:e}})}list(){return this.get(`/`)}},Te=class extends j{constructor(e){super(e,`/api/v1/analytics`)}runsSummary(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/summary${r?`?${r}`:``}`)}runsTimeSeries(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/time-series${r?`?${r}`:``}`)}runsTokenUsage(e,t){let n=new URLSearchParams;e?.start&&n.set(`start`,e.start),e?.end&&n.set(`end`,e.end),t&&n.set(`environment`,t);let r=n.toString();return this.get(`/runs/token-usage${r?`?${r}`:``}`)}},Ee=class extends j{constructor(e){super(e,`/api/v1/apikeys`)}list(e=`account`){return this.get(`/`,{query:{level:e}})}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}retrieve(e,t=!1){return t?this.get(`/${e}`,{query:{withValue:!0}}):this.get(`/${e}`)}delete(e){return this.del(`/${e}`)}getToken(e){return this.get(`/${e}/token`)}requestPublicKey(e={}){return this.get(`/pk`,{query:e})}},De=class extends j{constructor(e){super(e,`/api/v1/apps`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}previewDelete(e){return this.del(`/${e}`)}deleteApp(e){return this.del(`/${e}`,{query:{confirm:`true`}})}listVersions(e){return this.get(`/versions`,{query:{...e?.app_id&&{app_id:e.app_id},...e?.kind&&{kind:e.kind},...e?.include_expired!==void 0&&{include_expired:e.include_expired},...e?.limit!==void 0&&{limit:e.limit}}})}upsertVersion(e){return this.post(`/versions`,{payload:e})}getVersion(e){return this.get(`/versions/${e}`)}promoteVersion(e){return this.post(`/versions/${e}/promote`)}rebuildVersion(e){return this.post(`/versions/${e}/rebuild`)}deleteVersion(e){return this.del(`/versions/${e}`)}startBuild(e,t){return this.post(`/${encodeURIComponent(e)}/builds`,{payload:t})}getBuildProgress(e,t,n){return this.get(`/${encodeURIComponent(e)}/builds/${encodeURIComponent(t)}/${encodeURIComponent(n)}/progress`)}startScaffold(e){return this.post(`/scaffolds`,{payload:e})}getScaffoldProgress(e,t){return this.get(`/scaffolds/${encodeURIComponent(e)}/${encodeURIComponent(t)}/progress`)}listAppInstallationTools(e){return this.get(`/installations/${e}/tools`)}inspect(e){return this.get(`/${e}/inspect`)}getRepoTree(e,t){return this.get(`/${encodeURIComponent(e)}/repo/tree`,{query:{prefix:t?.prefix,ref:t?.ref}})}async getRepoFile(e,t,n){let r=`/${encodeURIComponent(e)}/repo/file`,i=await this.get(r,{query:{path:t,ref:n?.ref},reader:e=>e});if(!i.ok){let e=await this.readJSONPayload(i),t=await this.createRequest(i.url||this.getUrl(r),{method:`GET`});throw this.createServerError(t,i,e)}return i}commitRepoDocuments(e,t,n){let r=new FormData,i={ref:n.ref,expected_head:n.expectedHead,message:n.message||`Upload documentation`,files:t.map((e,t)=>({field:`file_${t}`,path:e.path}))};return r.append(`metadata`,JSON.stringify(i)),t.forEach((e,t)=>{r.append(`file_${t}`,e.content,e.fileName||e.path.split(`/`).pop()||`document`)}),this.post(`/${encodeURIComponent(e)}/repo/documents`,{payload:r,jsonPayload:!1,timeoutMs:12e4})}getRepoCommits(e,t,n){return this.get(`/${encodeURIComponent(e)}/repo/commits`,{query:{path:t,ref:n?.ref,limit:n?.limit,cursor:n?.cursor}})}getRepoRefs(e){return this.get(`/${encodeURIComponent(e)}/repo/refs`)}listDevelopmentTasks(e){return this.get(`/${encodeURIComponent(e)}/development-tasks`)}getDevelopmentTask(e,t){return this.get(`/${encodeURIComponent(e)}/development-tasks/${encodeURIComponent(t)}`)}createRepoBranch(e,t){return this.post(`/${encodeURIComponent(e)}/repo/branches`,{payload:t})}getAppPackage(e,t=`all`){return this.get(`/${encodeURIComponent(e)}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getAppInstallationPackage(e,t=`all`){return this.get(`/installations/${e}/package`,{query:{scope:Array.isArray(t)?t.join(`,`):t}})}getSystemToolsPackage(e=`tools`){return this.get(`/studio-tools/package`,{query:{scope:e}})}list(){return this.get(`/`)}install(e,t,n,r){return this.post(`/install`,{payload:{app_id:e,settings:t,oauth_params:n,oauth_provider_params:r}})}uninstall(e){return this.del(`/install/${e}`)}getAppInstallationByName(e){return this.get(`/installations/name/${e}`).catch(e=>{if(e.status===404)return null;throw e})}getAppInstallationProjects(e){if(!e.id&&!e.name)throw Error(`Invalid arguments: appId or appName must be specified`);let t=e.id?{id:e.id}:{name:e.name};return this.get(`/installations/projects`,{query:t})}getInstalledApps(e){return this.get(`/installations`,{query:{kind:e}})}getAllAppInstallations(){return this.get(`/installations/all`)}listInstallations(){return this.get(`/installations/refs`)}updateInstallationSettings(e){return this.put(`/installations/settings/${e.app_id}`,{payload:{app_id:e.app_id,settings:e.settings,...`access_control`in e?{access_control:e.access_control}:{}}})}updateToolAllowlist(e,t){return this.put(`/installations/${e}/tool-allowlist`,{payload:{tool_allowlist:t}})}validateUrl(e){return this.post(`/validate-url`,{payload:{url:e}})}},Oe=class extends j{constructor(e){super(e,`/api/v1/audit-trail`)}list(e){let t=new URLSearchParams;e?.actions?.length&&t.set(`actions`,e.actions.join(`,`)),e?.resourceTypes?.length&&t.set(`resourceTypes`,e.resourceTypes.join(`,`)),e?.resourceId&&t.set(`resourceId`,e.resourceId),e?.principalId&&t.set(`principalId`,e.principalId),e?.principalType&&t.set(`principalType`,e.principalType),e?.effectivePrincipalId&&t.set(`effectivePrincipalId`,e.effectivePrincipalId),e?.hasEffectivePrincipal!==void 0&&t.set(`hasEffectivePrincipal`,String(e.hasEffectivePrincipal)),e?.projectId&&t.set(`projectId`,e.projectId),e?.from&&t.set(`from`,e.from),e?.to&&t.set(`to`,e.to),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(`/${n?`?${n}`:``}`)}aggregate(e){return this.post(`/aggregate`,{payload:e})}},ke=class extends j{constructor(e){super(e,`/api/v1/commands`)}async isNamespaceAvailable(e){return this.get(`/namespaces/${e}/is_available`).then(e=>e.available)}async initSamples(){return this.post(`/onboarding/init-samples`)}},Ae=class extends j{constructor(e){super(e,`/api/v1/environments`)}list(e=!1){let t=e?{all:!0}:void 0;return this.get(`/`,{query:t})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}updateConfig(e,t){return this.put(`/${e}/config`,{payload:t})}listModels(e,t){return this.get(`/${e}/models`,{query:t?{...t}:void 0})}enableModel(e,t){return this.post(`/${e}/models/enabled`,{payload:t})}disableModel(e,t){return this.del(`/${e}/models/enabled/${encodeURIComponent(t)}`)}listTrainableModels(e){return this.get(`/${e}/trainable-models`)}embeddings(e,t){return this.post(`/${e}/embeddings`,{payload:t})}migrateInteractions(e){return this.post(`/migrate-interactions`,{payload:e})}},je=class extends j{constructor(e){super(e,`/groups`)}list(e){return this.get(`/`,{query:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}listMembers(e){return this.get(`/${e}/members`)}addMember(e,t){return this.post(`/${e}/members/${t}`)}removeMember(e,t){return this.del(`/${e}/members/${t}`)}syncMembers(){return this.post(`/sync-members`)}},Me=class extends j{constructor(e){super(e,`/api/v1/iam`)}aces=new Pe(this);roles=new Ne(this);groups=new je(this);getPrincipalIdentity(){return this.get(`/users/identity`)}},Ne=class extends j{constructor(e){super(e,`/roles`)}list(){return this.get(`/`)}listSystem(){return this.get(`/system`)}},Pe=class extends j{constructor(e){super(e,`/aces`)}list(e){return this.get(`/`,{query:{...e}})}listProjectAces(){return this.get(`/project`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};const M=(()=>{let e=typeof process<`u`?process.env?.VERTESIA_INTERACTION_TIMEOUT_MS:void 0,t=e?Number.parseInt(e,10):NaN;return Number.isFinite(t)&&t>0?t:1800*1e3})();async function N(){return typeof globalThis.EventSource==`function`?globalThis.EventSource:(await import(`eventsource`)).EventSource}async function P(e,t,n={},r){let i=!!r,o=await e.runs.create({...n,interaction:t,stream:i},{timeoutMs:i?void 0:M});if(i){if(o.status===a.failed)return o;await F(e,o.id,r)}return o}async function Fe(e,t,n={},r){let i=!!r,o=await e.post(`/api/v1/execute`,{payload:{...n,interaction:t,stream:i},timeoutMs:i?void 0:M});if(i){if(o.status===a.failed)return o;await F(e,o.id,r)}return o}function F(e,t,n){return new Promise((r,i)=>{(async()=>{try{let a=await N(),o=new URL(`${e.runs.baseUrl}/${t}/stream`),s=e._auth?await e._auth():void 0;if(s){let e=s.split(` `)[1];o.searchParams.set(`access_token`,e)}else throw Error(`No auth token available`);let c=new a(o.href);c.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);t&&n?.(t)}catch(e){i(e)}}),c.addEventListener(`close`,e=>{try{c.close(),r(JSON.parse(e.data))}catch(e){i(e)}})}catch(e){i(e)}})()})}async function Ie(e,t){return await e.post(`/api/v1/execute/async`,{payload:t})}async function Le(e,t){return await e.post(`/api/v1/execute/rate-limit/request`,{payload:t})}var Re=class extends j{constructor(e){super(e,`/api/v1/interactions/catalog`)}list(e={}){return this.get(`/`,{query:e})}listStoredInteractions(e={}){return this.get(`/stored`,{query:e})}listSysInteractions(e){return this.get(`/sys`,{query:{tag:e}})}listAppInteractions(e,t){return this.get(`/apps/${e}`,{query:{tag:t}})}listAllAppInteractions(e){return this.get(`/apps`,{query:{tag:e}})}resolve(e){return this.get(`/resolve/${e}`)}};const I=Symbol(`InteractionOutput`);function L(e){return e.result=z.from(e.result),e}function R(e){return e.result=z.from(e.result),e}var z=class{results;constructor(e){this.results=e}static from(e){return e?B(e)?e:V(Array.isArray(e)?e:typeof e==`object`?[{type:`json`,value:e}]:[{type:`text`,value:String(e)}]):V([])}static isInteractionOutputArray(e){return B(e)}get isEmpty(){return this.results.length===0}hasObject(){return this.results.some(e=>e.type===`json`)}hasText(){return this.results.some(e=>e.type===`text`)}hasImage(){return this.results.some(e=>e.type===`image`)}text(e=`
|
|
12
|
+
`){return this.results.filter(e=>e.type===`text`).map(e=>e.value).join(e)}texts(){return this.results.filter(e=>e.type===`text`).map(e=>e.value)}object(){let e=this.results.find(e=>e.type===`json`);return e?e.value:ze(this.results)}objects(){return this.results.filter(e=>e.type===`json`).map(e=>e.value)}objectAt(e){let t=0;for(let n of this.results)if(n.type===`json`){if(t===e)return n.value;t++}throw Error(`Object at index ${e} not found`)}image(){let e=this.results.find(e=>e.type===`image`);if(!e)throw Error(`No image result found`);return e.value}images(){return this.results.filter(e=>e.type===`image`).map(e=>e.value)}stringify(e=`
|
|
13
|
+
`,t=2){return this.results.map(e=>{switch(e.type){case`json`:return JSON.stringify(e.value,null,t);default:return String(e.value)}}).join(e)}toString(){return this.text()}toJSON(){return this.results}};function B(e){return!!e&&typeof e==`object`&&e[I]===!0}function V(e){let t=new z(e);return new Proxy(e,{get(e,n,r){if(n===I)return!0;if(n in t){let e=Reflect.get(t,n,t);return typeof e==`function`?e.bind(t):e}return Reflect.get(e,n,r)}})}function ze(e){let t;for(let n of e)if(n.type===`text`){let e=n.value.trim();try{return JSON.parse(e)}catch(e){t=e instanceof Error?e:Error(String(e))}}throw t||=Error(`No JSON result found and no text available to parse`),t}function Be(e){return!!e&&typeof e==`object`&&`id`in e&&typeof e.id==`string`}var Ve=class extends j{catalog;constructor(e){super(e,`/api/v1/interactions`),this.catalog=new Re(e)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}listEndpoints(e){return this.post(`/endpoints`,{payload:e})}listVersionsByName(e){return this.get(`/versions/${e}`)}listTags(e){return this.get(`/tags`,{query:{...e}})}computeFacets(e){return this.post(`/facets`,{payload:e})}listNames(){return this.get(`/names`)}export(e){return this.post(`/export`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e,t){let{cascade:n,query:r,...i}=t??{},a=n?{...r??{},cascade:`true`}:r??void 0;return super.delete(`/${e}`,{...i,query:a})}async execute(e,t={},n){return L(await P(this.client,e,t,n).catch(e=>{throw e instanceof y&&Be(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}async executeByName(e,t={},n){return L(await Fe(this.client,e,t,n).catch(e=>{throw e instanceof y&&Be(e.payload)?e.updateDetails({run_id:e.payload.id}):e}))}executeAsync(e){return Ie(this.client,e)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}generateInteraction(e,t){return this.post(`${e}/generate-interaction`,{payload:t})}generateTestData(e,t){return this.post(`${e}/generate-test-data`,{payload:t})}suggestImprovements(e,t){return this.post(`${e}/suggest-prompt-improvements`,{payload:t})}suggestPromptImprovements(e){return this.post(`/improve`,{payload:e})}listVersions(e){return this.get(`/${e}/versions`)}listForks(e){return this.get(`/${e}/forks`)}requestSlot(e){return Le(this.client,e)}resolve(e,t){return this.get(`/resolve/${encodeURIComponent(e)}`,{query:t})}},He=class extends j{constructor(e){super(e,`/internal/secrets`)}rotateEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/rotate`,{payload:t})}deleteEventWebhookSigningSecret(e,t){return this.post(`/event-webhooks/${e}/delete`,{payload:t})}signEventWebhook(e,t){return this.post(`/event-webhooks/${e}/sign`,{payload:t})}rotateEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/rotate`,{payload:t})}deleteEventIngestChannelSigningSecret(e,t){return this.post(`/event-ingest-channels/${e}/delete`,{payload:t})}verifyEventIngestSignature(e,t){return this.post(`/event-ingest-channels/${e}/verify`,{payload:t})}mintGithubInstallationToken(e){return this.post(`/github/installation-token`,{payload:e})}},Ue=class extends j{constructor(e){super(e,`/api/v1/oauth-clients`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}scopeMetadata(){return this.get(`/scope-metadata`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}};function We(e){if(e)return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)]))}var Ge=class extends j{constructor(e){super(e,`/api/v1/oauth-grants`)}list(e){return this.get(`/`,{query:We(e)})}retrieve(e){return this.get(`/${e}`)}revoke(e,t){return this.del(`/${e}`,{query:t})}revokeBulk(e){return this.post(`/revoke`,{payload:e})}},Ke=class extends j{constructor(e){super(e,`/api/v1/oauth-providers`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}remove(e){return this.del(`/${e}`)}authorize(e){return this.get(`/${e}/authorize`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}getStatus(e){return this.get(`/${e}/status`)}connect(e){return this.post(`/${e}/connect`,{payload:{}})}getToken(e){return this.post(`/${e}/token`,{payload:{}})}disconnect(e){return this.del(`/${e}/disconnect`)}},qe=class extends k{parent;constructor(e,t){super(new URL(`/oauth`,`${t||e.baseUrl}/`).toString(),e._fetch),this.parent=e,this.createServerError=e.createServerError,this.errorFactory=e.errorFactory,this.verboseErrors=e.verboseErrors}get headers(){return this.parent.headers}createRequest(e,t){return this.parent.createRequest(e,t)}handleResponse(e,t,n){return this.parent.handleResponse(e,t,n)}handleFetchResponse(e,t){this.parent.handleFetchResponse(e,t)}getRetryPolicy(){return this.parent.getRetryPolicy()}createAuthorizationRequest(e){return this.post(`/requests`,{payload:e})}createDeviceAuthorization(e){return this.post(`/device_authorization`,{payload:e})}retrieveDeviceRequest(e){return this.get(`/device/${encodeURIComponent(e)}`)}retrieveRequest(e){return this.get(`/requests/${e}`)}retrieveGrantableScopes(e,t){return this.get(`/requests/${e}/grantable-scopes`,{query:{project_id:t}})}approveRequest(e,t){return this.post(`/requests/${e}/approve`,{payload:t})}denyRequest(e){return this.post(`/requests/${e}/deny`,{payload:{}})}},Je=class extends j{integrations;constructor(e){super(e,`/api/v1/projects`),this.integrations=new Ye(this)}list(e){return this.get(`/`,{query:{account:e}})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}updateConfiguration(e,t){return this.put(`/${e}/configuration`,{payload:t})}getTools(e){return this.get(`/${e}/tools`)}getToolByName(e,t){return this.get(`/${e}/tools/${t}`).catch(e=>{if(e.status===404)return null;throw e})}listAppContentTypes(e,t){return this.get(`/${encodeURIComponent(e)}/app-types`,{query:{tag:t}})}getAppContentType(e,t){return this.get(`/${encodeURIComponent(e)}/app-types/${encodeURIComponent(t)}`)}listAppProcesses(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes`,{query:{tag:t}})}getAppProcess(e,t){return this.get(`/${encodeURIComponent(e)}/app-processes/${encodeURIComponent(t)}`)}listAppViews(e,t){return this.get(`/${encodeURIComponent(e)}/app-views`,{query:{tag:t}})}getAppView(e,t){return this.get(`/${encodeURIComponent(e)}/app-views/${encodeURIComponent(t)}`)}listAppRenderingTemplates(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates`,{query:{tag:t}})}getAppRenderingTemplate(e,t){return this.get(`/${encodeURIComponent(e)}/app-templates/${encodeURIComponent(t)}`)}getCompositeAppConfiguration(e){return this.get(`/${encodeURIComponent(e)}/composite-app`)}updateCompositeAppConfiguration(e,t){return this.put(`/${encodeURIComponent(e)}/composite-app`,{payload:t})}},Ye=class extends j{constructor(e){super(e,`/`)}list(e){return this.get(`/${e}/integrations`).then(e=>e.integrations)}retrieve(e,t){return this.get(`/${e}/integrations/${t}`).catch(e=>{if(e.status!==404)throw e})}update(e,t,n){return this.put(`/${e}/integrations/${t}`,{payload:n})}updatePlugins(e,t){return this.post(`/${e}/plugins`,{payload:{plugins:t}})}listPlugins(e){return this.get(`/${e}/plugins`)}},Xe=class extends j{constructor(e){super(e,`/api/v1/prompts`)}list(e={}){let t=e.query||{};return this.get(`/`,{query:{...t}})}computeFacets(e){return this.post(`/facets`,{payload:e})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}fork(e,t){return this.post(`/${e}/fork`,{payload:t})}render(e,t){return this.post(`/${e}/render`,{payload:t})}options(e){return this.get(`/options/${e}`)}listVersions(e){return this.get(`/${e}/versions`)}listInteractions(e){return this.get(`/${e}/interactions`)}listForks(e){return this.get(`/${e}/forks`)}},Ze=class extends j{constructor(e){super(e,`/api/v1/quota`)}standing(){return this.get(`/standing`)}tier(){return this.get(`/tier`)}},Qe=class extends j{constructor(e){super(e,`/api/v1/refs`)}resolve(e){return this.post(`/resolve`,{payload:{refs:e}})}},$e=class extends j{constructor(e){super(e,`/api/v1/remote-mcp-connections`)}getStatus(e){return this.get(`/status/${e}`)}getCollectionStatus(e,t){return this.get(`/status/${e}/${t}`)}getMetadata(e,t){return this.get(`/metadata/${e}/${t}`)}authorize(e,t){return this.get(`/authorize/${e}/${t}`)}exchange(e,t){return this.post(`/exchange`,{payload:{code:e,state:t}})}connect(e,t){return this.post(`/connect/${e}/${t}`,{})}disconnect(e,t){return this.del(`/disconnect/${e}/${t}`)}getCollectionToken(e,t){return this.post(`/token`,{payload:{app_install_id:e,collection_id:t}})}getToken(e){return this.post(`/token`,{payload:{mcp_server_url:e}})}},et=class extends j{constructor(e){super(e,`/api/v1/runs`)}list({limit:e,offset:t,filters:n}){let r={limit:e,offset:t,...n};return this.get(`/`,{query:r})}find(e){return this.post(`/find`,{payload:e})}async retrieve(e){return R(await this.get(`/${e}`))}retrievePopulated(e){return this.get(`/${e}`,{query:{populate:`true`}})}filterOptions(e,t){let n={...t};return this.get(`/filter-options/${e}`,{query:n})}async create(e,t){let n=this.client.sessionTags;if(n){let t=Array.isArray(n)?n:[n];Array.isArray(e.tags)?t=t.concat(e.tags):e.tags&&(t=t.concat([e.tags])),e={...e,tags:t}}return R(await this.post(`/`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal}))}sendToolResults(e,t){return this.post(`/tool-results`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal})}sendUserMessage(e,t){return this.post(`/user-message`,{payload:e,timeoutMs:t?.timeoutMs,signal:t?.signal})}computeFacets(e){return this.post(`/facets`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}clone(e){return this.post(`/clone`,{payload:e})}},tt=class extends j{constructor(e){super(e,`/api/v1/secrets`)}list(e,t){return this.get(`/`,{query:{...t,project_id:e}}).then(e=>e.secrets)}retrieve(e,t,n){return this.get(`/${t}`,{query:{...n,project_id:e}}).catch(e=>{if(e.status!==404)throw e})}create(e,t){return this.post(`/`,{query:{project_id:e},payload:t})}update(e,t,n,r){return this.put(`/${t}`,{query:{...r,project_id:e},payload:n})}remove(e,t,n){return this.del(`/${t}`,{query:{...n,project_id:e}})}fillWebsiteCredential(e,t,n){return this.post(`/${t}/actions/fill-browser`,{query:{project_id:e},payload:n})}},nt=class extends j{constructor(e){super(e,`/api/v1/skills`)}findRelevant(e,t){let n={context:e,limit:t};return this.post(`/find-relevant`,{payload:n})}findRelevantForTask(e,t){return this.findRelevant({task_description:e,tool_names:t})}};const rt=new Set([429,500,502,503,504]);function it(e){return new Promise(t=>setTimeout(t,e))}function at(e){let t=e.headers.get(`retry-after`);if(!t)return;let n=Number(t);if(Number.isFinite(n)&&n>=0)return n*1e3;let r=Date.parse(t);if(!Number.isNaN(r))return Math.max(0,r-Date.now())}function ot(e,t,n,r){let i=r?at(r):void 0;if(i!==void 0)return Math.min(n,i);let a=Math.min(n,t*2**e);return Math.floor(Math.random()*a)}const st=new TextEncoder;function ct(e){if(typeof e==`string`)return st.encode(e);if(e instanceof Blob)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`Unsupported signed-URL upload chunk of type "${typeof e}"; body streams must yield string or binary (Uint8Array/ArrayBuffer/DataView/Blob) chunks.`)}async function lt(e){if(e!=null){if(typeof ReadableStream<`u`&&e instanceof ReadableStream){let t=e.getReader(),n=[];try{for(;;){let{done:e,value:r}=await t.read();if(e)break;n.push(ct(r))}}catch(e){throw await t.cancel(e).catch(()=>void 0),e}finally{t.releaseLock()}return new Blob(n)}return e}}async function H(e,t={}){let{method:n=`GET`,headers:r,attempts:i=4,baseDelayMs:a=500,maxDelayMs:o=8e3,retryableStatuses:s=rt}=t,c=await lt(t.body),l;for(let t=0;t<i;t++){let u=t===i-1;try{let i=await fetch(e,{method:n,headers:r,body:c});if(i.ok||!s.has(i.status)||u)return i;await i.body?.cancel().catch(()=>void 0),await it(ot(t,a,o,i))}catch(e){if(l=e,u)throw e;await it(ot(t,a,o))}}throw l instanceof Error?l:Error(`Failed to fetch signed URL: ${e}`)}function ut(e){if(!e||typeof e!=`object`)return;let t=e.process_run_id;return typeof t==`string`?t:void 0}function dt(e,t){let n=ut(e);return!n||n===t}function U(e,t){return e.type===n.TERMINATED||e.type===n.COMPLETE&&(e.workstream_id??`main`)===`main`?dt(e.details,t):!1}function ft(e,t){return e.t===n.TERMINATED||e.t===n.COMPLETE&&(e.w??`main`)===`main`?dt(e.d,t):!1}var pt=class extends j{constructor(e){super(e,`/api/v1/agents`)}start(e){return this.post(`/`,{payload:e})}recordRun(e){return this.post(`/record`,{payload:e})}createRecord(e){return this.recordRun(e)}retrieve(e){return this.get(`/${e}`)}retrieveRun(e){return this.get(`/${e}`)}retrieveProcess(e){return this.get(`/${e}`)}list(e){return this.get(`/`,{query:this.buildListQueryParams(e)})}async listProcessRuns(e){return(await this.get(`/`,{query:this.buildListQueryParams({...e,run_kind:`process`})})).items.filter(mt)}buildListQueryParams(e){let t={};return e?.id&&(t.id=e.id),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.since&&(t.since=e.since.toISOString()),e?.until&&(t.until=e.until.toISOString()),e?.schedule_id&&(t.schedule_id=e.schedule_id),e?.type&&(t.type=e.type),e?.run_type&&(t.run_type=Array.isArray(e.run_type)?e.run_type.join(`,`):e.run_type),e?.run_kind&&(t.run_kind=e.run_kind),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.cursor&&(t.cursor=e.cursor),e?.sort&&(t.sort=e.sort),e?.order&&(t.order=e.order),t}search(e){let t={};return e?.query&&(t.query=e.query),e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.interaction&&(t.interaction=e.interaction),e?.started_by&&(t.started_by=e.started_by),e?.categories?.length&&(t.categories=e.categories.join(`,`)),e?.tags?.length&&(t.tags=e.tags.join(`,`)),e?.content_type_name&&(t.content_type_name=e.content_type_name),e?.since&&(t.since=e.since.toISOString()),e?.until&&(t.until=e.until.toISOString()),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),e?.sort?.length&&(t.sort=e.sort.join(`,`)),this.get(`/search`,{query:t})}terminate(e,t){let n=t?{reason:t}:void 0;return this.del(`/${e}`,{query:n})}restart(e){return this.post(`/${e}/restart`,{})}fork(e){return this.post(`/${e}/fork`,{})}getContext(e){return this.get(`/${e}/context`)}getHistory(e){return this.get(`/${e}/history`)}advance(e,t){return this.post(`/${e}/advance`,{payload:t??{}})}retryNode(e,t){return this.post(`/${e}/retry-node`,{payload:t??{}})}answerTask(e,t,n){return this.post(`/${e}/answer-task`,{payload:{task_id:t,result:n}})}updateStatus(e,t){return this.post(`/${e}/status`,{payload:t})}bindWorkflowRun(e,t){return this.post(`/${e}/workflow`,{payload:t})}sendSignal(e,t,n){return this.post(`/${e}/signal/${t}`,{payload:n})}query(e,t){return this.get(`/${e}/query/${t}`)}getActiveWorkstreams(e){return this.query(e,`ActiveWorkstreams`)}async retrieveMessages(e,t){let n=t?{since:t}:void 0;return(await this.get(`/${e}/updates`,{query:n})).messages.map(t=>m(f(t),e))}postMessage(e,t){return this.post(`/${e}/updates`,{payload:t})}async streamMessages(e,t,n,r,i){let a=()=>{},o=()=>{},s=new Promise((e,t)=>{a=e,o=t}),c=0,l=n||0,u=Date.now(),d=!1,p=null,h=null,g=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{g&&=(clearTimeout(g),null),h&&=(clearInterval(h),null),p&&=(p.close(),null),r&&_&&(r.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),a(e))},x=e=>typeof e==`string`&&[`completed`,`failed`,`cancelled`].includes(e),S=n=>{if(d)return;y(),console.warn(`Agent stream ${e}: SSE unavailable after 10 attempts; falling back to /updates polling.`,n instanceof Error?n.message:n);let r=async()=>{if(!d){try{let n=await this.retrieveMessages(e,l||void 0);for(let r of n){if(d)return;if(!((r.timestamp||0)<=l)){if(l=r.timestamp||l,t&&t(r,b),d)return;if(U(r,e)){b(null);return}}}}catch{}if(!d){try{let t=await this.get(`/${e}`);if(x(t?.status)){b(null);return}}catch{}d||(g=setTimeout(()=>{g=null,r()},5e3))}}};r()};if(r){if(r.aborted)return d=!0,y(),a(null),s;_=()=>{b(null)},r.addEventListener(`abort`,_,{once:!0})}try{if(!d){let r=await this.retrieveMessages(e,n);i?.onHistoryLoaded?.(r);let a=!1;for(let n=0;n<r.length;n++){let i=r[n];if(d||(l=Math.max(l,i.timestamp||0),t&&t(i,b),d))break;a=n===r.length-1&&U(i,e)}if(a)return b(null),s}}catch(e){d||(i?.onHistoryError?.(e),console.warn(`Failed to fetch historical messages, continuing with SSE:`,e))}!d&&l<=0&&(l=Math.max(1,u-1));let C=async(n=!1)=>{if(!d)try{let r=await N();if(d)return;let i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/stream`);l>0&&a.searchParams.set(`since`,l.toString()),a.searchParams.set(`skipHistory`,`true`);let s=i._auth?await i._auth():void 0;if(d)return;if(!s){d=!0,y(),o(Error(`No auth token available`));return}let u=s.split(` `)[1];if(a.searchParams.set(`access_token`,u),n&&console.log(`Reconnecting to agent stream ${e} (attempt ${c+1}/10)`),d)return;let _=new r(a.href);p=_,h=setInterval(()=>{},1e3);let x=0;_.onopen=()=>{n&&console.log(`Reconnected to agent stream ${e}`),x=Date.now()},_.onmessage=n=>{if(!d&&!(!n.data||n.data.startsWith(`:`)))try{let r=f(n.data);l=r.ts?Math.max(l,r.ts):Date.now(),t&&t(m(r,e),b),ft(r,e)&&b(null)}catch(e){console.error(`Failed to parse SSE message:`,e,n.data)}},_.onerror=e=>{if(!d)if(y(),(x?Date.now()-x:0)>5e3&&(c=0),c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||C(!0)},e)}else S(Error(`SSE connection failed after 10 reconnection attempts`))}}catch(e){if(d)return;if(c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||C(!0)},e)}else S(e)}};return C(!1),s}getInternals(e){return this.get(`/${e}/internals`)}getRunDetails(e,t){let n={};return t?.includeHistory&&(n.include_history=`true`),t?.hydratePayloads&&(n.hydrate_payloads=`true`),this.get(`/${e}/details`,{query:n})}async streamRunDetails(e,t,n){let r=await N(),i=this.client,a=new URL(`${i.agents.baseUrl}/${e}/details/stream`),o=i._auth?await i._auth():void 0;if(!o)throw Error(`No auth token available`);let s=o.split(` `)[1];return a.searchParams.set(`access_token`,s),new Promise((e,i)=>{let o=new r(a.href),s=null,c=()=>{o.close(),n&&s&&(n.removeEventListener(`abort`,s),s=null)};if(n){if(n.aborted){c(),e();return}s=()=>{c(),e()},n.addEventListener(`abort`,s,{once:!0})}o.addEventListener(`history`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`history`,data:n})}catch{}}),o.addEventListener(`control`,n=>{try{let r=JSON.parse(n.data);t&&t({type:`control`,data:r}),`type`in r&&r.type===`done`&&(c(),e())}catch{}}),o.addEventListener(`error`,e=>{try{let n=JSON.parse(e.data);t&&t({type:`error`,data:n})}catch{}}),o.onerror=e=>{c(),i(Error(`SSE connection failed for details stream`))}})}listChildren(e){return this.get(`/${e}/children`)}getChildDetails(e,t,n){let r={};return n?.includeHistory&&(r.include_history=`true`),n?.hydratePayloads&&(r.hydrate_payloads=`true`),this.get(`/${e}/children/${t}/details`,{query:r})}listArtifacts(e,t){let n=t?.visibility?{visibility:t.visibility}:void 0;return this.get(`/${e}/artifacts`,{query:n})}getArtifactContent(e,t){return this.get(`/${e}/artifact-content/${t}`)}updateArtifactContent(e,t,n){return this.put(`/${e}/artifact-content/${t}`,{payload:n})}getArtifactUrl(e,t,n,r){let i={url:`1`};return n&&(i.disposition=n),r&&(i.filename=r),this.get(`/${e}/artifacts/${t}`,{query:i})}async uploadArtifact(e,t,n,r){let i=r||`application/octet-stream`,a=await this.put(`/${e}/artifacts/${t}`,{headers:{"Content-Type":i}}),o=await H(a.url,{method:`PUT`,body:n,headers:{"Content-Type":i}});if(!o.ok)throw Error(`Failed to upload artifact: ${o.statusText}`);return a}async downloadArtifact(e,t){let{url:n}=await this.getArtifactUrl(e,t,`attachment`),r=await H(n);if(!r.ok)throw Error(`Failed to download artifact: ${r.statusText}`);if(!r.body)throw Error(`No body in artifact download response`);return r.body}ingestEvents(e,t){let n={events:t};return this.post(`/${e}/events`,{payload:n})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}};function mt(e){return e.run_kind===`process`}var ht=class extends j{constructor(e){super(e,`/api/v1/collections`)}search(e){return this.post(`/search`,{payload:e})}computeListFacets(e){return this.post(`/facets`,{payload:e})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}addMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`add`,members:t}})}listMembers(e,t){return this.get(`/${e}/members`,{query:{...t}})}computeFacets(e,t){return this.post(`/${e}/facets`,{payload:t})}searchMembers(e,t){return this.post(`/${e}/search`,{payload:t})}deleteMembers(e,t){return this.post(`/${e}/members`,{payload:{action:`delete`,members:t}})}addChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`add`,children:t}})}deleteChildren(e,t){return this.post(`/${e}/children`,{payload:{action:`delete`,children:t}})}searchChildren(e,t={}){return this.post(`/${e}/children/search`,{payload:t})}delete(e){return this.del(`/${e}`)}updatePermissions(e,t){return this.put(`/${e}/permissions`,{payload:t})}propagatePermissions(e){return this.post(`/${e}/propagate-permissions`)}propagateSharedProperties(e){return this.post(`/${e}/propagate-shared-props`)}},gt=class extends j{constructor(e){super(e,`/api/v1/cost`)}getAnalytics(e={}){return this.post(`/analytics`,{payload:e})}getGlobalAnalytics(e={}){return this.post(`/analytics/global`,{payload:e})}getModelPrices(e={}){return this.get(`/model-prices`,{query:{...e}})}getRunPrice(e){return this.post(`/run-price`,{payload:e})}getRunPriceComparison(e){return this.post(`/run-price`,{payload:{...e,include_comparison_pricing:!0}})}getExportUrl(e){let t=new URLSearchParams;e?.from&&t.set(`from`,typeof e.from==`number`?new Date(e.from).toISOString():e.from),e?.to&&t.set(`to`,typeof e.to==`number`?new Date(e.to).toISOString():e.to),e?.scope&&t.set(`scope`,e.scope),e?.project_id&&t.set(`project_id`,e.project_id),e?.workflow_id&&t.set(`workflow_id`,e.workflow_id);let n=t.toString();return`${this.baseUrl}/export${n?`?${n}`:``}`}},_t=class extends j{storeId;constructor(e,t){super(e,`/api/v1/data/${t}/dashboards`),this.storeId=t}storeHeaders(){return{[i.DATA_STORE_ID]:this.storeId}}list(e){let t=e?`?status=${e}`:``;return this.get(`/${t}`,{headers:this.storeHeaders()})}create(e){return this.post(`/`,{payload:e,headers:this.storeHeaders()})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders()})}update(e,t){return this.put(`/${e}`,{payload:t,headers:this.storeHeaders()})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders()})}bulkArchive(e){return this.post(`/bulk/archive`,{payload:{ids:e},headers:this.storeHeaders()})}bulkDelete(e){return this.post(`/bulk/delete`,{payload:{ids:e},headers:this.storeHeaders()})}listVersions(e,t){let n=new URLSearchParams;t?.snapshotsOnly&&n.set(`snapshots_only`,`true`),t?.limit&&n.set(`limit`,String(t.limit));let r=n.toString()?`?${n}`:``;return this.get(`/${e}/versions${r}`,{headers:this.storeHeaders()})}getVersion(e,t){return this.get(`/${e}/versions/${t}`,{headers:this.storeHeaders()})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders()})}promoteVersion(e,t,n){return this.post(`/${e}/versions/${t}/promote`,{payload:n||{},headers:this.storeHeaders()})}setVersioningEnabled(e,t){return this.put(`/${e}/versioning`,{payload:{enabled:t},headers:this.storeHeaders()})}},vt=class extends j{constructor(e){super(e,`/api/v1/data`)}storeHeaders(e){return{[i.DATA_STORE_ID]:e}}list(){return this.get(`/`)}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${e}`,{headers:this.storeHeaders(e)})}delete(e){return this.del(`/${e}`,{headers:this.storeHeaders(e)})}getSchema(e,t){let n=t?`?format=${t}`:``;return this.get(`/${e}/schema${n}`,{headers:this.storeHeaders(e)})}updateSchema(e,t){return this.put(`/${e}/schema`,{payload:t,headers:this.storeHeaders(e)})}getSchemaHistory(e){return this.get(`/${e}/schema/history`,{headers:this.storeHeaders(e)})}listTables(e){return this.get(`/${e}/tables`,{headers:this.storeHeaders(e)})}createTables(e,t){return this.post(`/${e}/tables`,{payload:t,headers:this.storeHeaders(e)})}getTable(e,t,n){let r=n?`?sample=true`:``;return this.get(`/${e}/tables/${t}${r}`,{headers:this.storeHeaders(e)})}alterTable(e,t,n){return this.put(`/${e}/tables/${t}`,{payload:n,headers:this.storeHeaders(e)})}dropTable(e,t){return this.del(`/${e}/tables/${t}`,{headers:this.storeHeaders(e)})}importData(e,t){return this.post(`/${e}/import`,{payload:t,headers:this.storeHeaders(e)})}getImportStatus(e,t){return this.get(`/${e}/import/${t}`,{headers:this.storeHeaders(e)})}listVersions(e,t){let n=t?`?snapshots_only=true`:``;return this.get(`/${e}/versions${n}`,{headers:this.storeHeaders(e)})}createSnapshot(e,t){return this.post(`/${e}/versions`,{payload:t,headers:this.storeHeaders(e)})}rollback(e,t){return this.post(`/${e}/versions/${t}/rollback`,{headers:this.storeHeaders(e)})}queryVersion(e,t,n){return this.post(`/${e}/versions/${t}/query`,{payload:n,headers:this.storeHeaders(e)})}query(e,t){return this.post(`/${e}/query`,{payload:t,headers:this.storeHeaders(e)})}queryBatch(e,t){return this.post(`/${e}/query/batch`,{payload:{queries:t},headers:this.storeHeaders(e)})}mutateRows(e,t){return this.post(`/${e}/mutate`,{payload:t,headers:this.storeHeaders(e)})}validateQueries(e,t){return this.post(`/${e}/query/validate`,{payload:{queries:t},headers:this.storeHeaders(e)})}getDownloadInfo(e,t){let n=t?`?version_id=${t}`:``;return this.get(`/${e}/download${n}`,{headers:this.storeHeaders(e)})}dashboards(e){return new _t(this.client,e)}},yt=class extends j{constructor(e){super(e,`/api/v1/email`)}send(e){return this.post(`/send`,{payload:e})}resolveRoute(e){return this.post(`/resolve-route`,{payload:{route_key:e}})}createRoute(e){return this.post(`/routes`,{payload:e})}getRoute(e){return this.get(`/routes/${e}`)}updateRoute(e,t){return this.put(`/routes/${e}`,{payload:t})}forwardEmail(e,t){return this.post(`/routes/${e}/forward`,{payload:t})}},bt=class extends j{constructor(e,t=`/api/v1/embeddings`){super(e,t)}async status(e){return this.get(`${e}/status`)}async activate(e,t){if(!t.environment)throw Error(`Invalid configuration: select environment`);return this.post(`${e}/enable`,{payload:t})}async disable(e){return this.post(`${e}/disable`)}async recalculate(e){return this.post(`${e}/recalculate`)}};function xt(e){return JSON.parse(e)}function St(e,t,n){let r=Math.min(t*2**e,n);return r+Math.random()*.1*r}function Ct(e,t){if(!t)return;let n=t.startsWith(`Bearer `)?t.slice(7):t;e.searchParams.set(`access_token`,n)}async function wt(e){let t=typeof e==`function`?await e():e;return t instanceof URL?new URL(t.href):new URL(t)}function Tt(e){let t=e.event_types?.length?e.event_types:[`message`],n=e.max_reconnect_attempts??10,r=e.base_reconnect_delay_ms??1e3,i=e.max_reconnect_delay_ms??3e4,a=e.parse??xt,o=!1,s=0,c=null,l=null,u=null,d=0,f,p=t=>{e.on_status?.(t)},m=()=>{c&&=(c.close(),null),l&&=(clearTimeout(l),null)},h=()=>{o||(o=!0,m(),e.signal&&u&&(e.signal.removeEventListener(`abort`,u),u=null),p(`closed`))},g=t=>{if(o)return;if(m(),(d?Date.now()-d:0)>5e3&&(s=0),s>=n){h(),e.on_error?.(t);return}let a=St(s,r,i);s+=1,p(`reconnecting`),l=setTimeout(()=>{l=null,v(!0)},a)},_=(t,n)=>{if(!(o||!n.data||String(n.data).startsWith(`:`)))try{let r=a(String(n.data),t),i=e.get_cursor?.(r);f=n.lastEventId||i||f,e.on_event({data:r,event_type:t,event_id:n.lastEventId||i})}catch(t){e.on_error?.(t)}},v=async n=>{if(!o)try{p(n?`reconnecting`:`connecting`);let r=await N();if(o)return;let i=await wt(e.url);if(f&&e.last_event_id_query_param&&!i.searchParams.has(e.last_event_id_query_param)&&i.searchParams.set(e.last_event_id_query_param,f),Ct(i,await e.get_access_token?.()),o)return;let a=new r(i.href);c=a,d=0,a.onopen=()=>{d=Date.now(),p(`open`)};for(let e of t)a.addEventListener(e,t=>_(e,t));a.onerror=e=>{g(e)}}catch(e){g(e)}};if(e.signal){if(e.signal.aborted)return o=!0,p(`closed`),{get closed(){return o},close:h};u=h,e.signal.addEventListener(`abort`,u,{once:!0})}return v(!1),{get closed(){return o},close:h}}function Et(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r);return Object.keys(t).length?t:void 0}var Dt=class extends j{constructor(e){super(e,`/api/v1/events/channels`)}list(e){return this.get(`/`,{query:Et(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}};function Ot(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(r!=null)if(Array.isArray(r)){if(r.length===0)continue;t[n]=r.join(`,`)}else t[n]=String(r);return Object.keys(t).length?t:void 0}var kt=class extends j{constructor(e){super(e,`/api/v1/events/subscriptions`)}list(e){return this.get(`/`,{query:Ot(e)})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},At=class extends j{subscriptions;channels;constructor(e){super(e,`/api/v1/events`),this.subscriptions=new kt(e),this.channels=new Dt(e)}searchDeliveries(e={}){return this.post(`/deliveries/search`,{payload:e})}queueSummary(e={}){return this.post(`/deliveries/queue-summary`,{payload:e})}subscribeDeliveries(e){let{signal:t,max_reconnect_attempts:n,on_snapshot:r,on_delivery:i,on_envelope:a,on_error:o,on_status:s,...c}=e;return Tt({url:()=>this.buildStreamUrl(c),event_types:[`snapshot`,`event`,`heartbeat`,`error`],signal:t,max_reconnect_attempts:n,last_event_id_query_param:`since_event_id`,get_access_token:async()=>{let e=this.client;return e._auth?await e._auth():void 0},get_cursor:e=>e.cursor,on_status:s,on_error:o,on_event:({data:e})=>{a?.(e),e.type===`snapshot`?r?.(e.deliveries,e):e.type===`event`?i?.(e.item,e):e.type===`error`&&o?.(Error(e.error))}})}buildStreamUrl(e){let t=new URL(`${this.baseUrl}/stream`);return this.setStreamParam(t,`limit`,e.limit),this.setStreamParam(t,`event_id`,e.event_id),this.setStreamParam(t,`resource_id`,e.resource_id),this.setStreamListParam(t,`resource_type`,e.resource_type),this.setStreamListParam(t,`event_category`,e.event_category),this.setStreamListParam(t,`action`,e.action),this.setStreamListParam(t,`outbox_status`,e.outbox_status),this.setStreamParam(t,`since_event_id`,e.since_event_id),this.setStreamParam(t,`since_created_at`,e.since_created_at),this.setStreamParam(t,`include_event`,e.include_event),this.setStreamParam(t,`poll_interval_ms`,e.poll_interval_ms),t}setStreamParam(e,t,n){n!=null&&n!==``&&e.searchParams.set(t,String(n))}setStreamListParam(e,t,n){n?.length&&e.searchParams.set(t,n.join(`,`))}},jt=class extends v{constructor(e,t){super(`Resource not found: ${t.message}`,e,404,t.payload)}},W=class{stream;name;type;id;constructor(e,t,n,r){this.stream=e,this.name=t,this.type=n,this.id=r}};function Mt(e){return e?.split(`;`,1)[0]?.trim().toLowerCase()||void 0}function G(e){return Mt(e)===`application/octet-stream`?void 0:e||void 0}function K(e,t){return G(e)||t||e||void 0}const Nt=`memories`,q=`agents`,Pt={attempts:3,methods:[`POST`],statuses:[502,503,504]};function J(e){let t=e.endsWith(`.tar.gz`)?e:`${e}.tar.gz`;return`${Nt}/${t}`}function Y(e,t){return`${q}/${e}/${t}`}var Ft=class extends j{constructor(e){super(e,`/api/v1/files`)}async deleteFile(e,t){return this.del(`/${e}`,{query:{prefix:t}})}getMetadata(e){return this.get(`/metadata`,{query:{file:e}})}setFileMetadata(e,t){let n={file:e,metadata:t};return this.put(`/metadata`,{payload:n})}getOrCreateBucket(){return this.post(`/bucket`)}ensureBucketReadAccess(e){let t={principal:e};return this.post(`/bucket/read-access`,{payload:t})}getBucketReadAccessStatus(e){return this.get(`/bucket/read-access`,{query:{principal:e}})}list(e){return this.get(`/list`,{query:{prefix:e}})}getUploadUrl(e){return this.post(`/upload-url`,{payload:e,retryPolicy:Pt})}getDownloadUrl(e,t,n){let r={file:e,name:t,disposition:n};return this.post(`/download-url`,{payload:r})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}bulkGetUploadUrls(e){return this.post(`/bulk-upload-urls`,{payload:e})}async bulkUpload(e,t=10){let n=e.map(e=>({name:e.name,mime_type:G(e.type),id:e instanceof W?e.id:void 0})),{files:r}=await this.bulkGetUploadUrls({files:n}),i=Array(e.length);for(let n=0;n<e.length;n+=t){let a=e.slice(n,n+t);await Promise.all(a.map(async(e,t)=>{let a=n+t,{url:o,id:s,mime_type:c}=r[a],l=e instanceof W,u=K(e.type,c),d=await H(o,{method:`PUT`,body:l?e.stream:e,headers:u?{"Content-Type":u}:void 0});if(!d.ok)throw Error(`Failed to upload file ${e.name}: ${d.statusText}`);let f=d.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);i[a]={source:s,name:e.name,type:u,etag:f}}))}return i}async uploadFile(e){return(await this.uploadFileWithPath(e)).id}async uploadFileWithPath(e){let t=e instanceof W,{url:n,id:r,path:i,mime_type:a}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:G(e.type)}),o=K(e.type,a)||`application/gzip`,s=await H(n,{method:`PUT`,body:t?e.stream:e,headers:{"Content-Type":o}}).catch(e=>{throw console.error(`Failed to upload file`,{err:e,url:n,id:r,path:i}),e});if(!s.ok)throw console.log(s),Error(`Failed to upload file: ${s.statusText}`);return{id:r,path:i}}async downloadFile(e){let{url:t}=e.startsWith(`https:`)?{url:e}:await this.getDownloadUrl(e),n=await H(t,{method:`GET`}).then(n=>{if(n.ok)return n;throw n.status===404?Error(`File at ${t} not found`):n.status===403?Error(`File at ${t} is forbidden`):(console.log(n),Error(`Failed to download file ${e}: ${n.statusText}`))}).catch(t=>{throw console.error(`Failed to download file ${e}.`,t),t});if(!n.body)throw Error(`No body in response while downloading file ${e}`);return n.body}async copyFile(e,t){return(await this.post(`/copy`,{payload:{source:e,dest:t}})).dest}async uploadMemoryPack(e){let t=J(e.name),n=e.name.endsWith(`.tar.gz`)?e.name:`${e.name}.tar.gz`;if(e instanceof File){let r=e;return this.uploadFile(new W(r.stream(),n,r.type,t))}else return this.uploadFile(new W(e.stream,n,e.type,t))}async downloadMemoryPack(e,t=!1){let n=await this.downloadFile(J(e));if(t){let e=new DecompressionStream(`gzip`);n=n.pipeThrough(e)}return n}listByPrefix(e){return this.get(`/list`,{query:{prefix:e}})}async uploadArtifact(e,t,n){let r=Y(e,t);if(n instanceof File){let e=n;return this.uploadFile(new W(e.stream(),t,e.type,r))}else return this.uploadFile(new W(n.stream,t,n.type,r))}async downloadArtifact(e,t){let n=Y(e,t);return this.downloadFile(n)}getArtifactDownloadUrl(e,t,n){let r=Y(e,t);return this.getDownloadUrl(r,t,n)}async listArtifacts(e){let t=`${q}/${e}/`;return(await this.listByPrefix(t)).files}},It=class extends j{constructor(e){super(e,`/api/v1/hive-memory`)}list(e){let t=new URLSearchParams;e?.category&&t.set(`category`,e.category),e?.scope&&t.set(`scope`,e.scope),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return this.get(n?`/?${n}`:`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}search(e){return this.post(`/search`,{payload:e})}recall(e,t){return this.post(`/recall`,{payload:{task_description:e,tools:t?.tools,category:t?.category,max_results:t?.maxResults}})}getFormatted(e){return this.get(`/${e}/formatted`)}recordUsage(e){return this.post(`/${e}/usage`,{})}getByCategory(e,t){let n=new URLSearchParams;t?.limit&&n.set(`limit`,String(t.limit)),t?.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return this.get(`/category/${e}${r?`?${r}`:``}`)}getStats(){return this.get(`/stats`)}applyDecay(e){return this.post(`/admin/decay`,{payload:{days_threshold:e?.daysThreshold,decay_rate:e?.decayRate}})}archiveLowConfidence(e){return this.post(`/admin/archive`,{payload:{threshold:e}})}},Lt=class extends j{constructor(e,t=`/api/v1/indexing`){super(e,t)}async status(){return this.get(`/status`)}async reindex(e){return this.post(`/reindex`,{payload:e})}async reindexAgentRuns(e){return this.post(`/agent-runs/reindex`,{payload:e})}async analyzeDrift(){return this.post(`/analyze-drift`,{payload:{}})}async getDriftAnalysis(){return this.get(`/drift-analysis`)}async enableIndexing(){return this.post(`/enable-indexing`)}async disableIndexing(){return this.post(`/disable-indexing`)}async enableQueries(){return this.post(`/enable-queries`)}async disableQueries(){return this.post(`/disable-queries`)}index(e,t){return this.post(`/internal/index`,{payload:{object_id:e,document:t}})}delete(e){return this.post(`/internal/delete`,{payload:{object_id:e}})}bulkIndex(e,t){return this.post(`/internal/bulk-index`,{payload:{documents:e,target_index:t}})}ensureIndex(e){return this.post(`/internal/ensure-index`,{payload:{recreate:e}})}createReindexTarget(){return this.post(`/internal/create-reindex-target`,{payload:{}})}getStats(){return this.post(`/internal/stats`,{payload:{}})}fetchBatch(e,t){return this.post(`/internal/fetch-batch`,{payload:{cursor:e,limit:t}})}getNextIndexCursor(e,t,n){return this.post(`/internal/next-cursor`,{payload:{cursor:e,limit:t,count:n}})}analyzeDriftBatch(e,t){return this.post(`/internal/analyze-drift-batch`,{payload:{cursor:e,limit:t}})}triggerReindex(e){return this.post(`/internal/trigger-reindex`,{payload:e?{full_reindex:e.fullReindex,object_ids:e.objectIds,recreate_index:e.recreateIndex}:{}})}fetchDocumentsByIds(e){return this.post(`/internal/fetch-by-ids`,{payload:{object_ids:e}})}bulkDelete(e){return this.post(`/internal/bulk-delete`,{payload:{object_ids:e}})}getConfiguration(){return this.post(`/internal/configuration`,{payload:{}})}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t})}computeShards(e,t,n,r){return this.zenoBulkPost(`/reindex/compute-shards`,{tenant_id:e,shard_size:t??25e4,updated_since:n,backend:r})}indexShard(e){return this.zenoBulkPost(`/reindex/shard`,{params:e})}swapAlias(e,t,n,r){return this.zenoBulkPost(`/reindex/swap-alias`,{tenant_id:e,target_index:t,alias:n,backend:r})}async reindexViaBulk(e,t,n,r,i,a){let o=`${this.zenoBulkBaseUrl}/reindex`,s={tenant_id:e,project_id:i,dry_run:n??!1,backend:r,shard_size:a?.shardSize,shards:a?.shards,bulk_concurrency:a?.bulkConcurrency,bulk_size_bytes:a?.bulkSizeBytes,bulk_max_docs:a?.bulkMaxDocs};if(!t)return this.client.post(o,{payload:{params:s}});let c;if(await this.client.sseRequest(`POST`,o,{payload:{params:s}},e=>{if(t(e),e.type===`event`&&e.event===`done`)try{c=JSON.parse(e.data)}catch{}}),!c)throw Error(`zeno-bulk SSE stream ended without a done event`);return c}},Rt=class extends j{objectId;constructor(e,t){super(e,`/${t}/analyze`),this.objectId=t}async start(e){return this.post(`/`,{payload:e})}async getStatus(){return this.get(`/status`)}async startGroundedExtraction(e){return this.post(`/grounded`,{payload:e??{}})}async getGroundedExtractionResult(){return this.get(`/grounded/result`)}async startGroundedAssistant(e){return this.post(`/grounded/assistant`,{payload:e??{}})}},zt=class extends j{constructor(e){super(e,`/api/v1/objects`)}analyze(e){return new Rt(this,e)}getUploadUrl(e){return this.post(`/upload-url`,{payload:e})}getDownloadUrl(e,t,n){return this.post(`/download-url`,{payload:{file:e,name:t,disposition:n}})}getDownloadUrlWithOptions(e){return this.post(`/download-url`,{payload:e})}getContentSource(e){return this.get(`/${e}/content-source`)}list(e={}){let t=e.limit||100,n=e.offset||0,r=e.query||{};return this.get(`/`,{query:{limit:t,offset:n,select:e.select,...r,all_revisions:e.all_revisions,from_root:e.from_root||void 0}})}computeFacets(e){return this.post(`/facets`,{payload:e})}startExport(e={}){return this.post(`/export/bulk`,{payload:e})}listExports(){return this.get(`/export/bulk/artifacts`)}deleteExport(e){return this.del(`/export/bulk/artifacts/${encodeURIComponent(e)}`)}getExportStatus(e,t){return this.get(`/export/bulk/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}getExportDownloadUrl(e,t){return this.get(`/export/bulk/artifacts/${encodeURIComponent(e)}/${t}/download-url`)}async downloadExportFile(e,t){let{url:n}=await this.getExportDownloadUrl(e,t),r=await H(n,{method:`GET`}).then(e=>{if(!e.ok)throw Error(`Failed to download export file: ${e.status} ${e.statusText}`);return e});if(!r.body)throw Error(`No response body received when downloading export file`);return r.body}exportToBucketViaBulk(e,t=!1){return this.zenoBulkPost(`/export`,e,t)}planContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/plan`,e,t)}exportContentObjectShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard`,e,t)}splitContentObjectExportShardViaBulk(e,t=!1){return this.zenoBulkPost(`/export/shard/split`,e,t)}composeContentObjectExportViaBulk(e,t=!1){return this.zenoBulkPost(`/export/compose`,e,t)}get zenoBulkBaseUrl(){let e=this.client.baseUrl;return e.includes(`localhost:`)||e.includes(`127.0.0.1:`)?`https://zeno-bulk-dev-main.api.dev1.vertesia.io`:e.includes(`zeno-server`)?e.replace(/zeno-server/,`zeno-bulk`):e}zenoBulkPost(e,t,n){return this.client.post(this.zenoBulkBaseUrl+e,{payload:t,timeoutMs:n})}listFolders(e=`/`){throw Error(`Not implemented yet`)}find(e){return this.post(`/find`,{payload:e})}count(e){return this.post(`/count`,{payload:e})}search(e){return this.post(`/search`,{payload:e})}retrieve(e,t){return this.get(`/${e}`,{query:{select:t}})}getObjectText(e){return this.get(`/${e}/text`)}async upload(e){let t=e instanceof W,{url:n,id:r,mime_type:i}=await this.getUploadUrl({id:t?e.id:void 0,name:e.name,mime_type:G(e.type)}),a=K(e.type,i),o=await H(n,{method:`PUT`,body:t?e.stream:e,headers:a?{"Content-Type":a}:void 0}).catch(e=>{throw console.error(`Failed to upload file`,e),e});if(!o.ok)throw console.error(`Failed to upload file`,{status:o.status,statusText:o.statusText,url:n}),Error(`Failed to upload file: ${o.statusText}`);let s=o.headers.get(`etag`)?.replace(/^"(.*)"$/,`$1`);return{source:r,name:e.name,type:a,etag:s}}async create(e,t){let{content:n,...i}=e,a={...i};n instanceof W||n instanceof File?a.content=await this.upload(n):a.content=n;let o={};return t?.processing_priority&&(o[r.PROCESSING_PRIORITY]=t.processing_priority),t?.collection_id&&(o[r.COLLECTION_ID]=t.collection_id),await this.post(`/`,{payload:a,headers:o})}async createFromExternalSource(e,t={},n){let i=await this.client.files.getMetadata(e),a={...t,content:{source:e,name:i.name,type:i.contentType,etag:i.etag}},o={};return n?.processing_priority&&(o[r.PROCESSING_PRIORITY]=n.processing_priority),n?.collection_id&&(o[r.COLLECTION_ID]=n.collection_id),await this.post(`/`,{payload:a,headers:o})}async update(e,t,n){let{content:i,...a}=t,o={...a};i instanceof W||i instanceof File?o.content=await this.upload(i):o.content=i;let s={};return n?.ifMatch&&(s[`if-match`]=n.ifMatch),n?.processing_priority&&(s[r.PROCESSING_PRIORITY]=n.processing_priority),n?.createRevision&&(s[r.CREATE_REVISION]=`true`,n.revisionLabel&&(s[r.REVISION_LABEL]=n.revisionLabel)),n?.suppressWorkflows&&(s[r.SUPPRESS_WORKFLOWS]=`true`),this.put(`/${e}`,{payload:o,headers:s})}getRevisions(e){return this.get(`/${e}/revisions`)}getCollections(e){return this.get(`/${e}/collections`)}delete(e){return Array.isArray(e)?this.client.runOperation({name:`delete`,ids:e,params:{}}):this.del(`/${e}`)}bulkUpdate(e){let t=Object.keys(e);return this.client.runOperation({name:`update`,ids:t,params:e})}bulkCreate(e,t){return this.client.runOperation({name:`create`,ids:[],params:{objects:e,...t}})}listWorkflowRuns(e){return this.get(`/${e}/workflow-runs`)}listRenditions(e){return this.get(`/${e}/renditions`)}getRendition(e,t){let n={max_hw:t.max_hw,generate_if_missing:t.generate_if_missing,sign_url:t.sign_url,block_on_generation:t.block_on_generation};return this.get(`/${e}/renditions/${t.format}`,{query:n})}getRenditionSafe(e,t,n){return c(t,n.format)?this.getRendition(e,n):Promise.resolve(null)}exportProperties(e){return this.post(`/export`,{payload:e})}setEmbedding(e,t,n){return this.put(`/${e}/embeddings/${t}`,{payload:n})}},Bt=class extends j{constructor(e){super(e,`/api/v1/pending-asks`)}register(e){return this.post(`/`,{payload:e})}resolve(e,t){return this.post(`/${e}/resolve`,{payload:t})}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}},Vt=class extends j{constructor(e){super(e,`/api/v1/processes`)}list(e){let t={};return e?.status&&(t.status=e.status),e?.process&&(t.process=e.process),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),e?.allVersions&&(t.all_versions=`true`),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}listVersions(e){return this.get(`/${e}/versions`)}publish(e,t){return this.post(`/${e}/publish`,{payload:t})}revert(e,t){return this.post(`/${e}/revert`,{payload:t})}delete(e){return this.del(`/${e}`)}},Ht=class extends j{constructor(e,t=`/api/v1/query`){super(e,t)}async execute(e){return this.post(`/`,{payload:e})}async sql(e){return this.execute({sql:e})}async esql(e){return this.execute({esql:e})}async dsl(e){return this.execute({dsl:e})}},X=class extends j{constructor(e){super(e,`/api/v1/rendering`)}start(e){return this.post(`/jobs`,{payload:e})}getStatus(e,t){return this.get(`/jobs/status`,{query:{workflow_id:e,workflow_run_id:t}})}async render(e,t={}){let n=t.pollIntervalMs??1500,r=t.timeoutMs??600*1e3,i=await this.start(e);if(!i.workflow_id||!i.workflow_run_id)throw Error(`Failed to start rendering workflow`);let a=Date.now();for(;;){let t=await this.getStatus(i.workflow_id,i.workflow_run_id);if(t.status===s.COMPLETED){if(!t.download_url&&!t.file_uri)throw Error(t.error||`Rendering completed but no output file was produced`);return{status:`success`,format:e.format,download_url:t.download_url,file_uri:t.file_uri}}if(d(t.status)){let e=s[t.status]||String(t.status);throw Error(t.error||`Rendering failed with status: ${e}`)}if(Date.now()-a>=r)throw Error(`Rendering timed out after ${r}ms`);await Ut(n)}}};function Ut(e){return new Promise(t=>setTimeout(t,e))}var Wt=class extends j{constructor(e){super(e,`/api/v1/schedules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}trigger(e){return this.post(`/${e}/trigger`,{})}pause(e,t){return this.post(`/${e}/pause`,{payload:{note:t}})}resume(e,t){return this.post(`/${e}/resume`,{payload:{note:t}})}},Gt=class extends j{constructor(e){super(e,`/api/v1/tasks`)}list(e){let t={};return e?.status&&(t.status=Array.isArray(e.status)?e.status.join(`,`):e.status),e?.assignee&&(t.assignee=e.assignee),e?.run_id&&(t.run_id=e.run_id),e?.source_type&&(t.source_type=e.source_type),e?.limit!=null&&(t.limit=String(e.limit)),e?.offset!=null&&(t.offset=String(e.offset)),this.get(`/`,{query:t})}retrieve(e){return this.get(`/${e}`)}create(e){return this.post(`/`,{payload:e})}update(e,t){return this.put(`/${e}`,{payload:t})}complete(e,t){return this.post(`/${e}/complete`,{payload:t})}cancel(e){return this.post(`/${e}/cancel`,{})}delete(e){return this.del(`/${e}`)}},Kt=class extends j{constructor(e){super(e,`/api/v1/types/catalog`)}list(e={}){return this.get(`/`,{query:e})}listSysTypes(e){return this.get(`/sys`,{query:{tag:e}})}listAppTypes(e){return this.get(`/apps`,{query:{tag:e}})}listStoredTypes(e={}){return this.get(`/stored`,{query:e})}resolve(e){let t=typeof e==`string`?e:e.id;return this.get(`/resolve/${t}`)}},qt=class extends j{catalog;constructor(e){super(e,`/api/v1/types`),this.catalog=new Kt(e)}list(e={},t){let n=e.limit||2e3,r=e.offset||0,i=e.query||{};return this.get(`/`,{query:{limit:n,offset:r,layout:!!t?.layout,schema:!!t?.schema,...i}})}find(e){return this.post(`/find`,{payload:e})}retrieve(e){return this.get(`/${e}`)}getTypeByName(e){return this.get(`/name/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}},Jt=class extends j{constructor(e){super(e,`/api/v1/view-executions`)}execute(e,t={}){return this.post(`/${encodeURIComponent(e)}/execute`,{payload:t})}preview(e){return this.post(`/preview`,{payload:e})}};const Yt=`20260319`,Z=`x-api-version`;var Xt=class extends j{constructor(e){super(e,`/api/v1/workflows`)}getActivityCatalog(){return this.get(`/activity-catalog`)}listRuns(e,t,n){return this.post(`/runs`,{payload:{documentId:e,eventName:t,ruleId:n}})}listConversations(e){return this.post(`/conversations`,{payload:e})}searchRuns(e){return this.post(`/runs`,{payload:e})}sendSignal(e,t,n,r){return this.post(`/runs/${e}/${t}/signal/${n}`,{payload:r})}getRunDetails(e,t,n){let r={};return n?.includeHistory!==void 0&&(r.include_history=n.includeHistory),n?.historyFormat!==void 0&&(r.history_format=n.historyFormat),n?.hydratePayloads!==void 0&&(r.hydrate_payloads=n.hydratePayloads),this.get(`/runs/${t}/${e}`,{query:r})}getRunInteraction(e,t){return this.get(`/runs/${e}/${t}/interaction`)}terminate(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/terminate`,{payload:r})}cancel(e,t,n){let r={reason:n};return this.post(`/runs/${e}/${t}/actions/cancel`,{payload:r})}query(e,t,n){return this.get(`/runs/${e}/${t}/query/${n}`)}execute(e,t={}){return this.post(`/execute/${e}`,{payload:t})}postMessage(e,t){if(!e)throw Error(`runId is required`);return this.post(`/runs/${e}/updates`,{payload:t})}async retrieveMessages(e,t,n){let r={since:n};return(await this.get(`/runs/${e}/${t}/updates`,{query:r})).messages.map(e=>m(f(e),t))}async streamMessages(e,t,r,i,a){return new Promise((o,s)=>{let c=0,l=i||0,u=Date.now(),d=!1,p=null,h=null,g=null,_=null,v=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},y=()=>{g&&=(clearTimeout(g),null),h&&=(clearInterval(h),null),p&&=(p.close(),null),a&&_&&(a.removeEventListener(`abort`,_),_=null)},b=e=>{d||(d=!0,y(),o(e))};if(a){if(a.aborted){b(null);return}_=()=>b(null),a.addEventListener(`abort`,_,{once:!0})}let x=async(i=!1)=>{if(!d)try{let a=await N(),u=this.client,_=new URL(`${u.workflows.baseUrl}/runs/${e}/${t}/stream`);l>0&&_.searchParams.set(`since`,l.toString()),_.searchParams.set(`skipHistory`,`true`);let S=u._auth?await u._auth():void 0;if(d)return;if(!S){d=!0,y(),s(Error(`No auth token available`));return}let C=S.split(` `)[1];_.searchParams.set(`access_token`,C),i&&console.log(`Reconnecting to SSE stream for run ${t} (attempt ${c+1}/10)`);let w=new a(_.href);p=w,h=setInterval(()=>{},1e3),w.onopen=()=>{i&&console.log(`Successfully reconnected to SSE stream for run ${t}`),c=0},w.onmessage=e=>{if(!e.data||e.data.startsWith(`:`)){console.log(`Received comment or heartbeat; ignoring it.: `,e.data);return}try{let i=f(e.data);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(m(i,t),b),ft(i,t)?(console.log(`Closing stream due to COMPLETE message from main workstream`),d||(d=!0,y(),o(null))):i.t===n.COMPLETE&&console.log(`Received COMPLETE message that does not close the root stream for run ${t}`)}catch(t){console.error(`Failed to parse SSE message:`,t,e.data)}},w.onerror=e=>{if(!d)if(console.warn(`SSE stream error for run ${t}:`,e),y(),c<10){let e=v(c);console.log(`Attempting to reconnect in ${e}ms (attempt ${c+1}/10)`),c++,g=setTimeout(()=>{g=null,d||x(!0)},e)}else console.error(`Failed to reconnect to SSE stream for run ${t} after 10 attempts`),d=!0,s(Error(`SSE connection failed after 10 reconnection attempts`))}}catch(e){if(console.error(`Error setting up SSE stream:`,e),c<10){let e=v(c);c++,g=setTimeout(()=>{g=null,d||x(!0)},e)}else s(e)}};(async()=>{try{let n=await this.retrieveMessages(e,t,i),a=!1;for(let e=0;e<n.length;e++){let i=n[e];l=Math.max(l,i.timestamp||0),r&&r(i,b),a=e===n.length-1&&U(i,t)}if(a){b(null);return}}catch(e){console.warn(`Failed to fetch historical messages, continuing with SSE:`,e)}!d&&l<=0&&(l=Math.max(1,u-1)),x(!1)})().catch(s)})}async streamMessagesWS(e,t,r,i){return new Promise((a,o)=>{let s=0,c=null,l=i||0,u=!1,d=e=>{let t=Math.min(1e3*2**e,3e4);return t+Math.random()*.1*t},p=async()=>{if(!u)try{let i=this.client,m=new URL(`${i.workflows.baseUrl}/runs/${e}/${t}/ws`);m.protocol=m.protocol.replace(`http`,`ws`),l>0&&m.searchParams.set(`since`,l.toString());let h=i._auth?await i._auth():void 0;if(!h){o(Error(`No auth token available`));return}let g=h.split(` `)[1];m.searchParams.set(`access_token`,g),s>0&&console.log(`Reconnecting to WebSocket for run ${t} (attempt ${s+1}/10)`),c=new WebSocket(m.href),c.onopen=()=>{s>0&&console.log(`Successfully reconnected to WebSocket for run ${t}`),s=0,u||a({cleanup:()=>{u=!0,c&&=(c.close(),null)},sendSignal:(e,t)=>{if(c?.readyState===WebSocket.OPEN){let n={type:`signal`,signalName:e,data:t,requestId:Date.now()};c.send(JSON.stringify(n))}else console.warn(`WebSocket not open, cannot send signal`)}})},c.onmessage=e=>{try{let t=JSON.parse(e.data);if(`type`in t&&typeof t.type==`string`){if(t.type===`pong`){console.debug(`Received pong`);return}else if(t.type===`ack`){console.debug(`Signal acknowledged`,t);return}else if(t.type===`error`){console.error(`WebSocket error message`,t);return}}let i=f(t);l=i.ts?Math.max(l,i.ts):Date.now(),r&&r(i);let a=i.w||`main`;(i.t===n.TERMINATED||i.t===n.COMPLETE&&a===`main`)&&(console.log(`Closing WebSocket due to workflow completion`),u=!0,c&&=(c.close(),null))}catch(e){console.error(`Failed to parse WebSocket message`,e)}},c.onerror=e=>{console.error(`WebSocket error`,e)},c.onclose=()=>{if(!u&&s<10){let e=d(s);console.log(`WebSocket closed, reconnecting in ${e}ms (attempt ${s+1}/10)`),s++,setTimeout(p,e)}else s>=10&&o(Error(`WebSocket connection failed after 10 attempts`))}}catch(e){if(console.error(`Error setting up WebSocket`,e),s<10){let e=d(s);s++,setTimeout(p,e)}else o(e)}};p()})}ingestEvents(e,t,n){return this.post(`/runs/${e}/${t}/events`,{payload:{events:n}})}getAnalyticsSummary(e={}){return this.post(`/analytics/summary`,{payload:e})}getTokenUsageAnalytics(e={}){return this.post(`/analytics/tokens`,{payload:e})}getLlmLatencyAnalytics(e={}){return this.post(`/analytics/latency/llm`,{payload:e})}getToolLatencyAnalytics(e={}){return this.post(`/analytics/latency/tools`,{payload:e})}getAgentLatencyAnalytics(e={}){return this.post(`/analytics/latency/agents`,{payload:e})}getErrorAnalytics(e={}){return this.post(`/analytics/errors`,{payload:e})}getToolAnalytics(e={}){return this.post(`/analytics/tools`,{payload:e})}getToolParameterAnalytics(e){return this.post(`/analytics/tools/parameters`,{payload:e})}getAnalyticsFilterOptions(e={}){return this.post(`/analytics/filter-options`,{payload:e})}getPromptSizeAnalytics(e={}){return this.post(`/analytics/prompt-size`,{payload:e})}getTopPrincipalsAnalytics(e={}){return this.post(`/analytics/top-principals`,{payload:e})}getRunsByAgentAnalytics(e={}){return this.post(`/analytics/runs-by-agent`,{payload:e})}getTimeToFirstResponseAnalytics(e={}){return this.post(`/analytics/time-to-first-response`,{payload:e})}getFirstResponseBehaviorAnalytics(e={}){return this.post(`/analytics/first-response-behavior`,{payload:e})}rules=new Zt(this);definitions=new Qt(this)},Zt=class extends j{constructor(e){super(e,`/rules`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}execute(e,t,n){let r={objectIds:t,vars:n};return this.post(`/${e}/execute`,{payload:r})}},Qt=class extends j{constructor(e){super(e,`/definitions`)}list(){return this.get(`/`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}create(e){return this.post(`/`,{payload:e})}delete(e){return this.del(`/${e}`)}};function $t(e){if(!e)throw Error(`zeno client serverUrl is required`);return e}var en=class extends A{constructor(e={}){super($t(e.serverUrl),e.fetch),e.apikey&&this.withApiKey(e.apikey),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.errorFactory=e=>e.status===404?new jt(e.request,e):e}withApiVersion(e){return e?this.headers[Z]=String(e):delete this.headers[Z],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withApiKey(e){return this.withAuthCallback(e?()=>Promise.resolve(`Bearer ${e}`):void 0)}runOperation(e){return this.post(`/api/v1/operations`,{payload:e})}get initialHeaders(){return{...super.initialHeaders,[Z]:Yt}}agents=new pt(this);cost=new gt(this);objects=new zt(this);types=new qt(this);workflows=new Xt(this);schedules=new Wt(this);processes=new Vt(this);tasks=new Gt(this);files=new Ft(this);collections=new ht(this);embeddings=new bt(this);email=new yt(this);events=new At(this);eventSubscriptions=this.events.subscriptions;pendingAsks=new Bt(this);data=new vt(this);indexing=new Lt(this);query=new Ht(this);hiveMemory=new It(this);rendering=new X(this);views=new Jt(this)},tn=class extends j{constructor(e){super(e,`/api/v1/tools`)}list(e){let t={};return e?.sources?.length&&(t.sources=e.sources.join(`,`)),e?.exclude?.length&&(t.exclude=e.exclude.join(`,`)),this.get(`/`,{query:Object.keys(t).length>0?t:void 0})}listBuiltins(){return this.list({sources:[`builtin`]})}validate(e){return this.post(`/validate`,{payload:{names:e}})}},nn=class extends j{constructor(e){super(e,`/api/v1/training`)}listSessions(e={}){return this.get(`/`,{query:{...e}})}listSessionNames(e={}){return this.get(`/names`,{query:{...e}})}createSession(e){return this.post(`/`,{payload:e})}getSession(e){return this.get(`/${e}`)}addToSession(e,t){return this.post(`/${e}/add`,{payload:{runs:t}})}listSessionRuns(e,t=100,n=0){return this.get(`/${e}/runs`,{query:{limit:t,offset:n}})}buildSession(e){return this.post(`/${e}/build`)}getDataUrl(e){return this.get(`/${e}/url`)}getDataUploadUrl(e,t=!1){return this.get(`/${e}/upload-url`,t?{query:{resumable:`true`}}:{})}startTraining(e){return this.post(`/${e}/start`)}cancelTraining(e){return this.post(`/${e}/cancel`)}getTrainingJob(e){return this.get(`/job/${e}`)}getAndSyncTrainingJob(e){return this.get(`/job/${e}`,{query:{sync:`true`}})}setDataset(e,t=`default`){return this.post(`/${e}/dataset`,{payload:{dataset:t}})}},rn=class extends j{constructor(e){super(e,`/api/v1/users`)}retrieve(e){return this.get(`/${e}`)}update(e,t){return this.put(`/${e}`,{payload:t})}delete(e){return this.del(`/${e}`)}},an=class extends j{executionApi;constructor(e,t){super(e,`/api/v1/views`),this.executionApi=t}list(e={}){return this.get(`/`,{query:{limit:e.limit,offset:e.offset}})}create(e){return this.post(`/`,{payload:e})}retrieve(e){return this.get(`/${encodeURIComponent(e)}`)}update(e,t){return this.put(`/${encodeURIComponent(e)}`,{payload:t})}delete(e){return this.del(`/${encodeURIComponent(e)}`)}execute(e,t={}){return this.executionApi.execute(e,t)}preview(e){return this.executionApi.preview(e)}},Q=class e extends A{_jwt=null;store;sessionTags;tokenServerUrl;oauthClients;oauthGrants;oauthServer;oauthProviders;remoteMcpConnections;secrets;internalSecrets;static async fromAuthToken(t,n,r){n||=$(t);let i=r||dn(n.endpoints);return await new e({serverUrl:i.studio,storeUrl:i.store,tokenServerUrl:i.token||n.iss}).withApiKey(t)}static decodeEndpoints(){}constructor(e={site:`api.vertesia.io`}){let t,n;if(e.serverUrl)t=e.serverUrl;else if(e.site)t=`https://${e.site}`;else throw Error(`Parameter 'site' or 'serverUrl' is required for VertesiaClient`);if(e.storeUrl)n=e.storeUrl;else if(e.site)n=`https://${e.site}`;else throw Error(`Parameter 'site' or 'storeUrl' is required for VertesiaClient`);if(super(t,e.fetch),e.tokenServerUrl)this.tokenServerUrl=e.tokenServerUrl;else if(e.site){let t=e.site.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else if(e.serverUrl||e.storeUrl){let t=e.serverUrl||e.storeUrl||``;try{let e=new URL(t);if(e.hostname.startsWith(`api`)){let t=e.hostname.replace(/^api/,`sts`);this.tokenServerUrl=`https://${t}`}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`}catch{this.tokenServerUrl=`https://sts.dev1.vertesia.io`}}else this.tokenServerUrl=`https://sts.dev1.vertesia.io`;this.store=new en({serverUrl:n,tokenServerUrl:this.tokenServerUrl,apikey:e.apikey,onRequest:e.onRequest,onResponse:e.onResponse,retryPolicy:e.retryPolicy,timeout:e.timeout,fetch:e.fetch}),this.views=new an(this,this.store.views),e.retryPolicy&&this.withRetryPolicy(e.retryPolicy),e.timeout!==void 0&&this.withTimeout(e.timeout),e.apikey&&this.withApiKey(e.apikey),this.onRequest=e.onRequest,this.onResponse=e.onResponse,this.sessionTags=e.sessionTags,this.oauthClients=new Ue(this),this.oauthGrants=new Ge(this),this.oauthServer=new qe(this,this.tokenServerUrl),this.oauthProviders=new Ke(this),this.remoteMcpConnections=new $e(this),this.secrets=new tt(this),this.internalSecrets=new He(this)}withApiVersion(e){return e?this.headers[Z]=String(e):delete this.headers[Z],this}withAppVersion(e){return e?this.headers[t]=String(e):delete this.headers[t],this}withAuthCallback(e){return this.store.withAuthCallback(e),super.withAuthCallback(e)}withRetryPolicy(e){return this.store.withRetryPolicy(e),super.withRetryPolicy(e)}withTimeout(e){return this.store.withTimeout(e),super.withTimeout(e)}async withApiKey(e){return this.withAuthCallback(e?async()=>{if(!on(e))return`Bearer ${e}`;if(sn(this._jwt)){let t=await this.getAuthToken(e);this._jwt=t.token}return`Bearer ${this._jwt}`}:void 0)}async getRawJWT(){if(!this._jwt&&this._auth){let e=await this._auth();this._jwt||=e.trim().split(` `)[1]}return this._jwt||null}async getDecodedJWT(){let e=await this.getRawJWT();return e?$(e):null}async getProject(){return(await this.getDecodedJWT())?.project||null}async getAccount(){return(await this.getDecodedJWT())?.account||null}get agents(){return this.store.agents}get workflows(){return this.store.workflows}get objects(){return this.store.objects}get files(){return this.store.files}get processes(){return this.store.processes}get tasks(){return this.store.tasks}get types(){return this.store.types}get data(){return this.store.data}get events(){return this.store.events}get storeUrl(){return this.store.baseUrl}async getAuthToken(e){return this.post(`${this.tokenServerUrl}/token/issue`,{headers:{"content-type":`application/json`,authorization:`Bearer ${e}`},retryPolicy:{attempts:4,methods:[`POST`],statuses:[429,500,502,503,504]}}).catch(e=>{throw console.error(`Error fetching token from ${this.tokenServerUrl}:`,{error:e}),e})}get initialHeaders(){return{...super.initialHeaders,[Z]:Yt}}projects=new Je(this);environments=new Ae(this);interactions=new Ve(this);skills=new nt(this);prompts=new Xe(this);runs=new et(this);account=new Ce(this);accounts=new we(this);apikeys=new Ee(this);analytics=new Te(this);auditTrail=new Oe(this);training=new nn(this);users=new rn(this);iam=new Me(this);refs=new Qe(this);commands=new ke(this);apps=new De(this);tools=new tn(this);quota=new Ze(this);views};function on(e){return e.startsWith(`pk-`)||e.startsWith(`sk-`)}function sn(e){if(!e)return!0;let t=$(e).exp;return Date.now()>=t*1e3-6e4}function $(e){let t=e.split(`.`)[1],n=un(t);return JSON.parse(n)}function cn(){return globalThis.Buffer}function ln(){return globalThis.process?.env?.STS_URL}function un(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=cn();if(n)return n.from(t,`base64`).toString(`utf-8`);if(typeof atob<`u`&&typeof TextDecoder<`u`){let e=atob(t),n=Uint8Array.from(e,e=>e.charCodeAt(0));return new TextDecoder().decode(n)}else throw Error(`No base64 decoder available`)}function dn(e){return e?typeof e==`string`?fn(e):e:fn(`api.vertesia.io`)}function fn(e){if(e===`local`)return{studio:`http://localhost:8091`,store:`http://localhost:8092`,token:ln()??`https://sts.dev1.vertesia.io`,git:`https://git.dev1.vertesia.io`};{let t=`https://${e}`;return{studio:t,store:t,token:t.replace(`api`,`sts`),git:t.replace(`api`,`git`)}}}var pn=class{id;client;constructor(e,t){this.id=e,t instanceof Q?this.client=t:this.client=new Q(t)}retrieve(){return this.client.interactions.retrieve(this.id)}update(e){return this.client.interactions.update(this.id,e)}render(e){throw Error(`Not implemented`)}async execute(e={},t){return P(this.client,this.id,e,t)}};export{e as APP_VERSION_HEADER,q as ARTIFACTS_PREFIX,pt as AgentsApi,vt as DataApi,yt as EmailApi,bt as EmbeddingsApi,Dt as EventIngestChannelsApi,kt as EventSubscriptionsApi,At as EventsApi,Ft as FilesApi,It as HiveMemoryApi,I as IS_INTERACTION_OUTPUT,Lt as IndexingApi,pn as InteractionBase,z as InteractionOutput,He as InternalSecretsApi,Nt as MEMORIES_PREFIX,Ue as OAuthClientsApi,Ge as OAuthGrantsApi,Ke as OAuthProvidersApi,qe as OAuthServerApi,zt as ObjectsApi,Bt as PendingAsksApi,o as Permission,Vt as ProcessApi,Ht as QueryApi,$e as RemoteMcpConnectionsApi,X as RenderingApi,Wt as SchedulesApi,tt as SecretsApi,Jt as StoreViewsApi,W as StreamSource,Gt as TaskApi,Kt as TypeCatalogApi,qt as TypesApi,Q as VertesiaClient,an as ViewsApi,Xt as WorkflowsApi,Qt as WorkflowsDefinitionApi,Zt as WorkflowsRulesApi,en as ZenoClient,jt as ZenoClientNotFoundError,c as canGenerateRendition,V as createInteractionOutput,dn as decodeEndpoints,$ as decodeJWT,R as enhanceExecutionRun,L as enhanceInteractionExecutionResult,H as fetchSignedUrl,Y as getAgentArtifactPath,J as getMemoryFilePath,l as getOAuthPermissionScopes,u as getSupportedRenditionFormats,sn as isTokenExpired,Tt as openManagedEventSource,p as supportsVisualRendition};
|
|
14
14
|
//# sourceMappingURL=vertesia-client.js.map
|