@agentoryhq/shared 0.1.1
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 +7 -0
- package/dist/index.d.ts +238 -0
- package/dist/index.js +98 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @agentoryhq/shared
|
|
2
|
+
|
|
3
|
+
Wire / DTO types shared by **agentory-node** adapters and (separately) the private Agentory control plane.
|
|
4
|
+
|
|
5
|
+
This package is **types + small helpers only** — no seat/quota enforcement, no HTTP server, no database. Enforcement and commercial logic live in the private product API.
|
|
6
|
+
|
|
7
|
+
Published under Apache-2.0 as part of the [agentory-node](https://github.com/tunsuy/agentory-node) open-source surface.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
export declare const PKG_VERSION = "0.1.1";
|
|
2
|
+
export declare const DEFAULT_API_PORT = 8787;
|
|
3
|
+
export declare const DEFAULT_CONSOLE_PORT = 5173;
|
|
4
|
+
export type HealthBody = {
|
|
5
|
+
ok: true;
|
|
6
|
+
service: "api" | "console" | "node";
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
export type Role = "owner" | "member";
|
|
10
|
+
export type WorkspacePlan = "free" | "pro";
|
|
11
|
+
export type Workspace = {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
/** Max memberships (Owner counts). Default from WORKSPACE_DEFAULT_SEAT_LIMIT. */
|
|
16
|
+
seatLimit: number;
|
|
17
|
+
/** free | pro — quotas only; no cashier. Default WORKSPACE_DEFAULT_PLAN. */
|
|
18
|
+
plan: WorkspacePlan;
|
|
19
|
+
/** Max active (non-revoked) nodes. */
|
|
20
|
+
nodeLimit: number;
|
|
21
|
+
/** Max lifetime successful align.confirm actions. */
|
|
22
|
+
alignConfirmLimit: number;
|
|
23
|
+
};
|
|
24
|
+
export type SeatsInfo = {
|
|
25
|
+
used: number;
|
|
26
|
+
limit: number;
|
|
27
|
+
};
|
|
28
|
+
export type NodesQuotaInfo = {
|
|
29
|
+
used: number;
|
|
30
|
+
limit: number;
|
|
31
|
+
};
|
|
32
|
+
export type AlignQuotaInfo = {
|
|
33
|
+
used: number;
|
|
34
|
+
limit: number;
|
|
35
|
+
};
|
|
36
|
+
export type Membership = {
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
email: string;
|
|
39
|
+
role: Role;
|
|
40
|
+
};
|
|
41
|
+
export type DesiredCatalog = {
|
|
42
|
+
workspaceId: string;
|
|
43
|
+
mcp: {
|
|
44
|
+
name: string;
|
|
45
|
+
command?: string;
|
|
46
|
+
}[];
|
|
47
|
+
skills: string[];
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
};
|
|
50
|
+
export type AlignDiffAction = "add" | "update" | "keep" | "keep_live";
|
|
51
|
+
export type AlignDiffItem = {
|
|
52
|
+
kind: "mcp" | "skill";
|
|
53
|
+
name: string;
|
|
54
|
+
action: AlignDiffAction;
|
|
55
|
+
/** live 与 desired 冲突;写入时以期望态为准 */
|
|
56
|
+
conflict: boolean;
|
|
57
|
+
liveCommand?: string;
|
|
58
|
+
desiredCommand?: string;
|
|
59
|
+
note?: string;
|
|
60
|
+
};
|
|
61
|
+
export type AlignPatch = {
|
|
62
|
+
mcp: {
|
|
63
|
+
name: string;
|
|
64
|
+
command?: string;
|
|
65
|
+
}[];
|
|
66
|
+
skills: string[];
|
|
67
|
+
};
|
|
68
|
+
export type AlignPlanStatus = "pending_confirm" | "confirmed" | "applied" | "failed" | "cancelled";
|
|
69
|
+
export type AlignPlan = {
|
|
70
|
+
id: string;
|
|
71
|
+
workspaceId: string;
|
|
72
|
+
agentId: string;
|
|
73
|
+
nodeId: string;
|
|
74
|
+
runtime: RuntimeKind;
|
|
75
|
+
status: AlignPlanStatus;
|
|
76
|
+
diff: AlignDiffItem[];
|
|
77
|
+
patch: AlignPatch;
|
|
78
|
+
createdAt: string;
|
|
79
|
+
createdBy: string;
|
|
80
|
+
confirmedAt?: string;
|
|
81
|
+
confirmedBy?: string;
|
|
82
|
+
appliedAt?: string;
|
|
83
|
+
resultError?: string;
|
|
84
|
+
snapshotPath?: string;
|
|
85
|
+
};
|
|
86
|
+
/** Supported first; others may be discovered but not aligned. */
|
|
87
|
+
export type RuntimeKind = "cursor" | "claude-code" | "unknown";
|
|
88
|
+
/** 目录条目状态:已支持纳管 / 规划中(仅展示,不进数据模型) */
|
|
89
|
+
export type CatalogStatus = "supported" | "planned";
|
|
90
|
+
/** Agent 页 runtime 目录条目(静态能力清单 SSOT;实例数由发现数据聚合,不在此) */
|
|
91
|
+
export type RuntimeCatalogEntry = {
|
|
92
|
+
runtime: RuntimeKind | string;
|
|
93
|
+
displayName: string;
|
|
94
|
+
description: string;
|
|
95
|
+
status: CatalogStatus;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* 常见 Agent runtime 目录。静态能力清单:0 实例也常驻展示(「未接入 · 0」),
|
|
99
|
+
* 实例计数与实例列表一律来自真实发现数据(console 前端按 runtime 聚合)。
|
|
100
|
+
* 顺序即展示顺序:已支持在前,规划中在后。
|
|
101
|
+
*/
|
|
102
|
+
export declare const RUNTIME_CATALOG: RuntimeCatalogEntry[];
|
|
103
|
+
export type McpHealthStatus = "healthy" | "degraded" | "failed" | "unknown";
|
|
104
|
+
export type LiveMcpBinding = {
|
|
105
|
+
name: string;
|
|
106
|
+
command?: string;
|
|
107
|
+
status: McpHealthStatus;
|
|
108
|
+
/** 失败 / 降级时必填可读原因 */
|
|
109
|
+
reason?: string;
|
|
110
|
+
};
|
|
111
|
+
export type DiscoveredAgent = {
|
|
112
|
+
runtime: RuntimeKind;
|
|
113
|
+
/** false → 可展示,不进入对齐 */
|
|
114
|
+
supported: boolean;
|
|
115
|
+
displayName: string;
|
|
116
|
+
mcp: LiveMcpBinding[];
|
|
117
|
+
skills: string[];
|
|
118
|
+
};
|
|
119
|
+
export type AgentRecord = DiscoveredAgent & {
|
|
120
|
+
id: string;
|
|
121
|
+
workspaceId: string;
|
|
122
|
+
nodeId: string;
|
|
123
|
+
discoveredAt: string;
|
|
124
|
+
};
|
|
125
|
+
export type NodeRecord = {
|
|
126
|
+
id: string;
|
|
127
|
+
workspaceId: string;
|
|
128
|
+
name: string;
|
|
129
|
+
hostname: string;
|
|
130
|
+
lastHeartbeatAt: string | null;
|
|
131
|
+
createdAt: string;
|
|
132
|
+
/** ISO timestamp when Owner revoked; null = active */
|
|
133
|
+
revokedAt: string | null;
|
|
134
|
+
};
|
|
135
|
+
/** Read-only Cursor session metadata (no message body). */
|
|
136
|
+
export type SessionIndexReportItem = {
|
|
137
|
+
sourceKey: string;
|
|
138
|
+
displayName: string;
|
|
139
|
+
projectPath?: string;
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
};
|
|
142
|
+
/** Read-only memory/rules metadata (no file body). */
|
|
143
|
+
export type MemoryIndexReportItem = {
|
|
144
|
+
sourceKey: string;
|
|
145
|
+
kind: "memory" | "rules";
|
|
146
|
+
pathLabel: string;
|
|
147
|
+
projectPath?: string;
|
|
148
|
+
updatedAt: string;
|
|
149
|
+
};
|
|
150
|
+
export type SessionIndexEntry = SessionIndexReportItem & {
|
|
151
|
+
id: string;
|
|
152
|
+
workspaceId: string;
|
|
153
|
+
nodeId: string;
|
|
154
|
+
runtime: "cursor";
|
|
155
|
+
discoveredAt: string;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Transcript message frozen by a node for on-demand review (model B).
|
|
159
|
+
* Desensitized + windowed on the NODE side before leaving the machine.
|
|
160
|
+
* (S-tier: brief §5 AC-3/AC-4)
|
|
161
|
+
*/
|
|
162
|
+
export type TranscriptMessage = {
|
|
163
|
+
role: "user" | "assistant";
|
|
164
|
+
ts: string;
|
|
165
|
+
text: string;
|
|
166
|
+
};
|
|
167
|
+
export type TranscriptSnapshot = {
|
|
168
|
+
/** sourceKey of the session index entry this snapshot belongs to */
|
|
169
|
+
sourceKey: string;
|
|
170
|
+
messages: TranscriptMessage[];
|
|
171
|
+
/** true when the message window was truncated (AC-4) */
|
|
172
|
+
truncated: boolean;
|
|
173
|
+
/** "27 of 67 messages" style hint when truncated */
|
|
174
|
+
windowTotal?: string;
|
|
175
|
+
/** captured (node-side) ISO timestamp */
|
|
176
|
+
capturedAt: string;
|
|
177
|
+
};
|
|
178
|
+
export type MemoryIndexEntry = MemoryIndexReportItem & {
|
|
179
|
+
id: string;
|
|
180
|
+
workspaceId: string;
|
|
181
|
+
nodeId: string;
|
|
182
|
+
runtime: "cursor";
|
|
183
|
+
discoveredAt: string;
|
|
184
|
+
};
|
|
185
|
+
export type AssetIndexFilter = {
|
|
186
|
+
projectPath?: string;
|
|
187
|
+
/** keyword; matches displayName/pathLabel or projectPath (case-insensitive) */
|
|
188
|
+
q?: string;
|
|
189
|
+
/** ISO timestamp; entries with updatedAt >= since */
|
|
190
|
+
since?: string;
|
|
191
|
+
/** memory index: restrict to kind (memory|rules); unset = all */
|
|
192
|
+
kind?: "memory" | "rules";
|
|
193
|
+
};
|
|
194
|
+
/** Context item frozen into a handoff package (metadata only, no body). */
|
|
195
|
+
export type HandoffContextSession = {
|
|
196
|
+
displayName: string;
|
|
197
|
+
projectPath?: string;
|
|
198
|
+
updatedAt: string;
|
|
199
|
+
};
|
|
200
|
+
export type HandoffContextMemory = {
|
|
201
|
+
kind: "memory" | "rules";
|
|
202
|
+
pathLabel: string;
|
|
203
|
+
displayName?: string;
|
|
204
|
+
projectPath?: string;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
};
|
|
207
|
+
export type HandoffRecord = {
|
|
208
|
+
id: string;
|
|
209
|
+
workspaceId: string;
|
|
210
|
+
fromAgentId: string;
|
|
211
|
+
toAgentId: string;
|
|
212
|
+
fromRuntime: string;
|
|
213
|
+
toRuntime: string;
|
|
214
|
+
note?: string;
|
|
215
|
+
status: "created" | "acknowledged";
|
|
216
|
+
depth: "package";
|
|
217
|
+
context: {
|
|
218
|
+
sessions: HandoffContextSession[];
|
|
219
|
+
memories: HandoffContextMemory[];
|
|
220
|
+
};
|
|
221
|
+
createdAt: string;
|
|
222
|
+
acknowledgedAt?: string;
|
|
223
|
+
acknowledgedBy?: string;
|
|
224
|
+
};
|
|
225
|
+
export type AssetIndexPage = {
|
|
226
|
+
/** page size; 1..500 */
|
|
227
|
+
limit: number;
|
|
228
|
+
/** zero-based row offset */
|
|
229
|
+
offset: number;
|
|
230
|
+
};
|
|
231
|
+
export declare function controlPlaneBaseUrl(): string;
|
|
232
|
+
export declare function listenPort(envName: string, fallback: number): number;
|
|
233
|
+
/** Bind address. Default loopback; set `LISTEN_HOST=0.0.0.0` for containers. */
|
|
234
|
+
export declare function listenHost(fallback?: string): string;
|
|
235
|
+
export declare function jsonHealth(service: HealthBody["service"]): HealthBody;
|
|
236
|
+
export declare function maskSecret(token: string): string;
|
|
237
|
+
export declare function worstMcpStatus(statuses: McpHealthStatus[]): McpHealthStatus;
|
|
238
|
+
export declare function isMcpHealthStatus(v: unknown): v is McpHealthStatus;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const PKG_VERSION = "0.1.1";
|
|
2
|
+
export const DEFAULT_API_PORT = 8787;
|
|
3
|
+
export const DEFAULT_CONSOLE_PORT = 5173;
|
|
4
|
+
/**
|
|
5
|
+
* 常见 Agent runtime 目录。静态能力清单:0 实例也常驻展示(「未接入 · 0」),
|
|
6
|
+
* 实例计数与实例列表一律来自真实发现数据(console 前端按 runtime 聚合)。
|
|
7
|
+
* 顺序即展示顺序:已支持在前,规划中在后。
|
|
8
|
+
*/
|
|
9
|
+
export const RUNTIME_CATALOG = [
|
|
10
|
+
{
|
|
11
|
+
runtime: "cursor",
|
|
12
|
+
displayName: "Cursor",
|
|
13
|
+
description: "IDE 内置 Agent",
|
|
14
|
+
status: "supported",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
runtime: "claude-code",
|
|
18
|
+
displayName: "Claude Code",
|
|
19
|
+
description: "终端 Agent",
|
|
20
|
+
status: "supported",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
runtime: "codex",
|
|
24
|
+
displayName: "Codex",
|
|
25
|
+
description: "OpenAI 终端 Agent",
|
|
26
|
+
status: "planned",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
runtime: "gemini-cli",
|
|
30
|
+
displayName: "Gemini CLI",
|
|
31
|
+
description: "Google 终端 Agent",
|
|
32
|
+
status: "planned",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
runtime: "opencode",
|
|
36
|
+
displayName: "OpenCode",
|
|
37
|
+
description: "开源终端 Agent",
|
|
38
|
+
status: "planned",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
runtime: "lingma",
|
|
42
|
+
displayName: "通义灵码",
|
|
43
|
+
description: "阿里云 · IDE 插件 + CLI",
|
|
44
|
+
status: "planned",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
runtime: "trae",
|
|
48
|
+
displayName: "Trae",
|
|
49
|
+
description: "字节跳动 · AI IDE",
|
|
50
|
+
status: "planned",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
runtime: "codebuddy",
|
|
54
|
+
displayName: "CodeBuddy",
|
|
55
|
+
description: "腾讯 · IDE 插件 + CLI",
|
|
56
|
+
status: "planned",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
runtime: "comate",
|
|
60
|
+
displayName: "文心快码",
|
|
61
|
+
description: "百度 · IDE 插件",
|
|
62
|
+
status: "planned",
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
export function controlPlaneBaseUrl() {
|
|
66
|
+
const raw = process.env.CONTROL_PLANE_BASE_URL?.trim();
|
|
67
|
+
if (raw)
|
|
68
|
+
return raw.replace(/\/$/, "");
|
|
69
|
+
return `http://127.0.0.1:${DEFAULT_API_PORT}`;
|
|
70
|
+
}
|
|
71
|
+
export function listenPort(envName, fallback) {
|
|
72
|
+
const n = Number(process.env[envName]);
|
|
73
|
+
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
74
|
+
}
|
|
75
|
+
/** Bind address. Default loopback; set `LISTEN_HOST=0.0.0.0` for containers. */
|
|
76
|
+
export function listenHost(fallback = "127.0.0.1") {
|
|
77
|
+
const raw = process.env.LISTEN_HOST?.trim();
|
|
78
|
+
return raw || fallback;
|
|
79
|
+
}
|
|
80
|
+
export function jsonHealth(service) {
|
|
81
|
+
return { ok: true, service, version: PKG_VERSION };
|
|
82
|
+
}
|
|
83
|
+
export function maskSecret(token) {
|
|
84
|
+
if (token.length <= 8)
|
|
85
|
+
return "••••";
|
|
86
|
+
return `${token.slice(0, 4)}••••${token.slice(-2)}`;
|
|
87
|
+
}
|
|
88
|
+
const MCP_STATUS_ORDER = ["failed", "degraded", "unknown", "healthy"];
|
|
89
|
+
export function worstMcpStatus(statuses) {
|
|
90
|
+
for (const s of MCP_STATUS_ORDER) {
|
|
91
|
+
if (statuses.includes(s))
|
|
92
|
+
return s;
|
|
93
|
+
}
|
|
94
|
+
return "unknown";
|
|
95
|
+
}
|
|
96
|
+
export function isMcpHealthStatus(v) {
|
|
97
|
+
return v === "healthy" || v === "degraded" || v === "failed" || v === "unknown";
|
|
98
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentoryhq/shared",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Agentory wire/DTO types for node adapters and control-plane clients",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": ["dist", "README.md"],
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/tunsuy/agentory-node.git",
|
|
20
|
+
"directory": "packages/shared"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
}
|
|
28
|
+
}
|