@lightcone-ai/daemon 0.15.5 → 0.15.7
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 +1 -1
- package/src/agent-manager.js +24 -34
- package/src/browser-login.js +6 -1
package/package.json
CHANGED
package/src/agent-manager.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
2
3
|
import {
|
|
3
4
|
existsSync,
|
|
4
5
|
mkdirSync,
|
|
@@ -124,6 +125,10 @@ function normalizeObject(value) {
|
|
|
124
125
|
return isPlainObject(value) ? value : {};
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
function hashRenderedWorkspaceContext(value) {
|
|
129
|
+
return createHash('sha256').update(String(value ?? ''), 'utf8').digest('hex');
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
function normalizePublishStage(value, fallback = 'unknown') {
|
|
128
133
|
const normalized = String(value ?? '').trim().toLowerCase();
|
|
129
134
|
if (!normalized) return fallback;
|
|
@@ -768,32 +773,6 @@ export class AgentManager {
|
|
|
768
773
|
};
|
|
769
774
|
}
|
|
770
775
|
|
|
771
|
-
// Fetches the per-spawn workspace context bundle (Goal State + active
|
|
772
|
-
// context items) so the daemon can inject it into the agent's system
|
|
773
|
-
// prompt. Returns '' when there is nothing to inject; never throws — a
|
|
774
|
-
// network error or absent workspaceId just degrades to empty context, so
|
|
775
|
-
// spawn proceeds without the bundle rather than failing closed.
|
|
776
|
-
async _fetchWorkspaceContextPrompt({ agentId, workspaceId }) {
|
|
777
|
-
if (!workspaceId) return '';
|
|
778
|
-
if (!this.serverUrl || !this.machineApiKey) return '';
|
|
779
|
-
try {
|
|
780
|
-
const url = `${this.serverUrl}/internal/agent/${encodeURIComponent(agentId)}/context?workspaceId=${encodeURIComponent(workspaceId)}`;
|
|
781
|
-
const res = await fetch(url, {
|
|
782
|
-
headers: { 'Authorization': `Bearer ${this.machineApiKey}` },
|
|
783
|
-
});
|
|
784
|
-
if (!res.ok) {
|
|
785
|
-
const text = await res.text();
|
|
786
|
-
console.log(`[AgentManager] Workspace context fetch failed for ${agentId} (non-fatal): ${res.status} ${text.slice(0, 200)}`);
|
|
787
|
-
return '';
|
|
788
|
-
}
|
|
789
|
-
const payload = await res.json();
|
|
790
|
-
return typeof payload?.renderedPrompt === 'string' ? payload.renderedPrompt : '';
|
|
791
|
-
} catch (err) {
|
|
792
|
-
console.log(`[AgentManager] Workspace context fetch error for ${agentId} (non-fatal): ${err.message}`);
|
|
793
|
-
return '';
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
776
|
async _fetchSpawnDirective({
|
|
798
777
|
agentId,
|
|
799
778
|
workspaceId,
|
|
@@ -1077,14 +1056,25 @@ export class AgentManager {
|
|
|
1077
1056
|
...credentialEnvVars,
|
|
1078
1057
|
};
|
|
1079
1058
|
|
|
1080
|
-
// Inject the
|
|
1081
|
-
//
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1059
|
+
// Inject the authoritative workspace context carried by spawn-directive.
|
|
1060
|
+
// This removes the historical daemon-side second context assembly path.
|
|
1061
|
+
const renderedWorkspaceContext = typeof directive?.rendered_context_prompt === 'string'
|
|
1062
|
+
? directive.rendered_context_prompt
|
|
1063
|
+
: '';
|
|
1064
|
+
const expectedWorkspaceContextHash = typeof directive?.rendered_context_prompt_hash === 'string'
|
|
1065
|
+
? directive.rendered_context_prompt_hash.trim()
|
|
1066
|
+
: '';
|
|
1067
|
+
if (expectedWorkspaceContextHash) {
|
|
1068
|
+
const actualWorkspaceContextHash = hashRenderedWorkspaceContext(renderedWorkspaceContext);
|
|
1069
|
+
if (actualWorkspaceContextHash !== expectedWorkspaceContextHash) {
|
|
1070
|
+
console.log(
|
|
1071
|
+
`[AgentManager] Spawn directive context hash mismatch for ${agentId}: `
|
|
1072
|
+
+ `expected=${expectedWorkspaceContextHash} actual=${actualWorkspaceContextHash}`
|
|
1073
|
+
);
|
|
1074
|
+
failStart('spawn_directive_invalid_context_hash');
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1088
1078
|
const baseSystemPrompt = typeof directive?.system_prompt === 'string'
|
|
1089
1079
|
? directive.system_prompt
|
|
1090
1080
|
: '';
|
package/src/browser-login.js
CHANGED
|
@@ -64,7 +64,12 @@ export const PLATFORM_CONFIGS = {
|
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
kuaishou: {
|
|
67
|
-
|
|
67
|
+
// Go directly to the passport login page (skip the cp.kuaishou.com intro page which
|
|
68
|
+
// requires an extra "立即登录" click before the actual login form appears).
|
|
69
|
+
// callback brings the user back to cp.kuaishou.com/profile after login.
|
|
70
|
+
loginUrl: 'https://passport.kuaishou.com/pc/account/login/?sid=kuaishou.web.cp.api&callback=https%3A%2F%2Fcp.kuaishou.com%2Frest%2Finfra%2Fsts%3FfollowUrl%3Dhttps%253A%252F%252Fcp.kuaishou.com%252Fprofile%26setRootDomain%3Dtrue',
|
|
71
|
+
// Empty array enables _switchToQrLogin() which falls through to text-match "扫码登录".
|
|
72
|
+
qrTabSelector: [],
|
|
68
73
|
getSessionValue: (cookies) => cookies.find(c => c.name === 'passToken')?.value ?? null,
|
|
69
74
|
isLoggedIn: (cookies, baseline) => {
|
|
70
75
|
const val = cookies.find(c => c.name === 'passToken')?.value ?? null;
|