Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
113 lines (101 loc) · 4.13 KB
/
Copy pathtypes.ts
File metadata and controls
113 lines (101 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// ─────────────────────────────────────────────────────────────────────────────
// Types
// ─────────────────────────────────────────────────────────────────────────────
// Per-resource state metadata. The state file is a pure `name → { uuid }`
// map: the only thing it records is which platform UUID a local resource
// file is bound to. Nothing else.
//
// The "last known platform state" content hash that drives drift detection
// lives OUTSIDE this file, in the gitignored per-developer hash store at
// `.vapi-state-hash/<org>/<uuid>` (see `hash-store.ts`). Keeping hashes out
// of the committed state file means the state diff is purely semantic
// (added/removed/re-bound resources) and the drift baseline is local to each
// developer's working copy.
//
// Legacy state files (bare string values, or objects carrying lastPulledHash /
// lastPushedHash / lastPulledAt) are NOT loaded by the sync commands — the
// `assertStateMigrated` guard in `migrate-hash-store.ts` blocks pull/push/apply
// until `npm run migrate` has slimmed every state file and seeded the hash
// store from the old hashes.
export interface ResourceState {
uuid: string;
}
// `StateFile` is the on-disk shape of `.vapi-state.<env>.json`. Each section
// carries `Record<string, ResourceState>` instead of bare strings.
// `loadState()` migrates legacy data automatically.
export interface StateFile {
credentials: Record<string, ResourceState>;
assistants: Record<string, ResourceState>;
structuredOutputs: Record<string, ResourceState>;
tools: Record<string, ResourceState>;
squads: Record<string, ResourceState>;
personalities: Record<string, ResourceState>;
scenarios: Record<string, ResourceState>;
simulations: Record<string, ResourceState>;
simulationSuites: Record<string, ResourceState>;
evals: Record<string, ResourceState>;
}
export interface ResourceFile<T = Record<string, unknown>> {
resourceId: string; // Path relative to resource type dir (e.g., "support/intake" or just "intake")
filePath: string;
data: T;
}
export interface VapiResponse {
id: string;
[key: string]: unknown;
}
export type ResourceType =
| "assistants"
| "structuredOutputs"
| "tools"
| "squads"
| "personalities"
| "scenarios"
| "simulations"
| "simulationSuites"
| "evals";
// Any slug-like string: "dev", "prod", "acme-production", etc.
export type Environment = string;
// Well-known names kept for backward-compatible npm scripts
export const VALID_ENVIRONMENTS: readonly string[] = ["dev", "stg", "prod"];
export const VALID_RESOURCE_TYPES: readonly ResourceType[] = [
"tools",
"structuredOutputs",
"assistants",
"squads",
"personalities",
"scenarios",
"simulations",
"simulationSuites",
"evals",
];
export interface LoadedResources {
tools: ResourceFile<Record<string, unknown>>[];
structuredOutputs: ResourceFile<Record<string, unknown>>[];
assistants: ResourceFile<Record<string, unknown>>[];
squads: ResourceFile<Record<string, unknown>>[];
personalities: ResourceFile<Record<string, unknown>>[];
scenarios: ResourceFile<Record<string, unknown>>[];
simulations: ResourceFile<Record<string, unknown>>[];
simulationSuites: ResourceFile<Record<string, unknown>>[];
evals: ResourceFile<Record<string, unknown>>[];
}
export interface OrphanedResource {
resourceId: string;
uuid: string;
}
// Who pushed an assistant version, recorded in its version metadata.
export interface VersionActor {
// Who pushed: the CI actor when set, else the local git identity.
name: string;
// Short commit SHA of HEAD, or null outside a git checkout.
commit: string | null;
// True when the pushed files had uncommitted edits, so the commit alone
// does not reproduce what was pushed.
dirty: boolean;
}
// Body of PATCH /assistant/:id/versions/:version.
export interface VersionMetadata {
versionName: string;
versionDescription: string;
}