siteplane 0.1.41 → 0.1.42

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
@@ -9,7 +9,7 @@ Copy the setup prompt in Siteplane, then run its exact one-time command in the
9
9
  website repository:
10
10
 
11
11
  ```bash
12
- npx -y siteplane@0.1.41 init --setup-token <one-time-setup-grant>
12
+ npx -y siteplane@0.1.42 init --setup-token <one-time-setup-grant>
13
13
  npx siteplane setup context
14
14
  ```
15
15
 
@@ -18,6 +18,16 @@ stores it only in the ignored `.siteplane/credentials.json`. No browser approval
18
18
  is required. The same connection resumes the open setup and review corrections
19
19
  until the owner completes or revokes the setup.
20
20
 
21
+ `setup context` returns the single `siteplane.setup-task.v2` task: exact packages, current run,
22
+ authorized modules/scopes, separate unchanged user instructions, environment provenance and one next action.
23
+ An initial instruction such as `Only prices` does not start a correction workflow. The agent integrates
24
+ Siteplane's existing CMS editing layer, preserving the website; it does not build a separate CMS.
25
+
26
+ Report observed work with `siteplane setup activity --phase inspecting` (also integrating, deploying,
27
+ verifying or repairing). Reports are limited to one per 30 seconds; context polling is not activity.
28
+ Optional Analytics preparation uses this same connection with explicit authorization. It grants no
29
+ activation, import, reporting, booking or publishing rights. Standalone bootstrap cannot replace an open task.
30
+
21
31
  ## Approved fields
22
32
 
23
33
  Run the exact command from Siteplane's compact apply prompt. It authenticates
@@ -1293,41 +1293,6 @@ var CONTINUE_SITE_SETUP_HTTP_BODY_MAX_BYTES = 64 * 1024;
1293
1293
  var siteSetupRunStatusSchema = z14.enum(SITE_SETUP_RUN_STATUSES);
1294
1294
  var siteSetupRunModeSchema = z14.enum(SITE_SETUP_RUN_MODES);
1295
1295
  var siteSetupErrorCodeSchema = z14.enum(SITE_SETUP_ERROR_CODES);
1296
- var siteSetupTaskSchema = z14.object({
1297
- contractVersion: z14.literal("siteplane.setup-task.v1"),
1298
- workflow: z14.enum(["initial_setup", "structure_update"]),
1299
- goal: z14.string().min(1),
1300
- modules: z14.tuple([z14.literal("visual_editor")]),
1301
- packages: z14.object({
1302
- siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1303
- runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1304
- }).strict(),
1305
- communication: z14.object({
1306
- beforeSourceChanges: z14.string().min(1),
1307
- updates: z14.array(z14.string().min(1)).min(1),
1308
- blocker: z14.string().min(1)
1309
- }).strict(),
1310
- discovery: z14.object({
1311
- inspectPublicRoutes: z14.boolean(),
1312
- contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1313
- rules: z14.array(z14.string().min(1)).min(1)
1314
- }).strict(),
1315
- steps: z14.array(z14.object({
1316
- id: z14.enum([
1317
- "inspect_repository",
1318
- "install_packages",
1319
- "instrument_fields",
1320
- "apply_contract",
1321
- "deploy_production",
1322
- "verify_deployment"
1323
- ]),
1324
- instruction: z14.string().min(1)
1325
- }).strict()).length(6),
1326
- completion: z14.object({
1327
- verifiedStatus: z14.literal("ready_for_review"),
1328
- instruction: z14.string().min(1)
1329
- }).strict()
1330
- }).strict();
1331
1296
  var editorFieldSchema = z14.object({
1332
1297
  fieldId: fieldIdSchema,
1333
1298
  label: z14.string().trim().min(1),
@@ -1465,7 +1430,7 @@ var setupCorrectionItemsSchema = z14.array(setupCorrectionItemSchema).max(CONTIN
1465
1430
  });
1466
1431
  }
1467
1432
  });
1468
- var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1433
+ var siteSetupOwnerEditabilityNoteSchema = z14.string().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1469
1434
  if (utf8Bytes(value) > SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES) {
1470
1435
  context.addIssue({
1471
1436
  code: "custom",
@@ -1479,6 +1444,161 @@ var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWN
1479
1444
  });
1480
1445
  }
1481
1446
  });
