@axiom-lattice/core 5.0.0 → 6.0.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.mts +74 -23
- package/dist/index.d.ts +74 -23
- package/dist/index.js +302 -283
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -282
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1894,6 +1894,7 @@ __export(index_exports, {
|
|
|
1894
1894
|
invokeWithRetry: () => invokeWithRetry,
|
|
1895
1895
|
isBuiltInSkill: () => isBuiltInSkill,
|
|
1896
1896
|
isDirectRoom: () => isDirectRoom,
|
|
1897
|
+
isMcpConnectionError: () => isMcpConnectionError,
|
|
1897
1898
|
isPluginSkillAuthorizedInSandbox: () => isPluginSkillAuthorizedInSandbox,
|
|
1898
1899
|
isPluginSkillManagedInSandbox: () => isPluginSkillManagedInSandbox,
|
|
1899
1900
|
isUsingDefaultKey: () => isUsingDefaultKey,
|
|
@@ -1916,7 +1917,6 @@ __export(index_exports, {
|
|
|
1916
1917
|
parallelLimit: () => parallelLimit,
|
|
1917
1918
|
parseCronExpression: () => parseCronExpression,
|
|
1918
1919
|
parseDirectRoomType: () => parseDirectRoomType,
|
|
1919
|
-
parseExternalDependency: () => parseExternalDependency,
|
|
1920
1920
|
parseJudgeVerdict: () => parseJudgeVerdict,
|
|
1921
1921
|
parsePackSize: () => parsePackSize,
|
|
1922
1922
|
parseQueuedExecutionMode: () => import_protocols2.parseQueuedExecutionMode,
|
|
@@ -30804,7 +30804,7 @@ var agentArchitectConfig = {
|
|
|
30804
30804
|
"delete_agent",
|
|
30805
30805
|
"manage_binding"
|
|
30806
30806
|
],
|
|
30807
|
-
subAgents: ["document-parser-benchmark"],
|
|
30807
|
+
subAgents: ["document-parser", "document-parser-benchmark"],
|
|
30808
30808
|
middleware: [
|
|
30809
30809
|
{
|
|
30810
30810
|
id: "filesystem",
|
|
@@ -32513,6 +32513,7 @@ async function removeCollectionVectorStore(name, tenantId2) {
|
|
|
32513
32513
|
|
|
32514
32514
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
32515
32515
|
var import_mcp_adapters = require("@langchain/mcp-adapters");
|
|
32516
|
+
var import_tools3 = require("@langchain/core/tools");
|
|
32516
32517
|
init_BaseLatticeManager();
|
|
32517
32518
|
|
|
32518
32519
|
// src/mcp_lattice/reconnectPolicy.ts
|
|
@@ -32522,6 +32523,13 @@ var DEFAULT_DELAY_MS = 1e3;
|
|
|
32522
32523
|
var MAX_BACKOFF_MS = 3e4;
|
|
32523
32524
|
var HEALTH_CHECK_INTERVAL_MS = 3e4;
|
|
32524
32525
|
var HEALTH_CHECK_TIMEOUT_MS = 5e3;
|
|
32526
|
+
function isMcpConnectionError(error) {
|
|
32527
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
32528
|
+
if (!message) return false;
|
|
32529
|
+
return /not connected|connection closed|session not found|no session|maximum reconnection/i.test(
|
|
32530
|
+
message
|
|
32531
|
+
);
|
|
32532
|
+
}
|
|
32525
32533
|
function nextBackoffDelay(attempt, base = DEFAULT_DELAY_MS, max = MAX_BACKOFF_MS) {
|
|
32526
32534
|
if (attempt <= 0) return base;
|
|
32527
32535
|
return Math.min(base * Math.pow(2, attempt - 1), max);
|
|
@@ -32546,12 +32554,21 @@ async function withTimeout2(operation, ms, onTimeout) {
|
|
|
32546
32554
|
|
|
32547
32555
|
// src/mcp_lattice/McpLatticeManager.ts
|
|
32548
32556
|
var realClientFactory = ({ mcpServers }) => new import_mcp_adapters.MultiServerMCPClient({ mcpServers });
|
|
32557
|
+
function extractRawCall(tool68) {
|
|
32558
|
+
const rawCall = tool68._call;
|
|
32559
|
+
if (typeof rawCall === "function") return rawCall.bind(tool68);
|
|
32560
|
+
return async (...args) => {
|
|
32561
|
+
const invoke = tool68.invoke.bind(tool68);
|
|
32562
|
+
return invoke(args[0], args[2]);
|
|
32563
|
+
};
|
|
32564
|
+
}
|
|
32549
32565
|
var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
32550
32566
|
constructor() {
|
|
32551
32567
|
super(...arguments);
|
|
32552
32568
|
this.runtimes = /* @__PURE__ */ new Map();
|
|
32553
32569
|
this.clientFactory = realClientFactory;
|
|
32554
32570
|
this.healthCheckInFlight = false;
|
|
32571
|
+
this.reconnectPromises = /* @__PURE__ */ new Map();
|
|
32555
32572
|
}
|
|
32556
32573
|
static getInstance() {
|
|
32557
32574
|
if (!_McpLatticeManager._instance) {
|
|
@@ -32809,6 +32826,64 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
32809
32826
|
rt.attempt = 0;
|
|
32810
32827
|
await this.reconnectRuntime(rt);
|
|
32811
32828
|
}
|
|
32829
|
+
/**
|
|
32830
|
+
* Single-flight a forced reconnect per `(tenantId, serverKey)` so concurrent
|
|
32831
|
+
* tool calls that all hit the same dead session reconnect once, not once each.
|
|
32832
|
+
*/
|
|
32833
|
+
reconnectShared(rt) {
|
|
32834
|
+
const key5 = this.compositeKey(rt.id.tenantId, rt.id.serverKey);
|
|
32835
|
+
const existing = this.reconnectPromises.get(key5);
|
|
32836
|
+
if (existing) return existing;
|
|
32837
|
+
const work = this.reconnectServer(rt.id.tenantId, rt.id.serverKey).finally(() => {
|
|
32838
|
+
if (this.reconnectPromises.get(key5) === work) this.reconnectPromises.delete(key5);
|
|
32839
|
+
});
|
|
32840
|
+
this.reconnectPromises.set(key5, work);
|
|
32841
|
+
return work;
|
|
32842
|
+
}
|
|
32843
|
+
/**
|
|
32844
|
+
* Wrap a raw MCP tool so a call landing on a torn-down session
|
|
32845
|
+
* (`Not connected` / `Connection closed` / session expiry) transparently
|
|
32846
|
+
* forces a reconnect and retries once against the fresh client, instead of
|
|
32847
|
+
* failing the surrounding run. Non-connection errors propagate untouched.
|
|
32848
|
+
*/
|
|
32849
|
+
wrapToolForResilience(rt, raw) {
|
|
32850
|
+
const call = extractRawCall(raw);
|
|
32851
|
+
return new import_tools3.DynamicStructuredTool({
|
|
32852
|
+
name: raw.name,
|
|
32853
|
+
description: raw.description,
|
|
32854
|
+
schema: raw.schema,
|
|
32855
|
+
responseFormat: raw.responseFormat,
|
|
32856
|
+
defaultConfig: raw.defaultConfig,
|
|
32857
|
+
metadata: raw.metadata,
|
|
32858
|
+
returnDirect: raw.returnDirect,
|
|
32859
|
+
func: async (...args) => this.invokeResilient(rt, raw.name, call, args)
|
|
32860
|
+
});
|
|
32861
|
+
}
|
|
32862
|
+
async invokeResilient(rt, toolName2, call, args) {
|
|
32863
|
+
try {
|
|
32864
|
+
await this.ensureConnected(rt.id.tenantId, rt.id.serverKey);
|
|
32865
|
+
return await call(...args);
|
|
32866
|
+
} catch (error) {
|
|
32867
|
+
if (!isMcpConnectionError(error) || !this.isActive(rt)) throw error;
|
|
32868
|
+
console.warn(
|
|
32869
|
+
`[MCP] ${rt.id.tenantId}/${rt.id.serverKey}: tool "${toolName2}" hit a dead session; reconnecting and retrying once`,
|
|
32870
|
+
error instanceof Error ? error.message : error
|
|
32871
|
+
);
|
|
32872
|
+
try {
|
|
32873
|
+
await this.reconnectShared(rt);
|
|
32874
|
+
} catch (reconnectError) {
|
|
32875
|
+
console.warn(
|
|
32876
|
+
`[MCP] ${rt.id.tenantId}/${rt.id.serverKey}: reconnect for tool "${toolName2}" failed`,
|
|
32877
|
+
reconnectError instanceof Error ? reconnectError.message : reconnectError
|
|
32878
|
+
);
|
|
32879
|
+
throw error;
|
|
32880
|
+
}
|
|
32881
|
+
const fresh = await this.getRawTools(rt.id.tenantId, rt.id.serverKey);
|
|
32882
|
+
const match = fresh.find((t) => t.name === toolName2);
|
|
32883
|
+
if (!match) throw error;
|
|
32884
|
+
return await extractRawCall(match)(...args);
|
|
32885
|
+
}
|
|
32886
|
+
}
|
|
32812
32887
|
async checkHealth() {
|
|
32813
32888
|
if (this.healthCheckInFlight) return;
|
|
32814
32889
|
this.healthCheckInFlight = true;
|
|
@@ -32827,8 +32902,12 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
32827
32902
|
await withTimeout2(session.listTools(), HEALTH_CHECK_TIMEOUT_MS, async () => {
|
|
32828
32903
|
});
|
|
32829
32904
|
if (!this.isActive(rt) || rt.state !== "connected") continue;
|
|
32830
|
-
} catch {
|
|
32905
|
+
} catch (error) {
|
|
32831
32906
|
if (this.isActive(rt) && rt.state === "connected") {
|
|
32907
|
+
console.warn(
|
|
32908
|
+
`[MCP] ${rt.id.tenantId}/${rt.id.serverKey}: health check failed; scheduling reconnect`,
|
|
32909
|
+
error instanceof Error ? error.message : error
|
|
32910
|
+
);
|
|
32832
32911
|
rt.state = "failed";
|
|
32833
32912
|
this.scheduleReconnect(rt);
|
|
32834
32913
|
}
|
|
@@ -33034,7 +33113,8 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
33034
33113
|
const visibility = Array.isArray(rawVisibility) ? rawVisibility : typeof rawVisibility === "string" ? [rawVisibility] : void 0;
|
|
33035
33114
|
if (visibility && !visibility.includes("model")) continue;
|
|
33036
33115
|
const ref = extractAppsRef(meta, serverKey);
|
|
33037
|
-
const
|
|
33116
|
+
const resilient = this.wrapToolForResilience(rt, tool68);
|
|
33117
|
+
const registered = ref ? wrapMcpToolWithUi(resilient, ref) : resilient;
|
|
33038
33118
|
const toolKey = _McpLatticeManager.buildToolKey(serverKey, tool68.name);
|
|
33039
33119
|
try {
|
|
33040
33120
|
toolLatticeManager.registerExistingToolWithTenant(tenantId2, toolKey, registered);
|
|
@@ -33103,6 +33183,7 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
33103
33183
|
}
|
|
33104
33184
|
}
|
|
33105
33185
|
this.runtimes.clear();
|
|
33186
|
+
this.reconnectPromises.clear();
|
|
33106
33187
|
}
|
|
33107
33188
|
};
|
|
33108
33189
|
var mcpManager = McpLatticeManager.getInstance();
|
|
@@ -37314,14 +37395,6 @@ async function applyBeliefImpacts(taskStore, owner, impacts) {
|
|
|
37314
37395
|
}
|
|
37315
37396
|
return { description: current.description ?? "", task: current };
|
|
37316
37397
|
}
|
|
37317
|
-
function parseExternalDependency(value) {
|
|
37318
|
-
const row = (0, import_protocols31.snapshotExactRecord)(value, ["type", "summary", "requestedAt", "dependencyTaskIds"]);
|
|
37319
|
-
const ids = (0, import_protocols31.snapshotExactArray)(row?.dependencyTaskIds);
|
|
37320
|
-
if (!row || row.type !== "external_dependency" || typeof row.summary !== "string" || !row.summary.trim() || typeof row.requestedAt !== "string" || !Number.isFinite(Date.parse(row.requestedAt)) || !ids || ids.length === 0 || ids.some((id) => typeof id !== "string" || !id.trim())) return void 0;
|
|
37321
|
-
const trimmed = ids.map((id) => id.trim());
|
|
37322
|
-
if (new Set(trimmed).size !== trimmed.length) return void 0;
|
|
37323
|
-
return { type: "external_dependency", summary: row.summary, requestedAt: row.requestedAt, dependencyTaskIds: trimmed };
|
|
37324
|
-
}
|
|
37325
37398
|
function unsupportedTaskStatus() {
|
|
37326
37399
|
return failure2(
|
|
37327
37400
|
"TASK_STATUS_UNSUPPORTED",
|
|
@@ -37620,9 +37693,6 @@ var TaskLifecycleService = class {
|
|
|
37620
37693
|
if (interruption && typeof interruption === "object" && interruption.type === "review_required") {
|
|
37621
37694
|
return failure2("REVIEW_APPROVAL_REQUIRED", "Review interruption requires explicit approval or rejection.");
|
|
37622
37695
|
}
|
|
37623
|
-
if (interruption && typeof interruption === "object" && interruption.type === "external_dependency" && !parseExternalDependency(interruption)) {
|
|
37624
|
-
return failure2("INVALID_EXTERNAL_DEPENDENCY", "Stored external dependency interruption is malformed.");
|
|
37625
|
-
}
|
|
37626
37696
|
const previousInterruption = interruption && typeof interruption === "object" ? interruption : {};
|
|
37627
37697
|
const resumeKey = this.resumeEventKey(task);
|
|
37628
37698
|
const audit = { eventKey: resumeKey, previousInterruption };
|
|
@@ -37803,6 +37873,108 @@ var TaskLifecycleService = class {
|
|
|
37803
37873
|
detail: { previousStatus: "failed" }
|
|
37804
37874
|
});
|
|
37805
37875
|
}
|
|
37876
|
+
/**
|
|
37877
|
+
* Reopens a terminal agent task by returning it to in_progress.
|
|
37878
|
+
*
|
|
37879
|
+
* @param input Task, actor, and optional thread.
|
|
37880
|
+
* @returns Structured lifecycle result. `completed` and `cancelled` tasks
|
|
37881
|
+
* reopen to `in_progress`; an already-`in_progress` task is acknowledged
|
|
37882
|
+
* without mutation; any other status or a lost CAS yields
|
|
37883
|
+
* `TASK_STATUS_CONFLICT`.
|
|
37884
|
+
* @remarks This is the single reverse edge of the terminal-irreversibility
|
|
37885
|
+
* relaxation. It records the status change only; re-dispatch is owned by
|
|
37886
|
+
* the application layer and is never triggered here.
|
|
37887
|
+
*/
|
|
37888
|
+
async reopenTask(input) {
|
|
37889
|
+
return this.transitionAgentTask({
|
|
37890
|
+
...input,
|
|
37891
|
+
targetStatus: "in_progress",
|
|
37892
|
+
expectedStatuses: ["completed", "cancelled"],
|
|
37893
|
+
updates: { status: "in_progress", failureReason: null, result: null },
|
|
37894
|
+
summary: "Task reopened",
|
|
37895
|
+
detail: { type: "reopen" }
|
|
37896
|
+
});
|
|
37897
|
+
}
|
|
37898
|
+
/**
|
|
37899
|
+
* Transfers a human-authored task's ownership to a chosen Agent before dispatch.
|
|
37900
|
+
*
|
|
37901
|
+
* @param input Task, actor, destination Agent, and optional Task Thread.
|
|
37902
|
+
* @returns Structured result with the reassigned owner and an `owner_assigned` audit.
|
|
37903
|
+
* @remarks Only tasks with `context.source === "user"` can be assigned this way.
|
|
37904
|
+
* Repeated assignment to the same owner is idempotent (repair-writes the audit
|
|
37905
|
+
* without a CAS). This changes owner only, never status, so it publishes no
|
|
37906
|
+
* Project lifecycle notification.
|
|
37907
|
+
*/
|
|
37908
|
+
async assignOwner(input) {
|
|
37909
|
+
let task;
|
|
37910
|
+
try {
|
|
37911
|
+
task = await this.deps.taskStore.getById(input.tenantId, input.taskId);
|
|
37912
|
+
} catch {
|
|
37913
|
+
return failure2("TASK_STORE_READ_FAILED", "Failed to read task lifecycle state.");
|
|
37914
|
+
}
|
|
37915
|
+
if (!task) return failure2("TASK_NOT_FOUND", "Task was not found.");
|
|
37916
|
+
if (task.context?.source !== "user") {
|
|
37917
|
+
return failure2("TASK_NOT_HUMAN_MANAGED", "Only user-authored tasks can be assigned to an Agent.");
|
|
37918
|
+
}
|
|
37919
|
+
const storedThreadId = typeof task.context?.thread_id === "string" && task.context.thread_id.length > 0 ? task.context.thread_id : void 0;
|
|
37920
|
+
const effectiveThreadId = storedThreadId ?? input.threadId;
|
|
37921
|
+
const detail = { type: "owner_assigned", fromOwnerType: task.ownerType, toOwnerId: input.ownerId };
|
|
37922
|
+
if (task.ownerType === "agent" && task.ownerId === input.ownerId && (input.threadId === void 0 || storedThreadId === input.threadId)) {
|
|
37923
|
+
const eventKey2 = this.statusEventKey(task, "owner_assigned", detail);
|
|
37924
|
+
const event2 = await this.writeStatusEvent(
|
|
37925
|
+
task,
|
|
37926
|
+
input.actor,
|
|
37927
|
+
effectiveThreadId,
|
|
37928
|
+
"activity",
|
|
37929
|
+
"Task owner assigned",
|
|
37930
|
+
detail,
|
|
37931
|
+
eventKey2
|
|
37932
|
+
);
|
|
37933
|
+
return {
|
|
37934
|
+
success: true,
|
|
37935
|
+
task,
|
|
37936
|
+
mutated: false,
|
|
37937
|
+
eventKey: event2.eventKey,
|
|
37938
|
+
...event2.warning ? { warnings: [event2.warning] } : {}
|
|
37939
|
+
};
|
|
37940
|
+
}
|
|
37941
|
+
const context = { ...task.context ?? {} };
|
|
37942
|
+
if (input.threadId && !storedThreadId) context.thread_id = input.threadId;
|
|
37943
|
+
let updated;
|
|
37944
|
+
try {
|
|
37945
|
+
updated = await this.deps.taskStore.updateIfStatusAndUpdatedAt(
|
|
37946
|
+
input.tenantId,
|
|
37947
|
+
input.taskId,
|
|
37948
|
+
{ ownerType: "agent", ownerId: input.ownerId, context },
|
|
37949
|
+
[task.status],
|
|
37950
|
+
task.updatedAt
|
|
37951
|
+
);
|
|
37952
|
+
} catch {
|
|
37953
|
+
return failure2(
|
|
37954
|
+
"TASK_STORE_WRITE_FAILED",
|
|
37955
|
+
"Failed to assign the task owner.",
|
|
37956
|
+
"The store rejected the write."
|
|
37957
|
+
);
|
|
37958
|
+
}
|
|
37959
|
+
if (!updated) return failure2("TASK_STATUS_CONFLICT", "Task changed concurrently.");
|
|
37960
|
+
const eventKey = this.statusEventKey(updated, "owner_assigned", detail);
|
|
37961
|
+
const event = await this.writeStatusEvent(
|
|
37962
|
+
updated,
|
|
37963
|
+
input.actor,
|
|
37964
|
+
effectiveThreadId,
|
|
37965
|
+
"activity",
|
|
37966
|
+
"Task owner assigned",
|
|
37967
|
+
detail,
|
|
37968
|
+
eventKey
|
|
37969
|
+
);
|
|
37970
|
+
return {
|
|
37971
|
+
success: true,
|
|
37972
|
+
task: updated,
|
|
37973
|
+
mutated: true,
|
|
37974
|
+
eventKey: event.eventKey,
|
|
37975
|
+
...event.warning ? { warnings: [event.warning] } : {}
|
|
37976
|
+
};
|
|
37977
|
+
}
|
|
37806
37978
|
/** Atomically cancels a nonterminal agent task and records an idempotent status event. */
|
|
37807
37979
|
async cancelTask(input) {
|
|
37808
37980
|
return this.transitionAgentTask({
|
|
@@ -37883,19 +38055,7 @@ var TaskLifecycleService = class {
|
|
|
37883
38055
|
async interruptTask(input) {
|
|
37884
38056
|
const summary = input.summary.trim();
|
|
37885
38057
|
if (!summary) return failure2("MISSING_INTERRUPTION_SUMMARY", "Agent interruption requires a nonblank summary.");
|
|
37886
|
-
if (input.type !== "external_dependency" && input.dependencyTaskIds !== void 0) {
|
|
37887
|
-
return failure2("INVALID_EXTERNAL_DEPENDENCY", "dependencyTaskIds are only valid for external dependencies.");
|
|
37888
|
-
}
|
|
37889
38058
|
const requestedAt = this.now().toISOString();
|
|
37890
|
-
const external = input.type === "external_dependency" ? parseExternalDependency({
|
|
37891
|
-
type: input.type,
|
|
37892
|
-
summary,
|
|
37893
|
-
requestedAt,
|
|
37894
|
-
dependencyTaskIds: input.dependencyTaskIds
|
|
37895
|
-
}) : void 0;
|
|
37896
|
-
if (input.type === "external_dependency" && !external) {
|
|
37897
|
-
return failure2("INVALID_EXTERNAL_DEPENDENCY", "External dependencies require exact, unique nonblank task IDs.");
|
|
37898
|
-
}
|
|
37899
38059
|
let task;
|
|
37900
38060
|
try {
|
|
37901
38061
|
task = await this.deps.taskStore.getById(input.tenantId, input.taskId);
|
|
@@ -37909,29 +38069,17 @@ var TaskLifecycleService = class {
|
|
|
37909
38069
|
if (threadFailure) return threadFailure;
|
|
37910
38070
|
const currentInterruption = task.context?.interruption;
|
|
37911
38071
|
if (task.status === "interrupted" && currentInterruption && typeof currentInterruption === "object") {
|
|
37912
|
-
|
|
37913
|
-
if (input.type === "external_dependency") {
|
|
37914
|
-
if (!external || !storedExternal || storedExternal.summary !== external.summary || canonicalJson(storedExternal.dependencyTaskIds) !== canonicalJson(external.dependencyTaskIds)) {
|
|
37915
|
-
return failure2(
|
|
37916
|
-
"TASK_STATUS_CONFLICT",
|
|
37917
|
-
"Task is already interrupted by a different or malformed external dependency.",
|
|
37918
|
-
"Use manage_task get to inspect the existing interruption in task context.interruption."
|
|
37919
|
-
);
|
|
37920
|
-
}
|
|
37921
|
-
} else if (currentInterruption.type !== input.type || currentInterruption.summary !== summary) {
|
|
38072
|
+
if (currentInterruption.type !== input.type || currentInterruption.summary !== summary) {
|
|
37922
38073
|
return failure2(
|
|
37923
38074
|
"TASK_STATUS_CONFLICT",
|
|
37924
38075
|
"Task is already interrupted by a different request.",
|
|
37925
38076
|
"Use manage_task get to inspect the existing interruption, or resume it first."
|
|
37926
38077
|
);
|
|
37927
38078
|
}
|
|
37928
|
-
const detail =
|
|
38079
|
+
const detail = currentInterruption;
|
|
37929
38080
|
const eventKey2 = this.statusEventKey(task, "interrupted", detail);
|
|
37930
38081
|
const event2 = await this.writeStatusEvent(task, input.actor, input.threadId, "interrupted", summary, detail, eventKey2);
|
|
37931
38082
|
const warnings2 = event2.warning ? [event2.warning] : [];
|
|
37932
|
-
if (storedExternal && task.workspaceId && task.projectId) {
|
|
37933
|
-
return this.finishExternalDependencyInterruption(task, input, storedExternal, event2, warnings2, false);
|
|
37934
|
-
}
|
|
37935
38083
|
return {
|
|
37936
38084
|
success: true,
|
|
37937
38085
|
task,
|
|
@@ -37947,11 +38095,7 @@ var TaskLifecycleService = class {
|
|
|
37947
38095
|
"Only pending or in_progress tasks can be interrupted. Use manage_task get to check the current status."
|
|
37948
38096
|
);
|
|
37949
38097
|
}
|
|
37950
|
-
|
|
37951
|
-
const dependencyFailure = await this.validateExternalDependencies(task, external.dependencyTaskIds);
|
|
37952
|
-
if (dependencyFailure) return dependencyFailure;
|
|
37953
|
-
}
|
|
37954
|
-
const interruption = external ? { ...external } : { type: input.type, summary, requestedAt };
|
|
38098
|
+
const interruption = { type: input.type, summary, requestedAt };
|
|
37955
38099
|
let updated;
|
|
37956
38100
|
try {
|
|
37957
38101
|
updated = await this.deps.taskStore.updateIfStatusAndUpdatedAt(input.tenantId, input.taskId, {
|
|
@@ -37973,9 +38117,6 @@ var TaskLifecycleService = class {
|
|
|
37973
38117
|
const eventKey = this.statusEventKey(updated, "interrupted", interruption);
|
|
37974
38118
|
const event = await this.writeStatusEvent(updated, input.actor, input.threadId, "interrupted", summary, interruption, eventKey);
|
|
37975
38119
|
const warnings = event.warning ? [event.warning] : await this.notifyWinningTransition(updated, "interrupted", event);
|
|
37976
|
-
if (external && updated.workspaceId && updated.projectId) {
|
|
37977
|
-
return this.finishExternalDependencyInterruption(updated, input, external, event, warnings, true);
|
|
37978
|
-
}
|
|
37979
38120
|
return {
|
|
37980
38121
|
success: true,
|
|
37981
38122
|
task: updated,
|
|
@@ -39214,7 +39355,9 @@ var TaskLifecycleService = class {
|
|
|
39214
39355
|
};
|
|
39215
39356
|
}
|
|
39216
39357
|
if (!input.expectedStatuses.includes(task.status)) return failure2("TASK_STATUS_CONFLICT", "Task status cannot make this transition.");
|
|
39217
|
-
const
|
|
39358
|
+
const clearedContext = clearInterruptionContext(task.context);
|
|
39359
|
+
const withThread = input.threadId && task.context?.thread_id === void 0 ? { ...clearedContext ?? {}, thread_id: input.threadId } : clearedContext;
|
|
39360
|
+
const updates = { ...input.updates, context: withThread };
|
|
39218
39361
|
let updated;
|
|
39219
39362
|
try {
|
|
39220
39363
|
updated = await this.deps.taskStore.updateIfStatusAndUpdatedAt(
|
|
@@ -39302,85 +39445,6 @@ var TaskLifecycleService = class {
|
|
|
39302
39445
|
return [{ code: "LIFECYCLE_NOTIFICATION_FAILED", taskId: task.id, eventKey: event.eventKey }];
|
|
39303
39446
|
}
|
|
39304
39447
|
}
|
|
39305
|
-
async validateExternalDependencies(task, dependencyTaskIds) {
|
|
39306
|
-
const declared = new Set(task.dependencies ?? []);
|
|
39307
|
-
if (dependencyTaskIds.some((id) => id === task.id || !declared.has(id))) {
|
|
39308
|
-
return failure2("INVALID_EXTERNAL_DEPENDENCY", "External dependency IDs must be declared non-self dependencies.");
|
|
39309
|
-
}
|
|
39310
|
-
try {
|
|
39311
|
-
for (const id of dependencyTaskIds) {
|
|
39312
|
-
const dependency = await this.deps.taskStore.getById(task.tenantId, id);
|
|
39313
|
-
if (!dependency || dependency.workspaceId !== task.workspaceId || dependency.projectId !== task.projectId || dependency.status === "completed") {
|
|
39314
|
-
return failure2("INVALID_EXTERNAL_DEPENDENCY", "External dependencies must exist, remain incomplete, and share exact scope.");
|
|
39315
|
-
}
|
|
39316
|
-
}
|
|
39317
|
-
} catch {
|
|
39318
|
-
return failure2("TASK_STORE_READ_FAILED", "Failed to validate external dependencies.");
|
|
39319
|
-
}
|
|
39320
|
-
return void 0;
|
|
39321
|
-
}
|
|
39322
|
-
async externalDependencyReadiness(task, dependencyTaskIds) {
|
|
39323
|
-
try {
|
|
39324
|
-
for (const id of dependencyTaskIds) {
|
|
39325
|
-
const dependency = await this.deps.taskStore.getById(task.tenantId, id);
|
|
39326
|
-
if (!dependency || dependency.workspaceId !== task.workspaceId || dependency.projectId !== task.projectId || dependency.status !== "completed") return { kind: "blocked" };
|
|
39327
|
-
}
|
|
39328
|
-
return { kind: "ready" };
|
|
39329
|
-
} catch {
|
|
39330
|
-
return {
|
|
39331
|
-
kind: "error",
|
|
39332
|
-
warning: { code: "DEPENDENCY_READ_FAILED", taskId: task.id }
|
|
39333
|
-
};
|
|
39334
|
-
}
|
|
39335
|
-
}
|
|
39336
|
-
async finishExternalDependencyInterruption(task, input, interruption, event, warnings, mutated) {
|
|
39337
|
-
if (event.warning) {
|
|
39338
|
-
return { success: true, task, mutated, eventKey: event.eventKey, warnings };
|
|
39339
|
-
}
|
|
39340
|
-
const readiness = await this.externalDependencyReadiness(task, interruption.dependencyTaskIds);
|
|
39341
|
-
if (readiness.kind === "blocked") {
|
|
39342
|
-
return { success: true, task, mutated, eventKey: event.eventKey, ...warnings.length ? { warnings } : {} };
|
|
39343
|
-
}
|
|
39344
|
-
if (readiness.kind === "error") {
|
|
39345
|
-
return {
|
|
39346
|
-
success: true,
|
|
39347
|
-
task,
|
|
39348
|
-
mutated,
|
|
39349
|
-
eventKey: event.eventKey,
|
|
39350
|
-
warnings: [...warnings, { ...readiness.warning, eventKey: event.eventKey }]
|
|
39351
|
-
};
|
|
39352
|
-
}
|
|
39353
|
-
const resumed = await this.resumeInterruption({
|
|
39354
|
-
tenantId: input.tenantId,
|
|
39355
|
-
taskId: input.taskId,
|
|
39356
|
-
actor: input.actor,
|
|
39357
|
-
threadId: input.threadId
|
|
39358
|
-
});
|
|
39359
|
-
if (resumed.success) {
|
|
39360
|
-
const combined = [...warnings, ...resumed.warnings ?? []];
|
|
39361
|
-
return {
|
|
39362
|
-
...resumed,
|
|
39363
|
-
mutated: mutated || resumed.mutated,
|
|
39364
|
-
...combined.length ? { warnings: combined } : {}
|
|
39365
|
-
};
|
|
39366
|
-
}
|
|
39367
|
-
let current;
|
|
39368
|
-
try {
|
|
39369
|
-
current = await this.deps.taskStore.getById(input.tenantId, input.taskId);
|
|
39370
|
-
} catch {
|
|
39371
|
-
return resumed;
|
|
39372
|
-
}
|
|
39373
|
-
if (current?.status === "in_progress" && (!current.context?.thread_id || current.context?.thread_id === input.threadId)) {
|
|
39374
|
-
return {
|
|
39375
|
-
success: true,
|
|
39376
|
-
task: current,
|
|
39377
|
-
mutated,
|
|
39378
|
-
eventKey: event.eventKey,
|
|
39379
|
-
...warnings.length ? { warnings } : {}
|
|
39380
|
-
};
|
|
39381
|
-
}
|
|
39382
|
-
return resumed;
|
|
39383
|
-
}
|
|
39384
39448
|
async clearAuditMarker(task, key5) {
|
|
39385
39449
|
const context = withoutContextKey(task.context, key5);
|
|
39386
39450
|
try {
|
|
@@ -43273,6 +43337,9 @@ function trustedRosterScope(trusted) {
|
|
|
43273
43337
|
callerAssistantId: context.assistantId
|
|
43274
43338
|
};
|
|
43275
43339
|
}
|
|
43340
|
+
function trustedRosterExempt(trusted) {
|
|
43341
|
+
return trusted.projectTask?.rosterExempt === true;
|
|
43342
|
+
}
|
|
43276
43343
|
async function requireTrustedOwner(trusted, targetAssistantId) {
|
|
43277
43344
|
const context = trusted.projectTask ?? trusted.projectRoom;
|
|
43278
43345
|
const memberships = getStoreLattice("default", "projectBotMembership").store;
|
|
@@ -43537,6 +43604,7 @@ async function validateTrustedChildDependencyWait(store, tenantId2, parent, depe
|
|
|
43537
43604
|
if (dependency.status === "completed") continue;
|
|
43538
43605
|
if (!["pending", "in_progress", "interrupted"].includes(dependency.status) || dependency.parentId !== parent.id || dependency.ownerType !== "agent" || !hasExactContextSource(dependency, expectedSource)) return void 0;
|
|
43539
43606
|
incompleteChildren += 1;
|
|
43607
|
+
if (trustedRosterExempt(trusted)) continue;
|
|
43540
43608
|
try {
|
|
43541
43609
|
await requireTrustedOwner(trusted, dependency.ownerId);
|
|
43542
43610
|
} catch (error) {
|
|
@@ -43611,7 +43679,6 @@ var manageTaskSchema = import_zod68.z.object({
|
|
|
43611
43679
|
ownerId: import_zod68.z.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
|
|
43612
43680
|
requireReview: import_zod68.z.boolean().optional().describe("If true, agent completion pauses as interrupted(review_required) for HITL approval"),
|
|
43613
43681
|
dependencies: import_zod68.z.array(import_zod68.z.string()).optional().describe("List of task IDs that must be completed before this task can start"),
|
|
43614
|
-
dependencyTaskIds: import_zod68.z.array(import_zod68.z.string().trim().min(1)).optional().describe("Exact blocking task IDs required for an external_dependency interruption"),
|
|
43615
43682
|
result: import_zod68.z.string().optional().describe("Result summary. Used with set_status status='completed' or update status='completed'"),
|
|
43616
43683
|
failureReason: import_zod68.z.string().optional().describe("Failure reason. Used with set_status status='failed' or update status='failed'"),
|
|
43617
43684
|
files: import_zod68.z.array(import_zod68.z.object({
|
|
@@ -43780,7 +43847,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
43780
43847
|
const workspaceId = trustedScope?.workspaceId ?? rc.workspaceId;
|
|
43781
43848
|
const projectId = trustedScope?.projectId ?? rc.projectId;
|
|
43782
43849
|
const revalidateCaller = async () => {
|
|
43783
|
-
if (!trustedProject) return void 0;
|
|
43850
|
+
if (!trustedProject || trustedRosterExempt(trustedProject)) return void 0;
|
|
43784
43851
|
try {
|
|
43785
43852
|
await createProjectTaskOwnerPolicy().requireCaller(trustedRosterScope(trustedProject));
|
|
43786
43853
|
} catch (error) {
|
|
@@ -43788,7 +43855,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
43788
43855
|
}
|
|
43789
43856
|
return void 0;
|
|
43790
43857
|
};
|
|
43791
|
-
if (trustedProject) {
|
|
43858
|
+
if (trustedProject && !trustedRosterExempt(trustedProject)) {
|
|
43792
43859
|
try {
|
|
43793
43860
|
await createProjectTaskOwnerPolicy().requireCaller(trustedRosterScope(trustedProject));
|
|
43794
43861
|
} catch (error) {
|
|
@@ -43821,10 +43888,12 @@ function createTaskMiddleware(options = {}) {
|
|
|
43821
43888
|
if (trustedProject) {
|
|
43822
43889
|
const snapshot = taskMutationSnapshot(existing);
|
|
43823
43890
|
if (!snapshot) return trustedContextError();
|
|
43824
|
-
|
|
43825
|
-
|
|
43826
|
-
|
|
43827
|
-
|
|
43891
|
+
if (!trustedRosterExempt(trustedProject)) {
|
|
43892
|
+
try {
|
|
43893
|
+
await createProjectTaskOwnerPolicy().requireCaller(trustedRosterScope(trustedProject));
|
|
43894
|
+
} catch (error) {
|
|
43895
|
+
return projectPolicyError(error);
|
|
43896
|
+
}
|
|
43828
43897
|
}
|
|
43829
43898
|
deleted = await store.deleteIfSnapshot(tenantId2, id, snapshot);
|
|
43830
43899
|
} else {
|
|
@@ -43877,13 +43946,15 @@ function createTaskMiddleware(options = {}) {
|
|
|
43877
43946
|
"Target Project task owner is not active in the exact roster."
|
|
43878
43947
|
));
|
|
43879
43948
|
}
|
|
43880
|
-
|
|
43881
|
-
|
|
43882
|
-
|
|
43883
|
-
|
|
43884
|
-
|
|
43885
|
-
|
|
43886
|
-
|
|
43949
|
+
if (!trustedRosterExempt(trustedProject)) {
|
|
43950
|
+
try {
|
|
43951
|
+
await requireTrustedOwner(trustedProject, ownerId);
|
|
43952
|
+
} catch (error) {
|
|
43953
|
+
return projectPolicyError(error instanceof ProjectTaskOwnerPolicyError ? error : new ProjectTaskOwnerPolicyError(
|
|
43954
|
+
"PROJECT_TASK_OWNER_INACTIVE",
|
|
43955
|
+
"Target Project task owner is not active in the exact roster."
|
|
43956
|
+
));
|
|
43957
|
+
}
|
|
43887
43958
|
}
|
|
43888
43959
|
}
|
|
43889
43960
|
if (effectiveOwnerType === "agent" && (input.result !== void 0 || input.failureReason !== void 0)) {
|
|
@@ -43931,10 +44002,12 @@ function createTaskMiddleware(options = {}) {
|
|
|
43931
44002
|
)) return trustedContextError("Parent or dependency task changed before creation.");
|
|
43932
44003
|
const callerError = await revalidateCaller();
|
|
43933
44004
|
if (callerError) return callerError;
|
|
43934
|
-
|
|
43935
|
-
|
|
43936
|
-
|
|
43937
|
-
|
|
44005
|
+
if (!trustedRosterExempt(trustedProject)) {
|
|
44006
|
+
try {
|
|
44007
|
+
await requireTrustedOwner(trustedProject, ownerId);
|
|
44008
|
+
} catch (error) {
|
|
44009
|
+
return projectPolicyError(error);
|
|
44010
|
+
}
|
|
43938
44011
|
}
|
|
43939
44012
|
}
|
|
43940
44013
|
return store.create({
|
|
@@ -44192,18 +44265,6 @@ function createTaskMiddleware(options = {}) {
|
|
|
44192
44265
|
return trustedFailure;
|
|
44193
44266
|
}
|
|
44194
44267
|
}
|
|
44195
|
-
if (trustedProject && input.dependencyTaskIds !== void 0) {
|
|
44196
|
-
const interruption = input.context?.interruption;
|
|
44197
|
-
const interruptionType2 = interruption && typeof interruption === "object" ? interruption.type : void 0;
|
|
44198
|
-
if (input.status !== "interrupted" || interruptionType2 !== "external_dependency") {
|
|
44199
|
-
taskUpdateBlocked(input.id, "INVALID_EXTERNAL_DEPENDENCY", {});
|
|
44200
|
-
return JSON.stringify({
|
|
44201
|
-
success: false,
|
|
44202
|
-
code: "INVALID_EXTERNAL_DEPENDENCY",
|
|
44203
|
-
error: "dependencyTaskIds are only valid for external dependency interruptions."
|
|
44204
|
-
});
|
|
44205
|
-
}
|
|
44206
|
-
}
|
|
44207
44268
|
if (trustedProject && (input.ownerType !== void 0 && input.ownerType !== existing.ownerType || input.ownerId !== void 0 && input.ownerId !== existing.ownerId)) {
|
|
44208
44269
|
taskUpdateBlocked(input.id, "TASK_OWNERSHIP_VIA_DISPATCH_REQUIRED", {
|
|
44209
44270
|
inputOwnerType: input.ownerType,
|
|
@@ -44395,7 +44456,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
44395
44456
|
return trustedContextError("Parent or dependency task changed before update.");
|
|
44396
44457
|
}
|
|
44397
44458
|
}
|
|
44398
|
-
if (trustedProject) {
|
|
44459
|
+
if (trustedProject && !trustedRosterExempt(trustedProject)) {
|
|
44399
44460
|
try {
|
|
44400
44461
|
await createProjectTaskOwnerPolicy().requireCaller(trustedRosterScope(trustedProject));
|
|
44401
44462
|
} catch (error) {
|
|
@@ -44435,7 +44496,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
44435
44496
|
const workItemSummary = input.summary;
|
|
44436
44497
|
let activityWarnings;
|
|
44437
44498
|
try {
|
|
44438
|
-
if (trustedProject) {
|
|
44499
|
+
if (trustedProject && !trustedRosterExempt(trustedProject)) {
|
|
44439
44500
|
try {
|
|
44440
44501
|
await createProjectTaskOwnerPolicy().requireCaller(trustedRosterScope(trustedProject));
|
|
44441
44502
|
} catch (error) {
|
|
@@ -44520,18 +44581,6 @@ function createTaskMiddleware(options = {}) {
|
|
|
44520
44581
|
return trustedFailure;
|
|
44521
44582
|
}
|
|
44522
44583
|
}
|
|
44523
|
-
if (trustedProject && input.dependencyTaskIds !== void 0) {
|
|
44524
|
-
const interruption = input.context?.interruption;
|
|
44525
|
-
const interruptionType2 = interruption && typeof interruption === "object" ? interruption.type : void 0;
|
|
44526
|
-
if (input.status !== "interrupted" || interruptionType2 !== "external_dependency") {
|
|
44527
|
-
taskUpdateBlocked(input.id, "INVALID_EXTERNAL_DEPENDENCY", {});
|
|
44528
|
-
return JSON.stringify({
|
|
44529
|
-
success: false,
|
|
44530
|
-
code: "INVALID_EXTERNAL_DEPENDENCY",
|
|
44531
|
-
error: "dependencyTaskIds are only valid for external dependency interruptions."
|
|
44532
|
-
});
|
|
44533
|
-
}
|
|
44534
|
-
}
|
|
44535
44584
|
if (trustedProject && (input.ownerType !== void 0 && input.ownerType !== existing.ownerType || input.ownerId !== void 0 && input.ownerId !== existing.ownerId)) {
|
|
44536
44585
|
taskUpdateBlocked(input.id, "TASK_OWNERSHIP_VIA_DISPATCH_REQUIRED", {});
|
|
44537
44586
|
return JSON.stringify({
|
|
@@ -44613,11 +44662,11 @@ function createTaskMiddleware(options = {}) {
|
|
|
44613
44662
|
const interruption = input.context?.interruption;
|
|
44614
44663
|
const explicitType = interruption && typeof interruption === "object" ? interruption.type : void 0;
|
|
44615
44664
|
const type = explicitType ?? "missing_input";
|
|
44616
|
-
if (type !== "missing_input" && type !== "
|
|
44665
|
+
if (type !== "missing_input" && type !== "user_decision") {
|
|
44617
44666
|
return JSON.stringify({
|
|
44618
44667
|
success: false,
|
|
44619
44668
|
code: "INVALID_INTERRUPTION_TYPE",
|
|
44620
|
-
error: "Agent interruption type must be missing_input
|
|
44669
|
+
error: "Agent interruption type must be missing_input or user_decision."
|
|
44621
44670
|
});
|
|
44622
44671
|
}
|
|
44623
44672
|
await validateExecutionResult();
|
|
@@ -44629,8 +44678,7 @@ function createTaskMiddleware(options = {}) {
|
|
|
44629
44678
|
type,
|
|
44630
44679
|
summary: input.summary ?? "",
|
|
44631
44680
|
actor,
|
|
44632
|
-
threadId: statusThreadId
|
|
44633
|
-
dependencyTaskIds: input.dependencyTaskIds
|
|
44681
|
+
threadId: statusThreadId
|
|
44634
44682
|
});
|
|
44635
44683
|
return lifecycleMutationResponse(interrupted);
|
|
44636
44684
|
}
|
|
@@ -45338,7 +45386,6 @@ canonical Belief State:
|
|
|
45338
45386
|
};
|
|
45339
45387
|
|
|
45340
45388
|
// src/middlewares/documentLearningMiddleware.ts
|
|
45341
|
-
var import_protocols34 = require("@axiom-lattice/protocols");
|
|
45342
45389
|
var import_langchain84 = require("langchain");
|
|
45343
45390
|
|
|
45344
45391
|
// src/middlewares/documentLearningSkills.ts
|
|
@@ -45583,15 +45630,6 @@ var createDocumentLearningMiddleware = () => (0, import_langchain84.createMiddle
|
|
|
45583
45630
|
contextSchema,
|
|
45584
45631
|
tools: []
|
|
45585
45632
|
});
|
|
45586
|
-
var DOCUMENT_LEARNER_SYSTEM_PROMPT = `You are a capability learning specialist.
|
|
45587
|
-
|
|
45588
|
-
CRITICAL FIRST ACTION \u2014 before any response about the task:
|
|
45589
|
-
1. Call the \`skill\` tool with skill_name: "agent-architecture" to load the
|
|
45590
|
-
authoritative Charter.
|
|
45591
|
-
2. Call the \`skill\` tool with skill_name: "document-learning-learn-capability" to
|
|
45592
|
-
load the source-to-capability workflow.
|
|
45593
|
-
Never announce that you will follow a skill. Load both in this order and follow
|
|
45594
|
-
their content. If either load fails, retry it once, then report the failure.`;
|
|
45595
45633
|
var documentLearningPlugin = {
|
|
45596
45634
|
meta: {
|
|
45597
45635
|
type: "document-learning",
|
|
@@ -45600,92 +45638,6 @@ var documentLearningPlugin = {
|
|
|
45600
45638
|
description: "\u4ECE\u6587\u6863\u4E2D\u5B66\u4E60\u77E5\u8BC6\uFF0C\u81EA\u52A8\u6784\u5EFA\u6280\u80FD\u4F53\u7CFB\u548C\u8BC4\u6D4B\u3002 Learn knowledge from documents and build structured skill systems with evaluations.",
|
|
45601
45639
|
recommends: ["skill", "eval"]
|
|
45602
45640
|
},
|
|
45603
|
-
agents: {
|
|
45604
|
-
"document-learner": {
|
|
45605
|
-
key: "document-learner",
|
|
45606
|
-
name: "Document Learning Agent",
|
|
45607
|
-
description: "Read documents and build structured skill systems with evaluations. Use this agent when you need to extract knowledge from documents and turn it into reusable, testable agent skills.",
|
|
45608
|
-
type: import_protocols34.AgentType.DEEP_AGENT,
|
|
45609
|
-
prompt: DOCUMENT_LEARNER_SYSTEM_PROMPT,
|
|
45610
|
-
subAgents: ["document-parser-benchmark"],
|
|
45611
|
-
tools: [
|
|
45612
|
-
"invoke_agent",
|
|
45613
|
-
"list_agents",
|
|
45614
|
-
"create_agent",
|
|
45615
|
-
"update_agent",
|
|
45616
|
-
"delete_agent",
|
|
45617
|
-
"get_agent",
|
|
45618
|
-
"list_tools",
|
|
45619
|
-
"list_middleware_types"
|
|
45620
|
-
],
|
|
45621
|
-
middleware: [
|
|
45622
|
-
{
|
|
45623
|
-
id: "skill",
|
|
45624
|
-
type: "skill",
|
|
45625
|
-
name: "Skill",
|
|
45626
|
-
description: "Skill creation and loading",
|
|
45627
|
-
enabled: true,
|
|
45628
|
-
config: { readAll: true }
|
|
45629
|
-
},
|
|
45630
|
-
{
|
|
45631
|
-
id: "document-learning",
|
|
45632
|
-
type: "document-learning",
|
|
45633
|
-
name: "Document Learning",
|
|
45634
|
-
description: "Source-to-capability learning workflow",
|
|
45635
|
-
enabled: true,
|
|
45636
|
-
config: {}
|
|
45637
|
-
},
|
|
45638
|
-
{
|
|
45639
|
-
id: "eval",
|
|
45640
|
-
type: "eval",
|
|
45641
|
-
name: "Eval",
|
|
45642
|
-
description: "Evaluation design and execution",
|
|
45643
|
-
enabled: true,
|
|
45644
|
-
config: {}
|
|
45645
|
-
},
|
|
45646
|
-
{
|
|
45647
|
-
id: "task",
|
|
45648
|
-
type: "task",
|
|
45649
|
-
name: "Task",
|
|
45650
|
-
description: "Training process tracking with approval gates",
|
|
45651
|
-
enabled: true,
|
|
45652
|
-
config: {}
|
|
45653
|
-
},
|
|
45654
|
-
{
|
|
45655
|
-
id: "widget",
|
|
45656
|
-
type: "widget",
|
|
45657
|
-
name: "Widget",
|
|
45658
|
-
description: "Visualize benchmark results and eval dashboards",
|
|
45659
|
-
enabled: true,
|
|
45660
|
-
config: {}
|
|
45661
|
-
},
|
|
45662
|
-
{
|
|
45663
|
-
id: "ask_user_to_clarify",
|
|
45664
|
-
type: "ask_user_to_clarify",
|
|
45665
|
-
name: "Ask User",
|
|
45666
|
-
description: "Wait for user input at approval gates",
|
|
45667
|
-
enabled: true,
|
|
45668
|
-
config: {}
|
|
45669
|
-
},
|
|
45670
|
-
{
|
|
45671
|
-
id: "filesystem",
|
|
45672
|
-
type: "filesystem",
|
|
45673
|
-
name: "Filesystem",
|
|
45674
|
-
description: "Read documents, write skill files",
|
|
45675
|
-
enabled: true,
|
|
45676
|
-
config: {}
|
|
45677
|
-
},
|
|
45678
|
-
{
|
|
45679
|
-
id: "document-parser",
|
|
45680
|
-
type: "document-parser",
|
|
45681
|
-
name: "Document Parser",
|
|
45682
|
-
description: "Parse documents with the chosen engine",
|
|
45683
|
-
enabled: true,
|
|
45684
|
-
config: { connectAll: true }
|
|
45685
|
-
}
|
|
45686
|
-
]
|
|
45687
|
-
}
|
|
45688
|
-
},
|
|
45689
45641
|
skills: {
|
|
45690
45642
|
"document-learning-learn-capability": {
|
|
45691
45643
|
version: "1.0.0",
|
|
@@ -45914,7 +45866,7 @@ function createParseDocumentTool({
|
|
|
45914
45866
|
}
|
|
45915
45867
|
|
|
45916
45868
|
// src/middlewares/documentParserMiddleware.ts
|
|
45917
|
-
var
|
|
45869
|
+
var import_protocols34 = require("@axiom-lattice/protocols");
|
|
45918
45870
|
|
|
45919
45871
|
// src/middlewares/documentBenchmarkWorkflow.ts
|
|
45920
45872
|
var DOCUMENT_PARSER_BENCHMARK_YAML = `name: document-parser-benchmark
|
|
@@ -46367,6 +46319,23 @@ function createDocumentParserMiddleware(config) {
|
|
|
46367
46319
|
tools: [createParseDocumentTool({ connectAll, connections, baseUrl, apiKey })]
|
|
46368
46320
|
});
|
|
46369
46321
|
}
|
|
46322
|
+
var DOCUMENT_PARSER_SYSTEM_PROMPT = `You are the Document Parser. Turn documents (pdf, docx, images, spreadsheets, and similar) into clean Markdown.
|
|
46323
|
+
|
|
46324
|
+
CRITICAL FIRST ACTION: call the \`skill\` tool with skill_name: "document-parser-markitdown" and follow it. Never announce skill loads.
|
|
46325
|
+
|
|
46326
|
+
DEFAULT \u2014 local MarkItDown:
|
|
46327
|
+
- Single file: run \`markitdown <input> -o <output.md>\` via shell.
|
|
46328
|
+
- Batch or literature collections: use the scripts bundled in the skill.
|
|
46329
|
+
- After converting, verify the output is non-empty and its structure/tables are intact, then report the exact input -> output paths.
|
|
46330
|
+
|
|
46331
|
+
ESCALATION \u2014 remote parse_document:
|
|
46332
|
+
- Call parse_document only when local conversion fails, the format is unsupported, the output is empty or materially incomplete, the structure is badly damaged, OCR quality is inadequate, or the user explicitly asks for professional parsing.
|
|
46333
|
+
- When the user is unsatisfied with quality, use ask_user_to_clarify to ask whether to switch to a remote engine, and recommend one engine based on the observed file features and the user's feedback. If the user names an engine, use it.
|
|
46334
|
+
|
|
46335
|
+
BENCHMARK:
|
|
46336
|
+
- Only when the user explicitly asks to compare engines. Confirm with ask_user_to_clarify first, then delegate to the document-parser-benchmark subagent. Never benchmark by default.
|
|
46337
|
+
|
|
46338
|
+
Report only what you actually produced; never claim success without inspecting the output file.`;
|
|
46370
46339
|
var documentParserPlugin = {
|
|
46371
46340
|
meta: {
|
|
46372
46341
|
type: "document-parser",
|
|
@@ -46437,9 +46406,59 @@ var documentParserPlugin = {
|
|
|
46437
46406
|
},
|
|
46438
46407
|
middleware: (config) => createDocumentParserMiddleware(config),
|
|
46439
46408
|
agents: {
|
|
46409
|
+
"document-parser": {
|
|
46410
|
+
key: "document-parser",
|
|
46411
|
+
type: import_protocols34.AgentType.DEEP_AGENT,
|
|
46412
|
+
name: "Document Parser",
|
|
46413
|
+
description: "Parse documents (pdf, docx, images, spreadsheets) into clean Markdown. Defaults to local MarkItDown; escalates to remote engines only when quality or format needs it; runs engine benchmarking only on explicit request.",
|
|
46414
|
+
prompt: DOCUMENT_PARSER_SYSTEM_PROMPT,
|
|
46415
|
+
subAgents: ["document-parser-benchmark"],
|
|
46416
|
+
middleware: [
|
|
46417
|
+
{
|
|
46418
|
+
id: "skill",
|
|
46419
|
+
type: "skill",
|
|
46420
|
+
name: "Skill",
|
|
46421
|
+
description: "Load the local MarkItDown parsing procedure",
|
|
46422
|
+
enabled: true,
|
|
46423
|
+
config: { readAll: true }
|
|
46424
|
+
},
|
|
46425
|
+
{
|
|
46426
|
+
id: "filesystem",
|
|
46427
|
+
type: "filesystem",
|
|
46428
|
+
name: "Filesystem",
|
|
46429
|
+
description: "Read source documents and write Markdown output",
|
|
46430
|
+
enabled: true,
|
|
46431
|
+
config: { vmIsolation: "project" }
|
|
46432
|
+
},
|
|
46433
|
+
{
|
|
46434
|
+
id: "code_eval",
|
|
46435
|
+
type: "code_eval",
|
|
46436
|
+
name: "Code Runner",
|
|
46437
|
+
description: "Run the markitdown CLI and bundled conversion scripts",
|
|
46438
|
+
enabled: true,
|
|
46439
|
+
config: { vmIsolation: "project" }
|
|
46440
|
+
},
|
|
46441
|
+
{
|
|
46442
|
+
id: "document-parser",
|
|
46443
|
+
type: "document-parser",
|
|
46444
|
+
name: "Document Parser",
|
|
46445
|
+
description: "Remote parse_document fallback for hard documents",
|
|
46446
|
+
enabled: true,
|
|
46447
|
+
config: { connectAll: true }
|
|
46448
|
+
},
|
|
46449
|
+
{
|
|
46450
|
+
id: "ask_user_to_clarify",
|
|
46451
|
+
type: "ask_user_to_clarify",
|
|
46452
|
+
name: "Ask User",
|
|
46453
|
+
description: "Confirm engine switches and benchmark runs",
|
|
46454
|
+
enabled: true,
|
|
46455
|
+
config: {}
|
|
46456
|
+
}
|
|
46457
|
+
]
|
|
46458
|
+
},
|
|
46440
46459
|
"document-parser-benchmark": {
|
|
46441
46460
|
key: "document-parser-benchmark",
|
|
46442
|
-
type:
|
|
46461
|
+
type: import_protocols34.AgentType.WORKFLOW,
|
|
46443
46462
|
name: "Document Parser Benchmark",
|
|
46444
46463
|
description: "Benchmark document parsing engines. Parses a document with 5 engines in parallel, scores results, and produces a ranking report. Use this when you need to evaluate which parsing engine works best for a given document.",
|
|
46445
46464
|
prompt: "Benchmark document parsing engines: parse with 5 engines, score, and rank results.",
|
|
@@ -46476,7 +46495,7 @@ var documentParserPlugin = {
|
|
|
46476
46495
|
|
|
46477
46496
|
// src/middlewares/projectRoomMiddleware.ts
|
|
46478
46497
|
var import_crypto10 = require("crypto");
|
|
46479
|
-
var
|
|
46498
|
+
var import_protocols35 = require("@axiom-lattice/protocols");
|
|
46480
46499
|
var import_langchain87 = require("langchain");
|
|
46481
46500
|
var import_zod70 = require("zod");
|
|
46482
46501
|
var PROJECT_ROOM_CONTEXT_REQUIRED = "PROJECT_ROOM_CONTEXT_REQUIRED";
|
|
@@ -46506,7 +46525,7 @@ function ownDataValue2(record, key5) {
|
|
|
46506
46525
|
if (typeof record !== "object" || record === null || Array.isArray(record)) return void 0;
|
|
46507
46526
|
try {
|
|
46508
46527
|
const descriptor = Object.getOwnPropertyDescriptor(record, key5);
|
|
46509
|
-
return (0,
|
|
46528
|
+
return (0, import_protocols35.descriptorDataValue)(descriptor)?.value;
|
|
46510
46529
|
} catch {
|
|
46511
46530
|
return void 0;
|
|
46512
46531
|
}
|
|
@@ -46516,14 +46535,14 @@ function readTrustedRoomScope(config) {
|
|
|
46516
46535
|
const runConfig = ownDataValue2(configurable, "runConfig");
|
|
46517
46536
|
const projectRoom = ownDataValue2(runConfig, "projectRoom");
|
|
46518
46537
|
try {
|
|
46519
|
-
return (0,
|
|
46538
|
+
return (0, import_protocols35.parseTrustedRunContext)({ projectRoom }).projectRoom;
|
|
46520
46539
|
} catch {
|
|
46521
46540
|
return void 0;
|
|
46522
46541
|
}
|
|
46523
46542
|
}
|
|
46524
46543
|
function exactValues2(value, required, optional = []) {
|
|
46525
46544
|
try {
|
|
46526
|
-
return (0,
|
|
46545
|
+
return (0, import_protocols35.snapshotExactRecord)(value, required, optional);
|
|
46527
46546
|
} catch {
|
|
46528
46547
|
return void 0;
|
|
46529
46548
|
}
|
|
@@ -46559,7 +46578,7 @@ function snapshotMembership3(value) {
|
|
|
46559
46578
|
return { ...values, joinedAt, updatedAt };
|
|
46560
46579
|
}
|
|
46561
46580
|
function snapshotRows(value) {
|
|
46562
|
-
return (0,
|
|
46581
|
+
return (0, import_protocols35.snapshotExactArray)(value) ?? [];
|
|
46563
46582
|
}
|
|
46564
46583
|
async function hasActiveCurrentMembership(scope) {
|
|
46565
46584
|
const memberships = getStoreLattice("default", "projectBotMembership").store;
|
|
@@ -46646,7 +46665,7 @@ var projectRoomPlugin = {
|
|
|
46646
46665
|
// src/middlewares/sandboxPluginsMiddleware.ts
|
|
46647
46666
|
var import_langchain88 = require("langchain");
|
|
46648
46667
|
var import_zod71 = require("zod");
|
|
46649
|
-
var
|
|
46668
|
+
var import_protocols36 = require("@axiom-lattice/protocols");
|
|
46650
46669
|
|
|
46651
46670
|
// src/middlewares/sandboxPluginsSkills.ts
|
|
46652
46671
|
var PLUGIN_JSON_TEMPLATE = `{
|
|
@@ -47396,7 +47415,7 @@ var sandboxPluginsPlugin = {
|
|
|
47396
47415
|
key: "plugin-builder",
|
|
47397
47416
|
name: "Plugin Builder",
|
|
47398
47417
|
description: "Author and manage tenant plugins in the shared sandbox: clarify goal, inputs/outputs, credentials, and whether a UI is needed; then write the manifest and JS handlers, add an optional HTML MCP App UI, and validate/test with the manage_plugin tool.",
|
|
47399
|
-
type:
|
|
47418
|
+
type: import_protocols36.AgentType.DEEP_AGENT,
|
|
47400
47419
|
prompt: PLUGIN_BUILDER_PROMPT,
|
|
47401
47420
|
middleware: [
|
|
47402
47421
|
{
|
|
@@ -48316,6 +48335,7 @@ registerBuiltinPlugins();
|
|
|
48316
48335
|
invokeWithRetry,
|
|
48317
48336
|
isBuiltInSkill,
|
|
48318
48337
|
isDirectRoom,
|
|
48338
|
+
isMcpConnectionError,
|
|
48319
48339
|
isPluginSkillAuthorizedInSandbox,
|
|
48320
48340
|
isPluginSkillManagedInSandbox,
|
|
48321
48341
|
isUsingDefaultKey,
|
|
@@ -48338,7 +48358,6 @@ registerBuiltinPlugins();
|
|
|
48338
48358
|
parallelLimit,
|
|
48339
48359
|
parseCronExpression,
|
|
48340
48360
|
parseDirectRoomType,
|
|
48341
|
-
parseExternalDependency,
|
|
48342
48361
|
parseJudgeVerdict,
|
|
48343
48362
|
parsePackSize,
|
|
48344
48363
|
parseQueuedExecutionMode,
|