@usecontextlayer/sdk 0.14.2 → 0.14.3

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/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # @usecontextlayer/sdk
2
2
 
3
- ContextLayer integration for React Router apps: the shared document Layout and Tools capability. In local development, tool calls execute through the ContextLayer platform using the manifest-selected viewer or app Owner's assigned Composio Platform connections.
3
+ ContextLayer integration for React Router apps: the shared document Layout and Tools capability. Local tool calls use the signed-in developer's personal accounts and current-folder connection bindings. Hosted calls use pushed requirements and platform-stored viewer/app-Owner assignments.
4
4
 
5
5
  Create an app with `npx @usecontextlayer/cli init my-app`. The CLI installs this package and configures a development-only Cloudflare Worker and native service binding. Use the generated app's normal `pnpm dev` command. First-party `@usecontextlayer/*` packages are exempt from pnpm's release-age policy in generated projects.
6
6
 
7
7
  ## Local login and assignment
8
8
 
9
- Run `ctx login` to save your ContextLayer login. Declare `work-email` as a viewer-mode Gmail requirement in `public/slate.json`, then use `ctx connections list` to find your connection and `ctx connection local assign work-email <connection_id>` to assign it. Run local commands from the app root.
9
+ Declare resources in `public/slate.json` and `agents/<name>/slate.json`, using the same Slate schema and shared resource names. Local commands read only the current app folder. Use the connection commands' `--help` for listing, personal account authorization, and assignment syntax. Local listing needs no login or push; choosing an account requires a matching `ctx login`. Account choices are saved in ignored `.contextlayer/connections.json` rather than production assignments.
10
10
 
11
- For an organization-owned app's owner-mode requirement, authorize and list the account under the organization before assigning it. The connection commands' `--help` owns organization selection. The member completes OAuth for that Owner, and the platform uses the same organization's Composio identity when executing the requirement.
11
+ Local development always uses your personal accounts, including owner-mode requirements in organization-owned apps. Local secrets read environment variables with exactly their declared names; local folders are generated under `.contextlayer/folders/<slug>`. Tooling ignores `.contextlayer/` in Git. Folder construction supplies paths, not an app or agent filesystem capability.
12
12
 
13
- When `pnpm dev` starts, `contextlayer(env)` from `@usecontextlayer/sdk/vite` configures the Cloudflare Vite plugin and calls the CLI-owned `getLocalToolsBindings` helper. This Node helper reads the AppID from Git origin, validates `public/slate.json`, and obtains a current access token using the same saved login as the CLI. The AppID, typed CLI credential, and parsed manifest startup snapshot become native props on the Tools service binding. Only the platform URL enters the auxiliary Worker’s environment. The Worker re-exports the same Tools implementation used by dispatcher. The refresh token stays in `~/.contextlayer/auth.json`; the Composio project key stays on the platform. Restart `pnpm dev` when the access token expires or the manifest changes.
13
+ When `pnpm dev` starts, `contextlayer(env)` from `@usecontextlayer/sdk/vite` configures the Cloudflare Vite plugin and calls the CLI-owned `getLocalToolsBindings` helper. This helper assembles the complete current-folder configuration before selecting the app consumer through `resourcesForConsumer`. Only the app's resolved connection entries, the AppID from Git origin, and the CLI access token become trusted native Tools service-binding props. Agent-only connections, secret values, folder paths, and local declarations are not sent to platform or browser code. The AppID supplies app access/subscription/usage context independently of personal credential ownership.
14
+
15
+ The auxiliary Worker exports the shared `LocalTools` entrypoint as `Tools`. It resolves the requested slug to the startup account ID and declaration toolkit, then calls the personal concrete-account endpoint. Unknown or unassigned local slugs fail locally; there is no production-assignment fallback. The refresh token stays in `~/.contextlayer/auth.json`; the Composio project key stays on platform. Restart `pnpm dev` when the access token expires or declarations/local configuration change.
14
16
 
15
17
  ## App Layout
16
18
 
@@ -20,15 +22,15 @@ The generated `app/root.tsx` re-exports the SDK's document Layout:
20
22
  export { Layout } from "@usecontextlayer/sdk/react"
21
23
  ```
22
24
 
23
- The Layout owns the HTML document, React Router's metadata, links, scripts, scroll restoration, and the shared ContextLayer header. The app owns its routes, root component, error boundary, stylesheet, and font links. The thin, full-width header has separate wordmark, connected-services, and viewer sections. The entire connected-services section toggles its inline connection tray, moving the app content down. The wordmark and identity are plain content; anonymous viewers see “Not signed in” without services controls. The tray lists required services and saved accounts, with account controls for Owners the viewer can manage.
25
+ The Layout owns the HTML document, React Router's metadata, links, scripts, scroll restoration, and the hosted ContextLayer header. Native Vite development detection disables the header locally, so local configuration never enters the platform frame. The app owns its routes, root component, error boundary, stylesheet, and font links. The thin, full-width header has separate wordmark, connected-services, and viewer sections. The entire connected-services section toggles its inline connection tray, moving the app content down. The wordmark and identity are plain content; anonymous viewers see “Not signed in” without services controls. The tray lists required services and saved accounts, with account controls for Owners the viewer can manage.
24
26
 
25
27
  The header and tray are served by platform in a cross-origin iframe on slate.usecontextlayer.com. Platform owns their styles, Fugaz One font, and data loading. Layout receives only a height message and resizes the frame to keep the expanding tray in document flow. The app's Tailwind/shadcn setup is independent; there is no SDK stylesheet export or chrome root loader.
26
28
 
27
- The frame authenticates directly with the native web session. Its cookie always uses Secure, HttpOnly, and SameSite=None, in every environment. When browser third-party-cookie policy permits delivery, the existing web login authenticates the header automatically, without a separate sign-in or frame cookie. Web logout revokes subsequent frame authentication. The surrounding authored page receives neither credentials nor chrome data. S4 remains incomplete pending deployed private-app acceptance.
29
+ The frame authenticates directly with the native web session. Its cookie always uses Secure, HttpOnly, and SameSite=None, in every environment. When browser third-party-cookie policy permits delivery, the existing web login authenticates the header automatically, without a separate sign-in or frame cookie. Web logout revokes subsequent frame authentication. The surrounding authored page receives neither credentials nor chrome data. Hosted private-app cookie delivery still requires deployed browser verification.
28
30
 
29
31
  ## A loader that reads Gmail
30
32
 
31
- The first argument is the connection requirement slug in `public/slate.json`, such as `work-email`. Its manifest mode selects the acting user's assignment (`viewer`) or the app's owning user or organization's assignment (`owner`):
33
+ The first argument is the connection requirement slug in `public/slate.json`, such as `work-email`. Locally it selects your saved personal account; in hosted execution the pushed declaration selects the acting user's assignment (`viewer`) or the app's owning user or organization's assignment (`owner`):
32
34
 
33
35
  ```ts