1447
+ var SITE_SETUP_MODULE_SCOPES = {
1448
+ editing: ["setup:read", "setup:write"],
1449
+ analytics: [
1450
+ "analytics:setup",
1451
+ "analytics:sync",
1452
+ "analytics:test",
1453
+ "analytics:readiness",
1454
+ "analytics:agent_instructions",
1455
+ "analytics:public_key_read"
1456
+ ]
1457
+ };
1458
+ var siteSetupModulesSchema = z14.array(z14.enum(["editing", "analytics"])).min(1).max(2).refine((modules) => modules[0] === "editing" && (modules.length === 1 || modules[1] === "analytics"), "Choose Editing with optional Analytics.");
1459
+ function siteSetupScopes(modules) {
1460
+ return modules.flatMap((module) => [...SITE_SETUP_MODULE_SCOPES[module]]);
1461
+ }
1462
+ function hasExactSiteSetupScopes(scopes, modules) {
1463
+ const matches = (expected) => scopes.length === expected.length && expected.every((scope) => scopes.includes(scope));
1464
+ return modules ? matches(siteSetupScopes(modules)) : matches(siteSetupScopes(["editing"])) || matches(siteSetupScopes(["editing", "analytics"]));
1465
+ }
1466
+ var siteSetupActivityInputSchema = z14.object({
1467
+ phase: z14.enum([
1468
+ "inspecting",
1469
+ "integrating",
1470
+ "deploying",
1471
+ "verifying",
1472
+ "repairing"
1473
+ ]),
1474
+ textId: z14.enum([
1475
+ "inspecting",
1476
+ "integrating",
1477
+ "deploying",
1478
+ "verifying",
1479
+ "repairing"
1480
+ ])
1481
+ }).strict().refine((value) => value.phase === value.textId, "Activity text must describe its phase.");
1482
+ var nextActionFields = {
1483
+ actor: z14.enum(["agent", "user", "siteplane"]),
1484
+ boundary: z14.enum([
1485
+ "source",
1486
+ "environment",
1487
+ "deployment",
1488
+ "verification",
1489
+ "authorization",
1490
+ "review"
1491
+ ]),
1492
+ precondition: z14.string().min(1).max(1e3),
1493
+ instruction: z14.string().min(1).max(2e3),
1494
+ expectedEvidence: z14.string().min(1).max(1e3)
1495
+ };
1496
+ var siteSetupNextActionSchema = z14.discriminatedUnion("kind", [
1497
+ z14.object({
1498
+ ...nextActionFields,
1499
+ kind: z14.literal("run_command"),
1500
+ command: z14.string().min(1).max(500)
1501
+ }).strict(),
1502
+ z14.object({ ...nextActionFields, kind: z14.literal("agent_edit") }).strict(),
1503
+ z14.object({ ...nextActionFields, kind: z14.literal("needs_user_action") }).strict(),
1504
+ z14.object({ ...nextActionFields, kind: z14.literal("wait") }).strict(),
1505
+ z14.object({ ...nextActionFields, kind: z14.literal("done") }).strict()
1506
+ ]);
1507
+ var siteSetupTaskRunSchema = z14.object({
1508
+ runId: z14.string().uuid(),
1509
+ mode: siteSetupRunModeSchema,
1510
+ status: siteSetupRunStatusSchema,
1511
+ fieldContractHash: z14.string().nullable(),
1512
+ deploymentOrigin: z14.string().url().nullable(),
1513
+ deploymentRevision: z14.string().nullable(),
1514
+ publicRuntimeKeyId: z14.string().uuid().nullable(),
1515
+ reviewVersion: z14.string().nullable()
1516
+ }).strict();
1517
+ var siteSetupTaskProgressSchema = z14.object({
1518
+ progressStage: z14.enum([
1519
+ "waiting_for_connection",
1520
+ "agent_connected",
1521
+ "project_context_loaded",
1522
+ "fields_prepared",
1523
+ "deployment_verification",
1524
+ "ready_for_review",
1525
+ "action_required",
1526
+ "completed"
1527
+ ]),
1528
+ lastVerifiedAt: z14.string().datetime().nullable(),
1529
+ lastActivityAt: z14.string().datetime(),
1530
+ activitySource: z14.enum(["user", "server", "agent"]),
1531
+ activityPhase: siteSetupActivityInputSchema.shape.phase.nullable(),
1532
+ activityTextId: siteSetupActivityInputSchema.shape.textId.nullable()
1533
+ }).strict();
1534
+ var siteSetupTaskSchema = z14.object({
1535
+ contractVersion: z14.literal("siteplane.setup-task.v2"),
1536
+ workflow: z14.enum(["initial_setup", "structure_update"]),
1537
+ goal: z14.string().min(1),
1538
+ modules: siteSetupModulesSchema,
1539
+ authorizationVersion: z14.number().int().positive(),
1540
+ authorizedScopes: z14.array(z14.string()).min(2),
1541
+ site: z14.object({
1542
+ siteId: z14.string().uuid(),
1543
+ portalPath: z14.string(),
1544
+ adminOrigin: z14.string().url()
1545
+ }).strict().nullable(),
1546
+ run: siteSetupTaskRunSchema.nullable(),
1547
+ progress: siteSetupTaskProgressSchema.nullable(),
1548
+ assignment: z14.literal("owned"),
1549
+ deadline: z14.string().datetime().nullable(),
1550
+ userInstructions: z14.object({
1551
+ text: siteSetupOwnerEditabilityNoteSchema,
1552
+ source: z14.literal("user"),
1553
+ trust: z14.literal("untrusted")
1554
+ }).strict(),
1555
+ corrections: setupCorrectionItemsSchema,
1556
+ environmentBindings: z14.array(z14.object({
1557
+ name: z14.string().regex(/^[A-Z][A-Z0-9_]+$/u),
1558
+ source: z14.string().min(1),
1559
+ sensitivity: z14.enum(["public", "secret"]),
1560
+ usage: z14.enum(["build", "server", "build_and_server"]),
1561
+ evidence: z14.string().min(1)
1562
+ }).strict()),
1563
+ nextAction: siteSetupNextActionSchema,
1564
+ error: z14.object({
1565
+ code: z14.string().regex(/^[a-z0-9_.]+$/u).max(160),
1566
+ boundary: nextActionFields.boundary,
1567
+ responsibleActor: nextActionFields.actor,
1568
+ retryable: z14.boolean(),
1569
+ retryAfter: z14.number().int().nonnegative().nullable(),
1570
+ requestId: z14.string().regex(/^[A-Za-z0-9_-]+$/u).max(128)
1571
+ }).strict().nullable(),
1572
+ packages: z14.object({
1573
+ siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1574
+ runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1575
+ }).strict(),
1576
+ communication: z14.object({
1577
+ beforeSourceChanges: z14.string().min(1),
1578
+ updates: z14.array(z14.string().min(1)).min(1),
1579
+ blocker: z14.string().min(1)
1580
+ }).strict(),
1581
+ discovery: z14.object({
1582
+ inspectPublicRoutes: z14.boolean(),
1583
+ contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1584
+ rules: z14.array(z14.string().min(1)).min(1)
1585
+ }).strict(),
1586
+ steps: z14.array(z14.object({
1587
+ id: z14.enum([
1588
+ "inspect_repository",
1589
+ "install_packages",
1590
+ "instrument_fields",
1591
+ "apply_contract",
1592
+ "deploy_production",
1593
+ "verify_deployment"
1594
+ ]),
1595
+ instruction: z14.string().min(1)
1596
+ }).strict()).length(6),
1597
+ completion: z14.object({
1598
+ verifiedStatus: z14.literal("ready_for_review"),
1599
+ instruction: z14.string().min(1)
1600
+ }).strict()
1601
+ }).strict().refine((task) => hasExactSiteSetupScopes(task.authorizedScopes, task.modules), "Task scopes must exactly match its modules.");
1482
1602
  var canonicalHashSchema = z14.string().regex(/^sha256:[0-9a-f]{64}$/iu);
