create-safest-tools 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +3 -3
  2. package/package.json +2 -2
  3. package/src/config.mjs +2 -2
  4. package/src/update.mjs +10 -1
  5. package/template/README.md +2 -2
  6. package/template/console/README.md +2 -2
  7. package/template/console/analytics/AnalyticsWorkspace.tsx +49 -36
  8. package/template/console/analytics/controller.ts +10 -2
  9. package/template/console/analytics/types.ts +7 -0
  10. package/template/console/appeals/AppealFollowup.tsx +171 -0
  11. package/template/console/appeals/AppealWorkspace.tsx +33 -4
  12. package/template/console/appeals/RecordAppealDialog.tsx +42 -0
  13. package/template/console/appeals/appeal-corrections.css +29 -0
  14. package/template/console/appeals/controller.ts +40 -14
  15. package/template/console/appeals/events.ts +1 -0
  16. package/template/console/appeals/types.ts +6 -0
  17. package/template/console/appeals/useAppealDraftGuard.ts +12 -0
  18. package/template/console/assistant/AssistantWorkspace.tsx +28 -5
  19. package/template/console/command/CommandCentre.tsx +101 -64
  20. package/template/console/command/controller.ts +80 -70
  21. package/template/console/command/events.ts +1 -2
  22. package/template/console/command/presentation.ts +29 -0
  23. package/template/console/command/store.ts +4 -4
  24. package/template/console/command/types.ts +26 -21
  25. package/template/console/configuration/ConfigurationBuilders.tsx +101 -0
  26. package/template/console/configuration/ConfigurationDialog.tsx +28 -13
  27. package/template/console/configuration/ConfigurationWorkspace.tsx +21 -8
  28. package/template/console/configuration/types.ts +1 -1
  29. package/template/console/lib/priority.ts +13 -0
  30. package/template/console/operations/CaseEscalations.tsx +142 -0
  31. package/template/console/operations/OperationsWorkspace.tsx +2 -0
  32. package/template/console/operations/case-escalations.css +20 -0
  33. package/template/console/people/PeopleWorkspace.tsx +8 -4
  34. package/template/console/people/PersonAccessDialog.tsx +40 -0
  35. package/template/console/people/types.ts +1 -0
  36. package/template/console/profile/ProfileWorkspace.tsx +1 -1
  37. package/template/console/registry/IntegrationSetup.tsx +41 -0
  38. package/template/console/registry/IntegrationVerification.tsx +54 -0
  39. package/template/console/registry/RegistryDetailsDialog.tsx +2 -2
  40. package/template/console/registry/RegistryDialog.tsx +56 -27
  41. package/template/console/registry/RegistryWorkspace.tsx +10 -5
  42. package/template/console/registry/integration-verification.css +25 -0
  43. package/template/console/reports/CaseActions.tsx +81 -0
  44. package/template/console/reports/CaseContinuity.tsx +27 -0
  45. package/template/console/reports/CaseNotices.tsx +48 -0
  46. package/template/console/reports/CaseOwnership.tsx +78 -0
  47. package/template/console/reports/CaseReviewTasks.tsx +148 -0
  48. package/template/console/reports/EnrichmentFindings.tsx +148 -0
  49. package/template/console/reports/InvestigationBrief.tsx +29 -0
  50. package/template/console/reports/ReportDrawer.tsx +122 -67
  51. package/template/console/reports/ReportWorkspace.tsx +112 -23
  52. package/template/console/reports/controller.ts +125 -60
  53. package/template/console/reports/events.ts +9 -2
  54. package/template/console/reports/load-inbox.ts +17 -0
  55. package/template/console/reports/presence-presentation.ts +52 -0
  56. package/template/console/reports/private-drafts.ts +32 -0
  57. package/template/console/reports/store.ts +2 -2
  58. package/template/console/reports/types.ts +50 -2
  59. package/template/console/reports/use-editing-access.ts +13 -0
  60. package/template/console/settings/SettingsWorkspace.tsx +1 -1
  61. package/template/console/shell/WorkspaceShell.tsx +55 -29
  62. package/template/console/shell/WorkspaceUpdateNotice.tsx +48 -0
  63. package/template/console/shell/controller.ts +23 -16
  64. package/template/console/shell/navigation.ts +30 -39
  65. package/template/console/workflows/CreatePlaybookDialog.tsx +73 -0
  66. package/template/console/workflows/PlaybookExamples.tsx +160 -0
  67. package/template/console/workflows/PlaybookFields.tsx +109 -0
  68. package/template/console/workflows/PlaybookGuideEditor.tsx +125 -0
  69. package/template/console/workflows/PlaybookHistory.tsx +106 -0
  70. package/template/console/workflows/WorkflowDialogs.tsx +2 -1
  71. package/template/console/workflows/WorkflowStudio.tsx +108 -39
  72. package/template/console/workflows/WorkflowWorkspace.tsx +9 -7
  73. package/template/console/workflows/templates.ts +3 -3
  74. package/template/console/workflows/types.ts +11 -0
  75. package/template/migrations/0001_safest_resolve_baseline.sql +0 -1
  76. package/template/migrations/0002_playbook_publication_evidence.sql +36 -0
  77. package/template/migrations/0003_action_confirmation.sql +24 -0
  78. package/template/migrations/0004_notice_recovery.sql +22 -0
  79. package/template/migrations/0005_appeal_continuity.sql +17 -0
  80. package/template/migrations/0006_case_ownership.sql +23 -0
  81. package/template/migrations/0007_integration_verification.sql +21 -0
  82. package/template/migrations/0008_case_escalations.sql +135 -0
  83. package/template/migrations/0009_participant_continuation.sql +61 -0
  84. package/template/migrations/0010_appeal_corrections.sql +41 -0
  85. package/template/npm-shrinkwrap.json +8036 -0
  86. package/template/package.json +31 -22
  87. package/template/public/_headers +16 -1
  88. package/template/public/console/auth-shell.js +22151 -14847
  89. package/template/public/console/release.json +1 -0
  90. package/template/public/console/workspace-features.css +2 -0
  91. package/template/public/embed/embed.css +3 -0
  92. package/template/public/embed/embed.js +19 -1
  93. package/template/public/embed/index.html +2 -0
  94. package/template/public/index.html +9 -6
  95. package/template/public/participant.css +2 -0
  96. package/template/public/participant.html +13 -0
  97. package/template/public/participant.js +111 -0
  98. package/template/public/public-report.js +21 -1
  99. package/template/public/report/index.html +1 -1
  100. package/template/public/styles.css +599 -83
  101. package/template/public/workspace.css +124 -0
  102. package/template/scripts/reports-plan.mjs +1 -1
  103. package/template/shared/case-escalations.ts +31 -0
  104. package/template/shared/integration-progress.ts +27 -0
  105. package/template/shared/notice-inputs.ts +3 -0
  106. package/template/shared/playbook-resources.ts +14 -0
  107. package/template/shared/playbooks.ts +249 -0
  108. package/template/src/agent-executor.ts +25 -8
  109. package/template/src/ai-observability.ts +14 -13
  110. package/template/src/ai-registry-validation.ts +1 -1
  111. package/template/src/appeal-continuity.ts +75 -0
  112. package/template/src/appeal-correction-state.ts +46 -0
  113. package/template/src/appeal-corrections.ts +112 -0
  114. package/template/src/appeal-decisions.ts +85 -0
  115. package/template/src/assistant.ts +3 -4
  116. package/template/src/case-escalations.ts +223 -0
  117. package/template/src/case-investigator.ts +179 -0
  118. package/template/src/component-executor.ts +5 -4
  119. package/template/src/configuration-registry.ts +4 -1
  120. package/template/src/connection-oauth.ts +12 -3
  121. package/template/src/database-readiness.ts +14 -0
  122. package/template/src/human-tasks.ts +152 -55
  123. package/template/src/index.ts +191 -29
  124. package/template/src/installation-admin.ts +2 -1
  125. package/template/src/integration-progress.ts +45 -0
  126. package/template/src/integration-verification.ts +249 -0
  127. package/template/src/investigation-evidence.ts +95 -0
  128. package/template/src/investigator-fixture.ts +30 -0
  129. package/template/src/notice-delivery.ts +19 -0
  130. package/template/src/notice-recovery.ts +81 -0
  131. package/template/src/operator-scope.ts +31 -0
  132. package/template/src/participant-access.ts +163 -0
  133. package/template/src/participant-case.ts +87 -0
  134. package/template/src/participant-customer-access.ts +93 -0
  135. package/template/src/participant-recovery.ts +43 -0
  136. package/template/src/participant-routes.ts +67 -0
  137. package/template/src/platform-registry-validation.ts +25 -2
  138. package/template/src/platform-registry.ts +10 -7
  139. package/template/src/playbook-resources.ts +58 -0
  140. package/template/src/report-admin.ts +9 -2
  141. package/template/src/report-auth.ts +1 -28
  142. package/template/src/report-better-auth.ts +18 -6
  143. package/template/src/report-delivery.ts +149 -148
  144. package/template/src/report-email-inbound.ts +33 -22
  145. package/template/src/report-email-template.ts +5 -2
  146. package/template/src/report-email.ts +7 -30
  147. package/template/src/report-governance.ts +42 -45
  148. package/template/src/report-http.ts +37 -2
  149. package/template/src/report-operations.ts +30 -67
  150. package/template/src/report-operator-accounts.ts +7 -6
  151. package/template/src/report-ownership.ts +64 -0
  152. package/template/src/report-presence.ts +15 -9
  153. package/template/src/report-repository.ts +16 -7
  154. package/template/src/report-turnstile.ts +7 -3
  155. package/template/src/report-types.ts +1 -0
  156. package/template/src/report-workflow.ts +183 -249
  157. package/template/src/workflow-actions.ts +248 -156
  158. package/template/src/workflow-compiler.ts +63 -12
  159. package/template/src/workflow-dynamic-runtime.ts +20 -9
  160. package/template/src/workflow-effects.ts +117 -39
  161. package/template/src/workflow-event-transport.ts +16 -0
  162. package/template/src/workflow-expressions.ts +30 -0
  163. package/template/src/workflow-loader-code.ts +21 -0
  164. package/template/src/workflow-platform-types.ts +3 -0
  165. package/template/src/workflow-platform-validation.ts +23 -1
  166. package/template/src/workflow-repository.ts +131 -28
  167. package/template/src/workflow-runs.ts +61 -13
  168. package/template/src/workflow-simulator.ts +7 -4
  169. package/template/src/workspace-governance.ts +6 -4
  170. package/template/tsconfig.json +1 -0
  171. package/template/vite.console.config.ts +30 -2
  172. package/template/worker-configuration.d.ts +3 -2
