@mindstudio-ai/remy 0.1.209 → 0.1.211
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/dist/index.js
CHANGED
|
@@ -329,6 +329,33 @@ async function generateBackgroundAck(params) {
|
|
|
329
329
|
return FALLBACK_ACK;
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
+
async function fetchRemyContext(config) {
|
|
333
|
+
if (!config.appId) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
const url = `${config.baseUrl}/developer/v2/helpers/remy-context?appId=${encodeURIComponent(config.appId)}`;
|
|
337
|
+
try {
|
|
338
|
+
const res = await fetch(url, {
|
|
339
|
+
method: "GET",
|
|
340
|
+
headers: {
|
|
341
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
342
|
+
},
|
|
343
|
+
signal: AbortSignal.timeout(2e4)
|
|
344
|
+
});
|
|
345
|
+
if (!res.ok) {
|
|
346
|
+
log.debug("remy-context fetch non-OK", { status: res.status });
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
const data = await res.json();
|
|
350
|
+
if (!data || typeof data !== "object" || typeof data.auth !== "object") {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
return data;
|
|
354
|
+
} catch (err) {
|
|
355
|
+
log.debug("remy-context fetch failed", { error: err.message });
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
332
359
|
var log, MAX_RETRIES, INITIAL_BACKOFF_MS, FALLBACK_ACK;
|
|
333
360
|
var init_api = __esm({
|
|
334
361
|
"src/api.ts"() {
|
|
@@ -1910,6 +1937,54 @@ var init_projectContext = __esm({
|
|
|
1910
1937
|
}
|
|
1911
1938
|
});
|
|
1912
1939
|
|
|
1940
|
+
// src/orgContext.ts
|
|
1941
|
+
async function initOrgContext(config) {
|
|
1942
|
+
try {
|
|
1943
|
+
cached = await fetchRemyContext(config);
|
|
1944
|
+
log3.debug("org context loaded", {
|
|
1945
|
+
delegatedAvailable: cached?.auth?.delegatedAvailable ?? false,
|
|
1946
|
+
requireDelegatedOnly: cached?.auth?.requireDelegatedOnly ?? false,
|
|
1947
|
+
hasOrgName: !!cached?.org?.name
|
|
1948
|
+
});
|
|
1949
|
+
} catch (err) {
|
|
1950
|
+
cached = null;
|
|
1951
|
+
log3.debug("org context init failed", { error: err.message });
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
function renderOrgContextBlock() {
|
|
1955
|
+
const ctx = cached;
|
|
1956
|
+
const auth = ctx?.auth;
|
|
1957
|
+
if (!auth || !auth.delegatedAvailable && !auth.requireDelegatedOnly) {
|
|
1958
|
+
return "";
|
|
1959
|
+
}
|
|
1960
|
+
const lines = ["<org_auth_context>"];
|
|
1961
|
+
if (ctx?.org?.name && ctx?.org?.name !== "Personal Workspace") {
|
|
1962
|
+
lines.push(`This app is owned by the organization "${ctx.org.name}".`);
|
|
1963
|
+
}
|
|
1964
|
+
if (auth.delegatedAvailable) {
|
|
1965
|
+
lines.push(
|
|
1966
|
+
'"Sign in with Remy" (platform-delegated sign-in) is an available auth type for this app: organization members can sign in without a verification code.'
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
if (auth.requireDelegatedOnly) {
|
|
1970
|
+
lines.push(
|
|
1971
|
+
"This organization requires delegated sign-in: non-delegated human auth methods (email-code, sms-code) are blocked at the platform edge for its apps."
|
|
1972
|
+
);
|
|
1973
|
+
}
|
|
1974
|
+
lines.push("</org_auth_context>");
|
|
1975
|
+
return lines.join("\n");
|
|
1976
|
+
}
|
|
1977
|
+
var log3, cached;
|
|
1978
|
+
var init_orgContext = __esm({
|
|
1979
|
+
"src/orgContext.ts"() {
|
|
1980
|
+
"use strict";
|
|
1981
|
+
init_api();
|
|
1982
|
+
init_logger();
|
|
1983
|
+
log3 = createLogger("orgContext");
|
|
1984
|
+
cached = null;
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
|
|
1913
1988
|
// src/prompt/index.ts
|
|
1914
1989
|
function resolveIncludes(template) {
|
|
1915
1990
|
const result = template.replace(
|
|
@@ -2045,6 +2120,8 @@ New projects progress through three onboarding states. The user might skip this
|
|
|
2045
2120
|
${projectContext}
|
|
2046
2121
|
</project_context>
|
|
2047
2122
|
|
|
2123
|
+
${renderOrgContextBlock()}
|
|
2124
|
+
|
|
2048
2125
|
<view_context>
|
|
2049
2126
|
The user is currently in ${viewContext?.mode ?? "code"} mode.
|
|
2050
2127
|
${viewContext?.activeFile ? `Active file: ${viewContext.activeFile}` : ""}
|
|
@@ -2059,6 +2136,7 @@ var init_prompt = __esm({
|
|
|
2059
2136
|
"use strict";
|
|
2060
2137
|
init_assets();
|
|
2061
2138
|
init_projectContext();
|
|
2139
|
+
init_orgContext();
|
|
2062
2140
|
}
|
|
2063
2141
|
});
|
|
2064
2142
|
|
|
@@ -2196,18 +2274,18 @@ function triggerCompaction(state, apiConfig, opts = {}) {
|
|
|
2196
2274
|
).then((summaries) => {
|
|
2197
2275
|
pendingSummaries.push(...summaries);
|
|
2198
2276
|
listener?.({ type: "complete", requestId });
|
|
2199
|
-
|
|
2277
|
+
log4.info("Compaction complete");
|
|
2200
2278
|
}).catch((err) => {
|
|
2201
2279
|
const message = err.message || "Compaction failed";
|
|
2202
2280
|
listener?.({ type: "complete", error: message, requestId });
|
|
2203
|
-
|
|
2281
|
+
log4.error("Compaction failed", { error: message });
|
|
2204
2282
|
throw err;
|
|
2205
2283
|
}).finally(() => {
|
|
2206
2284
|
inflightCompaction = null;
|
|
2207
2285
|
});
|
|
2208
2286
|
return inflightCompaction;
|
|
2209
2287
|
}
|
|
2210
|
-
var
|
|
2288
|
+
var log4, pendingSummaries, inflightCompaction, listener;
|
|
2211
2289
|
var init_trigger = __esm({
|
|
2212
2290
|
"src/compaction/trigger.ts"() {
|
|
2213
2291
|
"use strict";
|
|
@@ -2216,7 +2294,7 @@ var init_trigger = __esm({
|
|
|
2216
2294
|
init_tools7();
|
|
2217
2295
|
init_logger();
|
|
2218
2296
|
init_surfaces();
|
|
2219
|
-
|
|
2297
|
+
log4 = createLogger("compaction:trigger");
|
|
2220
2298
|
pendingSummaries = [];
|
|
2221
2299
|
inflightCompaction = null;
|
|
2222
2300
|
listener = null;
|
|
@@ -2986,7 +3064,7 @@ var init_editsFinished = __esm({
|
|
|
2986
3064
|
// src/tools/_helpers/sidecar.ts
|
|
2987
3065
|
function setSidecarBaseUrl(url) {
|
|
2988
3066
|
baseUrl = url;
|
|
2989
|
-
|
|
3067
|
+
log5.info("Configured", { url });
|
|
2990
3068
|
}
|
|
2991
3069
|
async function sidecarRequest(endpoint, body = {}, options) {
|
|
2992
3070
|
if (!baseUrl) {
|
|
@@ -3001,7 +3079,7 @@ async function sidecarRequest(endpoint, body = {}, options) {
|
|
|
3001
3079
|
signal: options?.timeout ? AbortSignal.timeout(options.timeout) : void 0
|
|
3002
3080
|
});
|
|
3003
3081
|
if (!res.ok) {
|
|
3004
|
-
|
|
3082
|
+
log5.error("Sidecar error", { endpoint, status: res.status });
|
|
3005
3083
|
throw new Error(`Sidecar error: ${res.status}`);
|
|
3006
3084
|
}
|
|
3007
3085
|
const data = await res.json();
|
|
@@ -3014,16 +3092,16 @@ async function sidecarRequest(endpoint, body = {}, options) {
|
|
|
3014
3092
|
if (err.message.startsWith("Sidecar error")) {
|
|
3015
3093
|
throw err;
|
|
3016
3094
|
}
|
|
3017
|
-
|
|
3095
|
+
log5.error("Sidecar connection error", { endpoint, error: err.message });
|
|
3018
3096
|
throw new Error(`Sidecar connection error: ${err.message}`);
|
|
3019
3097
|
}
|
|
3020
3098
|
}
|
|
3021
|
-
var
|
|
3099
|
+
var log5, baseUrl;
|
|
3022
3100
|
var init_sidecar = __esm({
|
|
3023
3101
|
"src/tools/_helpers/sidecar.ts"() {
|
|
3024
3102
|
"use strict";
|
|
3025
3103
|
init_logger();
|
|
3026
|
-
|
|
3104
|
+
log5 = createLogger("sidecar");
|
|
3027
3105
|
baseUrl = null;
|
|
3028
3106
|
}
|
|
3029
3107
|
});
|
|
@@ -3373,12 +3451,12 @@ var init_browserLock = __esm({
|
|
|
3373
3451
|
});
|
|
3374
3452
|
|
|
3375
3453
|
// src/toolRegistry.ts
|
|
3376
|
-
var
|
|
3454
|
+
var log6, USER_CANCELLED_RESULT, ToolRegistry;
|
|
3377
3455
|
var init_toolRegistry = __esm({
|
|
3378
3456
|
"src/toolRegistry.ts"() {
|
|
3379
3457
|
"use strict";
|
|
3380
3458
|
init_logger();
|
|
3381
|
-
|
|
3459
|
+
log6 = createLogger("tool-registry");
|
|
3382
3460
|
USER_CANCELLED_RESULT = "[USER CANCELLED] The user manually cancelled this tool. Do not retry it automatically \u2014 wait for the user\u2019s next message for direction.";
|
|
3383
3461
|
ToolRegistry = class {
|
|
3384
3462
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -3405,7 +3483,7 @@ var init_toolRegistry = __esm({
|
|
|
3405
3483
|
if (!entry) {
|
|
3406
3484
|
return false;
|
|
3407
3485
|
}
|
|
3408
|
-
|
|
3486
|
+
log6.info("Tool stopped", { toolCallId: id, name: entry.name, mode });
|
|
3409
3487
|
entry.abortController.abort(mode);
|
|
3410
3488
|
if (mode === "graceful") {
|
|
3411
3489
|
const partial = entry.getPartialResult?.() ?? "";
|
|
@@ -3438,7 +3516,7 @@ ${partial}` : "[INTERRUPTED] Tool execution was stopped.";
|
|
|
3438
3516
|
if (!entry) {
|
|
3439
3517
|
return false;
|
|
3440
3518
|
}
|
|
3441
|
-
|
|
3519
|
+
log6.info("Tool restarted", { toolCallId: id, name: entry.name });
|
|
3442
3520
|
entry.abortController.abort("restart");
|
|
3443
3521
|
const newInput = patchedInput ? { ...entry.input, ...patchedInput } : entry.input;
|
|
3444
3522
|
this.onEvent?.({
|
|
@@ -3730,7 +3808,7 @@ async function runSubAgent(config) {
|
|
|
3730
3808
|
const signal = background ? bgAbort.signal : parentSignal;
|
|
3731
3809
|
const agentName = subAgentId || "sub-agent";
|
|
3732
3810
|
const runStart = Date.now();
|
|
3733
|
-
|
|
3811
|
+
log7.info("Sub-agent started", { requestId, parentToolId, agentName });
|
|
3734
3812
|
const emit = (e) => {
|
|
3735
3813
|
onEvent({ ...e, parentToolId });
|
|
3736
3814
|
};
|
|
@@ -3947,7 +4025,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
3947
4025
|
...hasArtifacts ? { artifacts } : {}
|
|
3948
4026
|
};
|
|
3949
4027
|
}
|
|
3950
|
-
|
|
4028
|
+
log7.info("Tools executing", {
|
|
3951
4029
|
requestId,
|
|
3952
4030
|
parentToolId,
|
|
3953
4031
|
count: toolCalls.length,
|
|
@@ -4024,7 +4102,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
4024
4102
|
run2(tc.input);
|
|
4025
4103
|
const r = await resultPromise;
|
|
4026
4104
|
toolRegistry?.unregister(tc.id);
|
|
4027
|
-
|
|
4105
|
+
log7.info("Tool completed", {
|
|
4028
4106
|
requestId,
|
|
4029
4107
|
parentToolId,
|
|
4030
4108
|
toolCallId: tc.id,
|
|
@@ -4075,7 +4153,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
4075
4153
|
const wrapRun = async () => {
|
|
4076
4154
|
try {
|
|
4077
4155
|
const result = await run();
|
|
4078
|
-
|
|
4156
|
+
log7.info("Sub-agent complete", {
|
|
4079
4157
|
requestId,
|
|
4080
4158
|
parentToolId,
|
|
4081
4159
|
agentName,
|
|
@@ -4084,7 +4162,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
4084
4162
|
});
|
|
4085
4163
|
return result;
|
|
4086
4164
|
} catch (err) {
|
|
4087
|
-
|
|
4165
|
+
log7.warn("Sub-agent error", {
|
|
4088
4166
|
requestId,
|
|
4089
4167
|
parentToolId,
|
|
4090
4168
|
agentName,
|
|
@@ -4096,7 +4174,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
4096
4174
|
if (!background) {
|
|
4097
4175
|
return wrapRun();
|
|
4098
4176
|
}
|
|
4099
|
-
|
|
4177
|
+
log7.info("Sub-agent backgrounded", { requestId, parentToolId, agentName });
|
|
4100
4178
|
toolRegistry?.register({
|
|
4101
4179
|
id: parentToolId,
|
|
4102
4180
|
name: agentName,
|
|
@@ -4123,7 +4201,7 @@ ${partial}` : "[INTERRUPTED] Agent was interrupted before producing output.",
|
|
|
4123
4201
|
});
|
|
4124
4202
|
return { text: ack, messages: [], backgrounded: true };
|
|
4125
4203
|
}
|
|
4126
|
-
var
|
|
4204
|
+
var log7;
|
|
4127
4205
|
var init_runner = __esm({
|
|
4128
4206
|
"src/subagents/runner.ts"() {
|
|
4129
4207
|
"use strict";
|
|
@@ -4133,7 +4211,7 @@ var init_runner = __esm({
|
|
|
4133
4211
|
init_toolRegistry();
|
|
4134
4212
|
init_statusWatcher();
|
|
4135
4213
|
init_cleanMessages();
|
|
4136
|
-
|
|
4214
|
+
log7 = createLogger("sub-agent");
|
|
4137
4215
|
}
|
|
4138
4216
|
});
|
|
4139
4217
|
|
|
@@ -4408,7 +4486,7 @@ async function runBrowserAutomation(task, context, opts) {
|
|
|
4408
4486
|
}
|
|
4409
4487
|
}
|
|
4410
4488
|
} catch {
|
|
4411
|
-
|
|
4489
|
+
log8.debug("Failed to parse batch analysis result", {
|
|
4412
4490
|
batchResult
|
|
4413
4491
|
});
|
|
4414
4492
|
}
|
|
@@ -4434,7 +4512,7 @@ async function runBrowserAutomation(task, context, opts) {
|
|
|
4434
4512
|
release();
|
|
4435
4513
|
}
|
|
4436
4514
|
}
|
|
4437
|
-
var
|
|
4515
|
+
var log8, browserAutomationTool;
|
|
4438
4516
|
var init_browserAutomation = __esm({
|
|
4439
4517
|
"src/subagents/browserAutomation/index.ts"() {
|
|
4440
4518
|
"use strict";
|
|
@@ -4447,7 +4525,7 @@ var init_browserAutomation = __esm({
|
|
|
4447
4525
|
init_runMindstudioCli();
|
|
4448
4526
|
init_surfaces();
|
|
4449
4527
|
init_logger();
|
|
4450
|
-
|
|
4528
|
+
log8 = createLogger("browser-automation");
|
|
4451
4529
|
browserAutomationTool = {
|
|
4452
4530
|
clearable: true,
|
|
4453
4531
|
definition: {
|
|
@@ -5661,8 +5739,8 @@ function save(indices) {
|
|
|
5661
5739
|
}
|
|
5662
5740
|
}
|
|
5663
5741
|
function getSampleIndices(pools, sizes) {
|
|
5664
|
-
if (
|
|
5665
|
-
return
|
|
5742
|
+
if (cached2) {
|
|
5743
|
+
return cached2;
|
|
5666
5744
|
}
|
|
5667
5745
|
const loaded = load();
|
|
5668
5746
|
if (loaded) {
|
|
@@ -5677,10 +5755,10 @@ function getSampleIndices(pools, sizes) {
|
|
|
5677
5755
|
if (dirty2) {
|
|
5678
5756
|
save(loaded);
|
|
5679
5757
|
}
|
|
5680
|
-
|
|
5681
|
-
return
|
|
5758
|
+
cached2 = loaded;
|
|
5759
|
+
return cached2;
|
|
5682
5760
|
}
|
|
5683
|
-
|
|
5761
|
+
cached2 = {
|
|
5684
5762
|
uiInspiration: generateIndices(pools.uiInspiration, sizes.uiInspiration),
|
|
5685
5763
|
designReferences: generateIndices(
|
|
5686
5764
|
pools.designReferences,
|
|
@@ -5688,18 +5766,18 @@ function getSampleIndices(pools, sizes) {
|
|
|
5688
5766
|
),
|
|
5689
5767
|
fonts: generateIndices(pools.fonts, sizes.fonts)
|
|
5690
5768
|
};
|
|
5691
|
-
save(
|
|
5692
|
-
return
|
|
5769
|
+
save(cached2);
|
|
5770
|
+
return cached2;
|
|
5693
5771
|
}
|
|
5694
5772
|
function pickByIndices(arr, indices) {
|
|
5695
5773
|
return indices.filter((i) => i < arr.length).map((i) => arr[i]);
|
|
5696
5774
|
}
|
|
5697
|
-
var SAMPLE_FILE,
|
|
5775
|
+
var SAMPLE_FILE, cached2;
|
|
5698
5776
|
var init_sampleCache = __esm({
|
|
5699
5777
|
"src/subagents/designExpert/data/sampleCache.ts"() {
|
|
5700
5778
|
"use strict";
|
|
5701
5779
|
SAMPLE_FILE = ".remy-design-sample.json";
|
|
5702
|
-
|
|
5780
|
+
cached2 = null;
|
|
5703
5781
|
}
|
|
5704
5782
|
});
|
|
5705
5783
|
|
|
@@ -6638,7 +6716,7 @@ function loadSession(state) {
|
|
|
6638
6716
|
}
|
|
6639
6717
|
if (Array.isArray(data.messages) && data.messages.length > 0) {
|
|
6640
6718
|
state.messages = sanitizeMessages(data.messages);
|
|
6641
|
-
|
|
6719
|
+
log9.info("Session loaded", {
|
|
6642
6720
|
messageCount: state.messages.length,
|
|
6643
6721
|
...state.models && { models: state.models }
|
|
6644
6722
|
});
|
|
@@ -6691,9 +6769,9 @@ function saveSession(state) {
|
|
|
6691
6769
|
payload.models = state.models;
|
|
6692
6770
|
}
|
|
6693
6771
|
fs20.writeFileSync(SESSION_FILE, JSON.stringify(payload, null, 2), "utf-8");
|
|
6694
|
-
|
|
6772
|
+
log9.info("Session saved", { messageCount: state.messages.length });
|
|
6695
6773
|
} catch (err) {
|
|
6696
|
-
|
|
6774
|
+
log9.warn("Session save failed", { error: err.message });
|
|
6697
6775
|
}
|
|
6698
6776
|
}
|
|
6699
6777
|
function clearSession(state) {
|
|
@@ -6704,10 +6782,10 @@ function clearSession(state) {
|
|
|
6704
6782
|
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
6705
6783
|
const dest = path9.join(ARCHIVE_DIR, `cleared-${ts}.json`);
|
|
6706
6784
|
fs20.renameSync(SESSION_FILE, dest);
|
|
6707
|
-
|
|
6785
|
+
log9.info("Session archived on clear", { dest });
|
|
6708
6786
|
}
|
|
6709
6787
|
} catch (err) {
|
|
6710
|
-
|
|
6788
|
+
log9.warn("Session archive on clear failed, deleting instead", {
|
|
6711
6789
|
error: err.message
|
|
6712
6790
|
});
|
|
6713
6791
|
try {
|
|
@@ -6716,12 +6794,12 @@ function clearSession(state) {
|
|
|
6716
6794
|
}
|
|
6717
6795
|
}
|
|
6718
6796
|
}
|
|
6719
|
-
var
|
|
6797
|
+
var log9, SESSION_FILE, ARCHIVE_DIR;
|
|
6720
6798
|
var init_session = __esm({
|
|
6721
6799
|
"src/session.ts"() {
|
|
6722
6800
|
"use strict";
|
|
6723
6801
|
init_logger();
|
|
6724
|
-
|
|
6802
|
+
log9 = createLogger("session");
|
|
6725
6803
|
SESSION_FILE = ".remy-session.json";
|
|
6726
6804
|
ARCHIVE_DIR = ".logs/sessions";
|
|
6727
6805
|
}
|
|
@@ -6938,19 +7016,19 @@ import path10 from "path";
|
|
|
6938
7016
|
import { createHash } from "crypto";
|
|
6939
7017
|
async function runExtraction(apiConfig, model) {
|
|
6940
7018
|
const inputHash = computeInputHash();
|
|
6941
|
-
const
|
|
6942
|
-
if (
|
|
6943
|
-
|
|
7019
|
+
const cached3 = readCache();
|
|
7020
|
+
if (cached3 && cached3.inputHash === inputHash) {
|
|
7021
|
+
log10.debug("Brand inputs unchanged \u2014 skipping extraction", { inputHash });
|
|
6944
7022
|
return null;
|
|
6945
7023
|
}
|
|
6946
|
-
|
|
7024
|
+
log10.info("Extracting brand", { inputHash });
|
|
6947
7025
|
const brand = await extractBrand(apiConfig, model);
|
|
6948
7026
|
if (!brand) {
|
|
6949
|
-
|
|
7027
|
+
log10.warn("Brand extraction failed \u2014 leaving cache untouched");
|
|
6950
7028
|
return null;
|
|
6951
7029
|
}
|
|
6952
7030
|
persistBrand(brand, inputHash);
|
|
6953
|
-
|
|
7031
|
+
log10.info("Brand persisted", { inputHash });
|
|
6954
7032
|
return brand;
|
|
6955
7033
|
}
|
|
6956
7034
|
function computeInputHash() {
|
|
@@ -7016,7 +7094,7 @@ function parseFrontmatter3(filePath) {
|
|
|
7016
7094
|
async function extractBrand(apiConfig, model) {
|
|
7017
7095
|
const corpus = buildCorpus();
|
|
7018
7096
|
if (!corpus.trim()) {
|
|
7019
|
-
|
|
7097
|
+
log10.debug("No spec corpus \u2014 emitting empty brand");
|
|
7020
7098
|
return { version: 1 };
|
|
7021
7099
|
}
|
|
7022
7100
|
let responseText = "";
|
|
@@ -7047,17 +7125,17 @@ async function extractBrand(apiConfig, model) {
|
|
|
7047
7125
|
toolNames: []
|
|
7048
7126
|
});
|
|
7049
7127
|
} else if (event.type === "error") {
|
|
7050
|
-
|
|
7128
|
+
log10.error("Brand extraction stream error", { error: event.error });
|
|
7051
7129
|
return null;
|
|
7052
7130
|
}
|
|
7053
7131
|
}
|
|
7054
7132
|
} catch (err) {
|
|
7055
|
-
|
|
7133
|
+
log10.error("Brand extraction threw", { error: err?.message });
|
|
7056
7134
|
return null;
|
|
7057
7135
|
}
|
|
7058
7136
|
const parsed = parseJsonResponse(responseText);
|
|
7059
7137
|
if (!parsed) {
|
|
7060
|
-
|
|
7138
|
+
log10.warn("Brand extraction returned unparseable JSON", {
|
|
7061
7139
|
preview: responseText.slice(0, 200)
|
|
7062
7140
|
});
|
|
7063
7141
|
return null;
|
|
@@ -7197,7 +7275,7 @@ function readCache() {
|
|
|
7197
7275
|
return null;
|
|
7198
7276
|
}
|
|
7199
7277
|
}
|
|
7200
|
-
var
|
|
7278
|
+
var log10, EXTRACT_PROMPT, BRAND_FILE, CACHE_FILE;
|
|
7201
7279
|
var init_brandExtraction = __esm({
|
|
7202
7280
|
"src/brandExtraction/index.ts"() {
|
|
7203
7281
|
"use strict";
|
|
@@ -7205,7 +7283,7 @@ var init_brandExtraction = __esm({
|
|
|
7205
7283
|
init_assets();
|
|
7206
7284
|
init_logger();
|
|
7207
7285
|
init_usageLedger();
|
|
7208
|
-
|
|
7286
|
+
log10 = createLogger("brandExtraction");
|
|
7209
7287
|
EXTRACT_PROMPT = readAsset("brandExtraction", "extract.md");
|
|
7210
7288
|
BRAND_FILE = ".remy-brand.json";
|
|
7211
7289
|
CACHE_FILE = ".remy-brand.cache.json";
|
|
@@ -7220,7 +7298,7 @@ function triggerBrandExtraction(apiConfig, model) {
|
|
|
7220
7298
|
}
|
|
7221
7299
|
inflight = true;
|
|
7222
7300
|
void runExtraction(apiConfig, model).catch((err) => {
|
|
7223
|
-
|
|
7301
|
+
log11.error("Brand extraction failed", { error: err?.message });
|
|
7224
7302
|
}).finally(() => {
|
|
7225
7303
|
inflight = false;
|
|
7226
7304
|
if (dirty) {
|
|
@@ -7229,13 +7307,13 @@ function triggerBrandExtraction(apiConfig, model) {
|
|
|
7229
7307
|
}
|
|
7230
7308
|
});
|
|
7231
7309
|
}
|
|
7232
|
-
var
|
|
7310
|
+
var log11, inflight, dirty;
|
|
7233
7311
|
var init_trigger2 = __esm({
|
|
7234
7312
|
"src/brandExtraction/trigger.ts"() {
|
|
7235
7313
|
"use strict";
|
|
7236
7314
|
init_brandExtraction();
|
|
7237
7315
|
init_logger();
|
|
7238
|
-
|
|
7316
|
+
log11 = createLogger("brandExtraction:trigger");
|
|
7239
7317
|
inflight = false;
|
|
7240
7318
|
dirty = false;
|
|
7241
7319
|
}
|
|
@@ -7273,7 +7351,7 @@ async function runTurn(params) {
|
|
|
7273
7351
|
} = params;
|
|
7274
7352
|
const tools2 = getToolDefinitions(onboardingState);
|
|
7275
7353
|
const excludeToolsFromClearing = tools2.filter((t) => !CLEARABLE_TOOLS.has(t.name)).map((t) => t.name);
|
|
7276
|
-
|
|
7354
|
+
log12.info("Turn started", {
|
|
7277
7355
|
requestId,
|
|
7278
7356
|
model,
|
|
7279
7357
|
toolCount: tools2.length,
|
|
@@ -7526,7 +7604,7 @@ async function runTurn(params) {
|
|
|
7526
7604
|
const tool = getToolByName(event.name);
|
|
7527
7605
|
const wasStreamed = acc?.started ?? false;
|
|
7528
7606
|
const isInputStreaming = !!tool?.streaming?.partialInput;
|
|
7529
|
-
|
|
7607
|
+
log12.info("Tool received", {
|
|
7530
7608
|
requestId,
|
|
7531
7609
|
toolCallId: event.id,
|
|
7532
7610
|
name: event.name
|
|
@@ -7644,7 +7722,7 @@ async function runTurn(params) {
|
|
|
7644
7722
|
});
|
|
7645
7723
|
return;
|
|
7646
7724
|
}
|
|
7647
|
-
|
|
7725
|
+
log12.info("Tools executing", {
|
|
7648
7726
|
requestId,
|
|
7649
7727
|
count: toolCalls.length,
|
|
7650
7728
|
tools: toolCalls.map((tc) => tc.name)
|
|
@@ -7691,7 +7769,7 @@ async function runTurn(params) {
|
|
|
7691
7769
|
let result;
|
|
7692
7770
|
if (EXTERNAL_TOOLS.has(tc.name) && resolveExternalTool) {
|
|
7693
7771
|
saveSession(state);
|
|
7694
|
-
|
|
7772
|
+
log12.info("Waiting for external tool result", {
|
|
7695
7773
|
requestId,
|
|
7696
7774
|
toolCallId: tc.id,
|
|
7697
7775
|
name: tc.name
|
|
@@ -7759,7 +7837,7 @@ async function runTurn(params) {
|
|
|
7759
7837
|
if (!tc.input.background) {
|
|
7760
7838
|
toolRegistry?.unregister(tc.id);
|
|
7761
7839
|
}
|
|
7762
|
-
|
|
7840
|
+
log12.info("Tool completed", {
|
|
7763
7841
|
requestId,
|
|
7764
7842
|
toolCallId: tc.id,
|
|
7765
7843
|
name: tc.name,
|
|
@@ -7818,7 +7896,7 @@ async function runTurn(params) {
|
|
|
7818
7896
|
}
|
|
7819
7897
|
}
|
|
7820
7898
|
}
|
|
7821
|
-
var
|
|
7899
|
+
var log12, BRAND_TRIGGERING_TOOLS, EXTERNAL_TOOLS, USER_BLOCKING_EXTERNAL_TOOLS;
|
|
7822
7900
|
var init_agent = __esm({
|
|
7823
7901
|
"src/agent.ts"() {
|
|
7824
7902
|
"use strict";
|
|
@@ -7836,7 +7914,7 @@ var init_agent = __esm({
|
|
|
7836
7914
|
init_trigger2();
|
|
7837
7915
|
init_surfaces();
|
|
7838
7916
|
init_toolRegistry();
|
|
7839
|
-
|
|
7917
|
+
log12 = createLogger("agent");
|
|
7840
7918
|
BRAND_TRIGGERING_TOOLS = /* @__PURE__ */ new Set(["writeSpec", "editSpec"]);
|
|
7841
7919
|
EXTERNAL_TOOLS = /* @__PURE__ */ new Set([
|
|
7842
7920
|
"promptUser",
|
|
@@ -7864,10 +7942,10 @@ import os from "os";
|
|
|
7864
7942
|
function loadConfigFile() {
|
|
7865
7943
|
try {
|
|
7866
7944
|
const raw = fs22.readFileSync(CONFIG_PATH, "utf-8");
|
|
7867
|
-
|
|
7945
|
+
log13.debug("Loaded config file", { path: CONFIG_PATH });
|
|
7868
7946
|
return JSON.parse(raw);
|
|
7869
7947
|
} catch (err) {
|
|
7870
|
-
|
|
7948
|
+
log13.debug("No config file found", {
|
|
7871
7949
|
path: CONFIG_PATH,
|
|
7872
7950
|
error: err.message
|
|
7873
7951
|
});
|
|
@@ -7882,13 +7960,13 @@ function resolveConfig(flags2) {
|
|
|
7882
7960
|
const baseUrl2 = flags2?.baseUrl || process.env.MINDSTUDIO_BASE_URL || env?.apiBaseUrl || DEFAULT_BASE_URL;
|
|
7883
7961
|
const appId = process.env.MINDSTUDIO_APP_ID || void 0;
|
|
7884
7962
|
if (!apiKey) {
|
|
7885
|
-
|
|
7963
|
+
log13.error("No API key found");
|
|
7886
7964
|
throw new Error(
|
|
7887
7965
|
"No API key found. Set MINDSTUDIO_API_KEY or configure ~/.mindstudio-local-tunnel/config.json."
|
|
7888
7966
|
);
|
|
7889
7967
|
}
|
|
7890
7968
|
const keySource = flags2?.apiKey ? "cli flag" : process.env.MINDSTUDIO_API_KEY ? "env var" : "config file";
|
|
7891
|
-
|
|
7969
|
+
log13.info("Config resolved", {
|
|
7892
7970
|
baseUrl: baseUrl2,
|
|
7893
7971
|
keySource,
|
|
7894
7972
|
environment: activeEnv,
|
|
@@ -7896,12 +7974,12 @@ function resolveConfig(flags2) {
|
|
|
7896
7974
|
});
|
|
7897
7975
|
return { apiKey, baseUrl: baseUrl2, appId };
|
|
7898
7976
|
}
|
|
7899
|
-
var
|
|
7977
|
+
var log13, CONFIG_PATH, DEFAULT_BASE_URL;
|
|
7900
7978
|
var init_config = __esm({
|
|
7901
7979
|
"src/config.ts"() {
|
|
7902
7980
|
"use strict";
|
|
7903
7981
|
init_logger();
|
|
7904
|
-
|
|
7982
|
+
log13 = createLogger("config");
|
|
7905
7983
|
CONFIG_PATH = path11.join(
|
|
7906
7984
|
os.homedir(),
|
|
7907
7985
|
".mindstudio-local-tunnel",
|
|
@@ -7960,7 +8038,7 @@ async function persistAttachments(attachments) {
|
|
|
7960
8038
|
}
|
|
7961
8039
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
7962
8040
|
await writeFile(localPath, buffer);
|
|
7963
|
-
|
|
8041
|
+
log14.info("Attachment saved", {
|
|
7964
8042
|
filename: name,
|
|
7965
8043
|
path: localPath,
|
|
7966
8044
|
bytes: buffer.length
|
|
@@ -7974,7 +8052,7 @@ async function persistAttachments(attachments) {
|
|
|
7974
8052
|
if (textRes.ok) {
|
|
7975
8053
|
extractedTextPath = `${localPath}.txt`;
|
|
7976
8054
|
await writeFile(extractedTextPath, await textRes.text(), "utf-8");
|
|
7977
|
-
|
|
8055
|
+
log14.info("Extracted text saved", { path: extractedTextPath });
|
|
7978
8056
|
}
|
|
7979
8057
|
} catch {
|
|
7980
8058
|
}
|
|
@@ -8019,12 +8097,12 @@ function buildUploadHeader(results) {
|
|
|
8019
8097
|
return `[Uploaded files]
|
|
8020
8098
|
${lines.join("\n")}`;
|
|
8021
8099
|
}
|
|
8022
|
-
var
|
|
8100
|
+
var log14, UPLOADS_DIR, IMAGE_EXTENSIONS;
|
|
8023
8101
|
var init_attachments = __esm({
|
|
8024
8102
|
"src/headless/attachments.ts"() {
|
|
8025
8103
|
"use strict";
|
|
8026
8104
|
init_logger();
|
|
8027
|
-
|
|
8105
|
+
log14 = createLogger("headless:attachments");
|
|
8028
8106
|
UPLOADS_DIR = "src/.user-uploads";
|
|
8029
8107
|
IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".webp"]);
|
|
8030
8108
|
}
|
|
@@ -8238,12 +8316,13 @@ var headless_exports = {};
|
|
|
8238
8316
|
__export(headless_exports, {
|
|
8239
8317
|
HeadlessSession: () => HeadlessSession
|
|
8240
8318
|
});
|
|
8241
|
-
var
|
|
8319
|
+
var log15, EXTERNAL_TOOL_TIMEOUT_MS, USER_FACING_TOOLS, FORCED_COMPACTION_THRESHOLD_TOKENS, HISTORY_DEFAULT_LIMIT, HISTORY_MAX_LIMIT, HeadlessSession;
|
|
8242
8320
|
var init_headless = __esm({
|
|
8243
8321
|
"src/headless/index.ts"() {
|
|
8244
8322
|
"use strict";
|
|
8245
8323
|
init_logger();
|
|
8246
8324
|
init_config();
|
|
8325
|
+
init_orgContext();
|
|
8247
8326
|
init_prompt();
|
|
8248
8327
|
init_trigger();
|
|
8249
8328
|
init_compaction();
|
|
@@ -8259,7 +8338,7 @@ var init_headless = __esm({
|
|
|
8259
8338
|
init_messageQueue();
|
|
8260
8339
|
init_resolve();
|
|
8261
8340
|
init_sentinel();
|
|
8262
|
-
|
|
8341
|
+
log15 = createLogger("headless");
|
|
8263
8342
|
EXTERNAL_TOOL_TIMEOUT_MS = 3e5;
|
|
8264
8343
|
USER_FACING_TOOLS = /* @__PURE__ */ new Set([
|
|
8265
8344
|
"promptUser",
|
|
@@ -8326,6 +8405,7 @@ var init_headless = __esm({
|
|
|
8326
8405
|
apiKey: this.opts.apiKey,
|
|
8327
8406
|
baseUrl: this.opts.baseUrl
|
|
8328
8407
|
});
|
|
8408
|
+
await initOrgContext(this.config);
|
|
8329
8409
|
const resumed = loadSession(this.state);
|
|
8330
8410
|
this.queue = new MessageQueue(loadQueue(), () => {
|
|
8331
8411
|
this.persistStats();
|
|
@@ -8403,7 +8483,7 @@ var init_headless = __esm({
|
|
|
8403
8483
|
}
|
|
8404
8484
|
const line = JSON.stringify(payload) + "\n";
|
|
8405
8485
|
if (event === "history") {
|
|
8406
|
-
|
|
8486
|
+
log15.info("Wrote history event to stdout", {
|
|
8407
8487
|
requestId,
|
|
8408
8488
|
bytes: line.length
|
|
8409
8489
|
});
|
|
@@ -8480,7 +8560,7 @@ var init_headless = __esm({
|
|
|
8480
8560
|
if (this.sessionStats.lastContextSize <= FORCED_COMPACTION_THRESHOLD_TOKENS) {
|
|
8481
8561
|
return;
|
|
8482
8562
|
}
|
|
8483
|
-
|
|
8563
|
+
log15.info("Forced compaction gate triggered", {
|
|
8484
8564
|
contextSize: this.sessionStats.lastContextSize,
|
|
8485
8565
|
threshold: FORCED_COMPACTION_THRESHOLD_TOKENS,
|
|
8486
8566
|
requestId
|
|
@@ -8507,7 +8587,7 @@ var init_headless = __esm({
|
|
|
8507
8587
|
}
|
|
8508
8588
|
onBackgroundComplete = (toolCallId, name, result, subAgentMessages) => {
|
|
8509
8589
|
this.pendingBlockUpdates.push({ toolCallId, result, subAgentMessages });
|
|
8510
|
-
|
|
8590
|
+
log15.info("Background complete", {
|
|
8511
8591
|
toolCallId,
|
|
8512
8592
|
name,
|
|
8513
8593
|
requestId: this.currentRequestId
|
|
@@ -8729,7 +8809,7 @@ var init_headless = __esm({
|
|
|
8729
8809
|
await this.runForcedCompactionIfNeeded(requestId);
|
|
8730
8810
|
const attachments = parsed.attachments;
|
|
8731
8811
|
if (attachments?.length) {
|
|
8732
|
-
|
|
8812
|
+
log15.info("Message has attachments", {
|
|
8733
8813
|
count: attachments.length,
|
|
8734
8814
|
urls: attachments.map((a) => a.url)
|
|
8735
8815
|
});
|
|
@@ -8745,7 +8825,7 @@ var init_headless = __esm({
|
|
|
8745
8825
|
attachmentHeader = header;
|
|
8746
8826
|
}
|
|
8747
8827
|
} catch (err) {
|
|
8748
|
-
|
|
8828
|
+
log15.warn("Attachment persistence failed", { error: err.message });
|
|
8749
8829
|
}
|
|
8750
8830
|
}
|
|
8751
8831
|
let resolved = null;
|
|
@@ -8806,7 +8886,7 @@ var init_headless = __esm({
|
|
|
8806
8886
|
error: "Turn ended unexpectedly"
|
|
8807
8887
|
});
|
|
8808
8888
|
}
|
|
8809
|
-
|
|
8889
|
+
log15.info("Turn complete", {
|
|
8810
8890
|
requestId,
|
|
8811
8891
|
durationMs: Date.now() - this.turnStart
|
|
8812
8892
|
});
|
|
@@ -8818,7 +8898,7 @@ var init_headless = __esm({
|
|
|
8818
8898
|
error: err.message
|
|
8819
8899
|
});
|
|
8820
8900
|
}
|
|
8821
|
-
|
|
8901
|
+
log15.warn("Command failed", {
|
|
8822
8902
|
action: "message",
|
|
8823
8903
|
requestId,
|
|
8824
8904
|
error: err.message
|
|
@@ -8968,7 +9048,7 @@ var init_headless = __esm({
|
|
|
8968
9048
|
try {
|
|
8969
9049
|
parsed = JSON.parse(line);
|
|
8970
9050
|
} catch (err) {
|
|
8971
|
-
|
|
9051
|
+
log15.warn("Invalid JSON on stdin", {
|
|
8972
9052
|
error: err.message,
|
|
8973
9053
|
lineLength: line.length,
|
|
8974
9054
|
preview: line.slice(0, 200)
|
|
@@ -8977,7 +9057,7 @@ var init_headless = __esm({
|
|
|
8977
9057
|
return;
|
|
8978
9058
|
}
|
|
8979
9059
|
const { action, requestId } = parsed;
|
|
8980
|
-
|
|
9060
|
+
log15.info("Command received", { action, requestId });
|
|
8981
9061
|
if (action === "tool_result" && parsed.id) {
|
|
8982
9062
|
const id = parsed.id;
|
|
8983
9063
|
const result = parsed.result ?? "";
|
|
@@ -8986,7 +9066,7 @@ var init_headless = __esm({
|
|
|
8986
9066
|
this.pendingTools.delete(id);
|
|
8987
9067
|
pending.resolve(result);
|
|
8988
9068
|
} else if (!this.running) {
|
|
8989
|
-
|
|
9069
|
+
log15.info("Late tool_result while idle, dismissing", { id });
|
|
8990
9070
|
this.emit("completed", { success: true }, requestId);
|
|
8991
9071
|
} else {
|
|
8992
9072
|
this.earlyResults.set(id, result);
|
|
@@ -9005,7 +9085,7 @@ var init_headless = __esm({
|
|
|
9005
9085
|
startIndex--;
|
|
9006
9086
|
}
|
|
9007
9087
|
const endIndex = before;
|
|
9008
|
-
|
|
9088
|
+
log15.info("History response", {
|
|
9009
9089
|
requestId,
|
|
9010
9090
|
startIndex,
|
|
9011
9091
|
endIndex,
|
|
@@ -9460,6 +9540,7 @@ Error: ${err.message}`,
|
|
|
9460
9540
|
|
|
9461
9541
|
// src/index.tsx
|
|
9462
9542
|
init_config();
|
|
9543
|
+
init_orgContext();
|
|
9463
9544
|
init_logger();
|
|
9464
9545
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
9465
9546
|
var args = process.argv.slice(2);
|
|
@@ -9523,6 +9604,7 @@ if (headless) {
|
|
|
9523
9604
|
baseUrl: flags.baseUrl
|
|
9524
9605
|
});
|
|
9525
9606
|
printDebugInfo(config);
|
|
9607
|
+
await initOrgContext(config);
|
|
9526
9608
|
const { waitUntilExit } = render(
|
|
9527
9609
|
/* @__PURE__ */ jsx6(
|
|
9528
9610
|
App,
|