@astrale-os/adapter-cloudflare 0.1.9 → 0.1.10

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 (80) hide show
  1. package/package.json +1 -1
  2. package/template/.agents/skills/astrale-cli/SKILL.md +1 -1
  3. package/template/.agents/skills/astrale-domain/SKILL.md +5 -5
  4. package/template/.env.example +5 -7
  5. package/template/README.md +2 -2
  6. package/template/client/README.md +79 -62
  7. package/template/client/__tests__/app.test.tsx +188 -99
  8. package/template/client/__tests__/harness.ts +67 -12
  9. package/template/client/__tests__/kernel.test.ts +65 -50
  10. package/template/client/__tests__/seam.test.tsx +111 -0
  11. package/template/client/index.html +1 -1
  12. package/template/client/package.json +1 -0
  13. package/template/client/src/app.tsx +40 -83
  14. package/template/client/src/main.tsx +2 -2
  15. package/template/client/src/monitor/components/MonitorCard.tsx +50 -0
  16. package/template/client/src/monitor/components/index.ts +1 -0
  17. package/template/client/src/monitor/hooks/index.ts +3 -0
  18. package/template/client/src/monitor/hooks/useCheck.mutation.ts +16 -0
  19. package/template/client/src/monitor/hooks/useMonitor.query.ts +64 -0
  20. package/template/client/src/monitor/index.ts +6 -0
  21. package/template/client/src/monitor/monitor.api.ts +11 -0
  22. package/template/client/src/monitor/monitor.mappers.ts +38 -0
  23. package/template/client/src/monitor/monitor.types.ts +23 -0
  24. package/template/client/src/monitor/ui/MonitorDetails.UI.tsx +38 -0
  25. package/template/client/src/monitor/ui/StatusBadge.UI.tsx +14 -0
  26. package/template/client/src/monitor/ui/index.ts +8 -0
  27. package/template/client/src/shell/client.ts +67 -0
  28. package/template/client/src/shell/index.ts +20 -0
  29. package/template/client/src/shell/invoke.ts +35 -0
  30. package/template/client/src/shell/transformers.ts +72 -0
  31. package/template/client/src/shell/use-async.ts +56 -0
  32. package/template/client/src/shell/use-capability.ts +61 -0
  33. package/template/client/src/shell/use-node.ts +61 -0
  34. package/template/client/src/shell/use-shell.ts +91 -0
  35. package/template/client/src/shell/view-router.tsx +98 -0
  36. package/template/client/src/styles.css +177 -4
  37. package/template/client/src/ui/format.ts +24 -0
  38. package/template/client/src/ui/index.ts +9 -0
  39. package/template/client/src/ui/surface.tsx +56 -0
  40. package/template/client/src/ui/value.tsx +32 -0
  41. package/template/client/src/views/monitor.tsx +30 -0
  42. package/template/client/tsconfig.json +2 -1
  43. package/template/client/vite.config.ts +12 -13
  44. package/template/client/vitest.config.ts +12 -5
  45. package/template/core/monitor/health.ts +19 -0
  46. package/template/core/monitor/index.ts +9 -0
  47. package/template/core/monitor/keys.ts +29 -0
  48. package/template/core/monitor/node.ts +51 -0
  49. package/template/deps.ts +8 -8
  50. package/template/domain.ts +1 -1
  51. package/template/env.ts +2 -9
  52. package/template/integrations/prober/http.ts +43 -0
  53. package/template/integrations/prober/mock.ts +22 -0
  54. package/template/integrations/prober/port.ts +28 -0
  55. package/template/integrations/prober/registry.ts +66 -0
  56. package/template/package.json +1 -1
  57. package/template/pnpm-lock.yaml +2766 -0
  58. package/template/runtime/index.ts +36 -19
  59. package/template/runtime/monitor/check.ts +29 -0
  60. package/template/runtime/monitor/dependsOn.ts +16 -0
  61. package/template/runtime/monitor/index.ts +12 -0
  62. package/template/runtime/monitor/seed.ts +74 -0
  63. package/template/runtime/monitor/shared.ts +17 -0
  64. package/template/runtime/monitor/watch.ts +37 -0
  65. package/template/schema/index.ts +11 -4
  66. package/template/schema/monitor.ts +80 -0
  67. package/template/views/index.ts +9 -2
  68. package/template/views/monitor.ts +22 -0
  69. package/template/client/src/lib/kernel.ts +0 -135
  70. package/template/client/src/lib/shell.ts +0 -197
  71. package/template/client/src/lib/use-node.ts +0 -66
  72. package/template/client/src/lib/use-shell.ts +0 -85
  73. package/template/core/keys.ts +0 -28
  74. package/template/core/note.ts +0 -148
  75. package/template/integrations/summary/heuristic.ts +0 -25
  76. package/template/integrations/summary/http.ts +0 -69
  77. package/template/integrations/summary/port.ts +0 -21
  78. package/template/integrations/summary/registry.ts +0 -52
  79. package/template/schema/note.ts +0 -67
  80. package/template/views/note.ts +0 -21
