@yaklabs-ai/plugin-sdk 0.54.0 → 0.54.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.
@@ -1,12 +1,20 @@
1
1
  // packages/herd-transcript/dist/context-messages.js
2
+ var TAB_CONTEXT_CUSTOM_TYPE = "tab_context";
2
3
  var UI_ACTION_CUSTOM_TYPE = "ui_action";
4
+ var COMPOSER_REFERENCES_CUSTOM_TYPE = "composer_references";
3
5
  var USER_PASTED_CONTENT_CUSTOM_TYPE = "user_pasted_content";
4
6
  var ATTACHMENTS_CUSTOM_TYPE = "attachments";
5
7
  var DAEMON_SERVICE_TURN_CUSTOM_TYPE = "daemon_service_turn";
8
+ var COLLABORATION_MESSAGE_CUSTOM_TYPE = "collaboration_message";
9
+ var RUNTIME_NOTICE_CUSTOM_TYPE = "runtime_notice";
10
+ var AVAILABILITY_FACTS_CUSTOM_TYPE = "availability_facts";
6
11
  var MID_TURN_COMPACTION_OUTCOME_CUSTOM_TYPE = "mid_turn_compaction_outcome";
7
12
  var RUN_CONTINUATION_CARRIER_CUSTOM_TYPE = "herd_run_continuation";
8
13
  var DYNAMIC_CONTEXT_CUSTOM_TYPE = "dynamic_context";
14
+ var USER_SHELL_COMMAND_CUSTOM_TYPE = "user_shell_command";
9
15
  var USER_INVOKED_CUSTOM_TYPE = "user_invoked";
16
+ var HEADLESS_OPERATION_CUSTOM_TYPE = "headless_operation";
17
+ var SYSTEM_PROMPT_DELTA_CUSTOM_TYPE = "system_prompt_delta";
10
18
 
11
19
  // packages/herd-transcript/dist/turn-messages.js
12
20
  var SUBAGENT_RESULT_CUSTOM_TYPE = "subagent_result";
