@astrale-os/adapter-cloudflare 0.2.1 → 0.3.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 (64) hide show
  1. package/dist/build.d.ts +2 -1
  2. package/dist/build.d.ts.map +1 -1
  3. package/dist/build.js +1 -1
  4. package/dist/build.js.map +1 -1
  5. package/dist/client.d.ts +14 -13
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +25 -18
  8. package/dist/client.js.map +1 -1
  9. package/dist/cloudflare.d.ts +4 -1
  10. package/dist/cloudflare.d.ts.map +1 -1
  11. package/dist/cloudflare.js +40 -18
  12. package/dist/cloudflare.js.map +1 -1
  13. package/dist/codegen/worker.d.ts +3 -3
  14. package/dist/codegen/worker.d.ts.map +1 -1
  15. package/dist/codegen/worker.js +19 -8
  16. package/dist/codegen/worker.js.map +1 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.js +2 -2
  19. package/dist/params.d.ts +3 -0
  20. package/dist/params.d.ts.map +1 -1
  21. package/package.json +2 -2
  22. package/src/build.ts +2 -1
  23. package/src/client.ts +43 -18
  24. package/src/cloudflare.ts +41 -14
  25. package/src/codegen/worker.ts +19 -8
  26. package/src/index.ts +2 -2
  27. package/src/params.ts +4 -0
  28. package/template/CLAUDE.md +24 -0
  29. package/template/README.md +24 -15
  30. package/template/astrale.config.ts +4 -4
  31. package/template/client/README.md +9 -9
  32. package/template/client/__tests__/app.test.tsx +58 -19
  33. package/template/client/__tests__/harness.ts +16 -0
  34. package/template/client/__tests__/kernel.test.ts +23 -3
  35. package/template/client/src/shell/use-async.ts +4 -1
  36. package/template/client/src/status/components/StatusCard.tsx +115 -5
  37. package/template/client/src/status/hooks/useCheckable.query.ts +48 -40
  38. package/template/client/src/status/index.ts +2 -2
  39. package/template/client/src/status/status.api.ts +18 -1
  40. package/template/client/src/status/status.mappers.ts +89 -6
  41. package/template/client/src/status/status.types.ts +17 -2
  42. package/template/client/src/styles.css +235 -14
  43. package/template/client/src/views/status.tsx +1 -1
  44. package/template/core/monitor/index.ts +2 -2
  45. package/template/core/monitor/node.ts +12 -6
  46. package/template/domain.ts +6 -4
  47. package/template/functions/index.ts +31 -7
  48. package/template/package.json +2 -2
  49. package/template/pnpm-lock.yaml +2780 -0
  50. package/template/runtime/index.ts +8 -17
  51. package/template/runtime/monitoring/index.ts +8 -0
  52. package/template/runtime/{monitor → monitoring/monitor}/check.ts +3 -3
  53. package/template/runtime/{monitor → monitoring/monitor}/index.ts +3 -2
  54. package/template/runtime/{monitor → monitoring/monitor}/seed.ts +19 -10
  55. package/template/runtime/{monitor → monitoring/monitor}/watch.ts +5 -5
  56. package/template/runtime/{status-page → monitoring/page}/add.ts +2 -2
  57. package/template/runtime/{status-page → monitoring/page}/check.ts +2 -2
  58. package/template/runtime/{status-page → monitoring/page}/create.ts +3 -3
  59. package/template/runtime/monitoring/page/index.ts +9 -0
  60. package/template/schema/monitor.ts +6 -8
  61. package/template/views/index.ts +1 -1
  62. package/template/.agents/skills/astrale-cli/SKILL.md +0 -458
  63. package/template/.agents/skills/astrale-domain/SKILL.md +0 -372
  64. package/template/runtime/status-page/index.ts +0 -8
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Runtime composition root — the ONLY place request context (kernel/self/params/
3
3
  * auth) and `deps` meet the per-feature logic. Each `execute` resolves what it