1483
1603
  var deploymentRevisionSchema = normalizedSafeTextSchema(256, "deploymentRevision");
1484
1604
  var continueSiteSetupInputSchema = z14.object({
@@ -3970,31 +4090,7 @@ var safeErrorSchema = z27.object({
3970
4090
  message: z27.string().trim().min(1)
3971
4091
  }).passthrough();
3972
4092
  var errorResponseSchema2 = z27.object({ ok: z27.literal(false), error: safeErrorSchema }).passthrough();
3973
- var contextDataSchema = z27.object({
3974
- task: siteSetupTaskSchema,
3975
- site: z27.object({ siteId: z27.string().uuid(), portalPath: z27.string() }),
3976
- run: z27.object({
3977
- runId: z27.string().uuid(),
3978
- mode: z27.enum(["initial", "update"]),
3979
- status: z27.enum([
3980
- "waiting_for_agent",
3981
- "working",
3982
- "action_required",
3983
- "ready_for_review"
3984
- ]),
3985
- fieldContractHash: z27.string().nullable(),
3986
- deploymentOrigin: z27.string().nullable(),
3987
- deploymentRevision: z27.string().nullable(),
3988
- errorCode: z27.string().nullable(),
3989
- errorMessage: z27.string().nullable()
3990
- }),
3991
- structureHandoff: z27.object({
3992
- pendingFields: z27.array(setupCorrectionItemSchema).max(50),
3993
- ownerEditabilityNote: siteSetupOwnerEditabilityNoteSchema
3994
- }).strict().nullable(),
3995
- allowedTasks: z27.array(z27.string()),
3996
- requiredEnvironmentNames: z27.array(z27.string())
3997
- }).strict();
4093
+ var contextDataSchema = z27.object({ task: siteSetupTaskSchema }).strict();
3998
4094
  var contextResponseSchema = z27.object({ ok: z27.literal(true), data: contextDataSchema }).strict();
3999
4095
  var applyDataSchema = z27.object({
4000
4096
  status: z27.enum(["applied", "ready_for_review"]),
@@ -4132,6 +4228,24 @@ async function readGitRevision(projectDir) {
4132
4228
  }
4133
4229
  return revision;
4134
4230
  }
4231
+ async function siteSetupActivityCommand(input) {
4232
+ const activity = siteSetupActivityInputSchema.safeParse({
4233
+ phase: input.phase,
4234
+ textId: input.phase
4235
+ });
4236
+ if (!activity.success)
4237
+ return {
4238
+ status: "action_required",
4239
+ code: "site_setup.invalid_activity",
4240
+ message: "Choose inspecting, integrating, deploying, verifying or repairing."
4241
+ };
4242
+ const response = await postSiteSetup(input, "activity", activity.data);
4243
+ const parsed = z27.object({
4244
+ ok: z27.literal(true),
4245
+ data: z27.object({ status: z27.enum(["recorded", "rate_limited"]) }).strict()
4246
+ }).strict().safeParse(response.payload);
4247
+ return response.ok && parsed.success ? parsed.data.data : actionRequired(response.payload, "Setup activity could not be recorded.");
4248
+ }
4135
4249
 
4136
4250
  // src/bin/run-siteplane.ts
4137
4251
  async function runSiteplaneCli(args, dependencies = createDefaultDependencies()) {
@@ -4326,6 +4440,15 @@ async function runSetupCommand(args, dependencies) {
4326
4440
  dependencies.stdout(JSON.stringify(result, null, 2));
4327
4441
  return { exitCode: result.status === "action_required" ? 1 : 0 };
4328
4442
  }
4443
+ if (area === "activity") {
4444
+ const result = await dependencies.commands.siteSetupActivityCommand({
4445
+ projectDir,
4446
+ phase: readRequiredOption(areaArgs, "--phase"),
4447
+ ...connectionOptions
4448
+ });
4449
+ dependencies.stdout(JSON.stringify(result, null, 2));
4450
+ return { exitCode: result.status === "action_required" ? 1 : 0 };
4451
+ }
4329
4452
  if (area === "apply") {
4330
4453
  const editorDefinition = await dependencies.readJsonFile(
4331
4454
  readRequiredOption(areaArgs, "--definition")
@@ -4348,7 +4471,7 @@ async function runSetupCommand(args, dependencies) {
4348
4471
  dependencies.stdout(JSON.stringify(result, null, 2));
4349
4472
  return { exitCode: result.status === "ready_for_review" ? 0 : 1 };
4350
4473
  }
4351
- dependencies.stdout("Usage: siteplane setup <context|apply|verify>");
4474
+ dependencies.stdout("Usage: siteplane setup <context|activity|apply|verify>");
4352
4475
  return { exitCode: 1 };
4353
4476
  }
4354
4477
  async function runBookingCommand(args, dependencies) {
@@ -4481,6 +4604,7 @@ function createDefaultDependencies() {
4481
4604
  commands: {
4482
4605
  siteSetupApplyCommand,
4483
4606
  siteSetupContextCommand,
4607
+ siteSetupActivityCommand,
4484
4608
  siteSetupVerifyCommand,
4485
4609
  initCommand,
4486
4610
  bookingInitCommand,
package/dist/index.js CHANGED
@@ -1021,41 +1021,6 @@ var CONTINUE_SITE_SETUP_HTTP_BODY_MAX_BYTES = 64 * 1024;
1021
1021
  var siteSetupRunStatusSchema = z14.enum(SITE_SETUP_RUN_STATUSES);
1022
1022
  var siteSetupRunModeSchema = z14.enum(SITE_SETUP_RUN_MODES);
1023
1023
  var siteSetupErrorCodeSchema = z14.enum(SITE_SETUP_ERROR_CODES);
1024
- var siteSetupTaskSchema = z14.object({
1025
- contractVersion: z14.literal("siteplane.setup-task.v1"),
1026
- workflow: z14.enum(["initial_setup", "structure_update"]),
1027
- goal: z14.string().min(1),
1028
- modules: z14.tuple([z14.literal("visual_editor")]),
1029
- packages: z14.object({
1030
- siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1031
- runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1032
- }).strict(),
1033
- communication: z14.object({
1034
- beforeSourceChanges: z14.string().min(1),
1035
- updates: z14.array(z14.string().min(1)).min(1),
1036
- blocker: z14.string().min(1)
1037
- }).strict(),
1038
- discovery: z14.object({
1039
- inspectPublicRoutes: z14.boolean(),
1040
- contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1041
- rules: z14.array(z14.string().min(1)).min(1)
1042
- }).strict(),
1043
- steps: z14.array(z14.object({
1044
- id: z14.enum([
1045
- "inspect_repository",
1046
- "install_packages",
1047
- "instrument_fields",
1048
- "apply_contract",
1049
- "deploy_production",
1050
- "verify_deployment"
1051
- ]),
1052
- instruction: z14.string().min(1)
1053
- }).strict()).length(6),
1054
- completion: z14.object({
1055
- verifiedStatus: z14.literal("ready_for_review"),
1056
- instruction: z14.string().min(1)
1057
- }).strict()
1058
- }).strict();
1059
1024
  var editorFieldSchema = z14.object({
1060
1025
  fieldId: fieldIdSchema,
1061
1026
  label: z14.string().trim().min(1),
@@ -1193,7 +1158,7 @@ var setupCorrectionItemsSchema = z14.array(setupCorrectionItemSchema).max(CONTIN
1193
1158
  });
1194
1159
  }
1195
1160
  });
1196
- var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1161
+ var siteSetupOwnerEditabilityNoteSchema = z14.string().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1197
1162
  if (utf8Bytes(value) > SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES) {
1198
1163
  context.addIssue({
1199
1164
  code: "custom",
@@ -1207,6 +1172,161 @@ var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWN
1207
1172
  });
1208
1173
  }
1209
1174
  });
1175
+ var SITE_SETUP_MODULE_SCOPES = {
1176
+ editing: ["setup:read", "setup:write"],
1177
+ analytics: [
1178
+ "analytics:setup",
1179
+ "analytics:sync",
1180
+ "analytics:test",
1181
+ "analytics:readiness",
1182
+ "analytics:agent_instructions",
1183
+ "analytics:public_key_read"
1184
+ ]
1185
+ };
1186
+ var siteSetupModulesSchema = z14.array(z14.enum(["editing", "analytics"])).min(1).max(2).refine((modules) => modules[0] === "editing" && (modules.length === 1 || modules[1] === "analytics"), "Choose Editing with optional Analytics.");
1187
+ function siteSetupScopes(modules) {
1188
+ return modules.flatMap((module) => [...SITE_SETUP_MODULE_SCOPES[module]]);
1189
+ }
1190
+ function hasExactSiteSetupScopes(scopes, modules) {
1191
+ const matches = (expected) => scopes.length === expected.length && expected.every((scope) => scopes.includes(scope));
1192
+ return modules ? matches(siteSetupScopes(modules)) : matches(siteSetupScopes(["editing"])) || matches(siteSetupScopes(["editing", "analytics"]));
1193
+ }
1194
+ var siteSetupActivityInputSchema = z14.object({
1195
+ phase: z14.enum([
1196
+ "inspecting",
1197
+ "integrating",
1198
+ "deploying",
1199
+ "verifying",
1200
+ "repairing"
1201
+ ]),
1202
+ textId: z14.enum([
1203
+ "inspecting",
1204
+ "integrating",
1205
+ "deploying",
1206
+ "verifying",
1207
+ "repairing"
1208
+ ])
1209
+ }).strict().refine((value) => value.phase === value.textId, "Activity text must describe its phase.");
1210
+ var nextActionFields = {
1211
+ actor: z14.enum(["agent", "user", "siteplane"]),
1212
+ boundary: z14.enum([
1213
+ "source",
1214
+ "environment",
1215
+ "deployment",
1216
+ "verification",
1217
+ "authorization",
1218
+ "review"
1219
+ ]),
1220
+ precondition: z14.string().min(1).max(1e3),
1221
+ instruction: z14.string().min(1).max(2e3),
1222
+ expectedEvidence: z14.string().min(1).max(1e3)
1223
+ };
1224
+ var siteSetupNextActionSchema = z14.discriminatedUnion("kind", [
1225
+ z14.object({
1226
+ ...nextActionFields,
1227
+ kind: z14.literal("run_command"),
1228
+ command: z14.string().min(1).max(500)
1229
+ }).strict(),
1230
+ z14.object({ ...nextActionFields, kind: z14.literal("agent_edit") }).strict(),
1231
+ z14.object({ ...nextActionFields, kind: z14.literal("needs_user_action") }).strict(),
1232
+ z14.object({ ...nextActionFields, kind: z14.literal("wait") }).strict(),
1233
+ z14.object({ ...nextActionFields, kind: z14.literal("done") }).strict()
1234
+ ]);
1235
+ var siteSetupTaskRunSchema = z14.object({
1236
+ runId: z14.string().uuid(),
1237
+ mode: siteSetupRunModeSchema,
1238
+ status: siteSetupRunStatusSchema,
1239
+ fieldContractHash: z14.string().nullable(),
1240
+ deploymentOrigin: z14.string().url().nullable(),
1241
+ deploymentRevision: z14.string().nullable(),
1242
+ publicRuntimeKeyId: z14.string().uuid().nullable(),
1243
+ reviewVersion: z14.string().nullable()
1244
+ }).strict();
1245
+ var siteSetupTaskProgressSchema = z14.object({
1246
+ progressStage: z14.enum([
1247
+ "waiting_for_connection",
1248
+ "agent_connected",
1249
+ "project_context_loaded",
1250
+ "fields_prepared",
1251
+ "deployment_verification",
1252
+ "ready_for_review",
1253
+ "action_required",
1254
+ "completed"
1255
+ ]),
1256
+ lastVerifiedAt: z14.string().datetime().nullable(),
1257
+ lastActivityAt: z14.string().datetime(),
1258
+ activitySource: z14.enum(["user", "server", "agent"]),
1259
+ activityPhase: siteSetupActivityInputSchema.shape.phase.nullable(),
1260
+ activityTextId: siteSetupActivityInputSchema.shape.textId.nullable()
1261
+ }).strict();
1262
+ var siteSetupTaskSchema = z14.object({
1263
+ contractVersion: z14.literal("siteplane.setup-task.v2"),
1264
+ workflow: z14.enum(["initial_setup", "structure_update"]),
1265
+ goal: z14.string().min(1),
1266
+ modules: siteSetupModulesSchema,
1267
+ authorizationVersion: z14.number().int().positive(),
1268
+ authorizedScopes: z14.array(z14.string()).min(2),
1269
+ site: z14.object({
1270
+ siteId: z14.string().uuid(),
1271
+ portalPath: z14.string(),
1272
+ adminOrigin: z14.string().url()
1273
+ }).strict().nullable(),
1274
+ run: siteSetupTaskRunSchema.nullable(),
1275
+ progress: siteSetupTaskProgressSchema.nullable(),
1276
+ assignment: z14.literal("owned"),
1277
+ deadline: z14.string().datetime().nullable(),
1278
+ userInstructions: z14.object({
1279
+ text: siteSetupOwnerEditabilityNoteSchema,
1280
+ source: z14.literal("user"),
1281
+ trust: z14.literal("untrusted")
1282
+ }).strict(),
1283
+ corrections: setupCorrectionItemsSchema,
1284
+ environmentBindings: z14.array(z14.object({
1285
+ name: z14.string().regex(/^[A-Z][A-Z0-9_]+$/u),
1286
+ source: z14.string().min(1),
1287
+ sensitivity: z14.enum(["public", "secret"]),
1288
+ usage: z14.enum(["build", "server", "build_and_server"]),
1289
+ evidence: z14.string().min(1)
1290
+ }).strict()),
1291
+ nextAction: siteSetupNextActionSchema,
1292
+ error: z14.object({
1293
+ code: z14.string().regex(/^[a-z0-9_.]+$/u).max(160),
1294
+ boundary: nextActionFields.boundary,
1295
+ responsibleActor: nextActionFields.actor,
1296
+ retryable: z14.boolean(),
1297
+ retryAfter: z14.number().int().nonnegative().nullable(),
1298
+ requestId: z14.string().regex(/^[A-Za-z0-9_-]+$/u).max(128)
1299
+ }).strict().nullable(),
1300
+ packages: z14.object({
1301
+ siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1302
+ runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1303
+ }).strict(),
1304
+ communication: z14.object({
1305
+ beforeSourceChanges: z14.string().min(1),
1306
+ updates: z14.array(z14.string().min(1)).min(1),
1307
+ blocker: z14.string().min(1)
1308
+ }).strict(),
1309
+ discovery: z14.object({
1310
+ inspectPublicRoutes: z14.boolean(),
1311
+ contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1312
+ rules: z14.array(z14.string().min(1)).min(1)
1313
+ }).strict(),
1314
+ steps: z14.array(z14.object({
1315
+ id: z14.enum([
1316
+ "inspect_repository",
1317
+ "install_packages",
1318
+ "instrument_fields",
1319
+ "apply_contract",
1320
+ "deploy_production",
1321
+ "verify_deployment"
1322
+ ]),
1323
+ instruction: z14.string().min(1)
1324
+ }).strict()).length(6),
1325
+ completion: z14.object({
1326
+ verifiedStatus: z14.literal("ready_for_review"),
1327
+ instruction: z14.string().min(1)
1328
+ }).strict()
1329
+ }).strict().refine((task) => hasExactSiteSetupScopes(task.authorizedScopes, task.modules), "Task scopes must exactly match its modules.");
1210
1330
  var canonicalHashSchema = z14.string().regex(/^sha256:[0-9a-f]{64}$/iu);
1211
1331
  var deploymentRevisionSchema = normalizedSafeTextSchema(256, "deploymentRevision");
1212
1332
  var continueSiteSetupInputSchema = z14.object({
@@ -2366,31 +2486,7 @@ var safeErrorSchema = z27.object({
2366
2486
  message: z27.string().trim().min(1)
2367
2487
  }).passthrough();
2368
2488
  var errorResponseSchema2 = z27.object({ ok: z27.literal(false), error: safeErrorSchema }).passthrough();
2369
- var contextDataSchema = z27.object({
2370
- task: siteSetupTaskSchema,
2371
- site: z27.object({ siteId: z27.string().uuid(), portalPath: z27.string() }),
2372
- run: z27.object({
2373
- runId: z27.string().uuid(),
2374
- mode: z27.enum(["initial", "update"]),
2375
- status: z27.enum([
2376
- "waiting_for_agent",
2377
- "working",
2378
- "action_required",
2379
- "ready_for_review"
2380
- ]),
2381
- fieldContractHash: z27.string().nullable(),
2382
- deploymentOrigin: z27.string().nullable(),
2383
- deploymentRevision: z27.string().nullable(),
2384
- errorCode: z27.string().nullable(),
2385
- errorMessage: z27.string().nullable()
2386
- }),
2387
- structureHandoff: z27.object({
2388
- pendingFields: z27.array(setupCorrectionItemSchema).max(50),
2389
- ownerEditabilityNote: siteSetupOwnerEditabilityNoteSchema
2390
- }).strict().nullable(),
2391
- allowedTasks: z27.array(z27.string()),
2392
- requiredEnvironmentNames: z27.array(z27.string())
2393
- }).strict();
2489
+ var contextDataSchema = z27.object({ task: siteSetupTaskSchema }).strict();
2394
2490
  var contextResponseSchema = z27.object({ ok: z27.literal(true), data: contextDataSchema }).strict();
2395
2491
  var applyDataSchema = z27.object({
2396
2492
  status: z27.enum(["applied", "ready_for_review"]),
package/dist/next.js CHANGED
@@ -1223,41 +1223,6 @@ var CONTINUE_SITE_SETUP_HTTP_BODY_MAX_BYTES = 64 * 1024;
1223
1223
  var siteSetupRunStatusSchema = z14.enum(SITE_SETUP_RUN_STATUSES);
1224
1224
  var siteSetupRunModeSchema = z14.enum(SITE_SETUP_RUN_MODES);
1225
1225
  var siteSetupErrorCodeSchema = z14.enum(SITE_SETUP_ERROR_CODES);
1226
- var siteSetupTaskSchema = z14.object({
1227
- contractVersion: z14.literal("siteplane.setup-task.v1"),
1228
- workflow: z14.enum(["initial_setup", "structure_update"]),
1229
- goal: z14.string().min(1),
1230
- modules: z14.tuple([z14.literal("visual_editor")]),
1231
- packages: z14.object({
1232
- siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1233
- runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1234
- }).strict(),
1235
- communication: z14.object({
1236
- beforeSourceChanges: z14.string().min(1),
1237
- updates: z14.array(z14.string().min(1)).min(1),
1238
- blocker: z14.string().min(1)
1239
- }).strict(),
1240
- discovery: z14.object({
1241
- inspectPublicRoutes: z14.boolean(),
1242
- contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1243
- rules: z14.array(z14.string().min(1)).min(1)
1244
- }).strict(),
1245
- steps: z14.array(z14.object({
1246
- id: z14.enum([
1247
- "inspect_repository",
1248
- "install_packages",
1249
- "instrument_fields",
1250
- "apply_contract",
1251
- "deploy_production",
1252
- "verify_deployment"
1253
- ]),
1254
- instruction: z14.string().min(1)
1255
- }).strict()).length(6),
1256
- completion: z14.object({
1257
- verifiedStatus: z14.literal("ready_for_review"),
1258
- instruction: z14.string().min(1)
1259
- }).strict()
1260
- }).strict();
1261
1226
  var editorFieldSchema = z14.object({
1262
1227
  fieldId: fieldIdSchema,
1263
1228
  label: z14.string().trim().min(1),
@@ -1395,7 +1360,7 @@ var setupCorrectionItemsSchema = z14.array(setupCorrectionItemSchema).max(CONTIN
1395
1360
  });
1396
1361
  }
1397
1362
  });
1398
- var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1363
+ var siteSetupOwnerEditabilityNoteSchema = z14.string().max(SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_LENGTH).superRefine((value, context) => {
1399
1364
  if (utf8Bytes(value) > SITE_SETUP_OWNER_EDITABILITY_NOTE_MAX_BYTES) {
1400
1365
  context.addIssue({
1401
1366
  code: "custom",
@@ -1409,6 +1374,161 @@ var siteSetupOwnerEditabilityNoteSchema = z14.string().trim().max(SITE_SETUP_OWN
1409
1374
  });
1410
1375
  }
1411
1376
  });
1377
+ var SITE_SETUP_MODULE_SCOPES = {
1378
+ editing: ["setup:read", "setup:write"],
1379
+ analytics: [
1380
+ "analytics:setup",
1381
+ "analytics:sync",
1382
+ "analytics:test",
1383
+ "analytics:readiness",
1384
+ "analytics:agent_instructions",
1385
+ "analytics:public_key_read"
1386
+ ]
1387
+ };
1388
+ var siteSetupModulesSchema = z14.array(z14.enum(["editing", "analytics"])).min(1).max(2).refine((modules) => modules[0] === "editing" && (modules.length === 1 || modules[1] === "analytics"), "Choose Editing with optional Analytics.");
1389
+ function siteSetupScopes(modules) {
1390
+ return modules.flatMap((module) => [...SITE_SETUP_MODULE_SCOPES[module]]);
1391
+ }
1392
+ function hasExactSiteSetupScopes(scopes, modules) {
1393
+ const matches = (expected) => scopes.length === expected.length && expected.every((scope) => scopes.includes(scope));
1394
+ return modules ? matches(siteSetupScopes(modules)) : matches(siteSetupScopes(["editing"])) || matches(siteSetupScopes(["editing", "analytics"]));
1395
+ }
1396
+ var siteSetupActivityInputSchema = z14.object({
1397
+ phase: z14.enum([
1398
+ "inspecting",
1399
+ "integrating",
1400
+ "deploying",
1401
+ "verifying",
1402
+ "repairing"
1403
+ ]),
1404
+ textId: z14.enum([
1405
+ "inspecting",
1406
+ "integrating",
1407
+ "deploying",
1408
+ "verifying",
1409
+ "repairing"
1410
+ ])
1411
+ }).strict().refine((value) => value.phase === value.textId, "Activity text must describe its phase.");
1412
+ var nextActionFields = {
1413
+ actor: z14.enum(["agent", "user", "siteplane"]),
1414
+ boundary: z14.enum([
1415
+ "source",
1416
+ "environment",
1417
+ "deployment",
1418
+ "verification",
1419
+ "authorization",
1420
+ "review"
1421
+ ]),
1422
+ precondition: z14.string().min(1).max(1e3),
1423
+ instruction: z14.string().min(1).max(2e3),
1424
+ expectedEvidence: z14.string().min(1).max(1e3)
1425
+ };
1426
+ var siteSetupNextActionSchema = z14.discriminatedUnion("kind", [
1427
+ z14.object({
1428
+ ...nextActionFields,
1429
+ kind: z14.literal("run_command"),
1430
+ command: z14.string().min(1).max(500)
1431
+ }).strict(),
1432
+ z14.object({ ...nextActionFields, kind: z14.literal("agent_edit") }).strict(),
1433
+ z14.object({ ...nextActionFields, kind: z14.literal("needs_user_action") }).strict(),
1434
+ z14.object({ ...nextActionFields, kind: z14.literal("wait") }).strict(),
1435
+ z14.object({ ...nextActionFields, kind: z14.literal("done") }).strict()
1436
+ ]);
1437
+ var siteSetupTaskRunSchema = z14.object({
1438
+ runId: z14.string().uuid(),
1439
+ mode: siteSetupRunModeSchema,
1440
+ status: siteSetupRunStatusSchema,
1441
+ fieldContractHash: z14.string().nullable(),
1442
+ deploymentOrigin: z14.string().url().nullable(),
1443
+ deploymentRevision: z14.string().nullable(),
1444
+ publicRuntimeKeyId: z14.string().uuid().nullable(),
1445
+ reviewVersion: z14.string().nullable()
1446
+ }).strict();
1447
+ var siteSetupTaskProgressSchema = z14.object({
1448
+ progressStage: z14.enum([
1449
+ "waiting_for_connection",
1450
+ "agent_connected",
1451
+ "project_context_loaded",
1452
+ "fields_prepared",
1453
+ "deployment_verification",
1454
+ "ready_for_review",
1455
+ "action_required",
1456
+ "completed"
1457
+ ]),
1458
+ lastVerifiedAt: z14.string().datetime().nullable(),
1459
+ lastActivityAt: z14.string().datetime(),
1460
+ activitySource: z14.enum(["user", "server", "agent"]),
1461
+ activityPhase: siteSetupActivityInputSchema.shape.phase.nullable(),
1462
+ activityTextId: siteSetupActivityInputSchema.shape.textId.nullable()
1463
+ }).strict();
1464
+ var siteSetupTaskSchema = z14.object({
1465
+ contractVersion: z14.literal("siteplane.setup-task.v2"),
1466
+ workflow: z14.enum(["initial_setup", "structure_update"]),
1467
+ goal: z14.string().min(1),
1468
+ modules: siteSetupModulesSchema,
1469
+ authorizationVersion: z14.number().int().positive(),
1470
+ authorizedScopes: z14.array(z14.string()).min(2),
1471
+ site: z14.object({
1472
+ siteId: z14.string().uuid(),
1473
+ portalPath: z14.string(),
1474
+ adminOrigin: z14.string().url()
1475
+ }).strict().nullable(),
1476
+ run: siteSetupTaskRunSchema.nullable(),
1477
+ progress: siteSetupTaskProgressSchema.nullable(),
1478
+ assignment: z14.literal("owned"),
1479
+ deadline: z14.string().datetime().nullable(),
1480
+ userInstructions: z14.object({
1481
+ text: siteSetupOwnerEditabilityNoteSchema,
1482
+ source: z14.literal("user"),
1483
+ trust: z14.literal("untrusted")
1484
+ }).strict(),
1485
+ corrections: setupCorrectionItemsSchema,
1486
+ environmentBindings: z14.array(z14.object({
1487
+ name: z14.string().regex(/^[A-Z][A-Z0-9_]+$/u),
1488
+ source: z14.string().min(1),
1489
+ sensitivity: z14.enum(["public", "secret"]),
1490
+ usage: z14.enum(["build", "server", "build_and_server"]),
1491
+ evidence: z14.string().min(1)
1492
+ }).strict()),
1493
+ nextAction: siteSetupNextActionSchema,
1494
+ error: z14.object({
1495
+ code: z14.string().regex(/^[a-z0-9_.]+$/u).max(160),
1496
+ boundary: nextActionFields.boundary,
1497
+ responsibleActor: nextActionFields.actor,
1498
+ retryable: z14.boolean(),
1499
+ retryAfter: z14.number().int().nonnegative().nullable(),
1500
+ requestId: z14.string().regex(/^[A-Za-z0-9_-]+$/u).max(128)
1501
+ }).strict().nullable(),
1502
+ packages: z14.object({
1503
+ siteplane: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u),
1504
+ runtimeNext: z14.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u)
1505
+ }).strict(),
1506
+ communication: z14.object({
1507
+ beforeSourceChanges: z14.string().min(1),
1508
+ updates: z14.array(z14.string().min(1)).min(1),
1509
+ blocker: z14.string().min(1)
1510
+ }).strict(),
1511
+ discovery: z14.object({
1512
+ inspectPublicRoutes: z14.boolean(),
1513
+ contentKinds: z14.array(z14.enum(["text", "longText", "link", "image"])).min(1),
1514
+ rules: z14.array(z14.string().min(1)).min(1)
1515
+ }).strict(),
1516
+ steps: z14.array(z14.object({
1517
+ id: z14.enum([
1518
+ "inspect_repository",
1519
+ "install_packages",
1520
+ "instrument_fields",
1521
+ "apply_contract",
1522
+ "deploy_production",
1523
+ "verify_deployment"
1524
+ ]),
1525
+ instruction: z14.string().min(1)
1526
+ }).strict()).length(6),
1527
+ completion: z14.object({
1528
+ verifiedStatus: z14.literal("ready_for_review"),
1529
+ instruction: z14.string().min(1)
1530
+ }).strict()
1531
+ }).strict().refine((task) => hasExactSiteSetupScopes(task.authorizedScopes, task.modules), "Task scopes must exactly match its modules.");
1412
1532
  var canonicalHashSchema = z14.string().regex(/^sha256:[0-9a-f]{64}$/iu);
1413
1533
  var deploymentRevisionSchema = normalizedSafeTextSchema(256, "deploymentRevision");
1414
1534
  var continueSiteSetupInputSchema = z14.object({
@@ -2736,31 +2856,7 @@ var safeErrorSchema = z27.object({
2736
2856
  message: z27.string().trim().min(1)
2737
2857
  }).passthrough();
2738
2858
  var errorResponseSchema2 = z27.object({ ok: z27.literal(false), error: safeErrorSchema }).passthrough();
2739
- var contextDataSchema = z27.object({
2740
- task: siteSetupTaskSchema,
2741
- site: z27.object({ siteId: z27.string().uuid(), portalPath: z27.string() }),
2742
- run: z27.object({
2743
- runId: z27.string().uuid(),
2744
- mode: z27.enum(["initial", "update"]),
2745
- status: z27.enum([
2746
- "waiting_for_agent",
2747
- "working",
2748
- "action_required",
2749
- "ready_for_review"
2750
- ]),
2751
- fieldContractHash: z27.string().nullable(),
2752
- deploymentOrigin: z27.string().nullable(),
2753
- deploymentRevision: z27.string().nullable(),
2754
- errorCode: z27.string().nullable(),
2755
- errorMessage: z27.string().nullable()
2756
- }),
2757
- structureHandoff: z27.object({
2758
- pendingFields: z27.array(setupCorrectionItemSchema).max(50),
2759
- ownerEditabilityNote: siteSetupOwnerEditabilityNoteSchema
2760
- }).strict().nullable(),
2761
- allowedTasks: z27.array(z27.string()),
2762
- requiredEnvironmentNames: z27.array(z27.string())
2763
- }).strict();
2859
+ var contextDataSchema = z27.object({ task: siteSetupTaskSchema }).strict();
2764
2860
  var contextResponseSchema = z27.object({ ok: z27.literal(true), data: contextDataSchema }).strict();
2765
2861
  var applyDataSchema = z27.object({
2766
2862
  status: z27.enum(["applied", "ready_for_review"]),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "siteplane",
3
3
  "private": false,
4
- "version": "0.1.41",
4
+ "version": "0.1.42",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "publishConfig": {