@fa-software/semi2-dsh 0.0.11 → 0.0.13-preview.20260921160207
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/lib/api/client.js +1 -0
- package/lib/api/generated/documents.js +11 -0
- package/lib/api/generated/schema.js +43 -0
- package/lib/api/index.js +19 -1
- package/lib/contract.js +6 -5
- package/lib/domains/default-model/domain.js +3 -0
- package/lib/index.js +10 -0
- package/lib/service/audit.js +23 -0
- package/lib/service/config-service.js +24 -0
- package/lib/service/lifecycle.js +15 -0
- package/lib/service/publish.js +7 -0
- package/lib/types/api/client.d.ts +2 -0
- package/lib/types/api/generated/documents.d.ts +3 -1
- package/lib/types/api/generated/graphql.d.ts +31 -0
- package/lib/types/api/generated/schema.d.ts +130 -32
- package/lib/types/api/index.d.ts +18 -0
- package/lib/types/contract.d.ts +6 -1
- package/lib/types/domains/types.d.ts +4 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/service/audit.d.ts +6 -0
- package/lib/types/service/config-service.d.ts +11 -0
- package/package.json +1 -1
package/lib/api/client.js
CHANGED
|
@@ -91,6 +91,7 @@ export async function postGraphql(client, request) {
|
|
|
91
91
|
...(client.creator === undefined
|
|
92
92
|
? {}
|
|
93
93
|
: { 'x-semi2-cnb-creator': client.creator }),
|
|
94
|
+
...(client.face === undefined ? {} : { 'x-semi2-face': client.face }),
|
|
94
95
|
},
|
|
95
96
|
cache: 'no-store',
|
|
96
97
|
redirect: 'error',
|
|
@@ -73,10 +73,21 @@ export const RUNTIME_MODEL_CREDENTIALS_DOCUMENT = `query RuntimeModelCredentials
|
|
|
73
73
|
value
|
|
74
74
|
}
|
|
75
75
|
}`;
|
|
76
|
+
/** 运行面生命周期上报(会话启停 / 拒绝 / 交付分支与核对):`action` 与 `outcome` 用 SDL 枚举名,失败只 warn 降级。 */
|
|
77
|
+
export const RUNTIME_REPORT_EVENT_DOCUMENT = `mutation RuntimeReportEvent($input: RuntimeEventInput!) {
|
|
78
|
+
runtimeReportEvent(input: $input) {
|
|
79
|
+
id
|
|
80
|
+
action
|
|
81
|
+
outcome
|
|
82
|
+
code
|
|
83
|
+
occurredAt
|
|
84
|
+
}
|
|
85
|
+
}`;
|
|
76
86
|
/** 全部操作名(契约测试用:领域声明的操作必须都在这里)。 */
|
|
77
87
|
export const API_OPERATIONS = [
|
|
78
88
|
'RuntimeBoot',
|
|
79
89
|
'RuntimeSkillFiles',
|
|
80
90
|
'RuntimeWorkspaceProjects',
|
|
81
91
|
'RuntimeModelCredentials',
|
|
92
|
+
'RuntimeReportEvent',
|
|
82
93
|
];
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
/** 身份来源:会话 / 用户密钥 / 接入密钥 / 匿名(登录失败、无效密钥)。 */
|
|
2
|
+
export var AuditActorKind;
|
|
3
|
+
(function (AuditActorKind) {
|
|
4
|
+
AuditActorKind["AccessKey"] = "ACCESS_KEY";
|
|
5
|
+
AuditActorKind["Anonymous"] = "ANONYMOUS";
|
|
6
|
+
AuditActorKind["Session"] = "SESSION";
|
|
7
|
+
AuditActorKind["UserKey"] = "USER_KEY";
|
|
8
|
+
})(AuditActorKind || (AuditActorKind = {}));
|
|
9
|
+
/** 审查类别:读 / 写 / 身份凭据 / 运行面生命周期。 */
|
|
10
|
+
export var AuditCategory;
|
|
11
|
+
(function (AuditCategory) {
|
|
12
|
+
AuditCategory["Auth"] = "AUTH";
|
|
13
|
+
AuditCategory["Read"] = "READ";
|
|
14
|
+
AuditCategory["Runtime"] = "RUNTIME";
|
|
15
|
+
AuditCategory["Write"] = "WRITE";
|
|
16
|
+
})(AuditCategory || (AuditCategory = {}));
|
|
17
|
+
/** 来源面:控制台 / NPC / 云开发工作站 / 容器 Web / 宿主直跑 / 未标注。 */
|
|
18
|
+
export var AuditChannel;
|
|
19
|
+
(function (AuditChannel) {
|
|
20
|
+
AuditChannel["Console"] = "CONSOLE";
|
|
21
|
+
AuditChannel["ContainerWeb"] = "CONTAINER_WEB";
|
|
22
|
+
AuditChannel["Host"] = "HOST";
|
|
23
|
+
AuditChannel["Npc"] = "NPC";
|
|
24
|
+
AuditChannel["Unknown"] = "UNKNOWN";
|
|
25
|
+
AuditChannel["Workstation"] = "WORKSTATION";
|
|
26
|
+
})(AuditChannel || (AuditChannel = {}));
|
|
27
|
+
/** 结果:SUCCESS = 完成;DENIED = 身份 / 权限 / 来源被拒;ERROR = 领域校验或冲突失败。 */
|
|
28
|
+
export var AuditOutcome;
|
|
29
|
+
(function (AuditOutcome) {
|
|
30
|
+
AuditOutcome["Denied"] = "DENIED";
|
|
31
|
+
AuditOutcome["Error"] = "ERROR";
|
|
32
|
+
AuditOutcome["Success"] = "SUCCESS";
|
|
33
|
+
})(AuditOutcome || (AuditOutcome = {}));
|
|
1
34
|
/** 账户的 CNB 连接态。AWAITING_BINDING = 账户由上游目录预建,还没绑定本人令牌。 */
|
|
2
35
|
export var CnbConnectionState;
|
|
3
36
|
(function (CnbConnectionState) {
|
|
@@ -74,6 +107,16 @@ export var Role;
|
|
|
74
107
|
Role["Admin"] = "ADMIN";
|
|
75
108
|
Role["User"] = "USER";
|
|
76
109
|
})(Role || (Role = {}));
|
|
110
|
+
/** 运行面可上报的动作:会话启停、拒绝、交付分支与交付核对。 */
|
|
111
|
+
export var RuntimeEventAction;
|
|
112
|
+
(function (RuntimeEventAction) {
|
|
113
|
+
RuntimeEventAction["DeliveryReady"] = "DELIVERY_READY";
|
|
114
|
+
RuntimeEventAction["DeliveryVerified"] = "DELIVERY_VERIFIED";
|
|
115
|
+
RuntimeEventAction["SessionEnd"] = "SESSION_END";
|
|
116
|
+
RuntimeEventAction["SessionFailed"] = "SESSION_FAILED";
|
|
117
|
+
RuntimeEventAction["SessionRefused"] = "SESSION_REFUSED";
|
|
118
|
+
RuntimeEventAction["SessionStart"] = "SESSION_START";
|
|
119
|
+
})(RuntimeEventAction || (RuntimeEventAction = {}));
|
|
77
120
|
/** 技能附件内容的编码:文本类用 UTF8,其余(图片 / 二进制)用 BASE64。 */
|
|
78
121
|
export var SkillFileEncoding;
|
|
79
122
|
(function (SkillFileEncoding) {
|
package/lib/api/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { consoleEndpoint, postGraphql } from './client.js';
|
|
2
|
-
import { RUNTIME_BOOT_DOCUMENT, RUNTIME_MODEL_CREDENTIALS_DOCUMENT, RUNTIME_SKILL_FILES_DOCUMENT, RUNTIME_WORKSPACE_PROJECTS_DOCUMENT, } from './generated/documents.js';
|
|
2
|
+
import { RUNTIME_REPORT_EVENT_DOCUMENT, RUNTIME_BOOT_DOCUMENT, RUNTIME_MODEL_CREDENTIALS_DOCUMENT, RUNTIME_SKILL_FILES_DOCUMENT, RUNTIME_WORKSPACE_PROJECTS_DOCUMENT, } from './generated/documents.js';
|
|
3
3
|
import { exchangeCnbToken, loginToConsole } from './login.js';
|
|
4
4
|
import { ConfigurationError } from '../hub/errors.js';
|
|
5
5
|
function text(value) {
|
|
@@ -18,6 +18,10 @@ export function createSemi2Api(options) {
|
|
|
18
18
|
token: connection.token,
|
|
19
19
|
...(options.fetchImpl === undefined ? {} : { fetchImpl: options.fetchImpl }),
|
|
20
20
|
...(creator === undefined ? {} : { creator }),
|
|
21
|
+
...(() => {
|
|
22
|
+
const face = options.readFace?.();
|
|
23
|
+
return face === undefined ? {} : { face };
|
|
24
|
+
})(),
|
|
21
25
|
}, {
|
|
22
26
|
operationName,
|
|
23
27
|
document,
|
|
@@ -34,5 +38,19 @@ export function createSemi2Api(options) {
|
|
|
34
38
|
modelCredentials: connectionIds => request('RuntimeModelCredentials', RUNTIME_MODEL_CREDENTIALS_DOCUMENT, connectionIds === undefined ? {} : { connectionIds }),
|
|
35
39
|
exchangeCnbToken: input => exchangeCnbToken(input, options.fetchImpl),
|
|
36
40
|
loginToConsole: input => loginToConsole(input, options.fetchImpl),
|
|
41
|
+
reportEvent: event => request('RuntimeReportEvent', RUNTIME_REPORT_EVENT_DOCUMENT, {
|
|
42
|
+
input: {
|
|
43
|
+
action: event.action,
|
|
44
|
+
outcome: event.outcome,
|
|
45
|
+
...(event.code === undefined ? {} : { code: event.code }),
|
|
46
|
+
...(event.projectSlug === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { projectSlug: event.projectSlug }),
|
|
49
|
+
...(event.targetLabel === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: { targetLabel: event.targetLabel }),
|
|
52
|
+
...(event.detail === undefined ? {} : { detail: event.detail }),
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
37
55
|
};
|
|
38
56
|
}
|
package/lib/contract.js
CHANGED
|
@@ -18,8 +18,8 @@ function credentialsFromEnv(env) {
|
|
|
18
18
|
...(accessToken === undefined ? {} : { accessToken }),
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function runtime(platform, fields) {
|
|
22
|
-
const contract = { platform };
|
|
21
|
+
function runtime(platform, face, fields) {
|
|
22
|
+
const contract = { platform, face };
|
|
23
23
|
if (fields.credentials !== undefined)
|
|
24
24
|
contract.credentials = fields.credentials;
|
|
25
25
|
return contract;
|
|
@@ -27,9 +27,10 @@ function runtime(platform, fields) {
|
|
|
27
27
|
/**
|
|
28
28
|
* CNB 运行面:优先用 secret import 注入的 hub 接入密钥(`SEMI2_ACCESS_TOKEN`),
|
|
29
29
|
* 缺失时才回退平台短期 `CNB_TOKEN`(插件启动时换成 hub 用户密钥)。
|
|
30
|
+
* face 由调用它的适配器给(NPC 面与云开发工作站面共用这条 env 通道)。
|
|
30
31
|
*/
|
|
31
|
-
export function runtimeFromCnbEnv(env) {
|
|
32
|
-
return runtime('cnb', { credentials: credentialsFromEnv(env) });
|
|
32
|
+
export function runtimeFromCnbEnv(env, face) {
|
|
33
|
+
return runtime('cnb', face, { credentials: credentialsFromEnv(env) });
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* 容器运行面:**只盖章,不给凭据也不给身份**——本地容器靠登录(设置页账号密码换用户密钥)。
|
|
@@ -38,5 +39,5 @@ export function runtimeFromCnbEnv(env) {
|
|
|
38
39
|
* CNB 面相反:身份取平台注入的触发 env、凭据取 secret 注入的 env,见 `runtimeFromCnbEnv`。
|
|
39
40
|
*/
|
|
40
41
|
export function runtimeFromContainerEnv(_env) {
|
|
41
|
-
return runtime('container', {});
|
|
42
|
+
return runtime('container', 'container-web', {});
|
|
42
43
|
}
|
|
@@ -64,6 +64,7 @@ export class DefaultModelDomain {
|
|
|
64
64
|
if (this.host.state().status !== 'ready')
|
|
65
65
|
return {
|
|
66
66
|
kind: 'refused',
|
|
67
|
+
code: 'CONFIG_NOT_READY',
|
|
67
68
|
reason: `控制台配置未就绪(status=${this.host.state().status}),无法确定项目与模型;本次不运行。`,
|
|
68
69
|
};
|
|
69
70
|
if (compiled === null)
|
|
@@ -73,12 +74,14 @@ export class DefaultModelDomain {
|
|
|
73
74
|
if (workspace === undefined)
|
|
74
75
|
return {
|
|
75
76
|
kind: 'refused',
|
|
77
|
+
code: 'NO_WORKSPACE',
|
|
76
78
|
reason: '本面没有工作区能力,无法确定项目;本次不运行。',
|
|
77
79
|
};
|
|
78
80
|
const project = await workspace.projectForCwd(input.cwd);
|
|
79
81
|
if (project === null)
|
|
80
82
|
return {
|
|
81
83
|
kind: 'refused',
|
|
84
|
+
code: 'NO_PROJECT_MATCH',
|
|
82
85
|
reason: '没有匹配到项目:请先在控制台「项目与访问」登记本仓库(slug 需与仓库路径一致,且项目为启用、上游正常),再到「模型接入」配好全局默认模型。',
|
|
83
86
|
};
|
|
84
87
|
const projectModelId = role === 'execute' ? project.executeModelId : project.planModelId;
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,16 @@ export function apply(ctx, _config) {
|
|
|
19
19
|
ctx.provide('semi2Config', configuration.config);
|
|
20
20
|
ctx.provide('semi2Session', configuration.session);
|
|
21
21
|
ctx.provide('semi2Health', configuration.health);
|
|
22
|
+
// 运行面(NPC 面)回报生命周期与交付事实的出口;上报失败只 warn。
|
|
23
|
+
ctx.provide('semi2Audit', configuration.audit);
|
|
24
|
+
// 优雅卸载 = 本面会话结束:进程被强杀(SIGKILL / 容器停止)没有结束行,属已知边界。
|
|
25
|
+
ctx.effect(() => () => {
|
|
26
|
+
void configuration.audit.report({
|
|
27
|
+
action: 'SESSION_END',
|
|
28
|
+
outcome: 'SUCCESS',
|
|
29
|
+
detail: { platform: configuration.config.platform, reason: 'dispose' },
|
|
30
|
+
});
|
|
31
|
+
});
|
|
22
32
|
// 索引由使用方建立、工具由官方 MCP 服务提供:插件侧没有可失败的后台动作,只标注开关状态。
|
|
23
33
|
configuration.registerHealth({
|
|
24
34
|
key: 'healthCodegraph',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** 生命周期事件:动作名与结果名都用 hub SDL 的枚举名,两侧不各维护一张映射表。 */
|
|
2
|
+
export async function reportEvent(engine, event) {
|
|
3
|
+
try {
|
|
4
|
+
if (engine.connection() === null)
|
|
5
|
+
return;
|
|
6
|
+
const outcome = await engine.api.reportEvent({
|
|
7
|
+
...event,
|
|
8
|
+
detail: { face: faceOf(engine), ...(event.detail ?? {}) },
|
|
9
|
+
});
|
|
10
|
+
if (outcome.data === null)
|
|
11
|
+
engine.warn(`运行面事件上报失败(${event.action}):${outcome.errorCode ?? '未知错误'}`);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
engine.warn(`运行面事件上报失败(${event.action}):${error instanceof Error ? error.message : String(error)}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** 本面标识:契约里有就用它;宿主直跑没有契约,记 host。 */
|
|
18
|
+
export function faceOf(engine) {
|
|
19
|
+
const declared = engine.contract()?.face;
|
|
20
|
+
if (declared !== undefined)
|
|
21
|
+
return declared;
|
|
22
|
+
return engine.platform === 'host' || engine.platform === null ? 'host' : 'unknown';
|
|
23
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSemi2Api } from '../api/index.js';
|
|
2
2
|
import { createPorts } from './ports.js';
|
|
3
3
|
import { Orchestrator } from './orchestrator.js';
|
|
4
|
+
import { faceOf } from './audit.js';
|
|
4
5
|
import * as lifecycle from './lifecycle.js';
|
|
5
6
|
/**
|
|
6
7
|
* 装配三个能力面并开始后台领取:领域挂载与首次取数都在后台——不阻塞插件树 settle,
|
|
@@ -22,6 +23,7 @@ export function installConfiguration(ctx, options = {}) {
|
|
|
22
23
|
createSemi2Api({
|
|
23
24
|
readConnection: () => engineRef.current?.connection() ?? null,
|
|
24
25
|
environment: { ...process.env },
|
|
26
|
+
readFace: () => engineRef.current?.contract()?.face,
|
|
25
27
|
}), ports, { ...process.env }, options);
|
|
26
28
|
engineRef.current = orchestrator;
|
|
27
29
|
void orchestrator
|
|
@@ -37,6 +39,28 @@ export function installConfiguration(ctx, options = {}) {
|
|
|
37
39
|
logout: () => lifecycle.logout(orchestrator),
|
|
38
40
|
},
|
|
39
41
|
health: { snapshot: () => orchestrator.healthSnapshot() },
|
|
42
|
+
audit: {
|
|
43
|
+
report: async (event) => {
|
|
44
|
+
if (orchestrator.connection() === null)
|
|
45
|
+
return { ok: false, code: 'MISSING_ACCESS_TOKEN' };
|
|
46
|
+
try {
|
|
47
|
+
const outcome = await orchestrator.api.reportEvent({
|
|
48
|
+
...event,
|
|
49
|
+
detail: {
|
|
50
|
+
face: faceOf(orchestrator),
|
|
51
|
+
...(event.detail ?? {}),
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return { ok: outcome.data !== null, code: outcome.errorCode };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
return {
|
|
58
|
+
ok: false,
|
|
59
|
+
code: error instanceof Error ? error.message : String(error),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
},
|
|
40
64
|
registerHealth: (contributor) => {
|
|
41
65
|
orchestrator.registerHealthContributor(contributor);
|
|
42
66
|
},
|
package/lib/service/lifecycle.js
CHANGED
|
@@ -5,6 +5,7 @@ import { installSections } from './settings-sections.js';
|
|
|
5
5
|
import { appliedState, publishFailed, publishStatus } from './publish.js';
|
|
6
6
|
import { readOwned, readWorkspaces } from './namespaces.js';
|
|
7
7
|
import { DOMAINS } from './registry.js';
|
|
8
|
+
import { reportEvent } from './audit.js';
|
|
8
9
|
import { connectionSnapshot, exchangeCnbCredential, resolveConnectionWithRetry, resolveContract, } from './connection.js';
|
|
9
10
|
/** 首次加载;未配凭据或失败只落到 state.error,绝不 throw,也不注入任何配置。 */
|
|
10
11
|
export async function start(engine) {
|
|
@@ -38,6 +39,20 @@ export async function start(engine) {
|
|
|
38
39
|
else
|
|
39
40
|
await load(engine);
|
|
40
41
|
await publishStatus(engine);
|
|
42
|
+
// 会话启动 = 首次配置领取成功;未配凭据 / 领取失败都不是「会话起来过」。
|
|
43
|
+
// NPC 面自己的会话起点由适配器上报(带触发事实),这里只覆盖另外两个 Web 面与宿主直跑。
|
|
44
|
+
if (engine.connection() !== null &&
|
|
45
|
+
engine.state().status === 'ready' &&
|
|
46
|
+
engine.contract()?.face !== 'npc')
|
|
47
|
+
await reportEvent(engine, {
|
|
48
|
+
action: 'SESSION_START',
|
|
49
|
+
outcome: 'SUCCESS',
|
|
50
|
+
detail: {
|
|
51
|
+
platform: engine.platform,
|
|
52
|
+
consoleUrl: engine.connection()?.url ?? null,
|
|
53
|
+
identity: engine.state().identity?.username ?? null,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
41
56
|
}
|
|
42
57
|
finally {
|
|
43
58
|
engine.settle();
|
package/lib/service/publish.js
CHANGED
|
@@ -3,6 +3,7 @@ import { SYNC_FIELD } from './settings-sections.js';
|
|
|
3
3
|
import { SETTINGS_NAMESPACE } from './namespaces.js';
|
|
4
4
|
import { aggregateHealth, healthText } from './health.js';
|
|
5
5
|
import { DOMAINS } from './registry.js';
|
|
6
|
+
import { reportEvent } from './audit.js';
|
|
6
7
|
/** 状态 + 健康 + 工作区 tab 一次写回(权威 replace;sync 字段复位为空,无令牌比对)。 */
|
|
7
8
|
export async function publishStatus(engine) {
|
|
8
9
|
const settings = engine.settings();
|
|
@@ -50,6 +51,12 @@ export async function publishFailed(engine, code) {
|
|
|
50
51
|
engine.emitConfigUpdated();
|
|
51
52
|
// 失败也必须回写设置页:登录成功但同步失败时,错误码是唯一提示(客户端按 error 渲染「最近失败」)。
|
|
52
53
|
await publishStatus(engine);
|
|
54
|
+
// 启动期的整体失败落一条运行面事件:判「本面起没起来」不必翻容器日志。
|
|
55
|
+
await reportEvent(engine, {
|
|
56
|
+
action: 'SESSION_FAILED',
|
|
57
|
+
outcome: 'ERROR',
|
|
58
|
+
code,
|
|
59
|
+
});
|
|
53
60
|
}
|
|
54
61
|
/** boot 事实 → ready 状态(技能切片取自 skills 领域;项目缓存随装配作废,由工作区同步重取)。 */
|
|
55
62
|
export function appliedState(engine, boot, compiled, errorCode) {
|
|
@@ -6,6 +6,8 @@ export interface GraphqlClientOptions {
|
|
|
6
6
|
token: string;
|
|
7
7
|
/** CNB 面:环境创建者的外部用户 id(平台注入 CNB_BUILD_USER_ID),供 hub 决定读取身份。 */
|
|
8
8
|
creator?: string;
|
|
9
|
+
/** 本面标识(适配器在运行面契约里盖章):hub 审查日志据此区分来源面。 */
|
|
10
|
+
face?: string;
|
|
9
11
|
fetchImpl?: typeof fetch;
|
|
10
12
|
}
|
|
11
13
|
export interface GraphqlRequest {
|
|
@@ -6,6 +6,8 @@ export declare const RUNTIME_SKILL_FILES_DOCUMENT = "query RuntimeSkillFiles($sk
|
|
|
6
6
|
export declare const RUNTIME_WORKSPACE_PROJECTS_DOCUMENT = "query RuntimeWorkspaceProjects($slugs: [String!]) {\n runtimeProjects(slugs: $slugs) {\n id\n slug\n name\n enabled\n planModelId\n executeModelId\n planReasoningLevel\n executeReasoningLevel\n }\n}";
|
|
7
7
|
/** 连接级模型密钥(连接列表变化时只刷新密钥)。 */
|
|
8
8
|
export declare const RUNTIME_MODEL_CREDENTIALS_DOCUMENT = "query RuntimeModelCredentials($connectionIds: [ID!]) {\n runtimeModelCredentials(connectionIds: $connectionIds) {\n connectionId\n value\n }\n}";
|
|
9
|
+
/** 运行面生命周期上报(会话启停 / 拒绝 / 交付分支与核对):`action` 与 `outcome` 用 SDL 枚举名,失败只 warn 降级。 */
|
|
10
|
+
export declare const RUNTIME_REPORT_EVENT_DOCUMENT = "mutation RuntimeReportEvent($input: RuntimeEventInput!) {\n runtimeReportEvent(input: $input) {\n id\n action\n outcome\n code\n occurredAt\n }\n}";
|
|
9
11
|
/** 全部操作名(契约测试用:领域声明的操作必须都在这里)。 */
|
|
10
|
-
export declare const API_OPERATIONS: readonly ["RuntimeBoot", "RuntimeSkillFiles", "RuntimeWorkspaceProjects", "RuntimeModelCredentials"];
|
|
12
|
+
export declare const API_OPERATIONS: readonly ["RuntimeBoot", "RuntimeSkillFiles", "RuntimeWorkspaceProjects", "RuntimeModelCredentials", "RuntimeReportEvent"];
|
|
11
13
|
export type ApiOperation = (typeof API_OPERATIONS)[number];
|
|
@@ -8,9 +8,28 @@ type Exact<T extends {
|
|
|
8
8
|
export type Incremental<T> = T | {
|
|
9
9
|
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
|
|
10
10
|
};
|
|
11
|
+
/** 结果:SUCCESS = 完成;DENIED = 身份 / 权限 / 来源被拒;ERROR = 领域校验或冲突失败。 */
|
|
12
|
+
export type AuditOutcome = 'DENIED' | 'ERROR' | 'SUCCESS';
|
|
11
13
|
export type InputModality = 'IMAGE' | 'TEXT';
|
|
12
14
|
export type ModelProtocol = 'ANTHROPIC' | 'DEEPSEEK' | 'OPENAI_CHAT' | 'OPENAI_RESPONSES';
|
|
13
15
|
export type ReasoningLevel = 'HIGH' | 'LOW' | 'MAX' | 'MEDIUM' | 'MINIMAL' | 'OFF' | 'XHIGH';
|
|
16
|
+
/** 运行面可上报的动作:会话启停、拒绝、交付分支与交付核对。 */
|
|
17
|
+
export type RuntimeEventAction = 'DELIVERY_READY' | 'DELIVERY_VERIFIED' | 'SESSION_END' | 'SESSION_FAILED' | 'SESSION_REFUSED' | 'SESSION_START';
|
|
18
|
+
/**
|
|
19
|
+
* 运行面上报:只接受用户密钥身份,动作码限闭集;detail 由服务端脱敏后落库。
|
|
20
|
+
* 目标项目按 slug 解析:命中可读项目时 targetId 是项目 id,否则只留 slug 快照。
|
|
21
|
+
*/
|
|
22
|
+
export type RuntimeEventInput = {
|
|
23
|
+
action: RuntimeEventAction;
|
|
24
|
+
/** 原因码 / 交付状态码(例 SETUP_FAILED、delivered)。 */
|
|
25
|
+
code?: string | null | undefined;
|
|
26
|
+
detail?: unknown;
|
|
27
|
+
outcome: AuditOutcome;
|
|
28
|
+
/** 项目 slug(CNB 仓库 slug 或工作区目录名),用于把事件挂到项目上。 */
|
|
29
|
+
projectSlug?: string | null | undefined;
|
|
30
|
+
/** 目标展示名(例 `issue-12` / `PR #34`)。 */
|
|
31
|
+
targetLabel?: string | null | undefined;
|
|
32
|
+
};
|
|
14
33
|
/** 技能附件内容的编码:文本类用 UTF8,其余(图片 / 二进制)用 BASE64。 */
|
|
15
34
|
export type SkillFileEncoding = 'BASE64' | 'UTF8';
|
|
16
35
|
export type RuntimeBootQueryVariables = Exact<{
|
|
@@ -104,4 +123,16 @@ export type RuntimeModelCredentialsQuery = {
|
|
|
104
123
|
value: string;
|
|
105
124
|
}> | null;
|
|
106
125
|
};
|
|
126
|
+
export type RuntimeReportEventMutationVariables = Exact<{
|
|
127
|
+
input: RuntimeEventInput;
|
|
128
|
+
}>;
|
|
129
|
+
export type RuntimeReportEventMutation = {
|
|
130
|
+
runtimeReportEvent: {
|
|
131
|
+
id: string;
|
|
132
|
+
action: string;
|
|
133
|
+
outcome: AuditOutcome;
|
|
134
|
+
code: string | null;
|
|
135
|
+
occurredAt: string;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
107
138
|
export {};
|
|
@@ -26,6 +26,11 @@ export type Scalars = {
|
|
|
26
26
|
input: string;
|
|
27
27
|
output: string;
|
|
28
28
|
};
|
|
29
|
+
/** 自由形状的脱敏数据:仅审查日志的 detail 使用(服务端写入前已脱敏,只读不参与计算)。 */
|
|
30
|
+
JSON: {
|
|
31
|
+
input: unknown;
|
|
32
|
+
output: unknown;
|
|
33
|
+
};
|
|
29
34
|
};
|
|
30
35
|
export type Activation = {
|
|
31
36
|
__typename?: 'Activation';
|
|
@@ -36,6 +41,88 @@ export type AddCnbUsersInput = {
|
|
|
36
41
|
/** 要预建账户的上游成员 CNB 用户 ID;本轮上游没返回的会被跳过。 */
|
|
37
42
|
externalUserIds: Array<Scalars['String']['input']>;
|
|
38
43
|
};
|
|
44
|
+
/** 动作码选项:筛选下拉的选项来源(服务端注册表,前端不复制)。 */
|
|
45
|
+
export type AuditActionOption = {
|
|
46
|
+
__typename?: 'AuditActionOption';
|
|
47
|
+
action: Scalars['String']['output'];
|
|
48
|
+
category: AuditCategory;
|
|
49
|
+
label: Scalars['String']['output'];
|
|
50
|
+
};
|
|
51
|
+
/** 身份来源:会话 / 用户密钥 / 接入密钥 / 匿名(登录失败、无效密钥)。 */
|
|
52
|
+
export declare enum AuditActorKind {
|
|
53
|
+
AccessKey = "ACCESS_KEY",
|
|
54
|
+
Anonymous = "ANONYMOUS",
|
|
55
|
+
Session = "SESSION",
|
|
56
|
+
UserKey = "USER_KEY"
|
|
57
|
+
}
|
|
58
|
+
/** 审查类别:读 / 写 / 身份凭据 / 运行面生命周期。 */
|
|
59
|
+
export declare enum AuditCategory {
|
|
60
|
+
Auth = "AUTH",
|
|
61
|
+
Read = "READ",
|
|
62
|
+
Runtime = "RUNTIME",
|
|
63
|
+
Write = "WRITE"
|
|
64
|
+
}
|
|
65
|
+
/** 来源面:控制台 / NPC / 云开发工作站 / 容器 Web / 宿主直跑 / 未标注。 */
|
|
66
|
+
export declare enum AuditChannel {
|
|
67
|
+
Console = "CONSOLE",
|
|
68
|
+
ContainerWeb = "CONTAINER_WEB",
|
|
69
|
+
Host = "HOST",
|
|
70
|
+
Npc = "NPC",
|
|
71
|
+
Unknown = "UNKNOWN",
|
|
72
|
+
Workstation = "WORKSTATION"
|
|
73
|
+
}
|
|
74
|
+
export type AuditEvent = {
|
|
75
|
+
__typename?: 'AuditEvent';
|
|
76
|
+
/** 动作码,例 `write.project.delete`;闭集与中文文案由服务端的注册表给出。 */
|
|
77
|
+
action: Scalars['String']['output'];
|
|
78
|
+
/** 动作码的中文文案(筛选下拉同样取自服务端,前端不复制这张表)。 */
|
|
79
|
+
actionLabel: Scalars['String']['output'];
|
|
80
|
+
actorDisplayName?: Maybe<Scalars['String']['output']>;
|
|
81
|
+
actorId?: Maybe<Scalars['ID']['output']>;
|
|
82
|
+
actorKind: AuditActorKind;
|
|
83
|
+
actorUsername?: Maybe<Scalars['String']['output']>;
|
|
84
|
+
category: AuditCategory;
|
|
85
|
+
channel: AuditChannel;
|
|
86
|
+
clientIp?: Maybe<Scalars['String']['output']>;
|
|
87
|
+
/** 领域错误码或运行面原因码;成功(或被拒且无码)时为空。 */
|
|
88
|
+
code?: Maybe<Scalars['String']['output']>;
|
|
89
|
+
/** 脱敏快照:before / after、请求元信息、原因文本等。 */
|
|
90
|
+
detail: Scalars['JSON']['output'];
|
|
91
|
+
durationMs?: Maybe<Scalars['Int']['output']>;
|
|
92
|
+
id: Scalars['ID']['output'];
|
|
93
|
+
occurredAt: Scalars['DateTime']['output'];
|
|
94
|
+
outcome: AuditOutcome;
|
|
95
|
+
targetId?: Maybe<Scalars['String']['output']>;
|
|
96
|
+
/** 目标当时的展示名(目标已删除时仍可读)。 */
|
|
97
|
+
targetLabel?: Maybe<Scalars['String']['output']>;
|
|
98
|
+
/** 目标类型,例 user / project / model / connection / skill / access-key / run。 */
|
|
99
|
+
targetType?: Maybe<Scalars['String']['output']>;
|
|
100
|
+
};
|
|
101
|
+
/** 筛选:各条件并列(AND);from/to 为闭区间。 */
|
|
102
|
+
export type AuditEventFilter = {
|
|
103
|
+
/** 精确匹配动作码;选项清单走 auditActionOptions。 */
|
|
104
|
+
action?: InputMaybe<Scalars['String']['input']>;
|
|
105
|
+
actorUserId?: InputMaybe<Scalars['ID']['input']>;
|
|
106
|
+
category?: InputMaybe<AuditCategory>;
|
|
107
|
+
channel?: InputMaybe<AuditChannel>;
|
|
108
|
+
from?: InputMaybe<Scalars['DateTime']['input']>;
|
|
109
|
+
outcome?: InputMaybe<AuditOutcome>;
|
|
110
|
+
targetId?: InputMaybe<Scalars['String']['input']>;
|
|
111
|
+
targetType?: InputMaybe<Scalars['String']['input']>;
|
|
112
|
+
to?: InputMaybe<Scalars['DateTime']['input']>;
|
|
113
|
+
};
|
|
114
|
+
export type AuditEventPage = {
|
|
115
|
+
__typename?: 'AuditEventPage';
|
|
116
|
+
items: Array<AuditEvent>;
|
|
117
|
+
/** 与本次 filter 同口径的记录总数。 */
|
|
118
|
+
total: Scalars['Int']['output'];
|
|
119
|
+
};
|
|
120
|
+
/** 结果:SUCCESS = 完成;DENIED = 身份 / 权限 / 来源被拒;ERROR = 领域校验或冲突失败。 */
|
|
121
|
+
export declare enum AuditOutcome {
|
|
122
|
+
Denied = "DENIED",
|
|
123
|
+
Error = "ERROR",
|
|
124
|
+
Success = "SUCCESS"
|
|
125
|
+
}
|
|
39
126
|
/** CNB 接入密钥(Hub 生成、经 secret import 注入 CNB 环境;服务端只存摘要)。 */
|
|
40
127
|
export type CnbAccessKey = {
|
|
41
128
|
__typename?: 'CnbAccessKey';
|
|
@@ -87,30 +174,6 @@ export type CnbUserAddResult = {
|
|
|
87
174
|
skipped: Scalars['Int']['output'];
|
|
88
175
|
total: Scalars['Int']['output'];
|
|
89
176
|
};
|
|
90
|
-
/** 一次运行面配置读取的记账行:读取者就是记账者本人,没有代表关系。 */
|
|
91
|
-
export type ConfigurationRead = {
|
|
92
|
-
__typename?: 'ConfigurationRead';
|
|
93
|
-
actorDisplayName?: Maybe<Scalars['String']['output']>;
|
|
94
|
-
actorId?: Maybe<Scalars['ID']['output']>;
|
|
95
|
-
actorUsername?: Maybe<Scalars['String']['output']>;
|
|
96
|
-
/** 记账码,'READ' 表示读取成功。 */
|
|
97
|
-
code: Scalars['String']['output'];
|
|
98
|
-
id: Scalars['ID']['output'];
|
|
99
|
-
readAt: Scalars['DateTime']['output'];
|
|
100
|
-
};
|
|
101
|
-
/** 条件:userId 匹配读取者;from/to 为闭区间。 */
|
|
102
|
-
export type ConfigurationReadFilter = {
|
|
103
|
-
code?: InputMaybe<Scalars['String']['input']>;
|
|
104
|
-
from?: InputMaybe<Scalars['DateTime']['input']>;
|
|
105
|
-
to?: InputMaybe<Scalars['DateTime']['input']>;
|
|
106
|
-
userId?: InputMaybe<Scalars['ID']['input']>;
|
|
107
|
-
};
|
|
108
|
-
export type ConfigurationReadPage = {
|
|
109
|
-
__typename?: 'ConfigurationReadPage';
|
|
110
|
-
items: Array<ConfigurationRead>;
|
|
111
|
-
/** 与本次 filter 同口径的读取记录总数。 */
|
|
112
|
-
total: Scalars['Int']['output'];
|
|
113
|
-
};
|
|
114
177
|
export type CreateCnbAccessKeyInput = {
|
|
115
178
|
/** 省略 = 默认名「CNB 接入密钥」。 */
|
|
116
179
|
name?: InputMaybe<Scalars['String']['input']>;
|
|
@@ -284,7 +347,7 @@ export type ModelDefaultSelection = {
|
|
|
284
347
|
reasoningLevel?: Maybe<ReasoningLevel>;
|
|
285
348
|
};
|
|
286
349
|
/**
|
|
287
|
-
* 条件:connectionId 限定某连接的目录;protocol
|
|
350
|
+
* 条件:connectionId 限定某连接的目录;protocol / discoveryStatus 按所属连接的协议与发现状态过滤;
|
|
288
351
|
* ids 按模型 id 批查(≤100,用于显示名解析);search 匹配显示名 / 上游 id;
|
|
289
352
|
* missingOnly = 既不在上游发现也不在手工保留里;availableOnly = 连接启用 ∧ 密钥齐备 ∧ 模型启用 ∧ 存在(运行面可选池)。
|
|
290
353
|
*/
|
|
@@ -350,6 +413,11 @@ export type Mutation = {
|
|
|
350
413
|
removeSkillFiles: Skill;
|
|
351
414
|
/** 吊销接入密钥。 */
|
|
352
415
|
revokeCnbAccessKey: Scalars['ID']['output'];
|
|
416
|
+
/**
|
|
417
|
+
* 回报一条运行面生命周期事实(会话启停 / 拒绝 / 交付分支与核对)。
|
|
418
|
+
* 上报失败不改变运行面行为:运行面按「只 warn 降级」处理,事件缺失不影响交付闭环。
|
|
419
|
+
*/
|
|
420
|
+
runtimeReportEvent: AuditEvent;
|
|
353
421
|
saveGlobalConfiguration: GlobalConfiguration;
|
|
354
422
|
saveModel: Model;
|
|
355
423
|
saveModelConnection: ModelConnection;
|
|
@@ -411,6 +479,9 @@ export type MutationRemoveSkillFilesArgs = {
|
|
|
411
479
|
export type MutationRevokeCnbAccessKeyArgs = {
|
|
412
480
|
id: Scalars['ID']['input'];
|
|
413
481
|
};
|
|
482
|
+
export type MutationRuntimeReportEventArgs = {
|
|
483
|
+
input: RuntimeEventInput;
|
|
484
|
+
};
|
|
414
485
|
export type MutationSaveGlobalConfigurationArgs = {
|
|
415
486
|
input: SaveGlobalInput;
|
|
416
487
|
};
|
|
@@ -535,6 +606,10 @@ export type ProjectPage = {
|
|
|
535
606
|
};
|
|
536
607
|
export type Query = {
|
|
537
608
|
__typename?: 'Query';
|
|
609
|
+
/** 审查动作码清单(管理员):筛选下拉的选项来源。 */
|
|
610
|
+
auditActionOptions: Array<AuditActionOption>;
|
|
611
|
+
/** 审查日志(管理员):读取 / 写操作 / 身份凭据 / 运行面生命周期四类事实。 */
|
|
612
|
+
auditEvents: AuditEventPage;
|
|
538
613
|
/** 该用户可用模型(连接启用 + 模型启用 + 存在性 + 密钥齐备)。 */
|
|
539
614
|
availableModels: Array<Model>;
|
|
540
615
|
/** 该连接的内置目录模型清单;不需要密钥,上游读不到时的出路。 */
|
|
@@ -543,7 +618,6 @@ export type Query = {
|
|
|
543
618
|
cnbAccessKeys: Array<CnbAccessKey>;
|
|
544
619
|
/** 当前登录账户自己的 CNB 连接。 */
|
|
545
620
|
cnbConnection: CnbAccount;
|
|
546
|
-
configurationReads: ConfigurationReadPage;
|
|
547
621
|
/** 该用户三项生效默认(web / plan / execute);未配置或不在可用目录内为 null。 */
|
|
548
622
|
effectiveModelDefaults: EffectiveModelDefaults;
|
|
549
623
|
globalConfiguration: GlobalConfiguration;
|
|
@@ -608,17 +682,17 @@ export type Query = {
|
|
|
608
682
|
users: UserPage;
|
|
609
683
|
viewer: User;
|
|
610
684
|
};
|
|
685
|
+
export type QueryAuditEventsArgs = {
|
|
686
|
+
filter?: InputMaybe<AuditEventFilter>;
|
|
687
|
+
first?: InputMaybe<Scalars['Int']['input']>;
|
|
688
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
689
|
+
};
|
|
611
690
|
export type QueryAvailableModelsArgs = {
|
|
612
691
|
userId?: InputMaybe<Scalars['ID']['input']>;
|
|
613
692
|
};
|
|
614
693
|
export type QueryBuiltinModelCatalogArgs = {
|
|
615
694
|
connectionId: Scalars['ID']['input'];
|
|
616
695
|
};
|
|
617
|
-
export type QueryConfigurationReadsArgs = {
|
|
618
|
-
filter?: InputMaybe<ConfigurationReadFilter>;
|
|
619
|
-
first?: InputMaybe<Scalars['Int']['input']>;
|
|
620
|
-
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
621
|
-
};
|
|
622
696
|
export type QueryEffectiveModelDefaultsArgs = {
|
|
623
697
|
userId?: InputMaybe<Scalars['ID']['input']>;
|
|
624
698
|
};
|
|
@@ -730,6 +804,30 @@ export type RuntimeConnection = {
|
|
|
730
804
|
*/
|
|
731
805
|
provider?: Maybe<Scalars['String']['output']>;
|
|
732
806
|
};
|
|
807
|
+
/** 运行面可上报的动作:会话启停、拒绝、交付分支与交付核对。 */
|
|
808
|
+
export declare enum RuntimeEventAction {
|
|
809
|
+
DeliveryReady = "DELIVERY_READY",
|
|
810
|
+
DeliveryVerified = "DELIVERY_VERIFIED",
|
|
811
|
+
SessionEnd = "SESSION_END",
|
|
812
|
+
SessionFailed = "SESSION_FAILED",
|
|
813
|
+
SessionRefused = "SESSION_REFUSED",
|
|
814
|
+
SessionStart = "SESSION_START"
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* 运行面上报:只接受用户密钥身份,动作码限闭集;detail 由服务端脱敏后落库。
|
|
818
|
+
* 目标项目按 slug 解析:命中可读项目时 targetId 是项目 id,否则只留 slug 快照。
|
|
819
|
+
*/
|
|
820
|
+
export type RuntimeEventInput = {
|
|
821
|
+
action: RuntimeEventAction;
|
|
822
|
+
/** 原因码 / 交付状态码(例 SETUP_FAILED、delivered)。 */
|
|
823
|
+
code?: InputMaybe<Scalars['String']['input']>;
|
|
824
|
+
detail?: InputMaybe<Scalars['JSON']['input']>;
|
|
825
|
+
outcome: AuditOutcome;
|
|
826
|
+
/** 项目 slug(CNB 仓库 slug 或工作区目录名),用于把事件挂到项目上。 */
|
|
827
|
+
projectSlug?: InputMaybe<Scalars['String']['input']>;
|
|
828
|
+
/** 目标展示名(例 `issue-12` / `PR #34`)。 */
|
|
829
|
+
targetLabel?: InputMaybe<Scalars['String']['input']>;
|
|
830
|
+
};
|
|
733
831
|
/** 全局 headless 角色默认(plan / execute);读取失败时整个块为 null。 */
|
|
734
832
|
export type RuntimeHeadlessModels = {
|
|
735
833
|
__typename?: 'RuntimeHeadlessModels';
|
|
@@ -967,7 +1065,7 @@ export type SkillPage = {
|
|
|
967
1065
|
/** 与本次 filter 同口径的技能总数。 */
|
|
968
1066
|
total: Scalars['Int']['output'];
|
|
969
1067
|
};
|
|
970
|
-
/** 一个不可变历史快照。作者用扁平字段(同
|
|
1068
|
+
/** 一个不可变历史快照。作者用扁平字段(同 AuditEvent 口径),不构造完整 User。 */
|
|
971
1069
|
export type SkillVersion = {
|
|
972
1070
|
__typename?: 'SkillVersion';
|
|
973
1071
|
archived: Scalars['Boolean']['output'];
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RuntimeBootQuery, RuntimeModelCredentialsQuery, RuntimeSkillFilesQuery, RuntimeWorkspaceProjectsQuery } from './generated/graphql.js';
|
|
2
|
+
import type { RuntimeReportEventMutation } from './generated/graphql.js';
|
|
2
3
|
import type { ConnectionCredentials } from '../hub/credentials.js';
|
|
3
4
|
import type { ConsoleLoginInput, ConsoleLoginOutcome } from './login.js';
|
|
4
5
|
export type RuntimeBootFacts = {
|
|
@@ -28,11 +29,28 @@ export interface Semi2Api {
|
|
|
28
29
|
}>;
|
|
29
30
|
/** 密码登录换无会话用户密钥(密码只在本次请求内存里)。 */
|
|
30
31
|
loginToConsole(input: ConsoleLoginInput): Promise<ConsoleLoginOutcome>;
|
|
32
|
+
/** 运行面生命周期上报(会话启停 / 拒绝 / 交付);失败不改变运行面行为。 */
|
|
33
|
+
reportEvent(event: RuntimeEventReport): Promise<DomainOutcome<RuntimeReportedEvent>>;
|
|
31
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* 上报载荷:action / outcome 用 SDL 的枚举名(`SESSION_REFUSED` / `SUCCESS`),
|
|
37
|
+
* 与 hub 契约同名同义,两侧不各维护一张映射表。
|
|
38
|
+
*/
|
|
39
|
+
export interface RuntimeEventReport {
|
|
40
|
+
action: string;
|
|
41
|
+
outcome: 'SUCCESS' | 'DENIED' | 'ERROR';
|
|
42
|
+
code?: string;
|
|
43
|
+
projectSlug?: string;
|
|
44
|
+
targetLabel?: string;
|
|
45
|
+
detail?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export type RuntimeReportedEvent = RuntimeReportEventMutation['runtimeReportEvent'];
|
|
32
48
|
export interface Semi2ApiOptions {
|
|
33
49
|
/** 当前连接凭据(编排层持有权威副本);null = 未配置,调用会抛 MISSING_ACCESS_TOKEN。 */
|
|
34
50
|
readConnection(): ConnectionCredentials | null;
|
|
35
51
|
environment: NodeJS.ProcessEnv;
|
|
52
|
+
/** 本面标识(运行面契约的 face);未解析到契约时缺省,hub 记 unknown。 */
|
|
53
|
+
readFace?: () => string | undefined;
|
|
36
54
|
fetchImpl?: typeof fetch;
|
|
37
55
|
}
|
|
38
56
|
export declare function createSemi2Api(options: Semi2ApiOptions): Semi2Api;
|
package/lib/types/contract.d.ts
CHANGED
|
@@ -5,9 +5,13 @@ export interface Semi2Credentials {
|
|
|
5
5
|
}
|
|
6
6
|
/** 运行面平台:适配器声明的事实;宿主直跑(无契约)由插件判为 `host`。 */
|
|
7
7
|
export type Semi2Platform = 'cnb' | 'container';
|
|
8
|
+
/** 运行面标识:hub 的审查日志按它区分来源面(`host` = 无适配器的宿主直跑)。 */
|
|
9
|
+
export type Semi2Face = 'npc' | 'workstation' | 'container-web' | 'host';
|
|
8
10
|
export interface Semi2Runtime {
|
|
9
11
|
/** 由 runtimeFrom*Env 工厂盖章(适配器不自己填)。 */
|
|
10
12
|
platform: Semi2Platform;
|
|
13
|
+
/** 同上:本面是哪个运行面,hub 审查日志的来源面。 */
|
|
14
|
+
face: Semi2Face;
|
|
11
15
|
/** semi2-hub 连接凭据;缺省 = 回落 dsh credentials 登录存储。 */
|
|
12
16
|
credentials?: Semi2Credentials;
|
|
13
17
|
}
|
|
@@ -21,8 +25,9 @@ declare module '@deepseek-ai/cordis' {
|
|
|
21
25
|
/**
|
|
22
26
|
* CNB 运行面:优先用 secret import 注入的 hub 接入密钥(`SEMI2_ACCESS_TOKEN`),
|
|
23
27
|
* 缺失时才回退平台短期 `CNB_TOKEN`(插件启动时换成 hub 用户密钥)。
|
|
28
|
+
* face 由调用它的适配器给(NPC 面与云开发工作站面共用这条 env 通道)。
|
|
24
29
|
*/
|
|
25
|
-
export declare function runtimeFromCnbEnv(env: NodeJS.ProcessEnv): Semi2Runtime;
|
|
30
|
+
export declare function runtimeFromCnbEnv(env: NodeJS.ProcessEnv, face: 'npc' | 'workstation'): Semi2Runtime;
|
|
26
31
|
/**
|
|
27
32
|
* 容器运行面:**只盖章,不给凭据也不给身份**——本地容器靠登录(设置页账号密码换用户密钥)。
|
|
28
33
|
* 契约一旦提供 `credentials`,插件的 `login()` 会以 `CREDENTIAL_SOURCE_READONLY` 拒绝登录
|
|
@@ -71,8 +71,11 @@ export type HeadlessModelOutcome = {
|
|
|
71
71
|
kind: 'degraded';
|
|
72
72
|
role: 'plan' | 'execute';
|
|
73
73
|
reason: string;
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
|
+
/** code 是稳定原因码(审查日志按它筛选),reason 只作人读说明。 */
|
|
76
|
+
| {
|
|
75
77
|
kind: 'refused';
|
|
78
|
+
code: string;
|
|
76
79
|
reason: string;
|
|
77
80
|
};
|
|
78
81
|
/** 领域 id → 该领域的 peer 面(总映射,缺席靠 `| undefined` 表达)。 */
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
3
|
export type { RuntimeProject, } from './hub/compile.js';
|
|
4
4
|
export type { RuntimeIdentity, RuntimeSkillFact, RuntimeSkillFileContentFact, RuntimeSkillFileFact, Semi2ConfigState, } from './hub/facts.js';
|
|
5
|
-
export type { ConfigStatus, Semi2Config, Semi2Health, Semi2Session, } from './service/config-service.js';
|
|
5
|
+
export type { ConfigStatus, Semi2Config, Semi2Audit, Semi2Health, Semi2Session, } from './service/config-service.js';
|
|
6
6
|
export type { HeadlessModelOutcome } from './domains/types.js';
|
|
7
7
|
export type { Semi2Surface } from './hub/facts.js';
|
|
8
8
|
export { SEMI2_RUNTIME_SERVICE, runtimeFromCnbEnv, runtimeFromContainerEnv, } from './contract.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OrchestratorInternals } from './orchestrator.js';
|
|
2
|
+
import type { RuntimeEventReport } from '../api/index.js';
|
|
3
|
+
/** 生命周期事件:动作名与结果名都用 hub SDL 的枚举名,两侧不各维护一张映射表。 */
|
|
4
|
+
export declare function reportEvent(engine: OrchestratorInternals, event: RuntimeEventReport): Promise<void>;
|
|
5
|
+
/** 本面标识:契约里有就用它;宿主直跑没有契约,记 host。 */
|
|
6
|
+
export declare function faceOf(engine: OrchestratorInternals): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import { type Semi2Api } from '../api/index.js';
|
|
3
|
+
import type { RuntimeEventReport } from '../api/index.js';
|
|
3
4
|
import type { DomainId, DomainPeers, HeadlessModelOutcome, HealthItem } from '../domains/types.js';
|
|
4
5
|
import type { Semi2ConfigState, Semi2Surface } from '../hub/facts.js';
|
|
5
6
|
import type { HealthContributor } from './health.js';
|
|
@@ -38,6 +39,14 @@ export interface Semi2Session {
|
|
|
38
39
|
export interface Semi2Health {
|
|
39
40
|
snapshot(): Record<string, HealthItem>;
|
|
40
41
|
}
|
|
42
|
+
/** 上报面(`ctx.semi2Audit`):运行面(NPC 面)回报生命周期与交付事实,失败只 warn。 */
|
|
43
|
+
export interface Semi2Audit {
|
|
44
|
+
/** 返回是否被 hub 接受;调用方只记日志,不据此改变行为。 */
|
|
45
|
+
report(event: RuntimeEventReport): Promise<{
|
|
46
|
+
ok: boolean;
|
|
47
|
+
code: string | null;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
41
50
|
export interface ConfigurationOptions extends OrchestratorOptions {
|
|
42
51
|
/** 测试缝:替换网络层(假件)。 */
|
|
43
52
|
api?: Semi2Api;
|
|
@@ -49,6 +58,8 @@ export interface ConfigurationInstall {
|
|
|
49
58
|
session: Semi2Session;
|
|
50
59
|
/** 诊断面 → `ctx.semi2Health`。 */
|
|
51
60
|
health: Semi2Health;
|
|
61
|
+
/** 上报面 → `ctx.semi2Audit`。 */
|
|
62
|
+
audit: Semi2Audit;
|
|
52
63
|
/** 能力项(web 面 / CodeGraph 开关)登记健康贡献者。 */
|
|
53
64
|
registerHealth(contributor: HealthContributor): void;
|
|
54
65
|
/** 领域 peer 面(测试与内部接缝;运行面与领域之间经它取迟绑定事实)。 */
|