@happyvertical/smrt-app-shell 0.0.0-stage → 0.60.16

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 (56) hide show
  1. package/AGENTS.md +99 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +173 -2
  5. package/agents/engine.md +85 -0
  6. package/dist/engine/app-runtime.d.ts +138 -0
  7. package/dist/engine/app-runtime.js +545 -0
  8. package/dist/engine/app-worker.d.ts +1 -0
  9. package/dist/engine/app-worker.js +62 -0
  10. package/dist/engine/commands.d.ts +94 -0
  11. package/dist/engine/commands.js +30 -0
  12. package/dist/engine/definition.d.ts +192 -0
  13. package/dist/engine/definition.js +497 -0
  14. package/dist/engine/errors.d.ts +23 -0
  15. package/dist/engine/errors.js +35 -0
  16. package/dist/engine/host.d.ts +153 -0
  17. package/dist/engine/host.js +791 -0
  18. package/dist/engine/index.d.ts +6 -0
  19. package/dist/engine/index.js +7 -0
  20. package/dist/engine/sandbox.d.ts +60 -0
  21. package/dist/engine/sandbox.js +260 -0
  22. package/dist/engine/snapshots.d.ts +7 -0
  23. package/dist/engine/snapshots.js +54 -0
  24. package/dist/engine/store.d.ts +39 -0
  25. package/dist/engine/store.js +32 -0
  26. package/dist/engine/worker-handle.d.ts +29 -0
  27. package/dist/engine/worker-handle.js +89 -0
  28. package/dist/engine/worker-protocol.d.ts +22 -0
  29. package/dist/engine/worker-protocol.js +20 -0
  30. package/dist/lib/objects/App.d.ts +60 -0
  31. package/dist/lib/objects/App.js +273 -0
  32. package/dist/lib/objects/AppVersion.d.ts +22 -0
  33. package/dist/lib/objects/AppVersion.js +62 -0
  34. package/dist/lib/objects/Approval.d.ts +39 -0
  35. package/dist/lib/objects/Approval.js +101 -0
  36. package/dist/lib/objects/AssistantMessage.d.ts +24 -0
  37. package/dist/lib/objects/AssistantMessage.js +63 -0
  38. package/dist/lib/objects/AssistantThread.d.ts +16 -0
  39. package/dist/lib/objects/AssistantThread.js +44 -0
  40. package/dist/lib/objects/index.d.ts +5 -0
  41. package/dist/lib/objects/index.js +5 -0
  42. package/dist/lib/server/approvals.d.ts +69 -0
  43. package/dist/lib/server/approvals.js +239 -0
  44. package/dist/lib/server/builder.d.ts +16 -0
  45. package/dist/lib/server/builder.js +71 -0
  46. package/dist/lib/server/events.d.ts +16 -0
  47. package/dist/lib/server/events.js +14 -0
  48. package/dist/lib/server/host.d.ts +22 -0
  49. package/dist/lib/server/host.js +96 -0
  50. package/dist/lib/server/owner.d.ts +33 -0
  51. package/dist/lib/server/owner.js +92 -0
  52. package/dist/lib/server/version-store.d.ts +20 -0
  53. package/dist/lib/server/version-store.js +115 -0
  54. package/dist/manifest.json +1680 -0
  55. package/dist/smrt-knowledge.okf.md +95 -0
  56. package/package.json +80 -3
