@owlmeans/viable-sdk 0.1.18-rc.3 → 0.1.18-rc.30
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 +2 -28
- package/agent-meta/manifest.json +16 -0
- package/agent-meta/skills/viable-sdk/SKILL.md +518 -0
- package/build/api/remote.d.ts +7 -3
- package/build/api/remote.d.ts.map +1 -1
- package/build/api/remote.js +18 -29
- package/build/api/remote.js.map +1 -1
- package/build/consts.d.ts +22 -9
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +26 -9
- package/build/consts.js.map +1 -1
- package/build/context/index.d.ts +10 -1
- package/build/context/index.d.ts.map +1 -1
- package/build/context/index.js +70 -24
- package/build/context/index.js.map +1 -1
- package/build/executor/shell.d.ts.map +1 -1
- package/build/executor/shell.js +17 -5
- package/build/executor/shell.js.map +1 -1
- package/build/harness/templates.d.ts +2 -2
- package/build/harness/templates.d.ts.map +1 -1
- package/build/harness/templates.js +39 -20
- package/build/harness/templates.js.map +1 -1
- package/build/project/setup.d.ts +1 -1
- package/build/task/envelope.d.ts.map +1 -1
- package/build/task/envelope.js +5 -1
- package/build/task/envelope.js.map +1 -1
- package/build/tools/catalogue.d.ts +2 -2
- package/build/tools/catalogue.d.ts.map +1 -1
- package/build/tools/catalogue.js +227 -161
- package/build/tools/catalogue.js.map +1 -1
- package/build/tools/index.d.ts +3 -1
- package/build/tools/index.d.ts.map +1 -1
- package/build/tools/index.js +3 -1
- package/build/tools/index.js.map +1 -1
- package/build/tools/mcp.d.ts +2 -10
- package/build/tools/mcp.d.ts.map +1 -1
- package/build/tools/mcp.js +41 -34
- package/build/tools/mcp.js.map +1 -1
- package/build/tools/platform.d.ts +27 -8
- package/build/tools/platform.d.ts.map +1 -1
- package/build/tools/platform.js +125 -43
- package/build/tools/platform.js.map +1 -1
- package/build/tools/refusal.d.ts +2 -2
- package/build/tools/refusal.d.ts.map +1 -1
- package/build/tools/refusal.js +92 -5
- package/build/tools/refusal.js.map +1 -1
- package/build/tools/settings.d.ts +45 -0
- package/build/tools/settings.d.ts.map +1 -0
- package/build/tools/settings.js +86 -0
- package/build/tools/settings.js.map +1 -0
- package/build/tools/status.d.ts +17 -0
- package/build/tools/status.d.ts.map +1 -0
- package/build/tools/status.js +104 -0
- package/build/tools/status.js.map +1 -0
- package/build/tools/stories.d.ts +57 -0
- package/build/tools/stories.d.ts.map +1 -0
- package/build/tools/stories.js +102 -0
- package/build/tools/stories.js.map +1 -0
- package/build/tools/types.d.ts +8 -0
- package/build/tools/types.d.ts.map +1 -1
- package/build/tools/types.js.map +1 -1
- package/build/types.d.ts +43 -30
- package/build/types.d.ts.map +1 -1
- package/package.json +20 -17
- package/build/tools/jobs.d.ts +0 -12
- package/build/tools/jobs.d.ts.map +0 -1
- package/build/tools/jobs.js +0 -60
- package/build/tools/jobs.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,9 +12,7 @@ needs and the platform cannot supply:
|
|
|
12
12
|
both over HTTP and in-process;
|
|
13
13
|
- **a session runtime** that answers the operations the platform sends: file writes, shell
|
|
14
14
|
commands and git against a project on the user's own machine;
|
|
15
|
-
- **the tool catalogue and the model-task protocol** a parent agent reads
|
|
16
|
-
questions the platform puts to a person, and the tools for converting an application that
|
|
17
|
-
already exists.
|
|
15
|
+
- **the tool catalogue and the model-task protocol** a parent agent reads.
|
|
18
16
|
|
|
19
17
|
## The two axes
|
|
20
18
|
|
|
@@ -74,35 +72,11 @@ throughput problem, it is a corrupted tree.
|
|
|
74
72
|
outstanding, including what it had already answered when the connection dropped. Re-running a build
|
|
75
73
|
because an acknowledgement was lost is exactly the cost that cache avoids.
|
|
76
74
|
|
|
77
|
-
**A question is the user's, and the connector answers none of it.** An inquiry arrives on the
|
|
78
|
-
same operation loop as everything else and is executed by nobody: `next_question` hands it to the
|
|
79
|
-
parent to put to a person, and `answer_question` sends the answer back. The two queues stay
|
|
80
|
-
separate from the task queue, because draining one list would sooner or later hand a decision
|
|
81
|
-
about somebody's project to a subagent. Declining is an answer — a parent whose user is away says
|
|
82
|
-
so rather than waiting out the deadline or inventing one.
|
|
83
|
-
|
|
84
|
-
**A model task is handed over once.** The platform redelivers every unanswered operation on each
|
|
85
|
-
poll, which is free for a slot command the result cache answers and expensive for a task a
|
|
86
|
-
subagent is already working on. The shared queue remembers every id it has handed over and ignores
|
|
87
|
-
a second delivery of one, while still refreshing the operation the answer must route to.
|
|
88
|
-
|
|
89
75
|
**A malformed model-task answer is refused locally.** `parseTaskResult` checks the answer against
|
|
90
76
|
the task before the platform ever sees it — with the subagent's context still open, so the parent
|
|
91
77
|
can retry immediately. A malformed answer that reached the platform would cost a whole new task, a
|
|
92
78
|
new subagent and another wait.
|
|
93
79
|
|
|
94
|
-
**A refusal is phrased from its marker.** The platform's refusal classes live in packages this one
|
|
95
|
-
does not depend on, so an error crossing the wire arrives as a marshalled `type|||marker|||stack`
|
|
96
|
-
wrapped in a local stack trace. `REFUSALS` maps the marker to one sentence a parent agent can act
|
|
97
|
-
on; an unknown marker keeps the marker and names the tool to call next, and no stack ever reaches
|
|
98
|
-
the model — including the one shape with no separator in it, where `ResilientError.ensure` swaps a
|
|
99
|
-
plain-text response body into `type` and its stack into `message`.
|
|
100
|
-
|
|
101
|
-
**A refusal reads the same wherever it is rendered.** The same marker arrives thrown from a call
|
|
102
|
-
and stored as text — `job.error`, `slot.lastError`, a conversion's `lastError`, a pipeline row's
|
|
103
|
-
`error` — so every one of those goes through `refusalPhrase` too. Anything that is not a refusal,
|
|
104
|
-
a build warning above all, is rendered exactly as it stands.
|
|
105
|
-
|
|
106
80
|
**The harness installer never writes the token.** Each configuration references the environment
|
|
107
81
|
variable in its own syntax, so what it writes is safe to commit. `tests/harness.spec.ts` greps
|
|
108
82
|
every written file for a token shape.
|
|
@@ -119,7 +93,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
119
93
|
your project's skill store (`.agents/skills/`):
|
|
120
94
|
|
|
121
95
|
```sh
|
|
122
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
96
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.36
|
|
123
97
|
```
|
|
124
98
|
|
|
125
99
|
The embedded files are version-matched to this package release. Do not edit them
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 2,
|
|
3
|
+
"package": "@owlmeans/viable-sdk",
|
|
4
|
+
"version": "0.1.18-rc.30",
|
|
5
|
+
"generatedAt": "2026-09-22T22:22:19.435Z",
|
|
6
|
+
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
|
+
"entries": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "skill",
|
|
10
|
+
"name": "viable-sdk",
|
|
11
|
+
"category": "package-specific",
|
|
12
|
+
"file": "skills/viable-sdk/SKILL.md",
|
|
13
|
+
"canonicalPath": ".agents/skills/viable-sdk/SKILL.md"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: viable-sdk
|
|
3
|
+
description: How to use @owlmeans/viable-sdk — the connector SDK an external coding agent drives the OwlMeans Viable platform with — the token-authenticated client context, the two host kinds and their tool catalogue, the session operation loop, the local slot executor and local run, the model-task envelope, and the harness installer. Auto-invoked when building or changing a connector, an MCP host, a connector tool, the task envelope, or anything that executes platform slot commands on a developer's machine.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
7
|
+
|
|
8
|
+
# @owlmeans/viable-sdk
|
|
9
|
+
|
|
10
|
+
**Layer:** Tooling (Node/Bun; not a browser or React package)
|
|
11
|
+
**Install:** `"@owlmeans/viable-sdk": "^0.1.18-rc.30"` in `dependencies`
|
|
12
|
+
**Subpaths:** `.` · `./executor` · `./run` · `./tools` · `./task` · `./harness`
|
|
13
|
+
**Contracts:** `@owlmeans/viable-common` (`./connect`, `./slot`, `./integrity`, and the planning
|
|
14
|
+
vocabulary — story type and story flow) and `@owlmeans/planning` (the planning protocol tree
|
|
15
|
+
and facade) — every name on the wire is declared there, so the SDK and the platform cannot spell one
|
|
16
|
+
differently.
|
|
17
|
+
|
|
18
|
+
Everything a coding agent needs in order to drive the platform: authenticate with one access token,
|
|
19
|
+
attach a session to a project, execute the platform's slot commands against a directory on this
|
|
20
|
+
machine, deliver its model calls to the parent agent, and run the generated application locally.
|
|
21
|
+
`@owlmeans/viable-mcp` is one host built on it.
|
|
22
|
+
|
|
23
|
+
## Key Exports
|
|
24
|
+
|
|
25
|
+
| Export | Description |
|
|
26
|
+
|--------|-------------|
|
|
27
|
+
| `makeSdkContext({ apiUrl, token, service?, onRejected? })` | A client context authenticated by one token — a literal or a thunk — with the connector protocols and the planning tree bound and the planning client registered |
|
|
28
|
+
| `makeRemoteConnectorApi(context)` | `ConnectorApi` over HTTP; its `planning` is the context's planning client facade |
|
|
29
|
+
| `openSession(opts)` → `SessionRuntime` | One attached session: the operation loop, the task queue, `stats` |
|
|
30
|
+
| `renderTaskEnvelope(task, { harness })` · `parseTaskResult(task, raw)` | What the parent agent is told; what its answer is checked against |
|
|
31
|
+
| `makeModelTaskDriver({ models })` · `TaskDriver` | A reference parent agent backed by a chat model (tests, CLIs) |
|
|
32
|
+
| `installHarness(dir, harness, opts?)` · `describeHarness(harness)` · `WORKING_RULE` | Set a coding agent up; preview it first |
|
|
33
|
+
| `catalogue` · `visibleTools(host)` · `toolByName` · `registerCatalogue(server, deps)` · `serverInstructions({ host })` | The tools and how they reach an MCP server |
|
|
34
|
+
| `renderProjectStatus`, `renderStoryStatus(status, { landing? })`, `renderPipelineStatus`, `conversionNext` | Domain status as concise lines ending in the next valid action |
|
|
35
|
+
| `resolveStory(deps, projectId, ref)` · `storyQuery(projectId, filter?)` · `renderStories(items, page, total)` · `STORY_ORDER` · `isLandingStory(card)` · `LANDING_MARK` · `LANDING_NOTE` | The story tools' reading of planning cards |
|
|
36
|
+
| `PROJECT_SETTINGS` · `projectSettingOf(key)` · `settingsPatch(args)` · `renderProjectSettings(projectId, settings)` · `settingsReach(target)` | The project-settings tools: each setting's label and rule, the patch a call asks for, the rendering |
|
|
37
|
+
| `PLATFORM_CATALOGUE` (`pipelines`, `features`, `capabilities`) · `renderPlatform(catalogue, host)` · `GENERATED_SUMMARY` | What `describe_platform` renders, and the one-sentence product summary `describe_capabilities` ends with |
|
|
38
|
+
| `ToolHostKind` (`Stdio`/`Http`) · `ToolHost` · `ToolDeps` · `anyHost`/`localTarget`/`cloudTarget`/`withExecutor`/`delegatedLlm`/`sessionCapable`/`performsModelTasks` | The host description and the availability predicates |
|
|
39
|
+
| `./executor`: `makeLocalSlotExecutor(dir, opts?)`, `createLocalFileHelper`, `createLocalShellHelper`, `dispatchGitCommand`, `verifyTarget`/`forgetIntegrity`, `targetPaths`/`apiPath`/`webPath`/`workerPath`, `backendEnv`/`frontendEnv`, `classifyTargetHealth`/`readTargetHealth`, `runBootCheck`, `confineToProject`, the spawn helpers | The publisher's workload, on somebody's laptop |
|
|
40
|
+
| `./run`: `runLocal`, `stopLocal`, `localStatus`, `createLocalServer`, `startApi`/`startWorker`/`restartApi`/`stopProcess`, `readRun`/`writeRun`/`clearRun` | Building and running the generated app locally |
|
|
41
|
+
| `readMarker`/`writeMarker`/`discoverProject`/`isViableTree` · `readEnv`/`writeEnv`/`envStatus`/`replaceManagedBlock` | The `.viable/connect.json` marker and the managed `.env` block |
|
|
42
|
+
| `SdkError`, `SdkAuthError`, `SdkMisconfigured`, `SdkUnsupported` | Registered `ResilientError` classes |
|
|
43
|
+
| `ENV_TOKEN`, `ENV_API_URL`, `ENV_MCP_URL`, `ENV_TARGET`, `ENV_LLM`, `ENV_HARNESS`, `ENV_PROJECT_DIR` · `DEFAULT_MCP_URL` · `resolveMcpUrl(values)` · `TOOL_DEADLINE_MS` (45 s) · `COMMIT_WAIT_MS` (20 s) · `COMMIT_POLL_SEC` · `STORY_PAGE_SIZE` · `NEXT_TASK_WAIT_MS` · `PULL_WAIT_MS` | Configuration and deadlines |
|
|
44
|
+
|
|
45
|
+
## One credential, and the routes the server declares
|
|
46
|
+
|
|
47
|
+
`makeSdkContext` registers `makeTokenCarrierGuard` under `DEFAULT_GUARD` and binds the SAME
|
|
48
|
+
immutable `connectProtocols(...)` tree the server mounts, so a path or a schema cannot be right on
|
|
49
|
+
one end and wrong on the other. The planning tree is bound the same way:
|
|
50
|
+
`makePlanningProtocols({ base: { alias: 'viable:manager-api:planning', path: '/planning' }, guards:
|
|
51
|
+
DEFAULT_GUARD, socketBase: <the /update base> })` — manager-api's mount minus its ownership gate, which
|
|
52
|
+
is the server's to apply — followed by `appendPlanningClient(context, { protocols, bind: false, poll:
|
|
53
|
+
COMMIT_POLL_SEC, timeout: TOOL_DEADLINE_MS, schemas: false })`. The base alias and path are literals
|
|
54
|
+
beside the `/update` base for the same reason that one is: they belong to manager-api, and every
|
|
55
|
+
planning alias and path derives from them. No socket opener is passed, so a commit is awaited by long
|
|
56
|
+
poll only, and the schema bundle is not fetched at startup — nothing a tool does reads a flow, and a
|
|
57
|
+
server nobody has asked anything yet makes no call. There is deliberately **no second credential path**: a connector that could
|
|
58
|
+
fall back to another form of authentication is a connector whose access nobody can revoke by
|
|
59
|
+
revoking a token. A literal token that is empty or lacks `CONNECT_TOKEN_PREFIX` is refused locally
|
|
60
|
+
(`SdkMisconfigured` / `SdkAuthError`), because a 401 says nothing about which of several plausible
|
|
61
|
+
mistakes was made and the answer is always the same one.
|
|
62
|
+
|
|
63
|
+
**`token` may be a thunk** (`() => string | Promise<string>`), resolved on every request — what a
|
|
64
|
+
credential holder (`@owlmeans/cli-auth`) hands over, since it is `''` until a browser sign-in
|
|
65
|
+
completes and a real token after, with no reconfiguration. Only a literal is validated eagerly; a
|
|
66
|
+
thunk's value is unknown at construction, and an empty one is simply "not signed in". `onRejected`
|
|
67
|
+
is passed to the carrier guard and fires when the platform 401s the presented token, which is where
|
|
68
|
+
the holder forgets a dead file token (or reports a dead environment one) — see [[auth-token]].
|
|
69
|
+
|
|
70
|
+
**The `/mcp` URL is a value the SDK resolves, never one it derives:** `resolveMcpUrl(values)` returns
|
|
71
|
+
`values[ENV_MCP_URL]` (`VIABLE_MCP_URL`, empty = unset) else `DEFAULT_MCP_URL`
|
|
72
|
+
(`https://api.owlmeans.com/mcp`), trailing slash dropped so a resource URI has one spelling. The
|
|
73
|
+
caller passes the already merged environment + `~/.owlmeans` values (environment wins). A deployment's
|
|
74
|
+
own resource identifier stays host-derived on the server.
|
|
75
|
+
|
|
76
|
+
**The context must also declare the platform's `/update` base itself.** The connector's socket route
|
|
77
|
+
and the planning commit feed hang under that namespace, and a parent an entrypoint registry cannot resolve fails the **whole
|
|
78
|
+
context at init** rather than the one call that would have used it — a server that exited at startup
|
|
79
|
+
with `Entrypoint viable:manager-api:update:base not found`. It is declared with the path the
|
|
80
|
+
platform declares and never binds: it is a namespace, and nothing calls it.
|
|
81
|
+
|
|
82
|
+
**`cfg.webService` names the API CLIENT, never the backend.** It is the alias the entrypoint handler
|
|
83
|
+
looks up with `context.service(...)`, and the only thing registered under it is the `ApiClient` that
|
|
84
|
+
`makeClientContext` appends (`web-client`). Naming the backend service there — which is exactly what
|
|
85
|
+
`addWebService` does — makes every call fail with `Service <backend> not found` before a request is
|
|
86
|
+
sent. The backend belongs in `cfg.services` as an ordinary descriptor marked `default: true`; the
|
|
87
|
+
connect routes name no service of their own, so that is the one they resolve to.
|
|
88
|
+
|
|
89
|
+
**A POST with nothing to say still sends `{}`.** The client sets no `Content-Type` for an absent
|
|
90
|
+
body, and Fastify answers **415 Unsupported Media Type** before the handler runs — an error about
|
|
91
|
+
media types for a call whose only fault was having no arguments. `makeRemoteConnectorApi` fills an
|
|
92
|
+
empty body for any POST route that was given none; `session.close` and `session.heartbeat` are
|
|
93
|
+
exactly that shape.
|
|
94
|
+
|
|
95
|
+
## Two hosts, one interface
|
|
96
|
+
|
|
97
|
+
`ConnectorApi` is an interface because two implementations must stay interchangeable — one calling
|
|
98
|
+
the API over HTTP (`makeRemoteConnectorApi`, the npx server) and one calling the manager's own
|
|
99
|
+
handlers in process (`makeInProcessConnectorApi` in `viable-manager-api`, behind `POST /mcp`). Every
|
|
100
|
+
tool is written against it, so a tool cannot accidentally work in only one of the two. Which route
|
|
101
|
+
`openSession` calls fixes the mode: the delegated route carries the entitlement gate, so a caller
|
|
102
|
+
without the capability is refused at the boundary rather than by a check somewhere inside.
|
|
103
|
+
|
|
104
|
+
## A SESSION belongs to a host that stays; `sessionCapable` is what says so
|
|
105
|
+
|
|
106
|
+
A session is a connector ATTACHED — a process that drains the project's operations and holds a model
|
|
107
|
+
task until its answer comes back. The URL-configured host answers one request and forgets, so
|
|
108
|
+
opening one there would claim the project's single connector slot, **supersede the stdio connector
|
|
109
|
+
legitimately holding it**, and be abandoned before the first operation was delivered.
|
|
110
|
+
|
|
111
|
+
So `ensureSession` — what `confirm_project`, `reinitialize_project`, `develop_story`,
|
|
112
|
+
`modify_project` and `resume_pipeline` call before returning their job — opens one only on a
|
|
113
|
+
`sessionCapable` host, and `next_task`/`submit_task_result` are available on `performsModelTasks`
|
|
114
|
+
(delegated **and** session-capable) rather than on the account setting alone. `serverInstructions`
|
|
115
|
+
reads the same predicate: a parent told to call `next_task` when the tool is not in its list is a
|
|
116
|
+
parent that waits for a run nobody will advance. A host that cannot serve the delegated mode says so
|
|
117
|
+
in one sentence instead, naming the stdio connector.
|
|
118
|
+
|
|
119
|
+
The in-process implementation refuses the five session verbs (`openSession`, `closeSession`,
|
|
120
|
+
`heartbeat`, `pullOps`, `submitOp`) with a message naming `@owlmeans/viable-mcp`, because
|
|
121
|
+
"unsupported" alone leaves the reader with nothing to do about it.
|
|
122
|
+
|
|
123
|
+
## A tool that cannot work in a mode is HIDDEN, not failing
|
|
124
|
+
|
|
125
|
+
`ToolDefinition.availability` and `visibleTools(host)` decide the catalogue a parent actually sees. A
|
|
126
|
+
tool a host cannot serve is a tool the parent tries once, is refused, and remembers as broken — so
|
|
127
|
+
the list it reads is exactly the set of things that work for it. Predicates: `anyHost`,
|
|
128
|
+
`localTarget`, `cloudTarget`, `withExecutor`, `delegatedLlm`.
|
|
129
|
+
|
|
130
|
+
## 45 seconds is the ceiling, so long operations return domain status
|
|
131
|
+
|
|
132
|
+
Every MCP host bounds a tool call and the strictest default in the field is sixty seconds (Codex).
|
|
133
|
+
`TOOL_DEADLINE_MS` leaves room for the round trip and keeps the connector inside every host's
|
|
134
|
+
ceiling without configuration. A tool that outlives its host's ceiling is reported to the user as a
|
|
135
|
+
**broken server**, and the true answer — the platform was slow — never reaches them.
|
|
136
|
+
|
|
137
|
+
Anything that takes minutes returns the owning domain's status and continues server-side.
|
|
138
|
+
`project_status`, `story_status`, `conversion_status` and `pipeline_status` compose the durable
|
|
139
|
+
records and run state a parent needs. `registerCatalogue` enforces the deadline per call and
|
|
140
|
+
converts a throw into an `isError` result the model can read and act on, because an exception
|
|
141
|
+
crossing the transport tells it only that something went wrong somewhere. Each status renderer
|
|
142
|
+
ends with a single `next:` line so the parent follows the domain workflow and does not invent a
|
|
143
|
+
polling strategy or treat a parked run as failed.
|
|
144
|
+
|
|
145
|
+
## The story tools speak planning
|
|
146
|
+
|
|
147
|
+
A user story is a planning CARD of `VIABLE_STORY_TYPE` under its project card, and every change to one
|
|
148
|
+
is a transition executed through `ConnectorApi.planning` — a `PlanningFacade`: the client facade
|
|
149
|
+
`appendPlanningClient` registers over HTTP, and `ensurePlanningService(ctx).for(scope)` in the
|
|
150
|
+
platform's in-process host. The scope a call answers for is the CREDENTIAL's; a tool sends none.
|
|
151
|
+
|
|
152
|
+
| Tool | Facade call |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `list_stories` | `cards.list({ ...storyQuery(project, { status, area }), page, size, sort: STORY_ORDER })` → `renderStories` |
|
|
155
|
+
| `search_stories` | the same with `{ q }` |
|
|
156
|
+
| `create_story` | `execute({ action: create, card: { kind: card, type: VIABLE_STORY_TYPE, parent, title, fields: { primary: false } } }, { wait: true, timeout: COMMIT_WAIT_MS })` |
|
|
157
|
+
| `update_story` | `resolveStory` → `execute({ card, action: update, changes: { title }, expectSeq: head ?? seq }, { wait: true, … })` |
|
|
158
|
+
| `delete_story` | `resolveStory` → `execute({ card, action: delete }, { wait: true, … })` → the project-lock poll |
|
|
159
|
+
| `develop_story` | `resolveStory` → `execute({ card, action: transit, transition: start }, { wait: true, … })`, tolerating `CommitTimeout` → `story.status(project, card.id)` |
|
|
160
|
+
| `story_status` | `resolveStory` → the card, its development run, pending inquiry, warning and landing mark |
|
|
161
|
+
|
|
162
|
+
Rules the table rests on:
|
|
163
|
+
|
|
164
|
+
- **A tool NAME is a parent agent's vocabulary and is never renamed**, and neither is an argument:
|
|
165
|
+
`storyId` stays `storyId` although the platform keys on card ids. New facts are added (`designSystem`
|
|
166
|
+
on `confirm_project`, the project status line and the design-system section of `project_status`),
|
|
167
|
+
never substituted.
|
|
168
|
+
- **`storyId` accepts a code or an id**, because `list_stories` prints the CODE — the handle every
|
|
169
|
+
generated file names a story by. `resolveStory` asks for both at once, the id wins, a code is also
|
|
170
|
+
tried uppercased, and neither answers for a story of another project (`ProjectStoryNotFound`).
|
|
171
|
+
- **Development is the story's `start`, not a call of its own.** The platform begins the run once that
|
|
172
|
+
move COMMITS, and refuses it there too (the flow, one story in progress, the balance). The wait is
|
|
173
|
+
`COMMIT_WAIT_MS`, well inside the tool deadline; a late commit is not a failure — the transition is
|
|
174
|
+
durable — so `develop_story` answers from `story_status` rather than outliving the host's ceiling.
|
|
175
|
+
- **A story a person writes goes as written, with no area.** Re-formatting the narrative and deciding
|
|
176
|
+
the area are the platform's, done in its planning middleware for the `connect` channel; a connector
|
|
177
|
+
that guessed an area would be a second answer. `update_story` carries only `title` and the head it
|
|
178
|
+
read, so a change made in between is refused (`WorkcardConflict`) rather than overwritten.
|
|
179
|
+
- **The delete commit is no proof the slot is done.** It says the card is gone and nothing about the
|
|
180
|
+
placeholder screens still being retired under the project lock, so `delete_story` keeps its two
|
|
181
|
+
unlocked observations.
|
|
182
|
+
- **Stories are read in `order`, then `createdAt`**: `order` is the analysis's flow ordinal (a
|
|
183
|
+
connective story sits at a fraction between two steps). `renderStories` keeps the line shape a parent
|
|
184
|
+
already reads — `code · status[ · primary][ · landing gate][ · area]` over the narrative — under a
|
|
185
|
+
header counting the page by intrinsic state. A new fact is a new FLAG beside `primary`; the area
|
|
186
|
+
stays last.
|
|
187
|
+
- **The landing gate story is read off the card the tool already holds** (`fields.landing`, at most
|
|
188
|
+
one per project, decided by the platform at initialization — a connector never sets it). The list
|
|
189
|
+
flags it; `story_status` and `develop_story` pass the resolved card to `renderStoryStatus`, which
|
|
190
|
+
adds `LANDING_NOTE` under the status line, and their structured result gains `landing: true`. No
|
|
191
|
+
second call and no change to `connect.story.status`: that route carries the run, not the card's
|
|
192
|
+
fields. It is said because developing that story also replaces the guest-home sketch with the real
|
|
193
|
+
component, which the narrative alone never tells a parent.
|
|
194
|
+
- **A planning refusal is phrased like any other**: `planning:illegal-transition:`,
|
|
195
|
+
`workcard-conflict:`, `workcard-not-found:`, `fields-invalid:`, `commit-timeout:`, `commit-failed:`
|
|
196
|
+
and the story markers (`viable-project:story:not-found:` / `:missconfigured:`) each have a sentence in
|
|
197
|
+
`REFUSALS`.
|
|
198
|
+
|
|
199
|
+
- **A sign-in refusal is phrased**: `oauth:sign-in-required:` (detail `<url> <code>`, the code absent
|
|
200
|
+
while no device sign-in is pending), `oauth:token-rejected:` (an environment token that was refused
|
|
201
|
+
is never replaced) and `api:auth:guard:auth-token` (a file token the platform refused — forgotten,
|
|
202
|
+
the next call signs in). Each ends with "call this tool again".
|
|
203
|
+
|
|
204
|
+
## The project settings are ONE record, and the platform is the only validator
|
|
205
|
+
|
|
206
|
+
`project_settings` and `update_project_settings` read and change what a person edits on the project's
|
|
207
|
+
control panel — the copyright line, the organization name, the Terms and Privacy links and the Google
|
|
208
|
+
tag — through `ConnectorApi.projectBranding(projectId)` and
|
|
209
|
+
`saveProjectBranding(projectId, patch)` (`connect.project.branding.get` / `.save`,
|
|
210
|
+
`ConnectProjectBranding` / `ConnectProjectBrandingSave` from `@owlmeans/viable-common`).
|
|
211
|
+
|
|
212
|
+
- **A save is a PATCH.** `settingsPatch` keeps exactly the settings the call named, trimmed; an
|
|
213
|
+
omitted one keeps its stored value, and an EMPTY string is sent as given — for the Google tag that
|
|
214
|
+
is the removal, for the others a value the platform refuses. A call naming none is refused locally
|
|
215
|
+
and saves nothing. The answer is the merged record the platform stored, led by where the change
|
|
216
|
+
shows (`settingsReach`): a cloud preview is rebuilt, production takes it at the next Publish; a
|
|
217
|
+
local project gets it in its `.env` and `run_local` builds with it.
|
|
218
|
+
- **The connector states the rules and checks none of them.** `PROJECT_SETTINGS[].rule` is the web
|
|
219
|
+
save's validation in words — never-empty copyright and organization; an `https://` address without
|
|
220
|
+
credentials or a single-slash path on the application (`/terms`, `/privacy` are the generated
|
|
221
|
+
pages); a `GTM-`/`G-`/`GT-`/`AW-`/`DC-` id or `''` — used by the tool description and by the
|
|
222
|
+
refusal. A second copy of the check would be a second answer that drifts from the platform's.
|
|
223
|
+
- **A refusal names the setting and its rule.** The platform refuses a field with
|
|
224
|
+
`AuthenPayloadError(<wire field>)`; the `authen:payload:` phrase answers a known setting with its
|
|
225
|
+
label and rule and "Nothing was changed", any other field with a generic sentence. The tool runs in
|
|
226
|
+
`answering`, so the refusal is its own `isError` result and is still logged.
|
|
227
|
+
- **The save attaches the connector first** (`ensureSession`), like a story mutation: it ends in the
|
|
228
|
+
platform's configuration push, which for a local project is a `Configure` operation this connector
|
|
229
|
+
answers.
|
|
230
|
+
- **A relative link is annotated, never "fixed"**: `/terms` renders as "the generated Terms page", so
|
|
231
|
+
a parent does not rewrite it into an absolute address that points away from the generated page.
|
|
232
|
+
- **The credit switch is not reachable.** It is a paid capability with its own gated route;
|
|
233
|
+
neither the record nor the patch carries it.
|
|
234
|
+
|
|
235
|
+
## `describe_platform` also says what a generated application CARRIES
|
|
236
|
+
|
|
237
|
+
`PLATFORM_CATALOGUE.features` holds facts about the product the runs produce — the landing gate, the
|
|
238
|
+
generated Terms and Privacy pages, the consent-gated Google tag, the look, production builds without
|
|
239
|
+
preview scaffolding — rendered whole on every host under "WHAT A GENERATED APPLICATION CARRIES", with
|
|
240
|
+
only their `tools` narrowed to what the host offers. A parent that is not told the platform generates
|
|
241
|
+
the legal pages writes its own beside them. `describe_capabilities` ends with `GENERATED_SUMMARY`, the
|
|
242
|
+
same facts in one sentence, because it is read at the same moment by a parent that may never call
|
|
243
|
+
`describe_platform`; the two sit side by side in `platform.ts`. The pipelines' `stages` name the steps
|
|
244
|
+
a run can stop at (`landing` and `legal` in init, `landing` in story development).
|
|
245
|
+
|
|
246
|
+
## An out-of-credits refusal is phrased, and pushed through `notify`
|
|
247
|
+
|
|
248
|
+
`registerCatalogue`'s catch special-cases `ConnectOutOfCredits` (`@owlmeans/viable-common`
|
|
249
|
+
`connect/errors.ts`): rather than the raw `viable-connect:out-of-credits:...` marker, the tool
|
|
250
|
+
result reads as a sentence — what it needed, what the account has, and a link to top up — because
|
|
251
|
+
only `type` and `message` survive the platform's internal HTTP hop, so those three fields travel
|
|
252
|
+
packed into the message and are read back out with `finalizeUnmarshal()`. The same refusal is also
|
|
253
|
+
handed to the optional `ToolDeps.notify?(level, text)`, which a host wires to its own out-of-band
|
|
254
|
+
channel — the stdio `viable-mcp` host sends an MCP `notifications/message`; the platform's stateless
|
|
255
|
+
`/mcp` host has no channel and omits it, so `notify` is always best-effort and optional. Every other
|
|
256
|
+
error still returns as its own `.message`, unphrased, and never calls `notify`.
|
|
257
|
+
|
|
258
|
+
## The session loop: serial, and free to redeliver
|
|
259
|
+
|
|
260
|
+
`openSession` pulls operations, answers them **one at a time**, and puts model tasks aside. Serial
|
|
261
|
+
because the thing on the other end of a local operation is a filesystem the platform believes it is
|
|
262
|
+
the only writer of — two concurrent template writes into one tree is not a throughput problem, it is
|
|
263
|
+
a corrupted tree.
|
|
264
|
+
|
|
265
|
+
Results are remembered by operation id. A connector that reconnects is handed everything still
|
|
266
|
+
outstanding, **including whatever it had already answered when the connection dropped**, and the
|
|
267
|
+
cached result answers it without doing the work again — re-executing a build or a model task because
|
|
268
|
+
an acknowledgement was lost is exactly the cost this avoids. A failed `submitOp` is logged, never
|
|
269
|
+
thrown: the operation stays in the platform's store and is redelivered.
|
|
270
|
+
|
|
271
|
+
Model tasks are **not executed here at all** — they are the parent agent's to run in its own clean
|
|
272
|
+
subagent, and what the loop owes them is delivery. The operation id is kept beside each task and
|
|
273
|
+
never shown to the parent: a parent that could name one could answer an operation it was never
|
|
274
|
+
given.
|
|
275
|
+
|
|
276
|
+
A local operation that fails reports `ConnectOpErrorKind.Refused`, never `Unavailable`. The
|
|
277
|
+
connector ran and could not do the thing; `Unavailable` tells the platform to give up on a run that
|
|
278
|
+
is fine.
|
|
279
|
+
|
|
280
|
+
**The pull long-poll is the transport.** It works through every proxy and needs no reconnection
|
|
281
|
+
logic. It is also the only transport a session ever uses — the URL-configured host opens no session
|
|
282
|
+
at all, so it never pulls. The contract declares a socket
|
|
283
|
+
(`connect.session.socket`, served by manager-api) and `SessionStats.transport` can say `'socket'`,
|
|
284
|
+
but **the SDK implements only the pull loop** — `PING_INTERVAL_MS`, `SOCKET_HANDSHAKE_MS` and
|
|
285
|
+
`RECONNECT_BACKOFF_MS` are declared for a socket client that does not exist yet. Treat the socket as
|
|
286
|
+
a platform capability, not an SDK one.
|
|
287
|
+
|
|
288
|
+
## An answer is READ in the shapes models produce, not only the one asked for
|
|
289
|
+
|
|
290
|
+
The tool-call instruction asks for a JSON array and models mostly comply — but a single call comes
|
|
291
|
+
back as a bare object often enough, and some wrap the array in `{tool_calls: […]}`, that assuming
|
|
292
|
+
the array is a defect rather than strictness. The reference driver cast straight to an array, so a
|
|
293
|
+
bare object threw `parsed.map is not a function`; the TypeError was handed back AS the answer, the
|
|
294
|
+
model ladder read that as a bad answer and asked again with feedback that said nothing about what
|
|
295
|
+
was wrong, and the story failed with `retry-exceeded` having never been told. `toolCallsOf` accepts
|
|
296
|
+
all three shapes and still throws for an answer carrying no call at all — an empty answer is a bad
|
|
297
|
+
answer, and the retry is the right response to it.
|
|
298
|
+
|
|
299
|
+
The same rule is why `parseTaskResult` refuses with a described reason rather than a stack trace:
|
|
300
|
+
whatever comes back becomes a model's next prompt, so it has to be readable by one.
|
|
301
|
+
|
|
302
|
+
## A redelivered model task must NOT be handed over twice
|
|
303
|
+
|
|
304
|
+
The platform redelivers every unanswered operation on each poll — that is what makes a connector
|
|
305
|
+
restart cost a round trip instead of a run, and for a slot command it is free because the result
|
|
306
|
+
cache answers it. A MODEL task is different: it is answered by a parent agent in tens of seconds,
|
|
307
|
+
and every poll during that window used to queue another copy. The parent then ran the same task
|
|
308
|
+
over and over — real model calls, paid for by the user, thrown away — while the job stayed blocked,
|
|
309
|
+
because only the first answer routed to a live operation and every later one reported that no
|
|
310
|
+
operation was waiting.
|
|
311
|
+
|
|
312
|
+
`TaskQueue` therefore remembers every task id it has handed over and ignores a second delivery of
|
|
313
|
+
one, keeping the memory after the task settles so a redelivery that raced the platform's deletion
|
|
314
|
+
is ignored rather than answered again. The operation id IS refreshed on a redelivery, because the
|
|
315
|
+
answer must route to the operation the platform is currently waiting on. `push` returns whether the
|
|
316
|
+
task was accepted, and `tasksDelivered` counts only accepted ones — a counter that grew per poll
|
|
317
|
+
would make a stuck run look busy.
|
|
318
|
+
|
|
319
|
+
## The task envelope is text for a model to act on
|
|
320
|
+
|
|
321
|
+
The reader is a language model working from a tool result, so it must be able to act without a
|
|
322
|
+
schema in front of it. Everything it must do is stated **in order and before the material** — how to
|
|
323
|
+
run it (in a clean subagent, per harness), what to call afterwards (`submit_task_result`, with the
|
|
324
|
+
id spelled out), and what shape the answer takes — so a model that stops reading early has still
|
|
325
|
+
read the instruction. The task id appears at the top and in the follow-up call because it is the
|
|
326
|
+
only thing that routes an answer back: a parent that paraphrases the rest but copies the id still
|
|
327
|
+
works. A retry says which attempt it is and why the previous answer was refused. Harnesses differ
|
|
328
|
+
only in the isolation mechanism, never in what is asked; `Other` gets the request stated rather than
|
|
329
|
+
mechanised.
|
|
330
|
+
|
|
331
|
+
For Codex, the parent gives a fresh `viable-worker` only the task's system prompt, then its
|
|
332
|
+
conversation, then the requested result shape: the outer handoff instruction and
|
|
333
|
+
`submit_task_result` call are parent-only. It passes that final response through unchanged, but must
|
|
334
|
+
preserve the mode: a `text` task returns the requested source or text and never a JSON tool-call
|
|
335
|
+
array; that array belongs only to `tools` mode.
|
|
336
|
+
|
|
337
|
+
**`parseTaskResult` refuses a malformed answer locally**, and returns a `problem` rather than
|
|
338
|
+
throwing. The refusal is worth more than the parse: an answer that reaches the platform malformed
|
|
339
|
+
costs a whole retry — another task, another subagent, another wait — while one caught here is a
|
|
340
|
+
sentence the parent can act on immediately, with the subagent's context still open. It unfences,
|
|
341
|
+
rejects an array or a scalar in `Json` mode, and rejects a tool name the task never offered.
|
|
342
|
+
|
|
343
|
+
A task is handed out ONCE, and the platform then waits on it for up to 45 minutes. So the loop has
|
|
344
|
+
to survive a parent that lost the envelope — a compacted conversation, a subagent that died before
|
|
345
|
+
answering. `next_task` takes an optional `taskId` that re-reads a task already handed out, and when
|
|
346
|
+
nothing new is queued but something is unanswered it NAMES the outstanding ids rather than re-handing
|
|
347
|
+
them: re-handing would have a parent whose subagent is still working run the same task twice. A
|
|
348
|
+
refused answer keeps the task outstanding for exactly the same reason.
|
|
349
|
+
|
|
350
|
+
## The harness installer is idempotent by construction, and never writes the token
|
|
351
|
+
|
|
352
|
+
A section is replaced between `<!-- viable:begin -->` and `<!-- viable:end -->`, a JSON entry is
|
|
353
|
+
merged under its own key, and a file whose content would not change is skipped. An instruction file
|
|
354
|
+
belongs to its project: overwriting it to add a paragraph deletes whatever else was in it, and
|
|
355
|
+
appending unconditionally grows a duplicate on every install. That is what makes `install_harness`
|
|
356
|
+
safe to offer as a tool the agent may call whenever it is unsure. A configuration that is not valid
|
|
357
|
+
JSON is **refused** — somebody is editing it, and overwriting would destroy every other server they
|
|
358
|
+
had configured.
|
|
359
|
+
|
|
360
|
+
**No file it writes contains the token**, and none REQUIRES one: a person who signed in with a browser
|
|
361
|
+
has the token in `~/.owlmeans`, which the server reads itself. So each configuration references
|
|
362
|
+
`VIABLE_API_TOKEN` in its harness's own syntax only where that cannot break a machine that never set
|
|
363
|
+
it — claude-code's `.mcp.json` uses `${VIABLE_API_TOKEN:-}` (an unset `${VAR}` makes Claude Code refuse
|
|
364
|
+
the whole file; the server ignores the empty value), Copilot's `.vscode/mcp.json` has no token prompt
|
|
365
|
+
at all, and Codex's `env_vars` lists `VIABLE_API_TOKEN`, `OWLMEANS_CREDENTIALS` and `HOME` (its filtered
|
|
366
|
+
environment otherwise hides the credentials file). The result is safe to commit. `WORKING_RULE` is written once and rendered
|
|
367
|
+
into every harness's instruction file, so the four cannot drift into four different protocols.
|
|
368
|
+
|
|
369
|
+
**The server command is written once, too.** Every harness configuration starts the connector from
|
|
370
|
+
`MCP_COMMAND` in `src/harness/templates.ts` — viable-mcp through `npx -y`, pinned with a caret at the
|
|
371
|
+
viable-mcp release, on ONE line with its `npx` so the release pin audit reads it as an install
|
|
372
|
+
command and moves it with every viable-mcp bump. Never a tag (`@next` is refused by that audit) and
|
|
373
|
+
never a per-harness literal: three copies spelled `@next` while the fourth carried the pin.
|
|
374
|
+
`tests/harness.spec.ts` asserts all four configurations name the viable-mcp manifest's version, that no
|
|
375
|
+
file contains a `vib_…` secret, and the optional-token shapes above.
|
|
376
|
+
|
|
377
|
+
## The executor is the publisher's job, on somebody's laptop
|
|
378
|
+
|
|
379
|
+
`makeLocalSlotExecutor(dir)` answers the platform's slot commands against a directory here. The
|
|
380
|
+
dispatcher is the publisher's, switch for switch: the platform's remote helpers parse the ANSWERS
|
|
381
|
+
and cannot tell whether a pod or a laptop produced one, so an ordinary failure comes back in the
|
|
382
|
+
same shape ("error text or null"), and only an unknown command — a protocol fault rather than a
|
|
383
|
+
project fault — escapes as an exception. Everything is resolved per call rather than closed over,
|
|
384
|
+
because a re-initialization replaces the tree under a running connector. The integrity verdict is
|
|
385
|
+
forgotten after every command that changes the tree.
|
|
386
|
+
|
|
387
|
+
Five rules the local half adds, each learned from a defect:
|
|
388
|
+
|
|
389
|
+
- **`backendEnv` reads the root `.env` and `frontendEnv` the web package's own — the file split IS
|
|
390
|
+
the leak boundary.** The publisher has an allow-list (`frontendEnvVars`/`frontendSecrets`); here
|
|
391
|
+
the two files are never merged in either direction, because `FRONTEND_ENV_KEYS` announces
|
|
392
|
+
everything in the frontend set to the bundler and a merge would compile `OIDC_SECRET` and
|
|
393
|
+
`DATABASE_URL` into a bundle every visitor downloads.
|
|
394
|
+
- **`Discard` passes `git clean -fd -e .viable`.** `.viable/connect.json` is untracked until someone
|
|
395
|
+
commits it, and a discard that swept it leaves a tree no later session can recognise as a platform
|
|
396
|
+
project at all.
|
|
397
|
+
- **The always-keep list must not leave empty parent shells.** A wipe keeps `.viable`, `.env`, the
|
|
398
|
+
web package's `.env` and `.git` whatever the caller asked, so a directory holding a kept path is
|
|
399
|
+
walked and pruned rather than removed — and a keep that was not there (the web `.env` every
|
|
400
|
+
project without local branding lacks) must not leave the walked directory behind as a skeleton the
|
|
401
|
+
install then lands in.
|
|
402
|
+
- **An absolute path from elsewhere on the machine is re-rooted inside the project**, not refused —
|
|
403
|
+
the publisher's own behaviour, kept deliberately and pinned by a test. Concatenating it onto the
|
|
404
|
+
root instead builds a shadow tree: the write reports success, a later read of the same name
|
|
405
|
+
resolves to the untouched original, and the change looks silently ignored. `resolveInProject`
|
|
406
|
+
(exported as `confineToProject`) then compares the fully resolved path to the root — confinement,
|
|
407
|
+
not sanitization, and applied on **every** fs call rather than a `..`-to-`.` replace at one caller.
|
|
408
|
+
- **`run/state.ts` sits below both the shell commands and the run**, so the three do not form a
|
|
409
|
+
cycle: `DbSync` bounces the api child, `DbSync` is a shell command, and the shell commands are
|
|
410
|
+
reached through the executor the run is built on. Everything that touches a child process lives
|
|
411
|
+
there, and the run record is a file because the processes outlive the call — and, on a restarted
|
|
412
|
+
connector, the process — that started them.
|
|
413
|
+
|
|
414
|
+
## Attaching a session is what writes the project marker
|
|
415
|
+
|
|
416
|
+
`.viable/connect.json` is how a connector started in a directory tomorrow knows which project it
|
|
417
|
+
is, and `attach_project` finds a project by its directory through it. It was declared, read at MCP
|
|
418
|
+
startup and documented in `mcp.md` before anything wrote it — a marker nothing writes is a lookup
|
|
419
|
+
that always misses.
|
|
420
|
+
|
|
421
|
+
`openSession` writes it when the session names a project and a directory, which is the moment the
|
|
422
|
+
directory becomes that project's. Best-effort and idempotent: a session that works is worth more
|
|
423
|
+
than a note about it, and it is skipped when the marker already names the same project. It holds
|
|
424
|
+
no secret and is meant to be committed, which is why the API URL and the slug are in it and the
|
|
425
|
+
token never is.
|
|
426
|
+
|
|
427
|
+
## The managed block yields to every key the user assigned
|
|
428
|
+
|
|
429
|
+
A `.env` gives the LAST assignment of a key and the platform's block is appended, so a platform line
|
|
430
|
+
silently outranks whatever the user wrote above it. That made the documented promise — everything
|
|
431
|
+
outside the block is yours — false for the one value the platform cannot supply: `DATABASE_URL`, the
|
|
432
|
+
line the setup guide tells people to write. The application connected to the placeholder no matter
|
|
433
|
+
what its owner put in the file.
|
|
434
|
+
|
|
435
|
+
`writeEnv` therefore reads the file with the block cut out, and replaces any block line assigning a
|
|
436
|
+
key the user already assigns with a comment saying so. The rule is about VALUES, not lines: a key the
|
|
437
|
+
user has not claimed is still the platform's to set, and a key they later delete goes back to the
|
|
438
|
+
platform on the next push.
|
|
439
|
+
|
|
440
|
+
## The two services a local project needs are ASKED for, never assumed
|
|
441
|
+
|
|
442
|
+
The platform provisions nothing on somebody's own machine, so a database — and, for a project with a
|
|
443
|
+
worker, a queue store — is the one thing it cannot supply and must not guess. `local_setup_guide`
|
|
444
|
+
reports what the machine already provides and, where something is missing, returns a QUESTION with
|
|
445
|
+
three answers: the user already has one, wants one installed here, or wants a free hosted plan.
|
|
446
|
+
Guessing means either a container on somebody's machine they did not ask for, or a connection string
|
|
447
|
+
invented for a database that does not exist — and the second surfaces minutes later as a boot error
|
|
448
|
+
about a connection, which sends the reader looking for a database rather than for a typo.
|
|
449
|
+
|
|
450
|
+
`set_local_service` records what they answered: it writes the value into the project's own half of
|
|
451
|
+
the `.env`, replacing that key rather than appending a second copy, and PROBES it immediately, so a
|
|
452
|
+
string that does not connect is caught while the user is still in the conversation. A credential
|
|
453
|
+
never reaches the marker, a harness configuration, or the platform, and the guide warns when the
|
|
454
|
+
file is not git-ignored.
|
|
455
|
+
|
|
456
|
+
## A detached child outlives the connector, so the port is RECLAIMED before it is used
|
|
457
|
+
|
|
458
|
+
Every target process is spawned detached — that is what keeps a build from dying with the tool that
|
|
459
|
+
started it — and detaching is also why a connector killed mid-run (a host restart, a Ctrl-C, a
|
|
460
|
+
crashed test) leaves one alive. What survives holds port 3000, and the next attempt fails with the
|
|
461
|
+
TARGET's own "the api port is already in use", which reads as a defect in the generated app rather
|
|
462
|
+
than as a leftover.
|
|
463
|
+
|
|
464
|
+
Two rules, both ported from the publisher because a laptop needs them more than a pod does:
|
|
465
|
+
- `killGroupAndWait` never returns early on the child's own exit code. The child is a shell wrapping
|
|
466
|
+
`bun`, so a signal the shell dies from leaves `bun` alive while `exitCode` says gone; the wait
|
|
467
|
+
polls the GROUP instead of the child's exit event.
|
|
468
|
+
- `reclaimPort` runs before a spawn as well as after one, and matches on the script AND the process
|
|
469
|
+
marker (`--viable-api`, `--viable-worker`, `--viable-boot-check`) — never a port alone, and never
|
|
470
|
+
a marker alone, since reclaiming sends SIGKILL and a marker on its own matches any command line
|
|
471
|
+
that merely mentions it.
|
|
472
|
+
|
|
473
|
+
## Running the generated app locally
|
|
474
|
+
|
|
475
|
+
`runLocal` builds and starts the api, the worker (when the project has one) and a local server that
|
|
476
|
+
holds the web port and proxies `/api` to the api process on the same origin — the generated app's
|
|
477
|
+
configuration assumes one origin, and splitting them across two loopback ports would put its CORS
|
|
478
|
+
setup in the path of a developer's first page load. There is no respawn ladder, no reconciler and no
|
|
479
|
+
health route: a developer watching their own terminal is the supervisor. What IS reproduced is the
|
|
480
|
+
shape — the same ports, the same argv marker, the same environment, and the same "port ownership is
|
|
481
|
+
the only proof" rule about restarts. Nothing from the publisher's public-hostname policy (robots,
|
|
482
|
+
CSP, the preview error reporter, the build-state header) is reproduced: a loopback address has no
|
|
483
|
+
reputation to spend and no crawler to answer.
|
|
484
|
+
|
|
485
|
+
`run_local` refuses to start a project whose `.env` is still missing a required key, because an app
|
|
486
|
+
launched without a database URL fails at boot with a message about a connection, which sends the
|
|
487
|
+
reader looking for a database that was never configured.
|
|
488
|
+
|
|
489
|
+
## Tests
|
|
490
|
+
|
|
491
|
+
`bun test ./tests` — offline: the envelope and its parser, the harness installer, the tool catalogue,
|
|
492
|
+
the `registerCatalogue` out-of-credits and planning-refusal phrasing and `notify` wiring
|
|
493
|
+
(`mcp-catalogue.spec.ts`), the executor's files/git/layout rules, and the marker + managed-`.env`
|
|
494
|
+
block. The story tools run over a REAL `@owlmeans/server-planning` service (memory store, the Viable
|
|
495
|
+
types and flows, one plugin standing in for the platform's format seam) built in `tests/context.ts`,
|
|
496
|
+
the landing mark included; the settings tools over a recorded `ConnectorApi` (order of session and
|
|
497
|
+
save, the patch sent, the phrased `AuthenPayloadError`). `platform.spec.ts` pins that every tool a
|
|
498
|
+
pipeline, feature or group names exists and every tool is in a group; `planning-wiring.spec.ts` pins
|
|
499
|
+
the planning aliases and paths a context binds, and `remote.spec.ts` drives the remote facade and the
|
|
500
|
+
settings routes through a captured transport to pin their paths and deadlines.
|
|
501
|
+
|
|
502
|
+
## Depends On
|
|
503
|
+
|
|
504
|
+
- `@owlmeans/viable-common` — the whole wire contract · `@owlmeans/auth-token` — the carrier guard
|
|
505
|
+
- `@owlmeans/planning` — the protocol tree, the facade contract and its refusals ·
|
|
506
|
+
`@owlmeans/client-planning` — the remote facade and the long-poll commit wait
|
|
507
|
+
- `@owlmeans/api`, `@owlmeans/client-context`, `@owlmeans/client-entrypoint`, `@owlmeans/client-config`,
|
|
508
|
+
`@owlmeans/auth-common`, `@owlmeans/entrypoint`, `@owlmeans/route`, `@owlmeans/socket`,
|
|
509
|
+
`@owlmeans/config`, `@owlmeans/context`, `@owlmeans/error`, `@owlmeans/basic-ids`
|
|
510
|
+
- `@modelcontextprotocol/sdk` (types only, structurally), `zod`, `fs-extra`, `globby`, `ajv`
|
|
511
|
+
|
|
512
|
+
## Related
|
|
513
|
+
|
|
514
|
+
- [[viable-mcp]] — the npx stdio server built on this
|
|
515
|
+
- [[auth-token]] — the credential and its carrier guard
|
|
516
|
+
- [[client-planning]] · [[planning]] — the facade the story tools write through
|
|
517
|
+
- `@owlmeans/llm-delegate` (`internal` monorepo, skill `llm-delegate`) — the other end of a model
|
|
518
|
+
task, inside the platform
|
package/build/api/remote.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const isTransientTransportError: (value: unknown) => boolean;
|
|
|
7
7
|
* Recover a long poll with one non-blocking snapshot.
|
|
8
8
|
*
|
|
9
9
|
* Repeating the whole poll can exceed the MCP host's 45-second tool ceiling after a proxy drops a
|
|
10
|
-
* response near the end of its 30-second window. A snapshot asks for the same durable
|
|
10
|
+
* response near the end of its 30-second window. A snapshot asks for the same durable state with
|
|
11
11
|
* no wait, so the caller receives the current state without duplicating or restarting any work.
|
|
12
12
|
*/
|
|
13
13
|
export declare const recoverLongPoll: <T>(poll: () => Promise<T>, snapshot: () => Promise<T>) => Promise<T>;
|
|
@@ -16,8 +16,12 @@ export declare const recoverLongPoll: <T>(poll: () => Promise<T>, snapshot: () =
|
|
|
16
16
|
*
|
|
17
17
|
* Every call is bounded by the tool deadline rather than left to the transport's own default: a
|
|
18
18
|
* tool that outlives its host's ceiling is reported to the user as a broken server, and the true
|
|
19
|
-
* answer — the platform was slow — never reaches them.
|
|
20
|
-
*
|
|
19
|
+
* answer — the platform was slow — never reaches them. Long work returns its current domain status.
|
|
20
|
+
*
|
|
21
|
+
* `planning` is the facade `makeSdkContext` registered with `appendPlanningClient`: its reads and
|
|
22
|
+
* its execute POST carry the same tool deadline, and a commit is awaited by long polls whose HTTP
|
|
23
|
+
* deadline outlasts their own hold by ten seconds. Its scope is empty on purpose — the platform
|
|
24
|
+
* reads the organization and the profile from the token.
|
|
21
25
|
*/
|
|
22
26
|
export declare const makeRemoteConnectorApi: (context: Ctx) => ConnectorApi;
|
|
23
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/api/remote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/api/remote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAU3E,OAAO,KAAK,EAAE,YAAY,EAAiC,MAAM,aAAa,CAAA;AAE9E,KAAK,GAAG,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;AAOtC,4FAA4F;AAC5F,eAAO,MAAM,yBAAyB,UAAW,OAAO,KAAG,OAgB1D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAU,CAAC,QAC/B,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC,KACjD,OAAO,CAAC,CAAC,CAQX,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,YAAa,GAAG,KAAG,YAyHrD,CAAA"}
|