@perkos/perkos-a2a 0.12.40 → 0.12.42
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 +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +151 -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;
|
|
@@ -45,6 +55,19 @@ type EmbeddedChatRunResult = {
|
|
|
45
55
|
};
|
|
46
56
|
};
|
|
47
57
|
export declare function extractOpenClawChatReply(result: EmbeddedChatRunResult): string | null;
|
|
58
|
+
export type OpenClawRuntimeModelRoute = {
|
|
59
|
+
provider: string;
|
|
60
|
+
model: string;
|
|
61
|
+
source: "plugin-override" | "agent-default" | "gateway-default";
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Resolve the provider/model route already owned by OpenClaw. The embedded
|
|
65
|
+
* runner in OpenClaw 2026.5.x does not resolve `agents.defaults.model` when a
|
|
66
|
+
* plugin calls it directly; without explicit run parameters it silently
|
|
67
|
+
* starts from openai/gpt-5.5. Passing this resolved route is therefore an
|
|
68
|
+
* adapter responsibility, not a PerkOS model choice.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveOpenClawRuntimeModelRoute(runtimeConfig: unknown, agentId: string, explicitPluginOverride?: string): OpenClawRuntimeModelRoute | null;
|
|
48
71
|
export declare function runOpenClawChatTurn(api: any, config: A2APluginConfig, sessionKey: string, prompt: string, transcriptPrompt: string, logger: {
|
|
49
72
|
info: (...args: unknown[]) => void;
|
|
50
73
|
error: (...args: unknown[]) => void;
|
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,CA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AE,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,CAgHxB;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)}`
|
|
@@ -29555,6 +29631,31 @@ function openclawAgentId(config) {
|
|
|
29555
29631
|
const parts = sessionKey.split(":");
|
|
29556
29632
|
return parts[0] === "agent" && parts[1] ? parts[1] : "main";
|
|
29557
29633
|
}
|
|
29634
|
+
function parseOpenClawModelRef(value) {
|
|
29635
|
+
const modelRef = typeof value === "string" ? value.trim() : value && typeof value === "object" && typeof value.primary === "string" ? String(value.primary).trim() : "";
|
|
29636
|
+
const separator = modelRef.indexOf("/");
|
|
29637
|
+
if (separator <= 0 || separator >= modelRef.length - 1) return null;
|
|
29638
|
+
return {
|
|
29639
|
+
provider: modelRef.slice(0, separator),
|
|
29640
|
+
model: modelRef.slice(separator + 1)
|
|
29641
|
+
};
|
|
29642
|
+
}
|
|
29643
|
+
function resolveOpenClawRuntimeModelRoute(runtimeConfig, agentId, explicitPluginOverride) {
|
|
29644
|
+
const explicit = parseOpenClawModelRef(explicitPluginOverride);
|
|
29645
|
+
if (explicit) return { ...explicit, source: "plugin-override" };
|
|
29646
|
+
if (!runtimeConfig || typeof runtimeConfig !== "object") return null;
|
|
29647
|
+
const agents = runtimeConfig.agents;
|
|
29648
|
+
if (!agents || typeof agents !== "object") return null;
|
|
29649
|
+
const agentConfig = agents;
|
|
29650
|
+
const list = Array.isArray(agentConfig.list) ? agentConfig.list : [];
|
|
29651
|
+
const selectedAgent = list.find((entry) => entry && typeof entry === "object" && String(entry.id ?? "").trim() === agentId);
|
|
29652
|
+
const selected = parseOpenClawModelRef(selectedAgent?.model);
|
|
29653
|
+
if (selected) return { ...selected, source: "agent-default" };
|
|
29654
|
+
const defaults = agentConfig.defaults;
|
|
29655
|
+
if (!defaults || typeof defaults !== "object") return null;
|
|
29656
|
+
const gateway = parseOpenClawModelRef(defaults.model);
|
|
29657
|
+
return gateway ? { ...gateway, source: "gateway-default" } : null;
|
|
29658
|
+
}
|
|
29558
29659
|
async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPrompt, logger) {
|
|
29559
29660
|
const runEmbeddedAgent = api.runtime?.agent?.runEmbeddedAgent;
|
|
29560
29661
|
const currentConfig = api.runtime?.config?.current;
|
|
@@ -29565,20 +29666,34 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29565
29666
|
}
|
|
29566
29667
|
const agentId = openclawAgentId(config);
|
|
29567
29668
|
const runtimeConfig = currentConfig();
|
|
29669
|
+
const runtimeRoute = resolveOpenClawRuntimeModelRoute(
|
|
29670
|
+
runtimeConfig,
|
|
29671
|
+
agentId,
|
|
29672
|
+
config.runtime?.model
|
|
29673
|
+
);
|
|
29568
29674
|
const workspaceDir = resolveAgentWorkspaceDir(runtimeConfig, agentId);
|
|
29569
|
-
const
|
|
29675
|
+
const sessionContext = readOpenClawChatSession(api, agentId, sessionKey);
|
|
29676
|
+
const entry = sessionContext.entry;
|
|
29570
29677
|
const sessionId = typeof entry?.sessionId === "string" && entry.sessionId.trim() ? entry.sessionId : randomUUID7();
|
|
29571
29678
|
const configuredTimeout = api.runtime?.agent?.resolveAgentTimeoutMs?.(runtimeConfig);
|
|
29572
29679
|
const timeoutMs = Math.min(
|
|
29573
29680
|
75e3,
|
|
29574
29681
|
typeof configuredTimeout === "number" && configuredTimeout > 0 ? configuredTimeout : 75e3
|
|
29575
29682
|
);
|
|
29683
|
+
let selectedProvider = runtimeRoute?.provider;
|
|
29684
|
+
let selectedModel = runtimeRoute?.model;
|
|
29685
|
+
if (runtimeRoute) {
|
|
29686
|
+
logger.info(
|
|
29687
|
+
`[perkos-chat] using OpenClaw runtime-owned route ${runtimeRoute.provider}/${runtimeRoute.model} (${runtimeRoute.source})`
|
|
29688
|
+
);
|
|
29689
|
+
}
|
|
29576
29690
|
const run = async (configOverride, retryNative = false) => runEmbeddedAgent({
|
|
29577
29691
|
sessionId,
|
|
29578
29692
|
sessionKey,
|
|
29579
29693
|
agentId,
|
|
29580
29694
|
workspaceDir,
|
|
29581
29695
|
config: configOverride,
|
|
29696
|
+
...sessionContext.sessionFile ? { sessionFile: sessionContext.sessionFile } : {},
|
|
29582
29697
|
prompt,
|
|
29583
29698
|
transcriptPrompt,
|
|
29584
29699
|
timeoutMs,
|
|
@@ -29590,6 +29705,11 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29590
29705
|
terminalReplyExpectation: "required",
|
|
29591
29706
|
suppressLiveStreamOutput: true,
|
|
29592
29707
|
cleanupBundleMcpOnRunEnd: true,
|
|
29708
|
+
...selectedProvider && selectedModel ? { provider: selectedProvider, model: selectedModel } : {},
|
|
29709
|
+
onExecutionPhase: (info) => {
|
|
29710
|
+
if (info.provider?.trim()) selectedProvider = info.provider.trim();
|
|
29711
|
+
if (info.model?.trim()) selectedModel = info.model.trim();
|
|
29712
|
+
},
|
|
29593
29713
|
...retryNative ? {
|
|
29594
29714
|
// Cross-version compatibility: 2026.5.x recognizes `pi`, while
|
|
29595
29715
|
// current gateways recognize the explicit native runtime override.
|
|
@@ -29610,7 +29730,11 @@ async function runOpenClawChatTurn(api, config, sessionKey, prompt, transcriptPr
|
|
|
29610
29730
|
);
|
|
29611
29731
|
await forceNativeOpenClawChatRuntime(api, config, sessionKey, logger);
|
|
29612
29732
|
result = await run(
|
|
29613
|
-
|
|
29733
|
+
useNativeHarnessForResolvedRoute(
|
|
29734
|
+
omitUnavailableAgentHarness(runtimeConfig, unavailableHarnessId),
|
|
29735
|
+
selectedProvider,
|
|
29736
|
+
selectedModel
|
|
29737
|
+
),
|
|
29614
29738
|
true
|
|
29615
29739
|
);
|
|
29616
29740
|
}
|
|
@@ -30418,7 +30542,10 @@ export {
|
|
|
30418
30542
|
normalizeOpenClawPluginConfig,
|
|
30419
30543
|
omitUnavailableAgentHarness,
|
|
30420
30544
|
openclawChatSessionKey,
|
|
30421
|
-
|
|
30545
|
+
prepareOpenClawChatSession,
|
|
30546
|
+
resolveOpenClawRuntimeModelRoute,
|
|
30547
|
+
runOpenClawChatTurn,
|
|
30548
|
+
useNativeHarnessForResolvedRoute
|
|
30422
30549
|
};
|
|
30423
30550
|
/*! Bundled license information:
|
|
30424
30551
|
|