feishu-codex-console 1.0.0-beta.6
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/.env.example +101 -0
- package/.feishu-codex-policy.example.json +11 -0
- package/.feishu-codex-runbooks.example.json +36 -0
- package/CHANGELOG.md +129 -0
- package/CODE_OF_CONDUCT.md +7 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE +21 -0
- package/README.en.md +81 -0
- package/README.md +398 -0
- package/ROADMAP.md +40 -0
- package/SECURITY.md +53 -0
- package/dist/account-quota-card.js +233 -0
- package/dist/account-quota.js +125 -0
- package/dist/app-server-client.js +281 -0
- package/dist/card-session.js +166 -0
- package/dist/codex-events.js +1 -0
- package/dist/codex-runner.js +875 -0
- package/dist/config.js +198 -0
- package/dist/confirmation-card.js +135 -0
- package/dist/control-card.js +345 -0
- package/dist/conversation-turn-session.js +209 -0
- package/dist/data-maintenance.js +71 -0
- package/dist/device-card.js +460 -0
- package/dist/device-health.js +94 -0
- package/dist/diagnostics.js +253 -0
- package/dist/doctor.js +250 -0
- package/dist/fallback-card-session.js +37 -0
- package/dist/health-file.js +75 -0
- package/dist/index.js +4330 -0
- package/dist/lark-cli.js +558 -0
- package/dist/lark-retry.js +34 -0
- package/dist/maintenance.js +140 -0
- package/dist/model-capabilities.js +31 -0
- package/dist/onboarding-card.js +312 -0
- package/dist/permission-lease.js +22 -0
- package/dist/policy.js +506 -0
- package/dist/progress.js +267 -0
- package/dist/project-card.js +303 -0
- package/dist/project-overview-card.js +182 -0
- package/dist/project-overview.js +278 -0
- package/dist/project-policy.js +160 -0
- package/dist/project-registry.js +259 -0
- package/dist/project-status.js +45 -0
- package/dist/project-workspace.js +55 -0
- package/dist/quota-card.js +94 -0
- package/dist/recovery-policy.js +26 -0
- package/dist/redaction.js +67 -0
- package/dist/remote-ready.js +112 -0
- package/dist/response-card.js +139 -0
- package/dist/result-card.js +166 -0
- package/dist/review-card.js +452 -0
- package/dist/runbook-card.js +272 -0
- package/dist/runbooks.js +191 -0
- package/dist/runtime-card.js +337 -0
- package/dist/session-card.js +128 -0
- package/dist/session-naming.js +14 -0
- package/dist/smoke.js +28 -0
- package/dist/state-backup.js +302 -0
- package/dist/state-store.js +874 -0
- package/dist/task-card.js +640 -0
- package/dist/task-center-card.js +176 -0
- package/dist/task-failure.js +43 -0
- package/dist/task-intent.js +76 -0
- package/dist/task-queue.js +187 -0
- package/dist/task-reconciliation.js +80 -0
- package/dist/task-review.js +497 -0
- package/dist/team-card.js +275 -0
- package/dist/team-directory.js +54 -0
- package/dist/team-policy.js +93 -0
- package/dist/types.js +1 -0
- package/dist/version.js +9 -0
- package/dist/workspace-session.js +64 -0
- package/docs/ARCHITECTURE.md +54 -0
- package/docs/COMPATIBILITY.md +55 -0
- package/docs/CONFIGURATION.md +88 -0
- package/docs/DEMO.md +45 -0
- package/docs/GOOD_FIRST_ISSUES.md +23 -0
- package/docs/INSTALLATION.md +207 -0
- package/docs/OPEN_SOURCE_PRODUCT_PLAN.md +113 -0
- package/docs/PRODUCT_REQUIREMENTS_MAP.md +591 -0
- package/docs/RELEASE_CHECKLIST.md +65 -0
- package/docs/TEAM_DEPLOYMENT.md +35 -0
- package/docs/TROUBLESHOOTING.md +130 -0
- package/docs/V4_WORKSPACE_SESSION_FLOW.md +232 -0
- package/docs/requirements/D10_MAINTENANCE_AND_ECOSYSTEM.md +103 -0
- package/docs/requirements/D1_INSTALLATION_AND_FIRST_CONNECTION.md +479 -0
- package/docs/requirements/D2_DEVICE_AND_CONNECTIVITY.md +54 -0
- package/docs/requirements/D3_PROJECTS_AND_SESSIONS.md +107 -0
- package/docs/requirements/D4_REMOTE_TASK_EXECUTION.md +102 -0
- package/docs/requirements/D5_CODEX_NATIVE_INTERACTIONS.md +99 -0
- package/docs/requirements/D6_RESULTS_AND_CODE_REVIEW.md +100 -0
- package/docs/requirements/D7_SECURITY_GOVERNANCE.md +106 -0
- package/docs/requirements/D8_RELIABILITY_AND_RECOVERY.md +182 -0
- package/docs/requirements/D9_TEAM_COLLABORATION.md +129 -0
- package/package.json +76 -0
- package/scripts/capability-probe.mjs +113 -0
- package/scripts/cli.mjs +919 -0
- package/scripts/config-file.mjs +137 -0
- package/scripts/discovery-lib.mjs +78 -0
- package/scripts/install-card.mjs +37 -0
- package/scripts/install-detection.mjs +126 -0
- package/scripts/install-state.mjs +107 -0
- package/scripts/launchd.mjs +161 -0
- package/scripts/migrate-legacy.mjs +97 -0
- package/scripts/package-smoke.mjs +163 -0
- package/scripts/release-dist-tag.mjs +7 -0
- package/scripts/runbook-template.mjs +36 -0
- package/scripts/service-health.mjs +110 -0
- package/scripts/service.mjs +24 -0
- package/scripts/setup-lib.mjs +118 -0
- package/scripts/systemd.mjs +96 -0
- package/scripts/upgrade-lib.mjs +99 -0
- package/scripts/verify-release.mjs +37 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { applyCodexEvent, attachTaskReview, cancelTask, failTask, interruptTask, noteSteer, noteTask, recoverTask, startTask, succeedTask, updateQueuePosition, updateTaskCollaboration, } from "./progress.js";
|
|
2
|
+
import { renderStreamContent, renderTaskCard, } from "./task-card.js";
|
|
3
|
+
const STREAM_THROTTLE_MS = 700;
|
|
4
|
+
export class TaskCardSession {
|
|
5
|
+
lark;
|
|
6
|
+
cardId;
|
|
7
|
+
messageId;
|
|
8
|
+
current;
|
|
9
|
+
sequence = 0;
|
|
10
|
+
operationChain = Promise.resolve();
|
|
11
|
+
pendingContent = "";
|
|
12
|
+
lastContent = "";
|
|
13
|
+
streamTimer = null;
|
|
14
|
+
snapshotListener;
|
|
15
|
+
constructor(lark, cardId, messageId, current, sequence = 0) {
|
|
16
|
+
this.lark = lark;
|
|
17
|
+
this.cardId = cardId;
|
|
18
|
+
this.messageId = messageId;
|
|
19
|
+
this.current = current;
|
|
20
|
+
this.sequence = sequence;
|
|
21
|
+
this.lastContent = renderStreamContent(current);
|
|
22
|
+
}
|
|
23
|
+
static async create(lark, progress, replyToMessageId, idempotencyKey, replyInThread = false) {
|
|
24
|
+
const cardId = await lark.createCard(renderTaskCard(progress));
|
|
25
|
+
const messageId = await lark.replyCard(replyToMessageId, cardId, idempotencyKey, replyInThread);
|
|
26
|
+
return new TaskCardSession(lark, cardId, messageId ?? "", progress);
|
|
27
|
+
}
|
|
28
|
+
static restore(lark, cardId, messageId, progress, sequence) {
|
|
29
|
+
return new TaskCardSession(lark, cardId, messageId, progress, sequence);
|
|
30
|
+
}
|
|
31
|
+
get progress() {
|
|
32
|
+
return this.current;
|
|
33
|
+
}
|
|
34
|
+
get sequenceNumber() {
|
|
35
|
+
return this.sequence;
|
|
36
|
+
}
|
|
37
|
+
onSnapshot(listener) {
|
|
38
|
+
this.snapshotListener = listener;
|
|
39
|
+
}
|
|
40
|
+
async markRunning(reviewBaseline, permissionLabel) {
|
|
41
|
+
this.current = startTask(this.current, Date.now(), reviewBaseline, permissionLabel);
|
|
42
|
+
await this.updateFullCard("start");
|
|
43
|
+
}
|
|
44
|
+
async markRecovered(note, queuePosition = 1) {
|
|
45
|
+
this.current = recoverTask(this.current, queuePosition, note);
|
|
46
|
+
await this.updateFullCard("recover");
|
|
47
|
+
}
|
|
48
|
+
async updateQueuePosition(queuePosition) {
|
|
49
|
+
const next = updateQueuePosition(this.current, queuePosition);
|
|
50
|
+
if (next === this.current)
|
|
51
|
+
return;
|
|
52
|
+
this.current = next;
|
|
53
|
+
await this.updateFullCard("queue-position");
|
|
54
|
+
}
|
|
55
|
+
async markSteered() {
|
|
56
|
+
this.current = noteSteer(this.current);
|
|
57
|
+
await this.updateFullCard("steer");
|
|
58
|
+
}
|
|
59
|
+
handleCodexEvent(event) {
|
|
60
|
+
this.current = applyCodexEvent(this.current, event);
|
|
61
|
+
this.scheduleStream(renderStreamContent(this.current));
|
|
62
|
+
}
|
|
63
|
+
async finishSucceeded(finalResponse, usage, threadId) {
|
|
64
|
+
this.current = succeedTask(this.current, finalResponse, usage, threadId);
|
|
65
|
+
return this.updateFullCard("complete");
|
|
66
|
+
}
|
|
67
|
+
async finishFailed(error) {
|
|
68
|
+
this.current = failTask(this.current, error);
|
|
69
|
+
return this.updateFullCard("fail");
|
|
70
|
+
}
|
|
71
|
+
async finishCancelled(reason) {
|
|
72
|
+
if (this.current.phase === "cancelled")
|
|
73
|
+
return true;
|
|
74
|
+
this.current = cancelTask(this.current, reason);
|
|
75
|
+
return this.updateFullCard("cancel");
|
|
76
|
+
}
|
|
77
|
+
async finishInterrupted(reason) {
|
|
78
|
+
this.current = interruptTask(this.current, reason);
|
|
79
|
+
return this.updateFullCard("interrupt");
|
|
80
|
+
}
|
|
81
|
+
async addActionNote(note) {
|
|
82
|
+
this.current = noteTask(this.current, note);
|
|
83
|
+
await this.updateFullCard("note");
|
|
84
|
+
}
|
|
85
|
+
async updateCollaboration(context, note) {
|
|
86
|
+
this.current = updateTaskCollaboration(this.current, context, note);
|
|
87
|
+
await this.updateFullCard("collaboration");
|
|
88
|
+
}
|
|
89
|
+
async attachReview(review) {
|
|
90
|
+
this.current = attachTaskReview(this.current, review);
|
|
91
|
+
await this.updateFullCard("review");
|
|
92
|
+
}
|
|
93
|
+
async showSurface(card, label = "surface") {
|
|
94
|
+
await this.flushStream();
|
|
95
|
+
return this.enqueue(label, async () => {
|
|
96
|
+
this.sequence += 1;
|
|
97
|
+
await this.lark.updateCard(this.cardId, card, this.sequence);
|
|
98
|
+
await this.notifySnapshot();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
async restoreTaskSurface() {
|
|
102
|
+
return this.updateFullCard("restore-task");
|
|
103
|
+
}
|
|
104
|
+
async flush() {
|
|
105
|
+
await this.flushStream();
|
|
106
|
+
await this.operationChain;
|
|
107
|
+
}
|
|
108
|
+
scheduleStream(content) {
|
|
109
|
+
this.pendingContent = content;
|
|
110
|
+
if (this.streamTimer)
|
|
111
|
+
return;
|
|
112
|
+
this.streamTimer = setTimeout(() => {
|
|
113
|
+
this.streamTimer = null;
|
|
114
|
+
void this.flushStream();
|
|
115
|
+
}, STREAM_THROTTLE_MS);
|
|
116
|
+
this.streamTimer.unref();
|
|
117
|
+
}
|
|
118
|
+
async flushStream() {
|
|
119
|
+
if (this.streamTimer) {
|
|
120
|
+
clearTimeout(this.streamTimer);
|
|
121
|
+
this.streamTimer = null;
|
|
122
|
+
}
|
|
123
|
+
const content = this.pendingContent;
|
|
124
|
+
this.pendingContent = "";
|
|
125
|
+
if (!content || content === this.lastContent)
|
|
126
|
+
return;
|
|
127
|
+
await this.enqueue("stream", async () => {
|
|
128
|
+
this.sequence += 1;
|
|
129
|
+
await this.lark.streamCardContent(this.cardId, "stream_text", content, this.sequence);
|
|
130
|
+
this.lastContent = content;
|
|
131
|
+
await this.notifySnapshot();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async updateFullCard(label) {
|
|
135
|
+
await this.flushStream();
|
|
136
|
+
const card = renderTaskCard(this.current);
|
|
137
|
+
const content = renderStreamContent(this.current);
|
|
138
|
+
return this.enqueue(label, async () => {
|
|
139
|
+
this.sequence += 1;
|
|
140
|
+
await this.lark.updateCard(this.cardId, card, this.sequence);
|
|
141
|
+
this.lastContent = content;
|
|
142
|
+
await this.notifySnapshot();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async enqueue(label, operation) {
|
|
146
|
+
const next = this.operationChain.then(operation);
|
|
147
|
+
this.operationChain = next.catch((error) => {
|
|
148
|
+
console.error(`[card] ${label} update failed card=${this.cardId}`, error);
|
|
149
|
+
});
|
|
150
|
+
try {
|
|
151
|
+
await next;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async notifySnapshot() {
|
|
159
|
+
await this.snapshotListener?.({
|
|
160
|
+
cardId: this.cardId,
|
|
161
|
+
messageId: this.messageId,
|
|
162
|
+
sequence: this.sequence,
|
|
163
|
+
progress: this.current,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|