@vibes.diy/api-svc 13.1.17 → 13.1.19

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 (99) hide show
  1. package/analytics.d.ts +12 -0
  2. package/analytics.js +16 -0
  3. package/analytics.js.map +1 -1
  4. package/create-handler.js +2 -0
  5. package/create-handler.js.map +1 -1
  6. package/evento-handler-manifest.js +2 -0
  7. package/evento-handler-manifest.js.map +1 -1
  8. package/index.d.ts +6 -0
  9. package/index.js +6 -0
  10. package/index.js.map +1 -1
  11. package/intern/agent-assembly.d.ts +19 -0
  12. package/intern/agent-assembly.js +74 -0
  13. package/intern/agent-assembly.js.map +1 -0
  14. package/intern/agent-build-tools.js +8 -4
  15. package/intern/agent-build-tools.js.map +1 -1
  16. package/intern/agent-dispatcher.d.ts +18 -0
  17. package/intern/agent-dispatcher.js +74 -0
  18. package/intern/agent-dispatcher.js.map +1 -0
  19. package/intern/agent-instruction.d.ts +2 -0
  20. package/intern/agent-instruction.js +179 -0
  21. package/intern/agent-instruction.js.map +1 -0
  22. package/intern/agent-router.d.ts +18 -0
  23. package/intern/agent-router.js +32 -0
  24. package/intern/agent-router.js.map +1 -0
  25. package/intern/agent-turn.d.ts +4 -1
  26. package/intern/agent-turn.js +10 -13
  27. package/intern/agent-turn.js.map +1 -1
  28. package/intern/agent-wake.d.ts +36 -0
  29. package/intern/agent-wake.js +68 -0
  30. package/intern/agent-wake.js.map +1 -0
  31. package/intern/carry-app-settings.d.ts +12 -0
  32. package/intern/carry-app-settings.js +20 -0
  33. package/intern/carry-app-settings.js.map +1 -0
  34. package/intern/codegen-build-lock.d.ts +7 -0
  35. package/intern/codegen-build-lock.js +16 -4
  36. package/intern/codegen-build-lock.js.map +1 -1
  37. package/intern/ensure-chat-id.js +4 -4
  38. package/intern/ensure-chat-id.js.map +1 -1
  39. package/intern/mint-job-store.d.ts +1 -0
  40. package/intern/mint-job-store.js +14 -0
  41. package/intern/mint-job-store.js.map +1 -1
  42. package/intern/mint-style.d.ts +1 -0
  43. package/intern/mint-style.js +4 -1
  44. package/intern/mint-style.js.map +1 -1
  45. package/intern/pre-allocate.d.ts +10 -0
  46. package/intern/pre-allocate.js +10 -0
  47. package/intern/pre-allocate.js.map +1 -1
  48. package/intern/prompt-assembly.d.ts +1 -0
  49. package/intern/prompt-assembly.js +14 -2
  50. package/intern/prompt-assembly.js.map +1 -1
  51. package/intern/prompt-streaming.js +3 -2
  52. package/intern/prompt-streaming.js.map +1 -1
  53. package/intern/restyle-turn.js +9 -3
  54. package/intern/restyle-turn.js.map +1 -1
  55. package/intern/settings-carry-policy.d.ts +7 -0
  56. package/intern/settings-carry-policy.js +52 -0
  57. package/intern/settings-carry-policy.js.map +1 -0
  58. package/intern/turn-reach.d.ts +21 -0
  59. package/intern/turn-reach.js +35 -0
  60. package/intern/turn-reach.js.map +1 -0
  61. package/package.json +12 -11
  62. package/public/app-documents-head-query.d.ts +1 -0
  63. package/public/app-documents-head-query.js +13 -0
  64. package/public/app-documents-head-query.js.map +1 -1
  65. package/public/app-seq-allocation.js +6 -0
  66. package/public/app-seq-allocation.js.map +1 -1
  67. package/public/app-setting-items.d.ts +1 -0
  68. package/public/app-setting-items.js +21 -13
  69. package/public/app-setting-items.js.map +1 -1
  70. package/public/carry-app-settings-evento.d.ts +5 -0
  71. package/public/carry-app-settings-evento.js +78 -0
  72. package/public/carry-app-settings-evento.js.map +1 -0
  73. package/public/ensure-app-settings.js +2 -2
  74. package/public/ensure-app-settings.js.map +1 -1
  75. package/public/ensure-app-slug-item.js +41 -4
  76. package/public/ensure-app-slug-item.js.map +1 -1
  77. package/public/fork-app.d.ts +12 -0
  78. package/public/fork-app.js +145 -70
  79. package/public/fork-app.js.map +1 -1
  80. package/public/list-models.d.ts +2 -13
  81. package/public/list-models.js +7 -3
  82. package/public/list-models.js.map +1 -1
  83. package/public/llm-dispatch.d.ts +2 -1
  84. package/public/llm-dispatch.js +17 -2
  85. package/public/llm-dispatch.js.map +1 -1
  86. package/public/open-chat.d.ts +1 -0
  87. package/public/open-chat.js +5 -6
  88. package/public/open-chat.js.map +1 -1
  89. package/public/prompt-chat-section.js +244 -9
  90. package/public/prompt-chat-section.js.map +1 -1
  91. package/public/stream-assembly.d.ts +7 -2
  92. package/public/stream-assembly.js +18 -8
  93. package/public/stream-assembly.js.map +1 -1
  94. package/usage-report/codegen-delivery-alert-util.d.ts +80 -0
  95. package/usage-report/codegen-delivery-alert-util.js +220 -0
  96. package/usage-report/codegen-delivery-alert-util.js.map +1 -0
  97. package/usage-report/codegen-delivery-alert.d.ts +2 -0
  98. package/usage-report/codegen-delivery-alert.js +112 -0
  99. package/usage-report/codegen-delivery-alert.js.map +1 -0
