fuli-context 0.27.15 → 0.27.16

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.
Files changed (32) hide show
  1. package/dist/web/assets/{CopyFixPrompt-DEGrc4au.js → CopyFixPrompt-Bv_caDTd.js} +1 -1
  2. package/dist/web/assets/{SettingsPage-CSs4nimS.css → SettingsPage-Docv0Ilr.css} +1 -1
  3. package/dist/web/assets/SettingsPage-c41pV5VX.js +3 -0
  4. package/dist/web/assets/TodayPage-BTpt-4Kd.css +1 -0
  5. package/dist/web/assets/{TodayPage-Cx01cAUV.js → TodayPage-Dw3et7sK.js} +1 -1
  6. package/dist/web/assets/{index-v2PfAWGl.js → index-CrFuVoTH.js} +3 -3
  7. package/dist/web/assets/{version-BSosoSQY.js → version-BWAXzwxb.js} +1 -1
  8. package/dist/web/index.html +3 -3
  9. package/graph-provider/fuli_graph/store_task_contexts.py +42 -8
  10. package/graph-provider/pyproject.toml +1 -1
  11. package/native/win32/fuli-win-helper.exe +0 -0
  12. package/npm-shrinkwrap.json +2 -2
  13. package/package.json +1 -1
  14. package/skills/capturing-session-knowledge/SKILL.md +2 -0
  15. package/skills/operating-fuli/SKILL.md +1 -1
  16. package/src/agent-introductions/store.js +83 -0
  17. package/src/agent-roundtable/turn-receipt.js +2 -1
  18. package/src/agents/identity-receipt.js +5 -2
  19. package/src/data-format/local-stores.js +13 -1
  20. package/src/desktop-glance/glance.js +32 -5
  21. package/src/graphiti/collaboration-preference-entry.js +1 -1
  22. package/src/graphiti/local-runtimes.js +13 -0
  23. package/src/graphiti/session-capture-pause-request.js +3 -1
  24. package/src/graphiti/task-entry-introduction.js +135 -0
  25. package/src/graphiti/task-entry-preferences.js +8 -2
  26. package/src/graphiti/task-entry-project-scope.js +7 -3
  27. package/src/graphiti/task-knowledge-checkpoint.js +2 -1
  28. package/src/graphiti/task-preference-reader.js +3 -1
  29. package/src/presence/windows-helper-pin.js +1 -1
  30. package/src/whats-new/lines/0.27.16.json +13 -0
  31. package/dist/web/assets/SettingsPage-CGO8HYEC.js +0 -3
  32. package/dist/web/assets/TodayPage-AZR8M_JV.css +0 -1
@@ -9,7 +9,7 @@
9
9
  />
10
10
  <link rel="icon" href="/favicon.ico" sizes="any" />
11
11
  <title>复利 · Context Graph</title>
12
- <script type="module" crossorigin src="/assets/index-v2PfAWGl.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-CrFuVoTH.js"></script>
13
13
  <link rel="modulepreload" crossorigin href="/assets/_plugin-vue_export-helper-BB4OD0pm.js">
14
14
  <link rel="modulepreload" crossorigin href="/assets/runtime-dom.esm-bundler-KYUj_0oy.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/client-Czx1m2q7.js">
@@ -63,7 +63,7 @@
63
63
  <link rel="modulepreload" crossorigin href="/assets/source-adapters-DWeqGlv1.js">
64
64
  <link rel="modulepreload" crossorigin href="/assets/label-table-D4SR42iJ.js">
65
65
  <link rel="modulepreload" crossorigin href="/assets/settings-tabs-CkbYPvea.js">
66
- <link rel="modulepreload" crossorigin href="/assets/version-BSosoSQY.js">
66
+ <link rel="modulepreload" crossorigin href="/assets/version-BWAXzwxb.js">
67
67
  <link rel="modulepreload" crossorigin href="/assets/motion-preference-ByJGpZkg.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/role-names-BYQ6Ejew.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/AgentAvatar-C-qXHE1H.js">
@@ -89,7 +89,7 @@
89
89
  <link rel="modulepreload" crossorigin href="/assets/review-store-BLlMfs2O.js">
90
90
  <link rel="modulepreload" crossorigin href="/assets/roundtable-live-CR0oX3WO.js">
91
91
  <link rel="modulepreload" crossorigin href="/assets/motion-D-CCN29z.js">
92
- <link rel="modulepreload" crossorigin href="/assets/CopyFixPrompt-DEGrc4au.js">
92
+ <link rel="modulepreload" crossorigin href="/assets/CopyFixPrompt-Bv_caDTd.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/agent-identity-color-RqpT7gtx.js">
94
94
  <link rel="modulepreload" crossorigin href="/assets/task-evidence-D0XkNnb8.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/useAgentRecords-D4Ugm9rW.js">
@@ -42,6 +42,31 @@ def foreign_client_detail(begun_in, used_in):
42
42
  'including checkpoint_task_knowledge.')
43
43
 
44
44
 
45
+ # What the tray menu holds of a task's title; it cuts further to fit.
46
+ TASK_TITLE_CHARS = 60
47
+
48
+
49
+ def shown_task_title(board_title, work_log_json):
50
+ """A task's board title, else the first line of its work summary, cut short.
51
+
52
+ A task context keeps no prompt, so a task without either has no title.
53
+ """
54
+ # A work log that does not read leaves the title to the board alone: the
55
+ # tray read must not fail on one task's record.
56
+ try:
57
+ log = json.loads(work_log_json or 'null')
58
+ except ValueError:
59
+ log = None
60
+ summary = log.get('summary') if isinstance(log, dict) else None
61
+ if not isinstance(summary, str):
62
+ summary = None
63
+ for text in (board_title, summary):
64
+ line = next((part.strip() for part in (text or '').splitlines() if part.strip()), '')
65
+ if line:
66
+ return line[:TASK_TITLE_CHARS]
67
+ return None
68
+
69
+
45
70
  class StoreTaskContexts:
46
71
  async def adopt_task_context_agent(self, actor, token, request):
47
72
  async with query_store_transaction(self) as scoped:
@@ -232,10 +257,11 @@ class StoreTaskContexts:
232
257
 
233
258
  async def recent_working_agents(self, actor, space_id, since):
234
259
  """Each Agent that began a task since `since`, the latest first: when its
235
- latest task began and whether one of them is under way (its session's
236
- current task, not yet closed). The tray menu asks every few seconds, so
237
- the read starts from the space's task index and looks up a session only
238
- for the tasks in the window."""
260
+ latest task began, whether one of them is under way (its session's
261
+ current task, not yet closed), and the project and a short title of the
262
+ task it is on (the latest under way, else the latest). The tray menu
263
+ asks every few seconds, so the read starts from the space's task index
264
+ and looks up a session only for the tasks in the window."""
239
265
  self._require_personal()
240
266
  await self.authorize(actor, space_id, 'reader')
241
267
  rows, _, _ = await self.runtime.driver.execute_query(
@@ -243,14 +269,22 @@ class StoreTaskContexts:
243
269
  MATCH (task:FuliTaskContext {personal_space_id: $space_id})
244
270
  WHERE task.project_agent_id IS NOT NULL AND task.created_at >= $since
245
271
  MATCH (session:FuliTaskContextSession)-[:HAS_CONTEXT]->(task)
246
- RETURN task.project_agent_id AS agent_id, max(task.created_at) AS last_active,
247
- sum(CASE WHEN task.token = session.current_token
248
- AND NOT coalesce(task.completed, false) THEN 1 ELSE 0 END) > 0 AS working
272
+ WITH task, coalesce(task.token = session.current_token, false)
273
+ AND NOT coalesce(task.completed, false) AS under_way
274
+ ORDER BY under_way DESC, task.created_at DESC
275
+ WITH task.project_agent_id AS agent_id, max(task.created_at) AS last_active,
276
+ sum(CASE WHEN under_way THEN 1 ELSE 0 END) > 0 AS working, collect(task)[0] AS shown
277
+ RETURN agent_id, last_active, working, shown.personal_project_id AS project_id,
278
+ CASE WHEN shown.scrubbed_by IS NULL THEN head([(shown)-[:COORDINATES_TASK]->
279
+ (linked:FuliProjectAgentTask) | linked.title]) END AS board_title,
280
+ CASE WHEN shown.scrubbed_by IS NULL THEN shown.work_log_json END AS work_log_json
249
281
  ORDER BY last_active DESC, agent_id
250
282
  ''', space_id=space_id, since=since, routing_='r',
251
283
  )
252
284
  return [{'agent_id': row['agent_id'], 'working': row['working'],
253
- 'last_active': native_datetime(row['last_active']).isoformat()} for row in rows]
285
+ 'last_active': native_datetime(row['last_active']).isoformat(),
286
+ 'personal_project_id': row['project_id'],
287
+ 'title': shown_task_title(row['board_title'], row['work_log_json'])} for row in rows]
254
288
 
255
289
  async def get_task_context(self, actor, space_id, token, source_application):
256
290
  self._require_personal()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fuli-graph-provider"
3
- version = "0.27.15"
3
+ version = "0.27.16"
4
4
  description = "Graphiti-backed personal and shared project provider for Fuli."
5
5
  requires-python = ">=3.12"
6
6
  dependencies = [
Binary file
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "fuli-context",
3
- "version": "0.27.15",
3
+ "version": "0.27.16",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "fuli-context",
9
- "version": "0.27.15",
9
+ "version": "0.27.16",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "1.5.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuli-context",
3
- "version": "0.27.15",
3
+ "version": "0.27.16",
4
4
  "description": "Local-first collaboration relationship graph for AI agents.",
5
5
  "type": "module",
6
6
  "files": [
@@ -70,6 +70,8 @@ Every final user-visible reply MUST include the current task’s `agent_receipt.
70
70
 
71
71
  A `FULI 习惯:…` line is part of `agent_receipt.markdown`: copy it unchanged. Never count habits yourself, reword it, or add it to a receipt that lacks it.
72
72
 
73
+ The line under the owner's name in which an FLA introduces itself (a new FLA's first task for the person, or a project's lead passing to it from another FLA) is part of `agent_receipt.markdown` too, once: copy it unchanged, never write one yourself or repeat it on a later turn. A checkpoint or roundtable receipt, or a second entry, of the same turn carries it.
74
+
73
75
  Apply only `effective_preferences`. Personal-global preferences apply in every user task;
74
76
  project-scoped preferences layer on only for the exact selected project. Do not apply items
75
77
  listed as conflicts, and do not borrow preferences from a related, similarly named, or guessed
@@ -135,7 +135,7 @@ Read each returned worker's `context.agent.profile.allowedClients` and `executor
135
135
 
136
136
  Every final user-visible reply MUST include the current task’s `agent_receipt.markdown` unchanged exactly once. This includes greetings, status-only replies, failures, `retain_nothing`, and capture-disabled tasks. The receipt is independent of whether a memory checkpoint was saved. Never substitute a client name, configured peer, or an earlier task’s owner. If a legacy/unavailable entry supplies no receipt, explicitly state that the FULI Agent identity is unavailable. When `get_collaboration_preferences` returns `status: preferences_unavailable` (FULI's graph service did not answer), follow its `guidance`: continue without FULI preferences, retry it once before any FULI write or the final reply, and never reuse an earlier token. When `checkpoint_task_knowledge` returns `status: checkpoint_incomplete`, retry it once with exactly the same arguments (FULI may already keep the first input; changed wording is refused) and do not claim the task was saved until it returns `checkpointed`. When it returns `status: checkpoint_not_saved`, this connection's token was refused before anything was written, so this call saved nothing: tell the person in one line that this task's knowledge is not saved in FULI yet, call `get_collaboration_preferences` through this connection for a token of its own, and send the same content again with it in this conversation. A receipt with no authorized owner already supplies the correct neutral text.
137
137
 
138
- A `FULI 迁移已确认:…` line in the entry receipt means the person already confirmed, in the console, moving this session's temporary-project items: it says how many moved and how many still wait there. Do not ask them to confirm it again; continue the work. The line is information only and grants nothing. A `FULI 待迁移` line is the opposite: the move still waits on the linked page. A `FULI 习惯:…` line is part of `agent_receipt.markdown`: copy it unchanged. Never count habits yourself, reword it, or add it to a receipt that lacks it.
138
+ A `FULI 迁移已确认:…` line in the entry receipt means the person already confirmed, in the console, moving this session's temporary-project items: it says how many moved and how many still wait there. Do not ask them to confirm it again; continue the work. The line is information only and grants nothing. A `FULI 待迁移` line is the opposite: the move still waits on the linked page. A `FULI 习惯:…` line is part of `agent_receipt.markdown`: copy it unchanged. Never count habits yourself, reword it, or add it to a receipt that lacks it. The same holds for the line under the owner's name in which an FLA introduces itself (a new FLA's first task for the person, or a project's lead passing to it from another FLA): FULI adds it once, a checkpoint or roundtable receipt, or a second entry, of that turn carries it, and you never write or repeat one.
139
139
 
140
140
  ## Completion response
141
141
 
@@ -0,0 +1,83 @@
1
+ import { existsSync } from 'node:fs';
2
+
3
+ import { immediateTransaction, openFormattedDatabase, sqliteFormat } from '../../packages/roundtable/src/storage/database-format.js';
4
+
5
+ // Which FLAs the person already knows, and who last owned each project's
6
+ // tasks, so a receipt says "nice to meet you" once per new FLA and "handed
7
+ // over to me" once per change of a project's owner. An FLA created before
8
+ // introductions began (introductions_since, the moment this store was
9
+ // created) is known without one. IDs and the owner's display name only; no
10
+ // task content.
11
+ export const AGENT_INTRODUCTIONS_FILE = 'agent-introductions.sqlite';
12
+ export const AGENT_INTRODUCTIONS_FORMAT = sqliteFormat({
13
+ store: 'agent-introductions',
14
+ schema: `
15
+ CREATE TABLE IF NOT EXISTS introductions_since(
16
+ id INTEGER PRIMARY KEY CHECK(id = 1), since TEXT NOT NULL);
17
+ CREATE TABLE IF NOT EXISTS known_agents(
18
+ personal_space_id TEXT NOT NULL, agent_id TEXT NOT NULL, known_at TEXT NOT NULL,
19
+ PRIMARY KEY(personal_space_id, agent_id));
20
+ CREATE TABLE IF NOT EXISTS project_owners(
21
+ personal_space_id TEXT NOT NULL, personal_project_id TEXT NOT NULL, agent_id TEXT NOT NULL,
22
+ agent_name TEXT, recorded_at TEXT NOT NULL, PRIMARY KEY(personal_space_id, personal_project_id));`
23
+ });
24
+
25
+ export class AgentIntroductionStore {
26
+ constructor(path = ':memory:') {
27
+ this.path = path;
28
+ }
29
+
30
+ get db() {
31
+ this.database ??= openFormattedDatabase(this.path, AGENT_INTRODUCTIONS_FORMAT);
32
+ return this.database;
33
+ }
34
+
35
+ // Creates the store the first time FULI opens this data directory with it,
36
+ // keeping when introductions began (since(), asked only then): only an FLA
37
+ // created after it is new to the person. An existing file is not opened.
38
+ begin(since) {
39
+ if (this.path !== ':memory:' && existsSync(this.path)) return;
40
+ this.db.prepare('INSERT OR IGNORE INTO introductions_since VALUES(1, ?)').run(since());
41
+ }
42
+
43
+ // This entry's owner meets the person: whether it is new to them (created
44
+ // after introductions began and not met yet), and the project's previous
45
+ // owner when it changed. Both are recorded at once, so each is reported
46
+ // once. projectId null leaves the projects' owners alone. An entry that
47
+ // changes nothing reads and writes nothing else.
48
+ meet({ personalSpaceId, agentId, agentCreatedAt = null, agentName = null, projectId = null, at }) {
49
+ const seen = () => ({
50
+ known: Boolean(this.db.prepare('SELECT 1 FROM known_agents WHERE personal_space_id = ? AND agent_id = ?')
51
+ .get(personalSpaceId, agentId)),
52
+ owner: projectId ? this.db.prepare(`SELECT agent_id, agent_name FROM project_owners
53
+ WHERE personal_space_id = ? AND personal_project_id = ?`).get(personalSpaceId, projectId) ?? null : null
54
+ });
55
+ const current = owner => !projectId || (owner?.agent_id === agentId && owner.agent_name === agentName);
56
+ const before = seen();
57
+ if (before.known && current(before.owner)) return { firstMeeting: false, previousOwner: null };
58
+ return immediateTransaction(this.db, () => {
59
+ const { known, owner } = seen();
60
+ if (!known) this.db.prepare('INSERT INTO known_agents VALUES(?, ?, ?)').run(personalSpaceId, agentId, at);
61
+ if (!current(owner)) {
62
+ this.db.prepare(`INSERT INTO project_owners VALUES(?, ?, ?, ?, ?) ON CONFLICT(personal_space_id, personal_project_id)
63
+ DO UPDATE SET agent_id = excluded.agent_id, agent_name = excluded.agent_name, recorded_at = excluded.recorded_at`)
64
+ .run(personalSpaceId, projectId, agentId, agentName, at);
65
+ }
66
+ return { firstMeeting: !known && createdSince(this.db, agentCreatedAt),
67
+ previousOwner: owner && owner.agent_id !== agentId ? { agentId: owner.agent_id, name: owner.agent_name } : null };
68
+ });
69
+ }
70
+
71
+ close() {
72
+ this.database?.close();
73
+ this.database = null;
74
+ }
75
+ }
76
+
77
+ // An FLA whose creation time is unknown, or before introductions began, is
78
+ // one the person already works with.
79
+ function createdSince(db, agentCreatedAt) {
80
+ const since = db.prepare('SELECT since FROM introductions_since WHERE id = 1').get()?.since;
81
+ const created = Date.parse(agentCreatedAt ?? '');
82
+ return Boolean(since) && Number.isFinite(created) && created >= Date.parse(since);
83
+ }
@@ -1,5 +1,6 @@
1
1
  import { taskAgentReceipt, withReceiptLines } from '../agents/identity-receipt.js';
2
2
  import { storedHabitsLine } from '../graphiti/turn-receipt-delivery.js';
3
+ import { introductionReceiptLine } from '../graphiti/task-entry-introduction.js';
3
4
 
4
5
  // A turn that used the roundtable says so where the reply is signed (Jevons
5
6
  // 11-11): 「FULI Agents:A & B」 with a link to the conversation. A task is one
@@ -58,7 +59,7 @@ export async function withRoundtableReceipt(app, name, input, result) {
58
59
  .catch(() => null);
59
60
  const receipt = taskAgentReceipt(app, { projectId: task.personalProjectId, agentId: task.projectAgentId,
60
61
  name: owner?.profile?.display_name ?? null, role: owner?.profile?.name ?? null,
61
- sourceApplication: task.sourceApplication, roundtable: roundtableTurn(token) });
62
+ sourceApplication: task.sourceApplication, roundtable: roundtableTurn(token), introduction: introductionReceiptLine(task) });
62
63
  // It replaces the entry receipt, so the first task of a new conversation keeps its habits line.
63
64
  const { markdown } = withReceiptLines(receipt, [storedHabitsLine(app, task)].filter(Boolean));
64
65
  return { ...result, agent_receipt: { required: true, markdown, guidance: RECEIPT_NOTE } };
@@ -71,12 +71,14 @@ export function roundtableThreadUrl(application, threadId) {
71
71
  // One FLA signs 「FULI Agent:A」; with others, 「FULI Agents:A & B」. roundtable
72
72
  // ({ threads, peers }) is what this turn used of the roundtable: the FLAs that
73
73
  // took part join the line and each conversation gets a 「圆桌对话详情」 link.
74
+ // introduction is the owner's own line under it, the turn it introduces
75
+ // itself (task-entry-introduction.js), already Markdown-escaped.
74
76
  export const RECEIPT_GUIDANCE = 'MUST end every final user-visible reply with agent_receipt.markdown unchanged, exactly once: greetings, status, errors, even with capture disabled or nothing retained. checkpoint_task_knowledge receipt overrides entry and names actual collaborators. Never invent owners or collaborators.';
75
77
 
76
78
  export function taskAgentReceipt(application, { projectId, agentId, name = null, role = null,
77
79
  sourceApplication = null, workStatus = null, conversationId = null, persistence = null,
78
80
  collaborators = [], assignmentStatus = null, assignmentReason = null, notices = [], turnReceipt = null,
79
- roundtable = null }) {
81
+ roundtable = null, introduction = null }) {
80
82
  const owner = agentId ? { agent_id: agentId, name,
81
83
  profile_url: agentProfileUrl(application, agentId), source_application: sourceApplication } : null;
82
84
  const helpers = owner ? [...new Map(collaborators.filter(item => item.agentId !== agentId)
@@ -90,7 +92,8 @@ export function taskAgentReceipt(application, { projectId, agentId, name = null,
90
92
  ? `FULI Agent${helpers.length + peers.length ? 's' : ''}:${[agentLink(application, agentId, name, role),
91
93
  ...helpers.map(item => collaboratorLink(application, item)),
92
94
  ...peers.map(peer => agentLink(application, peer.agentId, peer.name))].join(' & ')}`
93
- : unassignedReceipt(assignmentStatus, assignmentReason), ...threads, ...notices].join(' · '), owner,
95
+ : unassignedReceipt(assignmentStatus, assignmentReason), ...threads, ...notices].join(' · ')
96
+ + (owner && introduction ? `\n${introduction}` : ''), owner,
94
97
  collaborators: helpers.map(item => ({ agent_id: item.agentId, name: item.name,
95
98
  profile_url: agentProfileUrl(application, item.agentId),
96
99
  ...(item.responsibility ? { responsibility: item.responsibility } : {}),
@@ -1,5 +1,5 @@
1
1
  import { CLIENT_PACK_FORMAT } from '../setup/agents/client-pack-store.js';
2
- import { readdirSync } from 'node:fs';
2
+ import { existsSync, readdirSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
 
5
5
  import { COORDINATOR_FORMAT } from '../../packages/roundtable/src/peer/coordinator-store.js';
@@ -12,6 +12,7 @@ import { AGENT_APP_FORMAT } from '../agent-apps/store.js';
12
12
  import { AGENT_SERVICES_FORMAT } from '../agent-services/store.js';
13
13
  import { AGENT_WORKFLOWS_FORMAT } from '../agent-workflows/store.js';
14
14
  import { RECALL_IMPRESSIONS_FORMAT } from '../knowledge-impressions/store.js';
15
+ import { AGENT_INTRODUCTIONS_FILE, AGENT_INTRODUCTIONS_FORMAT } from '../agent-introductions/store.js';
15
16
  import { AGENT_AVATARS_FORMAT } from '../agent-avatars/store.js';
16
17
  import { PROJECT_CHANGE_LOG_FORMAT } from '../project-change-log/store.js';
17
18
  import { WORK_SURFACES_FORMAT } from '../work-surfaces/store.js';
@@ -91,6 +92,8 @@ const sqliteStores = () => [
91
92
  ['agent-workflows.sqlite', AGENT_WORKFLOWS_FORMAT],
92
93
  // Which knowledge items the automatic task-entry recall showed and which the Agent reported using (rec#63); ids only.
93
94
  ['recall-impressions.sqlite', RECALL_IMPRESSIONS_FORMAT],
95
+ // Which FLAs introduced themselves to the person and who last owned each project's tasks; ids and names only.
96
+ [AGENT_INTRODUCTIONS_FILE, AGENT_INTRODUCTIONS_FORMAT],
94
97
  // Each Agent's look as the person chose it, every earlier choice kept (rec#11 D-89).
95
98
  ['agent-avatars.sqlite', AGENT_AVATARS_FORMAT],
96
99
  // Which recommended Skills and MCP servers of its occupation kit each FLA uses, every answer kept.
@@ -196,6 +199,15 @@ const logStores = () => [
196
199
  const STATE_ORDER = ['unavailable', 'newer_format', 'half_applied', 'pending_confirmation', 'unsupported',
197
200
  'unreadable', 'upgrade_on_open', 'unversioned', 'current', 'empty', 'absent'];
198
201
 
202
+ // Whether FULI already kept data in this directory: one of its SQLite stores
203
+ // or per-session record directories other than `except`, all created by use.
204
+ // The JSON files setup writes (settings, runtime configuration) do not count,
205
+ // so a new installation reads as one that kept nothing yet.
206
+ export function keptDataBefore(dataDir, except = []) {
207
+ return [...sqliteStores(), ...jsonDirectories()].some(([label]) => !except.includes(label)
208
+ && existsSync(join(dataDir, label)));
209
+ }
210
+
199
211
  // The single-file stores of one data directory: each kind's engine can
200
212
  // preview, apply, undo and restore them (migration-plan.js).
201
213
  export function localStoreFiles(dataDir) {
@@ -1,3 +1,4 @@
1
+ import { AUTO_CLOSE_SUMMARY, AUTO_KEEP_REASON } from '../conversations/stop-auto-close.js';
1
2
  import { withoutControls } from '../text/control-characters.js';
2
3
  import { singleLineExcerpt } from '../text/single-line.js';
3
4
 
@@ -7,8 +8,10 @@ import { singleLineExcerpt } from '../text/single-line.js';
7
8
  // works wherever a client session begins a task as it, so the rows come from
8
9
  // the task entries, not from the task board. A day is dozens of entries, so the
9
10
  // menu gets the few rows it can hold and how many more there are, never the
10
- // history, and no prompt or summary text. Each row names the console page it
11
- // opens as a fuli:// link.
11
+ // history. An assistant's row also names the project of the task it is on and
12
+ // a short title of it (its board task's, else the first line of its work
13
+ // summary; no prompt is kept), shown only in this computer's own menu, never
14
+ // logged. Each row names the console page it opens as a fuli:// link.
12
15
 
13
16
  const WINDOW_MS = 24 * 60 * 60 * 1000;
14
17
  const THREADS_READ = 30;
@@ -37,8 +40,25 @@ async function assistantsSection(app, personalSpaceId, since) {
37
40
  const worked = await app.personal.recentWorkingAgents({ personalSpaceId, since });
38
41
  // At work now first; within each, the latest first as the Provider sent them.
39
42
  const ordered = [...worked.filter((agent) => agent.working), ...worked.filter((agent) => !agent.working)];
40
- const { rows, read } = await named(app, personalSpaceId, ordered);
41
- return section(rows, ordered.length - read, ALL_ASSISTANTS);
43
+ // One read names every row's project; without it the rows keep their names.
44
+ const [{ rows, read }, projectName] = await Promise.all([
45
+ named(app, personalSpaceId, ordered),
46
+ ordered.length ? projectNames(app, personalSpaceId) : () => null
47
+ ]);
48
+ return section(rows.map(({ projectId, ...row }) => ({ ...row, project: projectName(projectId) })),
49
+ ordered.length - read, ALL_ASSISTANTS);
50
+ }
51
+
52
+ // A project's shown name by its id; null for one that cannot be read.
53
+ async function projectNames(app, personalSpaceId) {
54
+ let projects = [];
55
+ try {
56
+ projects = await app.listPersonalProjects({ personalSpaceId });
57
+ } catch {
58
+ // The rows keep their names and tasks.
59
+ }
60
+ const names = new Map(projects.map((project) => [project.project_id, shownText(project.profile?.name, NAME_CHARS)]));
61
+ return (projectId) => names.get(projectId) || null;
42
62
  }
43
63
 
44
64
  async function roundtablesSection(app, since) {
@@ -58,6 +78,12 @@ const section = (rows, more, link) => ({ rows, more, link });
58
78
  // A menu label is one short line a person can read: names come from profiles an
59
79
  // Agent wrote and from paired computers, so line breaks, tabs (a shortcut column
60
80
  // on Windows), hidden or reordering characters and length are taken out here.
81
+ // A task the Stop hook closed has its English boilerplate as its summary: that
82
+ // says nothing of what the assistant did, so the row shows no task text. The
83
+ // Provider cuts a title to 60 characters, so a cut copy is caught too.
84
+ const BOILERPLATE = [AUTO_CLOSE_SUMMARY, AUTO_KEEP_REASON];
85
+ const taskTitle = (title) => (typeof title === 'string' && BOILERPLATE.some((text) => text.startsWith(title.trim())) ? null : title);
86
+
61
87
  const shownText = (value, limit) => singleLineExcerpt(withoutControls(value), limit);
62
88
 
63
89
  // Who a thread waits for: the first names and how many more.
@@ -82,7 +108,8 @@ async function named(app, personalSpaceId, agents) {
82
108
  batch.forEach((agent, index) => {
83
109
  const profile = records[index].status === 'fulfilled' ? records[index].value.profile : null;
84
110
  const name = shownText(profile?.displayName || profile?.name, NAME_CHARS);
85
- if (name) rows.push({ name, working: agent.working, at: agent.last_active,
111
+ if (name) rows.push({ name, projectId: agent.personal_project_id ?? null, task: shownText(taskTitle(agent.title), SUBJECT_CHARS) || null,
112
+ working: agent.working, at: agent.last_active,
86
113
  link: `fuli://agents/${encodeURIComponent(personalSpaceId)}/${encodeURIComponent(agent.agent_id)}` });
87
114
  });
88
115
  }
@@ -46,7 +46,7 @@ async function collaborationPreferences(application, {
46
46
  }
47
47
  projectResolution = await resolveTaskEntryProject(application, projectResolution, {
48
48
  sessionId, sourceSessionId, sourceApplication, agentInvocation, agentToolName, projectAgentId, taskPrompt, sessionTask,
49
- clientModel
49
+ clientModel, turnId
50
50
  });
51
51
  const preferences = await taskEntryPreferences(application, projectResolution, {
52
52
  personalProjectId, projectAgentId, projectPath, taskPrompt, sourceApplication,
@@ -22,6 +22,8 @@ import {
22
22
  import { createStandingAssignments } from '../standing-assignments/port.js';
23
23
  import { createAgentWorkflows } from '../agent-workflows/port.js';
24
24
  import { RecallImpressionsStore } from '../knowledge-impressions/store.js';
25
+ import { AGENT_INTRODUCTIONS_FILE, AgentIntroductionStore } from '../agent-introductions/store.js';
26
+ import { keptDataBefore } from '../data-format/local-stores.js';
25
27
  import { DELEGATION_LOG_FILE, DelegatedOperationLog } from '../agent-delegation/operation-log.js';
26
28
  import { createAgentAvatars } from '../agent-avatars/port.js';
27
29
  import { createProjectChangeLog } from '../project-change-log/port.js';
@@ -102,6 +104,16 @@ export function openLocalRuntimes(app, { runtimeConfigPath, paths, env, fetchImp
102
104
  app.agentWorkflows = createAgentWorkflows({ path: join(dataDir, 'agent-workflows.sqlite') });
103
105
  // Which knowledge the automatic recall showed and which the Agent reported using (rec#63); recall reads it as a ranking prior.
104
106
  app.recallImpressions = new RecallImpressionsStore(join(dataDir, 'recall-impressions.sqlite'));
107
+ // Which FLAs the person knows and who last owned each project's tasks. Created
108
+ // when FULI first opens this data directory with it. After an upgrade (FULI
109
+ // already kept data here) the FLAs that exist then are not introduced as new;
110
+ // on a new installation every FLA is new to the person, so introductions
111
+ // count from the epoch.
112
+ app.agentIntroductions = new AgentIntroductionStore(join(dataDir, AGENT_INTRODUCTIONS_FILE));
113
+ try {
114
+ app.agentIntroductions.begin(() => keptDataBefore(dataDir, [AGENT_INTRODUCTIONS_FILE])
115
+ ? new Date().toISOString() : new Date(0).toISOString());
116
+ } catch { /* no introductions; entries go on */ }
105
117
  // Read here only for the compounding statement's count of changes made for the person;
106
118
  // the console's delegation port alone records them. A missing file reads as none.
107
119
  app.delegatedOperations = new DelegatedOperationLog(join(dataDir, DELEGATION_LOG_FILE));
@@ -164,6 +176,7 @@ export function closeLocalRuntimes(app) {
164
176
  app.standingAssignments?.close();
165
177
  app.agentWorkflows?.close();
166
178
  app.recallImpressions?.close();
179
+ app.agentIntroductions?.close();
167
180
  app.delegatedOperations?.close();
168
181
  app.agentAvatars?.close();
169
182
  app.visitorAccess?.close();
@@ -4,6 +4,7 @@ import { taskAgentIdentity } from './agent-conversations.js';
4
4
  import { captureDecision, captureSettingsVersion, taskCaptureScope } from './capture-decision.js';
5
5
  import { receiptNotices } from './capture-notice.js';
6
6
  import { storedHabitsLine } from './turn-receipt-delivery.js';
7
+ import { introductionReceiptLine } from './task-entry-introduction.js';
7
8
 
8
9
  // "这次别记" / "继续记" (rec#5 C3, C4-3): an Agent pauses or resumes automatic
9
10
  // recording of the session it works in, on the person's word and without a
@@ -35,7 +36,8 @@ export async function setSessionCapturePause(application, { taskContextToken, se
35
36
  // It replaces the entry receipt, so the first task of a new conversation keeps its habits line.
36
37
  agent_receipt: withReceiptLines(taskAgentReceipt(application, { projectId: task.personalProjectId,
37
38
  agentId: task.projectAgentId ?? null, ...await taskAgentIdentity(application, task),
38
- sourceApplication: task.sourceApplication, notices: receiptNotices(decision, [], { settingsUrl: captureSettingsUrl(application) }) }),
39
+ sourceApplication: task.sourceApplication, notices: receiptNotices(decision, [], { settingsUrl: captureSettingsUrl(application) }),
40
+ introduction: introductionReceiptLine(task) }),
39
41
  [storedHabitsLine(application, task)].filter(Boolean)),
40
42
  guidance: !state ? UNSAVED_GUIDANCE : sessionPaused ? PAUSED_GUIDANCE : RESUMED_GUIDANCE };
41
43
  }
@@ -0,0 +1,135 @@
1
+ import { receiptSummary, receiptText } from '../agents/identity-receipt.js';
2
+ import { sha256Bytes } from '../security/digest.js';
3
+ import { hostInternalActivity } from './task-entry-activity-origin.js';
4
+ import { TASK_ENTRY_TOOLS } from './repository-project-registration.js';
5
+
6
+ // A new FLA introduces itself once, in the receipt line under its name
7
+ // (11-17): the first time it owns one of the person's tasks, when it was
8
+ // created after introductions began (FLAs the person already had are known).
9
+ // A project whose tasks pass from one FLA to another says so once too (a
10
+ // hand-off, naming both). Only the owner of a person's own task entry does;
11
+ // a worker run, a roundtable wake and a tool that only reads preferences do
12
+ // not. What was said is kept locally (agent-introductions store); the line
13
+ // rides on the task as a route marker, so a receipt that replaces the
14
+ // entry's (checkpoint, roundtable, pause, recovery) carries it the same turn,
15
+ // and so does a second entry of the same turn.
16
+
17
+ // "fla_introduction <prompt hash or -> <line>"
18
+ const MARKER = /^fla_introduction (\S+) (.+)$/su;
19
+ const NO_PROMPT = '-';
20
+ // Code points each value may take in the line; with the longest template the
21
+ // line stays within 100 characters (test/fla-introduction.test.js measures it).
22
+ const LIMITS = Object.freeze({ name: 14, project: 14, previous: 14, duty: 16 });
23
+ // The first clause of a profile's responsibility is what the line calls its duty.
24
+ const CLAUSE_END = /[,,。;;::\n]|\.\s/u;
25
+ // A project changes owner only when its own routing chose the project's lead;
26
+ // a member picked for the work kind works there without taking it over.
27
+ const LEAD_REASONS = new Set(['project_team_lead']);
28
+
29
+ const duty = value => value ? `(${value})` : '';
30
+ // Projectless tasks (an unclaimed conversation's Astro) are "things not in a project yet".
31
+ const area = project => project ? ` ${project} 的事` : '还没归项目的事';
32
+
33
+ // Same FLA, same wording: the variant is chosen by its agent ID. A hand-off
34
+ // promises only the project's work: the earlier FLA's own memory stays its own.
35
+ const FIRST_MEETING = [
36
+ v => `👋 初次见面,我是 ${v.name}${duty(v.duty)}。以后${area(v.project)}找我,消息开头写 ${v.address}。`,
37
+ v => `🌱 新助手 ${v.name} 报到${duty(v.duty)}!以后${area(v.project)}归我照看,有事消息开头写 ${v.address}。`,
38
+ v => `🎒 ${v.name} 到岗${duty(v.duty)},以后${area(v.project)}交给我。找我的暗号:消息开头写 ${v.address}。`,
39
+ v => `☕ 你好,我是 ${v.name}${duty(v.duty)},以后${area(v.project)}归我管。想找我,消息开头写 ${v.address}。`
40
+ ];
41
+ const HANDOFF = [
42
+ v => `🤝 ${v.project} 从 ${v.previous} 手里交到我 ${v.name} 这儿了:项目里的事我接着办,找我消息开头写 ${v.address}。`,
43
+ v => `🏃 接力棒到手!${v.project} 由 ${v.previous} 交给我 ${v.name},项目里的事我接着办,找我消息开头写 ${v.address}。`,
44
+ v => `🔑 ${v.previous} 把 ${v.project} 的钥匙交给了我 ${v.name},项目里的事我接着办;找我消息开头写 ${v.address}。`,
45
+ v => `📦 ${v.name} 从 ${v.previous} 那儿接过 ${v.project} 啦,项目里的事我接着办;找我消息开头写 ${v.address}。`
46
+ ];
47
+
48
+ // The entry's introduction ({ line, marker }), or null. A second entry of the
49
+ // same turn for the same owner repeats the first one's (resolution.turnIntroduction)
50
+ // without asking the store, which already counts it as said. A project's owner
51
+ // is tracked only when routing chose the project's lead: an FLA the person or
52
+ // host named (#FLA, #FLG, an explicit Agent) or a member picked for the work
53
+ // works there without taking it over. sessionOwnerFrom is the FLA a session
54
+ // owner-change notice already names as the earlier one: a hand-off from it
55
+ // would say the same twice, so it is left out.
56
+ export function introductionEntry(application, { resolution, selection, context, input, sessionOwnerFrom = null,
57
+ now = new Date() }) {
58
+ const agentId = selection?.agent?.agentId;
59
+ if (!agentId || !context?.role || !application.agentIntroductions || !input.agentInvocation
60
+ || !TASK_ENTRY_TOOLS.has(input.agentToolName)
61
+ || hostInternalActivity(application, { sessionId: input.sessionId ?? input.sourceSessionId ?? null })) return null;
62
+ const carried = resolution.turnIntroduction;
63
+ if (carried?.agentId === agentId) return entryOf(carried.line, input.taskPrompt);
64
+ const projectId = resolution.personalProjectId ?? null;
65
+ const led = LEAD_REASONS.has(selection.reason) || context.team?.lead_agent_id === agentId;
66
+ const routed = projectId && led && !resolution.fla && !resolution.group && !input.projectAgentId;
67
+ let met;
68
+ try {
69
+ met = application.agentIntroductions.meet({ personalSpaceId: application.config.personal.spaceId, agentId,
70
+ agentCreatedAt: selection.agent.createdAt ?? null, agentName: context.role.name ?? null,
71
+ projectId: routed ? projectId : null, at: now.toISOString() });
72
+ } catch {
73
+ // A store this FULI cannot use introduces nobody; the entry goes on.
74
+ return null;
75
+ }
76
+ const previous = met.previousOwner?.agentId === sessionOwnerFrom ? null : met.previousOwner;
77
+ const line = introductionLine({ agentId, name: context.role.name ?? agentId,
78
+ responsibility: context.role.responsibility, project: projectId ? context.project_brief?.name || '这个项目' : null,
79
+ previous: previous ? previous.name ?? previous.agentId : null, firstMeeting: met.firstMeeting });
80
+ return line ? entryOf(line, input.taskPrompt) : null;
81
+ }
82
+
83
+ // The introduction the session's current task gave, when this entry is a
84
+ // second one of the same turn and that task has no completed checkpoint: the
85
+ // client's prompt hook run again with the same turn ID (Codex, for input
86
+ // arriving mid-turn), or, without a turn ID, the Agent's own
87
+ // get_collaboration_preferences for the same task prompt. A different prompt
88
+ // is a new turn, so a client whose turns are never checkpointed does not carry
89
+ // the line on.
90
+ export function sameTurnIntroduction(sessionTask, { turnId = null, agentToolName = null, taskPrompt = null } = {}) {
91
+ if (!sessionTask?.projectAgentId || sessionTask.checkpoint?.phase === 'complete') return null;
92
+ const stored = storedIntroduction(sessionTask);
93
+ if (!stored) return null;
94
+ const sameTurn = turnId ? sessionTask.turnId === turnId
95
+ : agentToolName === 'get_collaboration_preferences' && stored.prompt !== NO_PROMPT && stored.prompt === promptKey(taskPrompt);
96
+ return sameTurn ? { agentId: sessionTask.projectAgentId, line: stored.line } : null;
97
+ }
98
+
99
+ // The receipt line a task's entry introduced its owner with, or null.
100
+ export function introductionReceiptLine(task) {
101
+ return storedIntroduction(task)?.line ?? null;
102
+ }
103
+
104
+ function storedIntroduction(task) {
105
+ const match = (task?.agentAssignment?.match_basis ?? []).map(item => MARKER.exec(item)).find(Boolean);
106
+ return match ? { prompt: match[1], line: match[2] } : null;
107
+ }
108
+
109
+ // The marker keeps a short hash of the entry's task prompt, never its text.
110
+ function entryOf(line, taskPrompt) {
111
+ return { line, marker: `fla_introduction ${promptKey(taskPrompt)} ${line}` };
112
+ }
113
+
114
+ function promptKey(taskPrompt) {
115
+ const text = typeof taskPrompt === 'string' ? taskPrompt.replace(/\s+/g, ' ').trim() : '';
116
+ return text ? sha256Bytes(text).slice(0, 16) : NO_PROMPT;
117
+ }
118
+
119
+ // One Markdown line of receipt text, every value escaped. A name too long to
120
+ // show whole is addressed by a bare #FLA, which lists the person's FLAs.
121
+ function introductionLine({ agentId, name, responsibility, project, previous, firstMeeting }) {
122
+ const templates = previous ? HANDOFF : firstMeeting ? FIRST_MEETING : null;
123
+ if (!templates) return null;
124
+ const shown = name.replace(/\s+/g, ' ').trim();
125
+ return templates[parseInt(sha256Bytes(agentId).slice(0, 8), 16) % templates.length]({
126
+ name: receiptSummary(shown, LIMITS.name),
127
+ address: [...shown].length <= LIMITS.name ? `#FLA ${receiptText(shown)}` : '#FLA',
128
+ duty: firstClause(responsibility), project: project && receiptSummary(project, LIMITS.project),
129
+ previous: previous && receiptSummary(previous, LIMITS.previous) });
130
+ }
131
+
132
+ function firstClause(responsibility) {
133
+ const clause = String(responsibility ?? '').trim().split(CLAUSE_END)[0].trim();
134
+ return clause ? receiptSummary(clause, LIMITS.duty) : null;
135
+ }