34
36
  import { toolsContext } from "@usecontextlayer/sdk"
@@ -48,9 +50,9 @@ Calls return `{ data, logId }`. Validate the tool-specific `data` in your loader
48
50
 
49
51
  ## Runtime ownership
50
52
 
51
- The package root exports the `Tools` interface and `toolsContext`. `@usecontextlayer/sdk/react` exports the shared document Layout, which mounts platform’s chrome iframe. `@usecontextlayer/sdk/local` bundles and re-exports the shared `Tools` Worker entrypoint, also used by dispatcher. `@usecontextlayer/sdk/worker` exports `createApp`, which creates the React Router request handler and supplies Tools from local bindings or production request props. `@usecontextlayer/sdk/vite` owns the `contextlayer` integration. The CLI package owns the Node startup helper and saved-login handling. The generated application supplies its virtual server-build import, mode, and development flag through thin Worker wiring. The Cloudflare Vite plugin runs the auxiliary Worker only in development; production bundles exclude it and its service binding. Profile and connection reads belong to the trusted chrome frame; the SDK exposes no Viewer or Connections capability.
53
+ The package root exports the `Tools` interface and `toolsContext`. `@usecontextlayer/sdk/react` exports the shared document Layout, which mounts platform's chrome iframe only outside development. `@usecontextlayer/sdk/local` bundles the shared `LocalTools` entrypoint and exports it as `Tools`; dispatcher separately exports hosted `Tools`. Both entrypoints share HTTP result/error handling and preserve the authored `tools.call` interface. `@usecontextlayer/sdk/worker` exports `createApp`, which creates the React Router request handler and supplies Tools from local bindings or production request props. `@usecontextlayer/sdk/vite` owns the `contextlayer` integration. The CLI package owns the Node startup helper and saved-login handling. The generated application supplies its virtual server-build import, mode, and development flag through thin Worker wiring. The Cloudflare Vite plugin runs the auxiliary Worker only in development; production bundles exclude it and its service binding. Profile and connection reads belong to the trusted chrome frame; the SDK exposes no Viewer or Connections capability.
52
54
 
53
- In hosted apps, the dispatcher supplies `ctx.props.tools` as a request-scoped RPC handle. Its methods call the same platform execution API using the viewer session; the app cannot read the underlying viewer credential. That session authenticates the caller, while the deployed manifest's mode selects the viewer or app Owner's assignment for the app and slug. For viewer-mode requirements, a viewer using the same account as the CLI uses the same saved assignment. Owner-mode requirements use the app Owner's configured account. Local access-token bindings are not included in production builds.
55
+ In hosted apps, the dispatcher supplies `ctx.props.tools` as a request-scoped RPC handle. Its methods call the hosted slug-based platform execution API using the viewer session; the app cannot read the underlying viewer credential. That session authenticates the caller, while the coherent pushed declaration's mode selects the viewer or app Owner's assignment for the app and slug. Viewer-mode requirements use that viewer's production assignment. Local connection choices remain separate even when the developer is also a production viewer. Owner-mode requirements use the app Owner's configured account. Local access-token bindings are not included in production builds.
54
56
 
55
57
  ## Vite configuration
56
58
 
@@ -68,7 +70,7 @@ export default defineConfig((env) => ({
68
70
  }))