@@ -0,0 +1,179 @@
1
+ export const AGENT_INSTRUCTION_VERSION = "2026-09-02.3";
2
+ export const AGENT_INSTRUCTION = [
3
+ "<agent-turn>",
4
+ "You are the Vibes agent. You are talking with the person whose app this is, and you can build",
5
+ "and change that app yourself while you talk. There is one conversation and you own all of it:",
6
+ "answering a question, making a change, and deciding which of those the message called for.",
7
+ "",
8
+ "## Every build goes in two waves",
9
+ "",
10
+ "Almost every app is built in two waves, and you run both. The first is a rough draft they can",
11
+ "look at within a minute; the second is everything that makes it real. Expect to keep working",
12
+ "after the app first appears — that is the ordinary rhythm, not an escalation.",
13
+ "",
14
+ "**Wave 1 is immediate and never waits.** As soon as you understand roughly what they want,",
15
+ "dispatch it: `create_vibe` for a new app, `edit_vibe` for a change. Build the UI — real layout,",
16
+ "real screens, the real flow — with local seed data standing in for anything you have not found",
17
+ "out yet. Do not hold first paint for a question, a lookup, or a decision about server files.",
18
+ "Asking first costs them the whole build; dispatching costs them nothing.",
19
+ "",
20
+ "**Wave 2 runs behind the conversation.** While wave 1 builds, keep going: read the app with",
21
+ "`list_files`, `read_file`, `read_app_settings` and `list_versions`, read anything they linked",
22
+ "when this turn carries a tool for it, and ask your one question against the draft they can now",
23
+ "see. When the first build lands, dispatch a follow-up `edit_vibe` carrying what you worked out",
24
+ "— `backend.js`, `access.js`, the real data source in place of the stand-ins, and the `skills`",
25
+ "that change needs.",
26
+ "",
27
+ "Tell them what the draft fakes and what the second wave will make real: 'the schedule is",
28
+ "placeholder data for now — I am wiring it to the real feed' — so stand-in data never reads as a",
29
+ "bug.",
30
+ "",
31
+ "### If the second wave comes back busy",
32
+ "",
33
+ "A busy answer means the first build is still running and your change WAS NOT APPLIED.",
34
+ "NOTHING IS QUEUED BY IT: the change you tried to send is gone, and only you can send it again.",
35
+ "What happens next depends on the refusal itself, which tells you which case you are in.",
36
+ "",
37
+ "If it says you will be given another turn when that build finishes, you will — and sending the",
38
+ "change again in that turn is then your job, not the platform's. You may tell the person the second",
39
+ "part is still to come, because you are going to do it.",
40
+ "",
41
+ "If it does not say that, nothing brings you back. Either wait inside this turn — read the app again",
42
+ "to see whether the build has landed, then dispatch — or tell them the change has NOT been made yet",
43
+ "and to send it again once the build finishes. Do not soften that into 'it is next' or 'it is",
44
+ "coming': with nothing arranged to perform it, those are the same unsupported promise in a quieter",
45
+ "voice. Promising a dispatch that nothing performs is the same failure as announcing a result you",
46
+ "have not seen.",
47
+ "",
48
+ "### When a build you dispatched finishes",
49
+ "",
50
+ "You may be given the turn back on your own, with no new message from the person, once a build you",
51
+ "dispatched lands. You will be told plainly that this has happened and what the build did. That is",
52
+ "the turn to dispatch your second wave in — nothing sends it for you, and there is no third turn:",
53
+ "it happens once per request, so a build you dispatch from THAT turn will not bring you back again.",
54
+ "Use it or say plainly what is left undone. And a finished build is saved, not seen — the rules",
55
+ "below about what you may claim apply to it exactly as they do anywhere else.",
56
+ "",
57
+ "So the judgment at the start of a turn is one question:",
58
+ "is there anything left to research, author, or confirm? Almost always there is.",
59
+ "",
60
+ "### Asking, during wave 2",
61
+ "",
62
+ "Ask against the draft, never before it. One question at a time, and only when the answer changes",
63
+ "what you build and you cannot get it from the app or from something they linked — 'here is the",
64
+ "rough flow; which station's feed should power it?' beats a question asked into an empty screen.",
65
+ "A question you could have answered by reading a file is a round trip the person pays for.",
66
+ "",
67
+ "### When there is no second wave",
68
+ "",
69
+ "Some apps are genuinely finished after wave 1: none of the four cues below apply, no fact is",
70
+ "missing, and there is nothing worth confirming. A private to-do list is one person's own data on",
71
+ "their own device — it does not need a permission model, a server file, or a follow-up question,",
72
+ "and writing one anyway makes the app worse and slower to arrive. Say it is ready and stop.",
73
+ "",
74
+ "## Answering a question is not a build",
75
+ "",
76
+ "When the message is a question about the app rather than a change to it, answer it. Use the read",
77
+ "tools so the answer is about their actual app and not a plausible one, and never describe code",
78
+ "you have not read.",
79
+ "",
80
+ "## Styling asks are ordinary asks",
81
+ "",
82
+ "'Make it darker', 'less cramped', 'more playful' are changes. Dispatch them like any other edit.",
83
+ "Do not route them anywhere special, do not treat them as a lesser class of request, and do not",
84
+ "ask which shade of what before trying something.",
85
+ "",
86
+ "## backend.js and access.js are yours to write",
87
+ "",
88
+ "These are not upgrades to offer later. They are part of building the app right, and they are",
89
+ "the usual contents of wave 2 — authored behind a draft the person is already looking at, so",
90
+ "nothing about getting them right slows the app down.",
91
+ "",
92
+ "The four cues for what belongs in that second wave — the app involves any of:",
93
+ "",
94
+ "- data more than one person reads or writes,",
95
+ "- work that must happen when nobody is looking (a schedule, a tick, a digest),",
96
+ "- fetching from somewhere else,",
97
+ "- notifications.",
98
+ "",
99
+ "### Private and access.js go together",
100
+ "",
101
+ "A private app can and often should have an `access.js`. These answer different questions:",
102
+ "the app's privacy posture decides WHO CAN BE ADMITTED AT ALL; `access.js` decides who, among",
103
+ "the admitted, may see and change WHICH records. A members-only app where every member can read",
104
+ "every other member's records is usually wrong — a veterinary practice is private to the public",
105
+ "AND each client sees only their own pets. Never widen an app to shared or public because you",
106
+ "want per-record rules, and never skip the rules because the app is private.",
107
+ "",
108
+ "### What changes the moment you touch them",
109
+ "",
110
+ "`backend.js` and `access.js` run the LIVE release of the app for its owner and slug. As soon as",
111
+ "the edit you dispatch mints a release, the new rules and the new server code are what everyone",
112
+ "using the app is running — there is no staging copy of them. Say so before you change permission",
113
+ "rules on an app that has people using it, and prefer widening nothing you were not asked to widen.",
114
+ "Seed data has to satisfy the rules you just wrote; if it cannot, the rules are wrong, not the data.",
115
+ "",
116
+ "### What taking access away actually does",
117
+ "",
118
+ "Everyone using the app keeps their own copy of the data they already received. Narrowing access",
119
+ "stops them receiving your data from now on; it does not reach onto their device and delete what",
120
+ "is already there. So say the change stops someone receiving new data.",
121
+ "Never say they can no longer see what they have — that is an erase the platform will not perform.",
122
+ "",
123
+ "## Which handle",
124
+ "",
125
+ "If the account has more than one handle and nothing in the conversation says which one, ASK.",
126
+ "Do not pick. To everybody else, one account's two handles are two different people, and an app",
127
+ "published under the wrong one is published under someone the owner did not choose to be.",
128
+ "",
129
+ "## When a tool says no",
130
+ "",
131
+ "A refusal is information, not a failure. `busy` means their previous build is still running —",
132
+ "handle it exactly as 'If the second wave comes back busy' says above, and nowhere else: one",
133
+ "account of what busy means is the point. `stale-base` means the app",
134
+ "moved since you read it — read it again, then dispatch. Never show the person a reason code, an",
135
+ "id, or a tool name; tell them what happened in their words.",
136
+ "",
137
+ "## What you may claim when a build finishes",
138
+ "",
139
+ "A finished build means the change is SAVED. It does not mean the person is looking at it: the",
140
+ "running preview may still be showing the previous version, and a change that touched only",
141
+ "supporting or server files may not visibly change anything at all. So do not announce a specific",
142
+ "visible result as though you had seen it. Say what you changed and let them look —",
143
+ "'I moved the seal animation onto the header — take a look' rather than 'Done, the seal now",
144
+ "animates on the header'. If they say nothing happened, believe them: read the app and check,",
145
+ "rather than repeating the claim.",
146
+ "",
147
+ "## Voice",
148
+ "",
149
+ "Short, plain, and about their app. No preamble before a tool call, no narrating your own",
150
+ "mechanics, no lists of options they did not ask for. One thing per message.",
151
+ "",
152
+ "### Talk about the app, not the code",
153
+ "",
154
+ "The person you are talking to made an app. Most of them do not read code and will never",
155
+ "open a file, and the ones who do would still rather hear what their app DOES. So describe",
156
+ "the app the way they experience it — what someone visiting it can see, add, change, or is",
157
+ "kept out of — and leave the implementation out of your reply entirely.",
158
+ "",
159
+ "Never put these in a message: file names, function or hook names, prop and variable names,",
160
+ "line counts, framework names, and the platform's own jargon. Say 'only people you've added",
161
+ "can post' — never 'writes are gated through can.create'. Say 'the app has no rules yet about",
162
+ "who can change what, so it's using the default' — never 'no custom access.js is defined'.",
163
+ "Say 'the leaderboard sorts by who has read the most' — never 'ProgressList sorts descending",
164
+ "by percent'. If a fact is only expressible in code, it is a fact about your work, not theirs:",
165
+ "leave it out.",
166
+ "",
167
+ "The test before sending: would this read as plain English to someone who has never seen a",
168
+ "program? If a sentence would stop them, say the same thing in terms of what happens on screen.",
169
+ "",
170
+ "This is about vocabulary, not about being vague or soft. Be exact, be short, and never round",
171
+ "off a real limitation to make it sound better — 'I saved the change but I can't see whether",
172
+ "it looks right' stays exactly that blunt.",
173
+ "",
174
+ "Never write the app's code into your reply — no fenced code blocks of app files, no",
175
+ "SEARCH/REPLACE, no 'here is the new App.jsx'. `edit_vibe` writes code; you describe changes.",
176
+ "Quoting one short line back to the user to point at something is fine.",
177
+ "</agent-turn>",
178
+ ].join("\n");
179
+ //# sourceMappingURL=agent-instruction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-instruction.js","sourceRoot":"","sources":["../../jsr/intern/agent-instruction.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,yBAAyB,GAAG,cAAc,CAAC;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc;IACd,+FAA+F;IAC/F,+FAA+F;IAC/F,4FAA4F;IAC5F,EAAE;IACF,kCAAkC;IAClC,EAAE;IACF,+FAA+F;IAC/F,8FAA8F;IAC9F,+EAA+E;IAC/E,EAAE;IACF,4FAA4F;IAC5F,iGAAiG;IACjG,gGAAgG;IAChG,8FAA8F;IAC9F,0EAA0E;IAC1E,EAAE;IACF,6FAA6F;IAC7F,+FAA+F;IAC/F,gGAAgG;IAChG,gGAAgG;IAChG,+FAA+F;IAC/F,oBAAoB;IACp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A2C;IAC3C,EAAE;IACF,iGAAiG;IACjG,iGAAiG;IACjG,uEAAuE;IACvE,mGAAmG;IACnG,EAAE;IACF,iBAAiB;IACjB,EAAE;IACF,8FAA8F;IAC9F,gGAAgG;IAChG,0FAA0F;IAC1F,EAAE;IACF,wBAAwB;IACxB,EAAE;IACF,+FAA+F;IAC/F,6FAA6F;IAC7F,qEAAqE;IACrE,iGAAiG;IACjG,6DAA6D;IAC7D,EAAE;IACF,6CAA6C;IAC7C,EAAE;IACF,+FAA+F;IAC/F,2FAA2F;IAC3F,kGAAkG;IAClG,oFAAoF;IACpF,4FAA4F;IAC5F,8FAA8F;IAC9F,kCAAkC;IAClC,EAAE;IACF,UAAU;IACV,EAAE;IACF,0FAA0F;IAC1F,6EAA6E;IAC7E,EAAE;IACF,sCAAsC;IACtC,EAAE;IACF,yFAAyF;IACzF,2FAA2F;IAC3F,2FAA2F;IAC3F,wEAAwE;IACxE,EAAE;IACF,4FAA4F;IAC5F,4FAA4F;IAC5F,8FAA8F;IAC9F,2FAA2F;IAC3F,6FAA6F;IAC7F,+FAA+F;IAC/F,eAAe;IACf,EAAE;IACF,2FAA2F;IAC3F,gGAAgG;IAChG,EAAE;IACF,8FAA8F;IAC9F,6FAA6F;IAC7F,2CAA2C;IAC3C,EAAE;IACF,qFAAqF;IACrF,8FAA8F;IAC9F,wEAAwE;IACxE,eAAe;CAChB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type AgentRouteSkip = "flag-off" | "agent-dispatched" | "not-a-codegen-turn" | "dry-run" | "platform-initiated" | "first-turn";
2
+ export type AgentRouteDecision = {
3
+ readonly route: "agent";
4
+ } | {
5
+ readonly route: "codegen";
6
+ readonly skip: AgentRouteSkip;
7
+ };
8
+ export interface AgentRouteInput {
9
+ readonly agentLane: boolean;
10
+ readonly codegenChatTurn: boolean;
11
+ readonly dryRun: boolean;
12
+ readonly platformInitiated: boolean;
13
+ readonly directBuildRequested: boolean;
14
+ readonly agentWake: boolean;
15
+ readonly hasPriorTurn: boolean;
16
+ }
17
+ export declare function routeAgentTurn(input: AgentRouteInput): AgentRouteDecision;
18
+ export declare function legacyVariantHint(variant: string | undefined): string | undefined;
@@ -0,0 +1,32 @@
1
+ export function routeAgentTurn(input) {
2
+ if (input.agentLane === false)
3
+ return { route: "codegen", skip: "flag-off" };
4
+ if (input.agentWake === true)
5
+ return { route: "agent" };
6
+ if (input.directBuildRequested === true)
7
+ return { route: "codegen", skip: "agent-dispatched" };
8
+ if (input.codegenChatTurn === false)
9
+ return { route: "codegen", skip: "not-a-codegen-turn" };
10
+ if (input.dryRun === true)
11
+ return { route: "codegen", skip: "dry-run" };
12
+ if (input.platformInitiated === true)
13
+ return { route: "codegen", skip: "platform-initiated" };
14
+ if (input.hasPriorTurn === false)
15
+ return { route: "codegen", skip: "first-turn" };
16
+ return { route: "agent" };
17
+ }
18
+ export function legacyVariantHint(variant) {
19
+ switch (variant) {
20
+ case "discuss":
21
+ return "The user pressed a button that used to mean 'talk this through, do not write code'.";
22
+ case "work":
23
+ return "The user pressed a button that used to mean 'take your time and make one grounded improvement'.";
24
+ case "access-wizard":
25
+ return "This turn came from the old permissions wizard: the user is asking about who can see and change data.";
26
+ case "upgrade-backend":
27
+ return "This turn came from the old backend upgrade prompt: the user is asking to connect live or shared data.";
28
+ default:
29
+ return undefined;
30
+ }
31
+ }
32
+ //# sourceMappingURL=agent-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-router.js","sourceRoot":"","sources":["../../jsr/intern/agent-router.ts"],"names":[],"mappings":"AAmHA,MAAM,UAAU,cAAc,CAAC,KAAsB;IACnD,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC7E,IAAI,KAAK,CAAC,SAAS,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACxD,IAAI,KAAK,CAAC,oBAAoB,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC/F,IAAI,KAAK,CAAC,eAAe,KAAK,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;IAC7F,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACxE,IAAI,KAAK,CAAC,iBAAiB,KAAK,IAAI;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC;IAC9F,IAAI,KAAK,CAAC,YAAY,KAAK,KAAK;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAClF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAUD,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS;YACZ,OAAO,qFAAqF,CAAC;QAC/F,KAAK,MAAM;YACT,OAAO,iGAAiG,CAAC;QAC3G,KAAK,eAAe;YAClB,OAAO,uGAAuG,CAAC;QACjH,KAAK,iBAAiB;YACpB,OAAO,wGAAwG,CAAC;QAClH;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -2,7 +2,8 @@ import { Result } from "@adviser/cement";
2
2
  import type { LLMRequest, SseStreamMsg } from "@vibes.diy/call-ai-v2";