4
- * needs (the `Prober` port, the self node) and delegates to the per-operation I/O
5
- * functions in `runtime/monitor/` and `runtime/status-page/`. No business logic
4
+ * needs (the `Prober` port, the self node) and delegates to the monitoring
5
+ * bounded context in `runtime/monitoring/{monitor,page}`. No business logic
6
6
  * lives here.
7
7
  *
8
8
  * `check` is the `Checkable` interface method, declared `abstract`, so it is
@@ -19,8 +19,7 @@ import type { Deps } from '../deps'
19
19
 
20
20
  import { MONITOR_KEYS } from '../core/monitor'
21
21
  import { schema } from '../schema'
22
- import { check as monitorCheck, seed, watch } from './monitor'
23
- import { add, check as pageCheck, create } from './status-page'
22
+ import { monitor, page } from './monitoring'
24
23
 
25
24
  const method = remoteMethod<Deps>()
26
25
  const classMethods = remoteClassMethods<Deps>()
@@ -34,21 +33,14 @@ const monitorCheckMethod = method(schema, 'Monitor', 'check', {
34
33
  const url = node.props[MONITOR_KEYS.url]
35
34
  if (typeof url !== 'string') throw new Error('Monitor node is missing its url property')
36
35
  // Pass the node to the picker — the prober is chosen FOR this monitor.
37
- return monitorCheck(kernel, deps.prober({ class: node.class.raw, url }), self.path.raw, url)
36
+ return monitor.check(kernel, deps.prober({ class: node.class.raw, url }), self.path.raw, url)
38
37
  },
39
38
  })
40
39
 
41
40
  const watchMethod = method(schema, 'Monitor', 'watch', {
42
41
  authorize: async () => undefined,
43
42
  execute: ({ kernel, params }) => {
44
- return watch(kernel, params)
45
- },
46
- })
47
-
48
- const seedMethod = method(schema, 'Monitor', 'seed', {
49
- authorize: async () => undefined,
50
- execute: ({ kernel, deps }) => {
51
- return seed(kernel, deps.prober())
43
+ return monitor.watch(kernel, params)
52
44
  },
53
45
  })
54
46
 
