@operad-io/engine 0.0.0-stage → 0.0.1

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 (102) hide show
  1. package/LICENSE +21 -0
  2. package/config.schema.json +188 -0
  3. package/keys.schema.json +12 -0
  4. package/package.json +22 -4
  5. package/src/config/config.ts +627 -0
  6. package/src/config/index.ts +1 -0
  7. package/src/flow/define-flow.ts +57 -0
  8. package/src/flow/index.ts +5 -0
  9. package/src/flow/load.ts +41 -0
  10. package/src/flow/types.ts +107 -0
  11. package/src/flow/validate.ts +296 -0
  12. package/src/http/address.ts +142 -0
  13. package/src/http/index.ts +25 -0
  14. package/src/http/link.ts +20 -0
  15. package/src/http/server.ts +920 -0
  16. package/src/http/token.ts +85 -0
  17. package/src/index.ts +16 -0
  18. package/src/kernel/decide.ts +689 -0
  19. package/src/kernel/index.ts +3 -0
  20. package/src/kernel/state.ts +275 -0
  21. package/src/kernel/types.ts +366 -0
  22. package/src/log/errors.ts +77 -0
  23. package/src/log/facts.ts +50 -0
  24. package/src/log/index.ts +6 -0
  25. package/src/log/json-value.ts +67 -0
  26. package/src/log/open-log.ts +17 -0
  27. package/src/log/schema.ts +5 -0
  28. package/src/log/secret.ts +30 -0
  29. package/src/log/sqlite.ts +1011 -0
  30. package/src/log/types.ts +230 -0
  31. package/src/loop/code-watch.ts +486 -0
  32. package/src/loop/index.ts +3 -0
  33. package/src/loop/older-code.ts +58 -0
  34. package/src/loop/serve.ts +483 -0
  35. package/src/markdown.ts +451 -0
  36. package/src/notify/index.ts +10 -0
  37. package/src/notify/notify.ts +256 -0
  38. package/src/platform/file-lock.ts +385 -0
  39. package/src/platform/index.ts +13 -0
  40. package/src/platform/load.ts +18 -0
  41. package/src/platform/process-group.ts +635 -0
  42. package/src/platform/process-watch.ts +152 -0
  43. package/src/platform/sqlite-open.ts +104 -0
  44. package/src/platform/step-reap.ts +668 -0
  45. package/src/platform/watch.ts +158 -0
  46. package/src/platform/worker-reports.ts +34 -0
  47. package/src/plugin/action-schema.ts +550 -0
  48. package/src/plugin/declared-flows.ts +74 -0
  49. package/src/plugin/define-plugin.ts +12 -0
  50. package/src/plugin/errors.ts +73 -0
  51. package/src/plugin/filters.ts +46 -0
  52. package/src/plugin/harness.ts +50 -0
  53. package/src/plugin/home.ts +13 -0
  54. package/src/plugin/index.ts +65 -0
  55. package/src/plugin/install.ts +268 -0
  56. package/src/plugin/keys.ts +63 -0
  57. package/src/plugin/load.ts +256 -0
  58. package/src/plugin/logger.ts +30 -0
  59. package/src/plugin/object-facts.ts +132 -0
  60. package/src/plugin/open-store.ts +32 -0
  61. package/src/plugin/paging.ts +133 -0
  62. package/src/plugin/registry.ts +1783 -0
  63. package/src/plugin/secrets.ts +141 -0
  64. package/src/plugin/semver.ts +110 -0
  65. package/src/plugin/settings.ts +64 -0
  66. package/src/plugin/sqlite-store.ts +756 -0
  67. package/src/plugin/store.ts +318 -0
  68. package/src/plugin/types.ts +1236 -0
  69. package/src/plugin/usage.ts +157 -0
  70. package/src/plugin/validate.ts +1028 -0
  71. package/src/runner/answer.ts +156 -0
  72. package/src/runner/ask.ts +483 -0
  73. package/src/runner/cancel.ts +51 -0
  74. package/src/runner/errors.ts +20 -0
  75. package/src/runner/grants.ts +92 -0
  76. package/src/runner/index.ts +33 -0
  77. package/src/runner/limits.ts +403 -0
  78. package/src/runner/lock.ts +140 -0
  79. package/src/runner/runner.ts +1175 -0
  80. package/src/runner/service.ts +184 -0
  81. package/src/runner/step-worker.ts +303 -0
  82. package/src/testing/clock.ts +67 -0
  83. package/src/testing/index.ts +90 -0
  84. package/src/testing/types.ts +116 -0
  85. package/src/testing/world.ts +369 -0
  86. package/src/trigger/cron.ts +193 -0
  87. package/src/trigger/index.ts +32 -0
  88. package/src/trigger/kernel.ts +1212 -0
  89. package/src/trigger/rules.ts +300 -0
  90. package/src/trigger/store.ts +233 -0
  91. package/src/trigger/types.ts +156 -0
  92. package/src/util.ts +50 -0
  93. package/src/views/history.ts +634 -0
  94. package/src/views/index.ts +7 -0
  95. package/src/views/pending.ts +209 -0
  96. package/src/views/presentation.ts +2551 -0
  97. package/src/views/running.ts +255 -0
  98. package/src/views/settings.ts +452 -0
  99. package/src/views/types.ts +72 -0
  100. package/src/views/uploads.ts +228 -0
  101. package/triggers.schema.json +48 -0
  102. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yinghai Zhao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://operad.io/schemas/config.schema.json",
