@base44-preview/cli 0.3.2-pr.696.d724d11 → 0.3.2-pr.698.ea0a371

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/dist/cli/index.js CHANGED
@@ -237180,7 +237180,7 @@ var SKILL_NAME_REGEX = /^[a-z0-9]+(-[a-z0-9]+)*$/;
237180
237180
  var AgentSkillSchema = object({
237181
237181
  name: string2().trim().min(1).max(64).regex(SKILL_NAME_REGEX, "Skill name must be lowercase-hyphenated (a-z, 0-9, -)"),
237182
237182
  description: string2().trim().min(1, "Description is required").max(1024),
237183
- body: string2().trim().min(1, "Body is required").max(15000)
237183
+ body: string2().trim().min(1, "Body is required").max(50000)
237184
237184
  });
237185
237185
  var AgentSkillApiResponseSchema = object({
237186
237186
  name: string2(),
@@ -247073,6 +247073,7 @@ async function resolveBuildTarget(projectRoot, overrides = {}) {
247073
247073
  outputDir: resolve6(root, overrides.outputDir ?? site.outputDirectory ?? DEFAULT_SITE.outputDirectory),
247074
247074
  entitiesDir: project?.entitiesDir ?? "entities",
247075
247075
  agentsDir: project?.agentsDir ?? "agents",
247076
+ agentSkillsDir: project?.agentSkillsDir ?? "agent-skills",
247076
247077
  functionsDir: project?.functionsDir ?? "functions",
247077
247078
  actorsDir: project?.actorsDir ?? "actors"
247078
247079
  };
@@ -252878,6 +252879,7 @@ async function createVersion(artifacts, options = {}) {
252878
252879
  entities: artifacts.entities,
252879
252880
  agents: artifacts.agents,
252880
252881
  mcp_config: artifacts.mcpConfig,
252882
+ agent_skills: artifacts.agentSkills,
252881
252883
  source_commit: options.sourceCommit
252882
252884
  }, "declaring a version")).json(), "declare");
252883
252885
  const declaredFiles = [
@@ -256404,7 +256406,7 @@ Did you try connecting directly to this Durable Object? Try using getServerByNam
256404
256406
  };
256405
256407
 
256406
256408
  // src/shim/actor.ts
256407
- import { createClient } from "npm:@base44/sdk@0.8.54";
256409
+ import { createClient } from "npm:@base44/sdk@0.8.41";
256408
256410
 
256409
256411
  // src/shim/tick-loop.ts
