replicas-engine 0.1.612 → 0.1.615
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/src/index.js +61 -26
- package/package.json +3 -2
package/dist/src/index.js
CHANGED
|
@@ -2480,6 +2480,27 @@ const message = await replicas.slack.call<{ channel: string; ts: string }>('chat
|
|
|
2480
2480
|
await replicas.slack.attachThread({ channel: message.channel, threadTs: message.ts });
|
|
2481
2481
|
\`\`\`
|
|
2482
2482
|
|
|
2483
|
+
A link in the message text stays plain text, so when the message carries a pull request or merge request link, pass \`blocks\` alongside \`text\` to render a button for it. Keep \`text\` set to the same message \u2014 Slack uses it for notifications and fallback.
|
|
2484
|
+
|
|
2485
|
+
\`\`\`ts
|
|
2486
|
+
await replicas.slack.call('chat.postMessage', {
|
|
2487
|
+
channel: 'C0123ABC',
|
|
2488
|
+
thread_ts: '1234567890.123456',
|
|
2489
|
+
text: summary,
|
|
2490
|
+
blocks: [
|
|
2491
|
+
{ type: 'section', text: { type: 'mrkdwn', text: summary } },
|
|
2492
|
+
{
|
|
2493
|
+
type: 'actions',
|
|
2494
|
+
elements: [
|
|
2495
|
+
{ type: 'button', text: { type: 'plain_text', text: 'View PR' }, url: prUrl, action_id: 'view_pr' },
|
|
2496
|
+
],
|
|
2497
|
+
},
|
|
2498
|
+
],
|
|
2499
|
+
});
|
|
2500
|
+
\`\`\`
|
|
2501
|
+
|
|
2502
|
+
Use "View MR" for GitLab. With several links, give each button a unique \`action_id\` and name its repository in the label ("View PR \xB7 web").
|
|
2503
|
+
|
|
2483
2504
|
Attach every new top-level conversation so future replies route to this workspace. For a reply in another thread, attach its root \`thread_ts\`, not the reply timestamp. Do not attach the originating thread again.
|
|
2484
2505
|
|
|
2485
2506
|
## Search and batch
|
|
@@ -2546,6 +2567,7 @@ var DEFAULT_USER_PREFERENCES = {
|
|
|
2546
2567
|
pr_user_attribution: false,
|
|
2547
2568
|
auto_draft_prs: false,
|
|
2548
2569
|
open_prs_in_graphite: false,
|
|
2570
|
+
open_links_in_desktop_app: false,
|
|
2549
2571
|
default_fast_mode: false,
|
|
2550
2572
|
agent_defaults: { ...EMPTY_AGENT_DEFAULT_SETTINGS },
|
|
2551
2573
|
credential_priority: null
|
|
@@ -4244,7 +4266,7 @@ function normalizeContentBlocks(content) {
|
|
|
4244
4266
|
if (typeof content === "string") {
|
|
4245
4267
|
return content ? [{ type: "text", text: content }] : [];
|
|
4246
4268
|
}
|
|
4247
|
-
return content
|
|
4269
|
+
return Array.isArray(content) ? content.filter((block) => isRecord(block) && typeof block.type === "string") : [];
|
|
4248
4270
|
}
|
|
4249
4271
|
function parseStringField(value) {
|
|
4250
4272
|
if (typeof value !== "string") return null;
|
|
@@ -5624,16 +5646,15 @@ async function monolithRequest(path6, init = {}) {
|
|
|
5624
5646
|
if (!ENGINE_ENV.REPLICAS_WORKSPACE_ID) {
|
|
5625
5647
|
throw new Error("REPLICAS_WORKSPACE_ID is not set; cannot call monolith");
|
|
5626
5648
|
}
|
|
5627
|
-
const isFormData = init.body instanceof FormData;
|
|
5628
5649
|
const headers = {
|
|
5629
5650
|
Authorization: `Bearer ${ENGINE_ENV.REPLICAS_ENGINE_SECRET}`,
|
|
5630
5651
|
"X-Workspace-Id": ENGINE_ENV.REPLICAS_WORKSPACE_ID
|
|
5631
5652
|
};
|
|
5632
|
-
if (!
|
|
5653
|
+
if (!(init.body instanceof FormData)) headers["Content-Type"] = "application/json";
|
|
5633
5654
|
return fetch(`${ENGINE_ENV.REPLICAS_MONOLITH_URL}${path6}`, {
|
|
5634
5655
|
method: init.method ?? "POST",
|
|
5635
5656
|
headers,
|
|
5636
|
-
body: init.body === void 0 ? void 0 :
|
|
5657
|
+
body: init.body === void 0 ? void 0 : init.body instanceof FormData ? init.body : JSON.stringify(init.body),
|
|
5637
5658
|
signal: init.signal
|
|
5638
5659
|
});
|
|
5639
5660
|
}
|
|
@@ -8047,7 +8068,7 @@ function convertCursorEvent(event, linearSessionId) {
|
|
|
8047
8068
|
return null;
|
|
8048
8069
|
}
|
|
8049
8070
|
function isOpencodePartEnded(part) {
|
|
8050
|
-
return "time" in part && isRecord(part.time) && part.time.end !== void 0;
|
|
8071
|
+
return "time" in part && isRecord(part.time) && "end" in part.time && part.time.end !== void 0;
|
|
8051
8072
|
}
|
|
8052
8073
|
function convertOpencodePart(part, linearSessionId) {
|
|
8053
8074
|
if ((part.type === "text" || part.type === "reasoning") && isOpencodePartEnded(part)) {
|
|
@@ -8061,10 +8082,9 @@ function convertOpencodePart(part, linearSessionId) {
|
|
|
8061
8082
|
}
|
|
8062
8083
|
};
|
|
8063
8084
|
}
|
|
8064
|
-
if (part.type === "tool"
|
|
8085
|
+
if (part.type === "tool") {
|
|
8065
8086
|
const state = part.state;
|
|
8066
|
-
const
|
|
8067
|
-
const result = status === "completed" ? summarizeResult(state.output) || "Done" : status === "error" ? `Error: ${summarizeResult(state.error) || "Tool failed"}` : void 0;
|
|
8087
|
+
const result = state.status === "completed" ? summarizeResult(state.output) || "Done" : state.status === "error" ? `Error: ${summarizeResult(state.error) || "Tool failed"}` : void 0;
|
|
8068
8088
|
return {
|
|
8069
8089
|
linearSessionId,
|
|
8070
8090
|
content: {
|
|
@@ -10868,7 +10888,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
10868
10888
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
10869
10889
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
10870
10890
|
var codexCliVersionEnsured = null;
|
|
10871
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
10891
|
+
var ENGINE_PACKAGE_VERSION = "0.1.615";
|
|
10872
10892
|
var INITIALIZE_METHOD = "initialize";
|
|
10873
10893
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
10874
10894
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -11650,8 +11670,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
|
|
|
11650
11670
|
...codexApprovalPolicyOverrides(),
|
|
11651
11671
|
developerInstructions: developerInstructions ?? null,
|
|
11652
11672
|
config: { web_search: "live", model_reasoning_summary: "auto" },
|
|
11653
|
-
experimentalRawEvents: false
|
|
11654
|
-
persistExtendedHistory: false
|
|
11673
|
+
experimentalRawEvents: false
|
|
11655
11674
|
};
|
|
11656
11675
|
}
|
|
11657
11676
|
async function buildThreadResumeParams(workingDirectory, threadId, request, developerInstructions, serviceTier) {
|
|
@@ -11666,8 +11685,7 @@ async function buildThreadResumeParams(workingDirectory, threadId, request, deve
|
|
|
11666
11685
|
...codexApprovalPolicyOverrides(),
|
|
11667
11686
|
developerInstructions: developerInstructions ?? null,
|
|
11668
11687
|
config: { web_search: "live", model_reasoning_summary: "auto" },
|
|
11669
|
-
excludeTurns: false
|
|
11670
|
-
persistExtendedHistory: false
|
|
11688
|
+
excludeTurns: false
|
|
11671
11689
|
};
|
|
11672
11690
|
}
|
|
11673
11691
|
async function buildTurnInput(request) {
|
|
@@ -12096,7 +12114,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
12096
12114
|
}
|
|
12097
12115
|
recordUserMessageEvent(request, extraPayload = {}) {
|
|
12098
12116
|
const images = imageContentToUserMessageImages(request.images);
|
|
12099
|
-
this.
|
|
12117
|
+
this.recordCodexHistoryEvent("event_msg", {
|
|
12100
12118
|
type: "user_message",
|
|
12101
12119
|
message: request.message,
|
|
12102
12120
|
...images ? { images } : {},
|
|
@@ -12173,7 +12191,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
12173
12191
|
terminalError = retryFailure.error;
|
|
12174
12192
|
}
|
|
12175
12193
|
}
|
|
12176
|
-
const event = this.
|
|
12194
|
+
const event = this.recordCodexHistoryEvent("codex-asp-error", {
|
|
12177
12195
|
message: terminalError instanceof Error ? terminalError.message : String(terminalError)
|
|
12178
12196
|
});
|
|
12179
12197
|
this.onEvent(event);
|
|
@@ -12964,13 +12982,13 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
12964
12982
|
return;
|
|
12965
12983
|
}
|
|
12966
12984
|
this.currentGoal = nextGoal;
|
|
12967
|
-
const event = this.
|
|
12985
|
+
const event = this.recordCodexHistoryEvent(
|
|
12968
12986
|
CHAT_GOAL_EVENT_TYPE,
|
|
12969
12987
|
{ goal: nextGoal }
|
|
12970
12988
|
);
|
|
12971
12989
|
this.onEvent(event);
|
|
12972
12990
|
}
|
|
12973
|
-
|
|
12991
|
+
recordCodexHistoryEvent(type, payload) {
|
|
12974
12992
|
const event = {
|
|
12975
12993
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12976
12994
|
type,
|
|
@@ -13780,7 +13798,8 @@ function opencodeErrorPayload(error) {
|
|
|
13780
13798
|
};
|
|
13781
13799
|
}
|
|
13782
13800
|
function opencodeFetch(input, init) {
|
|
13783
|
-
|
|
13801
|
+
const requestInit = { ...init, dispatcher: OPENCODE_FETCH_DISPATCHER };
|
|
13802
|
+
return fetch(input, requestInit);
|
|
13784
13803
|
}
|
|
13785
13804
|
function parseOpencodeToolInputText(text) {
|
|
13786
13805
|
try {
|
|
@@ -14382,7 +14401,10 @@ function explicitSkillName(session, message) {
|
|
|
14382
14401
|
if (!match) return null;
|
|
14383
14402
|
return session.resourceLoader.getSkills().skills.some((skill) => skill.name === match[1]) ? match[1] : null;
|
|
14384
14403
|
}
|
|
14385
|
-
function
|
|
14404
|
+
function piThinkingLevel(thinkingLevel) {
|
|
14405
|
+
return thinkingLevel === "max" || thinkingLevel === "ultra" || thinkingLevel === "ultracode" ? "xhigh" : thinkingLevel;
|
|
14406
|
+
}
|
|
14407
|
+
function registerCommandProtection(cwd, historyFile, recordHistoryEvent) {
|
|
14386
14408
|
return (pi) => {
|
|
14387
14409
|
pi.on("tool_call", async (event) => {
|
|
14388
14410
|
const command = extractToolCommand(event.input);
|
|
@@ -14396,7 +14418,16 @@ function registerCommandProtection(cwd) {
|
|
|
14396
14418
|
toolUseId: event.toolCallId
|
|
14397
14419
|
});
|
|
14398
14420
|
if (!result.allowed) {
|
|
14399
|
-
reportCommandProtectionBlock({
|
|
14421
|
+
reportCommandProtectionBlock({
|
|
14422
|
+
managerName: "PiManager",
|
|
14423
|
+
action: "tool call",
|
|
14424
|
+
eventType: "pi-command-protection.blocked",
|
|
14425
|
+
result,
|
|
14426
|
+
command,
|
|
14427
|
+
context: { toolName: event.toolName, toolUseId: event.toolCallId },
|
|
14428
|
+
historyFile,
|
|
14429
|
+
recordHistoryEvent
|
|
14430
|
+
});
|
|
14400
14431
|
return { block: true, reason: result.reason ?? "Command blocked by Replicas protection." };
|
|
14401
14432
|
}
|
|
14402
14433
|
return void 0;
|
|
@@ -14440,7 +14471,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
14440
14471
|
}
|
|
14441
14472
|
async listSlashCommands() {
|
|
14442
14473
|
await this.initialized;
|
|
14443
|
-
return mergeSlashCommands(
|
|
14474
|
+
return mergeSlashCommands((this.session?.promptTemplates ?? []).map((template) => createProviderSlashCommand("pi", template.name, template.description)).filter((command) => Boolean(command)));
|
|
14444
14475
|
}
|
|
14445
14476
|
async enqueueMessage(request) {
|
|
14446
14477
|
await this.initialized;
|
|
@@ -14471,7 +14502,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
14471
14502
|
await this.session.setModel(model2);
|
|
14472
14503
|
}
|
|
14473
14504
|
if (request.thinkingLevel) {
|
|
14474
|
-
this.session.setThinkingLevel(request.thinkingLevel
|
|
14505
|
+
this.session.setThinkingLevel(piThinkingLevel(request.thinkingLevel));
|
|
14475
14506
|
}
|
|
14476
14507
|
return this.session;
|
|
14477
14508
|
}
|
|
@@ -14514,7 +14545,11 @@ var PiManager = class extends CodingAgentManager {
|
|
|
14514
14545
|
const resourceLoader = new DefaultResourceLoader({
|
|
14515
14546
|
cwd: this.workingDirectory,
|
|
14516
14547
|
agentDir: join21(ENGINE_ENV.HOME_DIR, ".pi", "agent"),
|
|
14517
|
-
extensionFactories: [registerCommandProtection(
|
|
14548
|
+
extensionFactories: [registerCommandProtection(
|
|
14549
|
+
this.workingDirectory,
|
|
14550
|
+
this.historyFile,
|
|
14551
|
+
this.recordHistoryEvent.bind(this)
|
|
14552
|
+
)],
|
|
14518
14553
|
appendSystemPrompt: [this.buildCombinedInstructions() ?? ""]
|
|
14519
14554
|
});
|
|
14520
14555
|
await resourceLoader.reload();
|
|
@@ -14528,7 +14563,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
14528
14563
|
});
|
|
14529
14564
|
this.session = result.session;
|
|
14530
14565
|
if (request.thinkingLevel) {
|
|
14531
|
-
this.session.setThinkingLevel(request.thinkingLevel
|
|
14566
|
+
this.session.setThinkingLevel(piThinkingLevel(request.thinkingLevel));
|
|
14532
14567
|
}
|
|
14533
14568
|
this.activeSessionFile = sessionManager.getSessionFile() ?? null;
|
|
14534
14569
|
await this.onSaveSessionId(this.activeSessionFile);
|
|
@@ -15781,7 +15816,7 @@ async function uploadCanvasItem(item) {
|
|
|
15781
15816
|
form.append("updated_at", item.updatedAt);
|
|
15782
15817
|
form.append(
|
|
15783
15818
|
"file",
|
|
15784
|
-
new Blob([item.bytes], { type: item.mimeType }),
|
|
15819
|
+
new Blob([Uint8Array.from(item.bytes)], { type: item.mimeType }),
|
|
15785
15820
|
item.filename
|
|
15786
15821
|
);
|
|
15787
15822
|
const response = await monolithRequest("/v1/engine/canvas", {
|
|
@@ -16086,7 +16121,7 @@ async function uploadEngineLog(input, timeoutMs) {
|
|
|
16086
16121
|
form.append("session_id", input.sessionId);
|
|
16087
16122
|
form.append("filename", input.filename);
|
|
16088
16123
|
form.append("updated_at", input.updatedAt);
|
|
16089
|
-
form.append("file", new Blob([input.content], { type: "text/plain" }), input.filename);
|
|
16124
|
+
form.append("file", new Blob([Uint8Array.from(input.content)], { type: "text/plain" }), input.filename);
|
|
16090
16125
|
const response = await monolithRequest("/v1/engine/logs", {
|
|
16091
16126
|
body: form,
|
|
16092
16127
|
signal: AbortSignal.timeout(timeoutMs)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "replicas-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.615",
|
|
4
4
|
"description": "Lightweight API server for Replicas workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"dev": "tsx watch --conditions=development src/index.ts",
|
|
20
|
-
"build": "bun run --cwd ../shared build && node scripts/generate-workspace-sdk-types.mjs && tsup",
|
|
20
|
+
"build": "bun run --cwd ../shared build && node scripts/generate-workspace-sdk-types.mjs && bun run typecheck && tsup",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
21
22
|
"dev-pack": "bun run build && node scripts/pack-dev-tarball.mjs",
|
|
22
23
|
"start": "node dist/src/index.js",
|
|
23
24
|
"dev-sync": "scripts/dev-sync.sh",
|