@company-semantics/contracts 9.0.0 → 9.2.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/package.json +6 -3
- package/src/__tests__/resource-keys.test.ts +30 -23
- package/src/admin/authz-simulate.ts +4 -4
- package/src/admin/direct-grants.ts +2 -2
- package/src/api/generated-spec-hash.ts +2 -2
- package/src/api/generated.ts +97 -0
- package/src/api/http/routes/ai-chat.ts +3 -3
- package/src/api/http/utils/resource-response.ts +5 -2
- package/src/api/index.ts +4 -4
- package/src/api/primitives.ts +6 -2
- package/src/auth/README.md +1 -0
- package/src/auth/index.ts +12 -5
- package/src/autotune.ts +5 -1
- package/src/billing/index.ts +1 -1
- package/src/billing/types.ts +1 -1
- package/src/chat/README.md +3 -0
- package/src/chat/__tests__/runtime-profile.test.ts +68 -48
- package/src/chat/index.ts +10 -4
- package/src/chat/runtime-profile.ts +25 -10
- package/src/chat/schemas.ts +49 -41
- package/src/chat/types.ts +48 -42
- package/src/ci-envelope/README.md +2 -0
- package/src/ci-envelope/__tests__/transitions.test.ts +56 -56
- package/src/ci-envelope/index.ts +2 -2
- package/src/ci-envelope/types.ts +20 -20
- package/src/ci-results/index.ts +2 -2
- package/src/ci-results/repo-ci-result.ts +15 -12
- package/src/compatibility.ts +6 -6
- package/src/content/index.ts +10 -4
- package/src/content/schemas.ts +42 -24
- package/src/dispatch/index.ts +18 -15
- package/src/email/__tests__/registry.test.ts +81 -77
- package/src/email/index.ts +3 -3
- package/src/email/registry.ts +25 -25
- package/src/email/types.ts +43 -43
- package/src/errors/index.ts +8 -8
- package/src/execution/__tests__/events.test.ts +42 -42
- package/src/execution/__tests__/lifecycle.test.ts +192 -190
- package/src/execution/__tests__/registry.test.ts +114 -114
- package/src/execution/audit-export.ts +4 -4
- package/src/execution/errors.ts +7 -7
- package/src/execution/event-metadata.ts +4 -4
- package/src/execution/events.ts +23 -21
- package/src/execution/expiry.ts +5 -5
- package/src/execution/hash-chain.ts +2 -2
- package/src/execution/index.ts +19 -28
- package/src/execution/kinds.ts +7 -7
- package/src/execution/lifecycle.ts +33 -33
- package/src/execution/registry.ts +63 -63
- package/src/execution/schemas.ts +31 -23
- package/src/execution/status.ts +45 -26
- package/src/execution/summary.ts +16 -17
- package/src/execution/timeline-ui.ts +9 -9
- package/src/execution/types.ts +31 -25
- package/src/generated/openapi-routes.ts +2 -0
- package/src/guards/config.ts +22 -18
- package/src/guards/index.ts +4 -4
- package/src/guards/types.ts +32 -24
- package/src/identity/__tests__/avatar.test.ts +68 -59
- package/src/identity/avatar.ts +8 -8
- package/src/identity/display-name.ts +3 -3
- package/src/identity/index.ts +8 -8
- package/src/identity/people-org-chart.ts +8 -4
- package/src/identity/schemas.ts +28 -18
- package/src/identity/types.ts +5 -5
- package/src/impersonation/index.ts +5 -5
- package/src/impersonation/schemas.ts +15 -9
- package/src/impersonation-events.ts +21 -21
- package/src/impersonation.ts +25 -24
- package/src/index.ts +118 -90
- package/src/interfaces/mcp/tools/help.ts +19 -19
- package/src/internal-admin.ts +6 -6
- package/src/mcp/README.md +2 -0
- package/src/mcp/__tests__/capability-graph.test.ts +290 -290
- package/src/mcp/capability-graph.ts +42 -40
- package/src/mcp/failure-context.ts +1 -3
- package/src/mcp/index.ts +69 -56
- package/src/mcp/resources.ts +9 -9
- package/src/meetings/index.ts +2 -2
- package/src/meetings/schemas.ts +51 -34
- package/src/message-parts/README.md +2 -0
- package/src/message-parts/__tests__/builder.test.ts +142 -142
- package/src/message-parts/__tests__/confirmation.test.ts +100 -86
- package/src/message-parts/__tests__/preview.test.ts +63 -63
- package/src/message-parts/__tests__/wire.test.ts +130 -124
- package/src/message-parts/builder.ts +23 -23
- package/src/message-parts/confirmation.ts +17 -14
- package/src/message-parts/execution.ts +7 -7
- package/src/message-parts/index.ts +10 -10
- package/src/message-parts/lifecycle.ts +25 -25
- package/src/message-parts/preview.ts +30 -30
- package/src/message-parts/types.ts +27 -27
- package/src/message-parts/wire.ts +24 -24
- package/src/mutations.ts +2 -2
- package/src/observability.ts +23 -11
- package/src/org/__tests__/org-units.test.ts +131 -96
- package/src/org/__tests__/tree-ordering.test.ts +57 -37
- package/src/org/__tests__/view-scopes.test.ts +40 -40
- package/src/org/domain.ts +9 -9
- package/src/org/index.ts +31 -21
- package/src/org/org-units.ts +34 -20
- package/src/org/schemas.ts +261 -124
- package/src/org/sharing.ts +17 -13
- package/src/org/tree-ordering.ts +3 -1
- package/src/org/types.ts +54 -47
- package/src/org/view-scopes.ts +9 -9
- package/src/permissions/access-levels.ts +7 -2
- package/src/permissions/access-source.ts +6 -6
- package/src/permissions/index.ts +5 -5
- package/src/permissions/orgchart-roles.ts +7 -7
- package/src/permissions/permission-introspection.ts +7 -5
- package/src/permissions/share-api.ts +19 -9
- package/src/pressure.ts +4 -4
- package/src/queryIntent.ts +21 -21
- package/src/ralph/__tests__/prd-groups.test.ts +159 -159
- package/src/ralph/__tests__/prd.test.ts +30 -30
- package/src/ralph/index.ts +3 -8
- package/src/ralph/prd.ts +33 -33
- package/src/ralph/progress.ts +1 -1
- package/src/rate-limit/README.md +4 -4
- package/src/rate-limit/index.ts +3 -3
- package/src/requests.ts +36 -8
- package/src/resource-keys.ts +207 -124
- package/src/resource-registry.ts +5 -5
- package/src/route-builder.ts +3 -3
- package/src/safe-mode.ts +2 -2
- package/src/security/index.ts +4 -4
- package/src/security/org-secrets.ts +13 -9
- package/src/security/secret.ts +3 -3
- package/src/sse.ts +3 -1
- package/src/system/README.md +3 -0
- package/src/system/capabilities.ts +22 -23
- package/src/system/diagram.ts +45 -45
- package/src/system/index.ts +14 -14
- package/src/tiers.ts +1 -1
- package/src/timeouts.ts +1 -1
- package/src/tracing.ts +30 -30
- package/src/types/analytics.ts +2 -2
- package/src/usage/README.md +3 -0
- package/src/usage/execution-types.ts +69 -69
- package/src/usage/types.ts +7 -3
|
@@ -4,105 +4,105 @@
|
|
|
4
4
|
* See PRD-00200 for design rationale and invariants.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ChatRuntimeProfile } from
|
|
7
|
+
import type { ChatRuntimeProfile } from "../chat/runtime-profile";
|
|
8
8
|
|
|
9
9
|
export type ExecutionFailureReason =
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
10
|
+
| "tool_error"
|
|
11
|
+
| "timeout"
|
|
12
|
+
| "model_error"
|
|
13
|
+
| "budget_exceeded"
|
|
14
|
+
| "client_disconnect"
|
|
15
|
+
| "unknown";
|
|
16
16
|
|
|
17
17
|
// @vocabulary-exempt reason: telemetry row is a single DB-aligned record; splitting risks consumer breakage
|
|
18
18
|
export interface RuntimeExecutionTelemetry {
|
|
19
|
-
executionId: string
|
|
20
|
-
orgId: string
|
|
21
|
-
chatId?: string
|
|
22
|
-
messageId?: string
|
|
23
|
-
profile: ChatRuntimeProfile
|
|
24
|
-
provider: string
|
|
25
|
-
model: string
|
|
26
|
-
stepCount: number
|
|
27
|
-
toolCallCount: number
|
|
28
|
-
tokensInput: number
|
|
29
|
-
tokensOutput: number
|
|
30
|
-
tokensTotal: number
|
|
31
|
-
costInputUsd: string
|
|
32
|
-
costOutputUsd: string
|
|
33
|
-
costTotalUsd: string
|
|
34
|
-
durationMs: number
|
|
35
|
-
success: boolean
|
|
36
|
-
failureReason?: ExecutionFailureReason
|
|
37
|
-
createdAt: string // ISO 8601
|
|
19
|
+
executionId: string;
|
|
20
|
+
orgId: string;
|
|
21
|
+
chatId?: string;
|
|
22
|
+
messageId?: string;
|
|
23
|
+
profile: ChatRuntimeProfile;
|
|
24
|
+
provider: string;
|
|
25
|
+
model: string;
|
|
26
|
+
stepCount: number;
|
|
27
|
+
toolCallCount: number;
|
|
28
|
+
tokensInput: number;
|
|
29
|
+
tokensOutput: number;
|
|
30
|
+
tokensTotal: number;
|
|
31
|
+
costInputUsd: string; // 8 decimal places
|
|
32
|
+
costOutputUsd: string; // 8 decimal places
|
|
33
|
+
costTotalUsd: string; // 8 decimal places
|
|
34
|
+
durationMs: number;
|
|
35
|
+
success: boolean;
|
|
36
|
+
failureReason?: ExecutionFailureReason;
|
|
37
|
+
createdAt: string; // ISO 8601
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// --- Aggregation response types (PRD-00201) ---
|
|
41
41
|
|
|
42
42
|
export interface ProfileStats {
|
|
43
|
-
executions: number
|
|
44
|
-
percentOfTotal: number
|
|
45
|
-
avgDurationMs: number
|
|
46
|
-
totalCostUsd: string
|
|
47
|
-
avgCostPerExecution: string
|
|
48
|
-
failureRate: number
|
|
49
|
-
avgStepCount: number
|
|
50
|
-
avgToolCallCount: number
|
|
43
|
+
executions: number;
|
|
44
|
+
percentOfTotal: number;
|
|
45
|
+
avgDurationMs: number;
|
|
46
|
+
totalCostUsd: string;
|
|
47
|
+
avgCostPerExecution: string;
|
|
48
|
+
failureRate: number;
|
|
49
|
+
avgStepCount: number;
|
|
50
|
+
avgToolCallCount: number;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface OrgExecutionSummary {
|
|
54
|
-
dateRange: { start: string; end: string }
|
|
54
|
+
dateRange: { start: string; end: string };
|
|
55
55
|
totals: {
|
|
56
|
-
executions: number
|
|
57
|
-
tokens: number
|
|
58
|
-
costUsd: string
|
|
59
|
-
avgDurationMs: number
|
|
60
|
-
}
|
|
61
|
-
byProfile: Record<ChatRuntimeProfile, ProfileStats
|
|
56
|
+
executions: number;
|
|
57
|
+
tokens: number;
|
|
58
|
+
costUsd: string;
|
|
59
|
+
avgDurationMs: number;
|
|
60
|
+
};
|
|
61
|
+
byProfile: Record<ChatRuntimeProfile, ProfileStats>;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export interface DailyExecutionStats {
|
|
65
|
-
date: string // YYYY-MM-DD
|
|
66
|
-
executions: number
|
|
67
|
-
totalCostUsd: string
|
|
68
|
-
byProfile: Record<ChatRuntimeProfile, number
|
|
65
|
+
date: string; // YYYY-MM-DD
|
|
66
|
+
executions: number;
|
|
67
|
+
totalCostUsd: string;
|
|
68
|
+
byProfile: Record<ChatRuntimeProfile, number>;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export interface ExecutionByUser {
|
|
72
|
-
userId: string
|
|
73
|
-
email: string
|
|
74
|
-
executions: number
|
|
75
|
-
totalCostUsd: string
|
|
76
|
-
favoriteProfile: ChatRuntimeProfile
|
|
72
|
+
userId: string;
|
|
73
|
+
email: string;
|
|
74
|
+
executions: number;
|
|
75
|
+
totalCostUsd: string;
|
|
76
|
+
favoriteProfile: ChatRuntimeProfile;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export interface ExecutionDetail {
|
|
80
|
-
execution: RuntimeExecutionTelemetry
|
|
80
|
+
execution: RuntimeExecutionTelemetry;
|
|
81
81
|
llmCalls: Array<{
|
|
82
|
-
callId: string
|
|
83
|
-
model: string
|
|
84
|
-
provider: string
|
|
85
|
-
tokensInput: number
|
|
86
|
-
tokensOutput: number
|
|
87
|
-
costUsd: string
|
|
88
|
-
durationMs: number
|
|
89
|
-
toolCalls: number
|
|
90
|
-
}
|
|
82
|
+
callId: string;
|
|
83
|
+
model: string;
|
|
84
|
+
provider: string;
|
|
85
|
+
tokensInput: number;
|
|
86
|
+
tokensOutput: number;
|
|
87
|
+
costUsd: string;
|
|
88
|
+
durationMs: number;
|
|
89
|
+
toolCalls: number;
|
|
90
|
+
}>;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// --- Budget governance types (PRD-00232) ---
|
|
94
94
|
|
|
95
95
|
export interface BudgetCheck {
|
|
96
|
-
allowed: boolean
|
|
97
|
-
reason?:
|
|
98
|
-
remainingBudgetUsd?: string
|
|
99
|
-
usedThisMonthUsd?: string
|
|
96
|
+
allowed: boolean;
|
|
97
|
+
reason?: "monthly_budget_exceeded" | "approaching_limit";
|
|
98
|
+
remainingBudgetUsd?: string;
|
|
99
|
+
usedThisMonthUsd?: string;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export interface OrgBudgetSettings {
|
|
103
|
-
monthlyBudgetUsd: string | null
|
|
104
|
-
maxCostPerExecution: string | null
|
|
105
|
-
agenticMaxSteps: number | null
|
|
106
|
-
alertThresholdPct: number
|
|
107
|
-
enabled: boolean
|
|
103
|
+
monthlyBudgetUsd: string | null;
|
|
104
|
+
maxCostPerExecution: string | null;
|
|
105
|
+
agenticMaxSteps: number | null;
|
|
106
|
+
alertThresholdPct: number;
|
|
107
|
+
enabled: boolean;
|
|
108
108
|
}
|
package/src/usage/types.ts
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
* See PRD-00166 for design rationale and invariants.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export type AiFeature =
|
|
7
|
+
export type AiFeature =
|
|
8
|
+
| "chat"
|
|
9
|
+
| "chat_title"
|
|
10
|
+
| "ingest_summarize"
|
|
11
|
+
| "ingest_embedding"
|
|
12
|
+
| "company_md_extraction";
|
|
8
13
|
|
|
9
14
|
export interface UsageSummary {
|
|
10
15
|
totalTokens: number;
|
|
@@ -13,7 +18,7 @@ export interface UsageSummary {
|
|
|
13
18
|
estimatedCostUsd: string;
|
|
14
19
|
requestCount: number;
|
|
15
20
|
periodStart: string; // UTC ISO8601
|
|
16
|
-
periodEnd: string;
|
|
21
|
+
periodEnd: string; // UTC ISO8601
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
export interface DailyUsage {
|
|
@@ -46,7 +51,6 @@ export interface UsageByUser {
|
|
|
46
51
|
requestCount: number;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
|
|
50
54
|
// ---------------------------------------------------------------------------
|
|
51
55
|
// Unified Usage Response (PRD-00276/277)
|
|
52
56
|
// ---------------------------------------------------------------------------
|