@owlmeans/viable-sdk 0.1.18-rc.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.
- package/README.md +128 -0
- package/build/api/index.d.ts +2 -0
- package/build/api/index.d.ts.map +1 -0
- package/build/api/index.js +2 -0
- package/build/api/index.js.map +1 -0
- package/build/api/remote.d.ts +14 -0
- package/build/api/remote.d.ts.map +1 -0
- package/build/api/remote.js +123 -0
- package/build/api/remote.js.map +1 -0
- package/build/consts.d.ts +47 -0
- package/build/consts.d.ts.map +1 -0
- package/build/consts.js +47 -0
- package/build/consts.js.map +1 -0
- package/build/context/index.d.ts +22 -0
- package/build/context/index.d.ts.map +1 -0
- package/build/context/index.js +92 -0
- package/build/context/index.js.map +1 -0
- package/build/errors.d.ts +21 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +36 -0
- package/build/errors.js.map +1 -0
- package/build/executor/boot-check.d.ts +73 -0
- package/build/executor/boot-check.d.ts.map +1 -0
- package/build/executor/boot-check.js +155 -0
- package/build/executor/boot-check.js.map +1 -0
- package/build/executor/env.d.ts +25 -0
- package/build/executor/env.d.ts.map +1 -0
- package/build/executor/env.js +77 -0
- package/build/executor/env.js.map +1 -0
- package/build/executor/errors.d.ts +69 -0
- package/build/executor/errors.d.ts.map +1 -0
- package/build/executor/errors.js +80 -0
- package/build/executor/errors.js.map +1 -0
- package/build/executor/files.d.ts +124 -0
- package/build/executor/files.d.ts.map +1 -0
- package/build/executor/files.js +529 -0
- package/build/executor/files.js.map +1 -0
- package/build/executor/git.d.ts +52 -0
- package/build/executor/git.d.ts.map +1 -0
- package/build/executor/git.js +353 -0
- package/build/executor/git.js.map +1 -0
- package/build/executor/health.d.ts +92 -0
- package/build/executor/health.d.ts.map +1 -0
- package/build/executor/health.js +98 -0
- package/build/executor/health.js.map +1 -0
- package/build/executor/index.d.ts +39 -0
- package/build/executor/index.d.ts.map +1 -0
- package/build/executor/index.js +173 -0
- package/build/executor/index.js.map +1 -0
- package/build/executor/integrity.d.ts +17 -0
- package/build/executor/integrity.d.ts.map +1 -0
- package/build/executor/integrity.js +59 -0
- package/build/executor/integrity.js.map +1 -0
- package/build/executor/layout.d.ts +61 -0
- package/build/executor/layout.d.ts.map +1 -0
- package/build/executor/layout.js +98 -0
- package/build/executor/layout.js.map +1 -0
- package/build/executor/shell.d.ts +89 -0
- package/build/executor/shell.d.ts.map +1 -0
- package/build/executor/shell.js +280 -0
- package/build/executor/shell.js.map +1 -0
- package/build/executor/spawn.d.ts +111 -0
- package/build/executor/spawn.d.ts.map +1 -0
- package/build/executor/spawn.js +314 -0
- package/build/executor/spawn.js.map +1 -0
- package/build/harness/index.d.ts +28 -0
- package/build/harness/index.d.ts.map +1 -0
- package/build/harness/index.js +83 -0
- package/build/harness/index.js.map +1 -0
- package/build/harness/templates.d.ts +30 -0
- package/build/harness/templates.d.ts.map +1 -0
- package/build/harness/templates.js +162 -0
- package/build/harness/templates.js.map +1 -0
- package/build/index.d.ts +13 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +12 -0
- package/build/index.js.map +1 -0
- package/build/project/env.d.ts +108 -0
- package/build/project/env.d.ts.map +1 -0
- package/build/project/env.js +233 -0
- package/build/project/env.js.map +1 -0
- package/build/project/marker.d.ts +34 -0
- package/build/project/marker.d.ts.map +1 -0
- package/build/project/marker.js +54 -0
- package/build/project/marker.js.map +1 -0
- package/build/project/setup.d.ts +62 -0
- package/build/project/setup.d.ts.map +1 -0
- package/build/project/setup.js +190 -0
- package/build/project/setup.js.map +1 -0
- package/build/run/index.d.ts +75 -0
- package/build/run/index.d.ts.map +1 -0
- package/build/run/index.js +150 -0
- package/build/run/index.js.map +1 -0
- package/build/run/serve.d.ts +18 -0
- package/build/run/serve.d.ts.map +1 -0
- package/build/run/serve.js +148 -0
- package/build/run/serve.js.map +1 -0
- package/build/run/state.d.ts +75 -0
- package/build/run/state.d.ts.map +1 -0
- package/build/run/state.js +136 -0
- package/build/run/state.js.map +1 -0
- package/build/session/index.d.ts +17 -0
- package/build/session/index.d.ts.map +1 -0
- package/build/session/index.js +226 -0
- package/build/session/index.js.map +1 -0
- package/build/session/questions.d.ts +16 -0
- package/build/session/questions.d.ts.map +1 -0
- package/build/session/questions.js +17 -0
- package/build/session/questions.js.map +1 -0
- package/build/session/queue.d.ts +54 -0
- package/build/session/queue.d.ts.map +1 -0
- package/build/session/queue.js +102 -0
- package/build/session/queue.js.map +1 -0
- package/build/session/tasks.d.ts +15 -0
- package/build/session/tasks.d.ts.map +1 -0
- package/build/session/tasks.js +16 -0
- package/build/session/tasks.js.map +1 -0
- package/build/task/driver.d.ts +30 -0
- package/build/task/driver.d.ts.map +1 -0
- package/build/task/driver.js +120 -0
- package/build/task/driver.js.map +1 -0
- package/build/task/envelope.d.ts +35 -0
- package/build/task/envelope.d.ts.map +1 -0
- package/build/task/envelope.js +230 -0
- package/build/task/envelope.js.map +1 -0
- package/build/task/index.d.ts +4 -0
- package/build/task/index.d.ts.map +1 -0
- package/build/task/index.js +4 -0
- package/build/task/index.js.map +1 -0
- package/build/task/inquiry.d.ts +53 -0
- package/build/task/inquiry.d.ts.map +1 -0
- package/build/task/inquiry.js +232 -0
- package/build/task/inquiry.js.map +1 -0
- package/build/tools/catalogue.d.ts +17 -0
- package/build/tools/catalogue.d.ts.map +1 -0
- package/build/tools/catalogue.js +1169 -0
- package/build/tools/catalogue.js.map +1 -0
- package/build/tools/index.d.ts +7 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +7 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/jobs.d.ts +12 -0
- package/build/tools/jobs.d.ts.map +1 -0
- package/build/tools/jobs.js +60 -0
- package/build/tools/jobs.js.map +1 -0
- package/build/tools/mcp.d.ts +43 -0
- package/build/tools/mcp.d.ts.map +1 -0
- package/build/tools/mcp.js +131 -0
- package/build/tools/mcp.js.map +1 -0
- package/build/tools/platform.d.ts +77 -0
- package/build/tools/platform.d.ts.map +1 -0
- package/build/tools/platform.js +316 -0
- package/build/tools/platform.js.map +1 -0
- package/build/tools/refusal.d.ts +66 -0
- package/build/tools/refusal.d.ts.map +1 -0
- package/build/tools/refusal.js +377 -0
- package/build/tools/refusal.js.map +1 -0
- package/build/tools/types.d.ts +83 -0
- package/build/tools/types.d.ts.map +1 -0
- package/build/tools/types.js +38 -0
- package/build/tools/types.js.map +1 -0
- package/build/types.d.ts +174 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { ResilientError } from '@owlmeans/error';
|
|
2
|
+
import { ModerationCategory } from '@owlmeans/viable-common';
|
|
3
|
+
/** What each moderation category refused, in the words the refusal is explained with. */
|
|
4
|
+
const MODERATION = {
|
|
5
|
+
[ModerationCategory.CredentialHarvesting]: 'collecting other people\'s passwords, one-time codes or card details',
|
|
6
|
+
[ModerationCategory.BrandImpersonation]: 'presenting itself as another company or as a real person',
|
|
7
|
+
[ModerationCategory.PaymentCapture]: 'taking payment details on behalf of a merchant the requester does not run',
|
|
8
|
+
[ModerationCategory.AbuseTooling]: 'abuse — unsolicited bulk messaging, credential stuffing or phishing kits',
|
|
9
|
+
};
|
|
10
|
+
/** ` (detail)`, or nothing at all: a phrase must read as a sentence when there is no detail. */
|
|
11
|
+
const aside = (detail) => detail !== '' ? ` (${detail})` : '';
|
|
12
|
+
/**
|
|
13
|
+
* Every refusal a connector can be handed, and the one sentence it is handed instead.
|
|
14
|
+
*
|
|
15
|
+
* Ordered by SPECIFICITY, because the first marker the message contains wins: every reason of a
|
|
16
|
+
* family sits above the family's own marker, or the family would answer for all of them. A marker
|
|
17
|
+
* that is a substring of a later one is a marker that shadows it, which `catalogue.spec.ts` pins
|
|
18
|
+
* rather than leaves to review.
|
|
19
|
+
*
|
|
20
|
+
* The markers are literals here on purpose. They are wire text owned by packages this one does not
|
|
21
|
+
* depend on, and copying the constant would need a dependency edge from a tooling package onto the
|
|
22
|
+
* platform's own — so they are spelled once, in the order the platform spells them, and are
|
|
23
|
+
* exactly the substrings the manager's own phrasing matches on. Anything unmatched falls back to
|
|
24
|
+
* its marker, which is the one outcome that stays honest as the platform grows a refusal this
|
|
25
|
+
* table has never heard of.
|
|
26
|
+
*/
|
|
27
|
+
export const REFUSALS = [
|
|
28
|
+
// ── A conversion refused by the platform ────────────────────────────────────────────────────
|
|
29
|
+
{
|
|
30
|
+
marker: 'conversion:unsupported:monorepo',
|
|
31
|
+
phrase: paths => 'This repository points at code that is not inside it — a git submodule, or a'
|
|
32
|
+
+ ' workspace package that lives elsewhere. Converting needs everything in one repository.'
|
|
33
|
+
+ (paths !== '' ? `\nunlinked: ${paths}` : ''),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
marker: 'conversion:unsupported:bad-origin-url',
|
|
37
|
+
phrase: url => 'That is not a repository address the platform can clone. Give the repository\'s'
|
|
38
|
+
+ ' own address, in the form https://github.com/owner/repository.'
|
|
39
|
+
+ (url !== '' ? `\ngiven: ${url}` : ''),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
marker: 'conversion:unsupported:not-linked',
|
|
43
|
+
phrase: () => 'The platform has no way to read that repository: no GitHub connection is'
|
|
44
|
+
+ ' recorded for this project, or its access was revoked. The user connects it in the web'
|
|
45
|
+
+ ' application, and the conversion is started again afterwards.',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
marker: 'conversion:unsupported:no-origin',
|
|
49
|
+
phrase: () => 'This project was generated by the platform rather than imported, so there is'
|
|
50
|
+
+ ' nothing to convert. develop_story is what changes a generated project.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
marker: 'conversion:unsupported:not-convertible',
|
|
54
|
+
phrase: () => 'The intake refused this origin: a conversion needs an application with source'
|
|
55
|
+
+ ' code it can read, not an empty repository, a documentation site or a bundle of binaries.'
|
|
56
|
+
+ ' check_convertible carries the reasons it gave.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
marker: 'conversion:unsupported:',
|
|
60
|
+
phrase: reason => `This origin cannot be converted${aside(reason)}, and no retry changes that.`
|
|
61
|
+
+ ' check_convertible carries the reasons.',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
marker: 'conversion:stage:',
|
|
65
|
+
phrase: asked => `That decision is not available from where the conversion stands${aside(asked)}.`
|
|
66
|
+
+ ' Call conversion_status for the stage it is on and the decision it takes now.',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
marker: 'conversion:clone-failed:',
|
|
70
|
+
phrase: () => 'The origin\'s sources could not be fetched. Check the repository still exists and'
|
|
71
|
+
+ ' that the project\'s GitHub connection still reaches it, then'
|
|
72
|
+
+ ' proceed_conversion { "decision": "retry" }.',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
marker: 'conversion:purge-in-place',
|
|
76
|
+
phrase: () => 'Nothing to purge: the original sources are the project itself (an in-place'
|
|
77
|
+
+ ' repair). It was converted where it stood rather than rebuilt beside a filed-away copy,'
|
|
78
|
+
+ ' so there is no __viable_converted/ to delete and nothing has been removed.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
marker: 'conversion:publish-origin',
|
|
82
|
+
phrase: () => 'That would publish onto the repository this project was imported FROM, and its'
|
|
83
|
+
+ ' original sources are still on the volume — the push would write over the user\'s own'
|
|
84
|
+
+ ' code. purge_origin first, or publish to a different repository.',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
marker: 'conversion:relocate-declined',
|
|
88
|
+
phrase: () => 'The conversion builds the new application around the existing code, which means'
|
|
89
|
+
+ ' moving that code one level down into __viable_converted/; nothing is deleted. The move'
|
|
90
|
+
+ ' was declined, so the conversion stopped here. Start it again and answer yes when it asks.',
|
|
91
|
+
},
|
|
92
|
+
// ── A conversion refused by the converter itself, usually reaching a parent on a failed job ──
|
|
93
|
+
{
|
|
94
|
+
marker: 'viable-converter:not-convertible:',
|
|
95
|
+
phrase: reason => `The origin is not an application this platform can convert${aside(reason)}.`,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
marker: 'viable-converter:unsupported-stack:',
|
|
99
|
+
phrase: stack => `The origin is built on a stack this converter carries no knowledge of${aside(stack)}.`
|
|
100
|
+
+ ' Nothing retries into a stack it cannot read.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
marker: 'viable-converter:unlinked:',
|
|
104
|
+
phrase: paths => 'The origin depends on code that is not inside it, so there is no one tree to'
|
|
105
|
+
+ ' convert.' + (paths !== '' ? `\nunlinked: ${paths}` : ''),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
marker: 'viable-converter:stage-order:',
|
|
109
|
+
phrase: asked => `A conversion stage was asked for out of order${aside(asked)}.`
|
|
110
|
+
+ ' conversion_status says which one comes next.',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
marker: 'viable-converter:capability:',
|
|
114
|
+
phrase: name => `The conversion needs something this deployment does not provide${aside(name)}.`
|
|
115
|
+
+ ' Nothing the parent agent does changes that; report it.',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
marker: 'viable-converter:too-large:',
|
|
119
|
+
phrase: bytes => 'The origin is larger than a conversion reads'
|
|
120
|
+
+ (bytes !== '' ? ` (${bytes} bytes)` : '') + '.'
|
|
121
|
+
+ ' Convert a sub-project of it, or bring in a smaller tree.',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
marker: 'viable-converter:taxonomy-missing',
|
|
125
|
+
phrase: () => 'This step needs what the ANALYSIS stage records, and the volume holds none of'
|
|
126
|
+
+ ' it. Run that stage first — proceed_conversion { "decision": "analyze" }.',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
marker: 'viable-converter:stack-missing',
|
|
130
|
+
phrase: () => 'This step needs what the INTAKE stage records about the stack, and the volume'
|
|
131
|
+
+ ' holds none of it. The intake is what convert_project runs.',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
marker: 'viable-converter:origin-missing',
|
|
135
|
+
phrase: () => 'The origin\'s sources are not on the volume: the stage that brings them in has'
|
|
136
|
+
+ ' not run. convert_project starts it.',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
marker: 'viable-converter:origin-purged',
|
|
140
|
+
phrase: () => 'The original sources were deleted by purge_origin and this needs them. A purge'
|
|
141
|
+
+ ' cannot be undone.',
|
|
142
|
+
},
|
|
143
|
+
// ── What the platform refuses to build, whatever asked for it ────────────────────────────────
|
|
144
|
+
{
|
|
145
|
+
marker: 'content-refused:',
|
|
146
|
+
phrase: category => 'The platform will not build this: it describes an application for '
|
|
147
|
+
+ (MODERATION[category] ?? 'something the platform does not host') + '.'
|
|
148
|
+
+ ' The refusal is about the SHAPE of the product, never its sector — say so to the user;'
|
|
149
|
+
+ ' re-sending the same description is refused the same way.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
marker: 'reserved-name:',
|
|
153
|
+
phrase: brand => (brand !== ''
|
|
154
|
+
? `"${brand}" is another company's name`
|
|
155
|
+
: 'That name belongs to another company')
|
|
156
|
+
+ ', and a project name becomes part of its public web address. Choose a name of the user\'s'
|
|
157
|
+
+ ' own — the product may still work with that company.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
marker: 'target-integrity:',
|
|
161
|
+
phrase: files => 'The files in this project are not a Viable application, so nothing will be'
|
|
162
|
+
+ ' built or started from them.' + (files !== '' ? `\n${files}` : ''),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
marker: 'legacy-target:',
|
|
166
|
+
phrase: () => 'This project was generated with an earlier application layout the platform no'
|
|
167
|
+
+ ' longer writes into. It keeps running, but no story or change can be applied to it.'
|
|
168
|
+
+ ' reinitialize_project rebuilds it with the current layout and keeps its stories.',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
marker: 'viable-project:missconfigured:',
|
|
172
|
+
phrase: () => 'This project\'s analysis is missing from its sandbox, so there is nothing to'
|
|
173
|
+
+ ' build a story from. reinitialize_project restores it.',
|
|
174
|
+
},
|
|
175
|
+
// ── A balance, rather than a fault ───────────────────────────────────────────────────────────
|
|
176
|
+
{
|
|
177
|
+
marker: 'out-of-tokens:conversion-budget',
|
|
178
|
+
phrase: () => 'The account balance will not cover this conversion stage. conversion_status'
|
|
179
|
+
+ ' carries the estimate; the balance is topped up in the web application.',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
marker: 'out-of-tokens:project-budget',
|
|
183
|
+
phrase: () => 'The account balance is below the floor a new project needs. It is topped up in'
|
|
184
|
+
+ ' the web application.',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
marker: 'out-of-tokens:story-budget',
|
|
188
|
+
phrase: () => 'The account balance will not cover developing a story. It is topped up in the'
|
|
189
|
+
+ ' web application.',
|
|
190
|
+
},
|
|
191
|
+
// ── The project is busy ──────────────────────────────────────────────────────────────────────
|
|
192
|
+
{
|
|
193
|
+
marker: 'viable-project:agent:occupied:',
|
|
194
|
+
phrase: verb => `The platform is already working on this project${aside(verb)}.`
|
|
195
|
+
+ ' Poll the running job with wait_for and ask again once it settles.',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
// Spelled with its package prefix, unlike every marker above: `locked:` alone is a substring of
|
|
199
|
+
// ordinary English and of `unlocked:`, and a false match would answer some other refusal with
|
|
200
|
+
// this sentence.
|
|
201
|
+
marker: 'viable-agent-common:locked:',
|
|
202
|
+
phrase: task => `The platform holds this project's lock${aside(task)}.`
|
|
203
|
+
+ ' Poll the running job with wait_for and ask again once it settles.',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
marker: 'git-busy:',
|
|
207
|
+
phrase: () => 'A git operation is already running on this project. Retry once it settles.',
|
|
208
|
+
},
|
|
209
|
+
// ── The connector, from the platform's side of it ────────────────────────────────────────────
|
|
210
|
+
{
|
|
211
|
+
marker: 'viable-connect:local-unsupported:',
|
|
212
|
+
phrase: op => `That addresses infrastructure a local project does not have${aside(op)}:`
|
|
213
|
+
+ ' sandbox lifecycle, production, preview watching and remote git are cloud-target only.',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
marker: 'viable-connect:session-gone:',
|
|
217
|
+
phrase: () => 'No connector is attached to this project any more, and this needs one. Call the'
|
|
218
|
+
+ ' tool again — a session is opened on demand — then resume_pipeline for the run that'
|
|
219
|
+
+ ' stopped.',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
marker: 'viable-connect:session-not-found:',
|
|
223
|
+
phrase: () => 'That session has expired or belongs to another profile. Call the tool again; a'
|
|
224
|
+
+ ' session is opened on demand.',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
marker: 'viable-connect:op-timeout:',
|
|
228
|
+
phrase: () => 'The connector did not answer within the operation\'s own deadline. Retry it.',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
marker: 'viable-connect:op-refused:',
|
|
232
|
+
phrase: detail => `The connector ran the operation and refused it${aside(detail)}.`,
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
marker: 'viable-connect:op-unknown:',
|
|
236
|
+
phrase: () => 'That operation is unknown, already answered, or belongs to another session.',
|
|
237
|
+
},
|
|
238
|
+
// ── The call itself ──────────────────────────────────────────────────────────────────────────
|
|
239
|
+
{
|
|
240
|
+
marker: 'viable-api:agent:',
|
|
241
|
+
phrase: verb => `The platform's agent could not complete this${aside(verb)}.`
|
|
242
|
+
+ ' project_status and conversion_status say where things stand; the call is retryable.',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
marker: 'api:client:auth:',
|
|
246
|
+
phrase: () => 'The platform refused this access token. It is issued in the web application and'
|
|
247
|
+
+ ' can be revoked there — check VIABLE_API_TOKEN.',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
marker: 'api:client:crashed:',
|
|
251
|
+
phrase: () => 'The platform errored on this call. Retry it, and read project_status for where'
|
|
252
|
+
+ ' the project actually stands before assuming nothing happened.',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
marker: 'api:client:forbidden',
|
|
256
|
+
phrase: () => 'This token may not do that: the project belongs to another account, or the'
|
|
257
|
+
+ ' capability is not on this plan.',
|
|
258
|
+
},
|
|
259
|
+
];
|
|
260
|
+
/** A stack frame, as every runtime prints one. */
|
|
261
|
+
const STACK_FRAME = /^\s+at\s/;
|
|
262
|
+
/** Everything up to the first stack frame — a parent agent can act on none of what follows. */
|
|
263
|
+
const withoutStack = (text) => {
|
|
264
|
+
const lines = text.split('\n');
|
|
265
|
+
const frame = lines.findIndex(line => STACK_FRAME.test(line));
|
|
266
|
+
return (frame < 0 ? lines : lines.slice(0, frame)).join('\n').trim();
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Whether this error is what `ResilientError.ensure` leaves when NOTHING recognised the class.
|
|
270
|
+
*
|
|
271
|
+
* Its fall-through converter is `new resilientErrorClass(err.message, err.stack)` against a
|
|
272
|
+
* constructor whose signature is `(type, message, stack)` — so `type` holds the original MESSAGE
|
|
273
|
+
* and `message` holds the original STACK, with no marshalling separator anywhere to give the shape
|
|
274
|
+
* away. Nothing about that path is exotic: `processResponse` in `@owlmeans/api` ensures ANY string
|
|
275
|
+
* response body, and an edge 502/503 answers in plain text (`upstream connect error …`), so a
|
|
276
|
+
* gateway failure was handed to the parent agent as a trace of the SDK's own frames.
|
|
277
|
+
*
|
|
278
|
+
* It is recognised by the head every runtime prints for a stack — `<Name>: <message>` followed by
|
|
279
|
+
* the frames — and what survives is the message the runtime put there, which for the plain-text
|
|
280
|
+
* body IS the refusal. The check is deliberately positional rather than a regex over `<Name>`: the
|
|
281
|
+
* type can itself be a whole marshalled string carrying newlines, and only the segment BEFORE the
|
|
282
|
+
* match has to be a single-line error name.
|
|
283
|
+
*/
|
|
284
|
+
const baseConverted = (e) => {
|
|
285
|
+
if (e.type === '')
|
|
286
|
+
return false;
|
|
287
|
+
const at = e.message.indexOf(`: ${e.type}`);
|
|
288
|
+
if (at < 0)
|
|
289
|
+
return false;
|
|
290
|
+
const rest = e.message.slice(at + e.type.length + 2);
|
|
291
|
+
return !e.message.slice(0, at).includes('\n') && (rest === '' || rest.startsWith('\n'));
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Where the marker actually is, for anything that can carry one.
|
|
295
|
+
*
|
|
296
|
+
* `ResilientError.ensure` rebuilds a class this process never registered by putting the whole
|
|
297
|
+
* marshalled string in `type` and its own local STACK in `message` — and every refusal the
|
|
298
|
+
* platform raises is such a class, since they are declared in packages the SDK does not depend on.
|
|
299
|
+
* So the marker can be in either field, and a stored `job.error` carries it as a bare string.
|
|
300
|
+
*
|
|
301
|
+
* {@link baseConverted} is asked FIRST, because that rebuild is the one shape where the stack sits
|
|
302
|
+
* outside the marshalling and the fields are swapped: everything below reads `message` as text and
|
|
303
|
+
* would hand the trace straight to the reader.
|
|
304
|
+
*/
|
|
305
|
+
const textOf = (e) => {
|
|
306
|
+
if (typeof e === 'string')
|
|
307
|
+
return e;
|
|
308
|
+
if (!(e instanceof Error))
|
|
309
|
+
return String(e ?? '');
|
|
310
|
+
if (e instanceof ResilientError && baseConverted(e))
|
|
311
|
+
return e.type;
|
|
312
|
+
const type = e instanceof ResilientError ? e.type : '';
|
|
313
|
+
if (e.message.includes(ResilientError.separator))
|
|
314
|
+
return e.message;
|
|
315
|
+
if (type.includes(ResilientError.separator))
|
|
316
|
+
return type;
|
|
317
|
+
return e.message !== '' ? e.message : type;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* What a refusal SAYS, with the marshalling and the stack taken off it.
|
|
321
|
+
*
|
|
322
|
+
* A marshalled error is `type|||message|||stack`, so the middle segment is the marker and the last
|
|
323
|
+
* one is a stack trace from a machine the reader has no access to. What is left is the marker
|
|
324
|
+
* alone — which is the fallback whenever nothing in {@link REFUSALS} recognises it, because a
|
|
325
|
+
* marker names the refusal even when no sentence has been written for it yet.
|
|
326
|
+
*
|
|
327
|
+
* Text that was never marshalled is returned exactly as it is. A stack only ever arrives inside
|
|
328
|
+
* the marshalling, and the same field carries things that are not refusals at all — a job's
|
|
329
|
+
* `error` doubles as the build warning a slot recorded, and cutting that at the first line that
|
|
330
|
+
* looks like a stack frame would throw away the diagnostics somebody asked for.
|
|
331
|
+
*/
|
|
332
|
+
export const refusalMessage = (e) => {
|
|
333
|
+
const parts = textOf(e).split(ResilientError.separator);
|
|
334
|
+
return parts.length > 1 ? withoutStack(parts[1] ?? '') : (parts[0] ?? '');
|
|
335
|
+
};
|
|
336
|
+
/** Said where the platform refused and said nothing about why at all. */
|
|
337
|
+
export const UNKNOWN_REFUSAL = 'The platform refused this and said nothing about why. Read'
|
|
338
|
+
+ ' project_status, or conversion_status for a conversion, before retrying.';
|
|
339
|
+
/** Said after a marker no sentence has been written for: the marker names it, this says what next. */
|
|
340
|
+
export const UNPHRASED_REFUSAL = 'That is the marker the platform refused with, and nothing here'
|
|
341
|
+
+ ' has a sentence for it yet. Read conversion_status for a conversion, project_status'
|
|
342
|
+
+ ' otherwise, before deciding whether anything is worth retrying.';
|
|
343
|
+
/**
|
|
344
|
+
* Wire text a refusal travels as — `package:family:reason`, with any detail after it.
|
|
345
|
+
*
|
|
346
|
+
* What separates an unphrased MARKER from the other things this same field carries: a deadline
|
|
347
|
+
* message, a build warning, a gateway error. Only a marker earns the next-step half, because only
|
|
348
|
+
* a marker is a refusal the parent can neither read nor act on; a build warning is diagnostics
|
|
349
|
+
* somebody asked for and is returned exactly as it stands.
|
|
350
|
+
*/
|
|
351
|
+
const MARKER_SHAPE = /^[a-z][\w-]*(?::[\w.-]+)+/;
|
|
352
|
+
/**
|
|
353
|
+
* The one sentence a parent agent is given for anything that refused it.
|
|
354
|
+
*
|
|
355
|
+
* The reader is a language model holding a tool result, and it acts on what it reads: a marshalled
|
|
356
|
+
* type name followed by a stack trace tells it only that something went wrong somewhere, so it
|
|
357
|
+
* retries a call that can never succeed, or reports the server as broken. A refusal is an ANSWER —
|
|
358
|
+
* this origin is the project, that decision is not available here, the balance will not cover it —
|
|
359
|
+
* and every one of them has something the parent should do next.
|
|
360
|
+
*
|
|
361
|
+
* An unknown marker keeps that property rather than dropping it: the marker stays, because it is
|
|
362
|
+
* the honest answer as the platform grows refusals faster than phrasings, and {@link
|
|
363
|
+
* UNPHRASED_REFUSAL} names the tool to call — a parent left holding wire text alone has neither.
|
|
364
|
+
*/
|
|
365
|
+
export const refusalPhrase = (e) => {
|
|
366
|
+
const message = refusalMessage(e);
|
|
367
|
+
if (message === '')
|
|
368
|
+
return UNKNOWN_REFUSAL;
|
|
369
|
+
const known = REFUSALS.find(entry => message.includes(entry.marker));
|
|
370
|
+
if (known == null) {
|
|
371
|
+
return MARKER_SHAPE.test(message) ? `${message}\n${UNPHRASED_REFUSAL}` : message;
|
|
372
|
+
}
|
|
373
|
+
const detail = message.slice(message.indexOf(known.marker) + known.marker.length)
|
|
374
|
+
.replace(/^:/, '').trim();
|
|
375
|
+
return known.phrase(detail);
|
|
376
|
+
};
|
|
377
|
+
//# sourceMappingURL=refusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/tools/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoB5D,yFAAyF;AACzF,MAAM,UAAU,GAA2B;IACzC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,EACvC,sEAAsE;IACxE,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,EACrC,0DAA0D;IAC5D,CAAC,kBAAkB,CAAC,cAAc,CAAC,EACjC,2EAA2E;IAC7E,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAC/B,0EAA0E;CAC7E,CAAA;AAED,gGAAgG;AAChG,MAAM,KAAK,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,KA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AG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;SAC9E,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAE3B,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ConnectHarness, ConnectLlm, ConnectTarget } from '@owlmeans/viable-common';
|
|
3
|
+
import type { ConnectorApi, LocalExecutor, SessionRuntime } from '../types.js';
|
|
4
|
+
/** Which of the two hosts a tool is being served from. */
|
|
5
|
+
export declare enum ToolHostKind {
|
|
6
|
+
/** The npx server, on the user's machine, with a local executor. */
|
|
7
|
+
Stdio = "stdio",
|
|
8
|
+
/** The platform's own URL-configured endpoint. No machine, no executor. */
|
|
9
|
+
Http = "http"
|
|
10
|
+
}
|
|
11
|
+
export interface ToolHost {
|
|
12
|
+
kind: ToolHostKind;
|
|
13
|
+
target: ConnectTarget;
|
|
14
|
+
llm: ConnectLlm;
|
|
15
|
+
harness: ConnectHarness;
|
|
16
|
+
/** Whether this host can execute anything on a disk. False for the URL-configured one. */
|
|
17
|
+
hasExecutor: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolDeps {
|
|
20
|
+
api: ConnectorApi;
|
|
21
|
+
host: ToolHost;
|
|
22
|
+
/** Opened lazily, by the first tool that needs one. */
|
|
23
|
+
session: () => Promise<SessionRuntime>;
|
|
24
|
+
/** The current session, if one has been opened. Never opens one. */
|
|
25
|
+
currentSession: () => SessionRuntime | null;
|
|
26
|
+
executor?: LocalExecutor;
|
|
27
|
+
/** The directory a local target lives in. */
|
|
28
|
+
dir?: string;
|
|
29
|
+
/** What project the connector is currently working on, and how it is remembered. */
|
|
30
|
+
attached: () => string | null;
|
|
31
|
+
attach: (projectId: string) => void;
|
|
32
|
+
log: (line: string) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface ToolResult {
|
|
35
|
+
text: string;
|
|
36
|
+
structured?: object;
|
|
37
|
+
isError?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface ToolDefinition<I extends z.ZodRawShape = z.ZodRawShape> {
|
|
40
|
+
name: string;
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
input: I;
|
|
44
|
+
/**
|
|
45
|
+
* Whether this tool is offered at all.
|
|
46
|
+
*
|
|
47
|
+
* Hiding rather than failing: a tool a host cannot serve is a tool the parent agent will try
|
|
48
|
+
* once, be refused, and remember as broken. The catalogue a parent sees is exactly the set of
|
|
49
|
+
* things that work in its mode.
|
|
50
|
+
*/
|
|
51
|
+
availability: (host: ToolHost) => boolean;
|
|
52
|
+
run: (args: Record<string, unknown>, deps: ToolDeps) => Promise<ToolResult>;
|
|
53
|
+
}
|
|
54
|
+
export declare const anyHost: () => boolean;
|
|
55
|
+
export declare const localTarget: (host: ToolHost) => boolean;
|
|
56
|
+
export declare const cloudTarget: (host: ToolHost) => boolean;
|
|
57
|
+
export declare const withExecutor: (host: ToolHost) => boolean;
|
|
58
|
+
export declare const delegatedLlm: (host: ToolHost) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether this host can hold a connector SESSION across calls.
|
|
61
|
+
*
|
|
62
|
+
* A session is a connector ATTACHED: a process that stays, drains the project's operations and
|
|
63
|
+
* keeps the model tasks handed to it until the parent agent answers them. The stdio server is
|
|
64
|
+
* exactly that. The URL-configured host answers one request and forgets — opening a session there
|
|
65
|
+
* would claim the project's single connector slot, supersede the connector legitimately holding
|
|
66
|
+
* it, and be abandoned before the first operation was delivered.
|
|
67
|
+
*/
|
|
68
|
+
export declare const sessionCapable: (host: ToolHost) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether the platform's own STORY and FREE-FLIGHT calls are this session's to perform.
|
|
71
|
+
*
|
|
72
|
+
* That is the delegated mode and nothing else, and it needs two things at once — the account
|
|
73
|
+
* setting, and a connector able to drain the tasks it produces. A host that cannot hold a session
|
|
74
|
+
* can never do the draining, whatever the account setting says.
|
|
75
|
+
*
|
|
76
|
+
* It decides WORDING, never a tool list. A conversion hands its model calls to the parent by
|
|
77
|
+
* default on any connector that can hold a session, whatever the account setting says, so
|
|
78
|
+
* `next_task` / `submit_task_result` are offered on {@link sessionCapable} instead — gated here
|
|
79
|
+
* they would leave an ordinary session with a conversion blocked on a task it has no tool to
|
|
80
|
+
* collect.
|
|
81
|
+
*/
|
|
82
|
+
export declare const performsModelTasks: (host: ToolHost) => boolean;
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE9E,0DAA0D;AAC1D,oBAAY,YAAY;IACtB,oEAAoE;IACpE,KAAK,UAAU;IACf,2EAA2E;IAC3E,IAAI,SAAS;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAA;IAClB,MAAM,EAAE,aAAa,CAAA;IACrB,GAAG,EAAE,UAAU,CAAA;IACf,OAAO,EAAE,cAAc,CAAA;IACvB,0FAA0F;IAC1F,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,YAAY,CAAA;IACjB,IAAI,EAAE,QAAQ,CAAA;IACd,uDAAuD;IACvD,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAA;IACtC,oEAAoE;IACpE,cAAc,EAAE,MAAM,cAAc,GAAG,IAAI,CAAA;IAC3C,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,6CAA6C;IA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@
|
|
|
1
|
+
/** Which of the two hosts a tool is being served from. */
|
|
2
|
+
export var ToolHostKind;
|
|
3
|
+
(function (ToolHostKind) {
|
|
4
|
+
/** The npx server, on the user's machine, with a local executor. */
|
|
5
|
+
ToolHostKind["Stdio"] = "stdio";
|
|
6
|
+
/** The platform's own URL-configured endpoint. No machine, no executor. */
|
|
7
|
+
ToolHostKind["Http"] = "http";
|
|
8
|
+
})(ToolHostKind || (ToolHostKind = {}));
|
|
9
|
+
export const anyHost = () => true;
|
|
10
|
+
export const localTarget = (host) => host.target === 'local';
|
|
11
|
+
export const cloudTarget = (host) => host.target === 'cloud';
|
|
12
|
+
export const withExecutor = (host) => host.hasExecutor;
|
|
13
|
+
export const delegatedLlm = (host) => host.llm === 'local';
|
|
14
|
+
/**
|
|
15
|
+
* Whether this host can hold a connector SESSION across calls.
|
|
16
|
+
*
|
|
17
|
+
* A session is a connector ATTACHED: a process that stays, drains the project's operations and
|
|
18
|
+
* keeps the model tasks handed to it until the parent agent answers them. The stdio server is
|
|
19
|
+
* exactly that. The URL-configured host answers one request and forgets — opening a session there
|
|
20
|
+
* would claim the project's single connector slot, supersede the connector legitimately holding
|
|
21
|
+
* it, and be abandoned before the first operation was delivered.
|
|
22
|
+
*/
|
|
23
|
+
export const sessionCapable = (host) => host.kind === ToolHostKind.Stdio;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the platform's own STORY and FREE-FLIGHT calls are this session's to perform.
|
|
26
|
+
*
|
|
27
|
+
* That is the delegated mode and nothing else, and it needs two things at once — the account
|
|
28
|
+
* setting, and a connector able to drain the tasks it produces. A host that cannot hold a session
|
|
29
|
+
* can never do the draining, whatever the account setting says.
|
|
30
|
+
*
|
|
31
|
+
* It decides WORDING, never a tool list. A conversion hands its model calls to the parent by
|
|
32
|
+
* default on any connector that can hold a session, whatever the account setting says, so
|
|
33
|
+
* `next_task` / `submit_task_result` are offered on {@link sessionCapable} instead — gated here
|
|
34
|
+
* they would leave an ordinary session with a conversion blocked on a task it has no tool to
|
|
35
|
+
* collect.
|
|
36
|
+
*/
|
|
37
|
+
export const performsModelTasks = (host) => delegatedLlm(host) && sessionCapable(host);
|
|
38
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAIA,0DAA0D;AAC1D,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,oEAAoE;IACpE,+BAAe,CAAA;IACf,2EAA2E;IAC3E,6BAAa,CAAA;AACf,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAiDD,MAAM,CAAC,MAAM,OAAO,GAAG,GAAY,EAAE,CAAC,IAAI,CAAA;AAC1C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAA;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,OAAO,CAAA;AAC/E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,WAAW,CAAA;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,OAAO,CAAA;AAE7E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,KAAK,CAAA;AAE3F;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAc,EAAW,EAAE,CAC5D,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAA"}
|