@steerable/pack-sdk 0.12.7 → 0.13.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/types/index.d.ts +215 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerable/pack-sdk",
3
- "version": "0.12.7",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "Scenario pack contract for @steerable/agent-shell (pure types, zero runtime). A scenario pack declares every extension a vertical scenario needs — services, tools, tables, skills, agent seeds, HTTP routes, renderer slots, branding — and the host composes the selected packs at build time.",
6
6
  "license": "Apache-2.0",
package/types/index.d.ts CHANGED
@@ -23,6 +23,196 @@
23
23
  /** 场景 id。开放字符串(不再是二值联合)。 */
24
24
  export type ScenarioId = string;
25
25
 
26
+ /** 触发当前请求或回合的入口渠道。 */
27
+ export type OriginChannel = 'desktop' | 'web' | 'cli' | 'im' | 'webhook';
28
+
29
+ /** 宿主解析并认证后的产品中立请求身份。 */
30
+ export interface Principal {
31
+ readonly id: string;
32
+ readonly tenantId: string;
33
+ readonly displayName: string;
34
+ readonly email: string | null;
35
+ readonly roles: readonly string[];
36
+ readonly isAdmin: boolean;
37
+ readonly externalId?: string | null;
38
+ readonly attrs?: Readonly<Record<string, string>>;
39
+ }
40
+
41
+ /** 凭证代管注入载荷(明文仅注入底层传输层,工具返回与日志自动脱敏)。 */
42
+ export interface CredentialInjection {
43
+ readonly headers?: Record<string, string>;
44
+ readonly query?: Record<string, string>;
45
+ readonly env?: Record<string, string>;
46
+ }
47
+
48
+ /** 注入给场景包工具的受控凭证解析客户端。 */
49
+ export interface PackCredentialClient {
50
+ resolve(sourceId: string): Promise<CredentialInjection | null>;
51
+ fetch(
52
+ sourceId: string,
53
+ url: string | URL,
54
+ init?: RequestInit,
55
+ ): Promise<Response>;
56
+ }
57
+
58
+ /** 场景包声明的外部数据源与凭证需求(兼支持 R1 加密凭据与 R4 `$source` 只读查询)。 */
59
+ export interface PackDataSource {
60
+ readonly id: string;
61
+ readonly label?: Readonly<Record<string, string>>;
62
+ readonly authKind?: 'bearer' | 'basic' | 'header' | 'oauth2' | 'custom_env';
63
+ readonly scope?: 'tenant' | 'user';
64
+ readonly requiredRoles?: readonly string[];
65
+ readonly description?: Readonly<Record<string, string>>;
66
+ readonly query?: (
67
+ params: Record<string, unknown>,
68
+ ctx: {
69
+ readonly principal: Principal;
70
+ readonly chatId: string;
71
+ },
72
+ ) => Promise<unknown>;
73
+ }
74
+
75
+ /** 交付物质检问题条目。 */
76
+ export interface VerifierIssue {
77
+ readonly severity: 'blocking' | 'warning';
78
+ readonly code: string;
79
+ readonly message: string;
80
+ readonly location?: string;
81
+ }
82
+
83
+ /** 交付物质检结论。 */
84
+ export interface DeliverableVerificationResult {
85
+ readonly status: 'verified' | 'warnings' | 'failed';
86
+ readonly issues: readonly VerifierIssue[];
87
+ readonly summary?: string;
88
+ readonly reportPath?: string;
89
+ }
90
+
91
+ /** 交付物完成定义与质检钩子(R5)。 */
92
+ export interface DeliverableVerifier {
93
+ readonly id: string;
94
+ readonly matchExtensions?: readonly string[];
95
+ readonly matchMimeTypes?: readonly string[];
96
+ verify(ctx: {
97
+ readonly filePath: string;
98
+ readonly chatId: string;
99
+ readonly principal: Principal;
100
+ readonly executedActions: readonly {
101
+ readonly id?: string;
102
+ readonly tool: string;
103
+ readonly arguments: Record<string, unknown>;
104
+ readonly success: boolean;
105
+ }[];
106
+ }): Promise<DeliverableVerificationResult>;
107
+ }
108
+
109
+ /** 声明式工作台实时数据源绑定(R4)。 */
110
+ export interface UiSurfaceSourceBinding {
111
+ readonly tool: string;
112
+ readonly args?: Record<string, unknown>;
113
+ readonly label?: Readonly<Record<string, string>>;
114
+ }
115
+
116
+ /** 声明式工作台受控写动作(仅允许引用已注册写工具)。 */
117
+ export interface UiSurfaceActionSpec {
118
+ readonly id: string;
119
+ readonly label: Readonly<Record<string, string>>;
120
+ readonly tool: string;
121
+ readonly checkpoint?: 'standard' | 'outward';
122
+ readonly staticArgs?: Record<string, unknown>;
123
+ }
124
+
125
+ /** 声明式工作台字段/区块节点(纯 JSON 受控组件树,禁止 HTML/脚本字符串)。 */
126
+ export type UiSurfaceNodeSpec =
127
+ | {
128
+ readonly kind: 'metric';
129
+ readonly id: string;
130
+ readonly label: Readonly<Record<string, string>>;
131
+ readonly sourceKey: string;
132
+ readonly path?: string;
133
+ }
134
+ | {
135
+ readonly kind: 'table';
136
+ readonly id: string;
137
+ readonly label: Readonly<Record<string, string>>;
138
+ readonly sourceKey: string;
139
+ readonly columns: readonly { readonly key: string; readonly label: Readonly<Record<string, string>> }[];
140
+ }
141
+ | {
142
+ readonly kind: 'input';
143
+ readonly id: string;
144
+ readonly name: string;
145
+ readonly label: Readonly<Record<string, string>>;
146
+ readonly inputType?: 'text' | 'number' | 'select' | 'checkbox';
147
+ readonly required?: boolean;
148
+ readonly defaultValue?: string | number | boolean;
149
+ readonly options?: readonly { readonly value: string; readonly label: Readonly<Record<string, string>> }[];
150
+ }
151
+ | {
152
+ readonly kind: 'callout';
153
+ readonly id: string;
154
+ readonly tone?: 'info' | 'warning' | 'danger';
155
+ readonly text: Readonly<Record<string, string>>;
156
+ };
157
+
158
+ /** 会话级声明式工作台规范(R4)。 */
159
+ export interface UiSurfaceSpec {
160
+ readonly surfaceId: string;
161
+ readonly title: Readonly<Record<string, string>>;
162
+ readonly summary?: Readonly<Record<string, string>>;
163
+ readonly sources?: Readonly<Record<string, UiSurfaceSourceBinding>>;
164
+ readonly nodes: readonly UiSurfaceNodeSpec[];
165
+ readonly actions?: readonly UiSurfaceActionSpec[];
166
+ }
167
+
168
+ /** 第二层 Agent Profile(角色提示词、默认工具集与技能编排,R3)。 */
169
+ export interface AgentProfileSpec {
170
+ readonly id: string;
171
+ readonly name: string;
172
+ readonly description?: string;
173
+ readonly rolePrompt: string;
174
+ readonly forbiddenPrompt?: string;
175
+ readonly defaultTools?: readonly string[];
176
+ readonly skillIds?: readonly string[];
177
+ readonly preferredModel?: string;
178
+ }
179
+
180
+ /** 未登录启动门公开认证方式描述(R3)。 */
181
+ export type PublicAuthMethod =
182
+ | { readonly kind: 'password'; readonly showTenantSlugInput: boolean }
183
+ | {
184
+ readonly kind: 'oidc';
185
+ readonly providerId: string;
186
+ readonly label: string;
187
+ readonly authorizePath: string;
188
+ }
189
+ | {
190
+ readonly kind: 'sso_proxy';
191
+ readonly label: string;
192
+ readonly loginUrl: string;
193
+ };
194
+
195
+ /** 未登录可读取的公开启动配置载荷(GET /api/v2/auth/bootstrap)。 */
196
+ export interface PublicBootstrapPayload {
197
+ readonly productName: string;
198
+ readonly authRequired: boolean;
199
+ readonly authMethods: readonly PublicAuthMethod[];
200
+ readonly iamMode?: string;
201
+ readonly defaultApplicationId?: string;
202
+ readonly safeMode?: boolean;
203
+ }
204
+
205
+ /** 第三层 Application 应用形态(默认工作台、导航裁剪与登录引导,R3)。 */
206
+ export interface ApplicationManifest {
207
+ readonly id: string;
208
+ readonly title: Readonly<Record<string, string>>;
209
+ readonly defaultAgentProfileId: string;
210
+ readonly allowedPackIds: readonly ScenarioId[];
211
+ readonly defaultWorkbenchTabs?: readonly ('preview' | 'workbench' | 'terminal' | 'fact_chain')[];
212
+ readonly hiddenNavItems?: readonly ('skills' | 'mcp' | 'agents' | 'terminal')[];
213
+ readonly bootstrapAuthMethods?: readonly ('password' | 'oidc' | 'sso_proxy')[];
214
+ }
215
+
26
216
  /**
27
217
  * 工具安全分级与曝光层。这两个枚举的单一真源在本包(0.3a 从
28
218
  * tool-router.ts 迁入);tool-router re-export 兼容既有调用方。
@@ -59,6 +249,12 @@ export interface PackToolContext {
59
249
  projectRoot?: string | null;
60
250
  /** 调用发生的 chat id;任务类工具按它归组。 */