3
3
  import { VibesApiSQLCtx } from "../types.js";
4
4
  import type { AgentActor } from "./agent-actor.js";
5
- import { type AgentBeltArgs } from "./agent-belt.js";
5
+ import { type AgentBelt, type AgentBeltArgs } from "./agent-belt.js";
6
+ import { type LlmToolLoopBudget } from "./llm-tool-loop.js";
6
7
  export declare const AGENT_TOTAL_BUDGET_MS = 120000;
7
8
  export declare const AGENT_MAX_TOOL_ROUNDS = 6;
8
9
  export declare const AGENT_MAX_TOOL_CALLS = 16;
@@ -13,6 +14,7 @@ export interface AgentTurnDispatch {
13
14
  }
14
15
  export interface AgentTurnStreamArgs {
15
16
  readonly vctx: VibesApiSQLCtx;
17
+ readonly belt?: AgentBelt;
16
18
  readonly actor: AgentActor;
17
19
  readonly chatId?: string;
18
20
  readonly vfs: ReadonlyMap<string, string>;
@@ -23,6 +25,7 @@ export interface AgentTurnStreamArgs {
23
25
  readonly abort: AbortController;
24
26
  readonly dispatch: (input: {
25
27
  request: LLMRequest;
28
+ budget: LlmToolLoopBudget;
26
29
  }) => Promise<Result<{
27
30
  readonly request: LLMRequest;
28
31
  readonly stream: ReadableStream<SseStreamMsg>;
@@ -6,18 +6,15 @@ export const AGENT_MAX_TOOL_ROUNDS = 6;
6
6
  export const AGENT_MAX_TOOL_CALLS = 16;
7
7
  export const AGENT_MAX_PROVIDER_ATTEMPTS = AGENT_MAX_TOOL_ROUNDS + 1;
8
8
  export function createAgentTurnStream(args) {
9
- const dispatched = [];
10
- const belt = createAgentBelt(args.vctx, {
11
- actor: args.actor,
12
- ...(args.chatId === undefined ? {} : { chatId: args.chatId }),
13
- vfs: args.vfs,
14
- ...(args.fetchUrl === undefined ? {} : { fetchUrl: args.fetchUrl }),
15
- dispatcher: args.dispatcher,
16
- onDispatch: (d) => {
17
- dispatched.push(d);
18
- args.onDispatch?.(d);
19
- },
20
- });
9
+ const belt = args.belt ??
10
+ createAgentBelt(args.vctx, {
11
+ actor: args.actor,
12
+ ...(args.chatId === undefined ? {} : { chatId: args.chatId }),
13
+ vfs: args.vfs,
14
+ ...(args.fetchUrl === undefined ? {} : { fetchUrl: args.fetchUrl }),
15
+ dispatcher: args.dispatcher,
16
+ onDispatch: (d) => args.onDispatch?.(d),
17
+ });
21
18
  const budget = createLlmToolLoopBudget({
22
19
  totalBudgetMs: AGENT_TOTAL_BUDGET_MS,
23
20
  maxAttempts: AGENT_MAX_PROVIDER_ATTEMPTS,
@@ -33,7 +30,7 @@ export function createAgentTurnStream(args) {
33
30
  maxToolRounds: AGENT_MAX_TOOL_ROUNDS,
34
31
  maxToolCalls: AGENT_MAX_TOOL_CALLS,
35
32
  dispatch: async (input) => {
36
- const r = await args.dispatch({ request: input.request });
33
+ const r = await args.dispatch({ request: input.request, budget: input.budget });
37
34
  if (r.isErr())
38
35
  return Result.Err(r.Err());
39
36
  const out = r.Ok();
@@ -1 +1 @@
1
- {"version":3,"file":"agent-turn.js","sourceRoot":"","sources":["../../jsr/intern/agent-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,OAAO,EAAE,eAAe,EAAsB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAA0B,MAAM,oBAAoB,CAAC;AAW9G,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,GAAG,CAAC,CAAC;AA8CrE,MAAM,UAAU,qBAAqB,CAAC,IAAyB;IAC7D,MAAM,UAAU,GAAwB,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE;QACtC,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7D,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CA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AC,KAAK,EAAE;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1C,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;aACzD,CAAC,CAAC;QACL,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;KACrD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { DashAuthType } from "@vibes.diy/identity";
2
+ import { VibesApiSQLCtx } from "../types.js";
3
+ import type { AgentDispatchHandle, AgentDispatchHostCtx } from "./agent-dispatcher.js";
4
+ export declare const AGENT_WAKE_MAX_BUDGET = 1;
5
+ export type AgentWakeSkip = "flag-off" | "not-agent-dispatched" | "not-a-build" | "budget-spent";
6
+ export type AgentWakeDecision = {
7
+ readonly wake: true;
8
+ readonly budget: number;
9
+ } | {
10
+ readonly wake: false;
11
+ readonly skip: AgentWakeSkip;
12
+ };
13
+ export interface AgentWakeInput {
14
+ readonly agentLane: boolean;
15
+ readonly agentDispatched: boolean;
16
+ readonly movedFilesystem: boolean;
17
+ readonly budget: number;
18
+ }
19
+ export declare function decideAgentWake(input: AgentWakeInput): AgentWakeDecision;
20
+ export declare function readAgentWakeBudget(raw: unknown): number;
21
+ export interface AgentWakeOutcome {
22
+ readonly outcome: "applied" | "no-code" | "error";
23
+ readonly touchedPaths?: readonly string[];
24
+ }
25
+ export declare function renderAgentWakeNote(outcome: AgentWakeOutcome): string;
26
+ export interface FireAgentWakeArgs {
27
+ readonly vctx: VibesApiSQLCtx;
28
+ readonly host: AgentDispatchHostCtx;
29
+ readonly auth: DashAuthType;
30
+ readonly outerTid: string;
31
+ readonly chatId: string;
32
+ readonly note: string;
33
+ readonly budget: number;
34
+ readonly handle: AgentDispatchHandle;
35
+ }
36
+ export declare function fireAgentWakeTurn(args: FireAgentWakeArgs): void;
@@ -0,0 +1,68 @@
1
+ import { exception2Result } from "@adviser/cement";
2
+ import { ensureLogger } from "@vibes.diy/identity";
3
+ export const AGENT_WAKE_MAX_BUDGET = 1;
4
+ export function decideAgentWake(input) {
5
+ if (input.agentLane === false)
6
+ return { wake: false, skip: "flag-off" };
7
+ if (input.agentDispatched === false)
8
+ return { wake: false, skip: "not-agent-dispatched" };
9
+ if (input.movedFilesystem === false)
10
+ return { wake: false, skip: "not-a-build" };
11
+ if (input.budget <= 0)
12
+ return { wake: false, skip: "budget-spent" };
13
+ return { wake: true, budget: input.budget - 1 };
14
+ }
15
+ export function readAgentWakeBudget(raw) {
16
+ if (typeof raw !== "number" || Number.isFinite(raw) === false)
17
+ return AGENT_WAKE_MAX_BUDGET;
18
+ return Math.max(0, Math.min(AGENT_WAKE_MAX_BUDGET, Math.floor(raw)));
19
+ }
20
+ export function renderAgentWakeNote(outcome) {
21
+ const touched = outcome.touchedPaths ?? [];
22
+ const settled = outcome.outcome === "error"
23
+ ? "The build you dispatched did not finish — it failed."
24
+ : outcome.outcome === "no-code"
25
+ ? "The build you dispatched finished and made no changes to the app."
26
+ : `The build you dispatched finished and its changes are saved${touched.length === 0 ? "" : ` (${touched.join(", ")})`}.`;
27
+ return [
28
+ "<build-finished>",
29
+ settled,
30
+ "The app is free for another change now.",
31
+ "",
32
+ "This is the platform telling you, not the person: they have not said anything new, so do not answer them",
33
+ "as though they had. Saved is not seen — they may still be looking at the previous version, so do not",
34
+ "announce a visible result.",
35
+ "",
36
+ "This is the only time you will be woken for this request. If your plan had a second wave, dispatch it now;",
37
+ "nothing else will. If there is nothing left to do, say one short line and stop.",
38
+ "</build-finished>",
39
+ ].join("\n");
40
+ }
41
+ export function fireAgentWakeTurn(args) {
42
+ const { vctx, host, auth, outerTid, chatId, note, budget, handle } = args;
43
+ const log = ensureLogger(vctx.sthis, "agentWake");
44
+ const payload = {
45
+ type: "vibes.diy.req-prompt-chat-section",
46
+ mode: "codegen",
47
+ auth,
48
+ chatId,
49
+ outerTid,
50
+ agentWake: true,
51
+ agentWakeBudget: budget,
52
+ agentWakeNote: note,
53
+ prompt: { messages: [] },
54
+ };
55
+ const msg = {
56
+ ...host.validated,
57
+ tid: vctx.sthis.nextId(12).str,
58
+ payload,
59
+ };
60
+ const run = exception2Result(() => handle({ ...host, validated: msg, enRequest: msg })).then((r) => {
61
+ if (r.isErr())
62
+ log.Error().Err(r).Str("chatId", chatId).Msg("agent wake turn failed");
63
+ return r;
64
+ });
65
+ if (vctx.waitUntil !== undefined)
66
+ vctx.waitUntil(run);
67
+ }
68
+ //# sourceMappingURL=agent-wake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-wake.js","sourceRoot":"","sources":["../../jsr/intern/agent-wake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAoDnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AA+CvC,MAAM,UAAU,eAAe,CAAC,KAAqB;IACnD,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IACxE,IAAI,KAAK,CAAC,e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CAAC,SAAS,KAAK,SAAS;QAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Result } from "@adviser/cement";
2
+ import { type AppSettingItemKey, type AppSettingItemsCtx } from "../public/app-setting-items.js";
3
+ export interface CarryAppSettingsArgs {
4
+ readonly src: AppSettingItemKey;
5
+ readonly dst: AppSettingItemKey;
6
+ readonly includePosture: boolean;
7
+ }
8
+ export interface CarryAppSettingsResult {
9
+ readonly carried: readonly string[];
10
+ readonly skippedPresent: readonly string[];
11
+ }
12
+ export declare function carryAppSettings(ctx: AppSettingItemsCtx, args: CarryAppSettingsArgs): Promise<Result<CarryAppSettingsResult>>;
@@ -0,0 +1,20 @@
1
+ import { Result, exception2Result } from "@adviser/cement";
2
+ import { isAppScopedEntry } from "@vibes.diy/api-types";
3
+ import { insertAppSettingItemIfAbsent, readComposedSettings, } from "../public/app-setting-items.js";
4
+ import { selectCarriedEntries } from "./settings-carry-policy.js";
5
+ export async function carryAppSettings(ctx, args) {
6
+ const rSrc = await exception2Result(() => readComposedSettings(ctx, args.src));
7
+ if (rSrc.isErr())
8
+ return Result.Err(`carryAppSettings: read source failed: ${rSrc.Err().message}`);
9
+ const srcEntries = rSrc.Ok().filter(isAppScopedEntry);
10
+ const carried = [];
11
+ const skippedPresent = [];
12
+ for (const entry of selectCarriedEntries(srcEntries, { includePosture: args.includePosture })) {
13
+ const rIns = await exception2Result(() => insertAppSettingItemIfAbsent(ctx, args.dst, entry));
14
+ if (rIns.isErr())
15
+ return Result.Err(`carryAppSettings: insert ${entry.type} failed: ${rIns.Err().message}`);
16
+ (rIns.Ok() ? carried : skippedPresent).push(entry.type);
17
+ }
18
+ return Result.Ok({ carried, skippedPresent });
19
+ }
20
+ //# sourceMappingURL=carry-app-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carry-app-settings.js","sourceRoot":"","sources":["../../jsr/intern/carry-app-settings.ts"],"names":[],"mappings":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,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;AAChD,CAAC"}
@@ -8,12 +8,18 @@ export type AcquireBuildLockResult = {
8
8
  readonly acquired: false;
9
9
  readonly inFlightPromptId: string;
10
10
  };
11
+ export interface BuildLockEntry {
12
+ readonly promptId: string;
13
+ readonly wakesOnTerminal: boolean;
14
+ }
15
+ export declare function peekBuildLockEntry(scope: object, chatId: string, clock?: BuildLockClock): BuildLockEntry | undefined;
11
16
  export declare function peekBuildLock(scope: object, chatId: string, clock?: BuildLockClock): string | undefined;
12
17
  export interface AcquireBuildLockArgs {
13
18
  readonly scope: object;
14
19
  readonly chatId: string;
15
20
  readonly promptId: string;
16
21
  readonly clock?: BuildLockClock;
22
+ readonly wakesOnTerminal?: boolean;
17
23
  }
18
24
  export declare function acquireBuildLock(args: AcquireBuildLockArgs): AcquireBuildLockResult;
19
25
  export declare function releaseBuildLock(scope: object, chatId: string, promptId: string): void;
@@ -29,6 +35,7 @@ export interface AcquireTurnBuildLockArgs {
29
35
  readonly chatId: string;
30
36
  readonly promptId: string;
31
37
  readonly movesFilesystem: boolean;
38
+ readonly wakesOnTerminal: boolean;
32
39
  }
33
40
  export declare function acquireTurnBuildLock(args: AcquireTurnBuildLockArgs): AcquireBuildLockResult;
34
41
  export declare function releaseTurnBuildLock(vctx: {
@@ -9,7 +9,7 @@ function locksFor(scope) {
9
9
  }
10
10
  return locks;
11
11
  }
12
- export function peekBuildLock(scope, chatId, clock = {}) {
12
+ export function peekBuildLockEntry(scope, chatId, clock = {}) {
13
13
  const now = (clock.now ?? Date.now)();
14
14
  const locks = locksFor(scope);
15
15
  const entry = locks.get(chatId);
@@ -19,14 +19,21 @@ export function peekBuildLock(scope, chatId, clock = {}) {
19
19
  locks.delete(chatId);
20
20
  return undefined;
21
21
  }
22
- return entry.promptId;
22
+ return { promptId: entry.promptId, wakesOnTerminal: entry.wakesOnTerminal };
23
+ }
24
+ export function peekBuildLock(scope, chatId, clock = {}) {
25
+ return peekBuildLockEntry(scope, chatId, clock)?.promptId;
23
26
  }
24
27
  export function acquireBuildLock(args) {
25
28
  const clock = args.clock ?? {};
26
29
  const held = peekBuildLock(args.scope, args.chatId, clock);
27
30
  if (held !== undefined)
28
31
  return { acquired: false, inFlightPromptId: held };
29
- locksFor(args.scope).set(args.chatId, { promptId: args.promptId, acquiredAtMs: (clock.now ?? Date.now)() });
32
+ locksFor(args.scope).set(args.chatId, {
33
+ promptId: args.promptId,
34
+ acquiredAtMs: (clock.now ?? Date.now)(),
35
+ wakesOnTerminal: args.wakesOnTerminal === true,
36
+ });
30
37
  return { acquired: true };
31
38
  }
32
39
  export function releaseBuildLock(scope, chatId, promptId) {
@@ -39,7 +46,12 @@ export function acquireTurnBuildLock(args) {
39
46
  return { acquired: true };
40
47
  if (agentLaneEnabled(args.vctx) === false)
41
48
  return { acquired: true };
42
- return acquireBuildLock({ scope: args.vctx.connections, chatId: args.chatId, promptId: args.promptId });
49
+ return acquireBuildLock({
50
+ scope: args.vctx.connections,
51
+ chatId: args.chatId,
52
+ promptId: args.promptId,
53
+ wakesOnTerminal: args.wakesOnTerminal,
54
+ });
43
55
  }
44
56
  export function releaseTurnBuildLock(vctx, chatId, promptId) {
45
57
  releaseBuildLock(vctx.connections, chatId, promptId);
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-build-lock.js","sourceRoot":"","sources":["../../jsr/intern/codegen-build-lock.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAYxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAO9C,MAAM,YAAY,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEnE,SAAS,QAAQ,CAAC,KAAa;IAC7B,IAAI,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAA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CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AACvD,CAAC"}
@@ -4,7 +4,7 @@ import { ensureLogger } from "@vibes.diy/identity";
4
4
  import { resolveUserHandleBinding, ensureAppSlug, getDefaultUserSlug, persistDefaultUserSlug, resolveAdminOwnerBinding, toRFC2822_32ByteLength, } from "./ensure-slug-binding.js";
5
5
  import { preAllocate } from "./pre-allocate.js";
6
6
  import { insertDraftChat } from "./draft-chat-store.js";
7
- import { MINT_FALLBACK_THEME, styleForTheme } from "./mint-style.js";
7
+ import { MINT_FALLBACK_THEME, stampableStyleForTheme } from "./mint-style.js";
8
8
  import { upsertPendingMintJob } from "./mint-job-store.js";
9
9
  import { generate } from "random-words";
10
10
  import { resolveDeveloperAccess } from "../public/developer-grants.js";
@@ -191,7 +191,7 @@ export async function ensureChatId(ctx, req, opts = {}) {
191
191
  preAllocPrivacySensitive = injected.privacySensitive;
192
192
  preAllocDeferred = injected.deferred;
193
193
  preAllocTextureNote = injected.textureNote;
194
- preAllocStyle = styleForTheme(injected.theme);
194
+ preAllocStyle = stampableStyleForTheme(injected.theme);
195
195
  }
196
196
  else {
197
197
  const rPre = await preAllocate(ctx, {
@@ -210,11 +210,11 @@ export async function ensureChatId(ctx, req, opts = {}) {
210
210
  preAllocDeferred = rPre.Ok().deferred;
211
211
  preAllocClarify = rPre.Ok().clarify;
212
212
  preAllocTextureNote = rPre.Ok().textureNote;
213
- preAllocStyle = preAllocTheme === undefined ? undefined : styleForTheme(preAllocTheme);
213
+ preAllocStyle = preAllocTheme === undefined ? undefined : stampableStyleForTheme(preAllocTheme);
214
214
  }
215
215
  else {
216
216
  console.warn("preAllocate failed; falling through to random-words:", rPre.Err());
217
- preAllocStyle = styleForTheme(MINT_FALLBACK_THEME);
217
+ preAllocStyle = stampableStyleForTheme(MINT_FALLBACK_THEME);
218
218
  }
219
219
  }
220
220
  }