@tangle-network/agent-provider-cli-bridge 0.3.4 → 0.4.0

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AgentEnvironmentCapabilities, AgentEnvironmentProvider } from "@tangle-network/agent-interface/environment-provider";
2
+ import { type HarnessType } from "@tangle-network/agent-interface";
2
3
  export interface CliBridgeProviderOptions {
3
4
  baseUrl: string;
4
5
  bearerToken?: string;
@@ -24,4 +25,9 @@ export interface CliBridgeProviderOptions {
24
25
  capabilities?: AgentEnvironmentCapabilities;
25
26
  }
26
27
  export declare function createCliBridgeProvider(options: CliBridgeProviderOptions): AgentEnvironmentProvider;
27
- export declare function defaultCliBridgeCapabilities(): AgentEnvironmentCapabilities;
28
+ /**
29
+ * @param harness The bridge backend these capabilities describe. The prompt intents belong to that
30
+ * harness, not to this adapter — the adapter only forwards `agent_profile`. Omit it and both intents
31
+ * declare `false`: an adapter that cannot name its harness cannot promise either one.
32
+ */
33
+ export declare function defaultCliBridgeCapabilities(harness?: HarnessType): AgentEnvironmentCapabilities;
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { harnessSystemPromptIntents, } from "@tangle-network/agent-interface";
2
3
  import { Agent, fetch as undiciFetch } from "undici";
3
4
  export function createCliBridgeProvider(options) {
4
5
  assertTimeout(options.headersTimeoutMs, "headersTimeoutMs");
@@ -403,7 +404,7 @@ function toChatCompletionsBody(options, environmentInput, turn, runId) {
403
404
  const profile = inlineProfile(environmentInput.profile);
404
405
  return {
405
406
  model: resolveBridgeModel(options, environmentInput, turn, profile),
406
- messages: messagesFromTurn(turn, profile),
407
+ messages: messagesFromTurn(turn),
407
408
  stream: true,
408
409
  ...(turn.sessionId ? { session_id: turn.sessionId } : {}),
409
410
  run_id: runId,
@@ -438,13 +439,18 @@ function resolveBridgeModel(options, environmentInput, turn, profile) {
438
439
  return `${harness}/${provider}/${model}`;
439
440
  return `${harness}/${model}`;
440
441
  }
441
- function messagesFromTurn(turn, profile) {
442
- const messages = [];
443
- const systemPrompt = profile?.prompt?.systemPrompt;
444
- if (systemPrompt)
445
- messages.push({ role: "system", content: systemPrompt });
446
- messages.push({ role: "user", content: contentFromTurn(turn) });
447
- return messages;
442
+ /**
443
+ * The turn's messages, and nothing else.
444
+ *
445
+ * No `role: "system"` message is synthesized from the profile. `prompt.systemPrompt` means DELETE
446
+ * the harness's own prompt; lowering it here would have added it on top of that prompt instead —
447
+ * the opposite intent, invisible to the caller. Both prompt intents ride `agent_profile` on the
448
+ * same request (see {@link toChatCompletionsBody}), where the bridge binds each to the control its
449
+ * harness actually owns or refuses it. The bridge additionally rejects any request that carries
450
+ * system-role messages beside `agent_profile`, so synthesizing one here failed the request outright.
451
+ */
452
+ function messagesFromTurn(turn) {
453
+ return [{ role: "user", content: contentFromTurn(turn) }];
448
454
  }
449
455
  function contentFromTurn(turn) {
450
456
  if (turn.parts)
@@ -615,11 +621,16 @@ function number(value) {
615
621
  function trimSlash(value) {
616
622
  return value.replace(/\/+$/, "");
617
623
  }
618
- export function defaultCliBridgeCapabilities() {
624
+ /**
625
+ * @param harness The bridge backend these capabilities describe. The prompt intents belong to that
626
+ * harness, not to this adapter — the adapter only forwards `agent_profile`. Omit it and both intents
627
+ * declare `false`: an adapter that cannot name its harness cannot promise either one.
628
+ */
629
+ export function defaultCliBridgeCapabilities(harness) {
619
630
  return {
620
631
  profile: {
621
632
  namedProfiles: false,
622
- systemPrompt: true,
633
+ systemPrompt: harnessSystemPromptIntents(harness),
623
634
  instructions: true,
624
635
  tools: true,
625
636
  permissions: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-cli-bridge",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "AgentEnvironmentProvider adapter for cli-bridge /v1/chat/completions",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "LICENSE"
30
30
  ],
31
31
  "dependencies": {
32
- "@tangle-network/agent-interface": "0.43.0",
32
+ "@tangle-network/agent-interface": "0.44.0",
33
33
  "undici": "7.28.0"
34
34
  },
35
35
  "devDependencies": {