@turri-dev/core 0.1.1-next.35d4c49 → 0.1.1-next.ad4aa8f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/README.md +17 -11
- package/dist/api/models.d.ts +9 -0
- package/dist/api/models.js +15 -0
- package/dist/api/plain.d.ts +6 -6
- package/dist/api/plain.js +4 -7
- package/dist/api/project.d.ts +35 -0
- package/dist/api/project.js +47 -0
- package/dist/api/session.d.ts +48 -0
- package/dist/api/session.js +17 -0
- package/dist/api/system.d.ts +18 -0
- package/dist/api/system.js +23 -0
- package/dist/btw.d.ts +1 -1
- package/dist/capture/capture.js +11 -8
- package/dist/capture/chat.d.ts +0 -11
- package/dist/capture/chat.js +0 -29
- package/dist/capture/config.d.ts +4 -5
- package/dist/capture/config.js +34 -20
- package/dist/capture/models.d.ts +2 -1
- package/dist/capture/models.js +1 -0
- package/dist/chat-entries.d.ts +81 -39
- package/dist/chat-entries.js +125 -11
- package/dist/chat-model.d.ts +37 -0
- package/dist/chat-model.js +61 -0
- package/dist/chats.d.ts +54 -42
- package/dist/chats.js +86 -80
- package/dist/client.d.ts +30 -0
- package/dist/client.js +12 -0
- package/dist/config-edit.d.ts +54 -1
- package/dist/config-edit.js +103 -33
- package/dist/config.d.ts +12 -9
- package/dist/config.js +38 -9
- package/dist/doctor-checks.d.ts +42 -0
- package/dist/doctor-checks.js +39 -0
- package/dist/environment.d.ts +2 -23
- package/dist/environment.js +5 -68
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +24 -0
- package/dist/extension.d.ts +23 -16
- package/dist/extension.js +170 -234
- package/dist/identity.d.ts +1 -1
- package/dist/identity.js +13 -9
- package/dist/init-config.d.ts +11 -9
- package/dist/init-config.js +15 -7
- package/dist/launch-session.d.ts +2 -0
- package/dist/launch-session.js +17 -1
- package/dist/loop-tools.js +11 -10
- package/dist/module-check.d.ts +13 -0
- package/dist/module-check.js +117 -0
- package/dist/notice.d.ts +5 -0
- package/dist/parse-tool.js +3 -2
- package/dist/plain/check.d.ts +27 -13
- package/dist/plain/check.js +51 -116
- package/dist/plain/files.d.ts +2 -0
- package/dist/plain/files.js +13 -0
- package/dist/plain/graph.js +2 -2
- package/dist/plain/highlight.d.ts +4 -20
- package/dist/plain/highlight.js +7 -5
- package/dist/project.d.ts +19 -0
- package/dist/project.js +34 -0
- package/dist/quiet.d.ts +0 -2
- package/dist/quiet.js +0 -14
- package/dist/regenerate/command-check.d.ts +0 -8
- package/dist/regenerate/command-check.js +133 -53
- package/dist/regenerate/conversation-writes.d.ts +5 -1
- package/dist/regenerate/conversation-writes.js +7 -3
- package/dist/regenerate/jobs.d.ts +25 -2
- package/dist/regenerate/jobs.js +3 -0
- package/dist/regenerate/launch.d.ts +1 -0
- package/dist/regenerate/launch.js +9 -0
- package/dist/regenerate/ledger-view.d.ts +14 -14
- package/dist/regenerate/ledger.d.ts +1 -0
- package/dist/regenerate/ledger.js +4 -2
- package/dist/regenerate/loop.d.ts +2 -1
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/os-sandbox.d.ts +4 -2
- package/dist/regenerate/os-sandbox.js +0 -1
- package/dist/regenerate/regenerate.js +2 -1
- package/dist/regenerate/requires-chain.d.ts +44 -0
- package/dist/regenerate/requires-chain.js +174 -0
- package/dist/regenerate/requires.d.ts +2 -40
- package/dist/regenerate/requires.js +14 -171
- package/dist/regenerate/resources.d.ts +0 -2
- package/dist/regenerate/resources.js +2 -14
- package/dist/regenerate/shell.js +20 -9
- package/dist/regenerate/spec-map.d.ts +2 -0
- package/dist/regenerate/spec-map.js +4 -0
- package/dist/regenerate/standing.d.ts +5 -2
- package/dist/run-report.js +2 -2
- package/dist/self-invocation.d.ts +1 -1
- package/dist/self-invocation.js +2 -3
- package/dist/sentinel-chat.js +7 -11
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +12 -5
- package/dist/session-events.d.ts +14 -0
- package/dist/session.d.ts +594 -0
- package/dist/session.js +672 -0
- package/dist/settings.d.ts +28 -2
- package/dist/settings.js +92 -56
- package/dist/setup.d.ts +6 -30
- package/dist/setup.js +28 -105
- package/dist/stack.d.ts +25 -12
- package/dist/stack.js +77 -12
- package/dist/surface.d.ts +2 -2
- package/dist/surface.js +4 -5
- package/dist/work.d.ts +125 -0
- package/dist/work.js +250 -0
- package/docs/README.md +2 -3
- package/docs/capture.md +4 -4
- package/docs/chats.md +5 -3
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +4 -4
- package/docs/core.md +105 -128
- package/docs/development.md +9 -9
- package/docs/headless.md +1 -1
- package/docs/installation.md +4 -2
- package/docs/launch.md +2 -2
- package/docs/parser.md +1 -1
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +4 -4
- package/docs/sentinel.md +4 -4
- package/docs/skills-and-gates.md +1 -1
- package/docs/using.md +2 -2
- package/genome/rules/integration-embedded-testing.md +3 -3
- package/genome/rules/integration-embedded.md +3 -3
- package/genome/skills/implement-conformance-testing-script/SKILL.md +6 -4
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_java.sh +13 -11
- package/genome/skills/implement-conformance-testing-script/assets/run_conformance_tests_python.sh +8 -7
- package/genome/skills/implement-unit-testing-script/SKILL.md +7 -5
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_java.sh +9 -13
- package/genome/skills/implement-unit-testing-script/assets/run_unittests_python.sh +1 -1
- package/package.json +19 -32
- package/dist/api/commands.d.ts +0 -45
- package/dist/api/commands.js +0 -54
- package/dist/api/config.d.ts +0 -8
- package/dist/api/config.js +0 -8
- package/dist/api/ledger.d.ts +0 -3
- package/dist/api/ledger.js +0 -3
- package/dist/api/startup.d.ts +0 -8
- package/dist/api/startup.js +0 -8
- package/dist/api/terminal.d.ts +0 -18
- package/dist/api/terminal.js +0 -16
- package/dist/chat-models.d.ts +0 -11
- package/dist/chat-models.js +0 -11
- package/dist/chat-ui.d.ts +0 -33
- package/dist/chat-ui.js +0 -192
- package/dist/headless.d.ts +0 -99
- package/dist/headless.js +0 -226
- package/dist/host-session.d.ts +0 -136
- package/dist/host-session.js +0 -139
- package/dist/host.d.ts +0 -8
- package/dist/host.js +0 -17
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -7
- package/dist/notifications.d.ts +0 -21
- package/dist/notifications.js +0 -44
- package/dist/reopen.d.ts +0 -29
- package/dist/reopen.js +0 -47
- package/dist/turri-versions.d.ts +0 -71
- package/dist/turri-versions.js +0 -276
- package/dist/view.d.ts +0 -78
- package/dist/view.js +0 -1
- package/docs/hosting.md +0 -284
package/dist/extension.js
CHANGED
|
@@ -5,8 +5,7 @@ import { conversationCommand, conversationSettled, conversationWriting } from ".
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { Type } from "typebox";
|
|
8
|
-
import {
|
|
9
|
-
import { AGENT_ROLES, CONFIG_FILE, configForSpec, readConfigFile, configModuleFor, hasProjectConfig, LEGACY_CONFIG_FILE, projectConfigFile, moduleConfigFile, moduleConfigFileIn, configModuleOf, moduleConfigsOf, withConfigModule, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, splitModelSpec, configLines } from "./config.js";
|
|
8
|
+
import { AGENT_ROLES, CONFIG_FILE, configForSpec, configOverrides, readConfigFile, configModuleFor, hasProjectConfig, LEGACY_CONFIG_FILE, projectConfigFile, moduleConfigFile, moduleConfigFileIn, configModuleOf, moduleConfigsOf, withConfigModule, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, splitModelSpec, configLines } from "./config.js";
|
|
10
9
|
import { projectDirOf, skillRunDir } from "./regenerate/paths.js";
|
|
11
10
|
import { sweepOrphanedGroups } from "./regenerate/shell.js";
|
|
12
11
|
import { readScript, scriptAgainstMachine, stackOnMachine, toolchainsBlock } from "./stack.js";
|
|
@@ -14,15 +13,14 @@ import { sandboxAvailable, sandboxSummary } from "./regenerate/os-sandbox.js";
|
|
|
14
13
|
import { findTestScripts, scriptKindOfSkill } from "./regenerate/test-scripts.js";
|
|
15
14
|
import { writingScript } from "./regenerate/scripts-being-written.js";
|
|
16
15
|
import { applyBedrockRegion } from "./bedrock-region.js";
|
|
17
|
-
import { bannerWarnings } from "./turri-versions.js";
|
|
18
16
|
import { CONFORMANCE_OFF_REFUSAL, conformanceBlock, conformanceTestsOn, conformanceTestsOnIn, turnOnConformanceTests } from "./conformance-switch.js";
|
|
19
17
|
import { BACKGROUND_NOTE, doneLine, failedTask, ownChanges, runDetails, skillRunDelivery, startedText } from "./background-skills.js";
|
|
20
18
|
import { runCapture } from "./capture/capture.js";
|
|
21
|
-
import { captureEnded, captureFailed, captureGoesOn,
|
|
19
|
+
import { captureEnded, captureFailed, captureGoesOn, captureRefusal, captureStartedText } from "./capture/chat.js";
|
|
22
20
|
import { reportFile as captureReportFile } from "./capture/state.js";
|
|
23
|
-
import { canReopen, REOPENED_AFTER_CAPTURE, reopenIn } from "./reopen.js";
|
|
24
21
|
import { duration } from "./capture/progress.js";
|
|
25
22
|
import { createAskUserTool } from "./tools.js";
|
|
23
|
+
import { planWork } from "./work.js";
|
|
26
24
|
import { asksFromScratch, asksWholeChain, driftTool, endWait, fromWorkingDir, haltLaunched, haltTool, loopReply, startWait, toldByWaitingCall, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, whenBuildable, WORKING_DIR_PARAM } from "./loop-tools.js";
|
|
27
25
|
import { createWebTools } from "./regenerate/web.js";
|
|
28
26
|
import { describeGates, interruptedRun, runSkill } from "./genome.js";
|
|
@@ -36,18 +34,20 @@ import { checkedSpecs } from "./sentinel-check.js";
|
|
|
36
34
|
import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
|
|
37
35
|
import { CAPTURE_HINT, NEW_PROJECT } from "./new-project.js";
|
|
38
36
|
import { describeResolution, resolveModel } from "./regenerate/model-names.js";
|
|
39
|
-
import {
|
|
37
|
+
import { checkModule } from "./module-check.js";
|
|
38
|
+
import { formatCheckResults } from "./plain/check.js";
|
|
40
39
|
import { checkPlainTool } from "./parse-tool.js";
|
|
41
40
|
import { changedFiles, projectFiles } from "./plain-files.js";
|
|
42
41
|
import { whyFailed } from "./regenerate/diagnose-job.js";
|
|
43
42
|
import { didNotLand } from "./regenerate/failure-reports.js";
|
|
44
43
|
import { conformanceRefusal, createWorkLoop, TestingStepsMissing, describeModules, isUpToDate } from "./regenerate/loop.js";
|
|
45
|
-
import { didNotPass
|
|
44
|
+
import { didNotPass } from "./regenerate/job-panel.js";
|
|
46
45
|
import { emitSessionEvent } from "./session-events.js";
|
|
46
|
+
import { followHarnessModel, outOfReachText } from "./chat-model.js";
|
|
47
47
|
import { createSessionSpending } from "./session-spending.js";
|
|
48
48
|
import { lookAhead } from "./preview.js";
|
|
49
49
|
import { defaultMapFiles } from "./regenerate/spec-map.js";
|
|
50
|
-
import { BANNER_ENTRY, appendChatEntry, sendChatMessage, COMMAND_OUTCOME, HISTORY_ENTRY, INTERVIEW_ENTRY, JOB_ENTRY, SIDE_ENTRY, SKILL_MESSAGE_ENTRY,
|
|
50
|
+
import { BANNER_ENTRY, appendChatEntry, framedForModel, sendChatMessage, COMMAND_OUTCOME, HISTORY_ENTRY, INTERVIEW_ENTRY, JOB_ENTRY, SIDE_ENTRY, SKILL_MESSAGE_ENTRY, SPEC_CONFLICT_MESSAGE, SENTINEL_PULSE_MESSAGE, SENTINEL_CHECK_MESSAGE, SENTINEL_RESUME_MESSAGE, JOB_LANDED_MESSAGE, NOTICE_ANSWER_MESSAGE, LAUNCH_MESSAGE, } from "./chat-entries.js";
|
|
51
51
|
import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
|
|
52
52
|
import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
|
|
53
53
|
import { defaultBuildDir } from "./regenerate/paths.js";
|
|
@@ -57,9 +57,8 @@ import { describePastPulse, describeRuns, earlierPulses, ledgerProjects } from "
|
|
|
57
57
|
import { doctorTool } from "./doctor-tool.js";
|
|
58
58
|
import { describeSpecConflict } from "./regenerate/stop-report.js";
|
|
59
59
|
import { inheritProviders, inheritThinkingLevel } from "./pi.js";
|
|
60
|
-
import { LOADING_PROVIDERS } from "./installed-providers.js";
|
|
61
60
|
import { machineChange, machineChangeReason, runsBuiltCode, writesPlain } from "./regenerate/command-check.js";
|
|
62
|
-
import { beginCapture, captureConsole, describeCaptured
|
|
61
|
+
import { beginCapture, captureConsole, describeCaptured } from "./quiet.js";
|
|
63
62
|
import { loadRules, renderRulesBlock } from "./rules.js";
|
|
64
63
|
import { registerSettings, ruleNames } from "./settings.js";
|
|
65
64
|
import { writeSetting } from "./config-edit.js";
|
|
@@ -73,7 +72,7 @@ import { createChats, scopedToChat } from "./chats.js";
|
|
|
73
72
|
import { ignoredGuidance, keepGuidance, landedNote, pulseEndsBlock, SENTINEL, SENTINEL_TOOLS, sentinelBrief, sentinelCheckBrief, sentinelPrompt, sentinelSetting, sentinelStartNotice, specConflictNotice } from "./sentinel.js";
|
|
74
73
|
import { noticeDialogs, registerSentinel } from "./sentinel-chat.js";
|
|
75
74
|
import { currentChat } from "./chat-scope.js";
|
|
76
|
-
import {
|
|
75
|
+
import { clientIdentity, setClient } from "./client.js";
|
|
77
76
|
import { answerSideQuestion, askWithAsides, BTW_HOW, runningSkill, skillRunStarted, skillSessionText, transcriptOf } from "./btw.js";
|
|
78
77
|
import { createJobRegistry, defaultParallelJobs, describeJob, formatDuration, pulseName, shouldWait, STOPPED_ON_REQUEST, } from "./regenerate/jobs.js";
|
|
79
78
|
/**
|
|
@@ -106,10 +105,8 @@ export const NO_USER_ANSWER = "No user is available to answer. Decide yourself w
|
|
|
106
105
|
export function askUserVia(ctx, onExchange,
|
|
107
106
|
/** Given, "/btw ..." typed as an answer is a side question: answered with this, and the question asked again. */
|
|
108
107
|
aside,
|
|
109
|
-
/**
|
|
110
|
-
dialogs
|
|
111
|
-
/** The view's way of asking (TurriView.questions), for a chat with a screen and no host dialogs: else pi's own dialogs. */
|
|
112
|
-
questions) {
|
|
108
|
+
/** The front end's own dialogs, the question put in them - else pi's own, in a chat with a screen. */
|
|
109
|
+
dialogs) {
|
|
113
110
|
return async (request) => {
|
|
114
111
|
if (dialogs === undefined && !ctx.hasUI) {
|
|
115
112
|
return NO_USER_ANSWER;
|
|
@@ -117,12 +114,10 @@ questions) {
|
|
|
117
114
|
// Declined - ctrl+c at it, the host's decline, or the turn that asked it stopped: the dialog open is closed, no other is
|
|
118
115
|
// opened, and it comes back as DECLINED.
|
|
119
116
|
const { declining, decline, done } = asking(ctx.signal);
|
|
120
|
-
// The question has the keys: what the view lets through its dialog - the side panel's peek - is caught here.
|
|
121
|
-
const unhook = dialogs === undefined ? (questions?.whileAsking?.(ctx) ?? (() => { })) : () => { };
|
|
122
117
|
if (dialogs === undefined)
|
|
123
118
|
ctx.ui.setWorkingMessage("waiting for your answer");
|
|
124
119
|
try {
|
|
125
|
-
const io = dialogs !== undefined ? hostDialogs(dialogs, declining) :
|
|
120
|
+
const io = dialogs !== undefined ? hostDialogs(dialogs, declining) : uiDialogs(ctx, declining);
|
|
126
121
|
const asking = (asked) => runAsk(asked, io);
|
|
127
122
|
const bare = { ...request, said: undefined };
|
|
128
123
|
const given = declining.declined ? DECLINED : aside !== undefined ? await askWithAsides(bare, asking, aside) : await asking(bare);
|
|
@@ -133,16 +128,11 @@ questions) {
|
|
|
133
128
|
}
|
|
134
129
|
finally {
|
|
135
130
|
done();
|
|
136
|
-
unhook();
|
|
137
131
|
if (dialogs === undefined)
|
|
138
132
|
ctx.ui.setWorkingMessage();
|
|
139
133
|
}
|
|
140
134
|
};
|
|
141
135
|
}
|
|
142
|
-
/**
|
|
143
|
-
* A question being asked, until `done`: declined by `decline` - ctrl+c at it - by the host (`Turri.decline`, through the
|
|
144
|
-
* chat's `asking`) or by `turn` being stopped.
|
|
145
|
-
*/
|
|
146
136
|
function asking(turn) {
|
|
147
137
|
const declining = { declined: turn?.aborted === true, close: undefined };
|
|
148
138
|
const decline = () => {
|
|
@@ -170,30 +160,18 @@ function hostDialogs(dialogs, declining) {
|
|
|
170
160
|
if (declining.declined)
|
|
171
161
|
return Promise.resolve(undefined);
|
|
172
162
|
const over = new AbortController();
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
]);
|
|
163
|
+
// Ready to close before the dialog opens: declined while it opens - the same tick - it closes all the same.
|
|
164
|
+
const closed = new Promise((resolve) => (declining.close = () => {
|
|
165
|
+
over.abort();
|
|
166
|
+
resolve(undefined);
|
|
167
|
+
}));
|
|
168
|
+
return Promise.race([asked(over.signal), closed]);
|
|
180
169
|
};
|
|
181
170
|
return {
|
|
182
171
|
select: (title, options, context, at) => until((signal) => dialogs.select(title, options, context, at, { signal })),
|
|
183
172
|
input: (title, context) => until((signal) => dialogs.input(title, context, { signal })),
|
|
184
173
|
};
|
|
185
174
|
}
|
|
186
|
-
/**
|
|
187
|
-
* A view's dialogs (TurriView.questions), for a question that can be declined: one asked for once it is declined opens
|
|
188
|
-
* nothing and comes back with no answer, whatever the view does - a question declined at one of its dialogs is not put
|
|
189
|
-
* again in another.
|
|
190
|
-
*/
|
|
191
|
-
function viewDialogs(io, declining) {
|
|
192
|
-
return {
|
|
193
|
-
select: (title, options, context, at, asked) => (declining.declined ? Promise.resolve(undefined) : io.select(title, options, context, at, asked)),
|
|
194
|
-
input: (title, context, asked) => (declining.declined ? Promise.resolve(undefined) : io.input(title, context, asked)),
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
175
|
/**
|
|
198
176
|
* pi's own dialogs, for a chat with a screen that has neither a host's dialogs nor a view's: what to read put above the
|
|
199
177
|
* question, as pi's select and input have no place of their own for it. Declined - or its asker's `signal` aborted - the
|
|
@@ -232,9 +210,9 @@ function uiDialogs(ctx, declining) {
|
|
|
232
210
|
* ask_user, for the conversation. `afterAnswer` may add to what an answer tells the model - a skill the person picked,
|
|
233
211
|
* to start at once.
|
|
234
212
|
*/
|
|
235
|
-
export function chatAskUserTool(dialogs, afterAnswer
|
|
213
|
+
export function chatAskUserTool(dialogs, afterAnswer) {
|
|
236
214
|
let conversation;
|
|
237
|
-
const tool = createAskUserTool((request) => (conversation !== undefined ? askUserVia(conversation, () => { }, undefined, dialogs
|
|
215
|
+
const tool = createAskUserTool((request) => (conversation !== undefined ? askUserVia(conversation, () => { }, undefined, dialogs)(request) : Promise.resolve("No user is available to answer.")), undefined, undefined, undefined, "reply");
|
|
238
216
|
return {
|
|
239
217
|
...tool,
|
|
240
218
|
promptGuidelines: [
|
|
@@ -251,12 +229,12 @@ export function chatAskUserTool(dialogs, afterAnswer, questions) {
|
|
|
251
229
|
};
|
|
252
230
|
}
|
|
253
231
|
/**
|
|
254
|
-
* The conversation's system prompt for a turn
|
|
255
|
-
*
|
|
232
|
+
* The conversation's system prompt for a turn of `chat`: pi's, turri's identity - with the front end's surface, when it
|
|
233
|
+
* has one - and turri's blocks; then the front end's last word on it.
|
|
256
234
|
*/
|
|
257
|
-
function conversationSystemPrompt(base, host, blocks) {
|
|
235
|
+
function conversationSystemPrompt(base, host, blocks, chat) {
|
|
258
236
|
const prompt = [base, conversationIdentity(host.surface), ...blocks].filter((part) => part !== "").join("\n\n");
|
|
259
|
-
return host.systemPrompt !== undefined ? host.systemPrompt(prompt) : prompt;
|
|
237
|
+
return host.systemPrompt !== undefined ? host.systemPrompt(prompt, chat) : prompt;
|
|
260
238
|
}
|
|
261
239
|
/** Whether the person has been told which of pi's skills turri left out: once a session, not once a chat. */
|
|
262
240
|
let leftOutSaid = false;
|
|
@@ -264,13 +242,13 @@ let leftOutSaid = false;
|
|
|
264
242
|
const hosts = new WeakMap();
|
|
265
243
|
/**
|
|
266
244
|
* A turri session: its job registry and work loop, the ledger, and its chats, each with turri's extension in it
|
|
267
|
-
* (chats.ts).
|
|
245
|
+
* (chats.ts). Every front end makes one through `createTurri` (session.ts); `persist`
|
|
268
246
|
* records the open chats for `turri --continue`; `view` is what a front-end draws of it (view.ts) - none for a host.
|
|
269
247
|
*/
|
|
270
248
|
export function createTurriCore(host = {}, options = {}) {
|
|
271
|
-
|
|
249
|
+
setClient(options.client);
|
|
272
250
|
const cwd = process.cwd();
|
|
273
|
-
const mode = options.mode ??
|
|
251
|
+
const mode = options.mode ?? "unattended";
|
|
274
252
|
// The AWS region the project's Bedrock models need, before any model is called - a host has no shell to export it in.
|
|
275
253
|
applyBedrockRegion(cwd);
|
|
276
254
|
let core;
|
|
@@ -279,8 +257,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
279
257
|
const running = new Set();
|
|
280
258
|
const busy = () => planning || running.size > 0;
|
|
281
259
|
const updateActivity = (job) => {
|
|
282
|
-
if (!core?.terminal)
|
|
283
|
-
return;
|
|
284
260
|
const before = busy();
|
|
285
261
|
if (!job)
|
|
286
262
|
planning = workLoops.get(jobs)?.loop.planned().some((row) => row.planning !== undefined) ?? false;
|
|
@@ -289,7 +265,7 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
289
265
|
else
|
|
290
266
|
running.delete(job.id);
|
|
291
267
|
if (busy() !== before)
|
|
292
|
-
core
|
|
268
|
+
core?.changed();
|
|
293
269
|
};
|
|
294
270
|
// Finished work is announced twice, to two audiences, because pi treats them differently - see ChatInstance.announce:
|
|
295
271
|
// in the chat that asked for it, or the one shown when that is closed.
|
|
@@ -327,8 +303,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
327
303
|
// Queued again as another job: that one says how it went.
|
|
328
304
|
if (job.replacedBy !== undefined)
|
|
329
305
|
return;
|
|
330
|
-
// The view hears of it first - the side panel opens on one that went wrong at the next ctrl+h.
|
|
331
|
-
core?.view?.pulseFinished?.(job);
|
|
332
306
|
core?.jobFinished(job);
|
|
333
307
|
},
|
|
334
308
|
});
|
|
@@ -347,18 +321,27 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
347
321
|
}
|
|
348
322
|
core?.launchChanged(launch);
|
|
349
323
|
},
|
|
324
|
+
onOutput: (launch, text) => {
|
|
325
|
+
try {
|
|
326
|
+
host.onLaunchOutput?.(launch, text);
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
/* a host that throws still has the launch run on */
|
|
330
|
+
}
|
|
331
|
+
},
|
|
350
332
|
});
|
|
351
333
|
sessionLaunches.set(jobs, launches);
|
|
334
|
+
projectHooks.set(jobs, { ...(options.openProject !== undefined ? { openProject: options.openProject } : {}), ...(options.captured !== undefined ? { captured: options.captured } : {}) });
|
|
352
335
|
let closeLedger;
|
|
353
336
|
const spending = createSessionSpending();
|
|
354
337
|
core = createChats({
|
|
355
338
|
spending,
|
|
356
|
-
onDispose: () => { stopModelEvents(); closeLedger?.(); },
|
|
339
|
+
onDispose: () => { stopModelEvents(); closeLedger?.(); setClient(undefined); },
|
|
357
340
|
cwd,
|
|
358
341
|
launches,
|
|
359
342
|
host,
|
|
360
343
|
jobs,
|
|
361
|
-
extension: (pi, link) => turriExtension(pi, core, link, busy
|
|
344
|
+
extension: (pi, link) => turriExtension(pi, core, link, busy),
|
|
362
345
|
// A finished pulse goes to the sentinel when the project wants one - read as each pulse finishes - the person asked
|
|
363
346
|
// first under `sentinel: ask`, and what they choose for the project written.
|
|
364
347
|
sentinel: () => sentinelSetting(cwd),
|
|
@@ -367,7 +350,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
367
350
|
ignored: (notice) => keepGuidance(cwd, ignoredGuidance(notice)),
|
|
368
351
|
...(options.persist !== undefined ? { persist: options.persist } : {}),
|
|
369
352
|
...(options.dialogs !== undefined ? { dialogs: options.dialogs } : {}),
|
|
370
|
-
...(options.view !== undefined ? { view: options.view } : {}),
|
|
371
353
|
});
|
|
372
354
|
const session = core;
|
|
373
355
|
hosts.set(jobs, host);
|
|
@@ -386,7 +368,8 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
386
368
|
const orphans = sweepOrphanedGroups();
|
|
387
369
|
if (orphans > 0) {
|
|
388
370
|
emitSessionEvent(host, { type: "orphansStopped", count: orphans });
|
|
389
|
-
|
|
371
|
+
// Said in the chat shown; a front end hears it as orphansStopped, not again as a notification.
|
|
372
|
+
session.notify(`Stopped ${orphans} process group${orphans === 1 ? "" : "s"} a turri that was killed left running.`, "info", { notification: false });
|
|
390
373
|
}
|
|
391
374
|
// A pulse's provider failing and waited out, or a turn turri ended itself: said in the chat shown as it happens - the
|
|
392
375
|
// job panel's activity holds it too, but scrolls by.
|
|
@@ -394,7 +377,8 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
394
377
|
const line = describeTurnIncident(event);
|
|
395
378
|
if (line !== undefined) {
|
|
396
379
|
emitSessionEvent(host, { type: "incident", event, text: line });
|
|
397
|
-
|
|
380
|
+
// Said in the chat shown; a front end hears it as the incident, not again as a notification.
|
|
381
|
+
session.notify(event.job !== undefined ? `${event.job}: ${line}` : line, "warning", { notification: false });
|
|
398
382
|
}
|
|
399
383
|
const cost = event.usage?.cost ?? 0;
|
|
400
384
|
if (event.kind === "call" && event.job === undefined && cost > 0) {
|
|
@@ -408,35 +392,22 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
408
392
|
inheritProviders(() => session.instanceInScope()?.context()?.modelRegistry);
|
|
409
393
|
return core;
|
|
410
394
|
}
|
|
411
|
-
/** The session pi builds turri's extension into when it is given turri's file rather than a session's factory. */
|
|
412
|
-
const SESSION = Symbol.for("turri.session");
|
|
413
|
-
/** The session of this process: pi-launch.ts's, or one made as pi first builds the extension (`pi -e src/extension.ts`). */
|
|
414
|
-
export function processSession(make = () => createTurriCore()) {
|
|
415
|
-
const global = globalThis;
|
|
416
|
-
return (global[SESSION] ??= make());
|
|
417
|
-
}
|
|
418
|
-
// Loaded as nothing while the person's pi extensions are loaded only for their providers (installed-providers.ts): an older
|
|
419
|
-
// turri installed into every pi is among them, and would start a session of its own.
|
|
420
|
-
const extension = (pi) => (process.env[LOADING_PROVIDERS] === "1" ? undefined : processSession().extension(pi));
|
|
421
|
-
export default extension;
|
|
422
395
|
/**
|
|
423
396
|
* The session's work loop, for a host to read: made with the first chat's context - the models it plans with - when no
|
|
424
|
-
* chat has asked for work yet.
|
|
397
|
+
* chat has asked for work yet, or with the config's models when no chat is open.
|
|
425
398
|
*/
|
|
426
399
|
export function sessionLoop(session) {
|
|
427
400
|
const known = workLoops.get(session.jobs)?.loop;
|
|
428
401
|
if (known !== undefined)
|
|
429
402
|
return known;
|
|
430
403
|
const live = session.shownChat()?.session ?? session.chats().map((info) => session.session(info.id)).find((found) => found !== undefined);
|
|
431
|
-
|
|
432
|
-
throw new Error("No chat is open yet: the work loop plans with a chat's models.");
|
|
433
|
-
return workLoopFor(session.jobs, session.cwd, live.extensionRunner.createContext());
|
|
404
|
+
return workLoopFor(session.jobs, session.cwd, live?.extensionRunner.createContext());
|
|
434
405
|
}
|
|
435
406
|
/**
|
|
436
407
|
* turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
|
|
437
408
|
* its id on the pulses it asks for - on the session's job registry and work loop.
|
|
438
409
|
*/
|
|
439
|
-
function turriExtension(api, session, link, busy
|
|
410
|
+
function turriExtension(api, session, link, busy) {
|
|
440
411
|
const pi = scopedToChat(api, link.scope);
|
|
441
412
|
const { cwd, host, jobs } = session;
|
|
442
413
|
// The session's sentinel: its own prompt and tools - the project to read, notices, its guidance - and nothing that
|
|
@@ -463,6 +434,15 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
463
434
|
return undefined;
|
|
464
435
|
}
|
|
465
436
|
};
|
|
437
|
+
// A person's chat runs on harness-model, and sends nothing to a model while that cannot be reached (chat-model.ts).
|
|
438
|
+
const harness = isSentinel
|
|
439
|
+
? undefined
|
|
440
|
+
: followHarnessModel({
|
|
441
|
+
wanted: () => modelSpec(projectModels(readProjectConfig(cwd)).harness),
|
|
442
|
+
setModel: (model) => pi.setModel(model),
|
|
443
|
+
setThinking: (level) => pi.setThinkingLevel(level),
|
|
444
|
+
changed: (outOfReach) => emitSessionEvent(host, { type: "outOfReach", chat: link.id, outOfReach: outOfReach ?? null }),
|
|
445
|
+
});
|
|
466
446
|
// Finished work is announced twice, to two audiences, because pi treats them differently.
|
|
467
447
|
// An entry is drawn the moment it is appended: the person sees the job end, now. The agent
|
|
468
448
|
// gets the full report as a hidden message that starts a turn of its own - at once when it is
|
|
@@ -471,14 +451,13 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
471
451
|
// does what the project's guidance says to do then (launch what was built, say), or says
|
|
472
452
|
// what finished. In the chat that asked for the pulse, shown or not.
|
|
473
453
|
const announce = (job) => {
|
|
474
|
-
|
|
475
|
-
announceJob(pi, job);
|
|
454
|
+
announceJob(pi, job);
|
|
476
455
|
// A pulse a call of this chat waits for is told in that call's reply: a turn of its own would say it again.
|
|
477
456
|
if (toldByWaitingCall(jobs, job) && job.specConflict === undefined)
|
|
478
457
|
return;
|
|
479
458
|
// A spec that contradicts itself is the person's to settle, now: the agent is started on it.
|
|
480
459
|
if (job.specConflict !== undefined) {
|
|
481
|
-
sendChatMessage(pi, { customType:
|
|
460
|
+
sendChatMessage(pi, { customType: SPEC_CONFLICT_MESSAGE, content: specConflictTask(job.specConflict), display: false, details: { jobId: job.id } }, { triggerTurn: true });
|
|
482
461
|
return;
|
|
483
462
|
}
|
|
484
463
|
let launching = false;
|
|
@@ -488,7 +467,8 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
488
467
|
catch {
|
|
489
468
|
/* a config that cannot be read launches nothing */
|
|
490
469
|
}
|
|
491
|
-
|
|
470
|
+
// A front end that shows the person the pulse's end itself: one that landed is told to the agent with no turn of its own.
|
|
471
|
+
const quiet = host.pulseEndsShown === true && job.status === "succeeded" && !didNotPass(job);
|
|
492
472
|
sendChatMessage(pi, {
|
|
493
473
|
customType: "turri_job",
|
|
494
474
|
content: pulseEndNote(job, { launching, quiet }),
|
|
@@ -508,7 +488,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
508
488
|
launch,
|
|
509
489
|
reaction: JOB_FINISHED_REACTION,
|
|
510
490
|
});
|
|
511
|
-
sendChatMessage(pi, { customType:
|
|
491
|
+
sendChatMessage(pi, { customType: SENTINEL_PULSE_MESSAGE, content, display: false, details: { jobId: job.id, status: job.status } }, { triggerTurn: true });
|
|
512
492
|
};
|
|
513
493
|
// The sentinel's: functional specs a host asked it to check, in what is launched of the module - told, in a
|
|
514
494
|
// conversation of its own for the check, its hidden first message `turri_sentinel_check`. It launches nothing.
|
|
@@ -523,7 +503,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
523
503
|
...(current !== undefined ? { dir: launchedDir(current) } : {}),
|
|
524
504
|
...(context.focused !== undefined ? { focused: context.focused } : {}),
|
|
525
505
|
});
|
|
526
|
-
sendChatMessage(pi, { customType:
|
|
506
|
+
sendChatMessage(pi, { customType: SENTINEL_CHECK_MESSAGE, content, display: false, details: { checkId: check.id, module: check.module, funcIds: check.funcIds } }, { triggerTurn: true });
|
|
527
507
|
};
|
|
528
508
|
// The sentinel's: its check carried on in the conversation it was in, once its codebase was launched again.
|
|
529
509
|
const resume = async (work) => {
|
|
@@ -531,7 +511,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
531
511
|
if (launches === undefined)
|
|
532
512
|
return;
|
|
533
513
|
const content = launches.resumeText(work);
|
|
534
|
-
sendChatMessage(pi, { customType:
|
|
514
|
+
sendChatMessage(pi, { customType: SENTINEL_RESUME_MESSAGE, content, display: false }, { triggerTurn: true });
|
|
535
515
|
};
|
|
536
516
|
// A launch this chat is to hear of ended: its agent told how it went, to tell the person.
|
|
537
517
|
const launched = (launch) => tellLaunch(pi, jobs, launch);
|
|
@@ -539,14 +519,13 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
539
519
|
// it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
|
|
540
520
|
// contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
|
|
541
521
|
const landed = (job, options = {}) => {
|
|
542
|
-
|
|
543
|
-
announceJob(pi, job);
|
|
522
|
+
announceJob(pi, job);
|
|
544
523
|
if (job.specConflict !== undefined)
|
|
545
524
|
session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
|
|
546
525
|
if (options.tell !== true || toldByWaitingCall(jobs, job))
|
|
547
526
|
return;
|
|
548
|
-
// A
|
|
549
|
-
const shown =
|
|
527
|
+
// A front end that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
|
|
528
|
+
const shown = host.pulseEndsShown === true;
|
|
550
529
|
let launching = false;
|
|
551
530
|
try {
|
|
552
531
|
launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
|
|
@@ -554,24 +533,10 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
554
533
|
catch {
|
|
555
534
|
/* a config that cannot be read launches nothing */
|
|
556
535
|
}
|
|
557
|
-
sendChatMessage(pi, { customType:
|
|
536
|
+
sendChatMessage(pi, { customType: JOB_LANDED_MESSAGE, content: landedNote(job, { shown, launching }), display: false, details: { jobId: job.id, status: job.status } }, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
|
|
558
537
|
};
|
|
559
538
|
const notices = noticeDialogs(pi, session, link, contextNow);
|
|
560
539
|
link.live({
|
|
561
|
-
plainPanel: {
|
|
562
|
-
busy,
|
|
563
|
-
open: () => sidePanelOf(session)?.visible() ?? false,
|
|
564
|
-
toggle: () => {
|
|
565
|
-
const panel = sidePanelOf(session);
|
|
566
|
-
if (!panel)
|
|
567
|
-
return;
|
|
568
|
-
if (panel.visible())
|
|
569
|
-
return panel.close();
|
|
570
|
-
const ctx = contextNow();
|
|
571
|
-
if (ctx?.hasUI)
|
|
572
|
-
panel.open(ctx, "map", "beside");
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
540
|
announce,
|
|
576
541
|
landed,
|
|
577
542
|
brief,
|
|
@@ -582,19 +547,30 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
582
547
|
noticeOver: notices.over,
|
|
583
548
|
concluded: notices.concluded,
|
|
584
549
|
act: (task) => {
|
|
585
|
-
sendChatMessage(pi, { customType:
|
|
550
|
+
sendChatMessage(pi, { customType: NOTICE_ANSWER_MESSAGE, content: task, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
586
551
|
},
|
|
587
552
|
thinkingLevel: () => pi.getThinkingLevel(),
|
|
588
553
|
context: contextNow,
|
|
554
|
+
...(harness !== undefined
|
|
555
|
+
? {
|
|
556
|
+
onHarnessModel: async () => {
|
|
557
|
+
const ctx = contextNow();
|
|
558
|
+
if (ctx !== undefined)
|
|
559
|
+
await harness.check(ctx);
|
|
560
|
+
},
|
|
561
|
+
outOfReach: harness.outOfReach,
|
|
562
|
+
}
|
|
563
|
+
: {}),
|
|
589
564
|
});
|
|
590
|
-
pi.on("session_start", (_event, ctx) => {
|
|
565
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
591
566
|
lastContext = ctx;
|
|
592
|
-
|
|
593
|
-
session.dismissWelcome();
|
|
567
|
+
await harness?.check(ctx);
|
|
594
568
|
});
|
|
595
569
|
pi.on("before_agent_start", (_event, ctx) => {
|
|
596
570
|
lastContext = ctx;
|
|
597
571
|
});
|
|
572
|
+
// turri's own messages framed as its notes, as the model reads them - never mistaken for the person's next message.
|
|
573
|
+
pi.on("context", (event) => ({ messages: framedForModel(event.messages) }));
|
|
598
574
|
// The ***plain rules go into the system prompt in full, every turn. The block is
|
|
599
575
|
// identical each time, so it sits inside the cached prefix rather than invalidating it.
|
|
600
576
|
// With them, the instruction to do turri's work with its tools rather than its command
|
|
@@ -631,20 +607,20 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
631
607
|
}
|
|
632
608
|
if (isSentinel) {
|
|
633
609
|
const prompt = [event.systemPrompt, sentinelPrompt(cwd, { extraTools: hostSentinelTools.map((tool) => tool.name), ...(host.sentinel?.surface !== undefined ? { surface: host.sentinel.surface } : {}) }), projectConfigBlock(cwd), rulesBlock()].join("\n\n");
|
|
634
|
-
return { systemPrompt: host.systemPrompt !== undefined ? host.systemPrompt(prompt) : prompt };
|
|
610
|
+
return { systemPrompt: host.systemPrompt !== undefined ? host.systemPrompt(prompt, link.id) : prompt };
|
|
635
611
|
}
|
|
636
612
|
return {
|
|
637
613
|
systemPrompt: conversationSystemPrompt(event.systemPrompt, host, [
|
|
638
614
|
TOOLS_NOT_CLI,
|
|
639
615
|
NEW_PROJECT,
|
|
640
616
|
CAPTURE_HINT,
|
|
641
|
-
pulseEndsBlock(session.sentinelOn(),
|
|
617
|
+
pulseEndsBlock(session.sentinelOn(), host.pulseEndsShown === true),
|
|
642
618
|
// Conformance tests - what they are, whether they are on here, and how they are turned on: every turn, read afresh.
|
|
643
619
|
conformanceBlock(conformanceTestsOnIn(cwd)),
|
|
644
620
|
projectConfigBlock(cwd),
|
|
645
621
|
machineBlock(cwd, machine.now()),
|
|
646
622
|
rulesBlock(),
|
|
647
|
-
]),
|
|
623
|
+
], link.id),
|
|
648
624
|
};
|
|
649
625
|
});
|
|
650
626
|
// The conversation's agent does not run turri again through its shell, unless the person
|
|
@@ -652,9 +628,22 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
652
628
|
let lastUserMessage = "";
|
|
653
629
|
/** While a skill runs in this chat: what passes the person's message to its agent. */
|
|
654
630
|
let skillMessage;
|
|
631
|
+
// Nothing reaches a model from a chat that cannot be on harness-model: what is typed, a skill, a prompt template, what a
|
|
632
|
+
// command sends - pi hears each as input after its commands run, which still do, and before anything is sent.
|
|
633
|
+
if (harness !== undefined) {
|
|
634
|
+
pi.on("input", async (_event, ctx) => {
|
|
635
|
+
await harness.check(ctx);
|
|
636
|
+
const outOfReach = harness.outOfReach();
|
|
637
|
+
if (outOfReach === undefined)
|
|
638
|
+
return { action: "continue" };
|
|
639
|
+
const text = outOfReachText(outOfReach);
|
|
640
|
+
if (ctx.hasUI)
|
|
641
|
+
ctx.ui.notify(text, "error");
|
|
642
|
+
emitSessionEvent(host, { type: "notification", chat: link.id, text, level: "error" });
|
|
643
|
+
return { action: "handled" };
|
|
644
|
+
});
|
|
645
|
+
}
|
|
655
646
|
pi.on("input", (event) => {
|
|
656
|
-
if (event.source === "interactive" && (event.text.trim() || event.images?.length))
|
|
657
|
-
session.dismissWelcome();
|
|
658
647
|
if (event.source !== "extension")
|
|
659
648
|
lastUserMessage = event.text;
|
|
660
649
|
// A skill running in this chat holds its agent for the whole run: what the person types meanwhile is for the
|
|
@@ -691,7 +680,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
691
680
|
if (event.toolName === "bash" && typeof command === "string") {
|
|
692
681
|
const what = selfInvocation(command);
|
|
693
682
|
if (what !== undefined && !askedForCommandLine(lastUserMessage))
|
|
694
|
-
return { block: true, reason: refusal(what
|
|
683
|
+
return { block: true, reason: refusal(what) };
|
|
695
684
|
}
|
|
696
685
|
markConversationWrite(event.toolCallId, event.toolName, event.input);
|
|
697
686
|
return undefined;
|
|
@@ -732,9 +721,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
732
721
|
};
|
|
733
722
|
pi.on("agent_end", endTurnCapture);
|
|
734
723
|
pi.on("agent_settled", endTurnCapture);
|
|
735
|
-
|
|
736
|
-
session.view?.chat?.(pi, { session, link, context: contextNow });
|
|
737
|
-
registerBranding(pi, discoveredSkills, mode);
|
|
724
|
+
registerBranding(pi, discoveredSkills);
|
|
738
725
|
registerJobTools(pi, session);
|
|
739
726
|
// The skills the person starts themselves - a project's, marked command-only: each has its command, and cultivate starts it only
|
|
740
727
|
// once its command is typed, or picked among the options the conversation offers with ask_user.
|
|
@@ -746,15 +733,12 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
746
733
|
return undefined;
|
|
747
734
|
gate.typed(chosen);
|
|
748
735
|
return startPicked(chosen, lastUserMessage);
|
|
749
|
-
}
|
|
736
|
+
});
|
|
750
737
|
registerRegenerate(pi, cwd, jobs);
|
|
751
738
|
registerDrift(pi, cwd, jobs);
|
|
752
739
|
registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
|
|
753
740
|
registerLaunch(pi, cwd, jobs);
|
|
754
741
|
registerSideQuestions(pi, cwd, jobs);
|
|
755
|
-
// More chats beside this one, in the terminal: /chat and its keys - the view's.
|
|
756
|
-
if (session.terminal)
|
|
757
|
-
session.view?.chatCommands?.(pi, { session, link, context: contextNow });
|
|
758
742
|
const { skills } = discoveredSkills;
|
|
759
743
|
if (skills.length === 0)
|
|
760
744
|
return;
|
|
@@ -1011,8 +995,6 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
1011
995
|
const phases = skill.steps.map((step) => step.name);
|
|
1012
996
|
const progressChanged = (progress) => {
|
|
1013
997
|
emitSessionEvent(host, { type: "skillProgress", chat: link.id, progress });
|
|
1014
|
-
if (ctx.hasUI)
|
|
1015
|
-
session.view?.skillProgress?.(ctx, progress);
|
|
1016
998
|
};
|
|
1017
999
|
const report = {
|
|
1018
1000
|
step: (name, attempt) => {
|
|
@@ -1077,7 +1059,7 @@ function turriExtension(api, session, link, busy, mode) {
|
|
|
1077
1059
|
push(` Q: ${question}`);
|
|
1078
1060
|
push(` A: ${answer}`);
|
|
1079
1061
|
recordExchange(pi, { skill: skill.name, question, answer, ...(said !== undefined && said.trim() !== "" ? { said: said.trim() } : {}) });
|
|
1080
|
-
}, (question) => askOnTheSide(pi, ctx, cwd, jobs, question), dialogs
|
|
1062
|
+
}, (question) => askOnTheSide(pi, ctx, cwd, jobs, question), dialogs),
|
|
1081
1063
|
model: skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx),
|
|
1082
1064
|
// Renders queued by a step land in the same registry as everything else, so
|
|
1083
1065
|
// pulses sees them without knowing a skill started them.
|
|
@@ -1279,7 +1261,7 @@ async function commandModule(cwd, ctx, args, say, words) {
|
|
|
1279
1261
|
return undefined;
|
|
1280
1262
|
}
|
|
1281
1263
|
}
|
|
1282
|
-
const check =
|
|
1264
|
+
const check = checkModule(plainFile);
|
|
1283
1265
|
if (!check.ok) {
|
|
1284
1266
|
say(`${relative(cwd, plainFile) || plainFile} does not parse, so nothing can be ${words.outcome} from it yet:\n${formatCheckResults([check])}`, "error");
|
|
1285
1267
|
return undefined;
|
|
@@ -1572,7 +1554,8 @@ function conformTool(options) {
|
|
|
1572
1554
|
const waiting = wait ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
|
|
1573
1555
|
let statuses;
|
|
1574
1556
|
try {
|
|
1575
|
-
statuses = await loop
|
|
1557
|
+
statuses = await planWork(loop, "conform", {
|
|
1558
|
+
plainFile,
|
|
1576
1559
|
...(params.funcIds !== undefined ? { funcIds: params.funcIds } : {}),
|
|
1577
1560
|
...(model !== undefined ? { model } : {}),
|
|
1578
1561
|
...(params.one_by_one === true ? { separately: true } : {}),
|
|
@@ -1623,7 +1606,12 @@ export function machineBlock(cwd, modules = stackOnMachine(cwd)) {
|
|
|
1623
1606
|
return [
|
|
1624
1607
|
"<this machine>",
|
|
1625
1608
|
`The agents' commands run on this machine, with its toolchains, ${walls}. The testing scripts run here too, unfenced, in the person's environment. Nothing is installed by an agent: what the machine lacks is the person's to install.`,
|
|
1626
|
-
...needing.map(({ module, needs, missing }) => `- ${module}: its implementation reqs need ${needs.map((need) => `${need.toolchain} (${need.words.join(", ")})`).join(", ")}${missing.length > 0
|
|
1609
|
+
...needing.map(({ module, needs, missing, older }) => `- ${module}: its implementation reqs need ${needs.map((need) => `${need.toolchain}${need.version !== undefined ? ` ${need.version}` : ""} (${need.words.join(", ")})`).join(", ")}${missing.length > 0 || older.length > 0
|
|
1610
|
+
? ` - this machine ${[
|
|
1611
|
+
...(missing.length > 0 ? [`LACKS ${missing.map((need) => need.toolchain).join(", ")}`] : []),
|
|
1612
|
+
...older.map((need) => `has ${need.toolchain} ${need.found}, OLDER than ${need.version}`),
|
|
1613
|
+
].join(", and ")}`
|
|
1614
|
+
: " - this machine has them"}.`),
|
|
1627
1615
|
...misfits,
|
|
1628
1616
|
"</this machine>",
|
|
1629
1617
|
"",
|
|
@@ -1858,17 +1846,17 @@ function jobModelOf(ctx, named, plainFile) {
|
|
|
1858
1846
|
return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
|
|
1859
1847
|
}
|
|
1860
1848
|
/**
|
|
1861
|
-
* The coding model this session starts from, and where it was given:
|
|
1862
|
-
*
|
|
1863
|
-
*
|
|
1849
|
+
* The coding model this session starts from, and where it was given: the project's config.turri.yaml, with the coding
|
|
1850
|
+
* model the session was opened with read as its `coding-model:` - read afresh, so an edit to the file holds for the next
|
|
1851
|
+
* render.
|
|
1864
1852
|
*/
|
|
1865
1853
|
function codingModelDefault(plainFile) {
|
|
1866
|
-
const flag = process.env[CODING_MODEL_ENV]?.trim();
|
|
1867
|
-
if (flag)
|
|
1868
|
-
return { named: flag, from: "--coding-model" };
|
|
1869
1854
|
// The coding model inherits what it leaves out from the harness model.
|
|
1870
1855
|
const named = modelSpec(projectModels(configOf(plainFile)).coding);
|
|
1871
|
-
|
|
1856
|
+
if (named === undefined)
|
|
1857
|
+
return undefined;
|
|
1858
|
+
const given = modelSpec(configOverrides(plainFile !== undefined ? dirname(resolve(process.cwd(), plainFile)) : process.cwd()).codingModel);
|
|
1859
|
+
return { named, from: given === named ? "the coding model this session was opened with" : CONFIG_FILE };
|
|
1872
1860
|
}
|
|
1873
1861
|
/**
|
|
1874
1862
|
* The default coding model, resolved as a name the person said would be. One that cannot be used
|
|
@@ -1899,6 +1887,13 @@ function projectModel(ctx, plainFile) {
|
|
|
1899
1887
|
const workLoops = new WeakMap();
|
|
1900
1888
|
/** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
|
|
1901
1889
|
const sessionLaunches = new WeakMap();
|
|
1890
|
+
/** What a session's front end does with a captured project, and the capture this session was opened after, by its jobs. */
|
|
1891
|
+
const projectHooks = new WeakMap();
|
|
1892
|
+
/**
|
|
1893
|
+
* The session's work loop, made once. With a chat's context - the last chat that asked for work - pulses build on the
|
|
1894
|
+
* coding model as that chat resolves it, and the planner runs on the chat's model; before any chat has asked, or with
|
|
1895
|
+
* none open, the config's models are used as they are named: the coding model builds, the harness model plans.
|
|
1896
|
+
*/
|
|
1902
1897
|
function workLoopFor(jobs, cwd, ctx) {
|
|
1903
1898
|
let shared = workLoops.get(jobs);
|
|
1904
1899
|
if (shared === undefined) {
|
|
@@ -1906,9 +1901,9 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1906
1901
|
const loop = createWorkLoop({
|
|
1907
1902
|
registry: jobs,
|
|
1908
1903
|
cwd,
|
|
1909
|
-
modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
|
|
1910
|
-
// The planner reasons about the whole of the work: it runs on the chat's model.
|
|
1911
|
-
plannerModel: () => chatModelOf(from.ctx),
|
|
1904
|
+
modelFor: (plainFile) => from.ctx !== undefined ? projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx) : codingModelDefault(plainFile)?.named,
|
|
1905
|
+
// The planner reasons about the whole of the work: it runs on the chat's model - or the harness model, with no chat.
|
|
1906
|
+
plannerModel: () => from.ctx !== undefined ? chatModelOf(from.ctx) : modelSpec(projectModels(configOf()).harness),
|
|
1912
1907
|
// A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
|
|
1913
1908
|
// codebase's next pulse not waiting on it.
|
|
1914
1909
|
landed: (input) => sessionLaunches.get(jobs)?.landed(input),
|
|
@@ -1916,7 +1911,8 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1916
1911
|
shared = { loop, from };
|
|
1917
1912
|
workLoops.set(jobs, shared);
|
|
1918
1913
|
}
|
|
1919
|
-
|
|
1914
|
+
if (ctx !== undefined)
|
|
1915
|
+
shared.from.ctx = ctx;
|
|
1920
1916
|
return shared.loop;
|
|
1921
1917
|
}
|
|
1922
1918
|
async function deliver(jobs, input) {
|
|
@@ -2124,25 +2120,14 @@ function registerJobTools(pi, session) {
|
|
|
2124
2120
|
appendChatEntry(pi, HISTORY_ENTRY, { module: name, text: historyLog(defaultBuildDir(name, cwd)) });
|
|
2125
2121
|
},
|
|
2126
2122
|
});
|
|
2127
|
-
//
|
|
2128
|
-
//
|
|
2129
|
-
// is shown, and what it says to a chat it says to the one shown.
|
|
2130
|
-
const sidePanel = sidePanelOf(session);
|
|
2131
|
-
if (session.terminal)
|
|
2132
|
-
pi.registerCommand("notifications", {
|
|
2133
|
-
description: "Open the side panel on finished pulses and sentinel notices",
|
|
2134
|
-
handler: async (_args, ctx) => { if (ctx.hasUI)
|
|
2135
|
-
sidePanel?.open(ctx, "notifications", "beside"); },
|
|
2136
|
-
});
|
|
2137
|
-
// /pulses opens the side panel on every pulse, regenerating, planned and finished, and what each regenerates; regen -
|
|
2138
|
-
// the spec, with how far the code has been regenerated into it - is PANEL_KEY's, no command of its own beside
|
|
2139
|
-
// /regenerate. What the agents did is in each pulse's log.
|
|
2123
|
+
// /pulses: every pulse, regenerating, planned and finished, and what each regenerates - where the front end shows them,
|
|
2124
|
+
// else listed in the chat. What the agents did is in each pulse's log.
|
|
2140
2125
|
pi.registerCommand("pulses", {
|
|
2141
|
-
description:
|
|
2126
|
+
description: "The pulses: every pulse, regenerating, planned and finished, and what each regenerates",
|
|
2142
2127
|
handler: async (_args, ctx) => {
|
|
2143
|
-
if (
|
|
2128
|
+
if (session.host.reveal?.({ kind: "pulses" }, { chat: currentChat()?.id ?? "" }) === true)
|
|
2144
2129
|
return;
|
|
2145
|
-
|
|
2130
|
+
shownAfterCommand(pi, ctx, "/pulses", listJobs(jobs, cwd), "info");
|
|
2146
2131
|
},
|
|
2147
2132
|
});
|
|
2148
2133
|
// /settings: every setting of config.turri.yaml from the chat, each taking effect as it says - what turri fixed at its
|
|
@@ -2151,8 +2136,8 @@ function registerJobTools(pi, session) {
|
|
|
2151
2136
|
cwd,
|
|
2152
2137
|
rules: ruleNames,
|
|
2153
2138
|
chatSpec: () => modelSpec(projectModels(readProjectConfig(cwd)).harness),
|
|
2154
|
-
// pi's own menu, last in /settings: the
|
|
2155
|
-
openPiMenu: () => session.
|
|
2139
|
+
// pi's own menu, last in /settings: the front end opens it where it has one.
|
|
2140
|
+
openPiMenu: () => session.host.openPiSettings?.() ?? false,
|
|
2156
2141
|
live: {
|
|
2157
2142
|
chatModel: async (spec, ctx) => {
|
|
2158
2143
|
if (spec === undefined)
|
|
@@ -2171,20 +2156,12 @@ function registerJobTools(pi, session) {
|
|
|
2171
2156
|
pi.setThinkingLevel(thinking);
|
|
2172
2157
|
return `The conversation runs on ${spec} now.`;
|
|
2173
2158
|
},
|
|
2174
|
-
codingModel: () => {
|
|
2175
|
-
const dropped = [];
|
|
2176
|
-
// What the session chose wins over the file; changed in the file, the file's holds from now on.
|
|
2177
|
-
if (process.env[CODING_MODEL_ENV] !== undefined) {
|
|
2178
|
-
dropped.push(`--coding-model ${process.env[CODING_MODEL_ENV]}`);
|
|
2179
|
-
delete process.env[CODING_MODEL_ENV];
|
|
2180
|
-
}
|
|
2181
|
-
return dropped.length === 0 ? undefined : `Chosen this session, and given way to the config: ${dropped.join("; ")}.`;
|
|
2182
|
-
},
|
|
2183
2159
|
parallelJobs: (count) => {
|
|
2184
2160
|
const limit = count ?? parallelJobs(cwd);
|
|
2185
2161
|
jobs.setMaxRunning(limit);
|
|
2186
2162
|
return `Up to ${limit} pulse${limit === 1 ? "" : "s"} run at once now.`;
|
|
2187
2163
|
},
|
|
2164
|
+
harnessChanged: () => session.onHarnessModel(),
|
|
2188
2165
|
},
|
|
2189
2166
|
});
|
|
2190
2167
|
}
|
|
@@ -2201,7 +2178,7 @@ export function pulseEndNote(job, options = {}) {
|
|
|
2201
2178
|
? `Pulse ${job.id} (${job.kind}) was stopped after ${formatDuration(job)}. ${job.error ?? STOPPED_ON_REQUEST}${job.error === undefined || job.error === STOPPED_ON_REQUEST ? " The person stopped it; what it was building counts as not built." : ""}`
|
|
2202
2179
|
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
|
|
2203
2180
|
if (options.quiet)
|
|
2204
|
-
return `${head}\n\
|
|
2181
|
+
return `${head}\n\nThe person is shown this result where they watch the pulses. It needs no announcement in the chat.`;
|
|
2205
2182
|
const landed = job.status === "succeeded" && job.details?.landed === true;
|
|
2206
2183
|
if (!landed || options.launching !== true)
|
|
2207
2184
|
return `${head}\n\n${JOB_FINISHED_REACTION}`;
|
|
@@ -2247,19 +2224,6 @@ export const JOB_FINISHED_REACTION = [
|
|
|
2247
2224
|
" PATH turri was started with does not reach needs turri restarted: say so.",
|
|
2248
2225
|
"- a credential `agent-env:` names that is not there: never make one up - tell the person where it is read from.",
|
|
2249
2226
|
].join("\n");
|
|
2250
|
-
/** The session's side panel, as its view draws it: opened from any chat, and the same panel whichever chat is shown. */
|
|
2251
|
-
const sidePanels = new WeakMap();
|
|
2252
|
-
/** The side panel of the session, made as a chat first asks for it - none without a view that draws one. */
|
|
2253
|
-
function sidePanelOf(session) {
|
|
2254
|
-
const known = sidePanels.get(session);
|
|
2255
|
-
if (known !== undefined)
|
|
2256
|
-
return known;
|
|
2257
|
-
const made = session.view?.panel?.(session);
|
|
2258
|
-
if (made !== undefined)
|
|
2259
|
-
sidePanels.set(session, made);
|
|
2260
|
-
return made;
|
|
2261
|
-
}
|
|
2262
|
-
/** Opens the side panel, and goes back to it from the conversation. */
|
|
2263
2227
|
/** The modules in this project that have a history, by name. */
|
|
2264
2228
|
function modulesWithHistory(cwd) {
|
|
2265
2229
|
const root = join(cwd, "plain_modules");
|
|
@@ -2354,9 +2318,9 @@ function jobLines(all) {
|
|
|
2354
2318
|
* so it needs no external tool, no API key and no credits - and it is the only honest way
|
|
2355
2319
|
* to answer "is this spec valid?" without generating anything.
|
|
2356
2320
|
*/
|
|
2357
|
-
function registerCheckPlain(pi, cwd, dialogs, afterAnswer
|
|
2321
|
+
function registerCheckPlain(pi, cwd, dialogs, afterAnswer) {
|
|
2358
2322
|
pi.registerTool(checkPlainTool(cwd));
|
|
2359
|
-
pi.registerTool(chatAskUserTool(dialogs, afterAnswer
|
|
2323
|
+
pi.registerTool(chatAskUserTool(dialogs, afterAnswer));
|
|
2360
2324
|
// The web, for the conversation too - a library's documentation, an API, an error; curl is its
|
|
2361
2325
|
// bash. Run here, like the rendering agents' (see render/web.ts).
|
|
2362
2326
|
for (const tool of createWebTools())
|
|
@@ -2369,18 +2333,20 @@ function registerCheckPlain(pi, cwd, dialogs, afterAnswer, questions) {
|
|
|
2369
2333
|
* for the chat's agent to pass on.
|
|
2370
2334
|
*/
|
|
2371
2335
|
function registerCapture(pi, session, chat, ends) {
|
|
2372
|
-
const { cwd, host
|
|
2336
|
+
const { cwd, host } = session;
|
|
2373
2337
|
let running;
|
|
2374
2338
|
pi.on("session_shutdown", (event) => {
|
|
2375
2339
|
if (event.reason === "quit")
|
|
2376
2340
|
running?.controller.abort();
|
|
2377
2341
|
});
|
|
2378
|
-
//
|
|
2342
|
+
// A session opened in the project a capture wrote: its report told in the first chat, once.
|
|
2379
2343
|
pi.on("session_start", () => {
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2382
|
-
if (told
|
|
2383
|
-
|
|
2344
|
+
const opened = projectHooks.get(session.jobs);
|
|
2345
|
+
const told = opened?.captured;
|
|
2346
|
+
if (told === undefined)
|
|
2347
|
+
return;
|
|
2348
|
+
opened.captured = undefined;
|
|
2349
|
+
ends.put(captureEnded(cwd, { plainDir: cwd, reportFile: captureReportFile(cwd), summary: told.summary }));
|
|
2384
2350
|
});
|
|
2385
2351
|
pi.registerCommand("capture", {
|
|
2386
2352
|
description: "Capture an existing codebase into ***plain, in the background - nothing is asked, and its report comes back here; a stopped one goes on: /capture [path] (this folder by default - the ***plain goes into <path>/plain)",
|
|
@@ -2396,20 +2362,17 @@ function registerCapture(pi, session, chat, ends) {
|
|
|
2396
2362
|
return refuse(refusal);
|
|
2397
2363
|
const controller = new AbortController();
|
|
2398
2364
|
running = { root, controller };
|
|
2399
|
-
const model = conversationModel(ctx);
|
|
2400
2365
|
shownAfterCommand(pi, ctx, command, captureStartedText(root, captureGoesOn(root)), "info", true);
|
|
2401
|
-
//
|
|
2402
|
-
//
|
|
2366
|
+
// Where it is, each agent at work and what it did last, as the front end hears it - a capture at work is told from one
|
|
2367
|
+
// that hangs.
|
|
2403
2368
|
let status;
|
|
2404
|
-
const shown = ctx.hasUI ? view?.captureProgress?.(ctx) : undefined;
|
|
2405
2369
|
const watch = (next) => {
|
|
2406
2370
|
status = next;
|
|
2407
2371
|
// The tracker reuses its status and agent rows; a host can keep this event for replay.
|
|
2408
2372
|
if (host.onEvent)
|
|
2409
2373
|
emitSessionEvent(host, { type: "captureProgress", chat, status: structuredClone(next) });
|
|
2410
|
-
shown?.update(next);
|
|
2411
2374
|
};
|
|
2412
|
-
// The same milestones as the CLI, kept in the chat that started the capture. Tool activity
|
|
2375
|
+
// The same milestones as the CLI, kept in the chat that started the capture. Tool activity is in its progress.
|
|
2413
2376
|
const started = Date.now();
|
|
2414
2377
|
const progress = (line) => {
|
|
2415
2378
|
if (controller.signal.aborted)
|
|
@@ -2418,12 +2381,11 @@ function registerCapture(pi, session, chat, ends) {
|
|
|
2418
2381
|
const spent = status && status.cost > 0 ? ` · $${status.cost.toFixed(2)}` : "";
|
|
2419
2382
|
showCommandEntry(pi, ctx, { command, text: `capture · ${elapsed}${spent} · ${line}`, level: "info", echoed: true });
|
|
2420
2383
|
};
|
|
2421
|
-
// The
|
|
2422
|
-
//
|
|
2423
|
-
const codingModel =
|
|
2384
|
+
// The chat may be on pi's fallback model. Capture uses the project's configured models, as the CLI does; only a coding
|
|
2385
|
+
// model turri was started with overrides the project's.
|
|
2386
|
+
const codingModel = modelSpec(configOverrides(cwd).codingModel);
|
|
2424
2387
|
const configured = {
|
|
2425
2388
|
configFrom: cwd,
|
|
2426
|
-
...(model !== undefined ? { model, harnessModel: `${model}:${pi.getThinkingLevel()}` } : {}),
|
|
2427
2389
|
...(codingModel !== undefined && codingModel !== "" ? { codingModel } : {}),
|
|
2428
2390
|
};
|
|
2429
2391
|
const capture = captureConsole(() => runCapture({ root, signal: controller.signal, progress, watch, ...configured }));
|
|
@@ -2433,24 +2395,11 @@ function registerCapture(pi, session, chat, ends) {
|
|
|
2433
2395
|
{ type: "captureEnded", chat, root, state: "failed", error: error instanceof Error ? error.message : String(error) }));
|
|
2434
2396
|
void capture
|
|
2435
2397
|
.then(async ({ result }) => {
|
|
2436
|
-
|
|
2437
|
-
//
|
|
2438
|
-
|
|
2439
|
-
if (
|
|
2440
|
-
|
|
2441
|
-
const chatModel = conversationModel(ctx);
|
|
2442
|
-
const codingModel = process.env[CODING_MODEL_ENV];
|
|
2443
|
-
const args = [
|
|
2444
|
-
...(chatModel !== undefined ? ["--model", chatModel] : []),
|
|
2445
|
-
"--thinking",
|
|
2446
|
-
pi.getThinkingLevel(),
|
|
2447
|
-
...(codingModel !== undefined && codingModel !== "" ? ["--coding-model", codingModel] : []),
|
|
2448
|
-
];
|
|
2449
|
-
if ((await ctx.ui.confirm(question.title, question.message)) && reopenIn(result.plainDir, { args, env: { [REOPENED_AFTER_CAPTURE]: reopenedAfterCapture(result.summary) } })) {
|
|
2450
|
-
ctx.shutdown();
|
|
2451
|
-
return;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2398
|
+
// A chat works on the project of its own folder, and the capture wrote one of its own: a front end that can
|
|
2399
|
+
// open it - on that project's config - does, and its report is told there; else it is told here.
|
|
2400
|
+
const open = projectHooks.get(session.jobs)?.openProject;
|
|
2401
|
+
if (open !== undefined && (await open(result.plainDir, { summary: result.summary, reportFile: result.reportFile })))
|
|
2402
|
+
return;
|
|
2454
2403
|
ends.put(captureEnded(cwd, result));
|
|
2455
2404
|
})
|
|
2456
2405
|
.catch((error) => {
|
|
@@ -2460,7 +2409,6 @@ function registerCapture(pi, session, chat, ends) {
|
|
|
2460
2409
|
})
|
|
2461
2410
|
.finally(() => {
|
|
2462
2411
|
running = undefined;
|
|
2463
|
-
shown?.close();
|
|
2464
2412
|
});
|
|
2465
2413
|
},
|
|
2466
2414
|
});
|
|
@@ -2512,12 +2460,12 @@ async function askOnTheSide(pi, ctx, cwd, jobs, question) {
|
|
|
2512
2460
|
/** A launch ended, told to a chat's agent - to tell the person where it runs, or why it did not come up. */
|
|
2513
2461
|
function tellLaunch(pi, jobs, launch) {
|
|
2514
2462
|
const job = "pulse" in launch.cause ? jobs.get(launch.cause.pulse) : undefined;
|
|
2515
|
-
sendChatMessage(pi, { customType:
|
|
2463
|
+
sendChatMessage(pi, { customType: LAUNCH_MESSAGE, content: launchedNote(launch, job), display: false, details: { launch: launch.id, status: launch.status } }, { triggerTurn: true, deliverAs: "followUp" });
|
|
2516
2464
|
}
|
|
2517
2465
|
/** A newer launch took the place of one a chat asked for, told to its agent: it hears that one's end instead. */
|
|
2518
2466
|
function tellReplaced(pi, jobs, launch, next) {
|
|
2519
2467
|
const job = "pulse" in next.cause ? jobs.get(next.cause.pulse) : undefined;
|
|
2520
|
-
sendChatMessage(pi, { customType:
|
|
2468
|
+
sendChatMessage(pi, { customType: LAUNCH_MESSAGE, content: replacedNote(launch, next, job), display: false, details: { launch: launch.id, status: launch.status, replacedBy: next.id } }, { triggerTurn: true, deliverAs: "followUp" });
|
|
2521
2469
|
}
|
|
2522
2470
|
function registerLaunch(pi, cwd, jobs) {
|
|
2523
2471
|
const launches = sessionLaunches.get(jobs);
|
|
@@ -2662,9 +2610,9 @@ export function chatRulesBlock(rules = loadRules(join(PACKAGE_ROOT, "genome", "r
|
|
|
2662
2610
|
}
|
|
2663
2611
|
/**
|
|
2664
2612
|
* /stdlib, and the banner at the top of every chat - what it says, appended once a chat (BannerData); the view draws it
|
|
2665
|
-
* (
|
|
2613
|
+
* (its renderers, a front end's extension), and a host reads it.
|
|
2666
2614
|
*/
|
|
2667
|
-
function registerBranding(pi, skills
|
|
2615
|
+
function registerBranding(pi, skills) {
|
|
2668
2616
|
pi.registerCommand("stdlib", {
|
|
2669
2617
|
description: "List the ***plain standard library: the stacks a spec can import instead of writing its implementation reqs.",
|
|
2670
2618
|
handler: async (_args, ctx) => {
|
|
@@ -2679,27 +2627,15 @@ function registerBranding(pi, skills, mode) {
|
|
|
2679
2627
|
return;
|
|
2680
2628
|
bannered = true;
|
|
2681
2629
|
try {
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
const versions = mode === "chat" ? bannerWarnings() : undefined;
|
|
2685
|
-
// A newer turri npm says is out only now - the banner read what it said last time: said under the banner once it does.
|
|
2686
|
-
void versions?.later.then((line) => {
|
|
2687
|
-
if (line === undefined)
|
|
2688
|
-
return;
|
|
2689
|
-
try {
|
|
2690
|
-
appendChatEntry(pi, VERSION_ENTRY, { text: line });
|
|
2691
|
-
}
|
|
2692
|
-
catch {
|
|
2693
|
-
/* the chat let go meanwhile: the next start's banner says it */
|
|
2694
|
-
}
|
|
2695
|
-
});
|
|
2630
|
+
// Who runs turri - the session's front end, else the core - as it said it.
|
|
2631
|
+
const identity = clientIdentity();
|
|
2696
2632
|
appendChatEntry(pi, BANNER_ENTRY, {
|
|
2633
|
+
name: identity.name,
|
|
2697
2634
|
version: identity.version ?? "0.0.0",
|
|
2698
|
-
commit: identity.git_commit
|
|
2635
|
+
...(identity.git_commit !== null ? { commit: identity.git_commit.slice(0, 7) } : {}),
|
|
2699
2636
|
changed: identity.git_dirty === true,
|
|
2700
2637
|
pending: skills.pending.length,
|
|
2701
2638
|
sandbox: sandboxSummary(),
|
|
2702
|
-
versions: versions?.lines ?? [],
|
|
2703
2639
|
config: configLines(ctx.cwd),
|
|
2704
2640
|
});
|
|
2705
2641
|
}
|