4
+ "title": "operad home config",
5
+ "description": "The config in $OPERAD_HOME/config.json: the plugins to load, their settings and the store the log uses.",
6
+ "type": "object",
7
+ "properties": {
8
+ "plugins": {
9
+ "description": "Plugins keyed by name, each with the module to load, whether it is enabled, and its own settings.",
10
+ "type": "object",
11
+ "additionalProperties": {
12
+ "oneOf": [
13
+ {
14
+ "type": "string",
15
+ "minLength": 1
16
+ },
17
+ {
18
+ "type": "object",
19
+ "properties": {
20
+ "module": {
21
+ "type": "string",
22
+ "minLength": 1,
23
+ "description": "The module or path to import; defaults to the plugin name."
24
+ },
25
+ "enabled": {
26
+ "type": "boolean",
27
+ "default": true,
28
+ "description": "A disabled plugin is not loaded; its stored objects stay."
29
+ },
30
+ "settings": {
31
+ "type": "object",
32
+ "description": "This plugin's section, validated by the plugin's own settings schema."
33
+ }
34
+ },
35
+ "additionalProperties": false
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ "store": {
41
+ "description": "Where the fact log lives: a sqlite database file.",
42
+ "type": "object",
43
+ "properties": {
44
+ "backend": {
45
+ "type": "string",
46
+ "enum": [
47
+ "sqlite"
48
+ ],
49
+ "default": "sqlite"
50
+ },
51
+ "path": {
52
+ "type": "string",
53
+ "minLength": 1,
54
+ "description": "Relative paths resolve against the operad home."
55
+ }
56
+ },
57
+ "additionalProperties": false
58
+ },
59
+ "http": {
60
+ "description": "The HTTP interface serve exposes for clients. It listens on 127.0.0.1 unless a person names other addresses.",
61
+ "type": "object",
62
+ "properties": {
63
+ "enabled": {
64
+ "type": "boolean",
65
+ "default": true,
66
+ "description": "Whether serve opens the port. It is on by default, on loopback only; serve creates the token on first use. Set false to turn the interface off."
67
+ },
68
+ "port": {
69
+ "type": "integer",
70
+ "minimum": 0,
71
+ "maximum": 65535,
72
+ "default": 7480
73
+ },
74
+ "listen": {
75
+ "type": "array",
76
+ "minItems": 1,
77
+ "items": {
78
+ "type": "string",
79
+ "minLength": 1
80
+ },
81
+ "default": [
82
+ "127.0.0.1"
83
+ ],
84
+ "description": "IP literals: loopback, an RFC 1918 or link-local address, or a Tailscale address. Wildcards are refused."
85
+ }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "notify": {
90
+ "description": "A command serve runs when something waits for a person, once per wait. It gets OPERAD_ID, OPERAD_TITLE, OPERAD_REASON and OPERAD_LINK in its environment.",
91
+ "type": "object",
92
+ "properties": {
93
+ "command": {
94
+ "type": [
95
+ "string",
96
+ "null"
97
+ ],
98
+ "minLength": 1,
99
+ "default": null,
100
+ "description": "A shell line run with sh -c in the operad home, for at most 30 seconds. null turns notifications off."
101
+ },
102
+ "on": {
103
+ "type": "array",
104
+ "items": {
105
+ "enum": [
106
+ "waiting"
107
+ ]
108
+ },
109
+ "default": [
110
+ "waiting"
111
+ ],
112
+ "description": "What triggers the command. Only waiting exists: an object now waits for a person."
113
+ }
114
+ },
115
+ "additionalProperties": false
116
+ },
117
+ "mcp": {
118
+ "description": "What the MCP server may write for a lead. The owner's decisions are not in this list unless it names them.",
119
+ "type": "object",
120
+ "properties": {
121
+ "channel": {
122
+ "description": "When the MCP channel (operad mcp --claude-channel) sends a block. Takes effect at the next operad mcp start.",
123
+ "type": "object",
124
+ "properties": {
125
+ "notify": {
126
+ "type": "array",
127
+ "items": {
128
+ "enum": [
129
+ "waiting",
130
+ "ended",
131
+ "loop",
132
+ "changes"
133
+ ]
134
+ },
135
+ "default": [
136
+ "waiting",
137
+ "ended",
138
+ "loop"
139
+ ],
140
+ "description": "waiting: a wait opens. ended: the object reaches a final state. loop: the same state is reached loopAfter times with no wait or end between. changes: every state change."
141
+ },
142
+ "loopAfter": {
143
+ "type": "integer",
144
+ "minimum": 2,
145
+ "default": 3,
146
+ "description": "How many times an object reaches the same state before a loop block is sent."
147
+ }
148
+ },
149
+ "additionalProperties": false
150
+ },
151
+ "actions": {
152
+ "type": "array",
153
+ "items": {
154
+ "type": "string",
155
+ "minLength": 1
156
+ },
157
+ "default": [],
158
+ "description": "The plugin actions named <plugin>:<action> that operad mcp may run. Every other action is refused for the owner to run. Takes effect at the next operad mcp start."
159
+ },
160
+ "confirmActions": {
161
+ "type": "array",
162
+ "items": {
163
+ "type": "string",
164
+ "minLength": 1
165
+ },
166
+ "default": [],
167
+ "description": "Allowed actions that also carry confirm: true. An action listed here runs through MCP; one that is only in actions is refused. Takes effect at the next operad mcp start."
168
+ }
169
+ },
170
+ "additionalProperties": false
171
+ },
172
+ "ask": {
173
+ "description": "How a step asks a person with ctx.ask.",
174
+ "type": "object",
175
+ "properties": {
176
+ "graceSecs": {
177
+ "type": "number",
178
+ "minimum": 0,
179
+ "maximum": 2147483,
180
+ "default": 600,
181
+ "description": "How long a step waits for an answer, in seconds, unless the call or the step's askGraceSecs param is narrower. 0 does not wait. There is no unlimited value."
182
+ }
183
+ },
184
+ "additionalProperties": false
185
+ }
186
+ },
187
+ "additionalProperties": true
188
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://operad.io/schemas/keys.schema.json",
4
+ "title": "operad key bindings",
5
+ "description": "The key overrides in $OPERAD_HOME/keys.json: each key names an action as <plugin>:<action>.",
6
+ "type": "object",
7
+ "propertyNames": { "minLength": 1 },
8
+ "additionalProperties": {
9
+ "type": "string",
10
+ "pattern": "^[^\\s:]+:[^\\s:]+$"
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@operad-io/engine",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./src/index.ts",
7
+ "./platform": "./src/platform/index.ts",
8
+ "./testing": "./src/testing/index.ts"
9
+ },
10
+ "description": "operad: the graph engine for flows, facts and plugins (in development)",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/operad-io/operad.git",
14
+ "directory": "packages/engine"
15
+ },
16
+ "license": "MIT",
17
+ "files": [
18
+ "src",
19
+ "config.schema.json",
20
+ "keys.schema.json",
21
+ "triggers.schema.json",
22
+ "LICENSE"
23
+ ]
24
+ }