aai-lark-bridge 0.2.4 → 0.2.6
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/cli.js +36 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "aai-lark-bridge",
|
|
7
|
-
version: "0.2.
|
|
7
|
+
version: "0.2.6",
|
|
8
8
|
description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
|
|
9
9
|
type: "module",
|
|
10
10
|
main: "./dist/index.js",
|
|
@@ -4963,6 +4963,7 @@ async function runQuiet(cmd, args, env) {
|
|
|
4963
4963
|
|
|
4964
4964
|
// src/bridge/lark-cli/profile-projection.ts
|
|
4965
4965
|
import { chmod as chmod4, mkdir as mkdir12 } from "fs/promises";
|
|
4966
|
+
import { basename as basename4 } from "path";
|
|
4966
4967
|
async function writeLarkCliSourceProjection(cfg, appPaths2) {
|
|
4967
4968
|
await mkdir12(appPaths2.larkCliSourceDir, { recursive: true, mode: 448 });
|
|
4968
4969
|
await chmod4(appPaths2.larkCliSourceDir, 448).catch(() => {
|
|
@@ -4989,9 +4990,9 @@ async function buildProjectionSecrets(cfg, appPaths2) {
|
|
|
4989
4990
|
...cfg.secrets?.providers ?? {}
|
|
4990
4991
|
};
|
|
4991
4992
|
const providerName = bridgeProviderName(cfg.accounts.app.secret);
|
|
4992
|
-
|
|
4993
|
+
const existing = providerName ? providers[providerName] : void 0;
|
|
4994
|
+
if (providerName && !isForeignExecProvider(existing)) {
|
|
4993
4995
|
const wrapperPath = await ensureSecretsGetterWrapper(appPaths2);
|
|
4994
|
-
const existing = providers[providerName];
|
|
4995
4996
|
providers[providerName] = {
|
|
4996
4997
|
...existing ?? {},
|
|
4997
4998
|
source: "exec",
|
|
@@ -5010,6 +5011,14 @@ async function buildProjectionSecrets(cfg, appPaths2) {
|
|
|
5010
5011
|
...Object.keys(providers).length > 0 ? { providers } : {}
|
|
5011
5012
|
};
|
|
5012
5013
|
}
|
|
5014
|
+
function isForeignExecProvider(pc) {
|
|
5015
|
+
if (!pc?.command || pc.source !== "exec") return false;
|
|
5016
|
+
const name = basename4(pc.command);
|
|
5017
|
+
if (name === "secrets-getter" || name === "secrets-getter.cmd") return false;
|
|
5018
|
+
const args = pc.args ?? [];
|
|
5019
|
+
if (args.length >= 2 && args[args.length - 2] === "secrets" && args[args.length - 1] === "get") return false;
|
|
5020
|
+
return true;
|
|
5021
|
+
}
|
|
5013
5022
|
function bridgeProviderName(secret) {
|
|
5014
5023
|
if (!isSecretRef(secret)) return void 0;
|
|
5015
5024
|
if (secret.source !== "exec") return void 0;
|
|
@@ -6226,6 +6235,9 @@ function* translateEvent(raw) {
|
|
|
6226
6235
|
};
|
|
6227
6236
|
return;
|
|
6228
6237
|
}
|
|
6238
|
+
if (typeof evt.result === "string" && evt.result.trim()) {
|
|
6239
|
+
yield { type: "final_text", content: evt.result };
|
|
6240
|
+
}
|
|
6229
6241
|
yield { type: "done", sessionId: evt.session_id, terminationReason: "normal" };
|
|
6230
6242
|
}
|
|
6231
6243
|
}
|
|
@@ -7142,7 +7154,7 @@ import {
|
|
|
7142
7154
|
unlinkSync as unlinkSync2,
|
|
7143
7155
|
writeFileSync as writeFileSync3
|
|
7144
7156
|
} from "fs";
|
|
7145
|
-
import { basename as
|
|
7157
|
+
import { basename as basename5, dirname as dirname14, isAbsolute as isAbsolute2, join as join19, sep as sep2 } from "path";
|
|
7146
7158
|
var BINDING_VERSION = 1;
|
|
7147
7159
|
var MIN_START_USD = 0.5;
|
|
7148
7160
|
var BINDING_INVALID_REPLY = "\u4EFB\u52A1\u7ED1\u5B9A\u8BFB\u4E0D\u4E86\uFF0C\u5148\u6309\u666E\u901A\u5BF9\u8BDD\u5904\u7406";
|
|
@@ -7304,7 +7316,7 @@ function copyAttachmentsIntoTask(binding, attachments) {
|
|
|
7304
7316
|
if (a.decision !== "accepted") return a;
|
|
7305
7317
|
try {
|
|
7306
7318
|
mkdirSync3(dir, { recursive: true });
|
|
7307
|
-
const dest = join19(dir,
|
|
7319
|
+
const dest = join19(dir, basename5(a.absPath));
|
|
7308
7320
|
if (!existsSync6(dest)) copyFileSync(a.absPath, dest);
|
|
7309
7321
|
return { ...a, absPath: dest, path: dest };
|
|
7310
7322
|
} catch {
|
|
@@ -15405,6 +15417,11 @@ async function runAgentBatch(deps) {
|
|
|
15405
15417
|
if (getShowToolCalls(controls.cfg)) return state;
|
|
15406
15418
|
return { ...state, blocks: state.blocks.filter((b) => b.kind !== "tool") };
|
|
15407
15419
|
};
|
|
15420
|
+
const forView = (state) => {
|
|
15421
|
+
const s = filterForPrefs(state);
|
|
15422
|
+
if (controls.profileConfig.agentKind === "codex" || !s.finalText) return s;
|
|
15423
|
+
return { ...s, blocks: [{ kind: "text", content: s.finalText, streaming: false }] };
|
|
15424
|
+
};
|
|
15408
15425
|
const cardRenderOptions = callbackAuth ? {
|
|
15409
15426
|
signCallback: (action) => callbackAuth.sign({
|
|
15410
15427
|
runId: execution.runId,
|
|
@@ -15485,7 +15502,7 @@ async function runAgentBatch(deps) {
|
|
|
15485
15502
|
producerStarted = true;
|
|
15486
15503
|
if (progress.abandoned()) return;
|
|
15487
15504
|
cardCtrl = ctrl;
|
|
15488
|
-
await ctrl.update(renderCard(
|
|
15505
|
+
await ctrl.update(renderCard(forView(latestState), cardRenderOptions));
|
|
15489
15506
|
await renderDone;
|
|
15490
15507
|
}
|
|
15491
15508
|
}
|
|
@@ -15503,7 +15520,7 @@ async function runAgentBatch(deps) {
|
|
|
15503
15520
|
latestState = state;
|
|
15504
15521
|
if (shouldOpenProgressStream(filterForPrefs(state))) progress.ensureOpen();
|
|
15505
15522
|
if (cardCtrl) {
|
|
15506
|
-
await cardCtrl.update(renderCard(
|
|
15523
|
+
await cardCtrl.update(renderCard(forView(state), cardRenderOptions));
|
|
15507
15524
|
}
|
|
15508
15525
|
},
|
|
15509
15526
|
startState
|
|
@@ -15516,10 +15533,10 @@ async function runAgentBatch(deps) {
|
|
|
15516
15533
|
producerStarted: () => producerStarted,
|
|
15517
15534
|
fallback: async (state) => {
|
|
15518
15535
|
if (controls.profileConfig.agentKind === "codex") return;
|
|
15519
|
-
if (renderText(
|
|
15536
|
+
if (renderText(forView(state)).trim() === "") return;
|
|
15520
15537
|
await channel.send(
|
|
15521
15538
|
chatId,
|
|
15522
|
-
{ card: renderCard(
|
|
15539
|
+
{ card: renderCard(forView(state), cardRenderOptions) },
|
|
15523
15540
|
sendOpts
|
|
15524
15541
|
);
|
|
15525
15542
|
}
|
|
@@ -15528,8 +15545,8 @@ async function runAgentBatch(deps) {
|
|
|
15528
15545
|
if (controls.profileConfig.agentKind !== "codex") throw err;
|
|
15529
15546
|
log.fail("stream", err, { mode: replyMode, step: "progress-stream" });
|
|
15530
15547
|
}
|
|
15531
|
-
await recallIfEmptyStreamedReply(channel, progress,
|
|
15532
|
-
scheduleProgressTerminalUpdate(channel, progress,
|
|
15548
|
+
await recallIfEmptyStreamedReply(channel, progress, forView(latestState), scope);
|
|
15549
|
+
scheduleProgressTerminalUpdate(channel, progress, forView(latestState), scope, replyMode);
|
|
15533
15550
|
if (controls.profileConfig.agentKind === "codex") {
|
|
15534
15551
|
await sendFinalReply({
|
|
15535
15552
|
channel,
|
|
@@ -15550,7 +15567,7 @@ async function runAgentBatch(deps) {
|
|
|
15550
15567
|
channel,
|
|
15551
15568
|
chatId,
|
|
15552
15569
|
scope,
|
|
15553
|
-
state: tailTextState(
|
|
15570
|
+
state: tailTextState(forView(latestState)),
|
|
15554
15571
|
replyMode,
|
|
15555
15572
|
sendOpts,
|
|
15556
15573
|
cardRenderOptions
|
|
@@ -15570,7 +15587,7 @@ async function runAgentBatch(deps) {
|
|
|
15570
15587
|
producerStarted = true;
|
|
15571
15588
|
if (progress.abandoned()) return;
|
|
15572
15589
|
markdownCtrl = ctrl;
|
|
15573
|
-
await ctrl.setContent(renderText(
|
|
15590
|
+
await ctrl.setContent(renderText(forView(latestState)));
|
|
15574
15591
|
await renderDone;
|
|
15575
15592
|
}
|
|
15576
15593
|
},
|
|
@@ -15587,7 +15604,7 @@ async function runAgentBatch(deps) {
|
|
|
15587
15604
|
latestState = state;
|
|
15588
15605
|
if (shouldOpenProgressStream(filterForPrefs(state))) progress.ensureOpen();
|
|
15589
15606
|
if (markdownCtrl) {
|
|
15590
|
-
await markdownCtrl.setContent(renderText(
|
|
15607
|
+
await markdownCtrl.setContent(renderText(forView(state)));
|
|
15591
15608
|
}
|
|
15592
15609
|
},
|
|
15593
15610
|
startState
|
|
@@ -15600,7 +15617,7 @@ async function runAgentBatch(deps) {
|
|
|
15600
15617
|
producerStarted: () => producerStarted,
|
|
15601
15618
|
fallback: async (state) => {
|
|
15602
15619
|
if (controls.profileConfig.agentKind === "codex") return;
|
|
15603
|
-
const body = renderText(
|
|
15620
|
+
const body = renderText(forView(state));
|
|
15604
15621
|
if (body.trim()) {
|
|
15605
15622
|
await channel.send(chatId, { markdown: body }, sendOpts);
|
|
15606
15623
|
}
|
|
@@ -15610,8 +15627,8 @@ async function runAgentBatch(deps) {
|
|
|
15610
15627
|
if (controls.profileConfig.agentKind !== "codex") throw err;
|
|
15611
15628
|
log.fail("stream", err, { mode: replyMode, step: "progress-stream" });
|
|
15612
15629
|
}
|
|
15613
|
-
await recallIfEmptyStreamedReply(channel, progress,
|
|
15614
|
-
scheduleProgressTerminalUpdate(channel, progress,
|
|
15630
|
+
await recallIfEmptyStreamedReply(channel, progress, forView(latestState), scope);
|
|
15631
|
+
scheduleProgressTerminalUpdate(channel, progress, forView(latestState), scope, replyMode);
|
|
15615
15632
|
if (controls.profileConfig.agentKind === "codex") {
|
|
15616
15633
|
await sendFinalReply({
|
|
15617
15634
|
channel,
|
|
@@ -15632,7 +15649,7 @@ async function runAgentBatch(deps) {
|
|
|
15632
15649
|
channel,
|
|
15633
15650
|
chatId,
|
|
15634
15651
|
scope,
|
|
15635
|
-
state: tailTextState(
|
|
15652
|
+
state: tailTextState(forView(latestState)),
|
|
15636
15653
|
replyMode,
|
|
15637
15654
|
sendOpts,
|
|
15638
15655
|
cardRenderOptions
|
|
@@ -15653,7 +15670,7 @@ async function runAgentBatch(deps) {
|
|
|
15653
15670
|
channel,
|
|
15654
15671
|
chatId,
|
|
15655
15672
|
scope,
|
|
15656
|
-
state: controls.profileConfig.agentKind === "codex" ? finalAnswerOnlyState(filterForPrefs(finalState)) :
|
|
15673
|
+
state: controls.profileConfig.agentKind === "codex" ? finalAnswerOnlyState(filterForPrefs(finalState)) : forView(finalState),
|
|
15657
15674
|
replyMode,
|
|
15658
15675
|
sendOpts,
|
|
15659
15676
|
cardRenderOptions
|