@xiaozhiclaw/qlogicagent-core 0.6.1 → 0.6.3
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 +127 -3
- package/dist/index.js +9 -9
- package/dist/types/embedded/cloud-agent.d.ts +3 -0
- package/dist/types/embedded/cloud-task.d.ts +7 -0
- package/dist/types/embedded/contracts.d.ts +3 -0
- package/dist/types/embedded/core-tools.d.ts +125 -0
- package/dist/types/embedded/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -89,6 +89,9 @@ export interface CloudAgentOptions extends Omit<CreateEmbeddedAgentOptions, "too
|
|
|
89
89
|
onWait?(invocation: CloudToolInvocation, wait: CloudToolWait["wait"]): Promise<void>;
|
|
90
90
|
/** Await the durable attempt record before network I/O and before acknowledging completion. */
|
|
91
91
|
onModelOperation?(operation: ModelOperation): Promise<void>;
|
|
92
|
+
/** Load only an original completed response needed for replay. The SaaS owns
|
|
93
|
+
* its immutable archive and scope checks; metadata remains in the checkpoint. */
|
|
94
|
+
loadModelResponse?(context: Readonly<CloudExecutionContext>, operation: Readonly<ModelOperation>): Promise<NonNullable<ModelOperation["response"]>>;
|
|
92
95
|
/** Product/model service atomically reserves money or token quota before network I/O. */
|
|
93
96
|
reserveModelBudget?(context: Readonly<CloudExecutionContext>, operation: Omit<ModelOperation, "response">, request: LLMRequest, signal?: AbortSignal): Promise<{
|
|
94
97
|
reference: string;
|
|
@@ -66,6 +66,13 @@ export interface CloudTaskStore {
|
|
|
66
66
|
/** CAS + live lease check + snapshot + next contiguous event cursor in one transaction. */
|
|
67
67
|
update(context: CloudExecutionContext, id: string, expectedRevision: number, task: CloudTaskSnapshot, event: CloudTaskEventPayload, leaseId?: string): Promise<CloudTaskSnapshot>;
|
|
68
68
|
release(context: CloudExecutionContext, id: string, leaseId: string): Promise<void>;
|
|
69
|
+
/** Text-only CAS event append without resending unchanged task history. */
|
|
70
|
+
appendDelta?(context: CloudExecutionContext, id: string, expectedRevision: number, event: Extract<CloudTurnEvent, {
|
|
71
|
+
type: "delta";
|
|
72
|
+
}>, leaseId: string): Promise<{
|
|
73
|
+
revision: number;
|
|
74
|
+
cursor: number;
|
|
75
|
+
}>;
|
|
69
76
|
events(context: CloudExecutionContext, id: string, after: number, limit: number): Promise<CloudTaskEvent[]>;
|
|
70
77
|
/** Atomic lease invalidation. Preserve unresolved model billing/effects as reconciliation_required;
|
|
71
78
|
* acknowledge cancelled only when their outcomes are known. Terminal tasks stay unchanged. */
|
|
@@ -46,6 +46,7 @@ export interface TurnRequest {
|
|
|
46
46
|
continuation?: {
|
|
47
47
|
completedRounds: number;
|
|
48
48
|
usage: TokenUsage;
|
|
49
|
+
pendingOutputText?: string;
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
export interface EmbeddedRuntimeOptions {
|
|
@@ -82,6 +83,8 @@ export interface TurnCheckpoint {
|
|
|
82
83
|
messages: ChatMessage[];
|
|
83
84
|
completedRounds: number;
|
|
84
85
|
usage: TokenUsage;
|
|
86
|
+
/** Committed partial final output, retained across response-capacity continuations. */
|
|
87
|
+
pendingOutputText?: string;
|
|
85
88
|
}
|
|
86
89
|
export interface EmbeddedAgent {
|
|
87
90
|
run(request: TurnRequest, signal?: AbortSignal): AsyncGenerator<TurnEvent>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolResult } from "./contracts.js";
|
|
2
|
+
import type { CloudToolInvocation, CloudToolWait } from "./cloud-agent.js";
|
|
3
|
+
export interface CoreResourceRead {
|
|
4
|
+
resourceId: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
cursor?: string;
|
|
7
|
+
limit?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CorePlanStep {
|
|
10
|
+
id: string;
|
|
11
|
+
description: string;
|
|
12
|
+
status: "pending" | "in_progress" | "completed" | "blocked" | "cancelled";
|
|
13
|
+
dependsOn?: string[];
|
|
14
|
+
evidenceRefs?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface CorePlanIssue {
|
|
17
|
+
id: string;
|
|
18
|
+
description: string;
|
|
19
|
+
stepIds?: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface CorePlanSnapshot {
|
|
22
|
+
steps: CorePlanStep[];
|
|
23
|
+
issues: CorePlanIssue[];
|
|
24
|
+
notes?: CorePlanNote[];
|
|
25
|
+
}
|
|
26
|
+
export interface CorePlanNote {
|
|
27
|
+
id: string;
|
|
28
|
+
category: "decision" | "constraint" | "blocker";
|
|
29
|
+
value: string;
|
|
30
|
+
evidenceRefs?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface CorePlanPatch {
|
|
33
|
+
upsertSteps?: CorePlanStep[];
|
|
34
|
+
removeStepIds?: string[];
|
|
35
|
+
upsertIssues?: CorePlanIssue[];
|
|
36
|
+
removeIssueIds?: string[];
|
|
37
|
+
upsertNotes?: CorePlanNote[];
|
|
38
|
+
removeNoteIds?: string[];
|
|
39
|
+
}
|
|
40
|
+
export type CorePlanInput = {
|
|
41
|
+
action: "read";
|
|
42
|
+
planId: string;
|
|
43
|
+
cursor?: string;
|
|
44
|
+
limit?: number;
|
|
45
|
+
stepIds?: string[];
|
|
46
|
+
} | ({
|
|
47
|
+
action: "create";
|
|
48
|
+
} & CorePlanSnapshot) | ({
|
|
49
|
+
action: "update";
|
|
50
|
+
planId: string;
|
|
51
|
+
expectedRevision: string;
|
|
52
|
+
} & CorePlanSnapshot) | ({
|
|
53
|
+
action: "patch";
|
|
54
|
+
planId: string;
|
|
55
|
+
expectedRevision: string;
|
|
56
|
+
} & CorePlanPatch);
|
|
57
|
+
export interface CoreConfirmationInput {
|
|
58
|
+
/** Immutable prepared-operation reference issued and resolved by the Host. */
|
|
59
|
+
operationRef: string;
|
|
60
|
+
summary: string;
|
|
61
|
+
targets: {
|
|
62
|
+
resourceId: string;
|
|
63
|
+
version?: string;
|
|
64
|
+
}[];
|
|
65
|
+
impacts: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface CoreToolInputs {
|
|
68
|
+
qlogic_ask_user: {
|
|
69
|
+
question: string;
|
|
70
|
+
choices?: string[];
|
|
71
|
+
};
|
|
72
|
+
qlogic_discover_capabilities: {
|
|
73
|
+
cursor?: string;
|
|
74
|
+
};
|
|
75
|
+
qlogic_search_resources: {
|
|
76
|
+
query: string;
|
|
77
|
+
cursor?: string;
|
|
78
|
+
limit?: number;
|
|
79
|
+
};
|
|
80
|
+
qlogic_read_resource: CoreResourceRead;
|
|
81
|
+
qlogic_read_skill: {
|
|
82
|
+
skillId: string;
|
|
83
|
+
resourceId?: string;
|
|
84
|
+
version?: string;
|
|
85
|
+
cursor?: string;
|
|
86
|
+
limit?: number;
|
|
87
|
+
};
|
|
88
|
+
qlogic_update_plan: CorePlanInput;
|
|
89
|
+
qlogic_request_confirmation: CoreConfirmationInput;
|
|
90
|
+
}
|
|
91
|
+
export type CoreToolName = keyof CoreToolInputs;
|
|
92
|
+
export type CoreToolWait<Name extends "qlogic_ask_user" | "qlogic_request_confirmation"> = {
|
|
93
|
+
kind: "wait";
|
|
94
|
+
wait: Omit<CloudToolWait["wait"], "kind"> & {
|
|
95
|
+
kind: Name extends "qlogic_ask_user" ? "input" : "confirmation";
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export type CoreToolHandler<Name extends CoreToolName> = (input: Readonly<CoreToolInputs[Name]>, invocation: Readonly<CloudToolInvocation>, signal?: AbortSignal) => Promise<ToolResult | (Name extends "qlogic_ask_user" | "qlogic_request_confirmation" ? CoreToolWait<Name> : never)>;
|
|
99
|
+
export interface CoreToolHost {
|
|
100
|
+
/** Revalidate the actor and exact resource/Skill reference on every invocation.
|
|
101
|
+
* A model-provided reference is never evidence of access or approval.
|
|
102
|
+
*/
|
|
103
|
+
authorize(invocation: Readonly<CloudToolInvocation>, input: Readonly<CoreToolInputs[CoreToolName]>, signal?: AbortSignal): Promise<void>;
|
|
104
|
+
handlers: {
|
|
105
|
+
[Name in CoreToolName]?: CoreToolHandler<Name>;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export interface CoreToolAdapter {
|
|
109
|
+
/** Only explicitly mounted Host handlers are offered to the model. */
|
|
110
|
+
readonly definitions: ToolDefinition[];
|
|
111
|
+
handles(name: string): boolean;
|
|
112
|
+
invoke(invocation: CloudToolInvocation, signal?: AbortSignal): Promise<ToolResult | CloudToolWait>;
|
|
113
|
+
}
|
|
114
|
+
/** Artifact inventory, independent of any product's currently mounted handlers. */
|
|
115
|
+
export declare function getCoreToolDefinitions(): ToolDefinition[];
|
|
116
|
+
/** Pure contract validation for a Host's locked snapshot; it owns CAS and persistence. */
|
|
117
|
+
export declare function applyCorePlanPatch(snapshot: CorePlanSnapshot, patch: CorePlanPatch): CorePlanSnapshot;
|
|
118
|
+
/** A typed dispatch adapter for the existing CloudAgent/CloudTask tool loop.
|
|
119
|
+
* The Host owns discovery, data, authorization, plans and user-decision receipts.
|
|
120
|
+
*/
|
|
121
|
+
export declare function createCoreToolAdapter(options: {
|
|
122
|
+
host: CoreToolHost;
|
|
123
|
+
/** Omit to enable the supplied handlers; an explicit list must have every handler. */
|
|
124
|
+
enabledTools?: readonly CoreToolName[];
|
|
125
|
+
}): CoreToolAdapter;
|
|
@@ -3,6 +3,9 @@ export { prepareSlidingWindowContext } from "./context-projection.js";
|
|
|
3
3
|
export { corePackageVersion } from "./package-version.js";
|
|
4
4
|
export { getCoreCapabilities } from "./core-capabilities.js";
|
|
5
5
|
export type { CoreCapabilities } from "./core-capabilities.js";
|
|
6
|
+
export { createCoreToolAdapter, applyCorePlanPatch } from "./core-tools.js";
|
|
7
|
+
export type { CorePlanPatch, CorePlanNote } from "./core-tools.js";
|
|
8
|
+
export type { CoreToolAdapter, CoreToolHost, CoreToolInputs, CoreToolName, CoreToolHandler, CoreToolWait, CoreResourceRead, CorePlanStep, CorePlanIssue, CorePlanSnapshot, CorePlanInput, CoreConfirmationInput } from "./core-tools.js";
|
|
6
9
|
export { AgentContentBlockValidationError, parseAgentContentBlock, } from "./content-blocks.js";
|
|
7
10
|
export type { ContextAnchor, ContextEnvelope, SemanticToolCapability, ToolIdentity, UsageRecord, UsageSource, AgentLogger, ChatMessage, CreateEmbeddedAgentOptions, EmbeddedAgent, EmbeddedRuntimeOptions, ModelContextPreparation, ModelContextProjection, LLMChunk, LLMRequest, LLMTransport, ModelRetryAuthorization, ToolDefinition, ToolInvoker, ToolInvocationContext, ToolResult, TurnCheckpoint, TokenUsage, TurnConfig, TurnEvent, TurnRequest, } from "./contracts.js";
|
|
8
11
|
export type { ModelOperation, ModelRecoveryProof } from "./model-operation.js";
|