@netnodeag/kraftwerk 0.90.0 → 0.92.0

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.
Files changed (30) hide show
  1. package/dist/config.d.ts +5 -5
  2. package/dist/config.js +5 -5
  3. package/dist/core/chat/seats.js +24 -1
  4. package/dist/core/chat/sessions.js +26 -3
  5. package/dist/core/chat/types.d.ts +7 -0
  6. package/dist/core/git.d.ts +16 -7
  7. package/dist/core/git.js +66 -17
  8. package/dist/core/settings.d.ts +1 -1
  9. package/dist/core/settings.js +2 -2
  10. package/dist/server/api/git.js +1 -1
  11. package/package.json +1 -1
  12. package/schema/kraftwerk.schema.json +4 -3
  13. package/web/dist/assets/{dist-C02y1COo.js → dist-BDzDJxBN.js} +1 -1
  14. package/web/dist/assets/{dist-BOtvWBvw.js → dist-BJHyEMD6.js} +1 -1
  15. package/web/dist/assets/{dist-DaZ2deKm.js → dist-BMw0PFGO.js} +1 -1
  16. package/web/dist/assets/{dist-DBxnTDVP.js → dist-BSM_KuBz.js} +1 -1
  17. package/web/dist/assets/{dist-DVQGJ3jn.js → dist-BVlbFMCK.js} +1 -1
  18. package/web/dist/assets/{dist-DsN_iYo9.js → dist-CM-I3GJQ.js} +1 -1
  19. package/web/dist/assets/{dist-CiW4TrSe.js → dist-CY76FfB-.js} +1 -1
  20. package/web/dist/assets/dist-CdbA3SAY.js +1 -0
  21. package/web/dist/assets/{dist-CpaDCoU0.js → dist-CuJkNA8f.js} +1 -1
  22. package/web/dist/assets/{dist-CwOPtmsk.js → dist-D2ma_vc1.js} +1 -1
  23. package/web/dist/assets/{dist-Dh-E5q9S.js → dist-DFZMTIk8.js} +1 -1
  24. package/web/dist/assets/{editor-BvzQYKnF.js → editor-JaYZTIcu.js} +3 -3
  25. package/web/dist/assets/index-63UhW1II.js +485 -0
  26. package/web/dist/assets/index-BiOStRo2.css +2 -0
  27. package/web/dist/index.html +2 -2
  28. package/web/dist/assets/dist-CEl-JzsB.js +0 -1
  29. package/web/dist/assets/index-B2HLf5j4.js +0 -485
  30. package/web/dist/assets/index-Dfq5Ocno.css +0 -2
package/dist/config.d.ts CHANGED
@@ -27,7 +27,7 @@
27
27
  * git: # workspace git sync (absent = off, bare key = on with defaults)
28
28
  * remote: origin
29
29
  * interval: 300 # seconds between background fetches
30
- * autosync: pull # off | pull
30
+ * autosync: pull # off | pull | push (push = pull, then push what is committed)
31
31
  * repos: # git repositories the agents work on (absent = off, bare key = on)
32
32
  * root: kraftwerk-data/repos # where clones land, relative to the file. Default: repos
33
33
  * vibeables: # small apps built live in a chat, rendered in the inspector (absent = off, bare key = on)
@@ -47,8 +47,8 @@ export declare const CONFIG_FILENAMES: string[];
47
47
  /**
48
48
  * Git sync for the workspace. The synced paths are not configurable: they
49
49
  * are the roots this file already declares (workflows, knowledge, agents,
50
- * skills), channels/, README.md and kraftwerk.yml itself. Commit and push stay manual; the
51
- * interval only fetches, and pulls when `autosync` allows it.
50
+ * skills), channels/, README.md and kraftwerk.yml itself. Commits stay manual; the
51
+ * interval fetches, pulls when `autosync` allows it, and pushes only with `autosync: push`.
52
52
  */
53
53
  /**
54
54
  * A remote or branch name kraftwerk will hand to git as a positional
@@ -66,8 +66,8 @@ export interface GitConfig {
66
66
  branch?: string;
67
67
  /** Seconds between background fetches. 0 disables the timer. Default: 300. */
