Skip to content

Commit 4b29903

Browse files
committed
skills,schema: collapse http-api-{basic,bearer,key} into single http-api pattern with auth-shape + one/two-step sub-dimensions
1 parent 7cf414b commit 4b29903

7 files changed

Lines changed: 97 additions & 80 deletions

File tree

.agents/schemas/evidence.schema.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,11 @@
118118
"properties": {
119119
"preferredPattern": {
120120
"type": "string",
121-
"description": "If probing strongly suggests one of the six authoring patterns, name it here. Otherwise omit.",
121+
"description": "If probing strongly suggests one of the four authoring patterns, name it here. Otherwise omit.",
122122
"enum": [
123123
"ssh-interactive",
124124
"ssh-batch",
125-
"http-api-basic",
126-
"http-api-bearer",
127-
"http-api-key",
125+
"http-api",
128126
"http-form-fill"
129127
]
130128
},

.agents/skills/script-authoring/SKILL.md

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
name: script-authoring
33
description: >-
4-
Use when drafting or revising the custom-platform JSON itself. Six
5-
pattern recipes (ssh-interactive, ssh-batch, http-api-basic,
6-
http-api-bearer, http-api-key, http-form-fill) cite schema, samples,
7-
and templates and cover Do blocks, status messages, custom parameters,
8-
and reserved variables. Mandates the fast inner loop: local schema
9-
validation against schema/ before any appliance round-trip. SchemaOnly
10-
green is necessary but not sufficient — cross-reference samples for
11-
analogous patterns before declaring ready.
4+
Use when drafting or revising the custom-platform JSON itself. Four
5+
pattern recipes (ssh-interactive, ssh-batch, http-api, http-form-fill)
6+
cite schema, samples, and templates and cover Do blocks, status
7+
messages, custom parameters, and reserved variables. The http-api
8+
recipe spans every auth shape the API documents — Basic/Digest via
9+
HttpAuth, or Bearer / custom Authorization scheme / custom-header API
10+
key via script-built Headers — plus one-step vs two-step token fetch.
11+
Mandates the fast inner loop: local schema validation against schema/
12+
before any appliance round-trip. SchemaOnly green is necessary but not
13+
sufficient — cross-reference samples for analogous patterns before
14+
declaring ready.
1215
---
1316

1417
# script-authoring
@@ -19,13 +22,11 @@ Before drafting or revising any platform JSON, consult [`AGENTS.md`](../../../AG
1922

2023
## Scope
2124

22-
Six pattern sub-recipes cover the supported transports:
25+
Four pattern sub-recipes cover the supported transports:
2326

2427
- [`ssh-interactive`](#ssh-interactive)
2528
- [`ssh-batch`](#ssh-batch)
26-
- [`http-api-basic`](#http-api-basic)
27-
- [`http-api-bearer`](#http-api-bearer)
28-
- [`http-api-key`](#http-api-key)
29+
- [`http-api`](#http-api)
2930
- [`http-form-fill`](#http-form-fill)
3031

3132
Telnet/TN3270 is out of scope (`agent-skills-plan.md` §2). The recipes below are starting points; pick one based on [`strategy-selection`](../strategy-selection/SKILL.md) output and adapt it.
@@ -63,7 +64,7 @@ A green local schema check proves the JSON parses and conforms to the schema. It
6364

6465
Before declaring a draft "ready to import," cross-reference an analogous sample from `samples-index.md`. If a sample uses a construct your draft does not (e.g., a `Try`/`Catch` around `Disconnect`, a `Receive` flush of the login banner, a `Headers` block before `HttpAuth`), surface that divergence to the operator rather than silently omitting it. The `agent-skills-plan.md` §5 rule is explicit: *"if a sample uses a construct the draft doesn't, surface the divergence."*
6566

66-
## Conventions all six patterns share
67+
## Conventions all four patterns share
6768

6869
- **Top-level shape.** `Id`, `BackEnd: "Scriptable"`, optional `Meta`, optional `Imports`, then one object per operation (`CheckSystem`, `CheckPassword`, `ChangePassword`, …). Operation objects contain `Parameters` (array of single-key objects) and `Do` (array of command objects). See [`schema/custom-platform-script.schema.json`](../../../schema/custom-platform-script.schema.json) lines 14–80 for the top-level fields, and [`docs/reference/script-structure.md`](../../../docs/reference/script-structure.md) for prose.
6970
- **Reserved parameters** are not declared by the script — SPP injects them. Custom parameters are declared in `Parameters` and addressed as `%Name%`. See [`docs/reference/reserved-parameters.md`](../../../docs/reference/reserved-parameters.md) and [`docs/reference/custom-parameters.md`](../../../docs/reference/custom-parameters.md).
@@ -144,15 +145,22 @@ Reference: [`docs/guides/ssh-platforms.md`](../../../docs/guides/ssh-platforms.m
144145

145146
Reference: [`docs/guides/ssh-platforms.md`](../../../docs/guides/ssh-platforms.md) ("Batch mode" section), [`docs/reference/commands/execute-command.md`](../../../docs/reference/commands/execute-command.md).
146147

147-
### http-api-basic
148+
### http-api
148149

149-
**Use when** vendor docs or a `WWW-Authenticate: Basic …` response indicate HTTP Basic on every call.
150+
**Use when** the target exposes a documented HTTP/REST API and the script presents a credential the operator already holds (token, password, API key, anything else).
150151

151-
**Starter:** [`templates/Pattern-GenericRestApiBasicAuth.json`](../../../templates/Pattern-GenericRestApiBasicAuth.json).
152+
The script shape is the same regardless of auth scheme: `BaseAddress``NewHttpRequest` → (auth setup) → `Request``ExtractJsonObject``Status`. What varies is two orthogonal choices the recipe makes you spell out: **auth shape** and **one-step vs two-step**.
152153

153-
**Closest production sample:** [`samples/http/wordpress/WordPressHttp.json`](../../../samples/http/wordpress/WordPressHttp.json). The pattern is `BaseAddress``NewHttpRequest``HttpAuth``Request`; verified at lines 33–40 and again at 78–82, 128–132 of that sample.
154+
#### Auth shape — pick a bucket, then a specific scheme
154155

155-
**Key shapes (verified in the sample):**
156+
The first decision is *who handles the auth dance*:
157+
158+
| Bucket | What the script does | Auth schemes |
159+
| --- | --- | --- |
160+
| **HttpAuth-managed** | Hand SPP a username/password and an auth `Type`; the runtime builds the header. | `Basic`, `Digest` |
161+
| **Script-managed header** | Build the header value yourself and attach it via `Headers`/`AddHeaders`. | `Authorization: Bearer <token>`, custom `Authorization` schemes (`PVEAPIToken=…`, `Token …`, vendor-specific), custom-header API keys (`X-API-Key`, `X-Vault-Token`, `X-Auth-Token`, …) |
162+
163+
**HttpAuth-managed (Basic, Digest).** Set per-request, not once globally; this matches the existing samples and avoids leaking the service-account credential into requests that should target the managed account.
156164

157165
```jsonc
158166
{ "HttpAuth": {
@@ -161,49 +169,35 @@ Reference: [`docs/guides/ssh-platforms.md`](../../../docs/guides/ssh-platforms.m
161169
"Credentials": { "Login": "%FuncUsername%", "Password": "%FuncPassword%" } } }
162170
```
163171

164-
Set Basic auth per-request, not once globally. This matches the sample and avoids leaking the service-account credential into requests that should target the managed account.
165-
166-
Reference: [`docs/guides/http-platforms.md`](../../../docs/guides/http-platforms.md), [`docs/reference/commands/http-auth.md`](../../../docs/reference/commands/http-auth.md), [`docs/reference/commands/http-setup.md`](../../../docs/reference/commands/http-setup.md), [`docs/reference/commands/request.md`](../../../docs/reference/commands/request.md).
167-
168-
### http-api-bearer
169-
170-
**Use when** vendor docs describe an OAuth2 / token-exchange endpoint and subsequent calls send `Authorization: Bearer …`.
171-
172-
**Starter:** [`templates/Pattern-GenericRestApiBearerToken.json`](../../../templates/Pattern-GenericRestApiBearerToken.json).
173-
174-
**Closest production sample:** [`samples/http/onelogin-jit/OneLogin_GRC_JIT_addon.json`](../../../samples/http/onelogin-jit/OneLogin_GRC_JIT_addon.json). It interleaves `HttpAuth Basic` (when calling the token endpoint with client credentials, lines 2275–2278) with `Authorization: Bearer %AccessToken%` headers on subsequent calls (lines 1228, 1361, 1510, 1672, 1834, 2002, 2135).
175-
176-
**Key shapes:**
177-
178-
- POST to the token endpoint (often `HttpAuth` `Basic` with client id/secret, sometimes form-encoded body).
179-
- Parse the response with `ExtractJsonObject` to capture `AccessToken` (or vendor-specific field).
180-
- Build a fresh `NewHttpRequest` for each subsequent call; attach `Authorization: Bearer %AccessToken%` via the `Headers.AddHeaders` map.
172+
Closest production sample for Basic: [`samples/http/wordpress/WordPressHttp.json`](../../../samples/http/wordpress/WordPressHttp.json) (lines 33–40, 78–82, 128–132). Starter template: [`templates/Pattern-GenericRestApiBasicAuth.json`](../../../templates/Pattern-GenericRestApiBasicAuth.json). For Digest the shape is identical with `Type: "Digest"`; clean self-hostable Digest targets are rare in 2025, so verify the runtime supports the scheme against the deployed appliance version before committing.
181173

182-
Do not reuse the same `RequestObjectName` for token-fetch and operation calls — Basic auth and Bearer auth have different `HttpAuth`/`Headers` configurations and crossing them is a common source of 401s.
183-
184-
Reference: [`docs/guides/http-platforms.md`](../../../docs/guides/http-platforms.md) ("Bearer/OAuth2" section), [`docs/reference/commands/http-auth.md`](../../../docs/reference/commands/http-auth.md), [`docs/reference/commands/json.md`](../../../docs/reference/commands/json.md).
185-
186-
### http-api-key
187-
188-
**Use when** the API takes a static key in a custom header (e.g., `X-API-Key`, `X-Auth-Token`) instead of `Authorization`.
189-
190-
**Starter:** [`templates/Pattern-GenericRestApiKeyRotation.json`](../../../templates/Pattern-GenericRestApiKeyRotation.json) — also covers the `CheckApiKey` / `ChangeApiKey` operation pair. The custom-header shape lives at lines 184–190 of that file:
174+
**Script-managed header (Bearer, custom Authorization scheme, custom-header API key).** Use `Headers`/`AddHeaders`, not `HttpAuth`. There is no `HttpAuth` `Type` for arbitrary header shapes.
191175

192176
```jsonc
193177
{ "Headers": {
194-
"RequestObjectName": "CheckApiKeyRequest",
178+
"RequestObjectName": "CheckRequest",
195179
"AddHeaders": {
196180
"Accept": "application/json",
197-
"X-API-Key": "%ApiKey%" } } }
181+
"Authorization": "Bearer %AccessToken%" } } }
198182
```
199183

200-
**Key shapes:**
184+
Swap `Authorization: Bearer <token>` for whatever the vendor actually uses. Two common variants:
185+
186+
- **Bearer or custom `Authorization` scheme** (`Authorization: Bearer <token>`, `Authorization: PVEAPIToken=user@realm!tokenid=UUID`, `Authorization: Token …`). Closest production sample: [`samples/http/onelogin-jit/OneLogin_GRC_JIT_addon.json`](../../../samples/http/onelogin-jit/OneLogin_GRC_JIT_addon.json) (Bearer header at lines 1228, 1361, 1510, 1672, 1834, 2002, 2135). Starter template: [`templates/Pattern-GenericRestApiBearerToken.json`](../../../templates/Pattern-GenericRestApiBearerToken.json).
187+
- **Custom-header API key** (`X-API-Key: %ApiKey%`, `X-Vault-Token: %Token%`, `X-Auth-Token: …`). See lines 184–190 of [`templates/Pattern-GenericRestApiKeyRotation.json`](../../../templates/Pattern-GenericRestApiKeyRotation.json). That template also covers the `CheckApiKey` / `ChangeApiKey` operation pair for when the script must rotate the key itself; pair with [`docs/guides/api-key-management.md`](../../../docs/guides/api-key-management.md).
188+
189+
Whichever bucket you're in, declare the credential as `Type: "Secret"` in `Parameters` so SPP redacts it in task logs.
190+
191+
#### One-step vs two-step
192+
193+
Orthogonal to the bucket above:
194+
195+
- **One-step** — the operator already holds the credential the script presents on every operation call. HttpAuth-managed shapes are almost always one-step. Script-managed-header shapes are one-step when the credential is a long-lived API key or PAT.
196+
- **Two-step** — the script POSTs credentials (often HttpAuth-managed `Basic` with client id/secret, sometimes form-encoded) to a token endpoint, parses the response with `ExtractJsonObject` to capture an access token, then attaches that token via script-managed `Headers` on every subsequent operation call. The `samples/http/onelogin-jit/` sample is the canonical example, interleaving `HttpAuth Basic` on the token call (lines 2275–2278) with `Authorization: Bearer %AccessToken%` on the operation calls.
201197

202-
- Use `Headers` / `AddHeaders` rather than `HttpAuth` — there is no `HttpAuth` type for arbitrary header schemes.
203-
- Declare the key as `Type: "Secret"` in `Parameters` so SPP redacts it in task logs.
204-
- For rotation, pair with [`docs/guides/api-key-management.md`](../../../docs/guides/api-key-management.md) — the script must implement `CheckApiKey` + `ChangeApiKey`, and the operations the platform exposes change accordingly.
198+
Two-step gotcha: do **not** reuse the same `RequestObjectName` for the token-fetch and the operation calls. The two have different `HttpAuth`/`Headers` configurations and crossing them is a common source of 401s. Build a fresh `NewHttpRequest` for each.
205199

206-
Reference: [`docs/guides/api-key-management.md`](../../../docs/guides/api-key-management.md), [`docs/reference/commands/http-setup.md`](../../../docs/reference/commands/http-setup.md).
200+
Reference: [`docs/guides/http-platforms.md`](../../../docs/guides/http-platforms.md), [`docs/reference/commands/http-auth.md`](../../../docs/reference/commands/http-auth.md), [`docs/reference/commands/http-setup.md`](../../../docs/reference/commands/http-setup.md), [`docs/reference/commands/request.md`](../../../docs/reference/commands/request.md), [`docs/reference/commands/json.md`](../../../docs/reference/commands/json.md), [`docs/guides/api-key-management.md`](../../../docs/guides/api-key-management.md).
207201

208202
### http-form-fill
209203

.agents/skills/strategy-selection/SKILL.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ description: >-
44
Use to decide the implementation approach for a custom platform from
55
protocol, vendor documentation, and probe evidence. Maps inputs to a
66
recommendation across SSH (interactive vs batch) and HTTP (form-fill
7-
vs API; basic / bearer / api-key; password vs key vs API key;
8-
self-managed vs service-account). Accepts both fetched URLs and
7+
vs api). For http-api, also picks the auth shape — HttpAuth-managed
8+
(Basic, Digest) vs script-managed header (Bearer, custom Authorization
9+
scheme, custom-header API key) — and one-step vs two-step token fetch.
10+
Plus credential intent (password / SSH key / API key / bearer token)
11+
and self-managed vs service-account. Accepts both fetched URLs and
912
vendor-doc excerpts the user pasted into the conversation.
1013
---
1114

@@ -17,16 +20,20 @@ Before recommending a pattern, consult [`AGENTS.md`](../../../AGENTS.md) for the
1720

1821
## Scope
1922

20-
Map `(protocol, vendor docs, probe evidence)` to one of the six authoring patterns covered by [`script-authoring`](../script-authoring/SKILL.md):
23+
Map `(protocol, vendor docs, probe evidence)` to one of the four authoring patterns covered by [`script-authoring`](../script-authoring/SKILL.md):
2124

2225
- `ssh-interactive`
2326
- `ssh-batch`
24-
- `http-api-basic`
25-
- `http-api-bearer`
26-
- `http-api-key`
27+
- `http-api`
2728
- `http-form-fill`
2829

29-
Plus two orthogonal dimensions: **credential intent** (password / SSH key / API key / bearer token) and **self-managed vs service-account**.
30+
When `http-api` is the recommendation, also pick:
31+
32+
- **Auth shape bucket.** *HttpAuth-managed* (Basic, Digest) vs *script-managed header* (Bearer, custom `Authorization` scheme, custom-header API key).
33+
- **Specific scheme** within the bucket (e.g., `Bearer` vs `PVEAPIToken=…` vs `X-API-Key`).
34+
- **One-step vs two-step** — does the operator already hold the credential the script presents on every call (one-step), or must the script POST credentials to a token endpoint first (two-step)?
35+
36+
Plus two orthogonal dimensions that apply to every pattern: **credential intent** (password / SSH key / API key / bearer token) and **self-managed vs service-account**.
3037

3138
## Modes
3239

@@ -80,17 +87,18 @@ The detailed rules per branch are in the decision tree. The skill-level meta-rul
8087

8188
## Self-managed vs service-account
8289

83-
Orthogonal to the six patterns. Decide based on vendor docs and probe evidence, not assumption (see the "Self-managed vs service-account" section of the decision tree). When in doubt, ask the operator which mode the deployment will use — the answer changes which operations the script must implement and may bring `service-account` parameters (like a separate `FuncUsername`/`FuncPassword`) into scope.
90+
Orthogonal to the four patterns. Decide based on vendor docs and probe evidence, not assumption (see the "Self-managed vs service-account" section of the decision tree). When in doubt, ask the operator which mode the deployment will use — the answer changes which operations the script must implement and may bring `service-account` parameters (like a separate `FuncUsername`/`FuncPassword`) into scope.
8491

8592
## Output
8693

8794
The skill emits a short structured recommendation to whichever caller asked, typically `script-authoring` next:
8895

89-
- **Recommended pattern** — one of the six.
96+
- **Recommended pattern** — one of the four.
97+
- **For `http-api`:** auth shape bucket + specific scheme + one-step vs two-step.
9098
- **Credential intent** — one of the schema-defined kinds.
9199
- **Self-managed vs service-account** — pick or "ask operator".
92100
- **Citations** — the decision-tree row that drove the choice, the vendor-doc record, and the relevant `probeRecord.id`s from the evidence artifact.
93101
- **Open questions** — anything the agent could not decide with the available evidence. Surface these to the operator before authoring rather than after.
94102

95-
When evidence is incomplete, the recommendation is allowed to be conditional ("`http-api-bearer` if vendor confirms the token endpoint at `/oauth/token`; otherwise re-probe and revisit"). A conditional recommendation is preferable to a confident guess.
103+
When evidence is incomplete, the recommendation is allowed to be conditional ("`http-api` with two-step Bearer if vendor confirms the token endpoint at `/oauth/token`; otherwise re-probe and revisit"). A conditional recommendation is preferable to a confident guess.
96104

.agents/skills/target-probing/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Every probing session produces one evidence artifact, conforming to [`.agents/sc
5050

5151
Protocol-specific findings live under `sshFindings` or `httpFindings`. The v0 schema marks the internal shapes of these as TODO and intentionally permissive; this skill is the first consumer to populate them. When the playbooks below settle on a final shape, propose a schema bump as a follow-up — do not silently invent fields the schema rejects.
5252

53-
`strategyHints` is optional. Use it sparingly: it signals to `strategy-selection` that probing strongly favours one of the six authoring patterns. The `rationale` must cite a specific `probeRecord.id`, not a generic statement.
53+
`strategyHints` is optional. Use it sparingly: it signals to `strategy-selection` that probing strongly favours one of the four authoring patterns. The `rationale` must cite a specific `probeRecord.id`, not a generic statement.
5454

5555
## Pre-flight echo template
5656

.agents/skills/task-log-analysis/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Hand the result back to the right skill:
9292

9393
- `connect` failures with host-key / SSL mismatches → re-run probes via [`target-probing`](../target-probing/SKILL.md) to capture the new fingerprint, then update the script.
9494
- `connect` / `auth` failures with credential issues → confirm the seed credential with the operator before any further appliance call. Do not retry blindly (credential lockout risk; the probe-safety contract in [`target-probing`](../target-probing/SKILL.md) applies even outside probing).
95-
- `auth` failures with HTTP 401 after a token exchange → revisit [`script-authoring`](../script-authoring/SKILL.md) for `http-api-bearer` token-handling shape; common cause is reusing a single `RequestObjectName` across token-fetch and operation calls.
95+
- `auth` failures with HTTP 401 after a token exchange → revisit [`script-authoring`](../script-authoring/SKILL.md) for the `http-api` two-step token-handling shape; common cause is reusing a single `RequestObjectName` across token-fetch and operation calls.
9696
- `parse` failures → revisit `script-authoring`; cross-reference the failing `Receive`/regex against the analogous sample.
9797
- `operation` failures (target accepted but state did not change) → revisit [`strategy-selection`](../strategy-selection/SKILL.md). The wrong pattern may have been chosen (e.g., interactive `passwd` over batch SSH succeeds visibly but does not actually rotate).
9898
- `unknown` → stop and ask.

0 commit comments

Comments
 (0)