@@ -57,21 +49,21 @@ const seedMethod = method(schema, 'Monitor', 'seed', {
57
49
  const pageCheckMethod = method(schema, 'StatusPage', 'check', {
58
50
  authorize: async () => undefined,
59
51
  execute: ({ kernel, self }) => {
60
- return pageCheck(kernel, self.path.raw)
52
+ return page.check(kernel, self.path.raw)
61
53
  },
62
54
  })
63
55
 
64
56
  const createMethod = method(schema, 'StatusPage', 'create', {
65
57
  authorize: async () => undefined,
66
58
  execute: ({ kernel, params }) => {
67
- return create(kernel, params)
59
+ return page.create(kernel, params)
68
60
  },
69
61
  })
70
62
 
71
63
  const addMethod = method(schema, 'StatusPage', 'add', {
72
64
  authorize: async () => undefined,
73
65
  execute: ({ kernel, self, params }) => {
74
- return add(kernel, self.path.raw, params)
66
+ return page.add(kernel, self.path.raw, params)
75
67
  },
76
68
  })
77
69
 
@@ -80,7 +72,6 @@ export const methods: SchemaMethodsImpl<typeof schema, Deps> = {
80
72
  Monitor: classMethods(schema, 'Monitor', {
81
73
  check: monitorCheckMethod,
82
74
  watch: watchMethod,
83
- seed: seedMethod,
84
75
  }),
85
76
  StatusPage: classMethods(schema, 'StatusPage', {
86
77
  check: pageCheckMethod,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Monitoring runtime context — method implementations grouped by the domain
3
+ * slice they serve. `runtime/index.ts` wires these into SDK method handlers.
4
+ */
5
+ import * as monitor from './monitor'
6
+ import * as page from './page'
7
+
8
+ export { monitor, page }
@@ -1,5 +1,5 @@
1
- import type { Prober } from '../../integrations/prober/port'
2
- import type { CallableKernel } from '../shared'
1
+ import type { Prober } from '../../../integrations/prober/port'
2
+ import type { CallableKernel } from '../../shared'
3
3
 
4
4
  /**
5
5
  * `Monitor.check` (instance) — implements `Checkable.check` for a single endpoint:
@@ -7,7 +7,7 @@ import type { CallableKernel } from '../shared'
7
7
  * record status/latency on the node, and return the verdict. `url` + `prober` are
8
8
  * resolved by the wiring (`runtime/index.ts`) from `self.node()`.
9
9
  */
10
- import { classify, MONITOR_KEYS } from '../../core/monitor'
10
+ import { classify, MONITOR_KEYS } from '../../../core/monitor'
11
11
 
12
12
  export async function check(
13
13
  kernel: CallableKernel,
@@ -1,6 +1,7 @@
1
1
  /**
2
- * Monitor operations one file per method, assembled here for the composition
3
- * root (`runtime/index.ts`). Each is transport-agnostic logic over a
2
+ * Monitor operations inside the monitoring bounded context one file per
3
+ * method, assembled here for the composition root (`runtime/index.ts`). Each is
4
+ * transport-agnostic logic over a
4
5
  * `CallableKernel` (+ the `Prober` port where it probes), delegating pure
5
6
  * decisions to `core/monitor` — so all are unit-testable with fakes.
6
7
  */
@@ -1,12 +1,14 @@
1
- import type { Prober } from '../../integrations/prober/port'
1
+ import type { Prober } from '../../../integrations/prober/port'
2
2
 
3
3
  /**
4
- * `Monitor.seed` (static) — the domain's post-install bootstrap. The kernel calls
5
- * it ONCE after install, as __SYSTEM__ (see `postInstall` in `domain.ts`), so the
6
- * domain comes up demonstrable: a `/monitors` folder + starter Monitors (each
7
- * probed once), and a `/status-pages` folder + one StatusPage that `watches` them
8
- * (its initial status rolled up from the probes). Idempotent: node creates swallow
9
- * `PATH_CONFLICT` (fixed paths) and re-linking a `watches` edge is a graph no-op.
4
+ * The domain's post-install bootstrap exposed as the standalone `seed` function
5
+ * (`functions/`) and wired as `postInstall` in `domain.ts`. The kernel calls it
6
+ * ONCE after install, as __SYSTEM__, so the
7
+ * domain comes up demonstrable: a `/monitoring` folder, `/monitoring/monitors`
8
+ * starter Monitors (each probed once), and `/monitoring/pages/status`, a
9
+ * StatusPage that `watches` them (its initial status rolled up from the probes).
10
+ * Idempotent: node creates swallow `PATH_CONFLICT` (fixed paths) and re-linking
11
+ * a `watches` edge is a graph no-op.
10
12
  * It grants nothing — the installing owner reaches these nodes via root-propagated
11
13
  * perms; grant explicitly here for non-owner access.
12
14
  */
@@ -15,6 +17,7 @@ import {
15
17
  FOLDER_CLASS,
16
18
  MONITOR_CLASS,
17
19
  MONITOR_KEYS,
20
+ MONITORING_PARENT,
18
21
  MONITORS_PARENT,
19
22
  NAME_KEY,
20
23
  NODE_CREATE,
@@ -26,8 +29,8 @@ import {
26
29
  PAGE_KEYS,
27
30
  WATCHES_EDGE,
28
31
  WATCHES_KEYS,
29
- } from '../../core/monitor'
30
- import { type CallableKernel, isPathConflict } from '../shared'
32
+ } from '../../../core/monitor'
33
+ import { type CallableKernel, isPathConflict } from '../../shared'
31
34
 
32
35
  /** Create a node, swallowing a re-seed's `PATH_CONFLICT`. Returns true if newly created. */
33
36
  async function ensure(kernel: CallableKernel, params: unknown): Promise<boolean> {
@@ -41,6 +44,12 @@ async function ensure(kernel: CallableKernel, params: unknown): Promise<boolean>
41
44
  }
42
45
 
43
46
  export async function seed(kernel: CallableKernel, prober: Prober): Promise<{ seeded: number }> {
47
+ await ensure(kernel, {
48
+ class: FOLDER_CLASS,
49
+ path: MONITORING_PARENT,
50
+ props: { [NAME_KEY]: 'monitoring' },
51
+ })
52
+
44
53
  await ensure(kernel, {
45
54
  class: FOLDER_CLASS,
46
55
  path: MONITORS_PARENT,
@@ -73,7 +82,7 @@ export async function seed(kernel: CallableKernel, prober: Prober): Promise<{ se
73
82
  await ensure(kernel, {
74
83
  class: FOLDER_CLASS,
75
84
  path: STATUS_PAGES_PARENT,
76
- props: { [NAME_KEY]: 'status-pages' },
85
+ props: { [NAME_KEY]: 'pages' },
77
86
  })
78
87
  const pagePath = `${STATUS_PAGES_PARENT}/${STARTER_PAGE.slug}`
79
88
  await ensure(kernel, {
@@ -1,7 +1,7 @@
1
1
  /**
2
- * `Monitor.watch` (static) — create a Monitor node under `/monitors`. The slug
3
- * format is pure (`core/monitor`'s `uniqueSlug`); the entropy suffix (impure,
4
- * clock/RNG) comes from `runtime/shared`, keeping core deterministic.
2
+ * `Monitor.watch` (static) — create a Monitor node under `/monitoring/monitors`.
3
+ * The slug format is pure (`core/monitor`'s `uniqueSlug`); the entropy suffix
4
+ * (impure, clock/RNG) comes from `runtime/shared`, keeping core deterministic.
5
5
  */
6
6
  import {
7
7
  MONITOR_CLASS,
@@ -10,8 +10,8 @@ import {
10
10
  NAME_KEY,
11
11
  NODE_CREATE,
12
12
  uniqueSlug,
13
- } from '../../core/monitor'
14
- import { type CallableKernel, randomSuffix } from '../shared'
13
+ } from '../../../core/monitor'
14
+ import { type CallableKernel, randomSuffix } from '../../shared'
15
15
 
16
16
  export async function watch(
17
17
  kernel: CallableKernel,
@@ -1,11 +1,11 @@
1
- import type { CallableKernel } from '../shared'
1
+ import type { CallableKernel } from '../../shared'
2
2
 
3
3
  /**
4
4
  * `StatusPage.add` (instance) — watch a Monitor: create a `watches` edge from
5
5
  * this page to `monitor`, tagged `critical` (default false). `monitor` is any
6
6
  * node address (a tree path or `@<id>`).
7
7
  */
8
- import { WATCHES_EDGE, WATCHES_KEYS } from '../../core/monitor'
8
+ import { WATCHES_EDGE, WATCHES_KEYS } from '../../../core/monitor'
9
9
 
10
10
  export async function add(
11
11
  kernel: CallableKernel,
@@ -1,4 +1,4 @@
1
- import type { CallableKernel } from '../shared'
1
+ import type { CallableKernel } from '../../shared'
2
2
 
3
3
  /**
4
4
  * `StatusPage.check` (instance) — implements `Checkable.check` for a page: walk
@@ -8,7 +8,7 @@ import type { CallableKernel } from '../shared'
8
8
  * `getLinks` returns raw `Edge`s whose endpoint/prop accessors aren't typed yet
9
9
  * (an SDK gap) — `parseWatches` is the small cast that bridges it.
10
10
  */
11
- import { PAGE_KEYS, rollup, WATCHES_EDGE, WATCHES_KEYS } from '../../core/monitor'
11
+ import { PAGE_KEYS, rollup, WATCHES_EDGE, WATCHES_KEYS } from '../../../core/monitor'
12
12
 
13
13
  /** A raw `watches` edge as `getLinks` returns it (endpoints are string-or-`{raw}`). */
14
14
  type RawEdge = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `StatusPage.create` (static) — create a StatusPage node under `/status-pages`.
2
+ * `StatusPage.create` (static) — create a StatusPage node under `/monitoring/pages`.
3
3
  */
4
4
  import {
5
5
  NAME_KEY,
@@ -7,8 +7,8 @@ import {
7
7
  STATUS_PAGE_CLASS,
8
8
  STATUS_PAGES_PARENT,
9
9
  uniqueSlug,
10
- } from '../../core/monitor'
11
- import { type CallableKernel, randomSuffix } from '../shared'
10
+ } from '../../../core/monitor'
11
+ import { type CallableKernel, randomSuffix } from '../../shared'
12
12
 
13
13
  export async function create(
14
14
  kernel: CallableKernel,
@@ -0,0 +1,9 @@
1
+ /**
2
+ * StatusPage operations inside the monitoring bounded context — one file per
3
+ * method, assembled here for the composition root (`runtime/index.ts`).
4
+ * Transport-agnostic logic over a `CallableKernel`, delegating the roll-up
5
+ * decision to `core/monitor`.
6
+ */
7
+ export { add } from './add'
8
+ export { check } from './check'
9
+ export { create } from './create'
@@ -6,7 +6,8 @@
6
6
  * implementing class brings its OWN body, and the
7
7
  * kernel dispatches by the node's class.
8
8
  * - Class `Monitor` a single HTTP check. `check()` probes `url`;
9
- * `watch` creates one; `seed` lays down the demo set.
9
+ * `watch` creates one. (The demo set is laid down by
10
+ * the standalone `seed` function — see `functions/`.)
10
11
  * - Class `StatusPage` a roll-up. `check()` re-checks the monitors it
11
12
  * `watches` and aggregates; `create` makes a page;
12
13
  * `add` watches a monitor.
@@ -50,17 +51,14 @@ export const Monitor = nodeClass({
50
51
  // Implements `Checkable.check` for a single endpoint (probe `url`). Redeclared
51
52
  // here — a concrete class must declare each abstract method it implements, so
52
53
  // the compiler materializes Monitor's OWN `check` node for per-class dispatch.
53
- // The body lives in `runtime/monitor/check.ts`.
54
+ // The body lives in `runtime/monitoring/monitor/check.ts`.
54
55
  check: fn({ returns: CheckResult }),
55
- /** Create a Monitor under `/monitors`. */
56
+ /** Create a Monitor under `/monitoring/monitors`. */
56
57
  watch: fn({
57
58
  static: true,
58
59
  params: { url: z.string(), name: z.string().optional() },
59
60
  returns: NodeRef,
60
61
  }),
61
- // Post-install bootstrap (wired as `postInstall` in domain.ts). Static: the
62
- // kernel calls it ONCE after install, as __SYSTEM__. Must stay idempotent.
63
- seed: fn({ static: true, returns: z.object({ seeded: z.number().int() }) }),
64
62
  },
65
63
  })
66
64
 
@@ -73,9 +71,9 @@ export const StatusPage = nodeClass({
73
71
  methods: {
74
72
  // Implements `Checkable.check` for a page (roll up the watched monitors).
75
73
  // Redeclared so StatusPage materializes its OWN `check` node. Body in
76
- // `runtime/status-page/check.ts`.
74
+ // `runtime/monitoring/page/check.ts`.
77
75
  check: fn({ returns: CheckResult }),
78
- /** Create a StatusPage under `/status-pages`. */
76
+ /** Create a StatusPage under `/monitoring/pages`. */
79
77
  create: fn({ static: true, params: { name: z.string() }, returns: NodeRef }),
80
78
  /** Watch a monitor (a `watches` edge); `critical` decides the roll-up weight. */
81
79
  add: fn({
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * View registry — one file per view under `views/`, assembled here. Slug = map
3
- * key; each becomes a View node at `/<origin>/core/views/<slug>` whose iframe
3
+ * key; each becomes a View node at `/<origin>/views/<slug>` whose iframe
4
4
  * binding the SDK stamps with the worker's live serving URL when it builds the
5
5
  * install bundle.
6
6
  *