61
251
  chatId?: string;
252
+ /** 宿主认证身份(本地/单机默认注入 LOCAL_DEFAULT_PRINCIPAL)。 */
253
+ principal?: Principal;
254
+ /** 触发当前回合的入口渠道。 */
255
+ originChannel?: OriginChannel;
256
+ /** 受控凭证代管解析客户端(明文不出工具上下文与 trace)。 */
257
+ credentials?: PackCredentialClient;
62
258
  }
63
259
 
64
260
  /** 工具 handler:接收模型 JSON 参数与调用上下文,返回可 JSON 序列化的结果。 */
@@ -77,6 +273,15 @@ export interface ToolContribution {
77
273
  readonly exposure?: ToolExposure;
78
274
  /** 缺省时审批类别等于工具名。 */
79
275
  readonly approval?: ToolApprovalSpec;
276
+ /**
277
+ * 幂等性声明:非幂等写工具(idempotent === false)一旦越过执行前校验进入
278
+ * 分发,超时或未知异常归类为 outcome_unknown 并阻断同名工具重试。
279
+ */
280
+ readonly idempotent?: boolean;
281
+ /**
282
+ * 签批等级:'outward' 强制逐次人类确认(禁止本会话/始终记住与 CLI 静默放行)。
283
+ */
284
+ readonly checkpoint?: 'standard' | 'outward';
80
285
  readonly handler: PackToolHandler;
81
286
  }
