codeer-cli 0.1.15__tar.gz → 0.1.16__tar.gz
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.
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/API_REFERENCE.md +22 -2
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/PKG-INFO +146 -11
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/README.md +145 -10
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/pyproject.toml +1 -1
- codeer_cli-0.1.16/src/codeer_cli/_http_contracts.py +109 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/_validate.py +8 -2
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/agents.py +1 -1
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/cli.py +5 -1
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/client.py +4 -3
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/_util.py +7 -2
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/agent.py +31 -10
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/history.py +96 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/histories.py +123 -24
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_client_transport.py +16 -0
- codeer_cli-0.1.16/tests/test_history_read.py +847 -0
- codeer_cli-0.1.16/tests/test_http_contracts.py +587 -0
- codeer_cli-0.1.16/tests/test_util.py +114 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/uv.lock +1 -1
- codeer_cli-0.1.15/tests/test_history_read.py +0 -299
- codeer_cli-0.1.15/tests/test_util.py +0 -22
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/.gitignore +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/__init__.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/chats.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/__init__.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/check.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/eval_cmd.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/kb.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/model.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/commands/profile.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/constants.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/eval_.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/kb.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/models.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/src/codeer_cli/parse.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_agent_handoff.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_agent_model_settings.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_chats_v2.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_eval_evaluators.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_eval_labels.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_eval_pairs.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_history_send.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_kb_export.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_kb_nodes.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_kb_ranges.py +0 -0
- {codeer_cli-0.1.15 → codeer_cli-0.1.16}/tests/test_models.py +0 -0
|
@@ -9,7 +9,9 @@ endpoints authenticate via `x-api-key` from `CODEER_API_KEY`.
|
|
|
9
9
|
|
|
10
10
|
Envelope: successful responses look like
|
|
11
11
|
`{"error_code": 0, "message": "", "pagination": null, "data": <payload>}`.
|
|
12
|
-
The client unwraps `data` automatically; errors raise `CodeerError`.
|
|
12
|
+
The client unwraps `data` automatically; errors raise `CodeerError`. Reads that
|
|
13
|
+
need top-level pagination can pass `unwrap=False` to preserve the validated
|
|
14
|
+
success envelope.
|
|
13
15
|
|
|
14
16
|
**Environment config split:**
|
|
15
17
|
Auth means `CODEER_API_KEY`; it comes from the process environment only.
|
|
@@ -27,6 +29,11 @@ need a default agent.
|
|
|
27
29
|
- `/histories` uses **`limit` + `offset`** (NOT `page` / `page_size`).
|
|
28
30
|
Default in `histories.list()` is `limit=500`. Backend hard-cap may be
|
|
29
31
|
lower — check the response length.
|
|
32
|
+
- `/external/histories/{id}/ai-drafts` uses **`limit` + `offset`**, with
|
|
33
|
+
pagination in the response envelope. `histories.list_ai_drafts()` follows
|
|
34
|
+
every page and rejects total-count changes or duplicate IDs. It marks the
|
|
35
|
+
artifact `snapshot_consistency: best-effort` because the endpoint does not
|
|
36
|
+
expose a revision token.
|
|
30
37
|
- `/api/v2/chats/{id}/messages` also uses `limit` + `offset`.
|
|
31
38
|
`chats.list_messages()` follows pages until exhaustion; its `limit` argument
|
|
32
39
|
is a page size, not a total-result cap.
|
|
@@ -290,8 +297,9 @@ the public CLI.
|
|
|
290
297
|
| `POST /api/v2/chats` | Create a persisted history using an agent's current published version |
|
|
291
298
|
| `POST /api/v2/chats/{id}/messages` | Append a turn through structured SSE using the current published version |
|
|
292
299
|
| `GET /api/v1/external/histories/{id}/messages` | Export persisted diagnostic parts for workspace editors (`history-parts-v1`) |
|
|
300
|
+
| `GET /api/v1/external/histories/{id}/ai-drafts` | Export AI Draft content, refinement signals, outcomes, tool activity, and actual delivery |
|
|
293
301
|
| `GET /api/v2/chats/{id}/messages` | Read client-visible parts under the external client-owner contract |
|
|
294
|
-
| `GET /api/v1/external/histories?agent_id=X&feedback_filter=improve_feedback&external_user_id
|
|
302
|
+
| `GET /api/v1/external/histories?agent_id=X&feedback_filter=improve_feedback&external_user_id=…&has_ai_drafts=true` | List conversations with filters and AI Draft lifecycle counts |
|
|
295
303
|
| `GET /api/v1/external/histories/{id}` | Read one history's metadata |
|
|
296
304
|
| `GET /api/v1/external/histories/{id}/conversations` | Legacy compact conversation rows; not complete tool I/O |
|
|
297
305
|
| `POST /api/v1/external/histories/{hid}/conversations/{cid}/feedbacks` | Leave freeform improvement feedback |
|
|
@@ -308,6 +316,18 @@ outcome, so read the history before retrying to avoid duplicate turns.
|
|
|
308
316
|
V2 read contract explicitly. The management export includes persisted tool
|
|
309
317
|
calls/results but excludes system prompts and provider raw traces.
|
|
310
318
|
|
|
319
|
+
`codeer history ai-drafts <history-id> --out <path>` uses the AI Draft export
|
|
320
|
+
and follows every page. The artifact preserves `generation_instruction`,
|
|
321
|
+
`dismiss_feedback`, refinement ancestry, lifecycle outcome, tool activities,
|
|
322
|
+
proposed actions, and correlated delivery. Those are recorded improvement
|
|
323
|
+
signals, not a server-generated recommendation. Compare them with the History
|
|
324
|
+
parts and accepted Behavior Contract before proposing an Agent change. Default
|
|
325
|
+
stdout exposes only structural flags and counts; `--full --out <path>` opts into
|
|
326
|
+
bounded sensitive text previews. Because this endpoint has no revision token,
|
|
327
|
+
the artifact is marked `snapshot_consistency: best-effort`; total-count changes
|
|
328
|
+
and duplicate IDs are rejected, but field updates during pagination cannot be
|
|
329
|
+
detected.
|
|
330
|
+
|
|
311
331
|
`feedback_filter` accepts the `FeedbackFilterType` enum values:
|
|
312
332
|
`no_feedback`, `with_feedback`, `helpful_feedback`, `improve_feedback`.
|
|
313
333
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: codeer-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Command line tools for managing Codeer agents over the Codeer API.
|
|
5
5
|
Project-URL: Homepage, https://www.codeer.ai
|
|
6
6
|
Author: Codeer.AI
|
|
@@ -175,6 +175,104 @@ becomes available in live published-agent conversations with a non-empty
|
|
|
175
175
|
`external_user_id`; editor Live Test conversations are internal and cannot
|
|
176
176
|
activate human mode.
|
|
177
177
|
|
|
178
|
+
## HTTP input contracts
|
|
179
|
+
|
|
180
|
+
`codeer agent apply --payload` and SDK `agents.create` / `agents.update` accept
|
|
181
|
+
`unified_tools[].http_request.body.input_contracts`. No separate HTTP command is
|
|
182
|
+
needed. The target backend must have the HTTP input-contract feature deployed
|
|
183
|
+
(codeer-copilot #1495); installing this CLI alone does not enable runtime support.
|
|
184
|
+
A local dry-run cannot establish server deployment or API business-rule success.
|
|
185
|
+
|
|
186
|
+
Example payload:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"name": "Order helper",
|
|
191
|
+
"system_prompt": "Use the configured API for approved order changes.",
|
|
192
|
+
"use_search": false,
|
|
193
|
+
"unified_tools": [{
|
|
194
|
+
"id": "submit",
|
|
195
|
+
"type": "http_request",
|
|
196
|
+
"http_request": {
|
|
197
|
+
"method": "POST",
|
|
198
|
+
"url_template": "https://example.com/orders",
|
|
199
|
+
"body": {
|
|
200
|
+
"template": {
|
|
201
|
+
"quantity": "{{agent[Requested quantity]}}",
|
|
202
|
+
"payload": "{{agent[Order details]}}",
|
|
203
|
+
"changes": "{{agent[Changes as JSON text]}}"
|
|
204
|
+
},
|
|
205
|
+
"input_contracts": {
|
|
206
|
+
"quantity": {"type": "integer"},
|
|
207
|
+
"payload": {"type": "object"},
|
|
208
|
+
"changes": {"type": "string", "format": "json", "json_type": "array"}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- `type`: `string` (default), `number`, `integer`, `boolean`, `object`, `array`.
|
|
217
|
+
- `format`: `text` (default) or `json`; `json` requires `type: string`.
|
|
218
|
+
- `json_type`: `any` (default), `object`, `array`; outside JSON format, only
|
|
219
|
+
`any` is valid. API names are snake_case; the CLI rejects `inputContracts`,
|
|
220
|
+
`jsonType`, and unknown fields inside individual contracts.
|
|
221
|
+
|
|
222
|
+
`type: object` / `array` sends a native JSON value. `type: string, format: json`
|
|
223
|
+
sends a string containing JSON. Existing valid JSON text is sent unchanged;
|
|
224
|
+
empty strings also pass unchanged, while non-empty text must parse and match
|
|
225
|
+
`json_type`. Plain strings retain existing behavior, including malformed JSON.
|
|
226
|
+
The backend converts supported representations before checking runtime values;
|
|
227
|
+
the CLI only validates configuration and never executes the configured HTTP
|
|
228
|
+
request. Contracts do not configure nested JSON Schema constraints or defaults.
|
|
229
|
+
|
|
230
|
+
Keys come from template paths, not instructions: `order.count` → `order_count`,
|
|
231
|
+
`items[0].id` → `items_0_id`, root string → `body`. Non-ASCII-alphanumeric runs
|
|
232
|
+
become `_`, edge underscores are removed, and keys are lowercased. Multiple
|
|
233
|
+
placeholders in one string add `_1`, `_2`; traversal collisions add `_2`, `_3`.
|
|
234
|
+
Object insertion order matters: preserve it when editing/exporting. Typed and
|
|
235
|
+
JSON-text placeholders must occupy the entire template value. Stale contract
|
|
236
|
+
keys fail validation; omitted entries remain ordinary strings.
|
|
237
|
+
|
|
238
|
+
For an existing Agent:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
codeer agent get <agent-id> --out .codeer/current/agent.json
|
|
242
|
+
# Prepare local_draft_agent.json from current writable settings; review its diff.
|
|
243
|
+
codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json --dry-run
|
|
244
|
+
# After approval:
|
|
245
|
+
codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json
|
|
246
|
+
codeer agent get <agent-id> --out .codeer/current/agent.json
|
|
247
|
+
codeer agent get <agent-id> --history <history-id-from-apply> --out .codeer/current/agent-version.json
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The external update uses PATCH, but it is **not a nested partial update**.
|
|
251
|
+
Preserve `name`, `system_prompt`, `use_search`, the complete `unified_tools` list
|
|
252
|
+
(including other tools, templates, auth and `draft_policy`), and the full desired
|
|
253
|
+
contract map. Also preserve description, attachments, suggested questions,
|
|
254
|
+
model settings, handoff and other writable settings. Sending one changed tool
|
|
255
|
+
replaces the list; omitting a contract entry resets that input to ordinary string.
|
|
256
|
+
GET responses and writable payloads have different shapes; reconstruct attachment
|
|
257
|
+
IDs and other absent writable fields from current version evidence as needed.
|
|
258
|
+
Do not apply an update if a current setting cannot be preserved by the CLI. See
|
|
259
|
+
[the skill workflow](../codeer-agent/reference/http-input-contracts.md) for details.
|
|
260
|
+
|
|
261
|
+
Dry-run's `http_inputs` lists tool indexes and each generated key's effective
|
|
262
|
+
`type` / `format` / `json_type`, with `configured: false` for defaults. It excludes
|
|
263
|
+
HTTP URLs, auth, headers, query values, instructions and template content.
|
|
264
|
+
`body_inputs_used` is false for GET/HEAD, whose body inputs are unused at runtime.
|
|
265
|
+
`--full` and `--out` deliberately retain complete nested content, including
|
|
266
|
+
credentials; metadata cleanup is limited to resource-level account fields and
|
|
267
|
+
workspace identity. These exports are not redacted artifacts.
|
|
268
|
+
|
|
269
|
+
Compare the fresh GET and exact version snapshot with the intended tools and
|
|
270
|
+
contracts; the server may materialize omitted defaults. `agent versions --out`
|
|
271
|
+
exports version metadata, not snapshots; use `agent get --history` for a snapshot.
|
|
272
|
+
Apply saves a draft. Publish the verified version separately, after approval,
|
|
273
|
+
using `codeer agent publish --agent <agent-id> --history <history-id>` (preview
|
|
274
|
+
with `--dry-run` first).
|
|
275
|
+
|
|
178
276
|
## Upgrade and uninstall
|
|
179
277
|
|
|
180
278
|
Upgrade the CLI:
|
|
@@ -200,8 +298,9 @@ Use this pattern during agent lifecycle work:
|
|
|
200
298
|
|
|
201
299
|
```bash
|
|
202
300
|
codeer agent list
|
|
203
|
-
codeer history list --agent <agent-id> --limit 50
|
|
301
|
+
codeer history list --agent <agent-id> --has-ai-drafts --limit 50
|
|
204
302
|
codeer history conversations <history-id> --out .codeer/current/history-<history-id>.json
|
|
303
|
+
codeer history ai-drafts <history-id> --out .codeer/current/ai-drafts-<history-id>.json
|
|
205
304
|
codeer history create --agent <agent-id> --message "Review this plan" --timeout 240
|
|
206
305
|
codeer history send <history-id> --message "Use the recommended options" --timeout 240
|
|
207
306
|
codeer eval run --agent <agent-id> --cases <case-ids> --evaluator <evaluator-id> --out .codeer/eval_run.json
|
|
@@ -220,19 +319,55 @@ workspace.
|
|
|
220
319
|
|
|
221
320
|
Flags:
|
|
222
321
|
|
|
223
|
-
- `--full` prints bounded extra detail for human inspection.
|
|
224
|
-
|
|
322
|
+
- `--full` prints bounded extra detail for human inspection. Some commands,
|
|
323
|
+
including `agent get`, can expose configuration credentials; `history
|
|
324
|
+
ai-drafts` can expose sensitive conversation text and therefore requires
|
|
325
|
+
`--out`. Use each command's flag description as the output contract, and
|
|
326
|
+
inspect complete artifacts locally without flooding LLM context.
|
|
225
327
|
- `--out <path>` writes complete diagnostic artifacts to a local file. Use it
|
|
226
328
|
for raw eval results, full conversation turns, full rubric matrices, and
|
|
227
329
|
other data that can grow with cases, versions, or turns.
|
|
228
330
|
|
|
229
|
-
`history conversations`
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
331
|
+
`history conversations` reads `/api/v1/external/histories/{id}/messages`
|
|
332
|
+
using a workspace admin API key and follows all pages automatically. Member
|
|
333
|
+
keys retain existing History visibility but are intentionally rejected by this
|
|
334
|
+
complete tool-payload export. This requires a server supporting
|
|
335
|
+
`history-parts-v1`; it never falls back to a
|
|
336
|
+
different authorization contract. Stdout shows at most 20 part summaries (50
|
|
337
|
+
with `--full`) and omits tool payload previews. `--out` retains native tool
|
|
338
|
+
args/results/outcomes, group/part IDs, attachments, feedback, and metadata.
|
|
339
|
+
Attachment URLs remain permission-checked History download endpoints rather
|
|
340
|
+
than direct storage/source URLs.
|
|
341
|
+
Legacy projections have `source: legacy-adapter`; tool outcomes absent from
|
|
342
|
+
the original records are omitted and marked `outcome_not_recorded`. System
|
|
343
|
+
prompts and provider raw traces are not included. Missing parts do not prove a tool never ran. Keep export files private.
|
|
344
|
+
|
|
345
|
+
`--client-visible --user <external-user-id>` explicitly selects the existing
|
|
346
|
+
Chat V2 owner/allowlist contract. No external identity is inferred from History
|
|
347
|
+
metadata. `history get` and the low-level legacy `get_conversations` reader
|
|
348
|
+
remain compatible. Management exports do not hydrate display-only tool payloads.
|
|
349
|
+
|
|
350
|
+
Release order: deploy the backend supporting `history-parts-v1` first, verify
|
|
351
|
+
an authorized management export across multiple pages, then release/install
|
|
352
|
+
this CLI. Existing CLI versions retain their previous behavior until upgraded.
|
|
353
|
+
If the backend endpoint is unavailable, the new CLI fails explicitly with no
|
|
354
|
+
fallback; keep the previous CLI installed until backend verification passes.
|
|
355
|
+
The management endpoint can remain available if the CLI release is rolled back.
|
|
356
|
+
|
|
357
|
+
`history list --has-ai-drafts` narrows the history page to conversations with
|
|
358
|
+
at least one AI Draft and includes lifecycle counts in compact output.
|
|
359
|
+
`history ai-drafts` follows every server page and writes every returned draft
|
|
360
|
+
lifecycle record to `--out`: generated content, refinement lineage,
|
|
361
|
+
`generation_instruction`, `dismiss_reason`, `dismiss_feedback`, outcomes, tool
|
|
362
|
+
activities, proposed actions, operator attribution, and the correlated actual
|
|
363
|
+
delivery when one exists. Default stdout shows structural flags and counts but
|
|
364
|
+
no generated, operator, customer, or tool text. `--full --out <path>` explicitly
|
|
365
|
+
opts into bounded content previews. The endpoint has no revision token, so a
|
|
366
|
+
multi-page artifact is marked `snapshot_consistency: best-effort`: count changes
|
|
367
|
+
and duplicate IDs fail the export, but lifecycle fields can still change during
|
|
368
|
+
paging. Re-run when point-in-time consistency matters. These fields are evidence
|
|
369
|
+
for an improvement analysis; the CLI does not invent a recommended Agent change
|
|
370
|
+
from them.
|
|
236
371
|
|
|
237
372
|
Use the external client-owner contract only when that distinction is the point
|
|
238
373
|
of the test:
|
|
@@ -157,6 +157,104 @@ becomes available in live published-agent conversations with a non-empty
|
|
|
157
157
|
`external_user_id`; editor Live Test conversations are internal and cannot
|
|
158
158
|
activate human mode.
|
|
159
159
|
|
|
160
|
+
## HTTP input contracts
|
|
161
|
+
|
|
162
|
+
`codeer agent apply --payload` and SDK `agents.create` / `agents.update` accept
|
|
163
|
+
`unified_tools[].http_request.body.input_contracts`. No separate HTTP command is
|
|
164
|
+
needed. The target backend must have the HTTP input-contract feature deployed
|
|
165
|
+
(codeer-copilot #1495); installing this CLI alone does not enable runtime support.
|
|
166
|
+
A local dry-run cannot establish server deployment or API business-rule success.
|
|
167
|
+
|
|
168
|
+
Example payload:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"name": "Order helper",
|
|
173
|
+
"system_prompt": "Use the configured API for approved order changes.",
|
|
174
|
+
"use_search": false,
|
|
175
|
+
"unified_tools": [{
|
|
176
|
+
"id": "submit",
|
|
177
|
+
"type": "http_request",
|
|
178
|
+
"http_request": {
|
|
179
|
+
"method": "POST",
|
|
180
|
+
"url_template": "https://example.com/orders",
|
|
181
|
+
"body": {
|
|
182
|
+
"template": {
|
|
183
|
+
"quantity": "{{agent[Requested quantity]}}",
|
|
184
|
+
"payload": "{{agent[Order details]}}",
|
|
185
|
+
"changes": "{{agent[Changes as JSON text]}}"
|
|
186
|
+
},
|
|
187
|
+
"input_contracts": {
|
|
188
|
+
"quantity": {"type": "integer"},
|
|
189
|
+
"payload": {"type": "object"},
|
|
190
|
+
"changes": {"type": "string", "format": "json", "json_type": "array"}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}]
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
- `type`: `string` (default), `number`, `integer`, `boolean`, `object`, `array`.
|
|
199
|
+
- `format`: `text` (default) or `json`; `json` requires `type: string`.
|
|
200
|
+
- `json_type`: `any` (default), `object`, `array`; outside JSON format, only
|
|
201
|
+
`any` is valid. API names are snake_case; the CLI rejects `inputContracts`,
|
|
202
|
+
`jsonType`, and unknown fields inside individual contracts.
|
|
203
|
+
|
|
204
|
+
`type: object` / `array` sends a native JSON value. `type: string, format: json`
|
|
205
|
+
sends a string containing JSON. Existing valid JSON text is sent unchanged;
|
|
206
|
+
empty strings also pass unchanged, while non-empty text must parse and match
|
|
207
|
+
`json_type`. Plain strings retain existing behavior, including malformed JSON.
|
|
208
|
+
The backend converts supported representations before checking runtime values;
|
|
209
|
+
the CLI only validates configuration and never executes the configured HTTP
|
|
210
|
+
request. Contracts do not configure nested JSON Schema constraints or defaults.
|
|
211
|
+
|
|
212
|
+
Keys come from template paths, not instructions: `order.count` → `order_count`,
|
|
213
|
+
`items[0].id` → `items_0_id`, root string → `body`. Non-ASCII-alphanumeric runs
|
|
214
|
+
become `_`, edge underscores are removed, and keys are lowercased. Multiple
|
|
215
|
+
placeholders in one string add `_1`, `_2`; traversal collisions add `_2`, `_3`.
|
|
216
|
+
Object insertion order matters: preserve it when editing/exporting. Typed and
|
|
217
|
+
JSON-text placeholders must occupy the entire template value. Stale contract
|
|
218
|
+
keys fail validation; omitted entries remain ordinary strings.
|
|
219
|
+
|
|
220
|
+
For an existing Agent:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
codeer agent get <agent-id> --out .codeer/current/agent.json
|
|
224
|
+
# Prepare local_draft_agent.json from current writable settings; review its diff.
|
|
225
|
+
codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json --dry-run
|
|
226
|
+
# After approval:
|
|
227
|
+
codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json
|
|
228
|
+
codeer agent get <agent-id> --out .codeer/current/agent.json
|
|
229
|
+
codeer agent get <agent-id> --history <history-id-from-apply> --out .codeer/current/agent-version.json
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The external update uses PATCH, but it is **not a nested partial update**.
|
|
233
|
+
Preserve `name`, `system_prompt`, `use_search`, the complete `unified_tools` list
|
|
234
|
+
(including other tools, templates, auth and `draft_policy`), and the full desired
|
|
235
|
+
contract map. Also preserve description, attachments, suggested questions,
|
|
236
|
+
model settings, handoff and other writable settings. Sending one changed tool
|
|
237
|
+
replaces the list; omitting a contract entry resets that input to ordinary string.
|
|
238
|
+
GET responses and writable payloads have different shapes; reconstruct attachment
|
|
239
|
+
IDs and other absent writable fields from current version evidence as needed.
|
|
240
|
+
Do not apply an update if a current setting cannot be preserved by the CLI. See
|
|
241
|
+
[the skill workflow](../codeer-agent/reference/http-input-contracts.md) for details.
|
|
242
|
+
|
|
243
|
+
Dry-run's `http_inputs` lists tool indexes and each generated key's effective
|
|
244
|
+
`type` / `format` / `json_type`, with `configured: false` for defaults. It excludes
|
|
245
|
+
HTTP URLs, auth, headers, query values, instructions and template content.
|
|
246
|
+
`body_inputs_used` is false for GET/HEAD, whose body inputs are unused at runtime.
|
|
247
|
+
`--full` and `--out` deliberately retain complete nested content, including
|
|
248
|
+
credentials; metadata cleanup is limited to resource-level account fields and
|
|
249
|
+
workspace identity. These exports are not redacted artifacts.
|
|
250
|
+
|
|
251
|
+
Compare the fresh GET and exact version snapshot with the intended tools and
|
|
252
|
+
contracts; the server may materialize omitted defaults. `agent versions --out`
|
|
253
|
+
exports version metadata, not snapshots; use `agent get --history` for a snapshot.
|
|
254
|
+
Apply saves a draft. Publish the verified version separately, after approval,
|
|
255
|
+
using `codeer agent publish --agent <agent-id> --history <history-id>` (preview
|
|
256
|
+
with `--dry-run` first).
|
|
257
|
+
|
|
160
258
|
## Upgrade and uninstall
|
|
161
259
|
|
|
162
260
|
Upgrade the CLI:
|
|
@@ -182,8 +280,9 @@ Use this pattern during agent lifecycle work:
|
|
|
182
280
|
|
|
183
281
|
```bash
|
|
184
282
|
codeer agent list
|
|
185
|
-
codeer history list --agent <agent-id> --limit 50
|
|
283
|
+
codeer history list --agent <agent-id> --has-ai-drafts --limit 50
|
|
186
284
|
codeer history conversations <history-id> --out .codeer/current/history-<history-id>.json
|
|
285
|
+
codeer history ai-drafts <history-id> --out .codeer/current/ai-drafts-<history-id>.json
|
|
187
286
|
codeer history create --agent <agent-id> --message "Review this plan" --timeout 240
|
|
188
287
|
codeer history send <history-id> --message "Use the recommended options" --timeout 240
|
|
189
288
|
codeer eval run --agent <agent-id> --cases <case-ids> --evaluator <evaluator-id> --out .codeer/eval_run.json
|
|
@@ -202,19 +301,55 @@ workspace.
|
|
|
202
301
|
|
|
203
302
|
Flags:
|
|
204
303
|
|
|
205
|
-
- `--full` prints bounded extra detail for human inspection.
|
|
206
|
-
|
|
304
|
+
- `--full` prints bounded extra detail for human inspection. Some commands,
|
|
305
|
+
including `agent get`, can expose configuration credentials; `history
|
|
306
|
+
ai-drafts` can expose sensitive conversation text and therefore requires
|
|
307
|
+
`--out`. Use each command's flag description as the output contract, and
|
|
308
|
+
inspect complete artifacts locally without flooding LLM context.
|
|
207
309
|
- `--out <path>` writes complete diagnostic artifacts to a local file. Use it
|
|
208
310
|
for raw eval results, full conversation turns, full rubric matrices, and
|
|
209
311
|
other data that can grow with cases, versions, or turns.
|
|
210
312
|
|
|
211
|
-
`history conversations`
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
313
|
+
`history conversations` reads `/api/v1/external/histories/{id}/messages`
|
|
314
|
+
using a workspace admin API key and follows all pages automatically. Member
|
|
315
|
+
keys retain existing History visibility but are intentionally rejected by this
|
|
316
|
+
complete tool-payload export. This requires a server supporting
|
|
317
|
+
`history-parts-v1`; it never falls back to a
|
|
318
|
+
different authorization contract. Stdout shows at most 20 part summaries (50
|
|
319
|
+
with `--full`) and omits tool payload previews. `--out` retains native tool
|
|
320
|
+
args/results/outcomes, group/part IDs, attachments, feedback, and metadata.
|
|
321
|
+
Attachment URLs remain permission-checked History download endpoints rather
|
|
322
|
+
than direct storage/source URLs.
|
|
323
|
+
Legacy projections have `source: legacy-adapter`; tool outcomes absent from
|
|
324
|
+
the original records are omitted and marked `outcome_not_recorded`. System
|
|
325
|
+
prompts and provider raw traces are not included. Missing parts do not prove a tool never ran. Keep export files private.
|
|
326
|
+
|
|
327
|
+
`--client-visible --user <external-user-id>` explicitly selects the existing
|
|
328
|
+
Chat V2 owner/allowlist contract. No external identity is inferred from History
|
|
329
|
+
metadata. `history get` and the low-level legacy `get_conversations` reader
|
|
330
|
+
remain compatible. Management exports do not hydrate display-only tool payloads.
|
|
331
|
+
|
|
332
|
+
Release order: deploy the backend supporting `history-parts-v1` first, verify
|
|
333
|
+
an authorized management export across multiple pages, then release/install
|
|
334
|
+
this CLI. Existing CLI versions retain their previous behavior until upgraded.
|
|
335
|
+
If the backend endpoint is unavailable, the new CLI fails explicitly with no
|
|
336
|
+
fallback; keep the previous CLI installed until backend verification passes.
|
|
337
|
+
The management endpoint can remain available if the CLI release is rolled back.
|
|
338
|
+
|
|
339
|
+
`history list --has-ai-drafts` narrows the history page to conversations with
|
|
340
|
+
at least one AI Draft and includes lifecycle counts in compact output.
|
|
341
|
+
`history ai-drafts` follows every server page and writes every returned draft
|
|
342
|
+
lifecycle record to `--out`: generated content, refinement lineage,
|
|
343
|
+
`generation_instruction`, `dismiss_reason`, `dismiss_feedback`, outcomes, tool
|
|
344
|
+
activities, proposed actions, operator attribution, and the correlated actual
|
|
345
|
+
delivery when one exists. Default stdout shows structural flags and counts but
|
|
346
|
+
no generated, operator, customer, or tool text. `--full --out <path>` explicitly
|
|
347
|
+
opts into bounded content previews. The endpoint has no revision token, so a
|
|
348
|
+
multi-page artifact is marked `snapshot_consistency: best-effort`: count changes
|
|
349
|
+
and duplicate IDs fail the export, but lifecycle fields can still change during
|
|
350
|
+
paging. Re-run when point-in-time consistency matters. These fields are evidence
|
|
351
|
+
for an improvement analysis; the CLI does not invent a recommended Agent change
|
|
352
|
+
from them.
|
|
218
353
|
|
|
219
354
|
Use the external client-owner contract only when that distinction is the point
|
|
220
355
|
of the test:
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""HTTP input *configuration* checks; value conversion belongs to the server.
|
|
2
|
+
|
|
3
|
+
Key generation follows collect_http_request_agent_placeholders in the backend's
|
|
4
|
+
http_request/execution.py. Keep its traversal and collision rules in sync.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_AGENT_PLACEHOLDER_RE = re.compile(r"\{\{\s*agent\[(.*?)\]\s*\}\}")
|
|
14
|
+
_CONTRACT_FIELDS = {
|
|
15
|
+
"type": ("string", "number", "integer", "boolean", "object", "array"),
|
|
16
|
+
"format": ("text", "json"),
|
|
17
|
+
"json_type": ("any", "object", "array"),
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _contract_defaults(contract: Any, key: str) -> dict[str, str]:
|
|
22
|
+
prefix = f"input_contracts[{key!r}]"
|
|
23
|
+
if not isinstance(contract, dict):
|
|
24
|
+
raise ValueError(f"{prefix} must be an object.")
|
|
25
|
+
if any(field not in _CONTRACT_FIELDS for field in contract):
|
|
26
|
+
raise ValueError(
|
|
27
|
+
f"{prefix} accepts only type, format, json_type (snake_case, not jsonType)."
|
|
28
|
+
)
|
|
29
|
+
resolved = {}
|
|
30
|
+
for field, choices in _CONTRACT_FIELDS.items():
|
|
31
|
+
value = contract.get(field, choices[0])
|
|
32
|
+
if not isinstance(value, str) or value not in choices:
|
|
33
|
+
raise ValueError(f"{prefix}.{field} must be one of: {', '.join(choices)}.")
|
|
34
|
+
resolved[field] = value
|
|
35
|
+
if resolved["format"] == "json" and resolved["type"] != "string":
|
|
36
|
+
raise ValueError(f"{prefix}: format=json is only available for type=string.")
|
|
37
|
+
if resolved["format"] != "json" and resolved["json_type"] != "any":
|
|
38
|
+
raise ValueError(f"{prefix}: json_type requires format=json unless it is any.")
|
|
39
|
+
return resolved
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def validate_http_input_contracts(body: Any) -> list[dict[str, Any]]:
|
|
43
|
+
"""Validate without mutation and return value-free input format summaries.
|
|
44
|
+
|
|
45
|
+
An omitted body is supplied as {} by callers; template may be null/absent.
|
|
46
|
+
Unconfigured placeholders retain string/text/any, including mixed text.
|
|
47
|
+
Unknown body fields follow the backend's existing ignore policy, except the
|
|
48
|
+
frontend alias inputContracts: reject it rather than silently losing intent.
|
|
49
|
+
Contract entries themselves are strict and reject all unknown fields.
|
|
50
|
+
"""
|
|
51
|
+
if not isinstance(body, dict):
|
|
52
|
+
raise ValueError("body must be an object; omit it for no body.")
|
|
53
|
+
if "inputContracts" in body:
|
|
54
|
+
raise ValueError("use input_contracts (snake_case), not inputContracts.")
|
|
55
|
+
contracts = body.get("input_contracts", {})
|
|
56
|
+
if not isinstance(contracts, dict) or any(
|
|
57
|
+
not isinstance(key, str) for key in contracts
|
|
58
|
+
):
|
|
59
|
+
raise ValueError("input_contracts must be an object with string keys.")
|
|
60
|
+
resolved = {
|
|
61
|
+
key: _contract_defaults(contract, key) for key, contract in contracts.items()
|
|
62
|
+
}
|
|
63
|
+
summaries: list[dict[str, Any]] = []
|
|
64
|
+
used_keys: set[str] = set()
|
|
65
|
+
|
|
66
|
+
def walk(value: Any, path: str) -> None:
|
|
67
|
+
if isinstance(value, dict):
|
|
68
|
+
for key, item in value.items():
|
|
69
|
+
walk(item, f"{path}.{key}" if path else key)
|
|
70
|
+
return
|
|
71
|
+
if isinstance(value, list):
|
|
72
|
+
for index, item in enumerate(value):
|
|
73
|
+
walk(item, f"{path}[{index}]")
|
|
74
|
+
return
|
|
75
|
+
if not isinstance(value, str):
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
matches = list(_AGENT_PLACEHOLDER_RE.finditer(value))
|
|
79
|
+
for index, match in enumerate(matches):
|
|
80
|
+
if not match.group(1).strip():
|
|
81
|
+
raise ValueError("Agent placeholder instruction cannot be empty.")
|
|
82
|
+
base = (
|
|
83
|
+
re.sub(r"[^a-zA-Z0-9]+", "_", path or "body").strip("_").lower()
|
|
84
|
+
or "body"
|
|
85
|
+
)
|
|
86
|
+
if len(matches) > 1:
|
|
87
|
+
base = f"{base}_{index + 1}"
|
|
88
|
+
key = base
|
|
89
|
+
suffix = 2
|
|
90
|
+
while key in used_keys:
|
|
91
|
+
key = f"{base}_{suffix}"
|
|
92
|
+
suffix += 1
|
|
93
|
+
used_keys.add(key)
|
|
94
|
+
contract = resolved.get(key) or _contract_defaults({}, key)
|
|
95
|
+
if (contract["type"] != "string" or contract["format"] == "json") and (
|
|
96
|
+
len(matches) != 1 or match.group(0) != value
|
|
97
|
+
):
|
|
98
|
+
raise ValueError(
|
|
99
|
+
f"Input {key!r}: typed and JSON-text inputs must occupy the entire template value."
|
|
100
|
+
)
|
|
101
|
+
summaries.append({"key": key, **contract, "configured": key in contracts})
|
|
102
|
+
|
|
103
|
+
walk(body.get("template"), "")
|
|
104
|
+
if set(contracts) - used_keys:
|
|
105
|
+
raise ValueError(
|
|
106
|
+
"input_contracts contains keys that do not match current placeholders; "
|
|
107
|
+
"remove stale contracts or regenerate keys after changing template paths/order."
|
|
108
|
+
)
|
|
109
|
+
return summaries
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
These checks exist because the backend's form-schema validator is lenient
|
|
4
4
|
(``extra="allow"``) and silently accepts unknown ``type`` strings, which then
|
|
5
5
|
render as blank fields in the web builder. Catching the common mistakes here
|
|
6
|
-
gives actionable errors before the
|
|
6
|
+
gives actionable errors before the PATCH/POST round-trip. HTTP input contracts
|
|
7
|
+
also need strict configuration checks before a draft is saved.
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
10
|
from __future__ import annotations
|
|
10
11
|
|
|
11
12
|
from typing import Any, Iterable
|
|
12
13
|
|
|
14
|
+
from ._http_contracts import validate_http_input_contracts
|
|
13
15
|
from .constants import (
|
|
14
16
|
FORM_FIELD_TYPES,
|
|
15
17
|
MAX_CALL_AGENT_TOOLS,
|
|
@@ -121,10 +123,14 @@ def _validate_single_tool(tool: dict[str, Any], index: int) -> None:
|
|
|
121
123
|
raise ToolValidationError(f"{prefix}: call_agent tool requires agent_id.")
|
|
122
124
|
elif tool_type == "http_request":
|
|
123
125
|
cfg = tool.get("http_request")
|
|
124
|
-
if not cfg or not cfg.get("method") or not cfg.get("url_template"):
|
|
126
|
+
if not isinstance(cfg, dict) or not cfg.get("method") or not cfg.get("url_template"):
|
|
125
127
|
raise ToolValidationError(
|
|
126
128
|
f"{prefix}: http_request tool requires http_request.method and http_request.url_template."
|
|
127
129
|
)
|
|
130
|
+
try:
|
|
131
|
+
validate_http_input_contracts(cfg.get("body", {}))
|
|
132
|
+
except ValueError as exc:
|
|
133
|
+
raise ToolValidationError(f"{prefix}.http_request.body: {exc}") from None
|
|
128
134
|
|
|
129
135
|
|
|
130
136
|
def _validate_form_schema(schema: Any, prefix: str) -> None:
|
|
@@ -66,7 +66,7 @@ def update(
|
|
|
66
66
|
attachment_ids: Optional[List[str]] = None,
|
|
67
67
|
human_handoff: Optional[dict[str, Any]] = None,
|
|
68
68
|
) -> dict:
|
|
69
|
-
"""
|
|
69
|
+
"""PATCH replaces settings and creates a draft; unified_tools is the full list."""
|
|
70
70
|
validated_tools = validate_unified_tools(unified_tools)
|
|
71
71
|
validated_handoff = validate_human_handoff(human_handoff)
|
|
72
72
|
body: dict[str, Any] = {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
codeer model list
|
|
6
6
|
codeer kb list|files|export|upload|node-rename|node-delete|faq-list|faq-get|faq-create|faq-update|faq-delete
|
|
7
7
|
codeer eval list|label-list|label-create|label-update|label-delete|case-update|case-delete|evaluators|evaluator-create|evaluator-update|run|export|reconcile|cases-apply|rubrics|rubrics-apply
|
|
8
|
-
codeer history list|get|conversations|negative-feedback|create|send
|
|
8
|
+
codeer history list|get|conversations|ai-drafts|negative-feedback|create|send
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
@@ -16,6 +16,7 @@ import sys
|
|
|
16
16
|
|
|
17
17
|
from .client import AuthError, CodeerClient, CodeerError
|
|
18
18
|
from .commands import check
|
|
19
|
+
from .histories import HistoryExportError
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
def main(argv: list[str] | None = None) -> int:
|
|
@@ -127,6 +128,9 @@ Use --out <path> for large raw artifacts; stdout defaults to compact summaries.
|
|
|
127
128
|
|
|
128
129
|
try:
|
|
129
130
|
return args.func(args, client)
|
|
131
|
+
except HistoryExportError as e:
|
|
132
|
+
print(f"error: {e}", file=sys.stderr)
|
|
133
|
+
return 1
|
|
130
134
|
except AuthError as e:
|
|
131
135
|
print(f"auth: {e}", file=sys.stderr)
|
|
132
136
|
return 3
|
|
@@ -161,6 +161,7 @@ class CodeerClient:
|
|
|
161
161
|
files: Any = None,
|
|
162
162
|
data: Any = None,
|
|
163
163
|
timeout: Optional[float] = None,
|
|
164
|
+
unwrap: bool = True,
|
|
164
165
|
) -> Any:
|
|
165
166
|
url = _api_url(path, api_version=api_version)
|
|
166
167
|
request_kwargs: dict[str, Any] = {}
|
|
@@ -186,7 +187,7 @@ class CodeerClient:
|
|
|
186
187
|
) from exc
|
|
187
188
|
except httpx.RequestError as exc:
|
|
188
189
|
raise self._transport_error(method_upper, path, exc) from exc
|
|
189
|
-
return self._parse(r)
|
|
190
|
+
return self._parse(r, unwrap=unwrap)
|
|
190
191
|
|
|
191
192
|
def get(self, path: str, **kwargs: Any) -> Any:
|
|
192
193
|
return self.request("GET", path, **kwargs)
|
|
@@ -290,7 +291,7 @@ class CodeerClient:
|
|
|
290
291
|
},
|
|
291
292
|
)
|
|
292
293
|
|
|
293
|
-
def _parse(self, r: httpx.Response) -> Any:
|
|
294
|
+
def _parse(self, r: httpx.Response, *, unwrap: bool = True) -> Any:
|
|
294
295
|
text = r.text
|
|
295
296
|
try:
|
|
296
297
|
payload = r.json() if text else None
|
|
@@ -306,7 +307,7 @@ class CodeerClient:
|
|
|
306
307
|
if isinstance(payload, dict) and "error_code" in payload and "data" in payload:
|
|
307
308
|
if payload.get("error_code") not in (0, None):
|
|
308
309
|
raise CodeerError(r.status_code, payload.get("message") or "error", payload)
|
|
309
|
-
return payload["data"]
|
|
310
|
+
return payload["data"] if unwrap else payload
|
|
310
311
|
return payload
|
|
311
312
|
|
|
312
313
|
def _raise_for_error(self, status: int, payload: Any) -> None:
|