@@ -215,6 +223,8 @@ var coverageSchema = z2.strictObject({
215
223
 
216
224
  // packages/herd-transcript/dist/run-failure.js
217
225
  var RUN_FAILURE_DIAGNOSTIC_TYPE = "herd.run.failure";
226
+ var RUN_FAILURE_CUSTOM_TYPE = "run_failure";
227
+ var RUN_RECOVERY_CUSTOM_TYPE = "run_recovery";
218
228
  var runFailureCauseSchema = z3.strictObject({
219
229
  reason: z3.enum(RUN_FAILURE_REASONS),
220
230
  source: z3.enum(["assistant_message", "exception", "runtime"]),
@@ -1414,7 +1424,7 @@ function reduceToolResultMessage(state, event, replay) {
1414
1424
  const body = getPath(asRecord2(event) ?? {}, ["message"]) ?? getPath(asRecord2(event) ?? {}, ["entry"]) ?? event;
1415
1425
  return reduceToolCompletion(state, normalizeToolResultMessageCompletion(body, getTimestamp(event), getEntryId(event)), replay);
1416
1426
  }
1417
- function normalizeToolResultMessageCompletion(body, completedAt, entryId) {
1427
+ function normalizeToolResultMessageCompletion(body, completedAt, entryId2) {
1418
1428
  const record = asRecord2(body);
1419
1429
  const toolCallId = getToolCallId(body);
1420
1430
  if (record === void 0 || toolCallId === void 0)
@@ -1423,7 +1433,7 @@ function normalizeToolResultMessageCompletion(body, completedAt, entryId) {
1423
1433
  const resultText = getResultText(record);
1424
1434
  return {
1425
1435
  toolCallId,
1426
- ...stringField("entryId", entryId),
1436
+ ...stringField("entryId", entryId2),
1427
1437
  ...stringField("name", getToolName(record)),
1428
1438
  ...stringField("resultText", resultText),
1429
1439
  ...unknownField("resultDetails", record["details"]),
@@ -3932,10 +3942,564 @@ function contentText(content) {
3932
3942
  function asRecord3(value) {
3933
3943
  return typeof value === "object" && value !== null ? value : void 0;
3934
3944
  }
3945
+
3946
+ // packages/plugin-protocol/dist/phase-shift.js
3947
+ import { z as z7 } from "zod";
3948
+
3949
+ // packages/plugin-protocol/dist/transcript.js
3950
+ import { z as z6 } from "zod";
3951
+ var WorkBlockCoverageSchema = z6.strictObject({
3952
+ firstToolResultEntryId: z6.string().min(1),
3953
+ lastToolResultEntryId: z6.string().min(1),
3954
+ toolResultEntryIds: z6.array(z6.string().min(1)).min(1).max(4096)
3955
+ }).refine((value) => value.firstToolResultEntryId === value.toolResultEntryIds[0] && value.lastToolResultEntryId === value.toolResultEntryIds.at(-1) && new Set(value.toolResultEntryIds).size === value.toolResultEntryIds.length);
3956
+ var RUN_STARTED_CUSTOM_TYPE = "session_run_started";
3957
+ var RUN_TERMINAL_CUSTOM_TYPE2 = "session_run_state";
3958
+
3959
+ // packages/plugin-protocol/dist/phase-shift.js
3960
+ var PHASE_SHIFT_EXTENSION_ID = "kay.phase-shift";
3961
+ var PHASE_SHIFT_ENTRY_NAME = "observation";
3962
+ var PHASE_SHIFT_CUSTOM_TYPE = `ext:${PHASE_SHIFT_EXTENSION_ID}:${PHASE_SHIFT_ENTRY_NAME}`;
3963
+ var PHASE_SHIFT_TIMELINE_CUSTOM_TYPE = `ext:${PHASE_SHIFT_EXTENSION_ID}:timeline`;
3964
+ var PHASE_SHIFT_DETECTOR_VERSION = "activity-memory-v1";
3965
+ var entryId = z7.string().min(1).max(256);
3966
+ var purpose = z7.string().trim().min(1).max(320);
3967
+ var sourceTime = z7.iso.datetime();
3968
+ var phaseShiftMemorySchema = z7.object({
3969
+ startEntryId: entryId,
3970
+ purpose,
3971
+ anchors: z7.array(z7.object({ entryId, excerpt: z7.string().max(250) })).min(1).max(3)
3972
+ });
3973
+ var phaseShiftCostSchema = z7.object({
3974
+ amountUsd: z7.number().nonnegative(),
3975
+ amountBasis: z7.enum(["measured", "list-estimate", "unknown"]),
3976
+ inputTokens: z7.number().int().nonnegative(),
3977
+ outputTokens: z7.number().int().nonnegative(),
3978
+ /**
3979
+ * The highest provider-attempt ordinal this check accounted for; recovery
3980
+ * after a failure makes it more than one. An attempt that threw before
3981
+ * reporting usage is invisible to accounting, so this is a lower bound on
3982
+ * what the provider was actually asked to do.
3983
+ */
3984
+ attempts: z7.number().int().positive()
3985
+ });
3986
+ var observationFields = {
3987
+ detectorVersion: z7.literal(PHASE_SHIFT_DETECTOR_VERSION),
3988
+ modelReference: z7.string().min(1).max(256),
3989
+ observedAt: z7.iso.datetime(),
3990
+ throughEntryId: entryId,
3991
+ windowEntryIds: z7.array(entryId).min(1).max(40),
3992
+ memory: phaseShiftMemorySchema
3993
+ };
3994
+ var changeFields = {
3995
+ startEntryId: entryId,
3996
+ relation: z7.enum(["outcome", "phase"]),
3997
+ reason: z7.string().trim().min(1).max(2e3),
3998
+ purposeAfter: purpose
3999
+ };
4000
+ var phaseShiftObservationV1Schema = z7.object({
4001
+ version: z7.literal(1),
4002
+ ...observationFields,
4003
+ changes: z7.array(z7.object(changeFields)).max(39)
4004
+ });
4005
+ var phaseShiftObservationV2Schema = z7.object({
4006
+ version: z7.literal(2),
4007
+ ...observationFields,
4008
+ /** Timestamp of the `windowEntryIds[0]` entry: where this check's coverage starts. */
4009
+ windowStartAt: sourceTime,
4010
+ /** Timestamp of the `throughEntryId` entry: where this check's coverage ends. */
4011
+ throughAt: sourceTime,
4012
+ /** What this check cost to run; absent on a record written before it was accounted. */
4013
+ cost: phaseShiftCostSchema.optional(),
4014
+ changes: z7.array(z7.object({
4015
+ ...changeFields,
4016
+ /** Timestamp of the `startEntryId` entry: when the new work began. */
4017
+ startedAt: sourceTime
4018
+ })).max(39)
4019
+ });
4020
+ var phaseShiftObservationSchema = z7.discriminatedUnion("version", [
4021
+ phaseShiftObservationV1Schema,
4022
+ phaseShiftObservationV2Schema
4023
+ ]);
4024
+
4025
+ // packages/time/dist/temporal.js
4026
+ import { Temporal as Polyfill } from "@js-temporal/polyfill";
4027
+ var engineTemporal = Reflect.get(globalThis, "Temporal");
4028
+
4029
+ // packages/plugin-protocol/dist/transcript-review.js
4030
+ var RUN_INPUT_CUSTOM_TYPE = "session_run_input";
4031
+ var ANSI_RE = new RegExp([
4032
+ "\\u001b\\[[0-?]*[ -/]*[@-~]",
4033
+ "\\u001b\\][^\\u0007\\u001b]*(?:\\u0007|\\u001b\\\\)",
4034
+ "\\u001b[@-Z\\\\-_]",
4035
+ "\\[[0-9;]*m"
4036
+ ].join("|"), "g");
4037
+
4038
+ // packages/agent-runtime-protocol/dist/model-change-reason.js
4039
+ var MODEL_CHANGE_REASON_CUSTOM_TYPE = "model_change_reason";
4040
+
4041
+ // packages/agent-runtime-protocol/dist/run-offline-stop.js
4042
+ import { z as z8 } from "zod";
4043
+ var RUN_OFFLINE_STOP_CUSTOM_TYPE = "run_offline_stop";
4044
+ var runOfflineStopSchema = z8.strictObject({
4045
+ failureRef: failureRefSchema
4046
+ });
4047
+
4048
+ // packages/agent-runtime-protocol/dist/routed-send.js
4049
+ function standsInForHumanSend(details) {
4050
+ return typeof details === "object" && details !== null && details.standsInForHumanSend === true;
4051
+ }
4052
+
4053
+ // packages/agent-runtime-protocol/dist/transcript-type-table.js
4054
+ function recordOf(value) {
4055
+ return typeof value === "object" && value !== null ? value : void 0;
4056
+ }
4057
+ function stringField2(details, key) {
4058
+ const value = recordOf(details)?.[key];
4059
+ return typeof value === "string" ? value : void 0;
4060
+ }
4061
+ var DAEMON_SERVICE_AUDIENCE = {
4062
+ wake: "model",
4063
+ subagent_brief: "person",
4064
+ subagent_wake: "model",
4065
+ automation: "model",
4066
+ followup_lane: "model",
4067
+ continuation: "person"
4068
+ };
4069
+ function daemonServiceOf(details) {
4070
+ const service = stringField2(details, "service");
4071
+ return service !== void 0 && Object.hasOwn(DAEMON_SERVICE_AUDIENCE, service) ? service : void 0;
4072
+ }
4073
+ function unansweredPermissionKind(details) {
4074
+ if (stringField2(details, "noticeKind") !== "permission_ask_unanswered")
4075
+ return void 0;
4076
+ const kind = stringField2(details, "kind");
4077
+ return kind === "expired" || kind === "undisplayed" ? kind : void 0;
4078
+ }
4079
+ function answersToolCall(details) {
4080
+ const toolCallId = stringField2(details, "toolCallId");
4081
+ return toolCallId === void 0 ? void 0 : { toolCallId };
4082
+ }
4083
+ function answersDraftCard(details) {
4084
+ const toolCallId = stringField2(details, "reviewToolCallId");
4085
+ if (toolCallId === void 0)
4086
+ return void 0;
4087
+ const elementId = stringField2(details, "elementId");
4088
+ return elementId === void 0 ? { toolCallId } : { toolCallId, elementId };
4089
+ }
4090
+ function herdPlacement(typeKey) {
4091
+ const row = DEFAULT_CUSTOM_MESSAGE_PLACEMENTS.get(typeKey);
4092
+ if (row === void 0)
4093
+ throw new Error(`@herd/transcript has no placement for ${typeKey}`);
4094
+ return row.placement;
4095
+ }
4096
+ var MESSAGE_DRAFT_SENT_TYPE = "message_draft_sent";
4097
+ var INTERRUPTED_RUN_RESUME_NOTE_CUSTOM_TYPE = "interrupted_run_resume_note";
4098
+ var ROWS = [
4099
+ // The six companions of a person's send, delivered in the same batch as its text: context and
4100
+ // attachments before it, dynamic context after. The bubble draws the three the person made
4101
+ // (attachments as its footer, an invoked command as its pill, a paste inline where it was
4102
+ // typed); the other three are context computed for the model. A card answer is not one (a
4103
+ // parts-only send is the input itself), nor is a shell command the person ran (a record of
4104
+ // its own, never tied to a text send).
4105
+ {
4106
+ typeKey: ATTACHMENTS_CUSTOM_TYPE,
4107
+ kinds: ["context"],
4108
+ placement: herdPlacement(ATTACHMENTS_CUSTOM_TYPE),
4109
+ audience: "person"
4110
+ },
4111
+ {
4112
+ typeKey: USER_INVOKED_CUSTOM_TYPE,
4113
+ kinds: ["context"],
4114
+ placement: herdPlacement(USER_INVOKED_CUSTOM_TYPE),
4115
+ audience: "person"
4116
+ },
4117
+ {
4118
+ typeKey: USER_PASTED_CONTENT_CUSTOM_TYPE,
4119
+ kinds: ["context"],
4120
+ placement: herdPlacement(USER_PASTED_CONTENT_CUSTOM_TYPE),
4121
+ audience: "person"
4122
+ },
4123
+ // The shell's ambient pane projection (north-star §5).
4124
+ {
4125
+ typeKey: TAB_CONTEXT_CUSTOM_TYPE,
4126
+ kinds: ["context"],
4127
+ placement: "companion-of-send",
4128
+ audience: "model"
4129
+ },
4130
+ // The pills the person picked, serialized for the agent's resolution; the bubble already shows
4131
+ // them as the marker text they typed.
4132
+ {
4133
+ typeKey: COMPOSER_REFERENCES_CUSTOM_TYPE,
4134
+ kinds: ["context"],
4135
+ placement: "companion-of-send",
4136
+ audience: "model"
4137
+ },
4138
+ // Retrieved memory and skill context, not work done on the person's behalf.
4139
+ {
4140
+ typeKey: DYNAMIC_CONTEXT_CUSTOM_TYPE,
4141
+ kinds: ["context"],
4142
+ placement: herdPlacement(DYNAMIC_CONTEXT_CUSTOM_TYPE),
4143
+ audience: "model"
4144
+ },
4145
+ // A card answer is the person's, and the card shows it: a spent MessageDraft reads Approved,
4146
+ // an answered Card collapses to the pressed label (ruling 2026-09-03). A row of its own repeated
4147
+ // it as the raw wire payload. Known gap: only MessageDraft rehydrates what was submitted, so a
4148
+ // typed Field value or an answer to a Button outside a Card survives a reload only in raw mode.
4149
+ {
4150
+ typeKey: UI_ACTION_CUSTOM_TYPE,
4151
+ kinds: ["said"],
4152
+ placement: herdPlacement(UI_ACTION_CUSTOM_TYPE),
4153
+ audience: "person",
4154
+ answers: answersToolCall
4155
+ },
4156
+ {
4157
+ typeKey: MESSAGE_DRAFT_SENT_TYPE,
4158
+ kinds: ["context"],
4159
+ placement: "standalone",
4160
+ audience: "model",
4161
+ answers: answersDraftCard
4162
+ },
4163
+ {
4164
+ typeKey: "plugin_card_submitted",
4165
+ kinds: ["context"],
4166
+ placement: "standalone",
4167
+ audience: "model"
4168
+ },
4169
+ // Tells the agent a send's outcome is unknown so it does not send again. Its text is an
4170
+ // instruction to the model. Known gap (#13684): the card states the outcome to the person only
4171
+ // in the renderer that pressed Send. It does not read this record, so after a reload or a daemon
4172
+ // restart it shows idle until a second press, which the daemon refuses as unconfirmed.
4173
+ {
4174
+ typeKey: "message_draft_send_unknown",
4175
+ kinds: ["context"],
4176
+ placement: "standalone",
4177
+ audience: "model",
4178
+ answers: answersDraftCard
4179
+ },
4180
+ // The daemon's agent-only note of a person's decision on an expired approval.
4181
+ {
4182
+ typeKey: "approval_decision",
4183
+ kinds: ["context"],
4184
+ placement: "standalone",
4185
+ audience: "model"
4186
+ },
4187
+ {
4188
+ typeKey: USER_SHELL_COMMAND_CUSTOM_TYPE,
4189
+ kinds: ["work"],
4190
+ placement: "standalone",
4191
+ audience: "person"
4192
+ },
4193
+ {
4194
+ typeKey: COLLABORATION_MESSAGE_CUSTOM_TYPE,
4195
+ kinds: ["said"],
4196
+ placement: "standalone",
4197
+ audience: "person"
4198
+ },
4199
+ // A settled result joins the agent turn that awaits it; one that does not read as settled
4200
+ // detached work stands where it landed. A spawn can keep its result out of the person's
4201
+ // transcript; that one is outside it.
4202
+ {
4203
+ typeKey: SUBAGENT_RESULT_CUSTOM_TYPE,
4204
+ kinds: ["said"],
4205
+ placement: herdPlacement(SUBAGENT_RESULT_CUSTOM_TYPE),
4206
+ audience: "person"
4207
+ },
4208
+ {
4209
+ typeKey: BACKGROUND_TASK_RESULT_CUSTOM_TYPE,
4210
+ kinds: ["work"],
4211
+ placement: herdPlacement(BACKGROUND_TASK_RESULT_CUSTOM_TYPE),
4212
+ audience: "person"
4213
+ },
4214
+ // Maintenance the run already performed, not an input the agent resumes on: post-run
4215
+ // compaction routinely lands after the final answer while the run is still open, and
4216
+ // counting it kept that answered turn reading as still working.
4217
+ {
4218
+ typeKey: COMPACTION_MARKER_CUSTOM_TYPE,
4219
+ kinds: ["context"],
4220
+ placement: herdPlacement(COMPACTION_MARKER_CUSTOM_TYPE),
4221
+ audience: "person"
4222
+ },
4223
+ // Fails closed: a service this release cannot read is the daemon's plumbing.
4224
+ {
4225
+ typeKey: DAEMON_SERVICE_TURN_CUSTOM_TYPE,
4226
+ kinds: ["said", "context"],
4227
+ // A wake delivery joins the agent turn it wakes; every other service stands where it landed.
4228
+ placement: herdPlacement(DAEMON_SERVICE_TURN_CUSTOM_TYPE),
4229
+ audience: (details) => {
4230
+ const service = daemonServiceOf(details);
4231
+ return service === void 0 ? void 0 : DAEMON_SERVICE_AUDIENCE[service];
4232
+ },
4233
+ onUndecodable: "hide"
4234
+ },
4235
+ // A notice whose kind is new to this release still reads as a generic notice. A missed-approval
4236
+ // notice of a kind this release does not know cannot say what was missed, so it hides.
4237
+ {
4238
+ typeKey: RUNTIME_NOTICE_CUSTOM_TYPE,
4239
+ kinds: ["notice"],
4240
+ placement: "standalone",
4241
+ audience: (details) => stringField2(details, "noticeKind") === "permission_ask_unanswered" && unansweredPermissionKind(details) === void 0 ? void 0 : "person",
4242
+ onUndecodable: "hide"
4243
+ },
4244
+ // Model-facing statements. Each was once visible for no decided reason, because this
4245
+ // classification allows by default.
4246
+ //
4247
+ // Who the person is connected as and what waits on a connect; Plugins and Connections show it
4248
+ // better, and the body instructs the agent.
4249
+ {
4250
+ typeKey: AVAILABILITY_FACTS_CUSTOM_TYPE,
4251
+ kinds: ["context"],
4252
+ placement: "standalone",
4253
+ audience: "model"
4254
+ },
4255
+ // The kernel telling the model a section of its own frozen instructions moved (#2996).
4256
+ {
4257
+ typeKey: SYSTEM_PROMPT_DELTA_CUSTOM_TYPE,
4258
+ kinds: ["context"],
4259
+ placement: "standalone",
4260
+ audience: "model"
4261
+ },
4262
+ // The statement into a forked headless session that no person is present.
4263
+ {
4264
+ typeKey: HEADLESS_OPERATION_CUSTOM_TYPE,
4265
+ kinds: ["context"],
4266
+ placement: "standalone",
4267
+ audience: "model"
4268
+ },
4269
+ // The note sent with a resumed run's first request: check before repeating an action.
4270
+ {
4271
+ typeKey: INTERRUPTED_RUN_RESUME_NOTE_CUSTOM_TYPE,
4272
+ kinds: ["context"],
4273
+ placement: "standalone",
4274
+ audience: "model"
4275
+ },
4276
+ // A compaction reminder riding the last result of a fan-out.
4277
+ {
4278
+ typeKey: "phase_shift_nudge",
4279
+ kinds: ["context"],
4280
+ placement: "standalone",
4281
+ audience: "model"
4282
+ },
4283
+ // Retired 2026-10-19 (the primer now rides the first call's result); older transcripts hold it.
4284
+ {
4285
+ typeKey: "auto_primer",
4286
+ kinds: ["context"],
4287
+ placement: "standalone",
4288
+ audience: "model"
4289
+ },
4290
+ // The kernel's notes to the model. The repair joins the agent turn it asks to finish; the other
4291
+ // two stay out of the transcript.
4292
+ {
4293
+ typeKey: MID_TURN_COMPACTION_OUTCOME_CUSTOM_TYPE,
4294
+ kinds: ["context"],
4295
+ placement: herdPlacement(MID_TURN_COMPACTION_OUTCOME_CUSTOM_TYPE),
4296
+ audience: "model"
4297
+ },
4298
+ {
4299
+ typeKey: FINAL_OUTPUT_REPAIR_CUSTOM_TYPE,
4300
+ kinds: ["context"],
4301
+ placement: herdPlacement(FINAL_OUTPUT_REPAIR_CUSTOM_TYPE),
4302
+ audience: "model"
4303
+ },
4304
+ {
4305
+ typeKey: RUN_CONTINUATION_CARRIER_CUSTOM_TYPE,
4306
+ kinds: ["context"],
4307
+ placement: herdPlacement(RUN_CONTINUATION_CARRIER_CUSTOM_TYPE),
4308
+ audience: "model"
4309
+ },
4310
+ // What the person sees when the policy changes their model, and a send a helper answered in the
4311
+ // session model's place (both drawn by the smart-model-selection plugin).
4312
+ {
4313
+ typeKey: "model_selection_change",
4314
+ kinds: ["notice"],
4315
+ placement: "standalone",
4316
+ audience: "person"
4317
+ },
4318
+ {
4319
+ typeKey: "model_selection_handoff",
4320
+ kinds: ["said"],
4321
+ placement: "opens-turn",
4322
+ audience: "person"
4323
+ },
4324
+ // Synthesized while reading, never written: a failed reply the renderer redraws as a
4325
+ // provider-switch notice, and activity the reducer could not classify.
4326
+ {
4327
+ typeKey: "kay.provider_fallback",
4328
+ kinds: ["notice"],
4329
+ placement: "standalone",
4330
+ audience: "person"
4331
+ },
4332
+ {
4333
+ typeKey: "herd.unknown_activity",
4334
+ kinds: ["unrecognized"],
4335
+ placement: "standalone",
4336
+ audience: "person"
4337
+ }
4338
+ ];
4339
+ function keyedRows(rows) {
4340
+ const table = /* @__PURE__ */ new Map();
4341
+ for (const row of rows) {
4342
+ if (table.has(row.typeKey))
4343
+ throw new Error(`two type rows for ${row.typeKey}`);
4344
+ table.set(row.typeKey, row);
4345
+ }
4346
+ return table;
4347
+ }
4348
+ var UNLISTED_TRANSCRIPT_TYPE_ROW = {
4349
+ typeKey: OTHER_CUSTOM_TYPES,
4350
+ kinds: ["unrecognized"],
4351
+ placement: (details, display) => standsInForHumanSend(details) ? "opens-turn" : customMessagePlacement(void 0, details, display),
4352
+ audience: "person"
4353
+ };
4354
+ var TRANSCRIPT_TYPE_TABLE = keyedRows(ROWS);
4355
+ var TRANSCRIPT_PLACEMENTS = new Map([
4356
+ ...TRANSCRIPT_TYPE_TABLE,
4357
+ [OTHER_CUSTOM_TYPES, UNLISTED_TRANSCRIPT_TYPE_ROW]
4358
+ ]);
4359
+ var ENTRY_ROWS = [
4360
+ // The daemon's bookkeeping. These were 20.3% of every attach snapshot and 26% of every tail
4361
+ // preview on 60 real transcripts (2026-09-01, apps/kay/bench/daemon-memory/projection-size.mjs);
4362
+ // a single resolved prompt is ~160 KB and a session writes one per daemon restart. Most are
4363
+ // spelled here because their constants live in @bonsai/agent-runtime, which this package cannot
4364
+ // import; the daemon's census test pins each constant to its row.
4365
+ ...[
4366
+ RUN_FAILURE_CUSTOM_TYPE,
4367
+ PHASE_SHIFT_CUSTOM_TYPE,
4368
+ RUN_TERMINAL_CUSTOM_TYPE2,
4369
+ RUN_STARTED_CUSTOM_TYPE,
4370
+ RUN_INPUT_CUSTOM_TYPE,
4371
+ "cwd_transition",
4372
+ "project_transition",
4373
+ "user_title",
4374
+ "agent_identity",
4375
+ "session_provenance",
4376
+ "processing_speed",
4377
+ "definition_permission_authority",
4378
+ "registered_definition_pointer",
4379
+ "inherited_definition_rules_pointer",
4380
+ "final_output_contract",
4381
+ "headless_session",
4382
+ "session_cleared",
4383
+ "composition_snapshot",
4384
+ "resolved_prompt",
4385
+ "model_selection",
4386
+ "owed_reply",
4387
+ // Replaced by owed_reply entries (session index migration 3); older logs still hold it.
4388
+ "subagent_task_lifecycle_event",
4389
+ // Retired 2026-09-10 with the daemon workspace roster; no install wrote one, but a log that did
4390
+ // must still keep it off the surface.
4391
+ "workspace_ref",
4392
+ // Converted pi 0.99.1 config records: data migration 4 keeps a format-3 transcript's session
4393
+ // name, model, thinking level and tool records as entries; their values live in the session's
4394
+ // own documents.
4395
+ "session_info",
4396
+ "model_change",
4397
+ "thinking_level_change",
4398
+ "active_tools_change"
4399
+ ].map((typeKey) => ({ typeKey, audience: "host-only" })),
4400
+ // Daemon-written, surface-read: the steward's recap trailer, the provider-switch notice
4401
+ // (provider-fallback-transcript.ts, #6370) and the recovered-run notice.
4402
+ { typeKey: "session_steward", audience: "person" },
4403
+ { typeKey: MODEL_CHANGE_REASON_CUSTOM_TYPE, audience: "person" },
4404
+ { typeKey: RUN_RECOVERY_CUSTOM_TYPE, audience: "person" },
4405
+ { typeKey: RUN_OFFLINE_STOP_CUSTOM_TYPE, audience: "person" }
4406
+ ];
4407
+ var CUSTOM_ENTRY_TYPE_TABLE = keyedRows(ENTRY_ROWS);
4408
+
4409
+ // packages/agent-runtime-protocol/dist/failure-echo.js
4410
+ function stripErrorLabel(text) {
4411
+ return text.replace(/^\s*(?:\S+\s+)?error:\s*/i, "").trim();
4412
+ }
4413
+ function echoesFailure(text, failure) {
4414
+ const candidate = stripErrorLabel(text);
4415
+ if (candidate === "")
4416
+ return false;
4417
+ if (candidate === failure)
4418
+ return true;
4419
+ if (looksLikeHtml(candidate) && readableFailureText(candidate) === failure) {
4420
+ return true;
4421
+ }
4422
+ return failure.endsWith("\u2026") && candidate.startsWith(failure.slice(0, -1));
4423
+ }
4424
+ function withoutFailureEcho(item) {
4425
+ const failure = stripErrorLabel(item.failureText ?? "");
4426
+ if (failure === "")
4427
+ return item;
4428
+ const parts = item.parts.filter((part) => part.type !== "text" || !echoesFailure(part.text, failure));
4429
+ return parts.length === item.parts.length ? item : { ...item, parts };
4430
+ }
4431
+ function visibleTextWithoutFailureEcho(item) {
4432
+ if (item.parts.length === 0) {
4433
+ const text = item.text ?? "";
4434
+ const failure = stripErrorLabel(item.failureText ?? "");
4435
+ return failure !== "" && echoesFailure(text, failure) ? "" : text;
4436
+ }
4437
+ const texts = [];
4438
+ for (const part of withoutFailureEcho(item).parts) {
4439
+ if (part.type === "text")
4440
+ texts.push(part.text);
4441
+ }
4442
+ return texts.join("\n");
4443
+ }
4444
+
4445
+ // packages/agent-runtime-protocol/dist/answer-stretch.js
4446
+ function isReply2(block) {
4447
+ return block.kind === "final_answer" || block.kind === "provisional_response";
4448
+ }
4449
+ function isBackgroundInput(block) {
4450
+ if (block.kind !== "custom_message")
4451
+ return false;
4452
+ const { message } = block;
4453
+ if (isEmbeddedAgentResultMessage(message) || isDaemonWakeMessage(message))
4454
+ return true;
4455
+ if (message.customType !== DAEMON_SERVICE_TURN_CUSTOM_TYPE)
4456
+ return false;
4457
+ const service = daemonServiceOf(message.details);
4458
+ return service === "automation" || service === "followup_lane";
4459
+ }
4460
+ function isBareFailureReply(block) {
4461
+ return block.status === "failed" && visibleTextWithoutFailureEcho(block.source).trim() === "";
4462
+ }
4463
+ function isStretchAnswer(block) {
4464
+ return isReply2(block) && !isBareFailureReply(block) && block.text.trim() !== "";
4465
+ }
4466
+ function answerStretchStarts(blocks) {
4467
+ const starts = /* @__PURE__ */ new Set();
4468
+ let answered = false;
4469
+ let pendingInput;
4470
+ for (const block of blocks) {
4471
+ if (block.kind === "steer_message") {
4472
+ starts.add(block.id);
4473
+ answered = false;
4474
+ pendingInput = void 0;
4475
+ } else if (answered && pendingInput === void 0 && isBackgroundInput(block)) {
4476
+ pendingInput = block.id;
4477
+ } else if (isStretchAnswer(block)) {
4478
+ if (pendingInput !== void 0)
4479
+ starts.add(pendingInput);
4480
+ pendingInput = void 0;
4481
+ answered = true;
4482
+ }
4483
+ }
4484
+ return starts;
4485
+ }
4486
+ function stretchOpeningResults(blocks, start) {
4487
+ const results = [];
4488
+ for (const block of blocks.slice(start)) {
4489
+ if (block.kind !== "custom_message")
4490
+ break;
4491
+ if (isEmbeddedAgentResultMessage(block.message))
4492
+ results.push(block);
4493
+ }
4494
+ return results;
4495
+ }
3935
4496
  export {
4497
+ TRANSCRIPT_TYPE_TABLE,
4498
+ answerStretchStarts,
3936
4499
  customMessagePlacement,
3937
4500
  eventsForEntry,
3938
4501
  projectCanonicalTranscript,
3939
4502
  reconstructInteractiveState,
3940
- runBoundaryReplayEvent
4503
+ runBoundaryReplayEvent,
4504
+ stretchOpeningResults
3941
4505
  };