68
68
  interval?: number;
69
- /** off = fetch only. pull = also fast-forward when behind and clean. Default: pull. */
70
- autosync?: "off" | "pull";
69
+ /** off = fetch only. pull = also fast-forward when behind and clean. push = pull, and push commits that are ahead. Default: pull. */
70
+ autosync?: "off" | "pull" | "push";
71
71
  }
72
72
  /**
73
73
  * Repositories: git clones the agents work on, kept under one root inside
package/dist/config.js CHANGED
@@ -32,7 +32,7 @@ import { parse } from "yaml";
32
32
  * git: # workspace git sync (absent = off, bare key = on with defaults)
33
33
  * remote: origin
34
34
  * interval: 300 # seconds between background fetches
35
- * autosync: pull # off | pull
35
+ * autosync: pull # off | pull | push (push = pull, then push what is committed)
36
36
  * repos: # git repositories the agents work on (absent = off, bare key = on)
37
37
  * root: kraftwerk-data/repos # where clones land, relative to the file. Default: repos
38
38
  * vibeables: # small apps built live in a chat, rendered in the inspector (absent = off, bare key = on)
@@ -53,8 +53,8 @@ const WORKFLOW_ROOT_CANDIDATES = ["src/workflows", "workflows"];
53
53
  /**
54
54
  * Git sync for the workspace. The synced paths are not configurable: they
55
55
  * are the roots this file already declares (workflows, knowledge, agents,
56
- * skills), channels/, README.md and kraftwerk.yml itself. Commit and push stay manual; the
57
- * interval only fetches, and pulls when `autosync` allows it.
56
+ * skills), channels/, README.md and kraftwerk.yml itself. Commits stay manual; the
57
+ * interval fetches, pulls when `autosync` allows it, and pushes only with `autosync: push`.
58
58
  */
