@lightcone-ai/daemon 0.15.5 → 0.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.15.5",
3
+ "version": "0.15.6",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -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 assembled workspace context (Goal State + active context
1081
- // items) directly into the system prompt, replacing the legacy
1082
- // "read BRIEF.md on startup" handshake. Empty workspaces leave the prompt
1083
- // unchanged.
1084
- const renderedWorkspaceContext = await this._fetchWorkspaceContextPrompt({
1085
- agentId,
1086
- workspaceId,
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
  : '';
@@ -64,7 +64,9 @@ export const PLATFORM_CONFIGS = {
64
64
  },
65
65
  },
66
66
  kuaishou: {
67
- loginUrl: 'https://www.kuaishou.com',
67
+ // Use creator platform so QR scan establishes a creator session (cp.kuaishou.com).
68
+ // www.kuaishou.com session is separate — it cannot access the creator publish APIs.
69
+ loginUrl: 'https://cp.kuaishou.com',
68
70
  getSessionValue: (cookies) => cookies.find(c => c.name === 'passToken')?.value ?? null,
69
71
  isLoggedIn: (cookies, baseline) => {
70
72
  const val = cookies.find(c => c.name === 'passToken')?.value ?? null;