@@ -268,12 +268,14 @@ export async function expireExports(env: Env, limit = 100): Promise<number> {
268
268
  return expired;
269
269
  }
270
270
 
271
- export async function loadWorkflowAnalytics(db: D1Database, days: number): Promise<Record<string, unknown>> {
271
+ export async function loadWorkflowAnalytics(db: D1Database, days: number, queueScope: string[] | null = null): Promise<Record<string, unknown>> {
272
272
  const since = new Date(Date.now() - Math.max(1, Math.min(366, days)) * 86_400_000).toISOString();
273
+ const scope = queueScope === null ? null : JSON.stringify(queueScope);
274
+ const visibleReports = `SELECT id FROM reports WHERE (?3 IS NULL OR queue_id IN (SELECT value FROM json_each(?3)))`;
273
275
  const [states, steps, components] = await Promise.all([
274
- db.prepare(`SELECT state, run_kind AS runKind, COUNT(*) AS count, AVG((julianday(COALESCE(finished_at, ?2)) - julianday(COALESCE(started_at, created_at))) * 86400000) AS averageDurationMs FROM workflow_runs WHERE created_at >= ?1 GROUP BY state, run_kind ORDER BY run_kind, state`).bind(since, now()).all(),
275
- db.prepare(`SELECT node_type AS nodeType, state, COUNT(*) AS count, AVG((julianday(COALESCE(finished_at, ?2)) - julianday(started_at)) * 86400000) AS averageDurationMs FROM workflow_step_runs WHERE updated_at >= ?1 GROUP BY node_type, state ORDER BY node_type, state`).bind(since, now()).all(),
276
- db.prepare(`SELECT d.component_key AS componentKey, r.state, COUNT(*) AS count, AVG((julianday(COALESCE(r.finished_at, ?2)) - julianday(r.started_at)) * 86400000) AS averageDurationMs FROM component_runs r JOIN component_versions v ON v.id = r.component_version_id JOIN component_definitions d ON d.id = v.definition_id WHERE r.created_at >= ?1 GROUP BY d.component_key, r.state ORDER BY d.component_key, r.state`).bind(since, now()).all(),
276
+ db.prepare(`SELECT state, run_kind AS runKind, COUNT(*) AS count, AVG((julianday(COALESCE(finished_at, ?2)) - julianday(COALESCE(started_at, created_at))) * 86400000) AS averageDurationMs FROM workflow_runs WHERE created_at >= ?1 AND report_id IN (${visibleReports}) GROUP BY state, run_kind ORDER BY run_kind, state`).bind(since, now(), scope).all(),
277
+ db.prepare(`SELECT node_type AS nodeType, state, COUNT(*) AS count, AVG((julianday(COALESCE(finished_at, ?2)) - julianday(started_at)) * 86400000) AS averageDurationMs FROM workflow_step_runs WHERE updated_at >= ?1 AND run_id IN (SELECT id FROM workflow_runs WHERE report_id IN (${visibleReports})) GROUP BY node_type, state ORDER BY node_type, state`).bind(since, now(), scope).all(),
278
+ db.prepare(`SELECT d.component_key AS componentKey, r.state, COUNT(*) AS count, AVG((julianday(COALESCE(r.finished_at, ?2)) - julianday(r.started_at)) * 86400000) AS averageDurationMs FROM component_runs r JOIN component_versions v ON v.id = r.component_version_id JOIN component_definitions d ON d.id = v.definition_id WHERE r.created_at >= ?1 AND r.report_id IN (${visibleReports}) GROUP BY d.component_key, r.state ORDER BY d.component_key, r.state`).bind(since, now(), scope).all(),
277
279
  ]);
278
280
  return { since, runStates: states.results, stepPerformance: steps.results, componentPerformance: components.results };
279
281
  }
@@ -3,6 +3,7 @@
3
3
  "target": "ES2022",
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Bundler",
6
+ "resolveJsonModule": true,
6
7
  "lib": [
7
8
  "ES2022"
8
9
  ],
@@ -1,9 +1,36 @@
1
1
  import { fileURLToPath, URL } from "node:url";
2
+ import { createHash } from "node:crypto";
3
+ import { readFile, writeFile } from "node:fs/promises";
2
4
  import react from "@vitejs/plugin-react";
3
- import { defineConfig } from "vite";
5
+ import { defineConfig, type Plugin } from "vite";
6
+
7
+ // Fixed URLs can retain an older release in a customer's browser even after
8
+ // cache headers change. Fingerprint every shell dependency on every build.
9
+ function workspaceRelease(): Plugin {
10
+ const path = (name: string) => fileURLToPath(new URL(`./public/${name}`, import.meta.url));
11
+ const hash = (value: string) => createHash("sha256").update(value).digest("hex").slice(0, 20);
12
+ return {
13
+ name: "workspace-release",
14
+ async closeBundle() {
15
+ const tokens = hash(await readFile(path("brand-tokens.css"), "utf8"));
16
+ const styles = (await readFile(path("styles.css"), "utf8")).replace(/\.\/brand-tokens\.css(?:\?v=[a-f0-9]+)?/g, `./brand-tokens.css?v=${tokens}`);
17
+ await writeFile(path("styles.css"), styles);
18
+ let html = (await readFile(path("index.html"), "utf8")).replace(/\s*<meta name="safest-release" content="[a-f0-9]+"\s*\/>/, "");
19
+ for (const name of ["styles.css", "workspace.css", "console/workspace-features.css", "customer-brand.js", "widget.js", "console/auth-shell.js"]) {
20
+ const fingerprint = hash(await readFile(path(name), "utf8"));
21
+ const pattern = new RegExp(`\\./${name.replaceAll(".", "\\.")}(?:\\?v=[a-f0-9]+)?(?=")`, "g");
22
+ html = html.replace(pattern, `./${name}?v=${fingerprint}`);
23
+ }
24
+ const release = hash(html);
25
+ html = html.replace("<head>", `<head>\n <meta name="safest-release" content="${release}" />`);
26
+ await writeFile(path("index.html"), html);
27
+ await writeFile(path("console/release.json"), `${JSON.stringify({ release })}\n`);
28
+ },
29
+ };
30
+ }
4
31
 
5
32
  export default defineConfig({
6
- plugins: [react()],
33
+ plugins: [react(), workspaceRelease()],
7
34
  publicDir: false,
8
35
  define: { "process.env.NODE_ENV": JSON.stringify("production") },
9
36
  build: {
@@ -15,6 +42,7 @@ export default defineConfig({
15
42
  entry: fileURLToPath(new URL("./console/main.tsx", import.meta.url)),
16
43
  formats: ["es"],
17
44
  fileName: () => "auth-shell.js",
45
+ cssFileName: "workspace-features",
18
46
  },
19
47
  },
20
48
  });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- // Generated by Wrangler by running `wrangler types --env-file=config/dev.vars.example --include-runtime=false --strict-vars=false` (hash: 2d2c98e01480f3c1492835530279c5f1)
2
+ // Generated by Wrangler by running `wrangler types --env-file=config/dev.vars.example --include-runtime=false --strict-vars=false` (hash: c7dab1dfe1b9b2d1711cbd0adcafd9a7)
3
3
  interface __BaseEnv_Env {
4
4
  PROFILE_MEDIA: R2Bucket;
5
5
  WORKFLOW_ARTIFACTS: R2Bucket;
@@ -47,12 +47,13 @@ interface __BaseEnv_Env {
47
47
  AI_LOCAL_FIXTURE_ENABLED: string;
48
48
  AI_LOCAL_FIXTURE_JSON: string;
49
49
  WORKSPACE_PRESENCE: DurableObjectNamespace<import("./src/index").WorkspacePresence>;
50
+ CASE_INVESTIGATOR: DurableObjectNamespace<import("./src/index").CaseInvestigator>;
50
51
  WORKFLOWS: Workflow<Parameters<import("./src/index").DynamicWorkflow['run']>[0]['payload']>;
51
52
  }
52
53
  declare namespace Cloudflare {
53
54
  interface GlobalProps {
54
55
  mainModule: typeof import("./src/index");
55
- durableNamespaces: "WorkspacePresence";
56
+ durableNamespaces: "WorkspacePresence" | "CaseInvestigator";
56
57
  }
57
58
  interface Env extends __BaseEnv_Env {}
58
59
  }