@@ -1,52 +0,0 @@
1
- /**
2
- * Summarizer registry — the ONE place the worker env becomes the live
3
- * `Summarizer` port. Adding a provider = one more arm in `selectSummarizer`;
4
- * handler logic only ever sees the resolved port.
5
- *
6
- * Selection is ON-REQUEST: the provider is chosen + built lazily on the first
7
- * handler that calls `summarizer()`, then cached for the isolate — NOT at
8
- * `deps()` construction. A worker left on the default never validates the HTTP
9
- * provider's env, and a per-request override could slot in here later.
10
- */
11
- import type { Env } from '../../env'
12
- import { createHeuristicSummarizer } from './heuristic'
13
- import { createHttpSummarizer } from './http'
14
- import type { Summarizer } from './port'
15
-
16
- export interface SummarizerRegistry {
17
- /** Resolve the configured summarizer port (lazy + cached per isolate). */
18
- summarizer(): Summarizer
19
- }
20
-
21
- /** Build the registry from the worker env (the port is built lazily + cached). */
22
- export function buildSummarizerRegistry(env: Env): SummarizerRegistry {
23
- let cached: Summarizer | undefined
24
- return {
25
- summarizer() {
26
- return (cached ??= selectSummarizer(env))
27
- },
28
- }
29
- }
30
-
31
- const DEFAULT_HTTP_MODEL = 'gpt-4o-mini'
32
-
33
- /** Bind the abstract summarizer port to the configured concrete adapter. */
34
- function selectSummarizer(env: Env): Summarizer {
35
- const provider = (env.NOTE_SUMMARIZER || 'heuristic').toLowerCase()
36
-
37
- if (provider === 'http') {
38
- if (!env.SUMMARIZER_API_KEY || !env.SUMMARIZER_BASE_URL) {
39
- throw new Error(
40
- 'NOTE_SUMMARIZER=http requires SUMMARIZER_API_KEY and SUMMARIZER_BASE_URL',
41
- )
42
- }
43
- return createHttpSummarizer({
44
- apiKey: env.SUMMARIZER_API_KEY,
45
- baseUrl: env.SUMMARIZER_BASE_URL,
46
- model: env.SUMMARIZER_MODEL || DEFAULT_HTTP_MODEL,
47
- })
48
- }
49
-
50
- // Default: the zero-config local heuristic (no network, no secret).
51
- return createHeuristicSummarizer()
52
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Note context — the domain's single bounded slice.
3
- *
4
- * One file per context: a class (or a few tightly-related classes) plus the
5
- * edges that bind them. Here that is the `NoteOps` interface, the `Note`
6
- * class that implements it, and the `references` edge from one Note to
7
- * another. To grow the domain, add `schema/<context>.ts` and register its
8
- * members in `schema/index.ts`.
9
- *
10
- * - Interface `NoteOps` one static op, `createNote`. Static → the impl
11
- * gets no `self`; it creates a brand-new Note.
12
- * - Class `Note` implements `[NoteOps, Container]`, inheriting
13
- * `createNote` and adding the instance method
14
- * `reference` (links this Note to another).
15
- * - Edge `references` Note → Note. Materialized at runtime by
16
- * `reference` (and by `seed`).
17
- */
18
- import { edgeClass, KernelSchema, nodeClass, nodeInterface } from '@astrale-os/kernel-core'
19
- import { fn } from '@astrale-os/kernel-dsl'
20
- import { z } from 'zod'
21
-
22
- /**
23
- * Thin ref to a created node — what node-creating ops return. A remote method
24
- * returns a plain `{ id, path }`, never `ref(SELF)` (whose full-Node value
25
- * does not round-trip over the worker wire).
26
- */
27
- export const NoteRef = z.object({ id: z.string(), path: z.string() })
28
-
29
- export const NoteOps = nodeInterface({
30
- methods: {
31
- createNote: fn({
32
- static: true,
33
- params: { title: z.string(), body: z.string() },
34
- returns: NoteRef,
35
- }),
36
- },
37
- })
38
-
39
- export const Note = nodeClass({
40
- implements: [NoteOps, KernelSchema.interfaces.Container],
41
- props: {
42
- title: z.string(),
43
- body: z.string(),
44
- // One-line summary, stamped at create/seed time from the `Summarizer` port
45
- // (see integrations/summary/) — the external-API seam wired through `deps`.
46
- summary: z.string().optional(),
47
- },
48
- methods: {
49
- reference: fn({
50
- params: { target: z.string() },
51
- returns: z.object({ linked: z.string() }),
52
- }),
53
- // Post-install bootstrap (wired as `postInstall` in astrale.config.ts).
54
- // Static: the kernel calls it ONCE after install, as __SYSTEM__, with no
55
- // `self`. Must stay idempotent — a re-install runs it again.
56
- seed: fn({
57
- static: true,
58
- returns: z.object({ seeded: z.number().int() }),
59
- }),
60
- },
61
- })
62
-
63
- export const references = edgeClass(
64
- { as: 'from_note', types: [Note], cardinality: '0..*' },
65
- { as: 'to_note', types: [Note], cardinality: '0..*' },
66
- { props: { reason: z.string().optional() } },
67
- )
@@ -1,21 +0,0 @@
1
- /**
2
- * `ui-note` — a rich View backed by the `client/` React + Vite SPA (instead of
3
- * an inline-HTML `render` like `welcome`). Because it declares `mount` rather
4
- * than `render`, the View node's iframe binding points at `<serving url>/ui/note`
5
- * — the SDK stamps it from the worker's live URL when it builds the install
6
- * bundle. The Cloudflare adapter serves `/ui/*` from `../.dist` (built by
7
- * `client/` with base `/ui/`) via the Worker's `ASSETS` binding.
8
- *
9
- * `viewFor: selfOf(Note)` attaches a `view_for` edge to the `Note` class
10
- * meta-node, so the GUI offers this view for any Note instance.
11
- */
12
- import { selfOf } from '@astrale-os/kernel-dsl'
13
- import { defineView } from '@astrale-os/sdk'
14
-
15
- import { Note } from '../schema/note'
16
-
17
- export const note = defineView({
18
- auth: 'public',
19
- mount: '/ui/note',
20
- viewFor: selfOf(Note),
21
- })