@opengeni/sdk 1.4.5-canary.38533006839001 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/adapters/next.js +2 -2
  2. package/dist/app-links.d.ts +42 -0
  3. package/dist/app-links.js +66 -0
  4. package/dist/app-links.js.map +1 -0
  5. package/dist/artifacts.js +4 -4
  6. package/dist/browser.js +2 -2
  7. package/dist/chat/index.js +5 -5
  8. package/dist/{chunk-CB2QVEMQ.js → chunk-7ZYDT364.js} +2 -2
  9. package/dist/{chunk-R4MQAGWV.js → chunk-ACYSTGHF.js} +2 -2
  10. package/dist/{chunk-AJXCH4PE.js → chunk-DVJAK3RA.js} +3 -3
  11. package/dist/{chunk-AJXCH4PE.js.map → chunk-DVJAK3RA.js.map} +1 -1
  12. package/dist/{chunk-XWTZPBQE.js → chunk-LHDKZT6R.js} +2 -2
  13. package/dist/{chunk-XWTZPBQE.js.map → chunk-LHDKZT6R.js.map} +1 -1
  14. package/dist/{chunk-D25GBNYN.js → chunk-W6PTFKPT.js} +2 -2
  15. package/dist/{chunk-D4DNZIPL.js → chunk-YS56XJYT.js} +2 -2
  16. package/dist/{chunk-LM66IGL2.js → chunk-ZHHHRWBL.js} +1 -1
  17. package/dist/{chunk-LM66IGL2.js.map → chunk-ZHHHRWBL.js.map} +1 -1
  18. package/dist/client.d.ts +1 -1
  19. package/dist/core.js +3 -3
  20. package/dist/document-authority.js +3 -3
  21. package/dist/editable-artifacts.js +1 -1
  22. package/dist/index.js +7 -7
  23. package/dist/message-links.d.ts +1 -1
  24. package/dist/session-proxy.js +2 -2
  25. package/dist/site.js +3 -3
  26. package/dist/types.d.ts +5 -3
  27. package/package.json +7 -3
  28. package/src/app-links.ts +117 -0
  29. package/src/client.ts +1 -1
  30. package/src/message-links.ts +1 -1
  31. package/src/types.ts +5 -3
  32. /package/dist/{chunk-CB2QVEMQ.js.map → chunk-7ZYDT364.js.map} +0 -0
  33. /package/dist/{chunk-R4MQAGWV.js.map → chunk-ACYSTGHF.js.map} +0 -0
  34. /package/dist/{chunk-D25GBNYN.js.map → chunk-W6PTFKPT.js.map} +0 -0
  35. /package/dist/{chunk-D4DNZIPL.js.map → chunk-YS56XJYT.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createSessionProxyHandler
3
- } from "../chunk-XWTZPBQE.js";
3
+ } from "../chunk-LHDKZT6R.js";
4
4
  import "../chunk-UM4ZXXJR.js";
5
5
  import "../chunk-QGEIL4TR.js";
6
6
  import "../chunk-UPTXNM2T.js";
7
- import "../chunk-LM66IGL2.js";
7
+ import "../chunk-ZHHHRWBL.js";
8
8
  import "../chunk-HTFTNJ5Y.js";
9
9
 
10
10
  // src/adapters/next.ts