69
71
  ```
70
72
 
71
- This integration supplies the Cloudflare plugin; do not add a second instance. It uses the generated `workers/local-tools/wrangler.jsonc` to start the local Tools Worker and provides its development-only Tools service binding. At development startup, the CLI reads the app's Git origin, saved ContextLayer login, and validated manifest snapshot. The restart prerequisites are described under [Local login and assignment](#local-login-and-assignment). Production builds exclude local credentials and the auxiliary Worker.
73
+ This integration supplies the Cloudflare plugin; do not add a second instance. It uses the generated `workers/local-tools/wrangler.jsonc` to start the local Tools Worker and provides its development-only Tools service binding. At development startup, the CLI reads the app's Git origin, saved ContextLayer login, and assembled current-folder configuration. The restart prerequisites are described under [Local login and assignment](#local-login-and-assignment). Production builds exclude local credentials and the auxiliary Worker.
72
74
 
73
75
  The app retains its routes, `public/slate.json`, and thin Worker/configuration files. `@usecontextlayer/sdk/worker` owns the React Router request handler and capability context setup.
74
76
 
@@ -76,6 +78,6 @@ The app retains its routes, `public/slate.json`, and thin Worker/configuration f
76
78
 
77
79
  The platform frame loader reads the browser viewer's profile and requirement/assignment rows through the shared app-connection listing operation. Signed-in viewers can inspect their required services and select accounts through each row's controls. The connected-services status counts missing assignments; it does not validate provider status. Anonymous frames show “Not signed in” without a connection status or tray. These data stay in the frame.
78
80
 
79
- The canonical manifest and viewer/owner requirements live in `@usecontextlayer/shared/slate`. The neutral requirement/assignment response in `@usecontextlayer/shared/app-connections` is shared by platform and CLI. Selecting an account saves the assignment and React Router revalidates the tray automatically. Connect account opens authorization in a new tab; refresh the app page afterward to select the new account. Changes made elsewhere appear on the next frame load. The tray does not refresh the app's route data. The local Vite integration exposes the AppID, platform URL, and validated manifest snapshot as non-secret browser configuration; credentials remain behind the Tools service binding. Tools uses that same manifest startup snapshot. Restart development after editing requirements.
81
+ The Slate schema and viewer/owner requirements live in `@usecontextlayer/shared/slate`. The neutral requirement/assignment response in `@usecontextlayer/shared/app-connections` is shared by platform and CLI. Selecting an account saves the assignment and React Router revalidates the tray automatically. Connect account opens authorization in a new tab; refresh the app page afterward to select the new account. Changes made elsewhere appear on the next frame load. The tray does not refresh the app's route data. Chrome is disabled during local development. Vite does not expose local configuration or app identity through a browser configuration plugin; the selected local connection inputs and credentials remain behind the Tools service binding. Restart development after editing requirements or bindings.
80
82
 
81
83
  `createApp` returns the exported `App` type from `@usecontextlayer/sdk/worker`, derived from Cloudflare's native `ExportedHandler` fetch contract. The SDK owns its local binding and request-props types. This gives the generated Worker a portable public declaration under the Cloudflare scaffold's composite TypeScript configuration.
package/dist/local.d.ts CHANGED
@@ -1,37 +1,63 @@
1
1
  import { z } from "zod";
2
2
  import { WorkerEntrypoint } from "cloudflare:workers";
3
- //#region ../shared/dist/slate.d.mts
4
- declare const slateSchema: z.ZodObject<{
3
+ //#region ../shared/dist/app-resources.d.mts
4
+ declare const localResourceConfigurationSchema: z.ZodObject<{
5
5
  connections: z.ZodRecord<z.ZodString, z.ZodObject<{
6
6
  mode: z.ZodEnum<{
7
7
  owner: "owner";
8
8
  viewer: "viewer";
9
9
  }>;
10
10
  toolkit: z.ZodString;
11
+ consumers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
12
+ type: z.ZodLiteral<"app">;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ name: z.ZodString;
15
+ type: z.ZodLiteral<"agent">;
16
+ }, z.core.$strict>], "type">>;
17
+ connection_id: z.ZodNullable<z.ZodString>;
11
18
  }, z.core.$strict>>;
12
- secrets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
19
+ folders: z.ZodRecord<z.ZodString, z.ZodObject<{
13
20
  mode: z.ZodEnum<{
14
21
  owner: "owner";
15
22
  viewer: "viewer";
16
23
  }>;
17
- }, z.core.$strict>>>;
24
+ consumers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
25
+ type: z.ZodLiteral<"app">;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ name: z.ZodString;
28
+ type: z.ZodLiteral<"agent">;
29
+ }, z.core.$strict>], "type">>;
30
+ path: z.ZodString;
31
+ }, z.core.$strict>>;
32
+ secrets: z.ZodRecord<z.ZodString, z.ZodObject<{
33
+ mode: z.ZodEnum<{
34
+ owner: "owner";
35
+ viewer: "viewer";
36
+ }>;
37
+ consumers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ type: z.ZodLiteral<"app">;
39
+ }, z.core.$strict>, z.ZodObject<{
40
+ name: z.ZodString;
41
+ type: z.ZodLiteral<"agent">;
42
+ }, z.core.$strict>], "type">>;
43
+ value: z.ZodNullable<z.ZodString>;
44
+ }, z.core.$strict>>;
18
45
  }, z.core.$strict>;
19
- type Slate = z.infer<typeof slateSchema>;
46
+ type LocalResourceConfiguration = z.infer<typeof localResourceConfigurationSchema>;
20
47
  //#endregion
21
48
  //#endregion
22
49
  //#region ../shared/dist/tools-worker.d.mts
23
- //#region lib/tools-worker.d.ts
24
- interface ToolsProps {
50
+ interface LocalToolsProps {
25
51
  appId: string;
52
+ connections: LocalResourceConfiguration["connections"];
26
53
  credential: {
27
54
  token: string;
28
- type: "access-token" | "session";
55
+ type: "access-token";
29
56
  };
30
- manifest?: Slate;
31
57
  }
32
- export declare class Tools extends WorkerEntrypoint<{
58
+ declare class LocalTools extends WorkerEntrypoint<{
33
59
  CTX_PLATFORM_URL: string;
34
- }, ToolsProps> {
60
+ }, LocalToolsProps> {
35
61
  call(slug: string, toolSlug: string, args: Record<string, unknown>): Promise<{
36
62
  data: Record<string, unknown>;
37
63
  logId: string;
@@ -39,4 +65,5 @@ export declare class Tools extends WorkerEntrypoint<{
39
65
  }
40
66
  //#endregion
41
67
  //#endregion
68
+ export { LocalTools as Tools };
42
69
  //# sourceMappingURL=local.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.d.ts","names":[],"sources":["../../shared/dist/slate.d.mts","../../shared/dist/tools-worker.d.mts"],"mappings":";;;cAqBqB,aAAa,EAAE;EAClC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE;IACtC,MAAM,EAAE;MACN;MACA;;IAEF,SAAS,EAAE;KACV,EAAE,KAAK;EACV,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE;IAC/C,MAAM,EAAE;MACN;MACA;;KAED,EAAE,KAAK;GACT,EAAE,KAAK;KACE,QAAQ,EAAE,aAAa;;;;;UCjClB;EACf;EACA;IACE;IACA;;EAEF,WAAW;;qBAEQ,cAAc;EACjC;GACC;EACD,KAAK,cAAc,kBAAkB,MAAM,0BAA0B;IACnE,MAAM;IACN"}
1
+ {"version":3,"file":"local.d.ts","names":[],"sources":["../../shared/dist/app-resources.d.mts","../../shared/dist/tools-worker.d.mts"],"mappings":";;;cA+HqB,kCAAkC,EAAE;EACvD,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE;IACtC,MAAM,EAAE;MACN;MACA;;IAEF,SAAS,EAAE;IACX,WAAW,EAAE,SAAS,EAAE,uBAAuB,EAAE;MAC/C,MAAM,EAAE;OACP,EAAE,KAAK,UAAU,EAAE;MACpB,MAAM,EAAE;MACR,MAAM,EAAE;OACP,EAAE,KAAK;IACV,eAAe,EAAE,YAAY,EAAE;KAC9B,EAAE,KAAK;EACV,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE;IAClC,MAAM,EAAE;MACN;MACA;;IAEF,WAAW,EAAE,SAAS,EAAE,uBAAuB,EAAE;MAC/C,MAAM,EAAE;OACP,EAAE,KAAK,UAAU,EAAE;MACpB,MAAM,EAAE;MACR,MAAM,EAAE;OACP,EAAE,KAAK;IACV,MAAM,EAAE;KACP,EAAE,KAAK;EACV,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE;IAClC,MAAM,EAAE;MACN;MACA;;IAEF,WAAW,EAAE,SAAS,EAAE,uBAAuB,EAAE;MAC/C,MAAM,EAAE;OACP,EAAE,KAAK,UAAU,EAAE;MACpB,MAAM,EAAE;MACR,MAAM,EAAE;OACP,EAAE,KAAK;IACV,OAAO,EAAE,YAAY,EAAE;KACtB,EAAE,KAAK;GACT,EAAE,KAAK;KACE,6BAA6B,EAAE,aAAa;;;;UC/JvC;EACf;EACA,aAAa;EACb;IACE;IACA;;;cAWiB,mBAAmB;EACtC;GACC;EACD,KAAK,cAAc,kBAAkB,MAAM,0BAA0B;IACnE,MAAM;IACN"}
package/dist/local.js CHANGED
@@ -1,37 +1,45 @@
1
1
  import { z } from "zod";
2
2
  import { WorkerEntrypoint } from "cloudflare:workers";
3
- //#region ../shared/dist/tools-worker.mjs
4
- const execution = z.object({
3
+ //#region ../shared/dist/tools.mjs
4
+ const toolResultSchema = z.object({
5
5
  data: z.record(z.string(), z.unknown()),
6
6
  error: z.string().nullable(),
7
7
  logId: z.string()
8
8
  });
9
- var Tools = class extends WorkerEntrypoint {
9
+ //#endregion
10
+ //#region ../shared/dist/tools-worker.mjs
11
+ var LocalTools = class extends WorkerEntrypoint {
10
12
  async call(slug, toolSlug, args) {
11
- const { appId, credential, manifest } = this.ctx.props;
12
- const response = await fetch(new URL(`/api/apps/${appId}/tools/call`, this.env.CTX_PLATFORM_URL), {
13
+ const { appId, connections, credential } = this.ctx.props;
14
+ const connection = new Map(Object.entries(connections)).get(slug);
15
+ if (!connection) throw new Error(`No local app connection requirement for "${slug}"`);
16
+ if (connection.connection_id === null) throw new Error(`No local account assigned to "${slug}". Run ctx connection local assign ${slug}.`);
17
+ return executeToolRequest(new Request(new URL(`/api/connections/${encodeURIComponent(connection.connection_id)}/tools/call`, this.env.CTX_PLATFORM_URL), {
13
18
  body: JSON.stringify({
19
+ app_id: appId,
14
20
  arguments: args,
15
- manifest,
16
- slug,
17
- tool: toolSlug
21
+ tool: toolSlug,
22
+ toolkit: connection.toolkit
18
23
  }),
19
24
  headers: {
20
- "content-type": "application/json",
21
- ...credential.type === "access-token" ? { authorization: `Bearer ${credential.token}` } : { cookie: `ctx-viewer-auth=${credential.token}` }
25
+ authorization: `Bearer ${credential.token}`,
26
+ "content-type": "application/json"
22
27
  },
23
28
  method: "POST"
24
- });
25
- if (!response.ok) throw new Error(`Tool call failed: HTTP ${response.status}`);
26
- const result = execution.parse(await response.json());
27
- if (result.error !== null) throw new Error(`${result.error} (log: ${result.logId})`);
28
- return {
29
- data: result.data,
30
- logId: result.logId
31
- };
29
+ }));
32
30
  }
33
31
  };
32
+ async function executeToolRequest(request) {
33
+ const response = await fetch(request);
34
+ if (!response.ok) throw new Error(`Tool call failed: HTTP ${response.status}`);
35
+ const result = toolResultSchema.parse(await response.json());
36
+ if (result.error !== null) throw new Error(`${result.error} (log: ${result.logId})`);
37
+ return {
38
+ data: result.data,
39
+ logId: result.logId
40
+ };
41
+ }
34
42
  //#endregion
35
- export { Tools };
43
+ export { LocalTools as Tools };
36
44
 
37
45
  //# sourceMappingURL=local.js.map
package/dist/local.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","names":[],"sources":["../../shared/dist/tools-worker.mjs"],"sourcesContent":["import { z } from \"zod\";\nimport { WorkerEntrypoint } from \"cloudflare:workers\";\n\n//#region lib/tools-worker.ts\nconst execution = z.object({\n\tdata: z.record(z.string(), z.unknown()),\n\terror: z.string().nullable(),\n\tlogId: z.string()\n});\nvar Tools = class extends WorkerEntrypoint {\n\tasync call(slug, toolSlug, args) {\n\t\tconst { appId, credential, manifest } = this.ctx.props;\n\t\tconst response = await fetch(new URL(`/api/apps/${appId}/tools/call`, this.env.CTX_PLATFORM_URL), {\n\t\t\tbody: JSON.stringify({\n\t\t\t\targuments: args,\n\t\t\t\tmanifest,\n\t\t\t\tslug,\n\t\t\t\ttool: toolSlug\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t...credential.type === \"access-token\" ? { authorization: `Bearer ${credential.token}` } : { cookie: `ctx-viewer-auth=${credential.token}` }\n\t\t\t},\n\t\t\tmethod: \"POST\"\n\t\t});\n\t\tif (!response.ok) throw new Error(`Tool call failed: HTTP ${response.status}`);\n\t\tconst result = execution.parse(await response.json());\n\t\tif (result.error !== null) throw new Error(`${result.error} (log: ${result.logId})`);\n\t\treturn {\n\t\t\tdata: result.data,\n\t\t\tlogId: result.logId\n\t\t};\n\t}\n};\n\n//#endregion\nexport { Tools };"],"mappings":";;;AAIA,MAAM,YAAY,EAAE,OAAO;CAC1B,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;CACtC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,OAAO,EAAE,OAAO;AACjB,CAAC;AACD,IAAI,QAAQ,cAAc,iBAAiB;CAC1C,MAAM,KAAK,MAAM,UAAU,MAAM;EAChC,MAAM,EAAE,OAAO,YAAY,aAAa,KAAK,IAAI;EACjD,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI,aAAa,MAAM,cAAc,KAAK,IAAI,gBAAgB,GAAG;GACjG,MAAM,KAAK,UAAU;IACpB,WAAW;IACX;IACA;IACA,MAAM;GACP,CAAC;GACD,SAAS;IACR,gBAAgB;IAChB,GAAG,WAAW,SAAS,iBAAiB,EAAE,eAAe,UAAU,WAAW,QAAQ,IAAI,EAAE,QAAQ,mBAAmB,WAAW,QAAQ;GAC3I;GACA,QAAQ;EACT,CAAC;EACD,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,0BAA0B,SAAS,QAAQ;EAC7E,MAAM,SAAS,UAAU,MAAM,MAAM,SAAS,KAAK,CAAC;EACpD,IAAI,OAAO,UAAU,MAAM,MAAM,IAAI,MAAM,GAAG,OAAO,MAAM,SAAS,OAAO,MAAM,EAAE;EACnF,OAAO;GACN,MAAM,OAAO;GACb,OAAO,OAAO;EACf;CACD;AACD"}
1
+ {"version":3,"file":"local.js","names":[],"sources":["../../shared/dist/tools.mjs","../../shared/dist/tools-worker.mjs"],"sourcesContent":["import { z } from \"zod\";\n\n//#region lib/tools.ts\nconst toolResultSchema = z.object({\n\tdata: z.record(z.string(), z.unknown()),\n\terror: z.string().nullable(),\n\tlogId: z.string()\n});\n\n//#endregion\nexport { toolResultSchema };","import { toolResultSchema } from \"./tools.mjs\";\nimport { WorkerEntrypoint } from \"cloudflare:workers\";\n\n//#region lib/tools-worker.ts\nvar Tools = class extends WorkerEntrypoint {\n\tasync call(slug, toolSlug, args) {\n\t\tconst { appId, credential } = this.ctx.props;\n\t\treturn executeToolRequest(new Request(new URL(`/api/apps/${appId}/tools/call`, this.env.CTX_PLATFORM_URL), {\n\t\t\tbody: JSON.stringify({\n\t\t\t\targuments: args,\n\t\t\t\tslug,\n\t\t\t\ttool: toolSlug\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\tcookie: `ctx-viewer-auth=${credential.token}`\n\t\t\t},\n\t\t\tmethod: \"POST\"\n\t\t}));\n\t}\n};\nvar LocalTools = class extends WorkerEntrypoint {\n\tasync call(slug, toolSlug, args) {\n\t\tconst { appId, connections, credential } = this.ctx.props;\n\t\tconst connection = new Map(Object.entries(connections)).get(slug);\n\t\tif (!connection) throw new Error(`No local app connection requirement for \"${slug}\"`);\n\t\tif (connection.connection_id === null) throw new Error(`No local account assigned to \"${slug}\". Run ctx connection local assign ${slug}.`);\n\t\treturn executeToolRequest(new Request(new URL(`/api/connections/${encodeURIComponent(connection.connection_id)}/tools/call`, this.env.CTX_PLATFORM_URL), {\n\t\t\tbody: JSON.stringify({\n\t\t\t\tapp_id: appId,\n\t\t\t\targuments: args,\n\t\t\t\ttool: toolSlug,\n\t\t\t\ttoolkit: connection.toolkit\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\tauthorization: `Bearer ${credential.token}`,\n\t\t\t\t\"content-type\": \"application/json\"\n\t\t\t},\n\t\t\tmethod: \"POST\"\n\t\t}));\n\t}\n};\nasync function executeToolRequest(request) {\n\tconst response = await fetch(request);\n\tif (!response.ok) throw new Error(`Tool call failed: HTTP ${response.status}`);\n\tconst result = toolResultSchema.parse(await response.json());\n\tif (result.error !== null) throw new Error(`${result.error} (log: ${result.logId})`);\n\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ACf;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","names":[],"sources":["../react.tsx"],"mappings":";;wBA6CgB,SAAS;EAAc,UAAU;oBAAW,IAAA"}
1
+ {"version":3,"file":"react.d.ts","names":[],"sources":["../react.tsx"],"mappings":";;wBA2CgB,SAAS;EAAc,UAAU;oBAAW,IAAA"}
package/dist/react.js CHANGED
@@ -10,15 +10,7 @@ const chromeHeightSchema = z.object({
10
10
  });
