@springbrand/agent-runtime 0.3.0-alpha.2 → 0.3.0-alpha.21
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/package.json +11 -9
- package/src/adapter/cloudflare/agent.ts +233 -179
- package/src/adapter/cloudflare/define-agent.ts +252 -104
- package/src/adapter/cloudflare/index.ts +18 -0
- package/src/adapter/cloudflare/scheduling/schedule-rule.ts +322 -0
- package/src/adapter/cloudflare/scheduling/zoned-cron.ts +11 -6
- package/src/adapter/cloudflare/schema.ts +21 -2
- package/src/adapter/cloudflare/subagent/definition.ts +25 -13
- package/src/adapter/cloudflare/subagent/runner.ts +43 -50
- package/src/adapter/cloudflare/subagent/tools.ts +4 -4
- package/src/adapter/cloudflare/universal-agent/preparation.ts +3 -3
- package/src/adapter/cloudflare/universal-agent/tools.ts +4 -6
- package/src/adapter/cloudflare/workspace/version-control.ts +1 -1
- package/src/config/activation.ts +13 -15
- package/src/config/agent-context.ts +1 -1
- package/src/config/assembler.ts +48 -31
- package/src/config/assembly-snapshot.ts +1 -1
- package/src/config/definition.ts +1 -1
- package/src/config/harness-runtime.ts +77 -49
- package/src/config/index.ts +1 -1
- package/src/config/model-guidance.ts +20 -0
- package/src/config/ports.ts +57 -7
- package/src/config/{pinning.ts → prepared-runtime.ts} +59 -123
- package/src/config/public-contracts.ts +2 -2
- package/src/config/runtime-config.ts +2 -1
- package/src/context/assembly.ts +1 -1
- package/src/context/extension/assembly.ts +2 -2
- package/src/context/memory/budget/gate.ts +19 -3
- package/src/conversation/harness-resume.ts +89 -238
- package/src/conversation/harness-stream.ts +87 -71
- package/src/conversation/history.ts +154 -152
- package/src/conversation/message/contract.ts +28 -4
- package/src/conversation/message/conversion.ts +46 -5
- package/src/conversation/message/projection.ts +61 -21
- package/src/conversation/session-entry.ts +29 -0
- package/src/conversation/state.ts +23 -2
- package/src/harness/governance.ts +206 -0
- package/src/harness/index.ts +3 -0
- package/src/harness/session-harness.ts +269 -445
- package/src/harness/submission-operation.ts +15 -40
- package/src/index.ts +18 -8
- package/src/lib/artifacts.ts +18 -0
- package/src/lib/execution-level.ts +13 -0
- package/src/lib/prompt.ts +9 -10
- package/src/lib/token-estimate.ts +8 -0
- package/src/model-protocol/openrouter.ts +41 -0
- package/src/models/index.ts +200 -35
- package/src/models/openrouter/messages.ts +13 -8
- package/src/models/openrouter/openai.ts +200 -0
- package/src/models/openrouter/protocol-response.ts +85 -0
- package/src/models/provider-streams.ts +45 -0
- package/src/session/cloudflare/migration.ts +382 -864
- package/src/session/cloudflare/storage.ts +13 -536
- package/src/session/index.ts +22 -35
- package/src/skills/springbrand-worker-website/index.ts +1 -1
- package/src/submission/admission.ts +20 -30
- package/src/submission/contracts.ts +42 -2
- package/src/submission/delivery.ts +1 -1
- package/src/submission/finalization.ts +36 -15
- package/src/submission/lifecycle.ts +28 -15
- package/src/submission/repository.ts +97 -49
- package/src/submission/steer-delivery.ts +32 -76
- package/src/submission/unattended.ts +40 -0
- package/src/telemetry/contract.ts +0 -1
- package/src/telemetry/coordinator.ts +1 -1
- package/src/telemetry/runtime-telemetry.ts +0 -4
- package/src/telemetry/subagent-lifecycle.ts +1 -1
- package/src/telemetry/turn-events.ts +35 -25
- package/src/tools/README.md +44 -0
- package/src/tools/{ai-adapter.ts → adapters/ai-to-pi.ts} +6 -9
- package/src/tools/{declared.ts → adapters/declared.ts} +6 -2
- package/src/tools/{nested-tools.ts → adapters/pi-to-ai.ts} +4 -4
- package/src/tools/assistant/ask-user.ts +319 -0
- package/src/tools/assistant/candidate.ts +15 -0
- package/src/tools/assistant/followups.ts +34 -0
- package/src/tools/assistant/index.ts +19 -0
- package/src/tools/assistant/memory.ts +73 -0
- package/src/tools/assistant/plan.ts +98 -0
- package/src/tools/{time.ts → assistant/time.ts} +1 -1
- package/src/tools/{core-host.ts → codemode/adapter.ts} +50 -53
- package/src/tools/{core.ts → codemode/index.ts} +36 -92
- package/src/tools/codemode/workspace-connector.ts +198 -0
- package/src/tools/extension/index.ts +42 -0
- package/src/tools/index.ts +29 -26
- package/src/tools/{gateway.ts → mcp/gateway.ts} +19 -19
- package/src/tools/{mcp.ts → mcp/index.ts} +5 -5
- package/src/tools/runtime/activation.ts +40 -0
- package/src/tools/{approval → runtime/approval}/repository.ts +13 -12
- package/src/tools/runtime/compiler.ts +246 -0
- package/src/tools/runtime/contracts.ts +140 -0
- package/src/tools/{decision-gate.ts → runtime/decision-gate.ts} +149 -39
- package/src/tools/{human-decisions.ts → runtime/human-decisions.ts} +4 -4
- package/src/tools/{interaction → runtime/interaction}/repository.ts +1 -7
- package/src/tools/runtime/result.ts +22 -0
- package/src/tools/runtime/unattended-error.ts +4 -0
- package/src/tools/sandbox/index.ts +228 -0
- package/src/tools/schedule/index.ts +301 -0
- package/src/tools/skill/contracts.ts +20 -0
- package/src/tools/skill/index.ts +99 -0
- package/src/tools/skill/resources.ts +322 -0
- package/src/tools/skill/scripts.ts +168 -0
- package/src/tools/{subagent-authority.ts → subagent/authority.ts} +31 -31
- package/src/tools/{subagent.ts → subagent/index.ts} +34 -37
- package/src/tools/{subagent-run-repository.ts → subagent/repository.ts} +1 -1
- package/src/tools/{subagent-runtime.ts → subagent/runtime.ts} +1 -1
- package/src/tools/{temporary-agent → subagent/temporary}/approvals.ts +4 -7
- package/src/tools/{temporary-agent → subagent/temporary}/core.ts +2 -3
- package/src/tools/{temporary-agent → subagent/temporary}/runner.ts +1 -1
- package/src/tools/{temporary-agent → subagent/temporary}/workspace.ts +1 -4
- package/src/tools/{web-fetch.ts → web/fetch.ts} +4 -13
- package/src/tools/web/index.ts +2 -0
- package/src/tools/web/search/api.ts +1322 -0
- package/src/tools/web/search/index.ts +2 -0
- package/src/tools/{web-search/web-search.ts → web/search/search.ts} +5 -7
- package/src/tools/{workspace-sandbox.ts → workspace/index.ts} +12 -272
- package/src/tools/{workspace-revision.ts → workspace/revision.ts} +3 -3
- package/src/tools/base.ts +0 -534
- package/src/tools/compiler.ts +0 -327
- package/src/tools/schedule.ts +0 -261
- package/src/tools/skill.ts +0 -565
- package/src/tools/web-search/api.ts +0 -1318
- package/src/tools/web-search/index.ts +0 -2
- package/src/tools/workspace-state-connector.ts +0 -146
- package/src/tools/{approval → runtime/approval}/index.ts +0 -0
- package/src/tools/{interaction → runtime/interaction}/index.ts +0 -0
- package/src/tools/{temporary-agent → subagent/temporary}/coordinator.ts +0 -0
- package/src/tools/{subagent-types → subagent/types}/contract.ts +0 -0
- package/src/tools/{subagent-types → subagent/types}/extract/index.ts +0 -0
- package/src/tools/{subagent-types → subagent/types}/fanout/index.ts +0 -0
- package/src/tools/{subagent-types → subagent/types}/registry.ts +1 -1
- /package/src/tools/{workspace-versioning.ts → workspace/versioning.ts} +0 -0
|
@@ -5,7 +5,7 @@ export class AgentToolRepository {
|
|
|
5
5
|
// 保存当前 Agent SQLite 的查询入口。
|
|
6
6
|
// RuntimeDatabase 构造时调用,活动投影随后通过这个 Repository 读取子运行。
|
|
7
7
|
// 把存储绑定留在构造阶段,避免每次读取都传入可能属于其他 Agent 的 sql。
|
|
8
|
-
constructor(private readonly sql: SqlTaggedTemplate) {}
|
|
8
|
+
constructor(private readonly sql: SqlTaggedTemplate) { }
|
|
9
9
|
|
|
10
10
|
// 是否仍有 Agent Tool 子运行在执行。
|
|
11
11
|
// 活动投影在重算 activity 时调用,判定只在这里做一次。
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { ApprovalDecision, ApprovalReceipt } from "
|
|
2
|
-
import type { RuntimeTelemetryCoordinator } from "
|
|
3
|
-
import type {
|
|
4
|
-
TemporaryAgentApprovalDecision,
|
|
5
|
-
TemporaryAgentApprovalRequest,
|
|
6
|
-
} from "./core";
|
|
1
|
+
import type { ApprovalDecision, ApprovalReceipt } from "../../../submission/contracts";
|
|
2
|
+
import type { RuntimeTelemetryCoordinator } from "../../../telemetry/coordinator";
|
|
3
|
+
import type { TemporaryAgentApprovalDecision, TemporaryAgentApprovalRequest } from "./core";
|
|
7
4
|
|
|
8
5
|
interface PendingApproval {
|
|
9
6
|
receipt: ApprovalReceipt;
|
|
@@ -19,7 +16,7 @@ export class TemporaryAgentApprovals {
|
|
|
19
16
|
constructor(private readonly options: {
|
|
20
17
|
capture: RuntimeTelemetryCoordinator["capture"];
|
|
21
18
|
onChanged(): Promise<void>;
|
|
22
|
-
}) {}
|
|
19
|
+
}) { }
|
|
23
20
|
|
|
24
21
|
find(executionId: string): ApprovalReceipt | null {
|
|
25
22
|
return this.pending.get(executionId)?.receipt ?? null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExecutionLevel } from "
|
|
1
|
+
import type { ExecutionLevel } from "../../../lib/execution-level";
|
|
2
2
|
|
|
3
3
|
export const TEMPORARY_AGENT_LAUNCH_KEY =
|
|
4
4
|
"universal-agent:temporary-agent-launch";
|
|
@@ -9,10 +9,9 @@ export interface TemporaryAgentRequest {
|
|
|
9
9
|
task: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export interface
|
|
12
|
+
export interface TemporaryAgentLaunchSelection
|
|
13
13
|
extends TemporaryAgentRequest {
|
|
14
14
|
runtimeKey: string;
|
|
15
|
-
config: Config;
|
|
16
15
|
executionLevel: ExecutionLevel;
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -10,14 +10,13 @@
|
|
|
10
10
|
* - 不依赖 Workers AI `toMarkdown()`——base runtime 不持有 AI binding,调用方若需要
|
|
11
11
|
* Markdown 转换,应在宿主层叠加;此处返回原始 UTF-8 解码内容。
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* 本文件未注册到默认 Tool Surface,可单独 import 使用。
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
17
17
|
import { Type } from "@earendil-works/pi-ai";
|
|
18
|
-
import type { PiToolCandidate } from "
|
|
18
|
+
import type { PiToolCandidate } from "../runtime/contracts";
|
|
19
19
|
|
|
20
|
-
// #region 常量
|
|
21
20
|
|
|
22
21
|
/** 服务端强制截断上限(字节)。调用方 maxBytes 在此之上再被夹断。 */
|
|
23
22
|
const HARD_MAX_BYTES = 5 * 1024 * 1024; // 5 MiB
|
|
@@ -28,9 +27,7 @@ const FETCH_TIMEOUT_MS = 30_000;
|
|
|
28
27
|
/** 发出请求时使用的 User-Agent 字符串。 */
|
|
29
28
|
const USER_AGENT = "UniversalAgent/1.0";
|
|
30
29
|
|
|
31
|
-
// #endregion
|
|
32
30
|
|
|
33
|
-
// #region 公开类型
|
|
34
31
|
|
|
35
32
|
export const webFetchParameters = Type.Object({
|
|
36
33
|
url: Type.String({
|
|
@@ -62,9 +59,7 @@ export interface WebFetchDetails {
|
|
|
62
59
|
bodyLength: number;
|
|
63
60
|
}
|
|
64
61
|
|
|
65
|
-
// #endregion
|
|
66
62
|
|
|
67
|
-
// #region 内部工具函数
|
|
68
63
|
|
|
69
64
|
/**
|
|
70
65
|
* 校验 URL 字符串是否符合 webFetch 的安全约束。
|
|
@@ -83,7 +78,7 @@ export function validateWebFetchUrl(input: string): URL {
|
|
|
83
78
|
if (parsed.protocol !== "https:") {
|
|
84
79
|
throw new Error(
|
|
85
80
|
`Only https:// URLs are allowed; got ${parsed.protocol}//. ` +
|
|
86
|
-
|
|
81
|
+
`Use the HTTPS version of this URL.`,
|
|
87
82
|
);
|
|
88
83
|
}
|
|
89
84
|
if (parsed.username || parsed.password) {
|
|
@@ -170,9 +165,7 @@ export function formatWebFetchResult(
|
|
|
170
165
|
].join("\n");
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
// #endregion
|
|
174
168
|
|
|
175
|
-
// #region Pi 工具候选项工厂
|
|
176
169
|
|
|
177
170
|
/**
|
|
178
171
|
* 创建独立的 `web_fetch` Pi 工具候选项。
|
|
@@ -247,7 +240,7 @@ export function webFetchPiToolCandidate(): PiToolCandidate {
|
|
|
247
240
|
try { await response.body?.cancel(); } catch { /* ignore */ }
|
|
248
241
|
throw new Error(
|
|
249
242
|
`The site at ${finalUrl} sets Content-Signal: ai-input=no, ` +
|
|
250
|
-
|
|
243
|
+
`indicating that it does not permit its content to be used as AI input.`,
|
|
251
244
|
);
|
|
252
245
|
}
|
|
253
246
|
|
|
@@ -277,5 +270,3 @@ export function webFetchPiToolCandidate(): PiToolCandidate {
|
|
|
277
270
|
tool,
|
|
278
271
|
};
|
|
279
272
|
}
|
|
280
|
-
|
|
281
|
-
// #endregion
|