@isomorph.ai/app-sdk 1.5.0 → 1.5.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 (3) hide show
  1. package/README.md +18 -0
  2. package/dist/index.js +23 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,3 +61,21 @@ App code declares exact HTTPS pages and named click/fill selectors reviewed for
61
61
  `isomorph dev` uses canned server-model fixtures. `dev --real` supplies an approved development connection to the action process. Hosted actions resolve their exact ACTIVE version key. The current V2 PLAN is published after LIVE; before key activation, an AI action fails and later actions retry. LIVE alone is not AI acceptance.
62
62
 
63
63
  Requires compatible SDK/CLI/toolkit publication, gateway protocol fixes, governance connection routes and V2 packaging/version wiring. No deployment is claimed here. Real model/file authorization and hosted Chromium sandbox checks remain release acceptance. Search, company skills, integration/browser writes, video, audio, STT, TTS and realtime audio are deferred.
64
+
65
+ ## Where the browser client sends its calls
66
+
67
+ `createClient()` with no `baseUrl` picks its base URL like this:
68
+
69
+ - In Node (the retained-check runner, the kit runtime), `ISOMORPH_GATEWAY_URL`.
70
+ - In a browser, `window.__isomorphApiOrigin` when it is an `http(s)` origin
71
+ string such as `https://fourier-app-x.api.preview.beta.apps.isomorph.ai`.
72
+ A deployed kit page carries the platform's credential shim, a `<script>` in
73
+ `<head>` that sets this global to the app's own API host and wraps
74
+ `window.fetch` so calls there carry the sign-in cookie; the realtime socket
75
+ and `files.getPublicUrl` follow the same host. Nothing in the app sets it.
76
+ - Otherwise the page-relative default (`''`, or `/p/<org>.<app>` on the
77
+ shared edge): a local `isomorph run` and a page without the shim are
78
+ unchanged.
79
+
80
+ A value that is not an `http(s)` origin — a path, a trailing slash, another
81
+ scheme, a non-string — is ignored. An explicit `baseUrl` always wins.
package/dist/index.js CHANGED
@@ -145,6 +145,11 @@ class Transport {
145
145
  constructor(options, onUnauthorized) {
146
146
  this.onUnauthorized = onUnauthorized;
147
147
  this.baseUrl = (options.baseUrl ?? applicationBaseUrl()).replace(/\/$/, '');
148
+ // Captured here, at createClient() time, not when this module is
149
+ // evaluated: a kit page's credential shim (a plain <script> in <head>)
150
+ // wraps window.fetch before any module script runs, so the fetch bound
151
+ // below is the wrapped one, and a call to the API origin leaves with
152
+ // credentials: 'include' although the transport asks for 'same-origin'.
148
153
  this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
149
154
  this.identity = options.identity;
150
155
  }
@@ -192,9 +197,27 @@ function applicationBaseUrl() {
192
197
  const runtime = globalThis.process;
193
198
  return (runtime?.env?.ISOMORPH_GATEWAY_URL ?? '').replace(/\/$/, '');
194
199
  }
200
+ // A kit page served from CloudFront talks to its own API host, not to the
201
+ // page origin: the transform injects the credential shim into the page and
202
+ // the shim publishes that host as window.__isomorphApiOrigin (an origin,
203
+ // https://<org>-<app>.api.<zone>, no path). Anything that is not an http(s)
204
+ // origin is ignored, so a page without the shim (isomorph run, a git app on
205
+ // the shared edge) keeps the page-relative base URL below.
206
+ const apiOrigin = globalThis.__isomorphApiOrigin;
207
+ if (typeof apiOrigin === 'string' && isHttpOrigin(apiOrigin))
208
+ return apiOrigin;
195
209
  const match = /^\/p\/([a-z0-9-]+\.[a-z0-9-]+)(?:\/|$)/.exec(location.pathname);
196
210
  return match ? `/p/${match[1]}` : '';
197
211
  }
212
+ function isHttpOrigin(value) {
213
+ try {
214
+ const url = new URL(value);
215
+ return (url.protocol === 'https:' || url.protocol === 'http:') && url.origin === value;
216
+ }
217
+ catch {
218
+ return false;
219
+ }
220
+ }
198
221
  // Result is what awaiting the builder resolves to: T[] for a list query, T
199
222
  // after .single(), T | null after .maybeSingle(). The gateway applies the
200
223
  // cardinality; the type follows it so a reader of these declarations sees the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isomorph.ai/app-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",