@@ -0,0 +1,42 @@
1
+ /** A deployment address as typed: trimmed, https by default, no trailing slash. */
2
+ export declare function normalizeServerUrl(input: string): string | null;
3
+ /** The host a person recognizes, e.g. app.opengeni.ai. */
4
+ export declare function serverLabel(baseUrl: string): string;
5
+ /** The part of a signed-in app account that link routing reads. */
6
+ export interface AppLinkAccount {
7
+ id: string;
8
+ /** The deployment's web origin, e.g. https://app.opengeni.ai. */
9
+ baseUrl: string;
10
+ /** The workspace last used with this account. */
11
+ workspaceId: string | null;
12
+ /** Set when the deployment rejected the credential. */
13
+ signedOut?: boolean;
14
+ }
15
+ /**
16
+ * A web link the app can show itself: a conversation or a workspace on some
17
+ * deployment. Everything else on the web (settings, organization, artifacts)
18
+ * stays in the browser.
19
+ */
20
+ export interface AppLink {
21
+ /** The deployment's origin, normalized like a stored account's baseUrl. */
22
+ origin: string;
23
+ /** Absent for the web's workspace-less `/sessions/:id` links. */
24
+ workspaceId: string | null;
25
+ /** Absent for a link to the workspace itself. */
26
+ sessionId: string | null;
27
+ /** The session moment the link points at (`?at=`). */
28
+ at: number | null;
29
+ /** The web address the link came from, for the browser fallback. */
30
+ webUrl: string;
31
+ }
32
+ /** The web link a raw URL points at, unwrapping the web's "Open in app" handoff. */
33
+ export declare function parseAppLink(raw: string): AppLink | null;
34
+ /**
35
+ * The signed-in account a link belongs to, or null when the app has none on
36
+ * that deployment (the browser opens it instead). With several accounts on the
37
+ * same deployment: the one last used in the link's workspace, else the active
38
+ * one, else the first.
39
+ */
40
+ export declare function accountForAppLink<Account extends AppLinkAccount>(link: AppLink, accounts: readonly Account[], activeId: string | null): Account | null;
41
+ /** The web's handoff link that opens a web page in the app. */
42
+ export declare function appHandoffUrl(webUrl: string): string;
@@ -0,0 +1,66 @@
1
+ // src/app-links.ts
2
+ function normalizeServerUrl(input) {
3
+ const raw = input.trim();
4
+ if (!raw) return null;
5
+ const withScheme = /^[a-z][a-z0-9+.-]*:\/\//iu.test(raw) ? raw : `https://${raw}`;
6
+ const match = /^(https?):\/\/([a-z0-9.-]+(?::\d{1,5})?)(?:[/?#].*)?$/iu.exec(withScheme);
7
+ return match ? `${match[1].toLowerCase()}://${match[2].toLowerCase()}` : null;
8
+ }
9
+ function serverLabel(baseUrl) {
10
+ return baseUrl.replace(/^https?:\/\//iu, "");
11
+ }
12
+ var HANDOFF = /^opengeni:\/\/open\/?\?(.*)$/iu;
13
+ var WEB_URL = /^(https?:\/\/[^/?#]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/iu;
14
+ var ID = "([A-Za-z0-9][A-Za-z0-9_-]{0,127})";
15
+ var SESSION_PATH = new RegExp(`^/workspaces/${ID}/sessions/${ID}/?$`, "u");
16
+ var WORKSPACE_PATH = new RegExp(`^/workspaces/${ID}(?:/sessions)?/?$`, "u");
17
+ var BARE_SESSION_PATH = new RegExp(`^/sessions/${ID}/?$`, "u");
18
+ function queryParam(query, name) {
19
+ for (const part of (query ?? "").replace(/^\?/u, "").split("&")) {
20
+ const [key, value = ""] = part.split("=");
21
+ if (key !== name) continue;
22
+ try {
23
+ return decodeURIComponent(value.replace(/\+/gu, " "));
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+ return null;
29
+ }
30
+ function parseAppLink(raw) {
31
+ const trimmed = raw.trim();
32
+ const handoff = HANDOFF.exec(trimmed);
33
+ const webUrl = handoff ? queryParam(handoff[1], "url") : trimmed;
34
+ if (!webUrl) return null;
35
+ const match = WEB_URL.exec(webUrl);
36
+ if (!match) return null;
37
+ const origin = normalizeServerUrl(match[1]);
38
+ if (!origin) return null;
39
+ const path = match[2] ?? "/";
40
+ const atRaw = queryParam(match[3], "at");
41
+ const at = atRaw && /^[1-9][0-9]{0,15}$/u.test(atRaw) ? Number(atRaw) : null;
42
+ const session = SESSION_PATH.exec(path);
43
+ if (session) return { origin, workspaceId: session[1], sessionId: session[2], at, webUrl };
44
+ const bare = BARE_SESSION_PATH.exec(path);
45
+ if (bare) return { origin, workspaceId: null, sessionId: bare[1], at, webUrl };
46
+ const workspace = WORKSPACE_PATH.exec(path);
47
+ if (workspace) return { origin, workspaceId: workspace[1], sessionId: null, at: null, webUrl };
48
+ return null;
49
+ }
50
+ function accountForAppLink(link, accounts, activeId) {
51
+ const candidates = accounts.filter(
52
+ (account) => !account.signedOut && normalizeServerUrl(account.baseUrl) === link.origin
53
+ );
54
+ return (link.workspaceId ? candidates.find((account) => account.workspaceId === link.workspaceId) : void 0) ?? candidates.find((account) => account.id === activeId) ?? candidates[0] ?? null;
55
+ }
56
+ function appHandoffUrl(webUrl) {
57
+ return `opengeni://open?url=${encodeURIComponent(webUrl)}`;
58
+ }
59
+ export {
60
+ accountForAppLink,
61
+ appHandoffUrl,
62
+ normalizeServerUrl,
63
+ parseAppLink,
64
+ serverLabel
65
+ };
66
+ //# sourceMappingURL=app-links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/app-links.ts"],"sourcesContent":["// Opengeni web links that a native app (phone or desktop) can show itself, and\n// the account each belongs to. Pure: no platform modules, so every app shares it.\n\n/** A deployment address as typed: trimmed, https by default, no trailing slash. */\nexport function normalizeServerUrl(input: string): string | null {\n const raw = input.trim();\n if (!raw) return null;\n const withScheme = /^[a-z][a-z0-9+.-]*:\\/\\//iu.test(raw) ? raw : `https://${raw}`;\n const match = /^(https?):\\/\\/([a-z0-9.-]+(?::\\d{1,5})?)(?:[/?#].*)?$/iu.exec(withScheme);\n return match ? `${match[1]!.toLowerCase()}://${match[2]!.toLowerCase()}` : null;\n}\n\n/** The host a person recognizes, e.g. app.opengeni.ai. */\nexport function serverLabel(baseUrl: string): string {\n return baseUrl.replace(/^https?:\\/\\//iu, \"\");\n}\n\n/** The part of a signed-in app account that link routing reads. */\nexport interface AppLinkAccount {\n id: string;\n /** The deployment's web origin, e.g. https://app.opengeni.ai. */\n baseUrl: string;\n /** The workspace last used with this account. */\n workspaceId: string | null;\n /** Set when the deployment rejected the credential. */\n signedOut?: boolean;\n}\n\n/**\n * A web link the app can show itself: a conversation or a workspace on some\n * deployment. Everything else on the web (settings, organization, artifacts)\n * stays in the browser.\n */\nexport interface AppLink {\n /** The deployment's origin, normalized like a stored account's baseUrl. */\n origin: string;\n /** Absent for the web's workspace-less `/sessions/:id` links. */\n workspaceId: string | null;\n /** Absent for a link to the workspace itself. */\n sessionId: string | null;\n /** The session moment the link points at (`?at=`). */\n at: number | null;\n /** The web address the link came from, for the browser fallback. */\n webUrl: string;\n}\n\n/** The app's own scheme for links handed over from the web: opengeni://open?url=… */\nconst HANDOFF = /^opengeni:\\/\\/open\\/?\\?(.*)$/iu;\nconst WEB_URL = /^(https?:\\/\\/[^/?#]+)(\\/[^?#]*)?(\\?[^#]*)?(#.*)?$/iu;\nconst ID = \"([A-Za-z0-9][A-Za-z0-9_-]{0,127})\";\nconst SESSION_PATH = new RegExp(`^/workspaces/${ID}/sessions/${ID}/?$`, \"u\");\nconst WORKSPACE_PATH = new RegExp(`^/workspaces/${ID}(?:/sessions)?/?$`, \"u\");\nconst BARE_SESSION_PATH = new RegExp(`^/sessions/${ID}/?$`, \"u\");\n\nfunction queryParam(query: string | undefined, name: string): string | null {\n for (const part of (query ?? \"\").replace(/^\\?/u, \"\").split(\"&\")) {\n const [key, value = \"\"] = part.split(\"=\");\n if (key !== name) continue;\n try {\n return decodeURIComponent(value.replace(/\\+/gu, \" \"));\n } catch {\n return null;\n }\n }\n return null;\n}\n\n/** The web link a raw URL points at, unwrapping the web's \"Open in app\" handoff. */\nexport function parseAppLink(raw: string): AppLink | null {\n const trimmed = raw.trim();\n const handoff = HANDOFF.exec(trimmed);\n const webUrl = handoff ? queryParam(handoff[1], \"url\") : trimmed;\n if (!webUrl) return null;\n const match = WEB_URL.exec(webUrl);\n if (!match) return null;\n const origin = normalizeServerUrl(match[1]!);\n if (!origin) return null;\n const path = match[2] ?? \"/\";\n const atRaw = queryParam(match[3], \"at\");\n const at = atRaw && /^[1-9][0-9]{0,15}$/u.test(atRaw) ? Number(atRaw) : null;\n const session = SESSION_PATH.exec(path);\n if (session) return { origin, workspaceId: session[1]!, sessionId: session[2]!, at, webUrl };\n const bare = BARE_SESSION_PATH.exec(path);\n if (bare) return { origin, workspaceId: null, sessionId: bare[1]!, at, webUrl };\n const workspace = WORKSPACE_PATH.exec(path);\n if (workspace) return { origin, workspaceId: workspace[1]!, sessionId: null, at: null, webUrl };\n return null;\n}\n\n/**\n * The signed-in account a link belongs to, or null when the app has none on\n * that deployment (the browser opens it instead). With several accounts on the\n * same deployment: the one last used in the link's workspace, else the active\n * one, else the first.\n */\nexport function accountForAppLink<Account extends AppLinkAccount>(\n link: AppLink,\n accounts: readonly Account[],\n activeId: string | null,\n): Account | null {\n const candidates = accounts.filter(\n (account) => !account.signedOut && normalizeServerUrl(account.baseUrl) === link.origin,\n );\n return (\n (link.workspaceId\n ? candidates.find((account) => account.workspaceId === link.workspaceId)\n : undefined) ??\n candidates.find((account) => account.id === activeId) ??\n candidates[0] ??\n null\n );\n}\n\n/** The web's handoff link that opens a web page in the app. */\nexport function appHandoffUrl(webUrl: string): string {\n return `opengeni://open?url=${encodeURIComponent(webUrl)}`;\n}\n"],"mappings":";AAIO,SAAS,mBAAmB,OAA8B;AAC/D,QAAM,MAAM,MAAM,KAAK;AACv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M,CAAC,KAAK;AACzB,QAAM,QAAQ,WAAW,MAAM,CAAC,GAAG,IAAI;AACvC,QAAM,KAAK,SAAS,sBAAsB,KAAK,KAAK,IAAI,OAAO,KAAK,IAAI;AACxE,QAAM,UAAU,aAAa,KAAK,IAAI;AACtC,MAAI,QAAS,QAAO,EAAE,QAAQ,aAAa,QAAQ,CAAC,GAAI,WAAW,QAAQ,CAAC,GAAI,IAAI,OAAO;AAC3F,QAAM,OAAO,kBAAkB,KAAK,IAAI;AACxC,MAAI,KAAM,QAAO,EAAE,QAAQ,aAAa,MAAM,WAAW,KAAK,CAAC,GAAI,IAAI,OAAO;AAC9E,QAAM,YAAY,eAAe,KAAK,IAAI;AAC1C,MAAI,UAAW,QAAO,EAAE,QAAQ,aAAa,UAAU,CAAC,GAAI,WAAW,MAAM,IAAI,MAAM,OAAO;AAC9F,SAAO;AACT;AAQO,SAAS,kBACd,MACA,UACA,UACgB;AAChB,QAAM,aAAa,SAAS;AAAA,IAC1B,CAAC,YAAY,CAAC,QAAQ,aAAa,mBAAmB,QAAQ,OAAO,MAAM,KAAK;AAAA,EAClF;AACA,UACG,KAAK,cACF,WAAW,KAAK,CAAC,YAAY,QAAQ,gBAAgB,KAAK,WAAW,IACrE,WACJ,WAAW,KAAK,CAAC,YAAY,QAAQ,OAAO,QAAQ,KACpD,WAAW,CAAC,KACZ;AAEJ;AAGO,SAAS,cAAc,QAAwB;AACpD,SAAO,uBAAuB,mBAAmB,MAAM,CAAC;AAC1D;","names":[]}
package/dist/artifacts.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  OpenGeniClient
3
- } from "./chunk-D4DNZIPL.js";
4
- import "./chunk-CB2QVEMQ.js";
5
- import "./chunk-AJXCH4PE.js";
3
+ } from "./chunk-YS56XJYT.js";
4
+ import "./chunk-7ZYDT364.js";
5
+ import "./chunk-DVJAK3RA.js";
6
6
  import "./chunk-VPVMLM7Q.js";
7
7
  import "./chunk-UPTXNM2T.js";
8
- import "./chunk-LM66IGL2.js";
8
+ import "./chunk-ZHHHRWBL.js";
9
9
  import "./chunk-W3DHELJ6.js";
10
10
  import "./chunk-HTFTNJ5Y.js";
11
11
  export {
package/dist/browser.js CHANGED
@@ -8,13 +8,13 @@ import {
8
8
  } from "./chunk-HINIVNYI.js";
9
9
  import {
10
10
  OpenGeniClient
11
- } from "./chunk-AJXCH4PE.js";
11
+ } from "./chunk-DVJAK3RA.js";
12
12
  import "./chunk-VPVMLM7Q.js";
13
13
  import "./chunk-UPTXNM2T.js";
14
14
  import {
15
15
  OPENGENI_API_CONTRACT_HEADER,
16
16
  OPENGENI_API_CONTRACT_REVISION
17
- } from "./chunk-LM66IGL2.js";
17
+ } from "./chunk-ZHHHRWBL.js";
18
18
  import "./chunk-W3DHELJ6.js";
19
19
  import {
20
20
  OpenGeniAllowanceExhaustedError,
@@ -11,18 +11,18 @@ import {
11
11
  EMPTY_FINAL_REPLY_NOTICE,
12
12
  OpenGeniEmbeddingClient,
13
13
  turnCompletedWithEmptyFinalReply
14
- } from "../chunk-R4MQAGWV.js";
15
- import "../chunk-D4DNZIPL.js";
16
- import "../chunk-CB2QVEMQ.js";
14
+ } from "../chunk-ACYSTGHF.js";
15
+ import "../chunk-YS56XJYT.js";
16
+ import "../chunk-7ZYDT364.js";
17
17
  import {
18
18
  chatDefaults
19
19
  } from "../chunk-UM4ZXXJR.js";
20
- import "../chunk-AJXCH4PE.js";
20
+ import "../chunk-DVJAK3RA.js";
21
21
  import "../chunk-VPVMLM7Q.js";
22
22
  import {
23
23
  parseSseStream
24
24
  } from "../chunk-UPTXNM2T.js";
25
- import "../chunk-LM66IGL2.js";
25
+ import "../chunk-ZHHHRWBL.js";
26
26
  import "../chunk-W3DHELJ6.js";
27
27
  import {
28
28
  OpenGeniApiError,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OpenGeniClient
3
- } from "./chunk-AJXCH4PE.js";
3
+ } from "./chunk-DVJAK3RA.js";
4
4
 
5
5
  // src/document-authority-client.ts
6
6
  var OpenGeniDocumentAuthorityClient = class extends OpenGeniClient {
@@ -147,4 +147,4 @@ var OpenGeniDocumentAuthorityClient = class extends OpenGeniClient {
147
147
  export {
148
148
  OpenGeniDocumentAuthorityClient
149
149
  };
150
- //# sourceMappingURL=chunk-CB2QVEMQ.js.map
150
+ //# sourceMappingURL=chunk-7ZYDT364.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OpenGeniClient
3
- } from "./chunk-D4DNZIPL.js";
3
+ } from "./chunk-YS56XJYT.js";
4
4
 
5
5
  // src/embedding-client.ts
6
6
  function hasStaticHeader(options, names) {
@@ -337,4 +337,4 @@ export {
337
337
  EMPTY_FINAL_REPLY_NOTICE,
338
338
  turnCompletedWithEmptyFinalReply
339
339
  };
340
- //# sourceMappingURL=chunk-R4MQAGWV.js.map
340
+ //# sourceMappingURL=chunk-ACYSTGHF.js.map
@@ -15,7 +15,7 @@ import {
15
15
  OPENGENI_API_CONTRACT_REVISION,
16
16
  OPENGENI_CORRELATION_HEADER,
17
17
  RETAINED_OUTPUT_MAX_PAGE_BYTES
18
- } from "./chunk-LM66IGL2.js";
18
+ } from "./chunk-ZHHHRWBL.js";
19
19
  import {
20
20
  OpenGeniInteractionClient,
21
21
  decodeComputerFrameMetadataHeader,
@@ -1833,7 +1833,7 @@ var OpenGeniClient = class {
1833
1833
  );
1834
1834
  }
1835
1835
  /** Open one macOS Privacy & Security pane on a connected Mac, so the person
1836
- * only has to flip the permission for OpenGeni. */
1836
+ * only has to flip the permission for Opengeni. */
1837
1837
  async openMachinePrivacySettings(workspaceId, enrollmentId, input) {
1838
1838
  return await this.requestJson(
1839
1839
  "POST",
@@ -7615,4 +7615,4 @@ export {
7615
7615
  parseMediaGenerationResult,
7616
7616
  OpenGeniClient
7617
7617
  };
7618
- //# sourceMappingURL=chunk-AJXCH4PE.js.map
7618
+ //# sourceMappingURL=chunk-DVJAK3RA.js.map