evolcore 0.0.5 → 0.0.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/CHANGELOG.md +43 -0
- package/README.md +4 -12
- package/dist/agents/baseagent.js +39 -0
- package/dist/agents/claude-runner.js +10 -2
- package/dist/agents/codex-runner.js +37 -8
- package/dist/agents/ecagent-runner.js +1159 -0
- package/dist/agents/gemini-runner.js +4 -1
- package/dist/agents/runner-types.js +20 -4
- package/dist/aun/msg/history.js +32 -9
- package/dist/aun/outbox.js +4 -9
- package/dist/channels/aun.js +32 -6
- package/dist/channels/daemon.js +7 -4
- package/dist/channels/dingtalk.js +3 -5
- package/dist/channels/feishu.js +16 -108
- package/dist/channels/wechat.js +4 -4
- package/dist/channels/wecom.js +4 -6
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent.js +42 -11
- package/dist/cli/aun-commands.js +50 -3
- package/dist/cli/daemon-commands.js +81 -6
- package/dist/cli/data-command.js +132 -0
- package/dist/cli/index.js +11 -3
- package/dist/cli/init.js +76 -17
- package/dist/cli/net-check.js +9 -20
- package/dist/cli/restart-monitor.js +11 -2
- package/dist/cli/trigger-command.js +1 -1
- package/dist/cli/watch-msg.js +12 -25
- package/dist/config/builtin-roles.js +3 -1
- package/dist/config/config-field-policy.js +1 -1
- package/dist/config/gateway-config.js +21 -4
- package/dist/config/resolved-config-op.js +10 -0
- package/dist/core/command/command-handler.js +2 -2
- package/dist/core/command/menu-handler.js +11 -9
- package/dist/core/command/role-menu.js +11 -0
- package/dist/core/command/slash-handler.js +18 -14
- package/dist/core/data-migration.js +1434 -0
- package/dist/core/handoff/store.js +14 -4
- package/dist/core/inference/text-inference.js +42 -1
- package/dist/core/message/pending-hints.js +1 -1
- package/dist/core/message/response-engine.js +406 -167
- package/dist/core/message/retry-scheduler.js +71 -0
- package/dist/core/model/model-catalog.js +7 -2
- package/dist/core/model/model-fallback.js +81 -0
- package/dist/core/protected-paths.js +41 -8
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +112 -0
- package/dist/core/session/session-fs-store.js +283 -59
- package/dist/core/session/session-manager.js +19 -21
- package/dist/core/session/session-title.js +1 -0
- package/dist/core/session/session-turn-coordinator.js +8 -1
- package/dist/core/system-channels.js +1 -0
- package/dist/index.js +10 -9
- package/dist/paths.js +35 -27
- package/dist/trigger/feedback.js +16 -0
- package/dist/trigger/legacy-session-history.js +19 -0
- package/dist/trigger/manager.js +12 -1
- package/dist/trigger/parser.js +4 -2
- package/dist/trigger/scheduler.js +185 -15
- package/dist/trigger/session-lock.js +62 -0
- package/dist/trigger/state.js +64 -0
- package/dist/trigger/validation.js +32 -2
- package/dist/utils/aid-bind.js +1 -1
- package/dist/utils/error-utils.js +9 -0
- package/dist/utils/welcome.js +2 -3
- package/ecagent/LICENSE +21 -0
- package/ecagent/NOTICE +11 -0
- package/ecagent/README.md +61 -0
- package/ecagent/dist/agent-loop.d.ts +24 -0
- package/ecagent/dist/agent-loop.d.ts.map +1 -0
- package/ecagent/dist/agent-loop.js +547 -0
- package/ecagent/dist/agent-loop.js.map +1 -0
- package/ecagent/dist/agent.d.ts +127 -0
- package/ecagent/dist/agent.d.ts.map +1 -0
- package/ecagent/dist/agent.js +386 -0
- package/ecagent/dist/agent.js.map +1 -0
- package/ecagent/dist/harness/agent-harness.d.ts +95 -0
- package/ecagent/dist/harness/agent-harness.d.ts.map +1 -0
- package/ecagent/dist/harness/agent-harness.js +926 -0
- package/ecagent/dist/harness/agent-harness.js.map +1 -0
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts +51 -0
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/ecagent/dist/harness/compaction/branch-summarization.js +174 -0
- package/ecagent/dist/harness/compaction/branch-summarization.js.map +1 -0
- package/ecagent/dist/harness/compaction/compaction.d.ts +95 -0
- package/ecagent/dist/harness/compaction/compaction.d.ts.map +1 -0
- package/ecagent/dist/harness/compaction/compaction.js +528 -0
- package/ecagent/dist/harness/compaction/compaction.js.map +1 -0
- package/ecagent/dist/harness/compaction/utils.d.ts +25 -0
- package/ecagent/dist/harness/compaction/utils.d.ts.map +1 -0
- package/ecagent/dist/harness/compaction/utils.js +131 -0
- package/ecagent/dist/harness/compaction/utils.js.map +1 -0
- package/ecagent/dist/harness/env/nodejs.d.ts +51 -0
- package/ecagent/dist/harness/env/nodejs.d.ts.map +1 -0
- package/ecagent/dist/harness/env/nodejs.js +513 -0
- package/ecagent/dist/harness/env/nodejs.js.map +1 -0
- package/ecagent/dist/harness/messages.d.ts +51 -0
- package/ecagent/dist/harness/messages.d.ts.map +1 -0
- package/ecagent/dist/harness/messages.js +102 -0
- package/ecagent/dist/harness/messages.js.map +1 -0
- package/ecagent/dist/harness/prompt-templates.d.ts +48 -0
- package/ecagent/dist/harness/prompt-templates.d.ts.map +1 -0
- package/ecagent/dist/harness/prompt-templates.js +230 -0
- package/ecagent/dist/harness/prompt-templates.js.map +1 -0
- package/ecagent/dist/harness/session/jsonl-repo.d.ts +26 -0
- package/ecagent/dist/harness/session/jsonl-repo.d.ts.map +1 -0
- package/ecagent/dist/harness/session/jsonl-repo.js +100 -0
- package/ecagent/dist/harness/session/jsonl-repo.js.map +1 -0
- package/ecagent/dist/harness/session/jsonl-storage.d.ts +34 -0
- package/ecagent/dist/harness/session/jsonl-storage.d.ts.map +1 -0
- package/ecagent/dist/harness/session/jsonl-storage.js +234 -0
- package/ecagent/dist/harness/session/jsonl-storage.js.map +1 -0
- package/ecagent/dist/harness/session/memory-repo.d.ts +18 -0
- package/ecagent/dist/harness/session/memory-repo.d.ts.map +1 -0
- package/ecagent/dist/harness/session/memory-repo.js +44 -0
- package/ecagent/dist/harness/session/memory-repo.js.map +1 -0
- package/ecagent/dist/harness/session/memory-storage.d.ts +25 -0
- package/ecagent/dist/harness/session/memory-storage.d.ts.map +1 -0
- package/ecagent/dist/harness/session/memory-storage.js +111 -0
- package/ecagent/dist/harness/session/memory-storage.js.map +1 -0
- package/ecagent/dist/harness/session/repo-utils.d.ts +11 -0
- package/ecagent/dist/harness/session/repo-utils.d.ts.map +1 -0
- package/ecagent/dist/harness/session/repo-utils.js +39 -0
- package/ecagent/dist/harness/session/repo-utils.js.map +1 -0
- package/ecagent/dist/harness/session/session.d.ts +47 -0
- package/ecagent/dist/harness/session/session.d.ts.map +1 -0
- package/ecagent/dist/harness/session/session.js +245 -0
- package/ecagent/dist/harness/session/session.js.map +1 -0
- package/ecagent/dist/harness/session/uuid.d.ts +2 -0
- package/ecagent/dist/harness/session/uuid.d.ts.map +1 -0
- package/ecagent/dist/harness/session/uuid.js +50 -0
- package/ecagent/dist/harness/session/uuid.js.map +1 -0
- package/ecagent/dist/harness/skills.d.ts +44 -0
- package/ecagent/dist/harness/skills.d.ts.map +1 -0
- package/ecagent/dist/harness/skills.js +311 -0
- package/ecagent/dist/harness/skills.js.map +1 -0
- package/ecagent/dist/harness/system-prompt.d.ts +3 -0
- package/ecagent/dist/harness/system-prompt.d.ts.map +1 -0
- package/ecagent/dist/harness/system-prompt.js +30 -0
- package/ecagent/dist/harness/system-prompt.js.map +1 -0
- package/ecagent/dist/harness/types.d.ts +619 -0
- package/ecagent/dist/harness/types.d.ts.map +1 -0
- package/ecagent/dist/harness/types.js +81 -0
- package/ecagent/dist/harness/types.js.map +1 -0
- package/ecagent/dist/harness/utils/shell-output.d.ts +14 -0
- package/ecagent/dist/harness/utils/shell-output.d.ts.map +1 -0
- package/ecagent/dist/harness/utils/shell-output.js +126 -0
- package/ecagent/dist/harness/utils/shell-output.js.map +1 -0
- package/ecagent/dist/harness/utils/truncate.d.ts +70 -0
- package/ecagent/dist/harness/utils/truncate.d.ts.map +1 -0
- package/ecagent/dist/harness/utils/truncate.js +290 -0
- package/ecagent/dist/harness/utils/truncate.js.map +1 -0
- package/ecagent/dist/index.d.ts +22 -0
- package/ecagent/dist/index.d.ts.map +1 -0
- package/ecagent/dist/index.js +27 -0
- package/ecagent/dist/index.js.map +1 -0
- package/ecagent/dist/node.d.ts +3 -0
- package/ecagent/dist/node.d.ts.map +1 -0
- package/ecagent/dist/node.js +3 -0
- package/ecagent/dist/node.js.map +1 -0
- package/ecagent/dist/proxy.d.ts +69 -0
- package/ecagent/dist/proxy.d.ts.map +1 -0
- package/ecagent/dist/proxy.js +278 -0
- package/ecagent/dist/proxy.js.map +1 -0
- package/ecagent/dist/runtime/api/lazy.d.ts +15 -0
- package/ecagent/dist/runtime/api/lazy.d.ts.map +1 -0
- package/ecagent/dist/runtime/api/lazy.js +59 -0
- package/ecagent/dist/runtime/api/lazy.js.map +1 -0
- package/ecagent/dist/runtime/api/pi-messages.d.ts +97 -0
- package/ecagent/dist/runtime/api/pi-messages.d.ts.map +1 -0
- package/ecagent/dist/runtime/api/pi-messages.js +307 -0
- package/ecagent/dist/runtime/api/pi-messages.js.map +1 -0
- package/ecagent/dist/runtime/api/pi-messages.lazy.d.ts +3 -0
- package/ecagent/dist/runtime/api/pi-messages.lazy.d.ts.map +1 -0
- package/ecagent/dist/runtime/api/pi-messages.lazy.js +3 -0
- package/ecagent/dist/runtime/api/pi-messages.lazy.js.map +1 -0
- package/ecagent/dist/runtime/auth/context.d.ts +7 -0
- package/ecagent/dist/runtime/auth/context.d.ts.map +1 -0
- package/ecagent/dist/runtime/auth/context.js +42 -0
- package/ecagent/dist/runtime/auth/context.js.map +1 -0
- package/ecagent/dist/runtime/auth/credential-store.d.ts +16 -0
- package/ecagent/dist/runtime/auth/credential-store.d.ts.map +1 -0
- package/ecagent/dist/runtime/auth/credential-store.js +39 -0
- package/ecagent/dist/runtime/auth/credential-store.js.map +1 -0
- package/ecagent/dist/runtime/auth/helpers.d.ts +20 -0
- package/ecagent/dist/runtime/auth/helpers.d.ts.map +1 -0
- package/ecagent/dist/runtime/auth/helpers.js +46 -0
- package/ecagent/dist/runtime/auth/helpers.js.map +1 -0
- package/ecagent/dist/runtime/auth/resolve.d.ts +26 -0
- package/ecagent/dist/runtime/auth/resolve.d.ts.map +1 -0
- package/ecagent/dist/runtime/auth/resolve.js +100 -0
- package/ecagent/dist/runtime/auth/resolve.js.map +1 -0
- package/ecagent/dist/runtime/auth/types.d.ts +180 -0
- package/ecagent/dist/runtime/auth/types.d.ts.map +1 -0
- package/ecagent/dist/runtime/auth/types.js +2 -0
- package/ecagent/dist/runtime/auth/types.js.map +1 -0
- package/ecagent/dist/runtime/compat.d.ts +28 -0
- package/ecagent/dist/runtime/compat.d.ts.map +1 -0
- package/ecagent/dist/runtime/compat.js +86 -0
- package/ecagent/dist/runtime/compat.js.map +1 -0
- package/ecagent/dist/runtime/index.d.ts +20 -0
- package/ecagent/dist/runtime/index.d.ts.map +1 -0
- package/ecagent/dist/runtime/index.js +17 -0
- package/ecagent/dist/runtime/index.js.map +1 -0
- package/ecagent/dist/runtime/models.d.ts +142 -0
- package/ecagent/dist/runtime/models.d.ts.map +1 -0
- package/ecagent/dist/runtime/models.js +245 -0
- package/ecagent/dist/runtime/models.js.map +1 -0
- package/ecagent/dist/runtime/oauth.d.ts +2 -0
- package/ecagent/dist/runtime/oauth.d.ts.map +1 -0
- package/ecagent/dist/runtime/oauth.js +2 -0
- package/ecagent/dist/runtime/oauth.js.map +1 -0
- package/ecagent/dist/runtime/providers/faux.d.ts +97 -0
- package/ecagent/dist/runtime/providers/faux.d.ts.map +1 -0
- package/ecagent/dist/runtime/providers/faux.js +395 -0
- package/ecagent/dist/runtime/providers/faux.js.map +1 -0
- package/ecagent/dist/runtime/types.d.ts +607 -0
- package/ecagent/dist/runtime/types.d.ts.map +1 -0
- package/ecagent/dist/runtime/types.js +2 -0
- package/ecagent/dist/runtime/types.js.map +1 -0
- package/ecagent/dist/runtime/utils/diagnostics.d.ts +19 -0
- package/ecagent/dist/runtime/utils/diagnostics.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/diagnostics.js +25 -0
- package/ecagent/dist/runtime/utils/diagnostics.js.map +1 -0
- package/ecagent/dist/runtime/utils/event-stream.d.ts +21 -0
- package/ecagent/dist/runtime/utils/event-stream.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/event-stream.js +77 -0
- package/ecagent/dist/runtime/utils/event-stream.js.map +1 -0
- package/ecagent/dist/runtime/utils/headers.d.ts +4 -0
- package/ecagent/dist/runtime/utils/headers.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/headers.js +18 -0
- package/ecagent/dist/runtime/utils/headers.js.map +1 -0
- package/ecagent/dist/runtime/utils/json-parse.d.ts +16 -0
- package/ecagent/dist/runtime/utils/json-parse.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/json-parse.js +113 -0
- package/ecagent/dist/runtime/utils/json-parse.js.map +1 -0
- package/ecagent/dist/runtime/utils/oauth/types.d.ts +64 -0
- package/ecagent/dist/runtime/utils/oauth/types.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/oauth/types.js +2 -0
- package/ecagent/dist/runtime/utils/oauth/types.js.map +1 -0
- package/ecagent/dist/runtime/utils/overflow.d.ts +58 -0
- package/ecagent/dist/runtime/utils/overflow.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/overflow.js +158 -0
- package/ecagent/dist/runtime/utils/overflow.js.map +1 -0
- package/ecagent/dist/runtime/utils/provider-env.d.ts +7 -0
- package/ecagent/dist/runtime/utils/provider-env.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/provider-env.js +44 -0
- package/ecagent/dist/runtime/utils/provider-env.js.map +1 -0
- package/ecagent/dist/runtime/utils/retry.d.ts +12 -0
- package/ecagent/dist/runtime/utils/retry.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/retry.js +90 -0
- package/ecagent/dist/runtime/utils/retry.js.map +1 -0
- package/ecagent/dist/runtime/utils/typebox-helpers.d.ts +17 -0
- package/ecagent/dist/runtime/utils/typebox-helpers.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/typebox-helpers.js +21 -0
- package/ecagent/dist/runtime/utils/typebox-helpers.js.map +1 -0
- package/ecagent/dist/runtime/utils/validation.d.ts +18 -0
- package/ecagent/dist/runtime/utils/validation.d.ts.map +1 -0
- package/ecagent/dist/runtime/utils/validation.js +269 -0
- package/ecagent/dist/runtime/utils/validation.js.map +1 -0
- package/ecagent/dist/types.d.ts +401 -0
- package/ecagent/dist/types.d.ts.map +1 -0
- package/ecagent/dist/types.js +2 -0
- package/ecagent/dist/types.js.map +1 -0
- package/ecagent/package.json +93 -0
- package/ecagent/src/agent-loop.ts +792 -0
- package/ecagent/src/agent.ts +575 -0
- package/ecagent/src/harness/agent-harness.ts +1029 -0
- package/ecagent/src/harness/compaction/branch-summarization.ts +261 -0
- package/ecagent/src/harness/compaction/compaction.ts +753 -0
- package/ecagent/src/harness/compaction/utils.ts +144 -0
- package/ecagent/src/harness/env/nodejs.ts +569 -0
- package/ecagent/src/harness/messages.ts +164 -0
- package/ecagent/src/harness/prompt-templates.ts +267 -0
- package/ecagent/src/harness/session/jsonl-repo.ts +179 -0
- package/ecagent/src/harness/session/jsonl-storage.ts +314 -0
- package/ecagent/src/harness/session/memory-repo.ts +50 -0
- package/ecagent/src/harness/session/memory-storage.ts +133 -0
- package/ecagent/src/harness/session/repo-utils.ts +51 -0
- package/ecagent/src/harness/session/session.ts +338 -0
- package/ecagent/src/harness/session/uuid.ts +54 -0
- package/ecagent/src/harness/skills.ts +375 -0
- package/ecagent/src/harness/system-prompt.ts +34 -0
- package/ecagent/src/harness/types.ts +838 -0
- package/ecagent/src/harness/utils/shell-output.ts +135 -0
- package/ecagent/src/harness/utils/truncate.ts +344 -0
- package/ecagent/src/index.ts +46 -0
- package/ecagent/src/node.ts +2 -0
- package/ecagent/src/proxy.ts +367 -0
- package/ecagent/src/runtime/api/lazy.ts +70 -0
- package/ecagent/src/runtime/api/pi-messages.lazy.ts +4 -0
- package/ecagent/src/runtime/api/pi-messages.ts +436 -0
- package/ecagent/src/runtime/auth/context.ts +45 -0
- package/ecagent/src/runtime/auth/credential-store.ts +47 -0
- package/ecagent/src/runtime/auth/helpers.ts +46 -0
- package/ecagent/src/runtime/auth/resolve.ts +141 -0
- package/ecagent/src/runtime/auth/types.ts +182 -0
- package/ecagent/src/runtime/compat.ts +158 -0
- package/ecagent/src/runtime/index.ts +31 -0
- package/ecagent/src/runtime/models.ts +452 -0
- package/ecagent/src/runtime/oauth.ts +1 -0
- package/ecagent/src/runtime/providers/faux.ts +538 -0
- package/ecagent/src/runtime/types.ts +718 -0
- package/ecagent/src/runtime/utils/diagnostics.ts +45 -0
- package/ecagent/src/runtime/utils/event-stream.ts +88 -0
- package/ecagent/src/runtime/utils/headers.ts +18 -0
- package/ecagent/src/runtime/utils/json-parse.ts +124 -0
- package/ecagent/src/runtime/utils/oauth/types.ts +79 -0
- package/ecagent/src/runtime/utils/overflow.ts +165 -0
- package/ecagent/src/runtime/utils/provider-env.ts +52 -0
- package/ecagent/src/runtime/utils/retry.ts +101 -0
- package/ecagent/src/runtime/utils/typebox-helpers.ts +24 -0
- package/ecagent/src/runtime/utils/validation.ts +310 -0
- package/ecagent/src/types.ts +430 -0
- package/ecagent/tsconfig.build.json +32 -0
- package/kits/schemas/_meta.json +7 -4
- package/kits/schemas/agent-config.schema.10.json +370 -0
- package/kits/schemas/defaults.schema.4.json +93 -0
- package/kits/schemas/relation-config.schema.8.json +69 -0
- package/kits/templates/roles/admin.json +1 -1
- package/package.json +22 -6
- package/skills/eclink/SKILL.md +70 -0
- package/skills/eclink/agents/openai.yaml +4 -0
- package/assets/.env.template +0 -4
package/dist/trigger/state.js
CHANGED
|
@@ -48,6 +48,70 @@ export class TriggerRunStateStore {
|
|
|
48
48
|
this.write(triggerId, active);
|
|
49
49
|
return run;
|
|
50
50
|
}
|
|
51
|
+
startExecutionAttempt(triggerId, runId, input) {
|
|
52
|
+
const active = this.read(triggerId);
|
|
53
|
+
const run = active.runs[runId];
|
|
54
|
+
if (!run)
|
|
55
|
+
return undefined;
|
|
56
|
+
const attempts = run.attempts ?? (run.attempts = []);
|
|
57
|
+
const existing = attempts.find(attempt => attempt.attemptId === input.attemptId);
|
|
58
|
+
if (existing) {
|
|
59
|
+
if (input.executionSessionId)
|
|
60
|
+
existing.executionSessionId = input.executionSessionId;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
attempts.push({
|
|
64
|
+
attempt: input.attempt,
|
|
65
|
+
attemptId: input.attemptId,
|
|
66
|
+
startedAt: input.startedAt,
|
|
67
|
+
status: 'running',
|
|
68
|
+
...(input.executionSessionId ? { executionSessionId: input.executionSessionId } : {}),
|
|
69
|
+
});
|
|
70
|
+
run.events.push({
|
|
71
|
+
seq: run.events.length,
|
|
72
|
+
event: 'execution.attempt.started',
|
|
73
|
+
ts: input.startedAt,
|
|
74
|
+
attempt: input.attempt,
|
|
75
|
+
attemptId: input.attemptId,
|
|
76
|
+
...(input.executionSessionId ? { executionSessionId: input.executionSessionId } : {}),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
run.attempt = input.attempt;
|
|
80
|
+
run.attemptId = input.attemptId;
|
|
81
|
+
if (input.executionSessionId)
|
|
82
|
+
run.executionSessionId = input.executionSessionId;
|
|
83
|
+
if (input.executionDeadlineAt !== undefined)
|
|
84
|
+
run.executionDeadlineAt = input.executionDeadlineAt;
|
|
85
|
+
this.write(triggerId, active);
|
|
86
|
+
return run;
|
|
87
|
+
}
|
|
88
|
+
completeExecutionAttempt(triggerId, runId, attemptId, result) {
|
|
89
|
+
const active = this.read(triggerId);
|
|
90
|
+
const run = active.runs[runId];
|
|
91
|
+
if (!run)
|
|
92
|
+
return undefined;
|
|
93
|
+
const attempt = run.attempts?.find(item => item.attemptId === attemptId);
|
|
94
|
+
if (!attempt || attempt.status !== 'running')
|
|
95
|
+
return run;
|
|
96
|
+
const finishedAt = result.finishedAt ?? Date.now();
|
|
97
|
+
attempt.status = result.status;
|
|
98
|
+
attempt.finishedAt = finishedAt;
|
|
99
|
+
if (result.error)
|
|
100
|
+
attempt.error = result.error;
|
|
101
|
+
run.events.push({
|
|
102
|
+
seq: run.events.length,
|
|
103
|
+
event: result.status === 'completed' || result.status === 'noop'
|
|
104
|
+
? 'execution.attempt.completed'
|
|
105
|
+
: 'execution.attempt.failed',
|
|
106
|
+
ts: finishedAt,
|
|
107
|
+
attempt: attempt.attempt,
|
|
108
|
+
attemptId,
|
|
109
|
+
status: result.status,
|
|
110
|
+
...(result.error ? { error: result.error } : {}),
|
|
111
|
+
});
|
|
112
|
+
this.write(triggerId, active);
|
|
113
|
+
return run;
|
|
114
|
+
}
|
|
51
115
|
remove(triggerId, runId) {
|
|
52
116
|
const active = this.read(triggerId);
|
|
53
117
|
delete active.runs[runId];
|
|
@@ -29,6 +29,35 @@ export function normalizeTriggerDefinition(input, opts = {}) {
|
|
|
29
29
|
export function validateTriggerDefinition(definition) {
|
|
30
30
|
normalizeTriggerDefinition(definition);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Keep legacy `per_run` definitions byte-stable while giving runtime code one
|
|
34
|
+
* canonical representation for session selection and validation.
|
|
35
|
+
*/
|
|
36
|
+
export function normalizeExecutionMode(execution) {
|
|
37
|
+
if (execution.type !== 'trigger_session')
|
|
38
|
+
return { type: execution.type };
|
|
39
|
+
return {
|
|
40
|
+
type: execution.type,
|
|
41
|
+
thread: execution.thread === 'per_run' || execution.thread === 'by_run'
|
|
42
|
+
? 'by_run'
|
|
43
|
+
: 'by_trigger',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Validate the run-concurrency policy against the session ownership model. */
|
|
47
|
+
export function validateConcurrencyCombination(execution, reliability) {
|
|
48
|
+
// Scripts do not share a model session, so all run-level policies remain valid.
|
|
49
|
+
if (execution.type === 'script')
|
|
50
|
+
return;
|
|
51
|
+
if (reliability.concurrency === 'allow') {
|
|
52
|
+
const mode = normalizeExecutionMode(execution);
|
|
53
|
+
if (mode.type === 'target_session') {
|
|
54
|
+
throw new Error('invalid Trigger concurrency: execution.type=target_session, concurrency=allow; allowed values are forbid or replace');
|
|
55
|
+
}
|
|
56
|
+
if (mode.thread === 'by_trigger') {
|
|
57
|
+
throw new Error('invalid Trigger concurrency: execution.type=trigger_session, thread=by_trigger, concurrency=allow; allowed values are forbid or replace');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
32
61
|
export function definitionRevision(definition) {
|
|
33
62
|
const stable = stableStringify(definition);
|
|
34
63
|
return `sha256:${sha256(stable)}`;
|
|
@@ -381,8 +410,8 @@ function normalizeExecutionThread(value) {
|
|
|
381
410
|
const thread = optionalString(value);
|
|
382
411
|
if (thread === undefined)
|
|
383
412
|
return undefined;
|
|
384
|
-
if (thread !== 'per_run' && thread !== 'by_trigger') {
|
|
385
|
-
throw new Error('execution.thread must be per_run or by_trigger');
|
|
413
|
+
if (thread !== 'per_run' && thread !== 'by_run' && thread !== 'by_trigger') {
|
|
414
|
+
throw new Error('execution.thread must be per_run, by_run, or by_trigger');
|
|
386
415
|
}
|
|
387
416
|
return thread;
|
|
388
417
|
}
|
|
@@ -572,6 +601,7 @@ function validateTriggerSemantics(definition) {
|
|
|
572
601
|
if (execution.type !== 'script' && (definition.feedback.onReply || definition.feedback.onNoop || definition.feedback.onFailure)) {
|
|
573
602
|
throw new Error('feedback.onReply/onNoop/onFailure are only allowed when execution.type=script');
|
|
574
603
|
}
|
|
604
|
+
validateConcurrencyCombination(execution, definition.reliability);
|
|
575
605
|
}
|
|
576
606
|
function generateTriggerId() {
|
|
577
607
|
return `trig_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`;
|
package/dist/utils/aid-bind.js
CHANGED
|
@@ -291,7 +291,7 @@ function resolveBaseagentInfo(config) {
|
|
|
291
291
|
return { active_baseagent, model, effort };
|
|
292
292
|
}
|
|
293
293
|
function pickFirstBaseagent(baseagents) {
|
|
294
|
-
for (const name of ['claude', 'codex', 'gemini']) {
|
|
294
|
+
for (const name of ['claude', 'codex', 'gemini', 'ecagent']) {
|
|
295
295
|
if (baseagents[name] !== undefined)
|
|
296
296
|
return name;
|
|
297
297
|
}
|
|
@@ -54,6 +54,15 @@ const NON_INFRA_TERMINAL_REASONS = new Set([
|
|
|
54
54
|
'aborted_streaming',
|
|
55
55
|
'aborted_tools',
|
|
56
56
|
]);
|
|
57
|
+
/**
|
|
58
|
+
* SDK terminal reasons that mean the current turn was stopped before normal
|
|
59
|
+
* completion. In particular, Claude reports a declined/expired
|
|
60
|
+
* AskUserQuestion as `aborted_tools`; that is a user interaction outcome, not
|
|
61
|
+
* an infrastructure or agent execution failure.
|
|
62
|
+
*/
|
|
63
|
+
export function isAbortTerminalReason(terminalReason) {
|
|
64
|
+
return terminalReason === 'aborted_streaming' || terminalReason === 'aborted_tools';
|
|
65
|
+
}
|
|
57
66
|
export function isInfraError(subtype, terminalReason) {
|
|
58
67
|
// terminalReason 优先级更高(更精确)
|
|
59
68
|
if (terminalReason && NON_INFRA_TERMINAL_REASONS.has(terminalReason)) {
|
package/dist/utils/welcome.js
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
* - 所有 IM 渠道(Feishu/WeChat/DingTalk/QQBot/WeCom):首次交互时发送给交互用户(被动响应)
|
|
9
9
|
*/
|
|
10
10
|
import fs from 'fs';
|
|
11
|
-
import
|
|
12
|
-
import { resolvePaths } from '../paths.js';
|
|
11
|
+
import { channelStatePath } from '../paths.js';
|
|
13
12
|
import { loadAgent, saveAgent } from '../config-store.js';
|
|
14
13
|
import { withLifecycleForWrite } from '../config/lifecycle.js';
|
|
15
14
|
import { logger } from './logger.js';
|
|
@@ -157,7 +156,7 @@ export class FirstInteractionWelcomeManager {
|
|
|
157
156
|
this.agentAid = agentAid;
|
|
158
157
|
this.channelName = channelName;
|
|
159
158
|
// 每个 channel instance 独立的已欢迎用户记录
|
|
160
|
-
this.greetedUsersFile =
|
|
159
|
+
this.greetedUsersFile = channelStatePath(channelName, 'welcome.jsonl');
|
|
161
160
|
this.loadGreetedUsers();
|
|
162
161
|
}
|
|
163
162
|
/**
|
package/ecagent/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mario Zechner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/ecagent/NOTICE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
This distribution contains modified packaging of @earendil-works/pi-agent-core.
|
|
2
|
+
|
|
3
|
+
Upstream project: https://github.com/earendil-works/pi
|
|
4
|
+
Upstream version: 0.80.7
|
|
5
|
+
Upstream commit: 818d67457cdd6b60bce6b121d16b23141c252dd8
|
|
6
|
+
|
|
7
|
+
Modification: TypeScript sources from @earendil-works/pi-agent-core and the
|
|
8
|
+
provider-free protocol subset of @earendil-works/pi-ai are maintained together
|
|
9
|
+
in this package. Provider SDK implementations and dependencies are excluded.
|
|
10
|
+
Callers supply a custom model stream function or use the included pi-messages
|
|
11
|
+
protocol runtime.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# ecagent
|
|
2
|
+
|
|
3
|
+
`ecagent` is an unofficial lightweight distribution of
|
|
4
|
+
[`@earendil-works/pi-agent-core`](https://github.com/earendil-works/pi). It
|
|
5
|
+
includes the Pi agent loop, tools, sessions, compaction, skills, and execution
|
|
6
|
+
environment abstractions together with an embedded provider-free model runtime.
|
|
7
|
+
The published package includes both the TypeScript source in `src/` and the
|
|
8
|
+
compiled ESM output in `dist/`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install ecagent
|
|
14
|
+
|
|
15
|
+
# Or install it globally for a shared Node.js runtime
|
|
16
|
+
npm install --global ecagent
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Supply a custom model stream function. No model provider SDK is installed by
|
|
20
|
+
default:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { Agent } from "ecagent";
|
|
24
|
+
|
|
25
|
+
const agent = new Agent({
|
|
26
|
+
initialState: {
|
|
27
|
+
model,
|
|
28
|
+
systemPrompt: "You are a coding agent.",
|
|
29
|
+
},
|
|
30
|
+
streamFn: evolcoreModelStream,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The `streamFn` must implement the Pi stream contract exported by
|
|
35
|
+
`ecagent/runtime`:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { AssistantMessageEventStream } from "ecagent/runtime";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
EvolCore uses this boundary to connect its own credentials, gateway, streaming,
|
|
42
|
+
and abort handling.
|
|
43
|
+
|
|
44
|
+
## Build from source
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install
|
|
48
|
+
npm run build
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The build runs TypeScript directly over the checked-in source. It does not
|
|
52
|
+
download precompiled upstream artifacts.
|
|
53
|
+
|
|
54
|
+
## Upstream
|
|
55
|
+
|
|
56
|
+
- Package: `@earendil-works/pi-agent-core@0.80.7`
|
|
57
|
+
- Runtime: `@earendil-works/pi-ai@0.80.7`
|
|
58
|
+
- Commit: `818d67457cdd6b60bce6b121d16b23141c252dd8`
|
|
59
|
+
- License: MIT
|
|
60
|
+
|
|
61
|
+
This package is not affiliated with or endorsed by the Pi maintainers.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent loop that works with AgentMessage throughout.
|
|
3
|
+
* Transforms to Message[] only at the LLM call boundary.
|
|
4
|
+
*/
|
|
5
|
+
import { EventStream } from "ecagent/runtime/compat";
|
|
6
|
+
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, StreamFn } from "./types.ts";
|
|
7
|
+
export type AgentEventSink = (event: AgentEvent) => Promise<void> | void;
|
|
8
|
+
/**
|
|
9
|
+
* Start an agent loop with a new prompt message.
|
|
10
|
+
* The prompt is added to the context and events are emitted for it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function agentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, signal?: AbortSignal, streamFn?: StreamFn): EventStream<AgentEvent, AgentMessage[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Continue an agent loop from the current context without adding a new message.
|
|
15
|
+
* Used for retries - context already has user message or tool results.
|
|
16
|
+
*
|
|
17
|
+
* **Important:** The last message in context must convert to a `user` or `toolResult` message
|
|
18
|
+
* via `convertToLlm`. If it doesn't, the LLM provider will reject the request.
|
|
19
|
+
* This cannot be validated here since `convertToLlm` is only called once per turn.
|
|
20
|
+
*/
|
|
21
|
+
export declare function agentLoopContinue(context: AgentContext, config: AgentLoopConfig, signal?: AbortSignal, streamFn?: StreamFn): EventStream<AgentEvent, AgentMessage[]>;
|
|
22
|
+
export declare function runAgentLoop(prompts: AgentMessage[], context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal?: AbortSignal, streamFn?: StreamFn): Promise<AgentMessage[]>;
|
|
23
|
+
export declare function runAgentLoopContinue(context: AgentContext, config: AgentLoopConfig, emit: AgentEventSink, signal?: AbortSignal, streamFn?: StreamFn): Promise<AgentMessage[]>;
|
|
24
|
+
//# sourceMappingURL=agent-loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-loop.d.ts","sourceRoot":"","sources":["../src/agent-loop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGN,WAAW,EAIX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACX,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,EAIZ,QAAQ,EACR,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEzE;;;GAGG;AACH,wBAAgB,SAAS,CACxB,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,QAAQ,GACjB,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,CAiBzC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,QAAQ,GACjB,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,CAAC,CAwBzC;AAED,wBAAsB,YAAY,CACjC,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,cAAc,EACpB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,QAAQ,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC,CAgBzB;AAED,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,cAAc,EACpB,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,QAAQ,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC,CAiBzB"}
|