@claxedo/agent-runtime-contract 0.8.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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/availability.d.ts +42 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/claims.d.ts +31 -0
- package/dist/connections.d.ts +21 -0
- package/dist/content.d.ts +411 -0
- package/dist/credential-broker-errors.d.ts +80 -0
- package/dist/errors.d.ts +43 -0
- package/dist/events.d.ts +460 -0
- package/dist/files.d.ts +52 -0
- package/dist/harness-effort.d.ts +56 -0
- package/dist/harness-table.d.ts +56 -0
- package/dist/harnesses.d.ts +96 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +815 -0
- package/dist/question-answers.d.ts +13 -0
- package/dist/session-group.d.ts +37 -0
- package/dist/sessions.d.ts +166 -0
- package/dist/tool-names.d.ts +3 -0
- package/dist/usage-windows.d.ts +23 -0
- package/dist/values.d.ts +10 -0
- package/package.json +53 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentQuestionAnswer } from "./content";
|
|
2
|
+
export type QuestionAnswerSource = {
|
|
3
|
+
question: string;
|
|
4
|
+
optionLabels: string[];
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A harness reports one answer per question as a single string, joining a multi-select
|
|
9
|
+
* with `", "`, which loses the selection boundaries. Splitting unconditionally would cut
|
|
10
|
+
* a free-text answer at its first comma, so the declared option labels decide: a value
|
|
11
|
+
* that is itself a label, or that does not split cleanly into labels, is one answer.
|
|
12
|
+
*/
|
|
13
|
+
export declare function reconstructQuestionAnswers(questions: QuestionAnswerSource[], answers: Record<string, unknown>): AgentQuestionAnswer[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type SessionHarness } from "./harnesses";
|
|
2
|
+
import type { PromptModel } from "./sessions";
|
|
3
|
+
/** The slots a Tasks preset resolves. A group names at most one entry per slot. */
|
|
4
|
+
export declare const SESSION_GROUP_SLOTS: readonly ["primary", "planning", "implementation", "review"];
|
|
5
|
+
export type SessionGroupSlot = (typeof SESSION_GROUP_SLOTS)[number];
|
|
6
|
+
export type SessionGroupEntry = {
|
|
7
|
+
harness: SessionHarness;
|
|
8
|
+
model: PromptModel;
|
|
9
|
+
/** Absent leaves the choice with the model's own default. */
|
|
10
|
+
effort?: string;
|
|
11
|
+
};
|
|
12
|
+
export type SessionModelGroup = Partial<Record<SessionGroupSlot, SessionGroupEntry>>;
|
|
13
|
+
export type SessionModelGroupParse = {
|
|
14
|
+
group: SessionModelGroup;
|
|
15
|
+
} | {
|
|
16
|
+
field: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function isSessionGroupSlot(value: string): value is SessionGroupSlot;
|
|
20
|
+
/**
|
|
21
|
+
* The machine-readable group a session was created under.
|
|
22
|
+
*
|
|
23
|
+
* A malformed slot is refused by name rather than dropped: a group that quietly
|
|
24
|
+
* lost a slot on the way in resolves a later delegation to the wrong model.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseSessionModelGroup(input: unknown): SessionModelGroupParse;
|
|
27
|
+
/**
|
|
28
|
+
* A slot's effort as a session create body spells it. The runtime's field is
|
|
29
|
+
* `variant` because a harness may accept a thinking level that is not an
|
|
30
|
+
* effort, so every caller resolving a slot translates here instead of by hand.
|
|
31
|
+
*/
|
|
32
|
+
export declare function sessionVariantForEffort(effort: string | undefined): {
|
|
33
|
+
variant?: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function sessionModelGroupJson(group: SessionModelGroup | null | undefined): string | null;
|
|
36
|
+
/** A row written by an older build, or corrupted, reads back as no group at all. */
|
|
37
|
+
export declare function parseStoredSessionModelGroup(json: string | null | undefined): SessionModelGroup | undefined;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { ExecutionAvailability } from "./availability";
|
|
2
|
+
import type { AgentAgentPartInput, AgentFilePartInput, AgentTextPartInput } from "./content";
|
|
3
|
+
export type AgentWorkspaceIdentity = {
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
directory: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The complete identity required for any provider-owned execution operation.
|
|
9
|
+
* `upstreamSessionId` is opaque: Claxedo stores and forwards it but never
|
|
10
|
+
* parses it or uses it to discover sessions.
|
|
11
|
+
*/
|
|
12
|
+
export type AgentWorkspaceExecutionBinding = AgentWorkspaceIdentity & {
|
|
13
|
+
scope?: "workspace";
|
|
14
|
+
sessionId: string;
|
|
15
|
+
connectionId: string;
|
|
16
|
+
upstreamSessionId: string;
|
|
17
|
+
};
|
|
18
|
+
export type AgentExecutionBinding = AgentWorkspaceExecutionBinding;
|
|
19
|
+
export type AgentExecutionBindingField = keyof AgentExecutionBinding;
|
|
20
|
+
export type AgentExecutionBindingExpectation = Readonly<{
|
|
21
|
+
scope?: "workspace";
|
|
22
|
+
sessionId: string;
|
|
23
|
+
workspaceId?: string;
|
|
24
|
+
directory: string;
|
|
25
|
+
connectionId: string;
|
|
26
|
+
upstreamSessionId: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type AgentSession = {
|
|
29
|
+
id: string;
|
|
30
|
+
workspaceId?: string;
|
|
31
|
+
title?: string | null;
|
|
32
|
+
slug?: string;
|
|
33
|
+
version?: string;
|
|
34
|
+
directory?: string;
|
|
35
|
+
parentID?: string;
|
|
36
|
+
rootID?: string;
|
|
37
|
+
projectID?: string;
|
|
38
|
+
tags?: unknown[];
|
|
39
|
+
attachments?: unknown[];
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
time?: {
|
|
42
|
+
created: number;
|
|
43
|
+
updated?: number;
|
|
44
|
+
archived?: number;
|
|
45
|
+
};
|
|
46
|
+
status?: string | null;
|
|
47
|
+
lastTurn?: AgentTurnOutcome;
|
|
48
|
+
executionAvailability?: ExecutionAvailability;
|
|
49
|
+
harnessPayload?: unknown;
|
|
50
|
+
};
|
|
51
|
+
export type AgentPresentationSession = AgentSession & {
|
|
52
|
+
tags?: string[];
|
|
53
|
+
slug: string;
|
|
54
|
+
projectID: string;
|
|
55
|
+
workspaceID?: string;
|
|
56
|
+
directory: string;
|
|
57
|
+
path?: string;
|
|
58
|
+
parentID?: string;
|
|
59
|
+
summary?: {
|
|
60
|
+
additions: number;
|
|
61
|
+
deletions: number;
|
|
62
|
+
files: number;
|
|
63
|
+
diffs?: import("./content").AgentSnapshotFileDiff[];
|
|
64
|
+
};
|
|
65
|
+
cost?: number;
|
|
66
|
+
tokens?: {
|
|
67
|
+
input: number;
|
|
68
|
+
output: number;
|
|
69
|
+
reasoning: number;
|
|
70
|
+
cache: {
|
|
71
|
+
read: number;
|
|
72
|
+
write: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
share?: {
|
|
76
|
+
url: string;
|
|
77
|
+
};
|
|
78
|
+
title: string;
|
|
79
|
+
agent?: string;
|
|
80
|
+
model?: {
|
|
81
|
+
id: string;
|
|
82
|
+
providerID: string;
|
|
83
|
+
variant?: string;
|
|
84
|
+
};
|
|
85
|
+
version: string;
|
|
86
|
+
permission?: Array<{
|
|
87
|
+
permission: string;
|
|
88
|
+
pattern: string;
|
|
89
|
+
action: "allow" | "deny" | "ask";
|
|
90
|
+
}>;
|
|
91
|
+
revert?: {
|
|
92
|
+
messageID: string;
|
|
93
|
+
partID?: string;
|
|
94
|
+
snapshot?: string;
|
|
95
|
+
diff?: string;
|
|
96
|
+
};
|
|
97
|
+
time: {
|
|
98
|
+
created: number;
|
|
99
|
+
updated: number;
|
|
100
|
+
archived?: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export type AgentTurnOutcome = ({
|
|
104
|
+
status: "completed";
|
|
105
|
+
completedAt: number;
|
|
106
|
+
reason?: string;
|
|
107
|
+
} | {
|
|
108
|
+
status: "failed";
|
|
109
|
+
completedAt: number;
|
|
110
|
+
error: string;
|
|
111
|
+
} | {
|
|
112
|
+
status: "cancelled";
|
|
113
|
+
completedAt: number;
|
|
114
|
+
reason?: string;
|
|
115
|
+
}) & {
|
|
116
|
+
assistantMessageId?: string;
|
|
117
|
+
};
|
|
118
|
+
export type PromptModel = {
|
|
119
|
+
providerID: string;
|
|
120
|
+
modelID: string;
|
|
121
|
+
};
|
|
122
|
+
export type PromptFormat = {
|
|
123
|
+
type: "json_schema";
|
|
124
|
+
name?: string;
|
|
125
|
+
schema?: unknown;
|
|
126
|
+
strict?: boolean;
|
|
127
|
+
provider_payload?: unknown;
|
|
128
|
+
} | {
|
|
129
|
+
type: string;
|
|
130
|
+
provider_payload?: unknown;
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
};
|
|
133
|
+
export type PromptInput = {
|
|
134
|
+
parts: Array<AgentTextPartInput | AgentFilePartInput | AgentAgentPartInput>;
|
|
135
|
+
userMessageId?: string;
|
|
136
|
+
/** Existing user intent that owns a provider-initiated continuation. */
|
|
137
|
+
parentMessageId?: string;
|
|
138
|
+
assistantMessageId: string;
|
|
139
|
+
agent: string;
|
|
140
|
+
model: PromptModel;
|
|
141
|
+
tools?: Record<string, boolean>;
|
|
142
|
+
format?: PromptFormat;
|
|
143
|
+
system?: string;
|
|
144
|
+
variant?: string;
|
|
145
|
+
permissionMode?: string;
|
|
146
|
+
/**
|
|
147
|
+
* What to do when the session is already running a turn. `steer` hands this
|
|
148
|
+
* prompt to that turn; `queue` holds it for the next one. Absent means the
|
|
149
|
+
* caller wants a turn of its own and will take an admission conflict.
|
|
150
|
+
*/
|
|
151
|
+
delivery?: PromptDeliveryRequest;
|
|
152
|
+
author?: AgentMessageAuthor;
|
|
153
|
+
};
|
|
154
|
+
export type PromptDeliveryRequest = "steer" | "queue";
|
|
155
|
+
/** How a prompt was admitted. `start` ran it as a turn of its own. */
|
|
156
|
+
export type PromptDelivery = "start" | PromptDeliveryRequest;
|
|
157
|
+
export type AgentMessageAuthor = {
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
avatarUrl?: string;
|
|
161
|
+
kind: "human" | "agent";
|
|
162
|
+
};
|
|
163
|
+
export declare function connectionIdForHarness(harness: {
|
|
164
|
+
id: string;
|
|
165
|
+
access: string;
|
|
166
|
+
}): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Claxedo name for each plan-usage window slot a vendor reports.
|
|
3
|
+
*
|
|
4
|
+
* Data only, and in the contract package because four readers spell the same
|
|
5
|
+
* three windows differently — the HTTP verifier, the Codex app-server
|
|
6
|
+
* self-report, the machine-wide probe and the Claude event adapter — and a
|
|
7
|
+
* window named one way by the writer and another by the reader draws as two
|
|
8
|
+
* plans.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Per harness, because one table across vendors would label half of them
|
|
12
|
+
* wrongly: `primary_window` is a session for Codex and the whole billing cycle
|
|
13
|
+
* for Cursor. A harness, or a slot, that is not listed keeps the vendor's own
|
|
14
|
+
* field name — inventing a tier name for it would rot on the next vendor change
|
|
15
|
+
* without anything failing.
|
|
16
|
+
*/
|
|
17
|
+
export declare const USAGE_WINDOW_NAMES: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
18
|
+
/**
|
|
19
|
+
* Codex's own usage read names a window by its declared `limit_window_seconds`
|
|
20
|
+
* rather than by the slot it arrives in: a free plan gets only the weekly
|
|
21
|
+
* window, delivered in the primary slot.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CODEX_WINDOW_NAME_BY_SECONDS: Readonly<Record<number, string>>;
|
package/dist/values.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural guards for values crossing a boundary into the contract types.
|
|
3
|
+
*
|
|
4
|
+
* A payload arriving as JSON, an IPC message, or a database row is `unknown`.
|
|
5
|
+
* These guards are how it becomes typed: they narrow by checking, so nothing
|
|
6
|
+
* downstream has to assert.
|
|
7
|
+
*/
|
|
8
|
+
export { asRecord, isRecord } from "@claxedo/helpers/guards";
|
|
9
|
+
/** The non-empty string `value` holds, or `undefined`. */
|
|
10
|
+
export declare function asText(value: unknown): string | undefined;
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"description": "Dependency-free canonical contracts for Claxedo agent sessions, content, execution, errors, and events",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/kyashrathore/Claxedo.git",
|
|
8
|
+
"directory": "packages/agent-runtime-contract"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"claxedo",
|
|
12
|
+
"agents",
|
|
13
|
+
"contracts",
|
|
14
|
+
"sessions",
|
|
15
|
+
"events"
|
|
16
|
+
],
|
|
17
|
+
"main": "./dist/index.mjs",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"development": "./src/index.ts",
|
|
22
|
+
"bun": "./src/index.ts",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"default": "./dist/index.mjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE",
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"name": "@claxedo/agent-runtime-contract",
|
|
37
|
+
"version": "0.8.0",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "bun build src/index.ts --target=browser --format=esm --outfile=dist/index.mjs && tsc -p tsconfig.build.json",
|
|
40
|
+
"test:node": "node --test scripts/package.test.mjs",
|
|
41
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
42
|
+
"test": "bun test src",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@claxedo/helpers": "0.1.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@tsconfig/bun": "1.0.9",
|
|
50
|
+
"@types/bun": "1.3.13",
|
|
51
|
+
"typescript": "catalog:"
|
|
52
|
+
}
|
|
53
|
+
}
|