11
11
  //#endregion
12
12
  //#region browser-env.ts
13
- const browserEnv = z.object({
14
- CTX_APP_ID: z.uuid().optional(),
15
- CTX_APP_MANIFEST: z.string().optional(),
16
- CTX_PLATFORM_URL: z.url().default("https://slate.usecontextlayer.com")
17
- }).parse({
18
- CTX_APP_ID: import.meta.env.CTX_APP_ID,
19
- CTX_APP_MANIFEST: import.meta.env.CTX_APP_MANIFEST,
20
- CTX_PLATFORM_URL: import.meta.env.CTX_PLATFORM_URL
21
- });
13
+ const browserEnv = z.object({ CTX_PLATFORM_URL: z.url().default("https://slate.usecontextlayer.com") }).parse({ CTX_PLATFORM_URL: import.meta.env.CTX_PLATFORM_URL });
22
14
  //#endregion
23
15
  //#region react.tsx
24
16
  function Chrome() {
@@ -26,10 +18,9 @@ function Chrome() {
26
18
  const [src, setSrc] = useState();
27
19
  const [height, setHeight] = useState(30);
28
20
  useEffect(() => {
29
- const target = browserEnv.CTX_APP_ID ?? window.location.hostname;
21
+ const target = window.location.hostname;
30
22
  const url = new URL(`${chromePath}/apps/${encodeURIComponent(target)}`, browserEnv.CTX_PLATFORM_URL);
31
23
  url.searchParams.set("parentOrigin", window.location.origin);
32
- if (browserEnv.CTX_APP_MANIFEST) url.searchParams.set("manifest", browserEnv.CTX_APP_MANIFEST);
33
24
  function resize(event) {
34
25
  if (event.origin !== url.origin || event.source !== frame.current?.contentWindow) return;
35
26
  const message = chromeHeightSchema.safeParse(event.data);
@@ -65,7 +56,7 @@ function Layout({ children }) {
65
56
  /* @__PURE__ */ jsx(Meta, {}),
66
57
  /* @__PURE__ */ jsx(Links, {})
67
58
  ] }), /* @__PURE__ */ jsxs("body", { children: [
68
- /* @__PURE__ */ jsx(Chrome, {}),
59
+ !import.meta.env.DEV && /* @__PURE__ */ jsx(Chrome, {}),
69
60
  children,
70
61
  /* @__PURE__ */ jsx(ScrollRestoration, {}),
71
62
  /* @__PURE__ */ jsx(Scripts, {})
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":[],"sources":["../../shared/dist/chrome.mjs","../browser-env.ts","../react.tsx"],"sourcesContent":["import { z } from \"zod\";\n\n//#region lib/chrome.ts\nconst chromePath = \"/dashboard/chrome\";\nconst chromeHeightSchema = z.object({\n\theight: z.number().finite().nonnegative(),\n\ttype: z.literal(\"ctx:chrome:height\")\n});\n\n//#endregion\nexport { chromeHeightSchema, chromePath };","import { z } from \"zod\"\n\nexport const browserEnv = z\n\t.object({\n\t\tCTX_APP_ID: z.uuid().optional(),\n\t\tCTX_APP_MANIFEST: z.string().optional(),\n\t\tCTX_PLATFORM_URL: z.url().default(\"https://slate.usecontextlayer.com\"),\n\t})\n\t.parse({\n\t\tCTX_APP_ID: import.meta.env.CTX_APP_ID,\n\t\tCTX_APP_MANIFEST: import.meta.env.CTX_APP_MANIFEST,\n\t\tCTX_PLATFORM_URL: import.meta.env.CTX_PLATFORM_URL,\n\t})\n","import { chromeHeightSchema, chromePath } from \"@usecontextlayer/shared/chrome\"\nimport { type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { Links, Meta, Scripts, ScrollRestoration } from \"react-router\"\nimport { browserEnv } from \"@/browser-env\"\n\nfunction Chrome() {\n\tconst frame = useRef<HTMLIFrameElement>(null)\n\tconst [src, setSrc] = useState<string>()\n\tconst [height, setHeight] = useState(30)\n\tuseEffect(() => {\n\t\tconst target = browserEnv.CTX_APP_ID ?? window.location.hostname\n\t\tconst url = new URL(\n\t\t\t`${chromePath}/apps/${encodeURIComponent(target)}`,\n\t\t\tbrowserEnv.CTX_PLATFORM_URL,\n\t\t)\n\t\turl.searchParams.set(\"parentOrigin\", window.location.origin)\n\t\tif (browserEnv.CTX_APP_MANIFEST)\n\t\t\turl.searchParams.set(\"manifest\", browserEnv.CTX_APP_MANIFEST)\n\t\tfunction resize(event: MessageEvent) {\n\t\t\tif (event.origin !== url.origin || event.source !== frame.current?.contentWindow)\n\t\t\t\treturn\n\t\t\tconst message = chromeHeightSchema.safeParse(event.data)\n\t\t\tif (message.success) setHeight(message.data.height)\n\t\t}\n\t\twindow.addEventListener(\"message\", resize)\n\t\tsetSrc(url.href)\n\t\treturn () => window.removeEventListener(\"message\", resize)\n\t}, [])\n\treturn (\n\t\t<iframe\n\t\t\tref={frame}\n\t\t\tsrc={src}\n\t\t\ttitle=\"ContextLayer\"\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor: \"oklch(96.8% 0.007 247.896)\",\n\t\t\t\tborder: 0,\n\t\t\t\tborderBottom: \"1px solid oklch(92.9% 0.013 255.508)\",\n\t\t\t\tdisplay: \"block\",\n\t\t\t\theight,\n\t\t\t\twidth: \"100%\",\n\t\t\t}}\n\t\t/>\n\t)\n}\n\nexport function Layout({ children }: { children: ReactNode }) {\n\treturn (\n\t\t<html lang=\"en\">\n\t\t\t<head>\n\t\t\t\t<meta charSet=\"utf-8\" />\n\t\t\t\t<meta\n\t\t\t\t\tname=\"viewport\"\n\t\t\t\t\tcontent=\"width=device-width, initial-scale=1\"\n\t\t\t\t/>\n\t\t\t\t<Meta />\n\t\t\t\t<Links />\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<Chrome />\n\t\t\t\t{children}\n\t\t\t\t<ScrollRestoration />\n\t\t\t\t<Scripts />\n\t\t\t</body>\n\t\t</html>\n\t)\n}\n"],"mappings":";;;;;AAGA,MAAM,aAAa;AACnB,MAAM,qBAAqB,EAAE,OAAO;CACnC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY;CACxC,MAAM,EAAE,QAAQ,mBAA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ACC,qBAAC,QAAD,EAAA,UAAA;GACC,oBAAC,QAAD,EAAM,SAAQ,QAAS,CAAA;GACvB,oBAAC,QAAD;IACC,MAAK;IACL,SAAQ;GACR,CAAA;GACD,oBAAC,MAAD,CAAO,CAAA;GACP,oBAAC,OAAD,CAAQ,CAAA;EACH,EAAA,CAAA,GACN,qBAAC,QAAD,EAAA,UAAA;GACC,oBAAC,QAAD,CAAS,CAAA;GACR;GACD,oBAAC,mBAAD,CAAoB,CAAA;GACpB,oBAAC,SAAD,CAAU,CAAA;EACL,EAAA,CAAA,CACD;;AAER"}
1
+ {"version":3,"file":"react.js","names":[],"sources":["../../shared/dist/chrome.mjs","../browser-env.ts","../react.tsx"],"sourcesContent":["import { z } from \"zod\";\n\n//#region lib/chrome.ts\nconst chromePath = \"/dashboard/chrome\";\nconst chromeHeightSchema = z.object({\n\theight: z.number().finite().nonnegative(),\n\ttype: z.literal(\"ctx:chrome:height\")\n});\n\n//#endregion\nexport { chromeHeightSchema, chromePath };","import { z } from \"zod\"\n\nexport const browserEnv = z\n\t.object({\n\t\tCTX_PLATFORM_URL: z.url().default(\"https://slate.usecontextlayer.com\"),\n\t})\n\t.parse({\n\t\tCTX_PLATFORM_URL: import.meta.env.CTX_PLATFORM_URL,\n\t})\n","import { chromeHeightSchema, chromePath } from \"@usecontextlayer/shared/chrome\"\nimport { type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { Links, Meta, Scripts, ScrollRestoration } from \"react-router\"\nimport { browserEnv } from \"@/browser-env\"\n\nfunction Chrome() {\n\tconst frame = useRef<HTMLIFrameElement>(null)\n\tconst [src, setSrc] = useState<string>()\n\tconst [height, setHeight] = useState(30)\n\tuseEffect(() => {\n\t\tconst target = window.location.hostname\n\t\tconst url = new URL(\n\t\t\t`${chromePath}/apps/${encodeURIComponent(target)}`,\n\t\t\tbrowserEnv.CTX_PLATFORM_URL,\n\t\t)\n\t\turl.searchParams.set(\"parentOrigin\", window.location.origin)\n\t\tfunction resize(event: MessageEvent) {\n\t\t\tif (event.origin !== url.origin || event.source !== frame.current?.contentWindow)\n\t\t\t\treturn\n\t\t\tconst message = chromeHeightSchema.safeParse(event.data)\n\t\t\tif (message.success) setHeight(message.data.height)\n\t\t}\n\t\twindow.addEventListener(\"message\", resize)\n\t\tsetSrc(url.href)\n\t\treturn () => window.removeEventListener(\"message\", resize)\n\t}, [])\n\treturn (\n\t\t<iframe\n\t\t\tref={frame}\n\t\t\tsrc={src}\n\t\t\ttitle=\"ContextLayer\"\n\t\t\tstyle={{\n\t\t\t\tbackgroundColor: \"oklch(96.8% 0.007 247.896)\",\n\t\t\t\tborder: 0,\n\t\t\t\tborderBottom: \"1px solid oklch(92.9% 0.013 255.508)\",\n\t\t\t\tdisplay: \"block\",\n\t\t\t\theight,\n\t\t\t\twidth: \"100%\",\n\t\t\t}}\n\t\t/>\n\t)\n}\n\nexport function Layout({ children }: { children: ReactNode }) {\n\treturn (\n\t\t<html lang=\"en\">\n\t\t\t<head>\n\t\t\t\t<meta charSet=\"utf-8\" />\n\t\t\t\t<meta\n\t\t\t\t\tname=\"viewport\"\n\t\t\t\t\tcontent=\"width=device-width, initial-scale=1\"\n\t\t\t\t/>\n\t\t\t\t<Meta />\n\t\t\t\t<Links />\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t{!import.meta.env.DEV && <Chrome />}\n\t\t\t\t{children}\n\t\t\t\t<ScrollRestoration />\n\t\t\t\t<Scripts />\n\t\t\t</body>\n\t\t</html>\n\t)\n}\n"],"mappings":";;;;;AAGA,MAAM,aAAa;AACnB,MAAM,qBAAqB,EAAE,OAAO;CACnC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY;CACxC,MAAM,EAAE,QAAQ,mBAAmB;AACpC,CAAC;;;ACLD,MAAa,aAAa,EACxB,OAAO,EACP,kBAAkB,EAAE,IAAI,CAAC,CAAC,QAAQ,mCAAmC,EACtE,CAAC,CAAC,CACD,MAAM,EACN,kBAAkB,YAAY,IAA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A,CAAA,CACD;;AAER"}
package/dist/vite.d.ts CHANGED
@@ -1,14 +1,5 @@
1
1
  import { ConfigEnv } from "vite";
2
2
  //#region vite.d.ts
3
- export declare function contextlayer({ command }: ConfigEnv): Promise<(import("vite").Plugin<any>[] | {
4
- config: () => {
5
- define: {
6
- "import.meta.env.CTX_APP_ID": string;
7
- "import.meta.env.CTX_APP_MANIFEST": string;
8
- "import.meta.env.CTX_PLATFORM_URL": string;
9
- };
10
- };
11
- name: string;
12
- })[]>;
3
+ export declare function contextlayer({ command }: ConfigEnv): Promise<import("vite").Plugin<any>[][]>;
13
4
  //#endregion
14
5
  //# sourceMappingURL=vite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","names":[],"sources":["../vite.ts"],"mappings":";;wBAIsB,eAAe,WAAW,YAAS,wBAAA;;IAKrD;MACC;MAEA;MAEA"}
1
+ {"version":3,"file":"vite.d.ts","names":[],"sources":["../vite.ts"],"mappings":";;wBAIsB,eAAe,WAAW,YAAS,uBAAA"}
package/dist/vite.js CHANGED
@@ -3,14 +3,7 @@ import { getLocalToolsBindings } from "@usecontextlayer/cli/vite";
3
3
  //#region vite.ts
4
4
  async function contextlayer({ command }) {
5
5
  const bindings = command === "serve" ? await getLocalToolsBindings() : void 0;
6
- return [{
7
- config: () => ({ define: {
8
- "import.meta.env.CTX_APP_ID": JSON.stringify(bindings?.props.appId) ?? "undefined",
9
- "import.meta.env.CTX_APP_MANIFEST": JSON.stringify(JSON.stringify(bindings?.props.manifest)) ?? "undefined",
10
- "import.meta.env.CTX_PLATFORM_URL": JSON.stringify(bindings?.vars.CTX_PLATFORM_URL) ?? "undefined"
11
- } }),
12
- name: "contextlayer-chrome"
13
- }, cloudflare({
6
+ return [cloudflare({
14
7
  auxiliaryWorkers: [{
15
8
  config: bindings ? { vars: bindings.vars } : {},
16
9
  configPath: "workers/local-tools/wrangler.jsonc",
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../vite.ts"],"sourcesContent":["import { cloudflare } from \"@cloudflare/vite-plugin\"\nimport { getLocalToolsBindings } from \"@usecontextlayer/cli/vite\"\nimport type { ConfigEnv } from \"vite\"\n\nexport async function contextlayer({ command }: ConfigEnv) {\n\tconst bindings = command === \"serve\" ? await getLocalToolsBindings() : undefined\n\treturn [\n\t\t{\n\t\t\tconfig: () => ({\n\t\t\t\tdefine: {\n\t\t\t\t\t\"import.meta.env.CTX_APP_ID\":\n\t\t\t\t\t\tJSON.stringify(bindings?.props.appId) ?? \"undefined\",\n\t\t\t\t\t\"import.meta.env.CTX_APP_MANIFEST\":\n\t\t\t\t\t\tJSON.stringify(JSON.stringify(bindings?.props.manifest)) ?? \"undefined\",\n\t\t\t\t\t\"import.meta.env.CTX_PLATFORM_URL\":\n\t\t\t\t\t\tJSON.stringify(bindings?.vars.CTX_PLATFORM_URL) ?? \"undefined\",\n\t\t\t\t},\n\t\t\t}),\n\t\t\tname: \"contextlayer-chrome\",\n\t\t},\n\t\tcloudflare({\n\t\t\tauxiliaryWorkers: [\n\t\t\t\t{\n\t\t\t\t\tconfig: bindings ? { vars: bindings.vars } : {},\n\t\t\t\t\tconfigPath: \"workers/local-tools/wrangler.jsonc\",\n\t\t\t\t\tdevOnly: true,\n\t\t\t\t},\n\t\t\t],\n\t\t\tconfig: bindings\n\t\t\t\t? {\n\t\t\t\t\t\tservices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbinding: \"TOOLS\",\n\t\t\t\t\t\t\t\tentrypoint: \"Tools\",\n\t\t\t\t\t\t\t\tprops: bindings.props,\n\t\t\t\t\t\t\t\tservice: \"ctx-local-tools\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t: {},\n\t\t\tviteEnvironment: { name: \"ssr\" },\n\t\t}),\n\t]\n}\n"],"mappings":";;;AAIA,eAAsB,aAAa,EAAE,WAAsB;CAC1D,MAAM,WAAW,YAAY,UAAU,MAAM,sBAAsB,IAAI,KAAA;CACvE,OAAO,CACN;EACC,eAAe,EACd,QAAQ;GACP,8BACC,KAAK,UAAU,UAAU,MAAM,KAAK,KAAK;GAC1C,oCACC,KAAK,UAAU,KAAK,UAAU,UAAU,MAAM,QAAQ,CAAC,KAAK;GAC7D,oCACC,KAAK,UAAU,UAAU,KAAK,gBAAgB,KAAK;EACrD,EACD;EACA,MAAM;CACP,GACA,WAAW;EACV,kBAAkB,CACjB;GACC,QAAQ,WAAW,EAAE,MAAM,SAAS,KAAK,IAAI,CAAC;GAC9C,YAAY;GACZ,SAAS;EACV,CACD;EACA,QAAQ,WACL,EACA,UAAU,CACT;GACC,SAAS;GACT,YAAY;GACZ,OAAO,SAAS;GAChB,SAAS;EACV,CACD,EACD,IACC,CAAC;EACJ,iBAAiB,EAAE,MAAM,MAAM;CAChC,CAAC,CACF;AACD"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../vite.ts"],"sourcesContent":["import { cloudflare } from \"@cloudflare/vite-plugin\"\nimport { getLocalToolsBindings } from \"@usecontextlayer/cli/vite\"\nimport type { ConfigEnv } from \"vite\"\n\nexport async function contextlayer({ command }: ConfigEnv) {\n\tconst bindings = command === \"serve\" ? await getLocalToolsBindings() : undefined\n\treturn [\n\t\tcloudflare({\n\t\t\tauxiliaryWorkers: [\n\t\t\t\t{\n\t\t\t\t\tconfig: bindings ? { vars: bindings.vars } : {},\n\t\t\t\t\tconfigPath: \"workers/local-tools/wrangler.jsonc\",\n\t\t\t\t\tdevOnly: true,\n\t\t\t\t},\n\t\t\t],\n\t\t\tconfig: bindings\n\t\t\t\t? {\n\t\t\t\t\t\tservices: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbinding: \"TOOLS\",\n\t\t\t\t\t\t\t\tentrypoint: \"Tools\",\n\t\t\t\t\t\t\t\tprops: bindings.props,\n\t\t\t\t\t\t\t\tservice: \"ctx-local-tools\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t: {},\n\t\t\tviteEnvironment: { name: \"ssr\" },\n\t\t}),\n\t]\n}\n"],"mappings":";;;AAIA,eAAsB,aAAa,EAAE,WAAsB;CAC1D,MAAM,WAAW,YAAY,UAAU,MAAM,sBAAsB,IAAI,KAAA;CACvE,OAAO,CACN,WAAW;EACV,kBAAkB,CACjB;GACC,QAAQ,WAAW,EAAE,MAAM,SAAS,KAAK,IAAI,CAAC;GAC9C,YAAY;GACZ,SAAS;EACV,CACD;EACA,QAAQ,WACL,EACA,UAAU,CACT;GACC,SAAS;GACT,YAAY;GACZ,OAAO,SAAS;GAChB,SAAS;EACV,CACD,EACD,IACC,CAAC;EACJ,iBAAiB,EAAE,MAAM,MAAM;CAChC,CAAC,CACF;AACD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "zod": "^4.4.3",
4
- "@usecontextlayer/cli": "0.14.2"
4
+ "@usecontextlayer/cli": "0.14.3"
5
5
  },
6
6
  "devDependencies": {
7
7
  "@cloudflare/vite-plugin": "^1.62.4",
@@ -15,7 +15,7 @@
15
15
  "tsdown": "latest",
16
16
  "typescript": "latest",
17
17
  "vite": "^8.3.2",
18
- "@usecontextlayer/shared": "0.14.2"
18
+ "@usecontextlayer/shared": "0.14.3"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
@@ -52,7 +52,7 @@
52
52
  "vite": "^8.3.2"
53
53
  },
54
54
  "type": "module",
55
- "version": "0.14.2",
55
+ "version": "0.14.3",
56
56
  "scripts": {
57
57
  "build": "tsdown",
58
58
  "dev:watch": "tsdown --watch",