59
59
  /**
60
60
  * A remote or branch name kraftwerk will hand to git as a positional
@@ -429,8 +429,8 @@ function validateGit(configPath, value) {
429
429
  if (g.interval !== undefined && (typeof g.interval !== "number" || !Number.isInteger(g.interval) || g.interval < 0)) {
430
430
  throw new Error(`${file}: git.interval must be a whole number of seconds (0 disables the timer)`);
431
431
  }
432
- if (g.autosync !== undefined && g.autosync !== "off" && g.autosync !== "pull") {
433
- throw new Error(`${file}: git.autosync must be "off" or "pull"`);
432
+ if (g.autosync !== undefined && g.autosync !== "off" && g.autosync !== "pull" && g.autosync !== "push") {
433
+ throw new Error(`${file}: git.autosync must be "off", "pull" or "push"`);
434
434
  }
435
435
  }
436
436
  /**
@@ -10,7 +10,7 @@ import { writeMeta } from "./store.js";
10
10
  import { availableSkills } from "./context.js";
11
11
  import { effectiveCwd } from "./sessions.js";
12
12
  import { sessionTemp } from "../temp.js";
13
- import { emit, isUnattended, ownerLabel, seatAuthor } from "./state.js";
13
+ import { MAIN, emit, isUnattended, ownerLabel, seatAuthor } from "./state.js";
14
14
  /**
15
15
  * Starting an agent process for a seat: its harness, tuning (model,
16
16
  * effort), working folder and context, and wiring its events into the chat.
@@ -190,5 +190,28 @@ export async function ensureBackend(state, seat) {
190
190
  // in its window. A fresh process is a fresh context window: re-send the
191
191
  // scope context with the next prompt.
192
192
  seat.needsContext = !seat.backend.resumed;
193
+ await applyPendingConfig(state, seat);
193
194
  return seat.backend;
194
195
  }
196
+ /**
197
+ * Settings picked while the agent was down (meta.pendingConfig), applied to
198
+ * the fresh backend before anything is prompted. One the agent refuses is
199
+ * said in the thread and dropped; the chat goes on with the agent's default.
200
+ */
201
+ async function applyPendingConfig(state, seat) {
202
+ const pending = state.meta.pendingConfig;
203
+ if (seat.key !== MAIN || !pending)
204
+ return;
205
+ delete state.meta.pendingConfig;
206
+ void writeMeta(state.meta).catch(() => { });
207
+ if (!seat.backend?.setConfig)
208
+ return;
209
+ for (const [configId, value] of Object.entries(pending)) {
210
+ try {
211
+ await seat.backend.setConfig(configId, value);
212
+ }
213
+ catch (err) {
214
+ emit(state, { type: "error", message: `could not apply ${configId} = ${String(value)}: ${err.message}` });
215
+ }
216
+ }
217
+ }
@@ -453,9 +453,12 @@ export async function setChatConfig(id, configId, value) {
453
453
  const state = await loadState(id);
454
454
  if (!state)
455
455
  return { error: "not found" };
456
- const backend = mainSeat(state).backend;
457
- if (!backend?.setConfig)
458
- return { error: "the agent is not running — send a message first, the settings appear once it is up" };
456
+ const seat = mainSeat(state);
457
+ const backend = seat.backend;
458
+ if (!backend)
459
+ return pendConfig(state, configId, value);
460
+ if (!backend.setConfig)
461
+ return { error: "this agent does not take settings" };
459
462
  try {
460
463
  await backend.setConfig(configId, value);
461
464
  return {};
@@ -464,6 +467,26 @@ export async function setChatConfig(id, configId, value) {
464
467
  return { error: err.message };
465
468
  }
466
469
  }
470
+ /**
471
+ * The agent is not running (idle reaper, restart, or it never started): keep
472
+ * the choice in meta.pendingConfig for the next start, and show it now by
473
+ * re-announcing the last known settings with the new value. Only an option
474
+ * the agent announced before, with a value it offered, is kept.
475
+ */
476
+ async function pendConfig(state, configId, value) {
477
+ const last = [...state.events].reverse().find((e) => e.type === "config" && !e.from);
478
+ const options = last?.type === "config" ? last.options : [];
479
+ const option = options.find((o) => o.id === configId);
480
+ if (!option)
481
+ return { error: "the agent is not running and has not announced this setting yet — send a message first" };
482
+ if (option.type === "select" ? typeof value !== "string" || !option.choices.some((c) => c.value === value) : typeof value !== "boolean") {
483
+ return { error: `"${String(value)}" is not a choice for ${option.name}` };
484
+ }
485
+ state.meta.pendingConfig = { ...state.meta.pendingConfig, [configId]: value };
486
+ await writeMeta(state.meta);
487
+ emit(state, { type: "config", options: options.map((o) => (o.id === configId ? { ...o, value } : o)) });
488
+ return {};
489
+ }
467
490
  /** The agent's own sessions in the project root (Claude Code / Codex transcripts), to continue one as a chat. */
468
491
  export async function listAgentSessionsFor(agent) {
469
492
  if (agent === "pi")
@@ -85,6 +85,13 @@ export interface ChatMeta {
85
85
  * over with the transcript as a summary.
86
86
  */
87
87
  sessions?: Record<string, string>;
88
+ /**
89
+ * Settings (model, thinking depth, ...) picked while the chat's agent was
90
+ * not running, by config id. The next backend of the main seat applies
91
+ * them before its first prompt, then they are dropped: switching away
92
+ * from a model that hit its limit must not need a message on that model.
93
+ */
94
+ pendingConfig?: Record<string, string | boolean>;
88
95
  /** Who started the chat (a routine's run: this machine's person). */
89
96
  author?: ChatPerson;
90
97
  /**
@@ -14,9 +14,13 @@
14
14
  * - Reads are scoped too: the diff endpoint only shows a path the status
15
15
  * screen lists as syncable, and status never lists what .gitignore hides,
16
16
  * so an untracked .env cannot be read through it.
17
- * - Commit and push are manual. The background timer only fetches, and pulls
18
- * fast-forward when `autosync: pull` is set, the configured branch is the
19
- * one checked out, and no tracked file is modified.
17
+ * - Commits are manual. The background timer only fetches, and pulls
18
+ * fast-forward when `autosync` is `pull` or `push`, the configured branch
19
+ * is the one checked out, and no tracked file is modified.
20
+ * - Push is a click, unless `autosync: push` opts in: then the timer also
21
+ * pushes commits that already exist to a branch that already tracks its
22
+ * upstream. It never creates a commit, never publishes a new branch and
23
+ * never forces.
20
24
  * - A diverged branch is reported, never merged or rebased from here.
21
25
  *
22
26
  * Every git call passes an argument array, so nothing reaches a shell, and
@@ -28,6 +32,8 @@
28
32
  /** Files that must never be staged, whatever the scope says. */
29
33
  /** Paths whose content is never shown or synced, whichever repo they sit in. */
30
34
  export declare const DENY: RegExp[];
35
+ /** off = fetch only. pull = also fast-forward. push = fast-forward, then push what is ahead. */
36
+ export type Autosync = "off" | "pull" | "push";
31
37
  export interface GitFile {
32
38
  /** Path relative to the repo root, which is what git speaks. */
33
39
  path: string;
@@ -58,10 +64,12 @@ export interface GitStatus {
58
64
  blockedHidden?: number;
59
65
  /** Repo-relative roots that may be committed. */
60
66
  scope?: string[];
61
- autosync?: "off" | "pull";
67
+ autosync?: Autosync;
62
68
  interval?: number;
63
69
  lastFetch?: string;
64
70
  lastPull?: string;
71
+ /** The last push that worked, by hand or in the background. */
72
+ lastPush?: string;
65
73
  lastError?: string;
66
74
  }
67
75
  export interface GitDiff {
@@ -139,9 +147,10 @@ export declare function gitPush(): Promise<{
139
147
  error?: string;
140
148
  }>;
141
149
  /**
142
- * Fetch on an interval, and fast-forward when `autosync: pull` is set. Never
143
- * commits. A pull is skipped while the tree is dirty, so nobody's unsaved
144
- * work is disturbed by a background merge. Ticks are chained, not scheduled
150
+ * Fetch on an interval, fast-forward when `autosync` is `pull` or `push`,
151
+ * and with `push` also push what is ahead. Never commits. A pull is skipped
152
+ * while the tree is dirty, so nobody's unsaved work is disturbed by a
153
+ * background merge. Ticks are chained, not scheduled
145
154
  * on a fixed interval: a fetch against a slow remote must finish (or time
146
155
  * out) before the next one starts, or a short interval piles up processes.
147
156
  */
package/dist/core/git.js CHANGED
@@ -22,9 +22,13 @@ import { workspaceEnv } from "./env.js";
22
22
  * - Reads are scoped too: the diff endpoint only shows a path the status
23
23
  * screen lists as syncable, and status never lists what .gitignore hides,
24
24
  * so an untracked .env cannot be read through it.
25
- * - Commit and push are manual. The background timer only fetches, and pulls
26
- * fast-forward when `autosync: pull` is set, the configured branch is the
27
- * one checked out, and no tracked file is modified.
25
+ * - Commits are manual. The background timer only fetches, and pulls
26
+ * fast-forward when `autosync` is `pull` or `push`, the configured branch
27
+ * is the one checked out, and no tracked file is modified.
28
+ * - Push is a click, unless `autosync: push` opts in: then the timer also
29
+ * pushes commits that already exist to a branch that already tracks its
30
+ * upstream. It never creates a commit, never publishes a new branch and
31
+ * never forces.
28
32
  * - A diverged branch is reported, never merged or rebased from here.
29
33
  *
30
34
  * Every git call passes an argument array, so nothing reaches a shell, and
@@ -344,10 +348,13 @@ const gitState = perWorkspace(() => ({
344
348
  chain: Promise.resolve(),
345
349
  lastFetch: undefined,
346
350
  lastPull: undefined,
351
+ lastPush: undefined,
347
352
  lastError: undefined,
348
353
  timer: null,
349
354
  ticking: false,
350
355
  lastRun: 0,
356
+ /** A commit asked for a sync while a tick was in flight: run one more right after it. */
357
+ again: false,
351
358
  /** Set when the workspace closes: a tick in flight does not schedule the next one. */
352
359
  stopped: false,
353
360
  }));
@@ -415,6 +422,7 @@ export async function gitStatus(fresh = false) {
415
422
  interval: repo.cfg.interval,
416
423
  lastFetch: gitState().lastFetch,
417
424
  lastPull: gitState().lastPull,
425
+ lastPush: gitState().lastPush,
418
426
  lastError: gitState().lastError,
419
427
  };
420
428
  // A failed status (a stale index.lock, a timeout on a huge untracked tree)
@@ -561,6 +569,9 @@ async function commitNow(paths, message) {
561
569
  return { ok: false, error };
562
570
  }
563
571
  touched();
572
+ // With `autosync: push` a commit should not sit here until the next interval.
573
+ if (repo.cfg.autosync === "push")
574
+ syncSoon();
564
575
  return { ok: true, committed: paths.length };
565
576
  }
566
577
  export function gitFetch() {
@@ -633,6 +644,7 @@ async function pushNow() {
633
644
  gitState().lastError = r.stderr || "push failed";
634
645
  return { ok: false, error: gitState().lastError };
635
646
  }
647
+ gitState().lastPush = new Date().toISOString();
636
648
  gitState().lastError = undefined;
637
649
  return { ok: true };
638
650
  }
@@ -645,9 +657,10 @@ async function pushNow() {
645
657
  */
646
658
  const RECHECK_MS = 60_000;
647
659
  /**
648
- * Fetch on an interval, and fast-forward when `autosync: pull` is set. Never
649
- * commits. A pull is skipped while the tree is dirty, so nobody's unsaved
650
- * work is disturbed by a background merge. Ticks are chained, not scheduled
660
+ * Fetch on an interval, fast-forward when `autosync` is `pull` or `push`,
661
+ * and with `push` also push what is ahead. Never commits. A pull is skipped
662
+ * while the tree is dirty, so nobody's unsaved work is disturbed by a
663
+ * background merge. Ticks are chained, not scheduled
651
664
  * on a fixed interval: a fetch against a slow remote must finish (or time
652
665
  * out) before the next one starts, or a short interval piles up processes.
653
666
  */
@@ -665,6 +678,25 @@ export function stopGitSync() {
665
678
  clearTimeout(s.timer);
666
679
  s.timer = null;
667
680
  }
681
+ /**
682
+ * Run the background sync now instead of at the next interval. Goes through
683
+ * the timer, so it is a no-op while the timer is off (interval 0) or the
684
+ * workspace's sync was never started, and it never overlaps a running tick.
685
+ */
686
+ function syncSoon() {
687
+ const s = gitState();
688
+ if (s.stopped)
689
+ return;
690
+ s.lastRun = 0;
691
+ if (s.ticking) {
692
+ s.again = true;
693
+ return;
694
+ }
695
+ if (!s.timer)
696
+ return;
697
+ clearTimeout(s.timer);
698
+ schedule(0);
699
+ }
668
700
  function schedule(ms) {
669
701
  const timer = setTimeout(() => void tick(), ms);
670
702
  timer.unref?.();
@@ -691,24 +723,41 @@ async function tick() {
691
723
  finally {
692
724
  // The workspace may have closed while git ran: then its state is gone and nothing is scheduled.
693
725
  if (workspaceOpen()) {
694
- gitState().ticking = false;
695
- if (!gitState().stopped)
726
+ const s = gitState();
727
+ s.ticking = false;
728
+ if (s.again)
729
+ next = 0;
730
+ s.again = false;
731
+ if (!s.stopped)
696
732
  schedule(next);
697
733
  }
698
734
  }
699
735
  }
700
736
  async function sync(repo) {
701
737
  const fetched = await gitFetch();
702
- if (!fetched.ok || repo.cfg.autosync !== "pull")
738
+ if (!fetched.ok || repo.cfg.autosync === "off")
703
739
  return;
704
- const st = await gitStatus();
705
- if (st.error || !st.behind || st.diverged || !st.repoRoot)
740
+ let st = await gitStatus();
741
+ if (st.error || st.diverged || !st.repoRoot)
742
+ return;
743
+ if (st.behind) {
744
+ // A local modification can make --ff-only refuse, and a failed pull
745
+ // every interval would park a permanent error in the UI. Untracked
746
+ // files do not count: they only collide when an incoming commit adds
747
+ // the same path, and that shows up as one pull error, not silence.
748
+ if (await hasLocalChanges(st.repoRoot))
749
+ return;
750
+ if (!(await gitPull()).ok)
751
+ return;
752
+ st = await gitStatus();
753
+ }
754
+ if (repo.cfg.autosync !== "push")
706
755
  return;
707
- // A local modification can make --ff-only refuse, and a failed pull
708
- // every interval would park a permanent error in the UI. Untracked
709
- // files do not count: they only collide when an incoming commit adds
710
- // the same path, and that shows up as one pull error, not silence.
711
- if (await hasLocalChanges(st.repoRoot))
756
+ // Only what would go through: a branch that already tracks its upstream
757
+ // (the first push, which publishes the branch, stays a click), is ahead
758
+ // of it and not behind. A diverged branch would be rejected every
759
+ // interval; it is reported on the git screen instead.
760
+ if (st.error || !st.upstream || !st.ahead || st.behind)
712
761
  return;
713
- await gitPull();
762
+ await gitPush();
714
763
  }
@@ -51,7 +51,7 @@ export interface GitSettingsInput {
51
51
  remote?: string;
52
52
  branch?: string;
53
53
  interval?: number | string;
54
- autosync?: "off" | "pull" | "";
54
+ autosync?: "off" | "pull" | "push" | "";
55
55
  }
56
56
  export declare function getSettings(): Promise<SettingsView>;
57
57
  export declare function saveSettings(input: SaveSettingsInput): Promise<SettingsView>;
@@ -68,8 +68,8 @@ function cleanGit(value) {
68
68
  out.interval = n;
69
69
  }
70
70
  if (value.autosync !== undefined && value.autosync !== "") {
71
- if (value.autosync !== "off" && value.autosync !== "pull")
72
- throw new Error('git.autosync must be "off" or "pull"');
71
+ if (value.autosync !== "off" && value.autosync !== "pull" && value.autosync !== "push")
72
+ throw new Error('git.autosync must be "off", "pull" or "push"');
73
73
  if (value.autosync !== GIT_DEFAULTS.autosync)
74
74
  out.autosync = value.autosync;
75
75
  }
@@ -18,7 +18,7 @@ export const gitRoutes = [
18
18
  fail(400, "path required");
19
19
  return gitDiff(file);
20
20
  }),
21
- // Commit and push stay manual; the background timer never writes history.
21
+ // Committing stays manual: the background timer never writes history, and pushes it only with `autosync: push`.
22
22
  route({ name: "git.commit", method: "POST", path: "/api/git/commit", summary: "stage and commit {paths, message}", errors: 400, body: Commit }, async (c) => {
23
23
  const { paths, message } = await c.body();
24
24
  const result = await gitCommit(paths, message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netnodeag/kraftwerk",
3
- "version": "0.90.0",
3
+ "version": "0.92.0",
4
4
  "description": "Open-source agentic workspace for teams — where people and AI agents get work done together: agents (Claude Code, Codex, Pi), skills, shared knowledge, repeatable workflows, and deterministic verification",
5
5
  "keywords": [
6
6
  "agents",
@@ -106,14 +106,15 @@
106
106
  "interval": {
107
107
  "type": "integer",
108
108
  "minimum": 0,
109
- "description": "Seconds between background fetches (and auto-pulls). 0 disables the timer. Default: 300"
109
+ "description": "Seconds between background fetches (and auto-pulls, auto-pushes). 0 disables the timer. Default: 300"
110
110
  },
111
111
  "autosync": {
112
112
  "enum": [
113
113
  "off",
114
- "pull"
114
+ "pull",
115
+ "push"
115
116
  ],
116
- "description": "off = fetch only. pull = also fast-forward when behind and the tree is clean. Default: pull"
117
+ "description": "off = fetch only. pull = also fast-forward when behind and the tree is clean. push = pull, then push commits that are ahead of the upstream. Default: pull"
117
118
  }
118
119
  }
119
120
  },