82
287
 
@@ -167,6 +372,8 @@ export interface HttpRouteRequest {
167
372
  readonly params: Record<string, string>;
168
373
  readonly query: Record<string, string>;
169
374
  readonly body: unknown;
375
+ readonly principal?: Principal;
376
+ readonly originChannel?: OriginChannel;
170
377
  }
171
378
 
172
379
  /** 主进程面贡献集合。 */
@@ -177,6 +384,10 @@ export interface MainContribution {
177
384
  readonly skills?: readonly SkillContribution[];
178
385
  readonly agentSeeds?: readonly AgentSeed[];
179
386
  readonly httpRoutes?: readonly HttpRouteContribution[];
387
+ readonly dataSources?: readonly PackDataSource[];
388
+ readonly deliverableVerifiers?: readonly DeliverableVerifier[];
389
+ readonly agentProfiles?: readonly AgentProfileSpec[];
390
+ readonly applications?: readonly ApplicationManifest[];
180
391
  }
181
392
 
182
393
  /**
@@ -327,6 +538,10 @@ export interface PackBackendRouteRequest {
327
538
  readonly body: unknown;
328
539
  /** 原始请求头(HTTP 模式下透传,便于检查 Range / If-None-Match)。 */
329
540
  readonly headers?: Record<string, string | string[] | undefined>;
541
+ /** 宿主认证身份(本地/单机默认注入 LOCAL_DEFAULT_PRINCIPAL)。 */
542
+ readonly principal?: Principal;
543
+ /** 触发当前请求的入口渠道。 */
544
+ readonly originChannel?: OriginChannel;
330
545
  }
331
546
 
332
547
  export interface PackBackendRoute {