@chipschat/protocol 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +56 -2
- package/dist/generated/types.d.ts +4052 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +7 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/src/address.d.ts +106 -0
- package/dist/src/address.d.ts.map +1 -0
- package/dist/src/address.js +141 -0
- package/dist/src/address.js.map +1 -0
- package/dist/src/agent-context-windows.d.ts +235 -0
- package/dist/src/agent-context-windows.d.ts.map +1 -0
- package/dist/src/agent-context-windows.js +213 -0
- package/dist/src/agent-context-windows.js.map +1 -0
- package/dist/src/agent-heartbeats.d.ts +106 -0
- package/dist/src/agent-heartbeats.d.ts.map +1 -0
- package/dist/src/agent-heartbeats.js +111 -0
- package/dist/src/agent-heartbeats.js.map +1 -0
- package/dist/src/agent-models.d.ts +158 -0
- package/dist/src/agent-models.d.ts.map +1 -0
- package/dist/src/agent-models.js +171 -0
- package/dist/src/agent-models.js.map +1 -0
- package/dist/src/agent-place.d.ts +76 -0
- package/dist/src/agent-place.d.ts.map +1 -0
- package/dist/src/agent-place.js +80 -0
- package/dist/src/agent-place.js.map +1 -0
- package/dist/src/agents.d.ts +24 -0
- package/dist/src/agents.d.ts.map +1 -0
- package/dist/src/agents.js +58 -0
- package/dist/src/agents.js.map +1 -0
- package/dist/src/capabilities.d.ts +121 -0
- package/dist/src/capabilities.d.ts.map +1 -0
- package/dist/src/capabilities.js +120 -0
- package/dist/src/capabilities.js.map +1 -0
- package/dist/src/checklist.d.ts +19 -0
- package/dist/src/checklist.d.ts.map +1 -0
- package/dist/src/checklist.js +22 -0
- package/dist/src/checklist.js.map +1 -0
- package/dist/src/commands.d.ts +50 -0
- package/dist/src/commands.d.ts.map +1 -0
- package/dist/src/commands.js +274 -0
- package/dist/src/commands.js.map +1 -0
- package/dist/src/connectors.d.ts +90 -0
- package/dist/src/connectors.d.ts.map +1 -0
- package/dist/src/connectors.js +119 -0
- package/dist/src/connectors.js.map +1 -0
- package/dist/src/context-files.d.ts +304 -0
- package/dist/src/context-files.d.ts.map +1 -0
- package/dist/src/context-files.js +247 -0
- package/dist/src/context-files.js.map +1 -0
- package/dist/src/context.d.ts +369 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +526 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/direct-asks.d.ts +36 -0
- package/dist/src/direct-asks.d.ts.map +1 -0
- package/dist/src/direct-asks.js +43 -0
- package/dist/src/direct-asks.js.map +1 -0
- package/dist/src/envelope.d.ts +70 -0
- package/dist/src/envelope.d.ts.map +1 -0
- package/dist/src/envelope.js +46 -0
- package/dist/src/envelope.js.map +1 -0
- package/dist/src/events/catalogue.d.ts +50 -0
- package/dist/src/events/catalogue.d.ts.map +1 -0
- package/dist/src/events/catalogue.js +70 -0
- package/dist/src/events/catalogue.js.map +1 -0
- package/dist/src/events/chips-to-harness.d.ts +37 -0
- package/dist/src/events/chips-to-harness.d.ts.map +1 -0
- package/dist/src/events/chips-to-harness.js +511 -0
- package/dist/src/events/chips-to-harness.js.map +1 -0
- package/dist/src/events/harness-to-chips.d.ts +38 -0
- package/dist/src/events/harness-to-chips.d.ts.map +1 -0
- package/dist/src/events/harness-to-chips.js +593 -0
- package/dist/src/events/harness-to-chips.js.map +1 -0
- package/dist/src/events/index.d.ts +6 -0
- package/dist/src/events/index.d.ts.map +1 -0
- package/dist/src/events/index.js +5 -0
- package/dist/src/events/index.js.map +1 -0
- package/dist/src/events/workspace.d.ts +222 -0
- package/dist/src/events/workspace.d.ts.map +1 -0
- package/dist/src/events/workspace.js +1039 -0
- package/dist/src/events/workspace.js.map +1 -0
- package/dist/src/exchange.d.ts +262 -0
- package/dist/src/exchange.d.ts.map +1 -0
- package/dist/src/exchange.js +413 -0
- package/dist/src/exchange.js.map +1 -0
- package/dist/src/first-names.d.ts +29 -0
- package/dist/src/first-names.d.ts.map +1 -0
- package/dist/src/first-names.js +80 -0
- package/dist/src/first-names.js.map +1 -0
- package/dist/src/frames.d.ts +526 -0
- package/dist/src/frames.d.ts.map +1 -0
- package/dist/src/frames.js +346 -0
- package/dist/src/frames.js.map +1 -0
- package/dist/src/harness-jobs.d.ts +313 -0
- package/dist/src/harness-jobs.d.ts.map +1 -0
- package/dist/src/harness-jobs.js +210 -0
- package/dist/src/harness-jobs.js.map +1 -0
- package/dist/src/ids/index.d.ts +3 -0
- package/dist/src/ids/index.d.ts.map +1 -0
- package/dist/src/ids/index.js +2 -0
- package/dist/src/ids/index.js.map +1 -0
- package/dist/src/ids/ulid.d.ts +96 -0
- package/dist/src/ids/ulid.d.ts.map +1 -0
- package/dist/src/ids/ulid.js +212 -0
- package/dist/src/ids/ulid.js.map +1 -0
- package/dist/src/index.d.ts +81 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +47 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/invite-link.d.ts +64 -0
- package/dist/src/invite-link.d.ts.map +1 -0
- package/dist/src/invite-link.js +99 -0
- package/dist/src/invite-link.js.map +1 -0
- package/dist/src/join.d.ts +188 -0
- package/dist/src/join.d.ts.map +1 -0
- package/dist/src/join.js +190 -0
- package/dist/src/join.js.map +1 -0
- package/dist/src/limits.d.ts +50 -0
- package/dist/src/limits.d.ts.map +1 -0
- package/dist/src/limits.js +106 -0
- package/dist/src/limits.js.map +1 -0
- package/dist/src/matters.d.ts +22 -0
- package/dist/src/matters.d.ts.map +1 -0
- package/dist/src/matters.js +26 -0
- package/dist/src/matters.js.map +1 -0
- package/dist/src/mentions.d.ts +63 -0
- package/dist/src/mentions.d.ts.map +1 -0
- package/dist/src/mentions.js +129 -0
- package/dist/src/mentions.js.map +1 -0
- package/dist/src/names.d.ts +58 -0
- package/dist/src/names.d.ts.map +1 -0
- package/dist/src/names.js +192 -0
- package/dist/src/names.js.map +1 -0
- package/dist/src/no-reply.d.ts +17 -0
- package/dist/src/no-reply.d.ts.map +1 -0
- package/dist/src/no-reply.js +48 -0
- package/dist/src/no-reply.js.map +1 -0
- package/dist/src/notifications.d.ts +81 -0
- package/dist/src/notifications.d.ts.map +1 -0
- package/dist/src/notifications.js +65 -0
- package/dist/src/notifications.js.map +1 -0
- package/dist/src/pages.d.ts +32 -0
- package/dist/src/pages.d.ts.map +1 -0
- package/dist/src/pages.js +32 -0
- package/dist/src/pages.js.map +1 -0
- package/dist/src/pairing.d.ts +99 -0
- package/dist/src/pairing.d.ts.map +1 -0
- package/dist/src/pairing.js +163 -0
- package/dist/src/pairing.js.map +1 -0
- package/dist/src/primitives.d.ts +267 -0
- package/dist/src/primitives.d.ts.map +1 -0
- package/dist/src/primitives.js +279 -0
- package/dist/src/primitives.js.map +1 -0
- package/dist/src/project.d.ts +335 -0
- package/dist/src/project.d.ts.map +1 -0
- package/dist/src/project.js +499 -0
- package/dist/src/project.js.map +1 -0
- package/dist/src/ranges.d.ts +31 -0
- package/dist/src/ranges.d.ts.map +1 -0
- package/dist/src/ranges.js +51 -0
- package/dist/src/ranges.js.map +1 -0
- package/dist/src/relay.d.ts +177 -0
- package/dist/src/relay.d.ts.map +1 -0
- package/dist/src/relay.js +147 -0
- package/dist/src/relay.js.map +1 -0
- package/dist/src/room-files.d.ts +146 -0
- package/dist/src/room-files.d.ts.map +1 -0
- package/dist/src/room-files.js +135 -0
- package/dist/src/room-files.js.map +1 -0
- package/dist/src/room-note.d.ts +213 -0
- package/dist/src/room-note.d.ts.map +1 -0
- package/dist/src/room-note.js +457 -0
- package/dist/src/room-note.js.map +1 -0
- package/dist/src/space-icons.d.ts +68 -0
- package/dist/src/space-icons.d.ts.map +1 -0
- package/dist/src/space-icons.js +142 -0
- package/dist/src/space-icons.js.map +1 -0
- package/dist/src/spend.d.ts +57 -0
- package/dist/src/spend.d.ts.map +1 -0
- package/dist/src/spend.js +94 -0
- package/dist/src/spend.js.map +1 -0
- package/dist/src/visibility.d.ts +170 -0
- package/dist/src/visibility.d.ts.map +1 -0
- package/dist/src/visibility.js +218 -0
- package/dist/src/visibility.js.map +1 -0
- package/fixtures/agent.asked.json +15 -0
- package/fixtures/agent.attached.json +15 -0
- package/fixtures/agent.deleted.json +16 -0
- package/fixtures/agent.fork.json +14 -0
- package/fixtures/agent.lock_set.json +13 -0
- package/fixtures/agent.registered.json +17 -0
- package/fixtures/agent.released.json +16 -0
- package/fixtures/agent.updated.json +14 -0
- package/fixtures/approval.executed.json +16 -0
- package/fixtures/approval.request.json +45 -0
- package/fixtures/approval.resolved.json +20 -0
- package/fixtures/approval.routed.json +20 -0
- package/fixtures/artifact.create.json +18 -0
- package/fixtures/attachment.fetched.json +15 -0
- package/fixtures/attachment.limits_set.json +15 -0
- package/fixtures/budget.warning.json +20 -0
- package/fixtures/checkpoint.json +16 -0
- package/fixtures/context.compacted.json +16 -0
- package/fixtures/context.usage.json +17 -0
- package/fixtures/exchange.limits_set.json +15 -0
- package/fixtures/exchange.set.json +13 -0
- package/fixtures/feedback.json +21 -0
- package/fixtures/frames/ack.json +6 -0
- package/fixtures/frames/context.edit.json +11 -0
- package/fixtures/frames/context_window.change.json +9 -0
- package/fixtures/frames/context_window.compact.json +8 -0
- package/fixtures/frames/error.json +6 -0
- package/fixtures/frames/event.json +20 -0
- package/fixtures/frames/events.json +39 -0
- package/fixtures/frames/folder.open.json +6 -0
- package/fixtures/frames/folder.open.page.json +7 -0
- package/fixtures/frames/folder.run.json +8 -0
- package/fixtures/frames/folder.run_state.json +12 -0
- package/fixtures/frames/heartbeat.change.json +10 -0
- package/fixtures/frames/hello.json +18 -0
- package/fixtures/frames/job.change.json +9 -0
- package/fixtures/frames/join.json +19 -0
- package/fixtures/frames/model.change.json +10 -0
- package/fixtures/frames/ping.json +4 -0
- package/fixtures/frames/pong.json +4 -0
- package/fixtures/frames/presence.json +12 -0
- package/fixtures/frames/receipt.json +5 -0
- package/fixtures/frames/restart.json +5 -0
- package/fixtures/frames/subscribe.json +6 -0
- package/fixtures/handoff.json +20 -0
- package/fixtures/harness.removed.json +15 -0
- package/fixtures/harness.transferred.json +15 -0
- package/fixtures/hello.json +61 -0
- package/fixtures/join.allowed.json +20 -0
- package/fixtures/join.denied.json +17 -0
- package/fixtures/lane.updated.json +17 -0
- package/fixtures/membership.added.json +16 -0
- package/fixtures/membership.removed.json +14 -0
- package/fixtures/membership.replaced.json +15 -0
- package/fixtures/message.deleted.json +15 -0
- package/fixtures/message.edited.json +15 -0
- package/fixtures/message.handed.json +14 -0
- package/fixtures/message.heard.json +14 -0
- package/fixtures/message.held.json +14 -0
- package/fixtures/message.hidden.json +14 -0
- package/fixtures/message.new.json +96 -0
- package/fixtures/message.overheard.json +22 -0
- package/fixtures/message.pinned.json +14 -0
- package/fixtures/message.post.json +14 -0
- package/fixtures/message.shown.json +14 -0
- package/fixtures/message.unpinned.json +14 -0
- package/fixtures/person.face_set.json +17 -0
- package/fixtures/person.joined.json +16 -0
- package/fixtures/person.removed.json +16 -0
- package/fixtures/person.renamed.json +14 -0
- package/fixtures/policy.updated.json +30 -0
- package/fixtures/project.changed.json +21 -0
- package/fixtures/question.answered.json +23 -0
- package/fixtures/question.ask.json +37 -0
- package/fixtures/receipt.json +15 -0
- package/fixtures/relay.set.json +12 -0
- package/fixtures/role.changed.json +15 -0
- package/fixtures/run.cancel.json +15 -0
- package/fixtures/run.completed.json +20 -0
- package/fixtures/run.failed.json +20 -0
- package/fixtures/run.pause.json +15 -0
- package/fixtures/run.plan.json +24 -0
- package/fixtures/run.requested.json +34 -0
- package/fixtures/run.resume.json +15 -0
- package/fixtures/run.started.json +33 -0
- package/fixtures/run.status.json +17 -0
- package/fixtures/run.steer.json +21 -0
- package/fixtures/session.ended.json +15 -0
- package/fixtures/session.renamed.json +15 -0
- package/fixtures/session.started.json +17 -0
- package/fixtures/space.claimed.json +15 -0
- package/fixtures/space.created.json +14 -0
- package/fixtures/space.erased.json +13 -0
- package/fixtures/space.lead_set.json +13 -0
- package/fixtures/space.lock_set.json +13 -0
- package/fixtures/space.spend_ceiling_set.json +13 -0
- package/fixtures/space.updated.json +14 -0
- package/fixtures/step.log.json +26 -0
- package/fixtures/task.json +22 -0
- package/fixtures/turn.passed.json +14 -0
- package/fixtures/usage.json +21 -0
- package/fixtures/workspace.renamed.json +13 -0
- package/generated/agent-connect.json +13966 -0
- package/generated/schema/agent.asked.json +114 -0
- package/generated/schema/agent.attached.json +465 -0
- package/generated/schema/agent.deleted.json +127 -0
- package/generated/schema/agent.fork.json +107 -0
- package/generated/schema/agent.lock_set.json +105 -0
- package/generated/schema/agent.registered.json +130 -0
- package/generated/schema/agent.released.json +129 -0
- package/generated/schema/agent.updated.json +151 -0
- package/generated/schema/approval.executed.json +125 -0
- package/generated/schema/approval.request.json +279 -0
- package/generated/schema/approval.resolved.json +162 -0
- package/generated/schema/approval.routed.json +185 -0
- package/generated/schema/artifact.create.json +206 -0
- package/generated/schema/attachment.fetched.json +114 -0
- package/generated/schema/attachment.limits_set.json +136 -0
- package/generated/schema/budget.warning.json +152 -0
- package/generated/schema/checkpoint.json +111 -0
- package/generated/schema/context.compacted.json +124 -0
- package/generated/schema/context.usage.json +120 -0
- package/generated/schema/exchange.limits_set.json +127 -0
- package/generated/schema/exchange.set.json +144 -0
- package/generated/schema/feedback.json +173 -0
- package/generated/schema/handoff.json +122 -0
- package/generated/schema/harness.removed.json +122 -0
- package/generated/schema/harness.transferred.json +117 -0
- package/generated/schema/hello.json +509 -0
- package/generated/schema/join.allowed.json +176 -0
- package/generated/schema/join.denied.json +150 -0
- package/generated/schema/lane.updated.json +223 -0
- package/generated/schema/membership.added.json +153 -0
- package/generated/schema/membership.removed.json +126 -0
- package/generated/schema/membership.replaced.json +106 -0
- package/generated/schema/message.deleted.json +105 -0
- package/generated/schema/message.edited.json +107 -0
- package/generated/schema/message.handed.json +111 -0
- package/generated/schema/message.heard.json +100 -0
- package/generated/schema/message.held.json +181 -0
- package/generated/schema/message.hidden.json +100 -0
- package/generated/schema/message.new.json +1369 -0
- package/generated/schema/message.overheard.json +701 -0
- package/generated/schema/message.pinned.json +100 -0
- package/generated/schema/message.post.json +290 -0
- package/generated/schema/message.shown.json +100 -0
- package/generated/schema/message.unpinned.json +100 -0
- package/generated/schema/person.face_set.json +134 -0
- package/generated/schema/person.joined.json +128 -0
- package/generated/schema/person.removed.json +133 -0
- package/generated/schema/person.renamed.json +114 -0
- package/generated/schema/policy.updated.json +277 -0
- package/generated/schema/project.changed.json +199 -0
- package/generated/schema/question.answered.json +154 -0
- package/generated/schema/question.ask.json +194 -0
- package/generated/schema/receipt.json +109 -0
- package/generated/schema/relay.set.json +99 -0
- package/generated/schema/role.changed.json +116 -0
- package/generated/schema/run.cancel.json +106 -0
- package/generated/schema/run.completed.json +139 -0
- package/generated/schema/run.failed.json +135 -0
- package/generated/schema/run.pause.json +106 -0
- package/generated/schema/run.plan.json +128 -0
- package/generated/schema/run.requested.json +309 -0
- package/generated/schema/run.resume.json +106 -0
- package/generated/schema/run.started.json +142 -0
- package/generated/schema/run.status.json +120 -0
- package/generated/schema/run.steer.json +163 -0
- package/generated/schema/session.ended.json +106 -0
- package/generated/schema/session.renamed.json +108 -0
- package/generated/schema/session.started.json +116 -0
- package/generated/schema/space.claimed.json +107 -0
- package/generated/schema/space.created.json +148 -0
- package/generated/schema/space.erased.json +129 -0
- package/generated/schema/space.lead_set.json +108 -0
- package/generated/schema/space.lock_set.json +99 -0
- package/generated/schema/space.spend_ceiling_set.json +102 -0
- package/generated/schema/space.updated.json +112 -0
- package/generated/schema/step.log.json +187 -0
- package/generated/schema/task.json +268 -0
- package/generated/schema/turn.passed.json +99 -0
- package/generated/schema/usage.json +155 -0
- package/generated/schema/workspace.renamed.json +107 -0
- package/generated/types.ts +4178 -0
- package/package.json +38 -3
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's heartbeat (ADR 0143): a turn its harness starts on its own every so often, switched
|
|
3
|
+
* on or off and timed on the agent's page in Chips, and kept by its harness.
|
|
4
|
+
*
|
|
5
|
+
* Nothing about a heartbeat is Chips'. A harness that declares `heartbeats` sends a copy of each
|
|
6
|
+
* agent's: whether it is on, how often it beats in minutes, the intervals a person may pick, and
|
|
7
|
+
* whether a person may change it. Chips puts the minutes into words itself. A person's change goes
|
|
8
|
+
* down the harness's socket as a `heartbeat.change` frame, and is done when the harness sends its
|
|
9
|
+
* copy back answering it, or refused with its words.
|
|
10
|
+
*
|
|
11
|
+
* The copies live in a registry, not the log, as a model's do (ADR 0140): one row per agent,
|
|
12
|
+
* holding the last change asked of it. What a heartbeat says in a room is an ordinary message,
|
|
13
|
+
* marked `heartbeat` on `message.post`.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { id, isoTimestamp } from "./primitives.js";
|
|
17
|
+
/** The most intervals an agent's copy offers. */
|
|
18
|
+
export const HEARTBEAT_CHOICES_MAX = 12;
|
|
19
|
+
/** The longest interval, in minutes: a week. */
|
|
20
|
+
export const HEARTBEAT_EVERY_MAX = 10_080;
|
|
21
|
+
/**
|
|
22
|
+
* How long a change waits for its harness's answer: the minute a model's change has. After it the
|
|
23
|
+
* change is missed, and the person is told the harness hasn't answered; an answer after it still
|
|
24
|
+
* counts, and a new change may be asked.
|
|
25
|
+
*/
|
|
26
|
+
export const HEARTBEAT_CHANGE_WAIT_MS = 60_000;
|
|
27
|
+
const minutes = z.int().min(1).max(HEARTBEAT_EVERY_MAX);
|
|
28
|
+
const ascending = (choices) => choices.every((each, at) => at === 0 || each > (choices[at - 1] ?? 0));
|
|
29
|
+
const copyFields = {
|
|
30
|
+
on: z.boolean().describe("Whether it beats now."),
|
|
31
|
+
every: minutes.describe("How often it beats, in minutes: one of `choices`, kept while it is off."),
|
|
32
|
+
choices: z
|
|
33
|
+
.array(minutes)
|
|
34
|
+
.min(1)
|
|
35
|
+
.max(HEARTBEAT_CHOICES_MAX)
|
|
36
|
+
.refine(ascending, { message: "The intervals go up, each named once." })
|
|
37
|
+
.describe("The intervals a person may pick, in minutes, shortest first: twelve at most."),
|
|
38
|
+
editable: z.boolean().describe("Whether a person may change it from Chips."),
|
|
39
|
+
why_read_only: z
|
|
40
|
+
.string()
|
|
41
|
+
.min(1)
|
|
42
|
+
.max(120)
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Why not, in the harness's words, only when it is not `editable`."),
|
|
45
|
+
};
|
|
46
|
+
const beatsAChoice = (copy) => copy.choices.includes(copy.every);
|
|
47
|
+
const whyOnlyWhenReadOnly = (copy) => copy.why_read_only === undefined || !copy.editable;
|
|
48
|
+
export const agentHeartbeatPut = z
|
|
49
|
+
.object({
|
|
50
|
+
...copyFields,
|
|
51
|
+
answers: id("change")
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("The change this copy answers: made, and this is the agent as it is now."),
|
|
54
|
+
refuses: z
|
|
55
|
+
.object({
|
|
56
|
+
change_id: id("change"),
|
|
57
|
+
message: z.string().min(1).max(300).optional().describe("Why not, for the person."),
|
|
58
|
+
})
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("A change not made. The copy beside it is the agent as it is now."),
|
|
61
|
+
})
|
|
62
|
+
.refine(beatsAChoice, { path: ["every"], message: "`every` is one of `choices`." })
|
|
63
|
+
.refine(whyOnlyWhenReadOnly, {
|
|
64
|
+
path: ["why_read_only"],
|
|
65
|
+
message: "Say why only for a heartbeat that can't be changed.",
|
|
66
|
+
})
|
|
67
|
+
.describe("`PUT /v1/agents/:id/heartbeat`: a harness's copy of one of its agents' heartbeat.");
|
|
68
|
+
export const heartbeatChangeAsk = z
|
|
69
|
+
.object({
|
|
70
|
+
on: z.boolean().describe("Whether it is to beat."),
|
|
71
|
+
every: minutes
|
|
72
|
+
.optional()
|
|
73
|
+
.describe("How often, one of `choices`. Left out: the copy's own `every`."),
|
|
74
|
+
})
|
|
75
|
+
.describe("`POST /v1/agents/:id/heartbeat/changes`: on or off, and how often.");
|
|
76
|
+
export const HEARTBEAT_CHANGE_STATES = ["waiting", "saved", "failed", "missed"];
|
|
77
|
+
export const heartbeatChangeState = z.enum(HEARTBEAT_CHANGE_STATES);
|
|
78
|
+
export const heartbeatChangeView = z
|
|
79
|
+
.object({
|
|
80
|
+
change_id: id("change"),
|
|
81
|
+
state: heartbeatChangeState.describe("`missed` once `HEARTBEAT_CHANGE_WAIT_MS` has passed with no answer; read, never stored."),
|
|
82
|
+
on: z.boolean(),
|
|
83
|
+
every: minutes,
|
|
84
|
+
asked_at: isoTimestamp,
|
|
85
|
+
answered_at: isoTimestamp.optional(),
|
|
86
|
+
message: z.string().max(300).optional().describe("The harness's words, for a refusal."),
|
|
87
|
+
})
|
|
88
|
+
.describe("The last change a person asked of an agent's heartbeat, and what became of it (ADR 0143).");
|
|
89
|
+
export const agentHeartbeatView = z
|
|
90
|
+
.object({
|
|
91
|
+
agent_id: id("agent"),
|
|
92
|
+
harness_id: id("harness"),
|
|
93
|
+
...copyFields,
|
|
94
|
+
read_at: isoTimestamp.describe("When the harness last sent its copy."),
|
|
95
|
+
away: z.boolean().describe("No socket of the harness hears changes now: read, not changed."),
|
|
96
|
+
change: heartbeatChangeView.optional(),
|
|
97
|
+
})
|
|
98
|
+
.describe("`GET /v1/agents/:id/heartbeat`, for the harness's owner or an admin.");
|
|
99
|
+
export const heartbeatChangeFrame = z
|
|
100
|
+
.object({
|
|
101
|
+
frame: z.literal("heartbeat.change"),
|
|
102
|
+
change_id: id("change"),
|
|
103
|
+
harness_id: id("harness"),
|
|
104
|
+
agent_id: id("agent"),
|
|
105
|
+
on: z.boolean(),
|
|
106
|
+
every: minutes.describe("One of the copy's `choices`: the copy's own when the person named none."),
|
|
107
|
+
asked_by: id("person"),
|
|
108
|
+
asked_at: isoTimestamp,
|
|
109
|
+
})
|
|
110
|
+
.describe("A person switched an agent's heartbeat or changed how often it beats (ADR 0143). Sent to a harness's socket that said `heartbeats` in its `hello`, now or never: it is not in the log. The harness answers with the agent's copy, `answers` or `refuses` naming `change_id`.");
|
|
111
|
+
//# sourceMappingURL=agent-heartbeats.js.map
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sE,CAAC,CAAC;AAGpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;IACpC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC;IACvB,UAAU,EAAE,EAAE,CAAC,SAAS,CAAC;IACzB,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC;IACrB,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;IACf,KAAK,EAAE,OAAO,CAAC,QAAQ,CACrB,yEAAyE,CAC1E;IACD,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC;IACtB,QAAQ,EAAE,YAAY;CACvB,CAAC;KACD,QAAQ,CACP,8QAA8Q,CAC/Q,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's model and effort (ADR 0140): what it runs on and how hard it thinks, chosen on its
|
|
3
|
+
* page in Chips and kept by its harness.
|
|
4
|
+
*
|
|
5
|
+
* Nothing about a model is Chips'. A harness that declares `models` sends a copy of each agent's:
|
|
6
|
+
* the model it runs on now and its effort, whether those are its own or the harness's default for
|
|
7
|
+
* it ("Same as J"), the models it may run on, each with its effort levels, lowest first, and every
|
|
8
|
+
* word a page shows for them. A person's change goes down the harness's socket as a `model.change`
|
|
9
|
+
* frame, and is done when the harness sends its copy back answering it, or refused with its words.
|
|
10
|
+
*
|
|
11
|
+
* The copies live in a registry, not the log, as context files do (ADR 0134): one row per agent,
|
|
12
|
+
* holding the last change asked of it.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
/** The most models an agent's copy offers. A harness sends the ones worth choosing. */
|
|
16
|
+
export declare const MODEL_CHOICES_MAX = 40;
|
|
17
|
+
/** The most effort levels a model has, one bar each. A harness sends its most useful eight. */
|
|
18
|
+
export declare const EFFORT_LEVELS_MAX = 8;
|
|
19
|
+
/**
|
|
20
|
+
* How long a change waits for its harness's answer: the minute a context edit has. After it the
|
|
21
|
+
* change is missed, and the person is told the harness hasn't answered; an answer after it still
|
|
22
|
+
* counts, and a new change may be asked.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MODEL_CHANGE_WAIT_MS = 60000;
|
|
25
|
+
export declare const effortLevel: z.ZodObject<{
|
|
26
|
+
id: z.ZodString;
|
|
27
|
+
label: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type EffortLevel = z.infer<typeof effortLevel>;
|
|
30
|
+
export declare const modelChoice: z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
label: z.ZodString;
|
|
33
|
+
efforts: z.ZodArray<z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
label: z.ZodString;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
effort_default: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export type ModelChoice = z.infer<typeof modelChoice>;
|
|
40
|
+
/** Whether `effort` is a level of the model `model` names among `choices`: absent for none. */
|
|
41
|
+
export declare function effortFits(choices: readonly ModelChoice[], model: string, effort: string | undefined): boolean;
|
|
42
|
+
export declare const modelDefault: z.ZodObject<{
|
|
43
|
+
label: z.ZodString;
|
|
44
|
+
model: z.ZodString;
|
|
45
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type ModelDefault = z.infer<typeof modelDefault>;
|
|
48
|
+
export declare const agentModelPut: z.ZodObject<{
|
|
49
|
+
answers: z.ZodOptional<z.ZodString>;
|
|
50
|
+
refuses: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
change_id: z.ZodString;
|
|
52
|
+
message: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
model: z.ZodString;
|
|
55
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
56
|
+
own: z.ZodBoolean;
|
|
57
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
label: z.ZodString;
|
|
59
|
+
model: z.ZodString;
|
|
60
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
efforts: z.ZodArray<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
label: z.ZodString;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
effort_default: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
editable: z.ZodBoolean;
|
|
72
|
+
why_read_only: z.ZodOptional<z.ZodString>;
|
|
73
|
+
followed_by: z.ZodOptional<z.ZodInt>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type AgentModelPut = z.infer<typeof agentModelPut>;
|
|
76
|
+
/** The copy as Chips keeps it: what the harness sent, without what it answered. */
|
|
77
|
+
export type AgentModelCopy = Omit<AgentModelPut, "answers" | "refuses">;
|
|
78
|
+
export declare const modelChangeAsk: z.ZodObject<{
|
|
79
|
+
model: z.ZodNullable<z.ZodString>;
|
|
80
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export type ModelChangeAsk = z.infer<typeof modelChangeAsk>;
|
|
83
|
+
export declare const MODEL_CHANGE_STATES: readonly ["waiting", "saved", "failed", "missed"];
|
|
84
|
+
export declare const modelChangeState: z.ZodEnum<{
|
|
85
|
+
waiting: "waiting";
|
|
86
|
+
saved: "saved";
|
|
87
|
+
failed: "failed";
|
|
88
|
+
missed: "missed";
|
|
89
|
+
}>;
|
|
90
|
+
export type ModelChangeState = z.infer<typeof modelChangeState>;
|
|
91
|
+
export declare const modelChangeView: z.ZodObject<{
|
|
92
|
+
change_id: z.ZodString;
|
|
93
|
+
state: z.ZodEnum<{
|
|
94
|
+
waiting: "waiting";
|
|
95
|
+
saved: "saved";
|
|
96
|
+
failed: "failed";
|
|
97
|
+
missed: "missed";
|
|
98
|
+
}>;
|
|
99
|
+
model: z.ZodNullable<z.ZodString>;
|
|
100
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
101
|
+
asked_at: z.ZodISODateTime;
|
|
102
|
+
answered_at: z.ZodOptional<z.ZodISODateTime>;
|
|
103
|
+
message: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export type ModelChangeView = z.infer<typeof modelChangeView>;
|
|
106
|
+
export declare const agentModelView: z.ZodObject<{
|
|
107
|
+
read_at: z.ZodISODateTime;
|
|
108
|
+
away: z.ZodBoolean;
|
|
109
|
+
change: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
change_id: z.ZodString;
|
|
111
|
+
state: z.ZodEnum<{
|
|
112
|
+
waiting: "waiting";
|
|
113
|
+
saved: "saved";
|
|
114
|
+
failed: "failed";
|
|
115
|
+
missed: "missed";
|
|
116
|
+
}>;
|
|
117
|
+
model: z.ZodNullable<z.ZodString>;
|
|
118
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
119
|
+
asked_at: z.ZodISODateTime;
|
|
120
|
+
answered_at: z.ZodOptional<z.ZodISODateTime>;
|
|
121
|
+
message: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
model: z.ZodString;
|
|
124
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
125
|
+
own: z.ZodBoolean;
|
|
126
|
+
default: z.ZodOptional<z.ZodObject<{
|
|
127
|
+
label: z.ZodString;
|
|
128
|
+
model: z.ZodString;
|
|
129
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
130
|
+
}, z.core.$strip>>;
|
|
131
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
132
|
+
id: z.ZodString;
|
|
133
|
+
label: z.ZodString;
|
|
134
|
+
efforts: z.ZodArray<z.ZodObject<{
|
|
135
|
+
id: z.ZodString;
|
|
136
|
+
label: z.ZodString;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
effort_default: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>>;
|
|
140
|
+
editable: z.ZodBoolean;
|
|
141
|
+
why_read_only: z.ZodOptional<z.ZodString>;
|
|
142
|
+
followed_by: z.ZodOptional<z.ZodInt>;
|
|
143
|
+
agent_id: z.ZodString;
|
|
144
|
+
harness_id: z.ZodString;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
export type AgentModelView = z.infer<typeof agentModelView>;
|
|
147
|
+
export declare const modelChangeFrame: z.ZodObject<{
|
|
148
|
+
frame: z.ZodLiteral<"model.change">;
|
|
149
|
+
change_id: z.ZodString;
|
|
150
|
+
harness_id: z.ZodString;
|
|
151
|
+
agent_id: z.ZodString;
|
|
152
|
+
model: z.ZodNullable<z.ZodString>;
|
|
153
|
+
effort: z.ZodNullable<z.ZodString>;
|
|
154
|
+
asked_by: z.ZodString;
|
|
155
|
+
asked_at: z.ZodISODateTime;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
export type ModelChangeFrame = z.infer<typeof modelChangeFrame>;
|
|
158
|
+
//# sourceMappingURL=agent-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-models.d.ts","sourceRoot":"","sources":["../../src/agent-models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,uFAAuF;AACvF,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAM3C,eAAO,MAAM,WAAW;;;iBAKuD,CAAC;AAChF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO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MAAM,gBAAgB;;;;;;;;;iBAa1B,CAAC;AACJ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's model and effort (ADR 0140): what it runs on and how hard it thinks, chosen on its
|
|
3
|
+
* page in Chips and kept by its harness.
|
|
4
|
+
*
|
|
5
|
+
* Nothing about a model is Chips'. A harness that declares `models` sends a copy of each agent's:
|
|
6
|
+
* the model it runs on now and its effort, whether those are its own or the harness's default for
|
|
7
|
+
* it ("Same as J"), the models it may run on, each with its effort levels, lowest first, and every
|
|
8
|
+
* word a page shows for them. A person's change goes down the harness's socket as a `model.change`
|
|
9
|
+
* frame, and is done when the harness sends its copy back answering it, or refused with its words.
|
|
10
|
+
*
|
|
11
|
+
* The copies live in a registry, not the log, as context files do (ADR 0134): one row per agent,
|
|
12
|
+
* holding the last change asked of it.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { id, isoTimestamp } from "./primitives.js";
|
|
16
|
+
/** The most models an agent's copy offers. A harness sends the ones worth choosing. */
|
|
17
|
+
export const MODEL_CHOICES_MAX = 40;
|
|
18
|
+
/** The most effort levels a model has, one bar each. A harness sends its most useful eight. */
|
|
19
|
+
export const EFFORT_LEVELS_MAX = 8;
|
|
20
|
+
/**
|
|
21
|
+
* How long a change waits for its harness's answer: the minute a context edit has. After it the
|
|
22
|
+
* change is missed, and the person is told the harness hasn't answered; an answer after it still
|
|
23
|
+
* counts, and a new change may be asked.
|
|
24
|
+
*/
|
|
25
|
+
export const MODEL_CHANGE_WAIT_MS = 60_000;
|
|
26
|
+
const modelId = z.string().min(1).max(200);
|
|
27
|
+
const effortId = z.string().min(1).max(64);
|
|
28
|
+
const label = z.string().min(1).max(80);
|
|
29
|
+
export const effortLevel = z
|
|
30
|
+
.object({
|
|
31
|
+
id: effortId.describe("The harness's own word for it: `high`."),
|
|
32
|
+
label: z.string().min(1).max(40).describe("What its bar says: `High`."),
|
|
33
|
+
})
|
|
34
|
+
.describe("One effort level of a model, as its harness names it (ADR 0140).");
|
|
35
|
+
export const modelChoice = z
|
|
36
|
+
.object({
|
|
37
|
+
id: modelId.describe("The harness's own id for the model: `heron-2`, `lathe/heron-2`."),
|
|
38
|
+
label: label.describe("What its row says: `Heron 2`."),
|
|
39
|
+
efforts: z
|
|
40
|
+
.array(effortLevel)
|
|
41
|
+
.max(EFFORT_LEVELS_MAX)
|
|
42
|
+
.refine((levels) => new Set(levels.map((level) => level.id)).size === levels.length, {
|
|
43
|
+
message: "Each level is named once.",
|
|
44
|
+
})
|
|
45
|
+
.describe("Its effort levels, lowest first: eight at most, none for a model without any."),
|
|
46
|
+
effort_default: effortId
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("The level it runs at when none is set, if the harness knows it."),
|
|
49
|
+
})
|
|
50
|
+
.refine((choice) => choice.effort_default === undefined ||
|
|
51
|
+
choice.efforts.some((level) => level.id === choice.effort_default), { message: "A model's default level is one of its levels." })
|
|
52
|
+
.describe("One model an agent may run on (ADR 0140).");
|
|
53
|
+
/** Whether `effort` is a level of the model `model` names among `choices`: absent for none. */
|
|
54
|
+
export function effortFits(choices, model, effort) {
|
|
55
|
+
const choice = choices.find((each) => each.id === model);
|
|
56
|
+
if (choice === undefined)
|
|
57
|
+
return false;
|
|
58
|
+
if (effort === undefined)
|
|
59
|
+
return true;
|
|
60
|
+
return choice.efforts.some((level) => level.id === effort);
|
|
61
|
+
}
|
|
62
|
+
export const modelDefault = z
|
|
63
|
+
.object({
|
|
64
|
+
label: label.describe("What the switch says: `Same as J`, `Lathe's default`."),
|
|
65
|
+
model: modelId,
|
|
66
|
+
effort: effortId.optional(),
|
|
67
|
+
})
|
|
68
|
+
.describe("What an agent runs on with no model or effort of its own (ADR 0140).");
|
|
69
|
+
const copyFields = {
|
|
70
|
+
model: modelId.describe("The model it runs on now: an id among `choices`."),
|
|
71
|
+
effort: effortId
|
|
72
|
+
.optional()
|
|
73
|
+
.describe("The level it runs at now: one of its model's. Absent when its model has none."),
|
|
74
|
+
own: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.describe("It has a model or an effort of its own. `false`: it runs on `default`."),
|
|
77
|
+
default: modelDefault
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("What it runs on with none of its own. Absent: there is no Same as switch."),
|
|
80
|
+
choices: z
|
|
81
|
+
.array(modelChoice)
|
|
82
|
+
.min(1)
|
|
83
|
+
.max(MODEL_CHOICES_MAX)
|
|
84
|
+
.refine((choices) => new Set(choices.map((choice) => choice.id)).size === choices.length, {
|
|
85
|
+
message: "Each model is named once.",
|
|
86
|
+
})
|
|
87
|
+
.describe("The models it may run on: forty at most, its own among them."),
|
|
88
|
+
editable: z.boolean().describe("Whether a person may change it from Chips."),
|
|
89
|
+
why_read_only: z
|
|
90
|
+
.string()
|
|
91
|
+
.min(1)
|
|
92
|
+
.max(120)
|
|
93
|
+
.optional()
|
|
94
|
+
.describe("Why not, in the harness's words: `Lathe's own agent. Change it in Lathe.`"),
|
|
95
|
+
followed_by: z
|
|
96
|
+
.int()
|
|
97
|
+
.nonnegative()
|
|
98
|
+
.optional()
|
|
99
|
+
.describe("How many agents have none of their own and run on this one's."),
|
|
100
|
+
};
|
|
101
|
+
const runsOnAChoice = (copy) => effortFits(copy.choices, copy.model, copy.effort);
|
|
102
|
+
const defaultIsAChoice = (copy) => copy.default === undefined || effortFits(copy.choices, copy.default.model, copy.default.effort);
|
|
103
|
+
export const agentModelPut = z
|
|
104
|
+
.object({
|
|
105
|
+
...copyFields,
|
|
106
|
+
answers: id("change")
|
|
107
|
+
.optional()
|
|
108
|
+
.describe("The change this copy answers: made, and this is the agent as it is now."),
|
|
109
|
+
refuses: z
|
|
110
|
+
.object({
|
|
111
|
+
change_id: id("change"),
|
|
112
|
+
message: z.string().min(1).max(300).optional().describe("Why not, for the person."),
|
|
113
|
+
})
|
|
114
|
+
.optional()
|
|
115
|
+
.describe("A change not made. The copy beside it is the agent as it is now."),
|
|
116
|
+
})
|
|
117
|
+
.refine(runsOnAChoice, {
|
|
118
|
+
path: ["model"],
|
|
119
|
+
message: "The model is one of `choices`, and its effort one of that model's levels.",
|
|
120
|
+
})
|
|
121
|
+
.refine(defaultIsAChoice, {
|
|
122
|
+
path: ["default"],
|
|
123
|
+
message: "The default's model is one of `choices`, and its effort one of that model's.",
|
|
124
|
+
})
|
|
125
|
+
.describe("`PUT /v1/agents/:id/model`: a harness's copy of one of its agents' model and effort.");
|
|
126
|
+
export const modelChangeAsk = z
|
|
127
|
+
.object({
|
|
128
|
+
model: modelId
|
|
129
|
+
.nullable()
|
|
130
|
+
.describe("The model to run on, one of `choices`. `null`, with `effort`: the default's."),
|
|
131
|
+
effort: effortId
|
|
132
|
+
.nullable()
|
|
133
|
+
.describe("One of that model's levels; `null` for a model with none, or for the default."),
|
|
134
|
+
})
|
|
135
|
+
.describe("`POST /v1/agents/:id/model/changes`: both of its own, or both the default's.");
|
|
136
|
+
export const MODEL_CHANGE_STATES = ["waiting", "saved", "failed", "missed"];
|
|
137
|
+
export const modelChangeState = z.enum(MODEL_CHANGE_STATES);
|
|
138
|
+
export const modelChangeView = z
|
|
139
|
+
.object({
|
|
140
|
+
change_id: id("change"),
|
|
141
|
+
state: modelChangeState.describe("`missed` once `MODEL_CHANGE_WAIT_MS` has passed with no answer; read, never stored."),
|
|
142
|
+
model: modelId.nullable(),
|
|
143
|
+
effort: effortId.nullable(),
|
|
144
|
+
asked_at: isoTimestamp,
|
|
145
|
+
answered_at: isoTimestamp.optional(),
|
|
146
|
+
message: z.string().max(300).optional().describe("The harness's words, for a refusal."),
|
|
147
|
+
})
|
|
148
|
+
.describe("The last change a person asked of an agent's model, and what became of it (ADR 0140).");
|
|
149
|
+
export const agentModelView = z
|
|
150
|
+
.object({
|
|
151
|
+
agent_id: id("agent"),
|
|
152
|
+
harness_id: id("harness"),
|
|
153
|
+
...copyFields,
|
|
154
|
+
read_at: isoTimestamp.describe("When the harness last sent its copy."),
|
|
155
|
+
away: z.boolean().describe("No socket of the harness hears changes now: read, not changed."),
|
|
156
|
+
change: modelChangeView.optional(),
|
|
157
|
+
})
|
|
158
|
+
.describe("`GET /v1/agents/:id/model`, for the harness's owner or an admin.");
|
|
159
|
+
export const modelChangeFrame = z
|
|
160
|
+
.object({
|
|
161
|
+
frame: z.literal("model.change"),
|
|
162
|
+
change_id: id("change"),
|
|
163
|
+
harness_id: id("harness"),
|
|
164
|
+
agent_id: id("agent"),
|
|
165
|
+
model: modelId.nullable().describe("`null`, with `effort`: no model of its own, the default."),
|
|
166
|
+
effort: effortId.nullable(),
|
|
167
|
+
asked_by: id("person"),
|
|
168
|
+
asked_at: isoTimestamp,
|
|
169
|
+
})
|
|
170
|
+
.describe("A person changed an agent's model or effort (ADR 0140). Sent to a harness's socket that said `models` in its `hello`, now or never: it is not in the log. The harness answers with the agent's copy, `answers` or `refuses` naming `change_id`.");
|
|
171
|
+
//# sourceMappingURL=agent-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-models.js","sourceRoot":"","sources":["../../src/agent-models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnD,uFAAuF;AACvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EA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at a time. Nine paths put an agent in a room: a person's add, a move, an
|
|
5
|
+
* unarchive, a room opened or claimed by key, a harness's attach, a fork's copy, a hand-off's
|
|
6
|
+
* home, an agent's first words, and the answer to a room asked of several. Each used to read where
|
|
7
|
+
* the agent was and then write, with its own version of the rule or none. Two at once, or a path
|
|
8
|
+
* that did not ask, left an agent in two rooms.
|
|
9
|
+
*
|
|
10
|
+
* The rule is this function. The store asks it inside the append's transaction, of every event
|
|
11
|
+
* that puts an agent in a room, whichever path wrote it: that is what makes it hold. The door asks
|
|
12
|
+
* it first, with the same facts, so a person is told why before anything is written. It lives
|
|
13
|
+
* with the protocol so that the conformance fake asks the same function, and cannot differ.
|
|
14
|
+
*
|
|
15
|
+
* What it says:
|
|
16
|
+
*
|
|
17
|
+
* - the room is there, and open: an archived room takes no agent until it is unarchived;
|
|
18
|
+
* - a Main room takes people and its Main agent, and no other agent;
|
|
19
|
+
* - the Main agent's place in its Main room is not taken by another;
|
|
20
|
+
* - a deleted agent is in no room again (ADR 0095);
|
|
21
|
+
* - the agent is in no other room, open or archived. An archived room's agents are released as it
|
|
22
|
+
* is archived, so one still in such a room is one whose release has not been written yet, and it
|
|
23
|
+
* is not put anywhere else until it has.
|
|
24
|
+
*
|
|
25
|
+
* What it leaves to the door, because Chips itself may do it: a Main agent put in a room that is
|
|
26
|
+
* not a Main room yet (its harness opens the room, then names it its home), and an agent archived
|
|
27
|
+
* in its harness (an unarchive brings back whoever the archive released).
|
|
28
|
+
*/
|
|
29
|
+
/** Why an agent may not be put in a room: the rule, in words, and where the agent is. */
|
|
30
|
+
export interface PlaceRefusal {
|
|
31
|
+
readonly kind: "unknown_space" | "lead_room" | "room_closed" | "agent_elsewhere" | "agent_deleted";
|
|
32
|
+
readonly message: string;
|
|
33
|
+
/** For `agent_elsewhere`: the room the agent is in, where a client offers Move. */
|
|
34
|
+
readonly space_id?: string | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** A room as the rule needs it. */
|
|
37
|
+
export interface PlaceRoom {
|
|
38
|
+
readonly space_id: string;
|
|
39
|
+
readonly state: string;
|
|
40
|
+
/** A harness's home (ADR 0069): the Main room of its Main agent. */
|
|
41
|
+
readonly home: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface AgentPlacement {
|
|
44
|
+
/** The agent to be put in the room; `deleted` when a person deleted it (ADR 0095). */
|
|
45
|
+
readonly agent: {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly lead: boolean;
|
|
48
|
+
readonly deleted?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** The room, or `null` when there is none by that id: erased, or never there. */
|
|
51
|
+
readonly room: PlaceRoom | null;
|
|
52
|
+
/** A room the agent is a member of now that is not this one, open or archived; `null`: none. */
|
|
53
|
+
readonly elsewhere: string | null;
|
|
54
|
+
/** How many agents the room holds already, less this one and the one whose place it takes. */
|
|
55
|
+
readonly others: number;
|
|
56
|
+
/** True when it takes the place of a Main agent: a harness's attach, in its Main room. */
|
|
57
|
+
readonly replacesLead: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Why this agent may not be put in this room, or nothing when it may. */
|
|
60
|
+
export declare function refuseAgentInto(placement: AgentPlacement): PlaceRefusal | undefined;
|
|
61
|
+
/** Why an agent left a room, as `agent.released` says it. */
|
|
62
|
+
type LeftBecause = "archived" | "deleted" | "moved" | "agent_archived" | "removed" | "agent_deleted";
|
|
63
|
+
/**
|
|
64
|
+
* What a run is told when its agent leaves the room it was working in, by why it left (agents
|
|
65
|
+
* review, findings 10 and 12): the `reason` on the `run.cancel` that stops it. Leaving a room
|
|
66
|
+
* stops the work, whatever the reason.
|
|
67
|
+
*/
|
|
68
|
+
export declare const STOPPED_BECAUSE: Readonly<Record<LeftBecause, string>>;
|
|
69
|
+
/**
|
|
70
|
+
* The refusals an `error` frame names in `refusal`, for a client that offers a way on (ADR 0087):
|
|
71
|
+
* Move for an agent that is elsewhere, Unarchive for a room that is archived, and words for the
|
|
72
|
+
* other two. The server's socket and the conformance fake's both read this list.
|
|
73
|
+
*/
|
|
74
|
+
export declare const ONE_ROOM_REFUSALS: ReadonlySet<string>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=agent-place.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-place.d.ts","sourceRoot":"","sources":["../../src/agent-place.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EACT,eAAe,GACf,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,eAAe,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5F,iFAAiF;IACjF,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,gGAAgG;IAChG,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;CAChC;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,SAAS,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAuBnF;AAED,6DAA6D;AAC7D,KAAK,WAAW,GACZ,UAAU,GACV,SAAS,GACT,OAAO,GACP,gBAAgB,GAChB,SAAS,GACT,eAAe,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAOjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAMhD,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an agent may be (ADR 0087, rules 1 and 7), in one place (agents review, findings 5 to 8).
|
|
3
|
+
*
|
|
4
|
+
* An agent is in one room at a time. Nine paths put an agent in a room: a person's add, a move, an
|
|
5
|
+
* unarchive, a room opened or claimed by key, a harness's attach, a fork's copy, a hand-off's
|
|
6
|
+
* home, an agent's first words, and the answer to a room asked of several. Each used to read where
|
|
7
|
+
* the agent was and then write, with its own version of the rule or none. Two at once, or a path
|
|
8
|
+
* that did not ask, left an agent in two rooms.
|
|
9
|
+
*
|
|
10
|
+
* The rule is this function. The store asks it inside the append's transaction, of every event
|
|
11
|
+
* that puts an agent in a room, whichever path wrote it: that is what makes it hold. The door asks
|
|
12
|
+
* it first, with the same facts, so a person is told why before anything is written. It lives
|
|
13
|
+
* with the protocol so that the conformance fake asks the same function, and cannot differ.
|
|
14
|
+
*
|
|
15
|
+
* What it says:
|
|
16
|
+
*
|
|
17
|
+
* - the room is there, and open: an archived room takes no agent until it is unarchived;
|
|
18
|
+
* - a Main room takes people and its Main agent, and no other agent;
|
|
19
|
+
* - the Main agent's place in its Main room is not taken by another;
|
|
20
|
+
* - a deleted agent is in no room again (ADR 0095);
|
|
21
|
+
* - the agent is in no other room, open or archived. An archived room's agents are released as it
|
|
22
|
+
* is archived, so one still in such a room is one whose release has not been written yet, and it
|
|
23
|
+
* is not put anywhere else until it has.
|
|
24
|
+
*
|
|
25
|
+
* What it leaves to the door, because Chips itself may do it: a Main agent put in a room that is
|
|
26
|
+
* not a Main room yet (its harness opens the room, then names it its home), and an agent archived
|
|
27
|
+
* in its harness (an unarchive brings back whoever the archive released).
|
|
28
|
+
*/
|
|
29
|
+
/** Why this agent may not be put in this room, or nothing when it may. */
|
|
30
|
+
export function refuseAgentInto(placement) {
|
|
31
|
+
const { agent, room, elsewhere } = placement;
|
|
32
|
+
if (agent.deleted === true) {
|
|
33
|
+
return { kind: "agent_deleted", message: "that agent was deleted" };
|
|
34
|
+
}
|
|
35
|
+
if (room === null)
|
|
36
|
+
return { kind: "unknown_space", message: "no such space in this workspace" };
|
|
37
|
+
if (room.home && (!agent.lead || placement.others > 0)) {
|
|
38
|
+
return { kind: "lead_room", message: "a Main space takes people, and no other agent" };
|
|
39
|
+
}
|
|
40
|
+
if (room.home && placement.replacesLead) {
|
|
41
|
+
return { kind: "lead_room", message: "the Main agent stays in its Main space" };
|
|
42
|
+
}
|
|
43
|
+
if (room.state === "closed") {
|
|
44
|
+
return { kind: "room_closed", message: "that space is archived: unarchive it first" };
|
|
45
|
+
}
|
|
46
|
+
if (elsewhere !== null) {
|
|
47
|
+
return {
|
|
48
|
+
kind: "agent_elsewhere",
|
|
49
|
+
message: "that agent is in another space: move it, or pick another",
|
|
50
|
+
space_id: elsewhere,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What a run is told when its agent leaves the room it was working in, by why it left (agents
|
|
57
|
+
* review, findings 10 and 12): the `reason` on the `run.cancel` that stops it. Leaving a room
|
|
58
|
+
* stops the work, whatever the reason.
|
|
59
|
+
*/
|
|
60
|
+
export const STOPPED_BECAUSE = {
|
|
61
|
+
archived: "The space was archived.",
|
|
62
|
+
deleted: "The space was deleted.",
|
|
63
|
+
moved: "The agent was moved to another space.",
|
|
64
|
+
agent_archived: "The agent was archived.",
|
|
65
|
+
removed: "The agent was taken out of the space.",
|
|
66
|
+
agent_deleted: "The agent was deleted.",
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The refusals an `error` frame names in `refusal`, for a client that offers a way on (ADR 0087):
|
|
70
|
+
* Move for an agent that is elsewhere, Unarchive for a room that is archived, and words for the
|
|
71
|
+
* other two. The server's socket and the conformance fake's both read this list.
|
|
72
|
+
*/
|
|
73
|
+
export const ONE_ROOM_REFUSALS = new Set([
|
|
74
|
+
"agent_elsewhere",
|
|
75
|
+
"lead_room",
|
|
76
|
+
"agent_archived",
|
|
77
|
+
"room_closed",
|
|
78
|
+
"agent_deleted",
|
|
79
|
+
]);
|
|
80
|
+
//# sourceMappingURL=agent-place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-place.js","sourceRoot":"","sources":["../../src/agent-place.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAoCH,0EAA0E;AAC1E,MAAM,UAAU,eAAe,CAAC,SAAyB;IACvD,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;IAC7C,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC;IACtE,CAAC;IACD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iCAAiC,EAAE,CAAC;IAChG,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QACvD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,+CAA+C,EAAE,CAAC;IACzF,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,YA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