@prestack/thread 0.0.1 → 0.0.2
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.
- package/dist/core/actor.ts +20 -0
- package/dist/core/asking.d.ts +0 -1
- package/dist/core/asking.js +0 -1
- package/dist/core/asking.ts +1342 -0
- package/dist/core/attach.js +2 -2
- package/dist/core/attach.ts +585 -0
- package/dist/core/chain.js +8 -1
- package/dist/core/chain.ts +148 -0
- package/dist/core/cli.js +97 -18
- package/dist/core/cli.ts +2004 -0
- package/dist/core/condition.ts +227 -0
- package/dist/core/descend.d.ts +1 -0
- package/dist/core/descend.js +36 -0
- package/dist/core/descend.ts +1001 -0
- package/dist/core/finding.ts +38 -0
- package/dist/core/generators/meta.js +6 -0
- package/dist/core/generators/meta.ts +1006 -0
- package/dist/core/init.ts +170 -0
- package/dist/core/invoked.ts +47 -0
- package/dist/core/round.ts +57 -0
- package/dist/core/rows.ts +369 -0
- package/dist/core/scope.ts +18 -0
- package/dist/core/thread.ts +29 -0
- package/dist/core/tree.ts +67 -0
- package/dist/core/types.ts +350 -0
- package/dist/derivation/attach.js +1 -1
- package/dist/derivation/attach.ts +68 -0
- package/dist/derivation/generators/build.ts +232 -0
- package/dist/derivation/generators/check.ts +118 -0
- package/dist/derivation/generators/derivation.ts +347 -0
- package/dist/derivation/generators/determinism.ts +145 -0
- package/dist/derivation/generators/release.js +19 -9
- package/dist/derivation/generators/release.ts +213 -0
- package/dist/derivation/makers/release.ts +135 -0
- package/dist/derivation/release.ts +23 -0
- package/dist/integrations/attach.js +2 -2
- package/dist/integrations/attach.ts +207 -0
- package/dist/integrations/generators/read.ts +127 -0
- package/dist/integrations/generators/secret.ts +289 -0
- package/dist/integrations/generators/target.js +16 -6
- package/dist/integrations/generators/target.ts +944 -0
- package/dist/integrations/generators/vault.js +46 -14
- package/dist/integrations/generators/vault.ts +212 -0
- package/dist/integrations/{sdk.js → module.js} +4 -4
- package/dist/integrations/module.ts +189 -0
- package/dist/integrations/secret.ts +50 -0
- package/dist/integrations/target.d.ts +3 -1
- package/dist/integrations/target.js +14 -11
- package/dist/integrations/target.ts +340 -0
- package/dist/integrations/vault.d.ts +2 -0
- package/dist/integrations/vault.js +4 -2
- package/dist/integrations/vault.ts +136 -0
- package/dist/integrity/attach.ts +234 -0
- package/dist/integrity/check-threads.js +2 -26
- package/dist/integrity/check-threads.ts +166 -0
- package/dist/integrity/constraint.ts +1202 -0
- package/dist/integrity/generators/compiler.ts +161 -0
- package/dist/integrity/generators/gate.ts +201 -0
- package/dist/integrity/generators/issues.ts +160 -0
- package/dist/integrity/generators/publish.js +14 -5
- package/dist/integrity/generators/publish.ts +247 -0
- package/dist/integrity/generators/rule.ts +271 -0
- package/dist/integrity/generators/seal.ts +117 -0
- package/dist/integrity/generators/trial.ts +320 -0
- package/dist/integrity/lint.ts +227 -0
- package/dist/integrity/lsp/bin.ts +42 -0
- package/dist/integrity/lsp/diagnostics.ts +92 -0
- package/dist/integrity/lsp/findings.ts +63 -0
- package/dist/integrity/lsp/lint.ts +140 -0
- package/dist/integrity/lsp/protocol.ts +78 -0
- package/dist/integrity/lsp/server.ts +224 -0
- package/dist/integrity/sealed.js +2 -2
- package/dist/integrity/sealed.ts +56 -0
- package/dist/integrity/slopnator.ts +350 -0
- package/dist/integrity/slopnators/sl_broken_lineage.ts +36 -0
- package/dist/integrity/slopnators/sl_declared_elsewhere.ts +39 -0
- package/dist/integrity/slopnators/sl_derived_drift.ts +98 -0
- package/dist/integrity/slopnators/sl_hardcoded_style.ts +55 -0
- package/dist/integrity/slopnators/sl_inert_island.ts +91 -0
- package/dist/integrity/slopnators/sl_inert_slopnator.ts +93 -0
- package/dist/integrity/slopnators/sl_missing_row.ts +182 -0
- package/dist/integrity/slopnators/sl_no_barrel.ts +48 -0
- package/dist/integrity/slopnators/sl_no_child_process.ts +74 -0
- package/dist/integrity/slopnators/sl_no_comment.ts +43 -0
- package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +328 -0
- package/dist/integrity/slopnators/sl_no_import_cycle.ts +50 -0
- package/dist/integrity/slopnators/sl_no_such_command.ts +64 -0
- package/dist/integrity/slopnators/sl_only_takes_a_literal.ts +63 -0
- package/dist/integrity/slopnators/sl_secret_literal.ts +100 -0
- package/dist/integrity/slopnators/sl_stale_path.ts +94 -0
- package/dist/integrity/slopnators/sl_twice_meant.ts +31 -0
- package/dist/integrity/slopnators/sl_twice_parented.ts +37 -0
- package/dist/integrity/slopnators/sl_undeclared_crossing.ts +87 -0
- package/dist/integrity/slopnators/sl_undeclared_destination.ts +65 -0
- package/dist/integrity/slopnators/sl_undeclared_element.ts +44 -0
- package/dist/integrity/slopnators/sl_undeclared_node.ts +69 -0
- package/dist/integrity/slopnators/sl_undeclared_operation.ts +147 -0
- package/dist/integrity/slopnators/sl_undeclared_variant.ts +148 -0
- package/dist/integrity/slopnators/sl_undescribed.ts +65 -0
- package/dist/integrity/slopnators/sl_ungoverned_island.ts +61 -0
- package/dist/integrity/slopnators/sl_unkept_rows.ts +111 -0
- package/dist/integrity/slopnators/sl_unnamed_island.ts +41 -0
- package/dist/integrity/slopnators/sl_unpaired_member.ts +131 -0
- package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +58 -0
- package/dist/integrity/slopnators/sl_unprefixed_member.ts +136 -0
- package/dist/integrity/slopnators/sl_unseamed_reach.ts +79 -0
- package/dist/integrity/slopnators/sl_unthreaded.ts +419 -0
- package/dist/integrity/slopnators/sl_untranslated_key.ts +164 -0
- package/dist/integrity/slopnators/sl_unversioned.ts +36 -0
- package/dist/integrity/sweep.ts +307 -0
- package/dist/knowledge/attach.ts +350 -0
- package/dist/knowledge/generators/docsgen.ts +174 -0
- package/dist/knowledge/generators/glossary.ts +73 -0
- package/dist/knowledge/generators/skills.ts +263 -0
- package/dist/knowledge/glossary.ts +6 -0
- package/dist/operations/access.ts +88 -0
- package/dist/operations/attach.ts +475 -0
- package/dist/operations/capabilities.ts +65 -0
- package/dist/operations/cost.ts +58 -0
- package/dist/operations/dispatch.ts +348 -0
- package/dist/operations/error-results.ts +31 -0
- package/dist/operations/errors/catalog.ts +168 -0
- package/dist/operations/errors/classes.ts +51 -0
- package/dist/operations/errors/errors.ts +314 -0
- package/dist/operations/generators/capability.js +29 -19
- package/dist/operations/generators/capability.ts +704 -0
- package/dist/operations/generators/compile.js +20 -1
- package/dist/operations/generators/compile.ts +643 -0
- package/dist/operations/generators/grant.ts +336 -0
- package/dist/operations/generators/operation.ts +972 -0
- package/dist/operations/generators/permits.ts +223 -0
- package/dist/operations/generators/seed.ts +347 -0
- package/dist/operations/generators/trial.js +4 -1
- package/dist/operations/generators/trial.ts +529 -0
- package/dist/operations/http.ts +164 -0
- package/dist/operations/makers/capability.ts +166 -0
- package/dist/operations/makers/trial.ts +520 -0
- package/dist/operations/memory.ts +470 -0
- package/dist/operations/metering.ts +328 -0
- package/dist/operations/nodes.ts +54 -0
- package/dist/operations/operations.ts +32 -0
- package/dist/operations/queue-policy.ts +10 -0
- package/dist/operations/result.ts +28 -0
- package/dist/operations/seams.d.ts +4 -4
- package/dist/operations/seams.ts +364 -0
- package/dist/operations/store.ts +29 -0
- package/package.json +8 -1
- package/dist/integrations/generators/sdk.d.ts +0 -1
- package/dist/integrations/generators/sdk.js +0 -148
- /package/dist/integrations/{sdk.d.ts → module.d.ts} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { defineError } from './catalog.ts'
|
|
4
|
+
|
|
5
|
+
export const AuthUnauthenticated = defineError({
|
|
6
|
+
code: 'auth.unauthenticated',
|
|
7
|
+
class: 'UNAUTHENTICATED',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export const AuthInvalidCredentials = defineError({
|
|
11
|
+
code: 'auth.invalid_credentials',
|
|
12
|
+
class: 'UNAUTHENTICATED',
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const AuthTokenExpired = defineError({
|
|
16
|
+
code: 'auth.token_expired',
|
|
17
|
+
class: 'UNAUTHENTICATED',
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const AuthTokenReused = defineError({
|
|
21
|
+
code: 'auth.token_reused',
|
|
22
|
+
class: 'UNAUTHENTICATED',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export const AuthSessionRevoked = defineError({
|
|
26
|
+
code: 'auth.session_revoked',
|
|
27
|
+
class: 'UNAUTHENTICATED',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const AuthDenied = defineError({
|
|
31
|
+
code: 'auth.denied',
|
|
32
|
+
class: 'PERMISSION_DENIED',
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const QuotaExceeded = defineError({
|
|
36
|
+
code: 'quota.exceeded',
|
|
37
|
+
class: 'RESOURCE_EXHAUSTED',
|
|
38
|
+
|
|
39
|
+
status: 402,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
export const QuotaReservationExpired = defineError({
|
|
43
|
+
code: 'quota.reservation_expired',
|
|
44
|
+
class: 'ABORTED',
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
export const RateLimitExceeded = defineError({
|
|
48
|
+
code: 'rate_limit.exceeded',
|
|
49
|
+
class: 'RESOURCE_EXHAUSTED',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const FeatureNotInPlan = defineError({
|
|
53
|
+
code: 'feature.not_in_plan',
|
|
54
|
+
class: 'PERMISSION_DENIED',
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export const DbNotFound = defineError({
|
|
58
|
+
code: 'db.not_found',
|
|
59
|
+
class: 'NOT_FOUND',
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
export const DbConstraintViolation = defineError({
|
|
63
|
+
code: 'db.constraint_violation',
|
|
64
|
+
class: 'FAILED_PRECONDITION',
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
export const DbAlreadyExists = defineError({
|
|
68
|
+
code: 'db.already_exists',
|
|
69
|
+
class: 'ALREADY_EXISTS',
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
export const DbConflict = defineError({
|
|
73
|
+
code: 'db.conflict',
|
|
74
|
+
class: 'ABORTED',
|
|
75
|
+
|
|
76
|
+
status: 412,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
export const DbMigrationChecksumMismatch = defineError({
|
|
80
|
+
code: 'db.migration_checksum_mismatch',
|
|
81
|
+
class: 'FAILED_PRECONDITION',
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
export const DbDestructiveWithoutDryRun = defineError({
|
|
85
|
+
code: 'db.destructive_without_dry_run',
|
|
86
|
+
class: 'FAILED_PRECONDITION',
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
export const DbRoundTripBudgetExceeded = defineError({
|
|
90
|
+
code: 'db.round_trip_budget_exceeded',
|
|
91
|
+
class: 'INTERNAL',
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
export const DbCursorInvalid = defineError({
|
|
95
|
+
code: 'db.cursor_invalid',
|
|
96
|
+
class: 'INVALID_ARGUMENT',
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
export const DbCursorExpired = defineError({
|
|
100
|
+
code: 'db.cursor_expired',
|
|
101
|
+
class: 'INVALID_ARGUMENT',
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
export const WorkflowNodeFailed = defineError({
|
|
105
|
+
code: 'workflow.node_failed',
|
|
106
|
+
class: 'INTERNAL',
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
export const WorkflowInvalidTransition = defineError({
|
|
110
|
+
code: 'workflow.invalid_transition',
|
|
111
|
+
class: 'FAILED_PRECONDITION',
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
export const WorkflowCompensationFailed = defineError({
|
|
115
|
+
code: 'workflow.compensation_failed',
|
|
116
|
+
class: 'INTERNAL',
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
export const WorkflowAlreadyRunning = defineError({
|
|
120
|
+
code: 'workflow.already_running',
|
|
121
|
+
class: 'ALREADY_EXISTS',
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
export const QueueJobFailed = defineError({
|
|
125
|
+
code: 'queue.job_failed',
|
|
126
|
+
class: 'INTERNAL',
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
export const QueueDlqExhausted = defineError({
|
|
130
|
+
code: 'queue.dlq_exhausted',
|
|
131
|
+
class: 'INTERNAL',
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
export const AiProviderUnavailable = defineError({
|
|
135
|
+
code: 'ai.provider_unavailable',
|
|
136
|
+
class: 'UNAVAILABLE',
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
export const AiSchemaValidationFailed = defineError({
|
|
140
|
+
code: 'ai.schema_validation_failed',
|
|
141
|
+
class: 'INTERNAL',
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
export const AiToolNotInMask = defineError({
|
|
145
|
+
code: 'ai.tool_not_in_mask',
|
|
146
|
+
class: 'PERMISSION_DENIED',
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
export const AiNodeCapExceeded = defineError({
|
|
150
|
+
code: 'ai.node_cap_exceeded',
|
|
151
|
+
class: 'RESOURCE_EXHAUSTED',
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
export const SearchIndexFailed = defineError({
|
|
155
|
+
code: 'search.index_failed',
|
|
156
|
+
class: 'INTERNAL',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
export const SearchQueryInvalid = defineError({
|
|
160
|
+
code: 'search.query_invalid',
|
|
161
|
+
class: 'INVALID_ARGUMENT',
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
export const CommsChannelKindUndeclared = defineError({
|
|
165
|
+
code: 'comms.channel_kind_undeclared',
|
|
166
|
+
class: 'FAILED_PRECONDITION',
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
export const CommsChannelKindUndescribed = defineError({
|
|
170
|
+
code: 'comms.channel_kind_undescribed',
|
|
171
|
+
class: 'FAILED_PRECONDITION',
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
export const CommsChannelKindUnlabelled = defineError({
|
|
175
|
+
code: 'comms.channel_kind_unlabelled',
|
|
176
|
+
class: 'FAILED_PRECONDITION',
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
export const CommsChannelKindUndocumented = defineError({
|
|
180
|
+
code: 'comms.channel_kind_undocumented',
|
|
181
|
+
class: 'FAILED_PRECONDITION',
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
export const CommsChannelKindDuplicate = defineError({
|
|
185
|
+
code: 'comms.channel_kind_duplicate',
|
|
186
|
+
class: 'ALREADY_EXISTS',
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
export const ConfigInvalid = defineError({
|
|
190
|
+
code: 'config.invalid',
|
|
191
|
+
class: 'FAILED_PRECONDITION',
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
export const ConfigMissingEnv = defineError({
|
|
195
|
+
code: 'config.missing_env',
|
|
196
|
+
class: 'FAILED_PRECONDITION',
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
export const ConfigSecretInPublicVar = defineError({
|
|
200
|
+
code: 'config.secret_in_public_var',
|
|
201
|
+
class: 'FAILED_PRECONDITION',
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
export const ConfigCredentialInvalid = defineError({
|
|
205
|
+
code: 'config.credential_invalid',
|
|
206
|
+
class: 'UNAUTHENTICATED',
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
export const ConfigScopeMissing = defineError({
|
|
210
|
+
code: 'config.scope_missing',
|
|
211
|
+
class: 'PERMISSION_DENIED',
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
export const ConfigResourceNotFound = defineError({
|
|
215
|
+
code: 'config.resource_not_found',
|
|
216
|
+
class: 'NOT_FOUND',
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
export const ConfigDestinationIncompatible = defineError({
|
|
220
|
+
code: 'config.destination_incompatible',
|
|
221
|
+
class: 'FAILED_PRECONDITION',
|
|
222
|
+
status: 406,
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
export const ConfigBlocksExit = defineError({
|
|
226
|
+
code: 'config.blocks_exit',
|
|
227
|
+
class: 'FAILED_PRECONDITION',
|
|
228
|
+
status: 422,
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
export const NetTimeout = defineError({
|
|
232
|
+
code: 'net.timeout',
|
|
233
|
+
class: 'DEADLINE_EXCEEDED',
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
export const NetUpstreamUnavailable = defineError({
|
|
237
|
+
code: 'net.upstream_unavailable',
|
|
238
|
+
class: 'UNAVAILABLE',
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
export const NetDestinationRefused = defineError({
|
|
242
|
+
code: 'net.destination_refused',
|
|
243
|
+
class: 'INVALID_ARGUMENT',
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
export const InternalUnexpected = defineError({
|
|
247
|
+
code: 'internal.unexpected',
|
|
248
|
+
class: 'INTERNAL',
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
export const InternalNotImplemented = defineError({
|
|
252
|
+
code: 'internal.not_implemented',
|
|
253
|
+
class: 'UNIMPLEMENTED',
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
export const InternalInvalidArgument = defineError({
|
|
257
|
+
code: 'internal.invalid_argument',
|
|
258
|
+
class: 'INVALID_ARGUMENT',
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
export const PLATFORM_ERRORS = [
|
|
262
|
+
AuthUnauthenticated,
|
|
263
|
+
AuthInvalidCredentials,
|
|
264
|
+
AuthTokenExpired,
|
|
265
|
+
AuthTokenReused,
|
|
266
|
+
AuthSessionRevoked,
|
|
267
|
+
AuthDenied,
|
|
268
|
+
QuotaExceeded,
|
|
269
|
+
QuotaReservationExpired,
|
|
270
|
+
RateLimitExceeded,
|
|
271
|
+
FeatureNotInPlan,
|
|
272
|
+
DbNotFound,
|
|
273
|
+
DbConstraintViolation,
|
|
274
|
+
DbAlreadyExists,
|
|
275
|
+
DbConflict,
|
|
276
|
+
DbMigrationChecksumMismatch,
|
|
277
|
+
DbDestructiveWithoutDryRun,
|
|
278
|
+
DbRoundTripBudgetExceeded,
|
|
279
|
+
DbCursorInvalid,
|
|
280
|
+
DbCursorExpired,
|
|
281
|
+
WorkflowNodeFailed,
|
|
282
|
+
WorkflowInvalidTransition,
|
|
283
|
+
WorkflowCompensationFailed,
|
|
284
|
+
WorkflowAlreadyRunning,
|
|
285
|
+
QueueJobFailed,
|
|
286
|
+
QueueDlqExhausted,
|
|
287
|
+
AiProviderUnavailable,
|
|
288
|
+
AiSchemaValidationFailed,
|
|
289
|
+
AiToolNotInMask,
|
|
290
|
+
AiNodeCapExceeded,
|
|
291
|
+
SearchIndexFailed,
|
|
292
|
+
SearchQueryInvalid,
|
|
293
|
+
CommsChannelKindUndeclared,
|
|
294
|
+
CommsChannelKindUndescribed,
|
|
295
|
+
CommsChannelKindUnlabelled,
|
|
296
|
+
CommsChannelKindUndocumented,
|
|
297
|
+
CommsChannelKindDuplicate,
|
|
298
|
+
ConfigInvalid,
|
|
299
|
+
ConfigMissingEnv,
|
|
300
|
+
ConfigSecretInPublicVar,
|
|
301
|
+
ConfigCredentialInvalid,
|
|
302
|
+
ConfigScopeMissing,
|
|
303
|
+
ConfigResourceNotFound,
|
|
304
|
+
ConfigDestinationIncompatible,
|
|
305
|
+
ConfigBlocksExit,
|
|
306
|
+
NetTimeout,
|
|
307
|
+
NetUpstreamUnavailable,
|
|
308
|
+
NetDestinationRefused,
|
|
309
|
+
InternalUnexpected,
|
|
310
|
+
InternalNotImplemented,
|
|
311
|
+
InternalInvalidArgument,
|
|
312
|
+
] as const
|
|
313
|
+
|
|
314
|
+
export type PlatformErrorCode = (typeof PLATFORM_ERRORS)[number]['def']['code']
|
|
@@ -17,7 +17,7 @@ import { named as packageOf } from "../../core/scope.js";
|
|
|
17
17
|
import { PREFIXES } from "../../core/thread.js";
|
|
18
18
|
import { servesBrowser } from "../../integrations/target.js";
|
|
19
19
|
import { CAPABILITIES_AT, CLIENT_AT, DECLARED_SEAMS_AT, MCP_AT, OPENAPI_AT, DISPATCHING_AT, SEAMS_AT, routeAt, SURFACES, switched, } from "../capabilities.js";
|
|
20
|
-
import { ENVIRONMENT } from "../../core/actor.js";
|
|
20
|
+
import { ANONYMOUS, ENVIRONMENT } from "../../core/actor.js";
|
|
21
21
|
import { PERMITS_AT } from "../access.js";
|
|
22
22
|
import { SAID as HANDED, supplies } from "../seams.js";
|
|
23
23
|
import { beside, operations, quoted, runtime, types } from "./seed.js";
|
|
@@ -314,9 +314,7 @@ function settled(keeping, stores, ruled, vaulted) {
|
|
|
314
314
|
const named = stores.map((one, at) => ({ from: beside(DECLARED_SEAMS_AT, one), as: `s${String(at)}` }));
|
|
315
315
|
const only = named[0];
|
|
316
316
|
return [
|
|
317
|
-
`import {
|
|
318
|
-
`import { httpSeam } from '${runtime(DECLARED_SEAMS_AT, '../http.ts')}'`,
|
|
319
|
-
`import { arrived, fresh, inMemorySeams } from '${runtime(DECLARED_SEAMS_AT, '../memory.ts')}'`,
|
|
317
|
+
`import type { Actor, Environment } from '${runtime(DECLARED_SEAMS_AT, '../../core/actor.ts')}'`,
|
|
320
318
|
`import type { Seams } from '${runtime(DECLARED_SEAMS_AT, '../seams.ts')}'`,
|
|
321
319
|
...(keeping ? [`import { ENTITIES } from '${beside(DECLARED_SEAMS_AT, ENTITIES_AT)}'`] : []),
|
|
322
320
|
...(ruled ? [`import { permits } from '${beside(DECLARED_SEAMS_AT, PERMITS_AT)}'`] : []),
|
|
@@ -326,18 +324,9 @@ function settled(keeping, stores, ruled, vaulted) {
|
|
|
326
324
|
'',
|
|
327
325
|
...(keeping
|
|
328
326
|
? [
|
|
329
|
-
'const
|
|
330
|
-
'',
|
|
331
|
-
'const ADDRESSED = new Map(',
|
|
332
|
-
' ENTITIES.flatMap((one) => {',
|
|
333
|
-
" const held = (one.must ?? []).flatMap((each) => ('unique' in each ? each.unique : []))[0]",
|
|
334
|
-
' return held === undefined ? [] : [[one.id, held] as const]',
|
|
335
|
-
' }),',
|
|
336
|
-
')',
|
|
337
|
-
'',
|
|
338
|
-
'const made = inMemorySeams({ entities: KEPT, keys: ADDRESSED }).seams',
|
|
327
|
+
'const made = {', " log: { write(level: string, action: string, who: Actor, data: Record<string, unknown>) { console.log(JSON.stringify({ level, action, who, data })) } },", " audit: { async append(who: Actor, record: unknown) { console.log(JSON.stringify({ audit: record, who })) } },", " errors: { async record(who: Actor, failure: unknown) { console.error(JSON.stringify({ failure, who })) } },", '}',
|
|
339
328
|
]
|
|
340
|
-
: ['const made =
|
|
329
|
+
: ['const made = {', " log: { write(level: string, action: string, who: Actor, data: Record<string, unknown>) { console.log(JSON.stringify({ level, action, who, data })) } },", " audit: { async append(who: Actor, record: unknown) { console.log(JSON.stringify({ audit: record, who })) } },", " errors: { async record(who: Actor, failure: unknown) { console.error(JSON.stringify({ failure, who })) } },", '}']),
|
|
341
330
|
'',
|
|
342
331
|
...(stores.length > 1
|
|
343
332
|
? [
|
|
@@ -361,15 +350,36 @@ function settled(keeping, stores, ruled, vaulted) {
|
|
|
361
350
|
'',
|
|
362
351
|
]
|
|
363
352
|
: []),
|
|
353
|
+
`const ANONYMOUS: Actor = ${JSON.stringify(ANONYMOUS)}`,
|
|
354
|
+
'',
|
|
355
|
+
"const http: NonNullable<Seams['http']> = {",
|
|
356
|
+
' async call(request) {',
|
|
357
|
+
' const base = new URL(request.address)',
|
|
358
|
+
" if (base.protocol !== 'https:') throw new Error(request.target + ' is reached over ' + base.protocol + ' and an outward call goes over https only')",
|
|
359
|
+
' const stem = base.pathname.length === 1 ? String() : base.pathname',
|
|
360
|
+
' const url = new URL(base.origin + stem + request.path)',
|
|
361
|
+
" if (url.origin !== base.origin) throw new Error(request.path + ' resolves to ' + url.origin + ', which is not where ' + request.target + ' is')",
|
|
362
|
+
' const headers: Record<string, string> = { ...request.headers }',
|
|
363
|
+
" if (request.contentType !== undefined) headers['content-type'] = request.contentType",
|
|
364
|
+
' const carried = new Uint8Array(request.body === undefined ? 0 : request.body.byteLength)',
|
|
365
|
+
' if (request.body !== undefined) carried.set(request.body)',
|
|
366
|
+
' const began = Date.now()',
|
|
367
|
+
' const sent = JSON.stringify(headers).length + (request.body === undefined ? 0 : request.body.byteLength)',
|
|
368
|
+
' const answered = await fetch(url.toString(), { method: request.method, headers, ...(request.body === undefined ? {} : { body: carried }), signal: AbortSignal.timeout(10000) })',
|
|
369
|
+
' const body = new Uint8Array(await answered.arrayBuffer())',
|
|
370
|
+
' return { status: answered.status, headers: Object.fromEntries(answered.headers.entries()), body, bytesSent: sent, bytesReceived: body.byteLength, durationMs: Date.now() - began }',
|
|
371
|
+
' },',
|
|
372
|
+
'}',
|
|
373
|
+
'',
|
|
364
374
|
'const shared = globalThis as { __threadSeams?: Seams }',
|
|
365
375
|
'',
|
|
366
376
|
'export const DECLARED: Seams = (shared.__threadSeams ??= {',
|
|
367
377
|
' ...made,',
|
|
368
378
|
...(stores.length === 1 ? [' store: kept,'] : []),
|
|
369
379
|
...(stores.length > 1 ? [' store,'] : []),
|
|
370
|
-
' clock: { now:
|
|
371
|
-
' random: { next: Math.random, uuid:
|
|
372
|
-
' http
|
|
380
|
+
' clock: { now: () => Date.now() },',
|
|
381
|
+
' random: { next: Math.random, uuid: () => crypto.randomUUID() },',
|
|
382
|
+
' http,',
|
|
373
383
|
...(ruled ? [' permits: { check: (actor, action, resource) => Promise.resolve(permits(actor, action, resource)) },'] : []),
|
|
374
384
|
...(vaulted ? [' vault: { resolve: opening },'] : []),
|
|
375
385
|
'})',
|
|
@@ -464,7 +474,7 @@ function dispatching(found) {
|
|
|
464
474
|
return [
|
|
465
475
|
'/* GENERATED by thread — do not edit. It is derived from what this app declares. */',
|
|
466
476
|
'',
|
|
467
|
-
`declare module '${packageOf('ui')}/checked' {`,
|
|
477
|
+
`declare module '${packageOf('ui')}/ui/checked' {`,
|
|
468
478
|
...(reachable.length === 0
|
|
469
479
|
? [' interface Dispatching {}']
|
|
470
480
|
: [' interface Dispatching {', ...reachable.map((one) => ` readonly ${one.operation}: true`), ' }']),
|