@songsid/agend 2.4.0-alpha.3 → 2.4.0-alpha.4
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/dist/agent-cli-instructions.md +8 -4
- package/dist/agent-whats-new.js +7 -7
- package/dist/agent-whats-new.js.map +1 -1
- package/dist/auth-api.js +7 -1
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.d.ts +8 -0
- package/dist/backend/claude-code.js +11 -4
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex.js +7 -3
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok.d.ts +19 -0
- package/dist/backend/grok.js +112 -1
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +10 -0
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-tools.js +2 -2
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/child-process.d.ts +1 -0
- package/dist/child-process.js.map +1 -1
- package/dist/claude-model-observation.d.ts +71 -0
- package/dist/claude-model-observation.js +169 -0
- package/dist/claude-model-observation.js.map +1 -0
- package/dist/cross-instance-envelope.d.ts +4 -1
- package/dist/cross-instance-envelope.js +12 -7
- package/dist/cross-instance-envelope.js.map +1 -1
- package/dist/daemon.d.ts +24 -2
- package/dist/daemon.js +263 -35
- package/dist/daemon.js.map +1 -1
- package/dist/delivery-consumed-watch.d.ts +24 -0
- package/dist/delivery-consumed-watch.js +21 -10
- package/dist/delivery-consumed-watch.js.map +1 -1
- package/dist/delivery-outbox.d.ts +5 -1
- package/dist/delivery-outbox.js +5 -0
- package/dist/delivery-outbox.js.map +1 -1
- package/dist/fleet-manager.d.ts +11 -1
- package/dist/fleet-manager.js +80 -2
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +16 -3
- package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +5 -3
- package/dist/general-knowledge/skills/hub/SKILL.md +161 -4
- package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -1
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +18 -7
- package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +1 -1
- package/dist/grok-delivery-proof.d.ts +24 -0
- package/dist/grok-delivery-proof.js +124 -0
- package/dist/grok-delivery-proof.js.map +1 -0
- package/dist/hub/assistant/admin-types.d.ts +43 -0
- package/dist/hub/assistant/admin-types.js +2 -0
- package/dist/hub/assistant/admin-types.js.map +1 -0
- package/dist/hub/assistant/claude-host.d.ts +17 -0
- package/dist/hub/assistant/claude-host.js +300 -0
- package/dist/hub/assistant/claude-host.js.map +1 -0
- package/dist/hub/assistant/context.d.ts +3 -0
- package/dist/hub/assistant/context.js +7 -0
- package/dist/hub/assistant/context.js.map +1 -0
- package/dist/hub/assistant/fleet-host.d.ts +19 -0
- package/dist/hub/assistant/fleet-host.js +28 -0
- package/dist/hub/assistant/fleet-host.js.map +1 -0
- package/dist/hub/assistant/runner.d.ts +64 -0
- package/dist/hub/assistant/runner.js +239 -0
- package/dist/hub/assistant/runner.js.map +1 -0
- package/dist/hub/assistant/service.d.ts +51 -0
- package/dist/hub/assistant/service.js +143 -0
- package/dist/hub/assistant/service.js.map +1 -0
- package/dist/hub/assistant/store.d.ts +3 -0
- package/dist/hub/assistant/store.js +65 -0
- package/dist/hub/assistant/store.js.map +1 -0
- package/dist/hub/assistant/types.d.ts +60 -0
- package/dist/hub/assistant/types.js +2 -0
- package/dist/hub/assistant/types.js.map +1 -0
- package/dist/hub/catalog.js +22 -3
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +10 -0
- package/dist/hub/client.js +48 -8
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +8 -1
- package/dist/hub/compose/member.js +224 -58
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +11 -1
- package/dist/hub/compose/server.js +68 -11
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/admission.d.ts +15 -0
- package/dist/hub/directory/admission.js +56 -0
- package/dist/hub/directory/admission.js.map +1 -0
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +63 -0
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/types.d.ts +13 -0
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/admin-control.d.ts +1 -0
- package/dist/hub/group-policy/admin-control.js +4 -2
- package/dist/hub/group-policy/admin-control.js.map +1 -1
- package/dist/hub/group-policy/admin-facts.d.ts +1 -0
- package/dist/hub/group-policy/admin-facts.js +2 -1
- package/dist/hub/group-policy/admin-facts.js.map +1 -1
- package/dist/hub/group-policy/admin-read.d.ts +1 -0
- package/dist/hub/group-policy/admin-read.js +3 -2
- package/dist/hub/group-policy/admin-read.js.map +1 -1
- package/dist/hub/group-policy/errors.d.ts +9 -0
- package/dist/hub/group-policy/errors.js +13 -0
- package/dist/hub/group-policy/errors.js.map +1 -0
- package/dist/hub/group-policy/store.d.ts +3 -9
- package/dist/hub/group-policy/store.js +5 -29
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/http/compose.d.ts +1 -0
- package/dist/hub/http/compose.js +429 -14
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +6 -5
- package/dist/hub/http/core.js +74 -48
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +18 -0
- package/dist/hub/http/schema.js +8 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/init/member-certificate.d.ts +1 -0
- package/dist/hub/init/member-certificate.js +39 -0
- package/dist/hub/init/member-certificate.js.map +1 -0
- package/dist/hub/init/plan-digest.js +1 -0
- package/dist/hub/init/plan-digest.js.map +1 -1
- package/dist/hub/invitations.d.ts +96 -0
- package/dist/hub/invitations.js +292 -0
- package/dist/hub/invitations.js.map +1 -0
- package/dist/hub/join/certificate-trust.d.ts +13 -0
- package/dist/hub/join/certificate-trust.js +41 -0
- package/dist/hub/join/certificate-trust.js.map +1 -0
- package/dist/hub/join/certificate.d.ts +11 -0
- package/dist/hub/join/certificate.js +67 -0
- package/dist/hub/join/certificate.js.map +1 -0
- package/dist/hub/join/client.d.ts +5 -0
- package/dist/hub/join/client.js +30 -3
- package/dist/hub/join/client.js.map +1 -1
- package/dist/hub/join/http.js +5 -3
- package/dist/hub/join/http.js.map +1 -1
- package/dist/hub/join/local.d.ts +32 -1
- package/dist/hub/join/local.js +116 -11
- package/dist/hub/join/local.js.map +1 -1
- package/dist/hub/join/service.d.ts +17 -0
- package/dist/hub/join/service.js +12 -0
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/join/trust.d.ts +9 -0
- package/dist/hub/join/trust.js +35 -0
- package/dist/hub/join/trust.js.map +1 -1
- package/dist/hub/member/pairing-api.js +9 -1
- package/dist/hub/member/pairing-api.js.map +1 -1
- package/dist/hub/member/room-ask.d.ts +137 -0
- package/dist/hub/member/room-ask.js +358 -0
- package/dist/hub/member/room-ask.js.map +1 -0
- package/dist/hub/member-journal.d.ts +18 -1
- package/dist/hub/member-journal.js +76 -3
- package/dist/hub/member-journal.js.map +1 -1
- package/dist/hub/member-origin.d.ts +177 -0
- package/dist/hub/member-origin.js +314 -0
- package/dist/hub/member-origin.js.map +1 -0
- package/dist/hub/pairing-notices.d.ts +1 -0
- package/dist/hub/pairing-notices.js +2 -1
- package/dist/hub/pairing-notices.js.map +1 -1
- package/dist/hub/pairing.d.ts +8 -0
- package/dist/hub/pairing.js +32 -5
- package/dist/hub/pairing.js.map +1 -1
- package/dist/hub/protocol.d.ts +159 -0
- package/dist/hub/protocol.js +19 -1
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/roles/clock.d.ts +18 -0
- package/dist/hub/roles/clock.js +58 -0
- package/dist/hub/roles/clock.js.map +1 -0
- package/dist/hub/roles/cutover-marker.d.ts +57 -0
- package/dist/hub/roles/cutover-marker.js +26 -0
- package/dist/hub/roles/cutover-marker.js.map +1 -0
- package/dist/hub/roles/cutover.js +3 -17
- package/dist/hub/roles/cutover.js.map +1 -1
- package/dist/hub/roles/read.d.ts +7 -3
- package/dist/hub/roles/read.js +9 -1
- package/dist/hub/roles/read.js.map +1 -1
- package/dist/hub/rooms/admin.d.ts +45 -0
- package/dist/hub/rooms/admin.js +105 -0
- package/dist/hub/rooms/admin.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +74 -0
- package/dist/hub/rooms/agents.js +333 -0
- package/dist/hub/rooms/agents.js.map +1 -0
- package/dist/hub/rooms/assistant.d.ts +44 -0
- package/dist/hub/rooms/assistant.js +179 -0
- package/dist/hub/rooms/assistant.js.map +1 -0
- package/dist/hub/rooms/context.d.ts +10 -0
- package/dist/hub/rooms/context.js +24 -0
- package/dist/hub/rooms/context.js.map +1 -0
- package/dist/hub/rooms/direct-view.d.ts +39 -0
- package/dist/hub/rooms/direct-view.js +38 -0
- package/dist/hub/rooms/direct-view.js.map +1 -0
- package/dist/hub/rooms/directory.d.ts +35 -0
- package/dist/hub/rooms/directory.js +98 -0
- package/dist/hub/rooms/directory.js.map +1 -0
- package/dist/hub/rooms/schema.d.ts +11 -0
- package/dist/hub/rooms/schema.js +73 -0
- package/dist/hub/rooms/schema.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +449 -0
- package/dist/hub/rooms/service.js +581 -0
- package/dist/hub/rooms/service.js.map +1 -0
- package/dist/hub/rooms/types.d.ts +79 -0
- package/dist/hub/rooms/types.js +2 -0
- package/dist/hub/rooms/types.js.map +1 -0
- package/dist/hub/rooms.d.ts +7 -1
- package/dist/hub/rooms.js +30 -5
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +8 -0
- package/dist/hub/runtime.js +57 -3
- package/dist/hub/runtime.js.map +1 -1
- package/dist/hub/server.d.ts +25 -0
- package/dist/hub/server.js +63 -5
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sessions.js +1 -1
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/settings-commit.d.ts +6 -1
- package/dist/hub/settings-commit.js +15 -0
- package/dist/hub/settings-commit.js.map +1 -1
- package/dist/hub/settings-directory-recovery.d.ts +5 -0
- package/dist/hub/settings-directory-recovery.js +11 -1
- package/dist/hub/settings-directory-recovery.js.map +1 -1
- package/dist/hub/settings-member-address-control.d.ts +84 -0
- package/dist/hub/settings-member-address-control.js +150 -0
- package/dist/hub/settings-member-address-control.js.map +1 -0
- package/dist/hub/settings-member-address-decision.d.ts +229 -0
- package/dist/hub/settings-member-address-decision.js +318 -0
- package/dist/hub/settings-member-address-decision.js.map +1 -0
- package/dist/hub/settings-member-address-http.d.ts +9 -0
- package/dist/hub/settings-member-address-http.js +78 -0
- package/dist/hub/settings-member-address-http.js.map +1 -0
- package/dist/hub/settings-member-address-network.d.ts +2 -0
- package/dist/hub/settings-member-address-network.js +22 -0
- package/dist/hub/settings-member-address-network.js.map +1 -0
- package/dist/hub/settings-member-address-notices.d.ts +22 -0
- package/dist/hub/settings-member-address-notices.js +21 -0
- package/dist/hub/settings-member-address-notices.js.map +1 -0
- package/dist/hub/settings-member-address-policy.d.ts +21 -0
- package/dist/hub/settings-member-address-policy.js +34 -0
- package/dist/hub/settings-member-address-policy.js.map +1 -0
- package/dist/hub/settings-member-address.d.ts +64 -0
- package/dist/hub/settings-member-address.js +239 -0
- package/dist/hub/settings-member-address.js.map +1 -0
- package/dist/hub/socket.d.ts +2 -0
- package/dist/hub/socket.js +2 -0
- package/dist/hub/socket.js.map +1 -1
- package/dist/hub/teams/types.d.ts +41 -0
- package/dist/hub/teams/types.js +2 -0
- package/dist/hub/teams/types.js.map +1 -0
- package/dist/hub/tls.d.ts +47 -0
- package/dist/hub/tls.js +23 -6
- package/dist/hub/tls.js.map +1 -1
- package/dist/hub/types.d.ts +51 -3
- package/dist/hub/validation.d.ts +1 -1
- package/dist/hub/validation.js +2 -2
- package/dist/hub/validation.js.map +1 -1
- package/dist/hub/web-origin.d.ts +20 -7
- package/dist/hub/web-origin.js +26 -15
- package/dist/hub/web-origin.js.map +1 -1
- package/dist/hub-pilot-trust-settings.d.ts +4 -0
- package/dist/hub-pilot-trust-settings.js +13 -0
- package/dist/hub-pilot-trust-settings.js.map +1 -0
- package/dist/human-delivery-receipts.d.ts +4 -2
- package/dist/human-delivery-receipts.js +20 -13
- package/dist/human-delivery-receipts.js.map +1 -1
- package/dist/inbound-presentation.d.ts +28 -0
- package/dist/inbound-presentation.js +48 -0
- package/dist/inbound-presentation.js.map +1 -0
- package/dist/instance-lifecycle.js +1 -0
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/instructions.d.ts +4 -2
- package/dist/instructions.js +7 -4
- package/dist/instructions.js.map +1 -1
- package/dist/locale.js +14 -0
- package/dist/locale.js.map +1 -1
- package/dist/log-service.d.ts +3 -0
- package/dist/log-service.js +39 -22
- package/dist/log-service.js.map +1 -1
- package/dist/log-steps.d.ts +56 -1
- package/dist/log-steps.js +318 -56
- package/dist/log-steps.js.map +1 -1
- package/dist/needs-you-hub.js +6 -2
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +5 -1
- package/dist/needs-you.js +4 -8
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.d.ts +1 -0
- package/dist/outbound-handlers.js +6 -0
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +1 -0
- package/dist/outbound-schemas.js +1 -0
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/queued-handoffs.d.ts +3 -1
- package/dist/queued-handoffs.js +1 -1
- package/dist/queued-handoffs.js.map +1 -1
- package/dist/runtime-transcript-source.d.ts +2 -0
- package/dist/runtime-transcript-source.js +23 -1
- package/dist/runtime-transcript-source.js.map +1 -1
- package/dist/settings-api.d.ts +1 -0
- package/dist/settings-api.js +15 -8
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +3 -0
- package/dist/settings-baseline.js +2 -2
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-effect.d.ts +3 -0
- package/dist/settings-effect.js +12 -2
- package/dist/settings-effect.js.map +1 -1
- package/dist/topic-commands.js +2 -1
- package/dist/topic-commands.js.map +1 -1
- package/dist/transcript-jsonl.d.ts +24 -0
- package/dist/transcript-jsonl.js +72 -22
- package/dist/transcript-jsonl.js.map +1 -1
- package/dist/transcript-monitor.d.ts +5 -1
- package/dist/transcript-monitor.js +65 -3
- package/dist/transcript-monitor.js.map +1 -1
- package/dist/transcript-needles.d.ts +1 -1
- package/dist/transcript-needles.js +1 -1
- package/dist/transcript-records.d.ts +2 -1
- package/dist/transcript-records.js.map +1 -1
- package/dist/transcript-sources.d.ts +4 -0
- package/dist/transcript-sources.js +2 -0
- package/dist/transcript-sources.js.map +1 -1
- package/dist/ui/agent-details-settings.js +10 -1
- package/dist/ui/chat-activity.js +2 -2
- package/dist/ui/fleet-canvas.js +5 -2
- package/dist/ui/fleet-office-card.js +4 -2
- package/dist/ui/fleet-org.js +2 -0
- package/dist/ui/hub-admin-rooms-strings.js +28 -0
- package/dist/ui/hub-admin-rooms.js +77 -0
- package/dist/ui/hub-assistant-admin-strings.js +26 -0
- package/dist/ui/hub-assistant-admin.js +85 -0
- package/dist/ui/hub-client.js +170 -14
- package/dist/ui/hub-invitations-strings.js +30 -0
- package/dist/ui/hub-invitations.js +108 -0
- package/dist/ui/hub-join-one-strings.js +2 -0
- package/dist/ui/hub-pairing-form-strings.js +48 -0
- package/dist/ui/hub-pilot-trust-strings.js +27 -0
- package/dist/ui/hub-pilot-trust.js +41 -0
- package/dist/ui/hub-room-composer.js +113 -0
- package/dist/ui/hub-room-favorites.js +90 -0
- package/dist/ui/hub-room-list.js +152 -0
- package/dist/ui/hub-room-members-strings.js +12 -0
- package/dist/ui/hub-room-members.js +104 -0
- package/dist/ui/hub-room-new-strings.js +46 -0
- package/dist/ui/hub-room-new.js +135 -0
- package/dist/ui/hub-room-presence.js +123 -0
- package/dist/ui/hub-room-settings-strings.js +26 -0
- package/dist/ui/hub-room-settings.js +134 -0
- package/dist/ui/hub-room-strings.js +222 -0
- package/dist/ui/hub-room-thread.js +262 -0
- package/dist/ui/hub-room-unread.js +51 -0
- package/dist/ui/hub-room-working.js +29 -0
- package/dist/ui/log-row.js +14 -5
- package/dist/ui/panel-details.js +6 -1
- package/dist/ui/panel-hub.js +91 -49
- package/dist/ui/panel-needs.js +2 -0
- package/dist/ui/settings-hub-company-join.js +31 -11
- package/dist/ui/settings-hub-connection.js +9 -3
- package/dist/ui/settings-hub-member-address.js +205 -0
- package/dist/ui/settings-hub-section.js +2 -0
- package/dist/ui/settings-hub.js +10 -4
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-needs.js +3 -0
- package/dist/ui/shared/app-shell.js +4 -1
- package/dist/ui/shared/app.css +5 -0
- package/dist/ui/shared/chat-render.js +10 -0
- package/dist/ui/shared/chat-thread.js +14 -5
- package/dist/ui/shared/hub-chat.css +17 -0
- package/dist/ui/shared/hub-rooms-u2.css +42 -0
- package/dist/ui/shared/model-observation.js +16 -0
- package/dist/ui/shared/stale-tab.css +6 -0
- package/dist/ui/shared/stale-tab.js +50 -0
- package/dist/web-api.d.ts +2 -0
- package/dist/web-api.js +6 -2
- package/dist/web-api.js.map +1 -1
- package/package.json +1 -1
package/dist/log-steps.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseClaudeModelRecord } from "./claude-model-observation.js";
|
|
1
2
|
/**
|
|
2
3
|
* #1218: an instance's work, step by step, for the web Log tab (紀錄) — the step model and the per-backend parsers.
|
|
3
4
|
* Design: issue #1218 comment 6142912335 and the user's decisions after it; docs/design/1218-live-activity.md.
|
|
@@ -10,10 +11,10 @@
|
|
|
10
11
|
* was cut, so the page can say so. The page renders words from the structured fields (kind, cat, subject), so the
|
|
11
12
|
* labels follow its language.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
+
* File reads are async: `readTailRecords` for Log/backfill, `readStartupTailRecords` for a bounded metadata look.
|
|
14
15
|
*/
|
|
15
16
|
import { open } from "node:fs/promises";
|
|
16
|
-
import { LINE_MAX_BYTES, LONG_HEAD_BYTES,
|
|
17
|
+
import { LINE_MAX_BYTES, LONG_HEAD_BYTES, boundaryBefore, openTranscript } from "./transcript-jsonl.js";
|
|
17
18
|
import { redactSecrets, shellProgramName } from "./tool-progress.js";
|
|
18
19
|
export const ANCHOR_TEXT = 200;
|
|
19
20
|
export const SUBJECT_MAX = 300;
|
|
@@ -206,7 +207,7 @@ export const tsOf = (v) => { const t = typeof v === "string" ? Date.parse(v) : N
|
|
|
206
207
|
/** AgEnD's `reply` tool as each backend names it: `mcp__agend__reply`, `mcp__agend-x__reply`, codex's `agend:reply`, kiro's bare `reply`. */
|
|
207
208
|
const REPLY_TOOL = /^(?:mcp__agend[\w-]*__|agend[\w-]*:)?reply$/;
|
|
208
209
|
export const isReplyTool = (name) => REPLY_TOOL.test(name);
|
|
209
|
-
const HUMAN_ID = /^\s*(?:<pasted_content[^>]*>\s*)?\[agend-human-id:(hmsg-[A-Za-z0-9-]{1,80})\]/;
|
|
210
|
+
const HUMAN_ID = /^\s*(?:<pasted_content[^>]*>\s*)?\[(?:hid|agend-human-id):(hmsg-[A-Za-z0-9-]{1,80})\]/;
|
|
210
211
|
const MESSAGE_ID = /\(message_id:\s*([A-Za-z0-9._:-]{1,80})(?:\s*\|[^)\n]{0,200})?\)/g;
|
|
211
212
|
/** The ids in a delivered prompt's text (the last `(message_id: …)` — the trailer AgEnD appends — wins), or undefined. */
|
|
212
213
|
export function promptAnchor(text) {
|
|
@@ -458,6 +459,11 @@ export class ClaudeStepParser extends StepParser {
|
|
|
458
459
|
record(e) {
|
|
459
460
|
const ts = tsOf(e.timestamp);
|
|
460
461
|
const msg = e.message;
|
|
462
|
+
const modelRecord = parseClaudeModelRecord(e);
|
|
463
|
+
if (modelRecord?.kind === "switch")
|
|
464
|
+
return [this.add({ id: `model:${modelRecord.sessionId}:${modelRecord.id}`, kind: "state", ts, note: `Model switched: ${modelRecord.original} → ${modelRecord.served}`,
|
|
465
|
+
modelSwitch: { id: modelRecord.id, original: modelRecord.original, served: modelRecord.served,
|
|
466
|
+
cause: modelRecord.cause, scope: modelRecord.scope, since: ts } })];
|
|
461
467
|
if (e.type === "system") {
|
|
462
468
|
if (e.subtype === "turn_duration") {
|
|
463
469
|
const out = this.endOpen("interrupted");
|
|
@@ -508,7 +514,7 @@ export class ClaudeStepParser extends StepParser {
|
|
|
508
514
|
for (const b of Array.isArray(content) ? content : []) {
|
|
509
515
|
const blk = b;
|
|
510
516
|
if (blk.type === "text" && typeof blk.text === "string" && blk.text.trim()) {
|
|
511
|
-
const s = this.add({ kind: "assistant", ts });
|
|
517
|
+
const s = this.add({ kind: "assistant", ts, ...(modelRecord?.kind === "served" ? { servedModel: modelRecord.served } : {}) });
|
|
512
518
|
bodyOf(s, blk.text, TEXT_MAX);
|
|
513
519
|
out.push(s);
|
|
514
520
|
}
|
|
@@ -557,6 +563,46 @@ export class ClaudeStepParser extends StepParser {
|
|
|
557
563
|
return [this.result(id, headString(head, "content") ?? "", false, ts, bytes)];
|
|
558
564
|
}
|
|
559
565
|
}
|
|
566
|
+
/** An `exec` script that sends a reply (`tools.mcp__agend__reply(...)`): its turn has said something. */
|
|
567
|
+
const REPLY_IN_SCRIPT = /\btools\.(?:mcp__agend[\w-]*__|agend[\w-]*:)?reply\s*\(/;
|
|
568
|
+
/**
|
|
569
|
+
* A codex `user` message that is a person's prompt. 0.15x+ names what each message holds (`content_item_kinds`): `user.text` is
|
|
570
|
+
* the prompt; `agents_md.instructions`, `environments.environment_context` and the like are Codex's own context — one of them
|
|
571
|
+
* is first in every turn and would be taken for the turn's prompt (and the turn would lose its anchor). A rollout without the
|
|
572
|
+
* kinds (older) is judged by its text.
|
|
573
|
+
*/
|
|
574
|
+
function isPrompt(payload, text) {
|
|
575
|
+
const kinds = payload.internal_chat_message_metadata_passthrough?.content_item_kinds;
|
|
576
|
+
if (Array.isArray(kinds) && kinds.length)
|
|
577
|
+
return kinds.includes("user.text");
|
|
578
|
+
return !/^(?:<(?:environment_context|user_instructions|permissions)|# AGENTS\.md instructions)/.test(text.trim());
|
|
579
|
+
}
|
|
580
|
+
/** A command's argv as the one command it runs: `["/bin/bash", "-lc", "<script>"]` (or powershell's `-Command`) is `<script>`. */
|
|
581
|
+
function commandText(cmd) {
|
|
582
|
+
if (!Array.isArray(cmd))
|
|
583
|
+
return String(cmd ?? "");
|
|
584
|
+
const argv = cmd.map(String);
|
|
585
|
+
const shell = /(?:^|[\\/])(?:bash|sh|zsh|fish|pwsh|powershell)(?:\.exe)?$/i.test(argv[0] ?? "");
|
|
586
|
+
const last = argv[argv.length - 1] ?? "";
|
|
587
|
+
return shell && argv.length >= 3 && /^-[A-Za-z]+$/.test(argv[argv.length - 2] ?? "") ? last : argv.join(" ");
|
|
588
|
+
}
|
|
589
|
+
/** The command of an `exec` script that runs exactly one `exec_command` (`tools.exec_command({cmd:"npm test"})`), else undefined. */
|
|
590
|
+
function scriptCommand(script) {
|
|
591
|
+
const tools = new Set([...script.matchAll(/\btools\.(\w+)\s*\(/g)].map((m) => m[1]));
|
|
592
|
+
if (tools.size !== 1 || !tools.has("exec_command"))
|
|
593
|
+
return undefined;
|
|
594
|
+
const lit = /\btools\.exec_command\s*\(\s*\{\s*["']?cmd["']?\s*:\s*("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\$]|\\.)*`)/.exec(script)?.[1];
|
|
595
|
+
if (!lit)
|
|
596
|
+
return undefined;
|
|
597
|
+
try {
|
|
598
|
+
return lit.startsWith('"') ? JSON.parse(lit) : lit.slice(1, -1).replace(/\\(['`\\])/g, "$1").replace(/\\n/g, "\n");
|
|
599
|
+
}
|
|
600
|
+
catch {
|
|
601
|
+
return undefined;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/** A `file:///C:/x/y.png` item path as the path it names. */
|
|
605
|
+
const filePath = (u) => String(u ?? "").replace(/^file:\/\/\/?(?=[A-Za-z]:|\/)/, "").replace(/^file:\/\//, "");
|
|
560
606
|
const CODEX_EXIT = /Process exited with code (-?\d+)/;
|
|
561
607
|
const CODEX_WALL = /Wall time: ([\d.]+) seconds/;
|
|
562
608
|
/**
|
|
@@ -564,22 +610,67 @@ const CODEX_WALL = /Wall time: ([\d.]+) seconds/;
|
|
|
564
610
|
* `local_shell_call` (running, by `call_id`) and their `*_output` (exec_command's output says its exit code and wall
|
|
565
611
|
* time); `event_msg`: `task_started` (a turn), `task_complete` / `turn_aborted` (its end), and — on versions that
|
|
566
612
|
* write them — `item_completed` items: CommandExecution (a command, with exit code and duration), McpToolCall,
|
|
567
|
-
* FileChange. Their AgentMessage / UserMessage duplicate the response items and are not shown twice;
|
|
613
|
+
* FileChange, Extension (web search). Their AgentMessage / UserMessage duplicate the response items and are not shown twice;
|
|
614
|
+
* reasoning never (only a summary the model chose to write — `encrypted_content` is not read).
|
|
615
|
+
*
|
|
616
|
+
* Codex 0.153–0.167 (real rollouts, #3787) runs every tool through one `exec` custom tool call — a script driving `tools.*` —
|
|
617
|
+
* and writes each tool it ran as an `item_completed` item of its own, with an id that is not the call's. Shown both, an action
|
|
618
|
+
* would be two steps: the item (the thing that was done, with its output) takes over the running `exec` call's step, so there is
|
|
619
|
+
* one step per action (`wrapper`). Further items of the same script are steps of their own.
|
|
620
|
+
*
|
|
621
|
+
* The turn is the `turn_id` every record of it carries, not only `task_started`: a read that begins inside a turn (the newest
|
|
622
|
+
* window after a long `compacted` record, or a poll that picks up mid-turn — each with a fresh parser) still names it, so its
|
|
623
|
+
* steps hang on the same turn as the ones read before.
|
|
568
624
|
*/
|
|
569
625
|
export class CodexStepParser extends StepParser {
|
|
570
626
|
started = new Map();
|
|
571
627
|
/** The reasoning texts of this turn already shown: `reasoning` and `agent_reasoning` say the same thing twice. */
|
|
572
628
|
reasoned = new Set();
|
|
629
|
+
/** The `exec` script call of this turn still running whose first tool item has not come yet (that item takes over its step). */
|
|
630
|
+
wrapper = "";
|
|
631
|
+
/** Script calls whose step an item has taken over: their `custom_tool_call_output` adds nothing. */
|
|
632
|
+
adopted = new Set();
|
|
633
|
+
/** This turn has said something (a message or a `reply` call): `task_complete` with no last message then is not a failure. */
|
|
634
|
+
spoke = false;
|
|
635
|
+
/**
|
|
636
|
+
* When a `compacted` record was read while the turn was still unknown (it carries no `turn_id`, and this read began inside the
|
|
637
|
+
* turn: its first record): its time. The note is made once a record names the turn — a step with no turn between two runs of
|
|
638
|
+
* one turn would cut the turn in two for the page.
|
|
639
|
+
*/
|
|
640
|
+
compactedAt = null;
|
|
641
|
+
/** A compaction happened at `ts`: a `state` step on the turn, or — the turn not known yet — as soon as it is. */
|
|
642
|
+
compacted(ts) {
|
|
643
|
+
if (this.turn)
|
|
644
|
+
return [this.add({ kind: "state", ts, note: "compacted" })];
|
|
645
|
+
this.compactedAt = ts;
|
|
646
|
+
return [];
|
|
647
|
+
}
|
|
573
648
|
record(e) {
|
|
574
|
-
const ts = tsOf(e.timestamp);
|
|
575
649
|
const p = e.payload;
|
|
576
650
|
if (!p)
|
|
577
651
|
return [];
|
|
652
|
+
// The turn this record belongs to, when this read has not met its `task_started`.
|
|
653
|
+
if (!this.turn) {
|
|
654
|
+
const tid = p.turn_id ?? p.internal_chat_message_metadata_passthrough?.turn_id;
|
|
655
|
+
if (typeof tid === "string" && tid)
|
|
656
|
+
this.turn = tid;
|
|
657
|
+
}
|
|
658
|
+
const lead = this.compactedAt !== null && this.turn ? [this.add({ kind: "state", ts: this.compactedAt, note: "compacted" })] : [];
|
|
659
|
+
if (lead.length)
|
|
660
|
+
this.compactedAt = null;
|
|
661
|
+
const out = this.codexRecord(e, p);
|
|
662
|
+
return lead.length ? [...lead, ...out] : out;
|
|
663
|
+
}
|
|
664
|
+
codexRecord(e, p) {
|
|
665
|
+
const ts = tsOf(e.timestamp);
|
|
578
666
|
if (e.type === "compacted")
|
|
579
|
-
return
|
|
667
|
+
return this.compacted(ts);
|
|
580
668
|
if (e.type === "event_msg") {
|
|
581
669
|
if (p.type === "task_started") {
|
|
582
670
|
this.reasoned.clear();
|
|
671
|
+
this.wrapper = "";
|
|
672
|
+
this.adopted.clear();
|
|
673
|
+
this.spoke = false;
|
|
583
674
|
return this.newTurn(String(p.turn_id ?? ""));
|
|
584
675
|
}
|
|
585
676
|
if (p.type === "agent_reasoning" && typeof p.text === "string")
|
|
@@ -592,7 +683,7 @@ export class CodexStepParser extends StepParser {
|
|
|
592
683
|
if (typeof p.reason === "string")
|
|
593
684
|
s.note = p.reason;
|
|
594
685
|
}
|
|
595
|
-
else if (p.last_agent_message == null)
|
|
686
|
+
else if (p.last_agent_message == null && !this.spoke)
|
|
596
687
|
s.status = "failed";
|
|
597
688
|
out.push(s);
|
|
598
689
|
return out;
|
|
@@ -614,8 +705,10 @@ export class CodexStepParser extends StepParser {
|
|
|
614
705
|
if (role !== "user" && role !== "assistant")
|
|
615
706
|
return [];
|
|
616
707
|
const text = resultText(p.content);
|
|
617
|
-
if (!text.trim() || (role === "user" &&
|
|
708
|
+
if (!text.trim() || (role === "user" && !isPrompt(p, text)))
|
|
618
709
|
return [];
|
|
710
|
+
if (role === "assistant")
|
|
711
|
+
this.spoke = true;
|
|
619
712
|
const out = [];
|
|
620
713
|
const anchor = role === "user" ? promptAnchor(text) : undefined;
|
|
621
714
|
const s = this.add({ kind: role, ts, ...(anchor ? { anchor } : {}) });
|
|
@@ -645,37 +738,65 @@ export class CodexStepParser extends StepParser {
|
|
|
645
738
|
input = { ...input, command: cmd.map(String).join(" ") };
|
|
646
739
|
}
|
|
647
740
|
const anchor = isReplyTool(name) ? replyAnchor(input) : undefined;
|
|
648
|
-
|
|
741
|
+
if (isReplyTool(name) || (typeof input === "string" && REPLY_IN_SCRIPT.test(input)))
|
|
742
|
+
this.spoke = true;
|
|
743
|
+
const described = describeTool(name, input);
|
|
744
|
+
// A script that runs one command: the step names the command while it runs (the item that finishes it says the same).
|
|
745
|
+
const one = name === "exec" && typeof input === "string" ? scriptCommand(input) : undefined;
|
|
746
|
+
const s = this.add({ ...(id ? { id } : {}), kind: "tool", ts, tool: name, ...described, ...(one ? { subject: subjectOf(one) } : {}), status: "running", ...(anchor ? { anchor } : {}) });
|
|
649
747
|
inputOf(s, input);
|
|
650
|
-
|
|
651
|
-
this.started.set(id, ts);
|
|
748
|
+
this.called(id, p.type, name, ts);
|
|
652
749
|
return [s];
|
|
653
750
|
}
|
|
654
751
|
case "function_call_output":
|
|
655
|
-
case "custom_tool_call_output":
|
|
656
|
-
|
|
657
|
-
const s = this.close(id) ?? this.add({ id: id || undefined, kind: "tool", ts, tool: "", cat: "other", status: "done" });
|
|
658
|
-
const text = resultText(p.output);
|
|
659
|
-
const exit = CODEX_EXIT.exec(text), wall = CODEX_WALL.exec(text);
|
|
660
|
-
s.status = (exit && exit[1] !== "0") || /^failed to /.test(text) ? "failed" : "done";
|
|
661
|
-
if (exit)
|
|
662
|
-
s.exitCode = Number(exit[1]);
|
|
663
|
-
const t0 = this.started.get(id);
|
|
664
|
-
this.started.delete(id);
|
|
665
|
-
if (wall)
|
|
666
|
-
s.durationMs = Math.round(Number(wall[1]) * 1000);
|
|
667
|
-
else if (t0 && ts >= t0)
|
|
668
|
-
s.durationMs = ts - t0;
|
|
669
|
-
const out = /\nOutput:\n([\s\S]*)$/.exec(text);
|
|
670
|
-
if (text) {
|
|
671
|
-
bodyOf(s, out ? out[1] : text, RESULT_MAX);
|
|
672
|
-
replyResult(s, text);
|
|
673
|
-
}
|
|
674
|
-
return [{ ...s }];
|
|
675
|
-
}
|
|
752
|
+
case "custom_tool_call_output":
|
|
753
|
+
return this.answered(String(p.call_id ?? ""), resultText(p.output), ts);
|
|
676
754
|
}
|
|
677
755
|
return [];
|
|
678
756
|
}
|
|
757
|
+
/**
|
|
758
|
+
* What a call leaves behind for its output and for the items that may take it over — the one place both the whole record and a
|
|
759
|
+
* long one (`long()`) go through, so a call over the line limit is bookkept exactly as a short one: its start time, and an `exec`
|
|
760
|
+
* script call as the `wrapper` the first item takes over.
|
|
761
|
+
*/
|
|
762
|
+
called(id, type, name, ts) {
|
|
763
|
+
if (ts && id)
|
|
764
|
+
this.started.set(id, ts);
|
|
765
|
+
if (id && type === "custom_tool_call" && name === "exec")
|
|
766
|
+
this.wrapper = id;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* A call's output (`text`: all of it, or the start of one too long to parse; `bytes`: its size then). An item already took the
|
|
770
|
+
* script's step over (it has the command, its output and its exit code): nothing to add, and above all not a second, nameless
|
|
771
|
+
* step of the same id — the page would lay it over the item's.
|
|
772
|
+
*/
|
|
773
|
+
answered(id, text, ts, bytes) {
|
|
774
|
+
if (id && this.wrapper === id)
|
|
775
|
+
this.wrapper = "";
|
|
776
|
+
if (id && this.adopted.delete(id)) {
|
|
777
|
+
this.started.delete(id);
|
|
778
|
+
return [];
|
|
779
|
+
}
|
|
780
|
+
const s = this.close(id) ?? this.add({ id: id || undefined, kind: "tool", ts, tool: "", cat: "other", status: "done" });
|
|
781
|
+
const exit = CODEX_EXIT.exec(text), wall = CODEX_WALL.exec(text);
|
|
782
|
+
s.status = (exit && exit[1] !== "0") || /^failed to /.test(text) ? "failed" : "done";
|
|
783
|
+
if (exit)
|
|
784
|
+
s.exitCode = Number(exit[1]);
|
|
785
|
+
const t0 = this.started.get(id);
|
|
786
|
+
this.started.delete(id);
|
|
787
|
+
if (wall)
|
|
788
|
+
s.durationMs = Math.round(Number(wall[1]) * 1000);
|
|
789
|
+
else if (t0 && ts >= t0)
|
|
790
|
+
s.durationMs = ts - t0;
|
|
791
|
+
if (bytes !== undefined)
|
|
792
|
+
s.bodyBytes = bytes;
|
|
793
|
+
const out = /\nOutput:\n([\s\S]*)$/.exec(text);
|
|
794
|
+
if (text) {
|
|
795
|
+
bodyOf(s, out ? out[1] : text, RESULT_MAX);
|
|
796
|
+
replyResult(s, text);
|
|
797
|
+
}
|
|
798
|
+
return [{ ...s }];
|
|
799
|
+
}
|
|
679
800
|
/** AGEND-181: a reasoning summary as a `thinking` step (none unless asked for, empty, or already shown this turn). */
|
|
680
801
|
reasoning(text, ts) {
|
|
681
802
|
if (!this.opts.thinking || !text.trim() || this.reasoned.has(text))
|
|
@@ -685,6 +806,31 @@ export class CodexStepParser extends StepParser {
|
|
|
685
806
|
bodyOf(s, text, TEXT_MAX);
|
|
686
807
|
return [s];
|
|
687
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* A tool item is the action itself. While an `exec` script call is running with no item yet, the first item takes over its step
|
|
811
|
+
* (same id, the call's start time): one step for the action, not the call and the item. Otherwise it is a step of its own.
|
|
812
|
+
*/
|
|
813
|
+
place(fields) {
|
|
814
|
+
const w = this.wrapper && !this.adopted.has(this.wrapper) ? this.openTool(this.wrapper) : undefined;
|
|
815
|
+
if (!w)
|
|
816
|
+
return this.add(fields);
|
|
817
|
+
this.close(w.id);
|
|
818
|
+
this.adopted.add(w.id);
|
|
819
|
+
this.started.delete(w.id);
|
|
820
|
+
delete w.input;
|
|
821
|
+
delete w.inputCut;
|
|
822
|
+
delete w.body;
|
|
823
|
+
delete w.bodyCut;
|
|
824
|
+
delete w.bodyBytes;
|
|
825
|
+
delete w.exitCode;
|
|
826
|
+
delete w.durationMs;
|
|
827
|
+
delete w.subject;
|
|
828
|
+
delete w.anchor;
|
|
829
|
+
// The page merges a later answer over the step it already holds (`{ ...held, ...new }`): a key the item does not say is kept
|
|
830
|
+
// from the script's step. So the keys the script's step had are always said here (empty when the item has none).
|
|
831
|
+
Object.assign(w, { input: "", subject: "" }, fields, { id: w.id, ts: w.ts || fields.ts });
|
|
832
|
+
return w;
|
|
833
|
+
}
|
|
688
834
|
item(it, ts) {
|
|
689
835
|
if (!it || typeof it.id !== "string")
|
|
690
836
|
return [];
|
|
@@ -692,40 +838,66 @@ export class CodexStepParser extends StepParser {
|
|
|
692
838
|
const durationMs = dur && typeof dur.secs === "number" ? dur.secs * 1000 + Math.round((dur.nanos ?? 0) / 1e6) : undefined;
|
|
693
839
|
const failed = it.status === "failed" || (typeof it.exit_code === "number" && it.exit_code !== 0);
|
|
694
840
|
const base = { id: it.id, kind: "tool", ts, status: (failed ? "failed" : "done"), ...(durationMs !== undefined ? { durationMs } : {}) };
|
|
841
|
+
const put = (fields) => this.place(fields);
|
|
842
|
+
const out = (s) => [this.adopted.has(s.id) ? { ...s } : s];
|
|
695
843
|
switch (it.type) {
|
|
696
844
|
case "CommandExecution": {
|
|
697
|
-
const cmd =
|
|
698
|
-
|
|
845
|
+
const cmd = commandText(it.command);
|
|
846
|
+
// codex classifies what it ran (`parsed_cmd`): one read of a file / one search is a read / a search, the rest a command.
|
|
847
|
+
const parsed = Array.isArray(it.parsed_cmd) && it.parsed_cmd.length === 1 ? it.parsed_cmd[0] : undefined;
|
|
848
|
+
const kind = parsed?.type === "read" && typeof (parsed.path ?? parsed.name) === "string" ? "read"
|
|
849
|
+
: parsed?.type === "search" ? "search" : parsed?.type === "list_files" ? "read" : "run";
|
|
850
|
+
const subject = kind === "read" ? subjectOf(parsed?.path ?? parsed?.name ?? parsed?.cmd) : kind === "search" ? subjectOf(parsed?.query ?? parsed?.cmd) : subjectOf(cmd);
|
|
851
|
+
const s = put({ ...base, tool: "command", cat: kind, subject: subject ?? subjectOf(cmd), ...(typeof it.exit_code === "number" ? { exitCode: it.exit_code } : {}) });
|
|
699
852
|
const text = String(it.aggregated_output ?? it.formatted_output ?? "");
|
|
700
853
|
if (text)
|
|
701
854
|
bodyOf(s, text, RESULT_MAX);
|
|
702
|
-
|
|
855
|
+
inputOf(s, cmd);
|
|
856
|
+
return out(s);
|
|
703
857
|
}
|
|
704
858
|
case "McpToolCall": {
|
|
705
859
|
const tool = `${it.server}:${it.tool}`;
|
|
706
860
|
const anchor = isReplyTool(tool) ? replyAnchor(it.arguments) : undefined;
|
|
707
|
-
|
|
861
|
+
if (isReplyTool(tool))
|
|
862
|
+
this.spoke = true;
|
|
863
|
+
const s = put({ ...base, tool, cat: /^agend/.test(String(it.server)) ? "message" : "mcp", subject: subjectOf(tool), ...(anchor ? { anchor } : {}) });
|
|
708
864
|
inputOf(s, it.arguments);
|
|
709
865
|
const text = resultText(it.result?.content);
|
|
710
866
|
if (text) {
|
|
711
867
|
bodyOf(s, text, RESULT_MAX);
|
|
712
868
|
replyResult(s, text);
|
|
713
869
|
}
|
|
714
|
-
return
|
|
870
|
+
return out(s);
|
|
715
871
|
}
|
|
716
872
|
case "FileChange": {
|
|
717
873
|
const files = Object.keys(it.changes ?? {});
|
|
718
|
-
const s =
|
|
874
|
+
const s = put({ ...base, tool: "file_change", cat: "edit", subject: subjectOf(files.join(", ")) });
|
|
719
875
|
const text = [it.stdout, it.stderr].filter((x) => typeof x === "string" && x).join("\n");
|
|
720
876
|
if (text)
|
|
721
877
|
bodyOf(s, text, RESULT_MAX);
|
|
722
|
-
return
|
|
878
|
+
return out(s);
|
|
879
|
+
}
|
|
880
|
+
case "Extension": {
|
|
881
|
+
// web search / page open (`kind: "web.search"`): what was asked or opened; the results are not kept.
|
|
882
|
+
if (it.kind !== "web.search")
|
|
883
|
+
return [];
|
|
884
|
+
const action = it.action;
|
|
885
|
+
const queries = Array.isArray(action?.queries) ? action.queries.map(String).join(" · ") : "";
|
|
886
|
+
const s = put({ ...base, tool: "web.search", cat: "web", subject: subjectOf(action?.url ?? it.query ?? (queries || undefined)) });
|
|
887
|
+
return out(s);
|
|
888
|
+
}
|
|
889
|
+
case "ImageView": {
|
|
890
|
+
const s = put({ ...base, tool: "view_image", cat: "read", subject: subjectOf(filePath(it.path)) });
|
|
891
|
+
return out(s);
|
|
723
892
|
}
|
|
724
893
|
}
|
|
725
894
|
return [];
|
|
726
895
|
}
|
|
727
896
|
/** A long rollout line: an output completes its call with the start of its text; a call starts by its name. */
|
|
728
897
|
long(head, bytes) {
|
|
898
|
+
// `compacted` carries the whole replacement history (megabytes): it is a long line, and its type is all that is read of it.
|
|
899
|
+
if (/^\{[^{}]{0,200}"type":"compacted"/.test(head))
|
|
900
|
+
return this.compacted(tsOf(/"timestamp":"([^"]{10,40})"/.exec(head)?.[1]));
|
|
729
901
|
if (!head.includes('"type":"response_item"'))
|
|
730
902
|
return [];
|
|
731
903
|
const type = /"payload":\{[^{}]{0,400}?"type":"(function_call|custom_tool_call|function_call_output|custom_tool_call_output)"/.exec(head)?.[1];
|
|
@@ -733,17 +905,15 @@ export class CodexStepParser extends StepParser {
|
|
|
733
905
|
if (!type || !id)
|
|
734
906
|
return [];
|
|
735
907
|
const ts = tsOf(/"timestamp":"([^"]{10,40})"/.exec(head)?.[1]);
|
|
736
|
-
if (type.endsWith("_output"))
|
|
737
|
-
|
|
738
|
-
s.status = "done";
|
|
739
|
-
s.bodyBytes = bytes;
|
|
740
|
-
const text = headString(head, "text") ?? headString(head, "output");
|
|
741
|
-
if (text)
|
|
742
|
-
bodyOf(s, text, RESULT_MAX);
|
|
743
|
-
return [{ ...s }];
|
|
744
|
-
}
|
|
908
|
+
if (type.endsWith("_output"))
|
|
909
|
+
return this.answered(id, headString(head, "text") ?? headString(head, "output") ?? "", ts, bytes);
|
|
745
910
|
const name = /"name":"([^"]{1,200})"/.exec(head)?.[1] ?? "tool";
|
|
746
|
-
|
|
911
|
+
// Its input is not read (too long): the head can still say it sends a reply.
|
|
912
|
+
if (isReplyTool(name) || REPLY_IN_SCRIPT.test(head))
|
|
913
|
+
this.spoke = true;
|
|
914
|
+
const s = this.add({ id, kind: "tool", ts, tool: name, ...describeTool(name, undefined), status: "running", bodyBytes: bytes });
|
|
915
|
+
this.called(id, type, name, ts);
|
|
916
|
+
return [s];
|
|
747
917
|
}
|
|
748
918
|
}
|
|
749
919
|
/** A kiro tool result's text: stdout and stderr of a command (with its exit status), or its text blocks. */
|
|
@@ -947,18 +1117,28 @@ const BACKFILL_CHUNK = 256 * 1024;
|
|
|
947
1117
|
export async function readTailRecords(path, opts = {}) {
|
|
948
1118
|
const maxBytes = Math.max(1, opts.maxBytes ?? BACKFILL_MAX_BYTES);
|
|
949
1119
|
const maxLines = Math.max(1, opts.maxLines ?? 2000);
|
|
950
|
-
// `end`: read the records before this offset (a record start, from an earlier read: a line boundary) — older ones.
|
|
951
|
-
const end = opts.end !== undefined ? Math.min(opts.end, await lastLineBoundary(path)) : await lastLineBoundary(path);
|
|
952
1120
|
const out = [];
|
|
953
|
-
if (end === 0)
|
|
954
|
-
return { records: out, truncated: false, end };
|
|
955
1121
|
const KEEP = LINE_MAX_BYTES + LONG_HEAD_BYTES;
|
|
956
|
-
const fh = await
|
|
1122
|
+
const fh = await openTranscript(path);
|
|
957
1123
|
try {
|
|
1124
|
+
// The last complete record ends at a line boundary. Finding it is part of the read, so it is inside the budget too: an
|
|
1125
|
+
// unfinished record after it (a record being written, or one of megabytes) is never scanned past `maxBytes`.
|
|
1126
|
+
// `end` (a record start from an earlier read: a boundary) is where the look begins — the older records before it — and
|
|
1127
|
+
// nothing after it is read; with none, the file's end.
|
|
1128
|
+
const size = (await fh.stat()).size;
|
|
1129
|
+
const from = opts.end !== undefined ? Math.min(opts.end, size) : size;
|
|
1130
|
+
const found = await boundaryBefore(fh, path, from, maxBytes);
|
|
1131
|
+
// No line end within the budget: an unfinished record longer than it. Complete lines only — none is returned. The cursor of a
|
|
1132
|
+
// read from the file's end is inside that record (`skip`: the next forward read drops through its end), not a boundary.
|
|
1133
|
+
if (found.at === null)
|
|
1134
|
+
return { records: out, truncated: true, end: from, ...(opts.end === undefined ? { skip: true } : {}) };
|
|
1135
|
+
const end = found.at;
|
|
1136
|
+
if (end === 0)
|
|
1137
|
+
return { records: out, truncated: false, end };
|
|
958
1138
|
let pos = end - 1; // the last record's line end (excluded); records lie between line ends
|
|
959
1139
|
let recEnd = end - 1; // where the record being assembled ends (its line end)
|
|
960
1140
|
let acc = Buffer.alloc(0); // its bytes after the current chunk: its first KEEP bytes at most
|
|
961
|
-
let read =
|
|
1141
|
+
let read = found.read; // the boundary search's reads count against the budget
|
|
962
1142
|
const emit = (bytes, total, at) => { if (total > 0)
|
|
963
1143
|
out.push({ record: toRecord(bytes, total, at), at }); };
|
|
964
1144
|
while (pos > 0 && read < maxBytes && out.length < maxLines) {
|
|
@@ -1002,6 +1182,88 @@ export async function readTailRecords(path, opts = {}) {
|
|
|
1002
1182
|
await fh.close();
|
|
1003
1183
|
}
|
|
1004
1184
|
}
|
|
1185
|
+
/** Metadata-only startup look. No forward cursor is exposed when a boundary does not fit the read budget. */
|
|
1186
|
+
export async function readStartupTailRecords(path, opts) {
|
|
1187
|
+
const maxBytes = Math.max(1, opts.maxBytes ?? BACKFILL_MAX_BYTES);
|
|
1188
|
+
const maxLines = Math.max(1, opts.maxLines ?? 2000);
|
|
1189
|
+
const fh = await open(path, "r");
|
|
1190
|
+
try {
|
|
1191
|
+
// The cursor is applied before any boundary read; all physical reads share the same budget.
|
|
1192
|
+
const size = (await fh.stat()).size;
|
|
1193
|
+
let boundary = Math.max(0, Math.min(opts.end, size)), end = 0, read = 0;
|
|
1194
|
+
while (boundary > 0 && read < maxBytes) {
|
|
1195
|
+
// The usual cursor already ends just after LF; one byte verifies it without rereading its whole chunk.
|
|
1196
|
+
const length = Math.min(read === 0 ? 1 : BACKFILL_CHUNK, boundary, maxBytes - read);
|
|
1197
|
+
const start = boundary - length, buf = Buffer.alloc(length);
|
|
1198
|
+
for (let filled = 0; filled < length;) {
|
|
1199
|
+
const { bytesRead } = await fh.read(buf, filled, length - filled, start + filled);
|
|
1200
|
+
if (bytesRead <= 0)
|
|
1201
|
+
throw new Error(`readStartupTailRecords: no progress reading ${path} at ${start + filled}`);
|
|
1202
|
+
filled += bytesRead;
|
|
1203
|
+
read += bytesRead;
|
|
1204
|
+
}
|
|
1205
|
+
const lf = buf.lastIndexOf(0x0a);
|
|
1206
|
+
if (lf >= 0) {
|
|
1207
|
+
end = start + lf + 1;
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
boundary = start;
|
|
1211
|
+
}
|
|
1212
|
+
if (end === 0)
|
|
1213
|
+
return { records: [], truncated: boundary > 0 };
|
|
1214
|
+
const { records, truncated } = await readTailAtBoundary(path, fh, end, maxBytes - read, maxLines);
|
|
1215
|
+
return { records, truncated };
|
|
1216
|
+
}
|
|
1217
|
+
finally {
|
|
1218
|
+
await fh.close();
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
async function readTailAtBoundary(path, fh, end, maxBytes, maxLines) {
|
|
1222
|
+
const out = [];
|
|
1223
|
+
const KEEP = LINE_MAX_BYTES + LONG_HEAD_BYTES;
|
|
1224
|
+
let read = 0;
|
|
1225
|
+
let pos = end - 1; // the last record's line end (excluded); records lie between line ends
|
|
1226
|
+
let recEnd = end - 1; // where the record being assembled ends (its line end)
|
|
1227
|
+
let acc = Buffer.alloc(0); // its bytes after the current chunk: its first KEEP bytes at most
|
|
1228
|
+
const emit = (bytes, total, at) => { if (total > 0)
|
|
1229
|
+
out.push({ record: toRecord(bytes, total, at), at }); };
|
|
1230
|
+
while (pos > 0 && read < maxBytes && out.length < maxLines) {
|
|
1231
|
+
const length = Math.min(BACKFILL_CHUNK, pos, maxBytes - read);
|
|
1232
|
+
const start = pos - length;
|
|
1233
|
+
const buf = Buffer.alloc(length);
|
|
1234
|
+
for (let filled = 0; filled < length;) {
|
|
1235
|
+
const { bytesRead } = await fh.read(buf, filled, length - filled, start + filled);
|
|
1236
|
+
if (bytesRead <= 0)
|
|
1237
|
+
throw new Error(`readTailRecords: no progress reading ${path} at ${start + filled}`);
|
|
1238
|
+
filled += bytesRead;
|
|
1239
|
+
}
|
|
1240
|
+
read += length;
|
|
1241
|
+
let segEnd = length;
|
|
1242
|
+
for (let i = length - 1; i >= 0 && out.length < maxLines; i--) {
|
|
1243
|
+
if (buf[i] !== 0x0a)
|
|
1244
|
+
continue;
|
|
1245
|
+
const total = recEnd - (start + i + 1);
|
|
1246
|
+
emit(Buffer.concat([buf.subarray(i + 1, segEnd), acc]), total, start + i + 1);
|
|
1247
|
+
acc = Buffer.alloc(0);
|
|
1248
|
+
recEnd = start + i;
|
|
1249
|
+
segEnd = i;
|
|
1250
|
+
}
|
|
1251
|
+
if (out.length >= maxLines) {
|
|
1252
|
+
pos = start + segEnd;
|
|
1253
|
+
break;
|
|
1254
|
+
}
|
|
1255
|
+
acc = Buffer.concat([buf.subarray(0, segEnd), acc]);
|
|
1256
|
+
if (acc.length > KEEP)
|
|
1257
|
+
acc = acc.subarray(0, KEEP);
|
|
1258
|
+
pos = start;
|
|
1259
|
+
}
|
|
1260
|
+
// The first record of the file, when the read reached it.
|
|
1261
|
+
if (pos === 0 && out.length < maxLines) {
|
|
1262
|
+
emit(acc, recEnd, 0);
|
|
1263
|
+
recEnd = 0;
|
|
1264
|
+
}
|
|
1265
|
+
return { records: out.reverse(), truncated: recEnd > 0, end };
|
|
1266
|
+
}
|
|
1005
1267
|
function toRecord(piece, bytes, offset) {
|
|
1006
1268
|
if (bytes > LINE_MAX_BYTES) {
|
|
1007
1269
|
let endAt = Math.min(LONG_HEAD_BYTES, piece.length);
|