tycono 0.1.90 → 0.1.91
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 +2 -1
- package/src/shared/types.ts +160 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycono",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.91",
|
|
4
4
|
"description": "Build an AI company. Watch them work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bin/",
|
|
11
11
|
"src/api/src/",
|
|
12
12
|
"src/api/package.json",
|
|
13
|
+
"src/shared/",
|
|
13
14
|
"src/web/dist/",
|
|
14
15
|
"templates/"
|
|
15
16
|
],
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Type Contract — Single Source of Truth
|
|
3
|
+
*
|
|
4
|
+
* 이 파일은 API와 Web이 공유하는 모든 상태/이벤트 타입을 정의합니다.
|
|
5
|
+
* 상태 관련 타입을 추가하거나 변경할 때는 반드시 이 파일을 수정하세요.
|
|
6
|
+
*
|
|
7
|
+
* 규칙:
|
|
8
|
+
* 1. 상태 타입은 여기서만 정의 — api/web에서 재정의 금지
|
|
9
|
+
* 2. UI-only 상태(waiting, connecting 등)는 별도 섹션에 명시적 분리
|
|
10
|
+
* 3. 상태 전이는 TRANSITIONS 맵으로 검증 가능
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* ═══════════════════════════════════════════════
|
|
14
|
+
* Job — 실행 단위의 핵심 상태
|
|
15
|
+
* ═══════════════════════════════════════════════ */
|
|
16
|
+
|
|
17
|
+
/** Job이 어떻게 시작되었는가 */
|
|
18
|
+
export type JobType = 'assign' | 'wave' | 'session-message' | 'consult';
|
|
19
|
+
|
|
20
|
+
/** Job의 실행 상태 — 시스템 전체에서 유일한 정의 */
|
|
21
|
+
export type JobStatus = 'running' | 'done' | 'error' | 'awaiting_input';
|
|
22
|
+
|
|
23
|
+
/** /api/exec/status 등에서 Role 단위로 집계할 때 사용 */
|
|
24
|
+
export type RoleStatus = 'idle' | 'working' | 'awaiting_input' | 'done';
|
|
25
|
+
|
|
26
|
+
/** JobStatus → RoleStatus 변환 (유일한 매핑 규칙) */
|
|
27
|
+
export function jobStatusToRoleStatus(jobStatus: JobStatus): RoleStatus {
|
|
28
|
+
switch (jobStatus) {
|
|
29
|
+
case 'running': return 'working';
|
|
30
|
+
case 'awaiting_input': return 'awaiting_input';
|
|
31
|
+
case 'done': return 'done';
|
|
32
|
+
case 'error': return 'done'; // error도 "더 이상 일하지 않는" 상태
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Role이 "활성 상태"인지 판단 — exec/status, Org Chart 등에서 사용 */
|
|
37
|
+
export function isRoleActive(status: RoleStatus): boolean {
|
|
38
|
+
return status === 'working' || status === 'awaiting_input';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Job이 "활성 상태"인지 판단 */
|
|
42
|
+
export function isJobActive(status: JobStatus): boolean {
|
|
43
|
+
return status === 'running' || status === 'awaiting_input';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 허용된 상태 전이 (from → to[]) */
|
|
47
|
+
export const JOB_TRANSITIONS: Record<JobStatus, JobStatus[]> = {
|
|
48
|
+
running: ['done', 'error', 'awaiting_input'],
|
|
49
|
+
awaiting_input: ['done', 'error'], // reply → done (old job), 또는 abort → error
|
|
50
|
+
done: [], // terminal state
|
|
51
|
+
error: [], // terminal state
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** 상태 전이 유효성 검증 */
|
|
55
|
+
export function canTransition(from: JobStatus, to: JobStatus): boolean {
|
|
56
|
+
return JOB_TRANSITIONS[from].includes(to);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ═══════════════════════════════════════════════
|
|
60
|
+
* Job Info — API 응답용 (런타임 객체에서 민감 정보 제거)
|
|
61
|
+
* ═══════════════════════════════════════════════ */
|
|
62
|
+
|
|
63
|
+
export interface JobInfo {
|
|
64
|
+
id: string;
|
|
65
|
+
type: JobType;
|
|
66
|
+
roleId: string;
|
|
67
|
+
task: string;
|
|
68
|
+
status: JobStatus;
|
|
69
|
+
parentJobId?: string;
|
|
70
|
+
childJobIds: string[];
|
|
71
|
+
createdAt: string;
|
|
72
|
+
targetRole?: string;
|
|
73
|
+
output?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* ═══════════════════════════════════════════════
|
|
77
|
+
* Activity Events — 실행 이벤트 로그
|
|
78
|
+
* ═══════════════════════════════════════════════ */
|
|
79
|
+
|
|
80
|
+
/** 모든 이벤트 타입 — ActivityStream JSONL에 기록되는 유일한 어휘 */
|
|
81
|
+
export type ActivityEventType =
|
|
82
|
+
// Job lifecycle
|
|
83
|
+
| 'job:start' | 'job:done' | 'job:error'
|
|
84
|
+
| 'job:awaiting_input' | 'job:reply'
|
|
85
|
+
// Execution
|
|
86
|
+
| 'text' | 'thinking'
|
|
87
|
+
| 'tool:start' | 'tool:result'
|
|
88
|
+
// Dispatch (child job)
|
|
89
|
+
| 'dispatch:start' | 'dispatch:done'
|
|
90
|
+
// Harness (turn limits)
|
|
91
|
+
| 'turn:complete' | 'turn:warning' | 'turn:limit'
|
|
92
|
+
// Knowledge import
|
|
93
|
+
| 'import:scan' | 'import:process' | 'import:created'
|
|
94
|
+
// Trace (full prompt/response capture for AI debugging)
|
|
95
|
+
| 'trace:prompt' | 'trace:response'
|
|
96
|
+
// Other
|
|
97
|
+
| 'stderr';
|
|
98
|
+
|
|
99
|
+
export interface ActivityEvent {
|
|
100
|
+
seq: number;
|
|
101
|
+
ts: string;
|
|
102
|
+
type: ActivityEventType;
|
|
103
|
+
roleId: string;
|
|
104
|
+
parentJobId?: string;
|
|
105
|
+
/** Trace ID — top-level jobId, inherited by all child jobs for chain tracking */
|
|
106
|
+
traceId?: string;
|
|
107
|
+
data: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ═══════════════════════════════════════════════
|
|
111
|
+
* Session — D-014 통합 세션
|
|
112
|
+
* ═══════════════════════════════════════════════ */
|
|
113
|
+
|
|
114
|
+
export type SessionStatus = 'active' | 'closed';
|
|
115
|
+
export type SessionSource = 'chat' | 'wave' | 'dispatch';
|
|
116
|
+
export type MessageStatus = 'streaming' | 'done' | 'error' | 'awaiting_input';
|
|
117
|
+
|
|
118
|
+
/* ═══════════════════════════════════════════════
|
|
119
|
+
* Wave — 조직 전파 단위
|
|
120
|
+
* ═══════════════════════════════════════════════ */
|
|
121
|
+
|
|
122
|
+
/** Wave JSON에 저장되는 role별 상태 — JobStatus와 동일 어휘 사용 */
|
|
123
|
+
export type WaveRoleStatus = JobStatus | 'unknown';
|
|
124
|
+
|
|
125
|
+
/* ═══════════════════════════════════════════════
|
|
126
|
+
* Frontend-Only 상태 (UI 전용, 백엔드에는 없음)
|
|
127
|
+
* 명시적으로 분리하여 혼동 방지
|
|
128
|
+
* ═══════════════════════════════════════════════ */
|
|
129
|
+
|
|
130
|
+
/** Wave 노드의 UI 상태 — JobStatus + UI-only 상태 */
|
|
131
|
+
export type WaveNodeStatus =
|
|
132
|
+
| JobStatus // 'running' | 'done' | 'error' | 'awaiting_input'
|
|
133
|
+
| 'waiting' // 아직 dispatch 안 됨 (UI 초기 상태)
|
|
134
|
+
| 'not-dispatched'; // wave 완료 후에도 dispatch 안 된 노드
|
|
135
|
+
|
|
136
|
+
/** WaveNode가 "활성 상태"인지 판단 — UI-only 상태 포함 */
|
|
137
|
+
export function isWaveNodeActive(status: WaveNodeStatus): boolean {
|
|
138
|
+
return status === 'running' || status === 'awaiting_input';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** SSE 연결 상태 — 네트워크 레벨, 실행 상태와 무관 */
|
|
142
|
+
export type StreamStatus = 'idle' | 'connecting' | 'streaming' | 'done' | 'error';
|
|
143
|
+
|
|
144
|
+
/** Message가 종료 상태인지 판단 */
|
|
145
|
+
export function isMessageTerminal(status: MessageStatus): boolean {
|
|
146
|
+
return status === 'done' || status === 'error';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** ActivityEventType → JobStatus 변환 (wave replay 등에서 사용) */
|
|
150
|
+
export function eventTypeToJobStatus(eventType: ActivityEventType): JobStatus | 'unknown' {
|
|
151
|
+
switch (eventType) {
|
|
152
|
+
case 'job:done': return 'done';
|
|
153
|
+
case 'job:error': return 'error';
|
|
154
|
+
case 'job:awaiting_input': return 'awaiting_input';
|
|
155
|
+
default: return 'unknown';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** TeamStatus — Role별 현재 상태 + 작업 내용 (context-assembler, runner에서 공유) */
|
|
160
|
+
export type TeamStatus = Record<string, { status: RoleStatus; task?: string }>;
|