@xiaozhiclaw/qlogicagent-core 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.js +11 -12
- package/dist/types/contracts/chat.d.ts +5 -0
- package/dist/types/embedded/business-contracts.d.ts +7 -0
- package/dist/types/embedded/cloud-agent.d.ts +4 -0
- package/dist/types/embedded/cloud-task.d.ts +23 -3
- package/dist/types/embedded/contracts.d.ts +4 -1
- package/dist/types/embedded/index.d.ts +2 -0
- package/dist/types/embedded/model-operation.d.ts +2 -0
- package/dist/types/embedded/package-version.d.ts +1 -0
- package/dist/types/runtime/ports/agent-runtime-ports.d.ts +1 -0
- package/dist/types/runtime/ports/model-transport-contracts.d.ts +12 -0
- package/package.json +1 -1
|
@@ -19,6 +19,11 @@ export type ContextAnchorCategory = "objective" | "acceptance" | "decision" | "c
|
|
|
19
19
|
export interface ContextAnchor {
|
|
20
20
|
category: ContextAnchorCategory;
|
|
21
21
|
value: string;
|
|
22
|
+
/** Product-owned identity and immutable revision; chronological order is not authority. */
|
|
23
|
+
id?: string;
|
|
24
|
+
revision?: string;
|
|
25
|
+
supersedes?: string[];
|
|
26
|
+
references?: string[];
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
29
|
* Canonical Goal/thread facts supplied by the product for one Agent turn.
|
|
@@ -42,9 +42,11 @@ export interface BusinessAssistantContext {
|
|
|
42
42
|
export interface BusinessGoal {
|
|
43
43
|
id: string;
|
|
44
44
|
description: string;
|
|
45
|
+
/** Opaque product parameters; Core does not implement domain rules or a universal condition language. */
|
|
45
46
|
criteria: Array<{
|
|
46
47
|
id: string;
|
|
47
48
|
description: string;
|
|
49
|
+
parameters?: Record<string, unknown>;
|
|
48
50
|
}>;
|
|
49
51
|
}
|
|
50
52
|
export interface BusinessGoalEvidence {
|
|
@@ -52,6 +54,11 @@ export interface BusinessGoalEvidence {
|
|
|
52
54
|
id: string;
|
|
53
55
|
status: "satisfied" | "missing" | "failed";
|
|
54
56
|
references: string[];
|
|
57
|
+
/** Product explanations, observed facts and exact versions for evidence-driven correction. */
|
|
58
|
+
detail?: string;
|
|
59
|
+
expected?: unknown;
|
|
60
|
+
observed?: unknown;
|
|
61
|
+
revision?: string;
|
|
55
62
|
}>;
|
|
56
63
|
}
|
|
57
64
|
export interface BusinessGoalOutcome extends BusinessGoalEvidence {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelOperation } from "./model-operation.js";
|
|
2
|
+
import type { TaskMonetaryBudget } from "../runtime/ports/model-transport-contracts.js";
|
|
2
3
|
import { type BusinessAssistantContext, type BusinessGoal } from "./business-contracts.js";
|
|
3
4
|
import { type AgentContentBlock } from "./content-blocks.js";
|
|
4
5
|
import type { CreateEmbeddedAgentOptions, ToolResult, TurnCheckpoint, TurnEvent, TurnRequest, LLMRequest } from "./contracts.js";
|
|
@@ -17,6 +18,8 @@ export interface CloudToolInvocation {
|
|
|
17
18
|
round: number;
|
|
18
19
|
name: string;
|
|
19
20
|
arguments: string;
|
|
21
|
+
/** Product-paid tools must forward this same immutable ceiling to their billing service. */
|
|
22
|
+
taskBudget?: Readonly<TaskMonetaryBudget>;
|
|
20
23
|
}
|
|
21
24
|
export interface CloudCheckpoint extends TurnCheckpoint {
|
|
22
25
|
schemaVersion: 1;
|
|
@@ -35,6 +38,7 @@ export interface CloudTurnRequest extends Omit<TurnRequest, "continuation"> {
|
|
|
35
38
|
executionBudget?: {
|
|
36
39
|
maxModelRequests?: number;
|
|
37
40
|
deadlineAtMs?: number;
|
|
41
|
+
monetary?: TaskMonetaryBudget;
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
export interface CloudToolWait {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CloudAgentOptions, type CloudCheckpoint, type CloudExecutionContext, type CloudToolReceipt, type CloudToolWait, type CloudTurnEvent, type CloudTurnRequest } from "./cloud-agent.js";
|
|
2
|
-
import type { ToolResult } from "./contracts.js";
|
|
2
|
+
import type { ToolResult, ChatMessage } from "./contracts.js";
|
|
3
3
|
import type { ModelOperation, ModelRecoveryProof } from "./model-operation.js";
|
|
4
|
-
import { type BusinessGoalEvidence, type BusinessGoalOutcome } from "./business-contracts.js";
|
|
4
|
+
import { type BusinessGoal, type BusinessGoalEvidence, type BusinessGoalOutcome } from "./business-contracts.js";
|
|
5
5
|
export type CloudTaskStatus = "queued" | "running" | "waiting_input" | "waiting_confirmation" | "waiting_external" | "reconciliation_required" | "completed" | "stopped" | "failed" | "cancelled";
|
|
6
6
|
export interface CloudTaskSnapshot {
|
|
7
7
|
id: string;
|
|
@@ -20,8 +20,18 @@ export interface CloudTaskSnapshot {
|
|
|
20
20
|
/** Durable product cancellation intent; reconciliation never resumes subsequent work. */
|
|
21
21
|
cancellationRequested?: boolean;
|
|
22
22
|
outcome?: BusinessGoalOutcome;
|
|
23
|
+
/** Product-authenticated amendments, retained independently of model context compaction. */
|
|
24
|
+
/** Optional data is product-owned receipt metadata; only messages enter the model checkpoint. */
|
|
25
|
+
inputs?: {
|
|
26
|
+
id: string;
|
|
27
|
+
messages: ChatMessage[];
|
|
28
|
+
data?: Record<string, unknown>;
|
|
29
|
+
}[];
|
|
23
30
|
}
|
|
24
31
|
export type CloudTaskEventPayload = CloudTurnEvent | {
|
|
32
|
+
type: "goal_verification";
|
|
33
|
+
outcome: BusinessGoalOutcome;
|
|
34
|
+
} | {
|
|
25
35
|
type: "task_status";
|
|
26
36
|
status: CloudTaskStatus;
|
|
27
37
|
} | {
|
|
@@ -68,7 +78,11 @@ export interface CloudTaskRuntimeOptions {
|
|
|
68
78
|
agent: Omit<CloudAgentOptions, "checkpoints" | "onToolResult" | "onWait" | "onModelOperation">;
|
|
69
79
|
/** Query authoritative product state; an LLM's success text is never completion evidence. */
|
|
70
80
|
verifyGoal?(task: CloudTaskSnapshot): Promise<BusinessGoalEvidence>;
|
|
71
|
-
|
|
81
|
+
/** Product-owned confirmed goals may be established through a tool confirmation receipt. */
|
|
82
|
+
resolveGoal?(task: CloudTaskSnapshot): Promise<BusinessGoal | undefined>;
|
|
83
|
+
/** Feed independently checked evidence back through the same loop; no separate correction runner. */
|
|
84
|
+
goalFeedback?(task: CloudTaskSnapshot, outcome: BusinessGoalOutcome): Promise<ChatMessage[]>;
|
|
85
|
+
authorize(context: CloudExecutionContext, action: "create" | "read" | "execute" | "cancel" | "complete_wait" | "recover" | "append_input"): Promise<void>;
|
|
72
86
|
/** Validate actual employee approval/input or query the original external job; never trust browser results. */
|
|
73
87
|
authorizeCompletion(task: CloudTaskSnapshot, waitId: string, result: ToolResult): Promise<void>;
|
|
74
88
|
/** Required for interrupted model calls or unresolved effects. The product proves billing/retry safety. */
|
|
@@ -87,6 +101,12 @@ export interface CloudTaskRuntime {
|
|
|
87
101
|
/** Called by the existing product worker, independently from browser subscriptions. */
|
|
88
102
|
execute(context: CloudExecutionContext, id: string, workerSignal?: AbortSignal): Promise<void>;
|
|
89
103
|
cancel(context: CloudExecutionContext, id: string): Promise<CloudTaskSnapshot>;
|
|
104
|
+
/** Continue a resolved task on explicit user input, preserving its identity and original budgets. */
|
|
105
|
+
appendInput(context: CloudExecutionContext, id: string, input: {
|
|
106
|
+
id: string;
|
|
107
|
+
messages: ChatMessage[];
|
|
108
|
+
data?: Record<string, unknown>;
|
|
109
|
+
}): Promise<CloudTaskSnapshot>;
|
|
90
110
|
completeWait(context: CloudExecutionContext, id: string, waitId: string, result: ToolResult): Promise<CloudTaskSnapshot>;
|
|
91
111
|
recover(context: CloudExecutionContext, id: string, receipts?: CloudToolReceipt[]): Promise<CloudTaskSnapshot>;
|
|
92
112
|
}
|
|
@@ -49,7 +49,10 @@ export interface TurnRequest {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
export interface EmbeddedRuntimeOptions {
|
|
52
|
-
|
|
52
|
+
/** Product-owned model projection; receipts retain the full result. Return undefined to keep it. */
|
|
53
|
+
projectToolResult?: (message: Readonly<ChatMessage>) => Promise<string | undefined>;
|
|
54
|
+
/** Evidence or new questions supplied by the product before accepting a model's final answer. */
|
|
55
|
+
reviewCompletion?: (messages: readonly ChatMessage[], answer: string) => Promise<ChatMessage[]>;
|
|
53
56
|
onCheckpoint?: (checkpoint: TurnCheckpoint) => Promise<void>;
|
|
54
57
|
}
|
|
55
58
|
export interface TurnCheckpoint {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { createEmbeddedAgent } from "./embedded-agent.js";
|
|
2
|
+
export { corePackageVersion } from "./package-version.js";
|
|
2
3
|
export { AgentContentBlockValidationError, analyzeEngineeringFile, createStandardPresentationToolResult, isEngineeringFile, parseAgentContentBlock, standardPresentationToolDefinitions, standardPresentationToolNames, } from "./content-blocks.js";
|
|
3
4
|
export type { ContextAnchor, ContextEnvelope, SemanticToolCapability, ToolIdentity, UsageRecord, UsageSource, AgentLogger, ChatMessage, CreateEmbeddedAgentOptions, EmbeddedAgent, EmbeddedRuntimeOptions, LLMChunk, LLMRequest, LLMTransport, ModelRetryAuthorization, ToolDefinition, ToolInvoker, ToolInvocationContext, ToolResult, TurnCheckpoint, TokenUsage, TurnConfig, TurnEvent, TurnRequest, } from "./contracts.js";
|
|
4
5
|
export type { ModelOperation, ModelRecoveryProof } from "./model-operation.js";
|
|
6
|
+
export type { TaskMonetaryBudget } from "../runtime/ports/model-transport-contracts.js";
|
|
5
7
|
export type { BusinessAssistantContext, BusinessGoal, BusinessGoalEvidence, BusinessGoalOutcome } from "./business-contracts.js";
|
|
6
8
|
export { createCloudAgent, completeCloudToolCheckpoint, canonicalCloudValue } from "./cloud-agent.js";
|
|
7
9
|
export type { CloudAgent, CloudAgentOptions, CloudCheckpoint, CloudExecutionContext, CloudToolInvocation, CloudToolReceipt, CloudToolWait, CloudTurnEvent, CloudTurnRequest, } from "./cloud-agent.js";
|
|
@@ -7,6 +7,8 @@ export interface ModelOperation {
|
|
|
7
7
|
attempt: number;
|
|
8
8
|
requestDigest: string;
|
|
9
9
|
model: string;
|
|
10
|
+
/** Product transport binding, persisted before I/O; never a credential. */
|
|
11
|
+
originReference?: string;
|
|
10
12
|
startedAtMs?: number;
|
|
11
13
|
finishedAtMs?: number;
|
|
12
14
|
status: "prepared" | "responding" | "completed" | "rejected" | "unknown";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const corePackageVersion: string;
|
|
@@ -39,6 +39,7 @@ export interface StreamingToolExecutorPortConfig {
|
|
|
39
39
|
executionTimeoutMsByTool?: ReadonlyMap<string, number>;
|
|
40
40
|
}
|
|
41
41
|
export interface ToolLoopRuntimePorts {
|
|
42
|
+
reviewCompletion?(messages: readonly ChatMessage[], answer: string): Promise<ChatMessage[]>;
|
|
42
43
|
saveCheckpoint?(checkpoint: {
|
|
43
44
|
turnId: string;
|
|
44
45
|
sessionId: string;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ChatMessage, ToolDefinition } from "./agent-execution-contracts.js";
|
|
2
2
|
import type { WireUsageRecord } from "../../contracts/usage.js";
|
|
3
3
|
import type { ModelOperation, ModelRecoveryProof } from "../../embedded/model-operation.js";
|
|
4
|
+
/** Immutable product task ceiling, enforced by the model service's financial authority. */
|
|
5
|
+
export interface TaskMonetaryBudget {
|
|
6
|
+
id: string;
|
|
7
|
+
currency: "CNY";
|
|
8
|
+
maxAmount: string;
|
|
9
|
+
}
|
|
4
10
|
export interface LLMRequest {
|
|
5
11
|
/** Stable product execution reference; not a provider-side idempotency guarantee. */
|
|
6
12
|
execution?: {
|
|
@@ -8,6 +14,8 @@ export interface LLMRequest {
|
|
|
8
14
|
requestDigest: string;
|
|
9
15
|
round: number;
|
|
10
16
|
attempt: number;
|
|
17
|
+
originReference?: string;
|
|
18
|
+
taskBudget?: TaskMonetaryBudget;
|
|
11
19
|
};
|
|
12
20
|
model: string;
|
|
13
21
|
messages: ChatMessage[];
|
|
@@ -82,6 +90,10 @@ export interface AccumulatedToolCall {
|
|
|
82
90
|
arguments: string;
|
|
83
91
|
}
|
|
84
92
|
export interface LLMTransport {
|
|
93
|
+
/** True only when every billed dispatch enforces execution.taskBudget durably. */
|
|
94
|
+
supportsTaskMonetaryBudget?: true;
|
|
95
|
+
/** Select an opaque, durable transport/account reference before dispatch. No inference or credentials in the reference. */
|
|
96
|
+
bindModelRequest?(request: LLMRequest, apiKey: string): Promise<string>;
|
|
85
97
|
/** Forward requested provider controls or reject unsupported ones before inference; never silently discard them. */
|
|
86
98
|
stream(request: LLMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<LLMChunk>;
|
|
87
99
|
/** Query the original service receipt without starting inference. Missing evidence must reject. */
|