@perkos/perkos-a2a 0.12.40 → 0.12.41
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.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -24
- package/dist/index.js.map +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ type OpenClawSessionEntry = Record<string, unknown>;
|
|
|
25
25
|
* whose default model metadata can reference a plugin harness that is absent.
|
|
26
26
|
*/
|
|
27
27
|
export declare function omitUnavailableAgentHarness(value: unknown, unavailableHarnessId: string): unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Select OpenClaw's built-in harness for the route OpenClaw itself resolved.
|
|
30
|
+
* This changes no provider/model selection: the temporary policy is scoped to
|
|
31
|
+
* that exact runtime-owned route and exists only for this retry.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useNativeHarnessForResolvedRoute(value: unknown, provider?: string, model?: string): unknown;
|
|
28
34
|
/**
|
|
29
35
|
* Remove model and harness selections persisted by an earlier chat wake so
|
|
30
36
|
* the next turn resolves the gateway's current default. A configured plugin
|
|
@@ -32,6 +38,10 @@ export declare function omitUnavailableAgentHarness(value: unknown, unavailableH
|
|
|
32
38
|
* model, without imposing a provider on every invited agent.
|
|
33
39
|
*/
|
|
34
40
|
export declare function alignOpenClawChatSessionModel(entry: OpenClawSessionEntry, configuredModel?: string): OpenClawSessionEntry;
|
|
41
|
+
export declare function prepareOpenClawChatSession(api: any, config: A2APluginConfig, sessionKey: string, logger: {
|
|
42
|
+
info: (...args: unknown[]) => void;
|
|
43
|
+
error: (...args: unknown[]) => void;
|
|
44
|
+
}): Promise<void>;
|
|
35
45
|
type EmbeddedChatRunResult = {
|
|
36
46
|
payloads?: Array<{
|
|
37
47
|
text?: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAGV,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,YAAY,CAAC;AA0C3B,kEAAkE;AAClE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAItF;AAED,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAGV,WAAW,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,YAAY,CAAC;AA0C3B,kEAAkE;AAClE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM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ACR,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CAAE,GAClF,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmGxB;AAYD,oFAAoF;AACpF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,EAAE,EACvB,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAWR;AA4CD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAe/D;AAMD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAc7E;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,GAAG,EAAE,GAAG,QAszBxC"}
|
package/dist/index.js
CHANGED
|
@@ -29443,6 +29443,58 @@ function openclawChatSessionKey(config, convId) {
|
|
|
29443
29443
|
const safe = convId.replace(/[^a-zA-Z0-9_.-]/g, "-").slice(0, 120) || "unknown";
|
|
29444
29444
|
return `${configured}:perkos-chat-${safe}`;
|
|
29445
29445
|
}
|
|
29446
|
+
async function mutateOpenClawChatSession(api, config, sessionKey, update) {
|
|
29447
|
+
const sessionApi = api.runtime?.agent?.session;
|
|
29448
|
+
const patchSessionEntry = sessionApi?.patchSessionEntry;
|
|
29449
|
+
if (typeof patchSessionEntry === "function") {
|
|
29450
|
+
await patchSessionEntry({
|
|
29451
|
+
sessionKey,
|
|
29452
|
+
fallbackEntry: { sessionId: randomUUID7(), updatedAt: Date.now() },
|
|
29453
|
+
preserveActivity: true,
|
|
29454
|
+
replaceEntry: true,
|
|
29455
|
+
update
|
|
29456
|
+
});
|
|
29457
|
+
return "modern";
|
|
29458
|
+
}
|
|
29459
|
+
const resolveStorePath = sessionApi?.resolveStorePath;
|
|
29460
|
+
const updateSessionStore = sessionApi?.updateSessionStore;
|
|
29461
|
+
if (typeof resolveStorePath !== "function" || typeof updateSessionStore !== "function") {
|
|
29462
|
+
return null;
|
|
29463
|
+
}
|
|
29464
|
+
const agentId = openclawAgentId(config);
|
|
29465
|
+
const storePath = resolveStorePath(void 0, { agentId });
|
|
29466
|
+
await updateSessionStore(
|
|
29467
|
+
storePath,
|
|
29468
|
+
(store) => {
|
|
29469
|
+
const current = store[sessionKey] ?? { sessionId: randomUUID7(), updatedAt: Date.now() };
|
|
29470
|
+
store[sessionKey] = update(current);
|
|
29471
|
+
return store[sessionKey];
|
|
29472
|
+
},
|
|
29473
|
+
{ activeSessionKey: sessionKey }
|
|
29474
|
+
);
|
|
29475
|
+
return "legacy";
|
|
29476
|
+
}
|
|
29477
|
+
function readOpenClawChatSession(api, agentId, sessionKey) {
|
|
29478
|
+
const sessionApi = api.runtime?.agent?.session;
|
|
29479
|
+
const modernEntry = sessionApi?.getSessionEntry?.({ agentId, sessionKey });
|
|
29480
|
+
if (modernEntry && typeof modernEntry === "object") return { entry: modernEntry };
|
|
29481
|
+
const resolveStorePath = sessionApi?.resolveStorePath;
|
|
29482
|
+
const loadSessionStore = sessionApi?.loadSessionStore;
|
|
29483
|
+
if (typeof resolveStorePath !== "function" || typeof loadSessionStore !== "function") {
|
|
29484
|
+
return {};
|
|
29485
|
+
}
|
|
29486
|
+
try {
|
|
29487
|
+
const storePath = resolveStorePath(void 0, { agentId });
|
|
29488
|
+
const store = loadSessionStore(storePath, { skipCache: true, clone: true });
|
|
29489
|
+
const entry = store?.[sessionKey];
|
|
29490
|
+
const sessionId = typeof entry?.sessionId === "string" ? entry.sessionId : void 0;
|
|
29491
|
+
const resolveSessionFilePath = sessionApi?.resolveSessionFilePath;
|
|
29492
|
+
const sessionFile = sessionId && typeof resolveSessionFilePath === "function" ? resolveSessionFilePath(sessionId, entry, { agentId, storePath }) : void 0;
|
|
29493
|
+
return { entry, sessionFile };
|
|
29494
|
+
} catch {
|
|
29495
|
+
return {};
|
|
29496
|
+
}
|
|
29497
|
+
}
|
|
29446
29498
|
var MISSING_AGENT_HARNESS_RE = /Requested agent harness "([^"]+)" is not registered\./u;
|
|
29447
29499
|
function missingAgentHarnessId(error) {
|
|
29448
29500
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -29466,6 +29518,33 @@ function omitUnavailableAgentHarness(value, unavailableHarnessId) {
|
|
|
29466
29518
|
}
|
|
29467
29519
|
return next;
|
|
29468
29520
|
}
|
|
29521
|
+
function useNativeHarnessForResolvedRoute(value, provider, model) {
|
|
29522
|
+
const selectedProvider = provider?.trim();
|
|
29523
|
+
const selectedModel = model?.trim();
|
|
29524
|
+
if (!value || typeof value !== "object" || !selectedProvider || !selectedModel) return value;
|
|
29525
|
+
const source = value;
|
|
29526
|
+
const agents = source.agents && typeof source.agents === "object" ? source.agents : {};
|
|
29527
|
+
const defaults = agents.defaults && typeof agents.defaults === "object" ? agents.defaults : {};
|
|
29528
|
+
const models = defaults.models && typeof defaults.models === "object" ? defaults.models : {};
|
|
29529
|
+
const modelKey = selectedModel.includes("/") ? selectedModel : `${selectedProvider}/${selectedModel}`;
|
|
29530
|
+
const modelEntry = models[modelKey] && typeof models[modelKey] === "object" ? models[modelKey] : {};
|
|
29531
|
+
return {
|
|
29532
|
+
...source,
|
|
29533
|
+
agents: {
|
|
29534
|
+
...agents,
|
|
29535
|
+
defaults: {
|
|
29536
|
+
...defaults,
|
|
29537
|
+
models: {
|
|
29538
|
+
...models,
|
|
29539
|
+
[modelKey]: {
|
|
29540
|
+
...modelEntry,
|
|
29541
|
+
agentRuntime: { id: "pi" }
|
|
29542
|
+
}
|
|
29543
|
+
}
|
|
29544
|
+
}
|
|
29545
|
+
}
|
|
29546
|
+
};
|
|
29547
|
+
}
|
|
29469
29548
|
function alignOpenClawChatSessionModel(entry, configuredModel) {
|
|
29470
29549
|
const next = { ...entry };
|
|
29471
29550
|
for (const key of [
|
|
@@ -29498,21 +29577,19 @@ function alignOpenClawChatSessionModel(entry, configuredModel) {
|
|
|
29498
29577
|
return next;
|
|
29499
29578
|
}
|
|
29500
29579
|
async function prepareOpenClawChatSession(api, config, sessionKey, logger) {
|
|
29501
|
-
const patchSessionEntry = api.runtime?.agent?.session?.patchSessionEntry;
|
|
29502
|
-
if (typeof patchSessionEntry !== "function") {
|
|
29503
|
-
logger.info("[perkos-chat] OpenClaw session metadata API unavailable \u2014 using gateway session defaults");
|
|
29504
|
-
return;
|
|
29505
|
-
}
|
|
29506
29580
|
try {
|
|
29507
|
-
await
|
|
29581
|
+
const source = await mutateOpenClawChatSession(
|
|
29582
|
+
api,
|
|
29583
|
+
config,
|
|
29508
29584
|
sessionKey,
|
|
29509
|
-
|
|
29510
|
-
|
|
29511
|
-
|
|
29512
|
-
|
|
29513
|
-
|
|
29585
|
+
(entry) => alignOpenClawChatSessionModel(entry, config.runtime?.model)
|
|
29586
|
+
);
|
|
29587
|
+
if (!source) {
|
|
29588
|
+
logger.info("[perkos-chat] OpenClaw session metadata API unavailable \u2014 using gateway session defaults");
|
|
29589
|
+
return;
|
|
29590
|
+
}
|
|
29514
29591
|
logger.info(
|
|
29515
|
-
config.runtime?.model ? `[perkos-chat] session ${sessionKey} pinned to ${config.runtime.model}` : `[perkos-chat] session ${sessionKey} aligned to the gateway's active default model`
|
|
29592
|
+
config.runtime?.model ? `[perkos-chat] session ${sessionKey} pinned to ${config.runtime.model}` : `[perkos-chat] session ${sessionKey} aligned to the gateway's active default model (${source} session API)`
|
|
29516
29593
|
);
|
|
29517
29594
|
} catch (err) {
|
|
29518
29595
|
logger.error(
|
|
@@ -29521,23 +29598,22 @@ async function prepareOpenClawChatSession(api, config, sessionKey, logger) {
|
|
|
29521
29598
|
}
|
|
29522
29599
|
}
|
|
29523
29600
|
async function forceNativeOpenClawChatRuntime(api, config, sessionKey, logger) {
|
|
29524
|
-
const patchSessionEntry = api.runtime?.agent?.session?.patchSessionEntry;
|
|
29525
|
-
if (typeof patchSessionEntry !== "function") return;
|
|
29526
29601
|
try {
|
|
29527
|
-
await
|
|
29602
|
+
const source = await mutateOpenClawChatSession(
|
|
29603
|
+
api,
|
|
29604
|
+
config,
|
|
29528
29605
|
sessionKey,
|
|
29529
|
-
|
|
29530
|
-
preserveActivity: true,
|
|
29531
|
-
replaceEntry: true,
|
|
29532
|
-
update: (entry) => ({
|
|
29606
|
+
(entry) => ({
|
|
29533
29607
|
...alignOpenClawChatSessionModel(entry, config.runtime?.model),
|
|
29534
29608
|
// OpenClaw <= 2026.5.x calls its built-in runtime "pi". Newer
|
|
29535
29609
|
// gateways normalize the alias to their native "openclaw" harness.
|
|
29536
29610
|
agentRuntimeOverride: "pi",
|
|
29537
29611
|
agentHarnessId: "pi"
|
|
29538
29612
|
})
|
|
29539
|
-
|
|
29540
|
-
|
|
29613
|
+
);
|
|
29614
|
+
if (source) {
|
|
29615
|
+
logger.info(`[perkos-chat] session ${sessionKey} retrying with the native OpenClaw harness (${source} session API)`);
|
|
29616
|
+
}
|
|
29541
29617
|
} catch (err) {
|
|
29542
29618
|
logger.error(
|
|
29543
29619
|
`[perkos-chat] failed to select native OpenClaw harness: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -29566,19 +29642,23 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29566
29642
|
const agentId = openclawAgentId(config);
|
|
29567
29643
|
const runtimeConfig = currentConfig();
|
|
29568
29644
|
const workspaceDir = resolveAgentWorkspaceDir(runtimeConfig, agentId);
|
|
29569
|
-
const
|
|
29645
|
+
const sessionContext = readOpenClawChatSession(api, agentId, sessionKey);
|
|
29646
|
+
const entry = sessionContext.entry;
|
|
29570
29647
|
const sessionId = typeof entry?.sessionId === "string" && entry.sessionId.trim() ? entry.sessionId : randomUUID7();
|
|
29571
29648
|
const configuredTimeout = api.runtime?.agent?.resolveAgentTimeoutMs?.(runtimeConfig);
|
|
29572
29649
|
const timeoutMs = Math.min(
|
|
29573
29650
|
75e3,
|
|
29574
29651
|
typeof configuredTimeout === "number" && configuredTimeout > 0 ? configuredTimeout : 75e3
|
|
29575
29652
|
);
|
|
29653
|
+
let selectedProvider;
|
|
29654
|
+
let selectedModel;
|
|
29576
29655
|
const run = async (configOverride, retryNative = false) => runEmbeddedAgent({
|
|
29577
29656
|
sessionId,
|
|
29578
29657
|
sessionKey,
|
|
29579
29658
|
agentId,
|
|
29580
29659
|
workspaceDir,
|
|
29581
29660
|
config: configOverride,
|
|
29661
|
+
...sessionContext.sessionFile ? { sessionFile: sessionContext.sessionFile } : {},
|
|
29582
29662
|
prompt,
|
|
29583
29663
|
transcriptPrompt,
|
|
29584
29664
|
timeoutMs,
|
|
@@ -29590,6 +29670,10 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29590
29670
|
terminalReplyExpectation: "required",
|
|
29591
29671
|
suppressLiveStreamOutput: true,
|
|
29592
29672
|
cleanupBundleMcpOnRunEnd: true,
|
|
29673
|
+
onExecutionPhase: (info) => {
|
|
29674
|
+
if (info.provider?.trim()) selectedProvider = info.provider.trim();
|
|
29675
|
+
if (info.model?.trim()) selectedModel = info.model.trim();
|
|
29676
|
+
},
|
|
29593
29677
|
...retryNative ? {
|
|
29594
29678
|
// Cross-version compatibility: 2026.5.x recognizes `pi`, while
|
|
29595
29679
|
// current gateways recognize the explicit native runtime override.
|
|
@@ -29610,7 +29694,11 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29610
29694
|
);
|
|
29611
29695
|
await forceNativeOpenClawChatRuntime(api, config, sessionKey, logger);
|
|
29612
29696
|
result = await run(
|
|
29613
|
-
|
|
29697
|
+
useNativeHarnessForResolvedRoute(
|
|
29698
|
+
omitUnavailableAgentHarness(runtimeConfig, unavailableHarnessId),
|
|
29699
|
+
selectedProvider,
|
|
29700
|
+
selectedModel
|
|
29701
|
+
),
|
|
29614
29702
|
true
|
|
29615
29703
|
);
|
|
29616
29704
|
}
|
|
@@ -30418,7 +30506,9 @@ export {
|
|
|
30418
30506
|
normalizeOpenClawPluginConfig,
|
|
30419
30507
|
omitUnavailableAgentHarness,
|
|
30420
30508
|
openclawChatSessionKey,
|
|
30421
|
-
|
|
30509
|
+
prepareOpenClawChatSession,
|
|
30510
|
+
runOpenClawChatTurn,
|
|
30511
|
+
useNativeHarnessForResolvedRoute
|
|
30422
30512
|
};
|
|
30423
30513
|
/*! Bundled license information:
|
|
30424
30514
|
|