@@ -0,0 +1,153 @@
1
+ import { EventEmitter } from 'node:events';
2
+ import { type Command, type ExecuteOptions, type Plan, type Template } from './commands.ts';
3
+ import { type AppDefinition } from './definition.ts';
4
+ import type { VersionStore } from './store.ts';
5
+ type Row = Record<string, unknown>;
6
+ export interface HostOptions {
7
+ store: VersionStore;
8
+ /** The worker entry. Defaults to `./app-worker.ts` or `.js` next to this module. */
9
+ workerUrl?: URL | string;
10
+ }
11
+ export interface ChangeResult {
12
+ version: number;
13
+ summary: string;
14
+ statements: string[];
15
+ snapshot: string | null;
16
+ appRestartMs: number;
17
+ affectedMethods?: string[];
18
+ converted?: number;
19
+ emptied?: number;
20
+ undid?: string;
21
+ }
22
+ export interface CleanUpResult {
23
+ purgedVersions: number[];
24
+ values: number;
25
+ tables: number;
26
+ /** Old migration/schema snapshot files removed. */
27
+ snapshots: number;
28
+ }
29
+ export type ExecuteResult = ChangeResult | CleanUpResult | Template;
30
+ export interface MethodResult {
31
+ result: unknown;
32
+ writes: unknown[];
33
+ applied: number;
34
+ snapshot: string | null;
35
+ }
36
+ export interface ToolResult {
37
+ content: unknown;
38
+ isError: boolean;
39
+ structuredContent?: unknown;
40
+ }
41
+ export interface RestResult {
42
+ status: number;
43
+ contentType: string;
44
+ body: string;
45
+ }
46
+ export interface VersionSummary {
47
+ version: number;
48
+ parent: number | null;
49
+ author: string;
50
+ summary: string;
51
+ createdAt: string;
52
+ purged: boolean;
53
+ current: boolean;
54
+ }
55
+ export declare class AppHost extends EventEmitter {
56
+ def: AppDefinition;
57
+ version: number;
58
+ readonly dataDir: string;
59
+ lastSwapMs: number;
60
+ private store;
61
+ private workerUrl;
62
+ private app;
63
+ private closed;
64
+ /** Changes are applied one at a time. Work inside the queue must not wait on it. */
65
+ private queue;
66
+ private constructor();
67
+ static open(dataDir: string, opts: HostOptions): Promise<AppHost>;
68
+ private boot;
69
+ private spawn;
70
+ private run;
71
+ /**
72
+ * Start an app runtime on `def`; swap it in only if it comes up. With a
73
+ * migration the old runtime is stopped first, so nothing writes while tables
74
+ * change; if the new one fails, the migration rolled back and the old
75
+ * definition is started again.
76
+ */
77
+ private swap;
78
+ /**
79
+ * Swap to `next`, then persist. If persisting fails the app is put back
80
+ * where the store still says it is.
81
+ */
82
+ private transition;
83
+ /** Validate, start the new app runtime, record the version. Every change takes this path. */
84
+ private applyChange;
85
+ /** What a command would do, without changing anything. */
86
+ plan(cmd: Command): Promise<Plan>;
87
+ /**
88
+ * Apply a command. A risky one throws {@link ApprovalRequiredError} unless
89
+ * `approved` is true, and then nothing has changed.
90
+ */
91
+ execute(cmd: Command, opts: ExecuteOptions): Promise<ExecuteResult>;
92
+ private clone;
93
+ private model;
94
+ /** Where an own field of `model` is stored. */
95
+ private storage;
96
+ /** Methods (of any model) whose code mentions `name`; their code is not rewritten. */
97
+ private methodsMentioning;
98
+ private analyse;
99
+ private assertValid;
100
+ private analyseUndo;
101
+ /** The model and field stored in `table.column` under `def`. */
102
+ private locate;
103
+ /** The chain from the current version back to the root, newest first. */
104
+ private chain;
105
+ private analyseCleanUp;
106
+ private exportTemplate;
107
+ private analyseImport;
108
+ /** Talk to the app. Callers inside the change queue use this; others use onApp. */
109
+ private callApp;
110
+ private onApp;
111
+ list(model: string, limit?: number): Promise<Row[]>;
112
+ get(model: string, id: string): Promise<Row>;
113
+ create(model: string, data: Row): Promise<Row>;
114
+ update(model: string, id: string, data: Row): Promise<Row>;
115
+ remove(model: string, id: string): Promise<{
116
+ deleted: string;
117
+ }>;
118
+ runMethod(model: string, method: string, id?: string | null, params?: Row): Promise<MethodResult>;
119
+ /** The app's own generated MCP tools. */
120
+ appTools(): Promise<{
121
+ name: string;
122
+ description?: string;
123
+ inputSchema?: unknown;
124
+ }[]>;
125
+ /** Call one of the app's generated tools. A delete needs `approved: true`. */
126
+ callAppTool(name: string, args?: Row, opts?: {
127
+ approved?: boolean;
128
+ }): Promise<ToolResult>;
129
+ /** The worker's generated REST routes, passed through. A DELETE needs `approved: true`. */
130
+ rest(req: {
131
+ method: string;
132
+ url: string;
133
+ body?: string;
134
+ }, opts?: {
135
+ approved?: boolean;
136
+ }): Promise<RestResult>;
137
+ describe(): {
138
+ name: string;
139
+ version: number;
140
+ recipes: string[];
141
+ models: Record<string, import("./definition.ts").DescribedModel>;
142
+ };
143
+ versions(): Promise<VersionSummary[]>;
144
+ /** Restart the app runtime on the same definition (e.g. after a crash). */
145
+ restartApp(): Promise<{
146
+ appRestartMs: number;
147
+ }>;
148
+ /** Stop the app thread as a crash would. For tests and for the shell's own watchdogs. */
149
+ killApp(): Promise<void>;
150
+ get appAlive(): boolean;
151
+ close(): Promise<void>;
152
+ }
153
+ export {};