256410
256412
  var TickLoop = class {
@@ -256814,26 +256816,6 @@ var Actor = class _Actor extends Server {
256814
256816
  }
256815
256817
  handleWake(_key) {
256816
256818
  }
256817
- // Optional: the platform posted an event into this room. Delivery is
256818
- // at-least-once; a repeat of an event_id this instance already took is dropped
256819
- // here, so a room that must be exact across evictions dedups on event_id too.
256820
- handlePlatformEvent(_event) {
256821
- }
256822
- takenPlatformEvents = [];
256823
- static REMEMBERED_PLATFORM_EVENTS = 64;
256824
- // Called by the generated wrapper for a verified POST .../events; never user-facing.
256825
- async _b44PlatformEvent(request) {
256826
- const room = request.headers.get("x-partykit-room");
256827
- if (room) await this.setName(room);
256828
- const event = await request.json();
256829
- if (!this.takenPlatformEvents.includes(event.event_id)) {
256830
- await this.handlePlatformEvent(event);
256831
- this.takenPlatformEvents.push(event.event_id);
256832
- if (this.takenPlatformEvents.length > _Actor.REMEMBERED_PLATFORM_EVENTS) this.takenPlatformEvents.shift();
256833
- await this.maintainTicker();
256834
- }
256835
- return new Response(null, { status: 204 });
256836
- }
256837
256819
  async schedule(key, at) {
256838
256820
  const when = typeof at === "number" ? at : at.getTime();
256839
256821
  await this.mutateSchedules((m) => {
@@ -258574,7 +258556,7 @@ var TELEMETRY_PATCH = [
258574
258556
  var TELEMETRY_STORE_FIELDS = "reqId: crypto.randomUUID(), respondedAt: null, inflight: new Map(), inflightTotal: 0, hadRejection: false, hadNonOk: false, logBudget: 5";
258575
258557
 
258576
258558
  // ../functions-compiler/src/version.ts
258577
- var COMPILER_VERSION = "0.3.0-beta.2";
258559
+ var COMPILER_VERSION = "0.2.0";
258578
258560
 
258579
258561
  // ../functions-compiler/src/worker-entry.ts
258580
258562
  function denoShimSource() {
@@ -259073,12 +259055,8 @@ function buildActorAuth() {
259073
259055
  return `// Auto-generated by the base44 bundler. Do not edit.
259074
259056
  const TOKEN_HEADER = "X-Base44-Actor-Token";
259075
259057
  const IDENTITY_HEADER = "X-Base44-Actor-Identity";
259076
- const EVENT_TOKEN_HEADER = "X-Base44-Actor-Event-Token";
259077
259058
  const CLOCK_SKEW_SECONDS = 30;
259078
259059
  const TOKEN_TTL_SECONDS = 300;
259079
- const EVENT_TOKEN_TTL_SECONDS = 60;
259080
- const EVENT_MAX_BYTES = 64 * 1024;
259081
- const EVENT_TYPE_PREFIX = "__";
259082
259060
 
259083
259061
  const decodeSegment = (segment) => {
259084
259062
  const normalized = segment.replace(/-/g, "+").replace(/_/g, "/");
@@ -259094,37 +259072,6 @@ const unauthorized = () => ({
259094
259072
  ok: false,
259095
259073
  response: new Response("Unauthorized", { status: 401 }),
259096
259074
  });
259097
- const refused = (status, text) => ({ ok: false, response: new Response(text, { status }) });
259098
-
259099
- // The claims of an EdDSA JWT whose signature the actor's public key verifies, else null.
259100
- const verifiedClaims = async (token, publicKey) => {
259101
- if (typeof token !== "string" || token.length > 4096) return null;
259102
- const parts = token.split(".");
259103
- if (parts.length !== 3) return null;
259104
- const header = decodeJsonSegment(parts[0]);
259105
- if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) return null;
259106
- const key = await crypto.subtle.importKey(
259107
- "raw",
259108
- decodeSegment(publicKey),
259109
- { name: "Ed25519" },
259110
- false,
259111
- ["verify"],
259112
- );
259113
- const validSignature = await crypto.subtle.verify(
259114
- { name: "Ed25519" },
259115
- key,
259116
- decodeSegment(parts[2]),
259117
- new TextEncoder().encode(parts[0] + "." + parts[1]),
259118
- );
259119
- return validSignature ? decodeJsonSegment(parts[1]) : null;
259120
- };
259121
-
259122
- const validTimes = (claims, now, ttlSeconds) =>
259123
- [claims.iat, claims.nbf, claims.exp].every(Number.isInteger) &&
259124
- claims.iat <= now + CLOCK_SKEW_SECONDS &&
259125
- claims.nbf <= now + CLOCK_SKEW_SECONDS &&
259126
- claims.exp >= now - CLOCK_SKEW_SECONDS &&
259127
- claims.exp > claims.iat && claims.exp - claims.iat <= ttlSeconds;
259128
259075
 
259129
259076
  const validPrincipal = (principal) => {
259130
259077
  if (principal === null || typeof principal !== "object" || Array.isArray(principal)) return false;
@@ -259143,21 +259090,46 @@ export async function verifyActorConnection(request, env, actorName, room) {
259143
259090
  const token = request.headers.get(TOKEN_HEADER) ?? new URL(request.url).searchParams.get("token");
259144
259091
  if (
259145
259092
  typeof publicKey !== "string" || !publicKey ||
259146
- typeof scriptId !== "string" || !scriptId
259093
+ typeof scriptId !== "string" || !scriptId ||
259094
+ typeof token !== "string" || token.length > 4096
259147
259095
  ) return unauthorized();
259148
259096
 
259097
+ const parts = token.split(".");
259098
+ if (parts.length !== 3) return unauthorized();
259149
259099
  try {
259150
- const claims = await verifiedClaims(token, publicKey);
259151
- if (!claims) return unauthorized();
259100
+ const header = decodeJsonSegment(parts[0]);
259101
+ const claims = decodeJsonSegment(parts[1]);
259102
+ if (header?.alg !== "EdDSA" || (header.typ !== undefined && header.typ !== "JWT")) {
259103
+ return unauthorized();
259104
+ }
259105
+ const key = await crypto.subtle.importKey(
259106
+ "raw",
259107
+ decodeSegment(publicKey),
259108
+ { name: "Ed25519" },
259109
+ false,
259110
+ ["verify"],
259111
+ );
259112
+ const validSignature = await crypto.subtle.verify(
259113
+ { name: "Ed25519" },
259114
+ key,
259115
+ decodeSegment(parts[2]),
259116
+ new TextEncoder().encode(parts[0] + "." + parts[1]),
259117
+ );
259118
+ if (!validSignature) return unauthorized();
259152
259119
 
259153
259120
  const now = Math.floor(Date.now() / 1000);
259121
+ const times = [claims.iat, claims.nbf, claims.exp];
259122
+ if (!times.every(Number.isInteger)) return unauthorized();
259154
259123
  if (
259155
259124
  claims.iss !== "base44" ||
259156
259125
  claims.aud !== "base44-actor-connect" ||
259157
259126
  claims.purpose !== "actor-connect" ||
259158
259127
  claims.v !== 1 ||
259159
259128
  typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
259160
- !validTimes(claims, now, TOKEN_TTL_SECONDS) ||
259129
+ claims.iat > now + CLOCK_SKEW_SECONDS ||
259130
+ claims.nbf > now + CLOCK_SKEW_SECONDS ||
259131
+ claims.exp < now - CLOCK_SKEW_SECONDS ||
259132
+ claims.exp <= claims.iat || claims.exp - claims.iat > TOKEN_TTL_SECONDS ||
259161
259133
  claims.app_id !== env.BASE44_APP_ID ||
259162
259134
  claims.actor_name !== actorName ||
259163
259135
  claims.actor_script_id !== scriptId ||
@@ -259187,75 +259159,6 @@ export function authorizedActorRequest(request, identity, actorName, room, runti
259187
259159
  headers.set("base44-functions-version", runtimeMode === "prod" ? "prod" : "preview");
259188
259160
  return new Request(new Request(url.toString(), request), { headers });
259189
259161
  }
259190
-
259191
- // A platform event the backend posts into one room. Same key as connection
259192
- // tokens, its own audience and purpose: neither token is accepted as the other.
259193
- // 401 is a token this key did not mint or that has lapsed; 403 is a good token
259194
- // for another app, actor, script or room.
259195
- export async function verifyActorEvent(request, env, actorName, room) {
259196
- const publicKey = env.BASE44_ACTOR_PUBLIC_KEY;
259197
- const scriptId = env.BASE44_ACTOR_SCRIPT_ID;
259198
- if (
259199
- typeof publicKey !== "string" || !publicKey ||
259200
- typeof scriptId !== "string" || !scriptId
259201
- ) return unauthorized();
259202
- try {
259203
- const claims = await verifiedClaims(request.headers.get(EVENT_TOKEN_HEADER), publicKey);
259204
- if (!claims) return unauthorized();
259205
- const now = Math.floor(Date.now() / 1000);
259206
- if (
259207
- claims.iss !== "base44" ||
259208
- claims.aud !== "base44-actor-event" ||
259209
- claims.purpose !== "actor-platform-event" ||
259210
- claims.v !== 1 ||
259211
- typeof claims.jti !== "string" || !claims.jti || claims.jti.length > 64 ||
259212
- !validTimes(claims, now, EVENT_TOKEN_TTL_SECONDS) ||
259213
- typeof claims.event_id !== "string" || !claims.event_id || claims.event_id.length > 256
259214
- ) return unauthorized();
259215
- if (
259216
- claims.app_id !== env.BASE44_APP_ID ||
259217
- claims.actor_name !== actorName ||
259218
- claims.actor_script_id !== scriptId ||
259219
- claims.room !== room
259220
- ) return refused(403, "Forbidden");
259221
- return { ok: true, eventId: claims.event_id };
259222
- } catch {
259223
- return unauthorized();
259224
- }
259225
- }
259226
-
259227
- // The JSON body of a verified event: one object in the platform's "__" type
259228
- // namespace whose event_id is the one the token was minted for.
259229
- export async function readPlatformEvent(request, eventId) {
259230
- let text;
259231
- try { text = await request.text(); } catch { return refused(400, "Unreadable event"); }
259232
- if (new TextEncoder().encode(text).length > EVENT_MAX_BYTES) return refused(413, "Event too large");
259233
- let event;
259234
- try { event = JSON.parse(text); } catch { return refused(400, "Invalid event"); }
259235
- if (
259236
- event === null || typeof event !== "object" || Array.isArray(event) ||
259237
- typeof event.type !== "string" || !event.type.startsWith(EVENT_TYPE_PREFIX) || event.type.length > 128 ||
259238
- event.event_id !== eventId
259239
- ) return refused(400, "Invalid event");
259240
- return { ok: true, event };
259241
- }
259242
-
259243
- // Into the room as POST /parties/<actor>/<room>/events: a path no client route
259244
- // forwards (the legacy route is exactly four segments, the direct route rewrites
259245
- // the path), so the Durable Object can trust the shape alone.
259246
- export function platformEventRequest(request, env, actorName, room, event) {
259247
- const url = new URL(request.url);
259248
- url.search = "";
259249
- url.pathname = "/parties/" + encodeURIComponent(actorName) + "/" + encodeURIComponent(room) + "/events";
259250
- return new Request(url.toString(), {
259251
- method: "POST",
259252
- headers: {
259253
- "Content-Type": "application/json",
259254
- "base44-functions-version": env.BASE44_FUNCTIONS_VERSION === "prod" ? "prod" : "preview",
259255
- },
259256
- body: JSON.stringify(event),
259257
- });
259258
- }
259259
259162
  `;
259260
259163
  }
259261
259164
  function buildPrelude() {
@@ -259276,13 +259179,7 @@ function buildEntryWrapper(doClassName, userEntry) {
259276
259179
  import "./${ACTOR_PRELUDE_FILENAME}";
259277
259180
  import Base44UserActor from ${JSON.stringify(userImport)};
259278
259181
  import { runWithWorkerEnvironment as _b44Run } from ${JSON.stringify(RUNTIME_CONTEXT_SPECIFIER)};
259279
- import {
259280
- authorizedActorRequest as _b44AuthorizedActorRequest,
259281
- platformEventRequest as _b44PlatformEventRequest,
259282
- readPlatformEvent as _b44ReadPlatformEvent,
259283
- verifyActorConnection as _b44VerifyActorConnection,
259284
- verifyActorEvent as _b44VerifyActorEvent,
259285
- } from "./${ACTOR_AUTH_FILENAME}";
259182
+ import { authorizedActorRequest as _b44AuthorizedActorRequest, verifyActorConnection as _b44VerifyActorConnection } from "./${ACTOR_AUTH_FILENAME}";
259286
259183
 
259287
259184
  const _b44ActorState = new WeakMap();
259288
259185
  const _b44RunWithActorEnvironment = (ctx, env, runtimeEnv, callback) => _b44Run({
@@ -259312,11 +259209,6 @@ const _b44RunActor = (actor, request, callback) => {
259312
259209
  state.runtimeEnv = runtimeEnv;
259313
259210
  return _b44RunWithActorEnvironment(state.ctx, state.env, runtimeEnv, callback);
259314
259211
  };
259315
- const _b44IsPlatformEvent = (request) => {
259316
- if (request.method !== "POST") return false;
259317
- const parts = new URL(request.url).pathname.split("/");
259318
- return parts.length === 5 && parts[1] === "parties" && parts[4] === "events";
259319
- };
259320
259212
 
259321
259213
  export class ${doClassName} extends Base44UserActor {
259322
259214
  // Read by the shim's service-token exchange: the assertion's actor_name claim
@@ -259329,11 +259221,6 @@ export class ${doClassName} extends Base44UserActor {
259329
259221
  }
259330
259222
 
259331
259223
  fetch(request) {
259332
- // Ahead of the user's own fetch override: a platform event is the wrapper's,
259333
- // never a request the room handles itself.
259334
- if (_b44IsPlatformEvent(request)) {
259335
- return _b44RunActor(this, request, () => this._b44PlatformEvent(request));
259336
- }
259337
259224
  return _b44RunActor(this, request, () => super.fetch(request));
259338
259225
  }
259339
259226
 
@@ -259367,22 +259254,15 @@ export default {
259367
259254
  const parts = url.pathname.split("/");
259368
259255
  const direct = parts[1] === "rooms" && parts.length === 3;
259369
259256
  const legacy = parts[1] === "parties" && parts.length === 4;
259370
- const event = request.method === "POST" && parts[1] === "rooms" && parts.length === 4 && parts[3] === "events";
259371
- if (direct || legacy || event) {
259257
+ if (direct || legacy) {
259372
259258
  // Decode the room: the token was verified against the decoded instance id,
259373
259259
  // so an escaped room must map to the same Durable Object.
259374
- const namespace = legacy ? parts[2] : "${doClassName}";
259375
- const encodedRoom = legacy ? parts[3] : parts[2];
259260
+ const namespace = direct ? "${doClassName}" : parts[2];
259261
+ const encodedRoom = direct ? parts[2] : parts[3];
259376
259262
  let room;
259377
259263
  try { room = decodeURIComponent(encodedRoom); } catch { return new Response("Invalid room", { status: 400 }); }
259378
259264
  let actorRequest = request;
259379
- if (event) {
259380
- const verification = await _b44VerifyActorEvent(request, env, "${doClassName}", room);
259381
- if (!verification.ok) return verification.response;
259382
- const platformEvent = await _b44ReadPlatformEvent(request, verification.eventId);
259383
- if (!platformEvent.ok) return platformEvent.response;
259384
- actorRequest = _b44PlatformEventRequest(request, env, "${doClassName}", room, platformEvent.event);
259385
- } else if (direct || typeof env.BASE44_ACTOR_PUBLIC_KEY === "string") {
259265
+ if (direct || typeof env.BASE44_ACTOR_PUBLIC_KEY === "string") {
259386
259266
  const verification = await _b44VerifyActorConnection(request, env, "${doClassName}", room);
259387
259267
  if (!verification.ok) return verification.response;
259388
259268
  actorRequest = _b44AuthorizedActorRequest(
@@ -264679,13 +264559,29 @@ async function readMcpConfig(configDir) {
264679
264559
  const path = join30(configDir, "mcp", "config.json");
264680
264560
  return await pathExists(path) ? await readTextFile(path) : "";
264681
264561
  }
264562
+ async function readAgentSkillFiles(dir) {
264563
+ if (!await pathExists(dir)) {
264564
+ return {};
264565
+ }
264566
+ const files = await globby("*.md", {
264567
+ cwd: dir,
264568
+ onlyFiles: true,
264569
+ followSymbolicLinks: false
264570
+ });
264571
+ const skills = {};
264572
+ for (const file of files.sort()) {
264573
+ skills[file.replace(/\.md$/, "")] = await readTextFile(join30(dir, file));
264574
+ }
264575
+ return skills;
264576
+ }
264682
264577
  async function collectResources(configDir, dirs) {
264683
- const [entities, agents, mcpConfig] = await Promise.all([
264578
+ const [entities, agents, mcpConfig, agentSkills] = await Promise.all([
264684
264579
  readRawResources(join30(configDir, dirs.entitiesDir)),
264685
264580
  readRawResources(join30(configDir, dirs.agentsDir)),
264686
- readMcpConfig(configDir)
264581
+ readMcpConfig(configDir),
264582
+ readAgentSkillFiles(join30(configDir, dirs.agentSkillsDir))
264687
264583
  ]);
264688
- return { entities, agents, mcpConfig };
264584
+ return { entities, agents, mcpConfig, agentSkills };
264689
264585
  }
264690
264586
  async function collectArtifacts(target) {
264691
264587
  const built = await resolveFullStackBuild(target.root);
@@ -275204,4 +275100,4 @@ export {
275204
275100
  runCLI
275205
275101
  };
275206
275102
 
275207
- //# debugId=A603E00A0A7CA68764756E2164756E21
275103
+ //# debugId=2490C9565A93147064756E2164756E21