forge-openclaw-plugin 0.2.26 → 0.2.27
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/README.md +59 -3
- package/dist/assets/{board-ta0rUHOf.js → board-C6jCchjI.js} +2 -2
- package/dist/assets/{board-ta0rUHOf.js.map → board-C6jCchjI.js.map} +1 -1
- package/dist/assets/index-DVvS8iiU.css +1 -0
- package/dist/assets/index-zYB-9Dfo.js +85 -0
- package/dist/assets/index-zYB-9Dfo.js.map +1 -0
- package/dist/assets/knowledge-graph-layout.worker-DRvzPxhP.js +2 -0
- package/dist/assets/knowledge-graph-layout.worker-DRvzPxhP.js.map +1 -0
- package/dist/assets/{motion-fBKPB6yw.js → motion-DFHrH2rd.js} +2 -2
- package/dist/assets/{motion-fBKPB6yw.js.map → motion-DFHrH2rd.js.map} +1 -1
- package/dist/assets/{table-C-IGTQni.js → table-ZL7Di_u3.js} +2 -2
- package/dist/assets/{table-C-IGTQni.js.map → table-ZL7Di_u3.js.map} +1 -1
- package/dist/assets/{ui-DInOpaYF.js → ui-CKNPpz7q.js} +2 -2
- package/dist/assets/{ui-DInOpaYF.js.map → ui-CKNPpz7q.js.map} +1 -1
- package/dist/assets/vendor-DoNZuFhn.js +1247 -0
- package/dist/assets/vendor-DoNZuFhn.js.map +1 -0
- package/dist/index.html +7 -7
- package/dist/openclaw/local-runtime.js +16 -0
- package/dist/openclaw/routes.d.ts +27 -0
- package/dist/openclaw/routes.js +16 -12
- package/dist/server/server/migrations/037_workbench_public_inputs_and_run_inputs.sql +5 -0
- package/dist/server/server/migrations/038_data_management_settings.sql +11 -0
- package/dist/server/server/migrations/039_life_force_and_action_points.sql +114 -0
- package/dist/server/server/migrations/040_screen_time_domain.sql +89 -0
- package/dist/server/server/migrations/041_companion_source_states.sql +21 -0
- package/dist/server/server/migrations/042_movement_boxes.sql +47 -0
- package/dist/server/server/migrations/043_movement_box_overlap_overrides.sql +26 -0
- package/dist/server/server/src/app.js +1684 -117
- package/dist/server/server/src/connectors/box-registry.js +44 -9
- package/dist/server/server/src/data-management-types.js +107 -0
- package/dist/server/server/src/db.js +68 -4
- package/dist/server/server/src/demo-data.js +2 -2
- package/dist/server/server/src/health.js +702 -18
- package/dist/server/server/src/managers/platform/llm-manager.js +7 -4
- package/dist/server/server/src/managers/platform/mock-workbench-provider.js +149 -0
- package/dist/server/server/src/managers/platform/secrets-manager.js +18 -1
- package/dist/server/server/src/managers/runtime.js +9 -0
- package/dist/server/server/src/movement.js +1971 -112
- package/dist/server/server/src/openapi.js +489 -1
- package/dist/server/server/src/psyche-types.js +9 -1
- package/dist/server/server/src/repositories/activity-events.js +8 -0
- package/dist/server/server/src/repositories/ai-connectors.js +522 -74
- package/dist/server/server/src/repositories/habits.js +37 -1
- package/dist/server/server/src/repositories/model-settings.js +13 -3
- package/dist/server/server/src/repositories/notes.js +3 -0
- package/dist/server/server/src/repositories/settings.js +380 -18
- package/dist/server/server/src/repositories/tasks.js +170 -10
- package/dist/server/server/src/runtime-data-root.js +82 -0
- package/dist/server/server/src/screen-time.js +802 -0
- package/dist/server/server/src/services/data-management.js +788 -0
- package/dist/server/server/src/services/entity-crud.js +205 -2
- package/dist/server/server/src/services/knowledge-graph.js +1455 -0
- package/dist/server/server/src/services/life-force-model.js +197 -0
- package/dist/server/server/src/services/life-force.js +1270 -0
- package/dist/server/server/src/services/psyche-observation-calendar.js +383 -16
- package/dist/server/server/src/types.js +286 -13
- package/dist/server/server/src/web.js +228 -13
- package/dist/server/src/components/customization/utility-widgets.js +136 -27
- package/dist/server/src/components/ui/info-tooltip.js +25 -0
- package/dist/server/src/components/workbench-boxes/calendar/calendar-boxes.js +78 -0
- package/dist/server/src/components/workbench-boxes/goals/goals-boxes.js +62 -0
- package/dist/server/src/components/workbench-boxes/habits/habits-boxes.js +62 -0
- package/dist/server/src/components/workbench-boxes/health/health-boxes.js +63 -8
- package/dist/server/src/components/workbench-boxes/insights/insights-boxes.js +50 -0
- package/dist/server/src/components/workbench-boxes/kanban/kanban-boxes.js +62 -54
- package/dist/server/src/components/workbench-boxes/movement/movement-boxes.js +18 -8
- package/dist/server/src/components/workbench-boxes/notes/notes-boxes.js +56 -38
- package/dist/server/src/components/workbench-boxes/overview/overview-boxes.js +65 -0
- package/dist/server/src/components/workbench-boxes/preferences/preferences-boxes.js +78 -0
- package/dist/server/src/components/workbench-boxes/projects/projects-boxes.js +35 -30
- package/dist/server/src/components/workbench-boxes/psyche/psyche-boxes.js +88 -0
- package/dist/server/src/components/workbench-boxes/questionnaires/questionnaires-boxes.js +61 -0
- package/dist/server/src/components/workbench-boxes/review/review-boxes.js +53 -0
- package/dist/server/src/components/workbench-boxes/shared/define-workbench-box.js +3 -1
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +39 -3
- package/dist/server/src/components/workbench-boxes/strategies/strategies-boxes.js +62 -0
- package/dist/server/src/components/workbench-boxes/tasks/tasks-boxes.js +76 -0
- package/dist/server/src/components/workbench-boxes/today/today-boxes.js +47 -32
- package/dist/server/src/components/workbench-boxes/wiki/wiki-boxes.js +60 -0
- package/dist/server/src/lib/api.js +280 -21
- package/dist/server/src/lib/data-management-types.js +1 -0
- package/dist/server/src/lib/entity-visuals.js +279 -0
- package/dist/server/src/lib/knowledge-graph-types.js +276 -0
- package/dist/server/src/lib/knowledge-graph.js +470 -0
- package/dist/server/src/lib/schemas.js +4 -0
- package/dist/server/src/lib/snapshot-normalizer.js +43 -1
- package/dist/server/src/lib/workbench/contracts.js +229 -0
- package/dist/server/src/lib/workbench/nodes.js +200 -0
- package/dist/server/src/lib/workbench/registry.js +52 -5
- package/dist/server/src/lib/workbench/runtime.js +254 -38
- package/dist/server/src/lib/workbench/tool-catalog.js +68 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server/migrations/037_workbench_public_inputs_and_run_inputs.sql +5 -0
- package/server/migrations/038_data_management_settings.sql +11 -0
- package/server/migrations/039_life_force_and_action_points.sql +114 -0
- package/server/migrations/040_screen_time_domain.sql +89 -0
- package/server/migrations/041_companion_source_states.sql +21 -0
- package/server/migrations/042_movement_boxes.sql +47 -0
- package/server/migrations/043_movement_box_overlap_overrides.sql +26 -0
- package/skills/forge-openclaw/SKILL.md +24 -11
- package/skills/forge-openclaw/entity_conversation_playbooks.md +210 -34
- package/skills/forge-openclaw/psyche_entity_playbooks.md +113 -17
- package/dist/assets/index-Ro0ZF_az.css +0 -1
- package/dist/assets/index-ytlpSj23.js +0 -79
- package/dist/assets/index-ytlpSj23.js.map +0 -1
- package/dist/assets/vendor-lE3tZJcC.js +0 -876
- package/dist/assets/vendor-lE3tZJcC.js.map +0 -1
|
@@ -3,11 +3,11 @@ import cors from "@fastify/cors";
|
|
|
3
3
|
import multipart from "@fastify/multipart";
|
|
4
4
|
import { CronExpressionParser } from "cron-parser";
|
|
5
5
|
import { z, ZodError } from "zod";
|
|
6
|
-
import { configureDatabase, configureDatabaseSeeding, runInTransaction } from "./db.js";
|
|
6
|
+
import { configureDatabase, configureDatabaseSeeding, getEffectiveDataRoot, resolveDataDir, resolveDatabasePathForDataRoot, runInTransaction } from "./db.js";
|
|
7
7
|
import { HttpError, isHttpError } from "./errors.js";
|
|
8
8
|
import { listActivityEvents, listActivityEventsForTask, recordActivityEvent, removeActivityEvent } from "./repositories/activity-events.js";
|
|
9
9
|
import { approveApprovalRequest, createAgentAction, createInsight, createInsightFeedback, deleteInsight, getInsightById, listAgentActions, listApprovalRequests, listInsights, rejectApprovalRequest, updateInsight } from "./repositories/collaboration.js";
|
|
10
|
-
import { createAiConnector, deleteAiConnector, getAiConnectorById, getAiConnectorBySlug, getAiConnectorConversationForConnector, listAiConnectorRuns, listAiConnectors, runAiConnector, updateAiConnector } from "./repositories/ai-connectors.js";
|
|
10
|
+
import { createAiConnector, deleteAiConnector, getAiConnectorById, getAiConnectorRunById, getAiConnectorRunNodeResult, getAiConnectorRunNodeResults, getLatestAiConnectorNodeOutput, getAiConnectorBySlug, getAiConnectorConversationForConnector, listAiConnectorRuns, listAiConnectors, runAiConnector, updateAiConnector } from "./repositories/ai-connectors.js";
|
|
11
11
|
import { createAiProcessor, createAiProcessorLink, deleteAiProcessor, deleteAiProcessorLink, getAiProcessorById, getAiProcessorBySlug, listAiProcessors, getSurfaceProcessorGraph, runAiProcessor, updateAiProcessor } from "./repositories/ai-processors.js";
|
|
12
12
|
import { listEventLog } from "./repositories/event-log.js";
|
|
13
13
|
import { createDiagnosticMessage, DIAGNOSTIC_LOG_RETENTION_SWEEP_INTERVAL_MS, enforceDiagnosticLogRetention, listDiagnosticLogs, normalizeDiagnosticSource, recordDiagnosticLog, serializeDiagnosticError } from "./repositories/diagnostic-logs.js";
|
|
@@ -20,27 +20,30 @@ import { buildNotesSummaryByEntity, createNote, getNoteById, listNotes, updateNo
|
|
|
20
20
|
import { createWikiIngestJobSchema, createUploadedWikiIngestJob, createWikiSpace, createWikiSpaceSchema, deleteWikiIngestJob, deleteWikiProfile, getWikiHealth, getWikiIngestJob, getWikiHomePageDetail, getWikiPageDetail, getWikiPageDetailBySlug, getWikiSettingsPayload, ingestWikiSource, listWikiIngestJobs, listWikiLlmProfiles, listWikiPageTree, listWikiPages, listWikiSpaces, processWikiIngestJob, reindexWikiEmbeddings, reindexWikiEmbeddingsSchema, rerunWikiIngestJob, reviewWikiIngestJob, reviewWikiIngestJobSchema, searchWikiPages, syncWikiVaultFromDisk, syncWikiVaultSchema, testWikiLlmProfileSchema, upsertWikiEmbeddingProfile, upsertWikiEmbeddingProfileSchema, upsertWikiLlmProfile, upsertWikiLlmProfileSchema, wikiSearchQuerySchema } from "./repositories/wiki-memory.js";
|
|
21
21
|
import { filterOwnedEntities, setEntityOwner } from "./repositories/entity-ownership.js";
|
|
22
22
|
import { createBehavior, createBehaviorPattern, createBeliefEntry, createEmotionDefinition, createEventType, createModeGuideSession, createModeProfile, createPsycheValue, createTriggerReport, getBehaviorById, getBehaviorPatternById, getBeliefEntryById, getEmotionDefinitionById, getEventTypeById, getModeGuideSessionById, getModeProfileById, getPsycheValueById, getTriggerReportById, listBehaviors, listBehaviorPatterns, listBeliefEntries, listEmotionDefinitions, listEventTypes, listModeGuideSessions, listModeProfiles, listPsycheValues, listSchemaCatalog, listTriggerReports, updateBehavior, updateBehaviorPattern, updateBeliefEntry, updateEmotionDefinition, updateEventType, updateModeGuideSession, updateModeProfile, updatePsycheValue, updateTriggerReport } from "./repositories/psyche.js";
|
|
23
|
-
import { cloneQuestionnaireInstrument, completeQuestionnaireRun, createQuestionnaireInstrument, ensureQuestionnaireDraftVersion, getQuestionnaireInstrumentDetail, getQuestionnaireRunDetail, listQuestionnaireInstruments, publishQuestionnaireDraftVersion, startQuestionnaireRun, updateQuestionnaireDraftVersion, updateQuestionnaireRun } from "./repositories/questionnaires.js";
|
|
23
|
+
import { cloneQuestionnaireInstrument, completeQuestionnaireRun, createQuestionnaireInstrument, deleteQuestionnaireInstrument, ensureQuestionnaireDraftVersion, getQuestionnaireInstrumentDetail, getQuestionnaireRunDetail, listQuestionnaireInstruments, publishQuestionnaireDraftVersion, startQuestionnaireRun, updateQuestionnaireInstrument, updateQuestionnaireInstrumentSchema, updateQuestionnaireDraftVersion, updateQuestionnaireRun } from "./repositories/questionnaires.js";
|
|
24
24
|
import { createProject, updateProject } from "./repositories/projects.js";
|
|
25
|
-
import { createPreferenceCatalog, createPreferenceCatalogItem, createPreferenceContext, createPreferenceItem, createPreferenceItemFromEntity, deletePreferenceCatalog, deletePreferenceCatalogItem, getPreferenceWorkspace, mergePreferenceContexts, startPreferenceGame, submitAbsoluteSignal, submitPairwiseJudgment, updatePreferenceCatalog, updatePreferenceCatalogItem, updatePreferenceContext, updatePreferenceItem, updatePreferenceScore } from "./repositories/preferences.js";
|
|
25
|
+
import { createPreferenceCatalog, createPreferenceCatalogItem, createPreferenceContext, createPreferenceItem, createPreferenceItemFromEntity, deletePreferenceCatalog, deletePreferenceCatalogItem, deletePreferenceContext, deletePreferenceItem, getPreferenceCatalogById, getPreferenceCatalogItemById, getPreferenceContextById, getPreferenceItemById, getPreferenceWorkspace, listPreferenceCatalogItems, listPreferenceCatalogs, listPreferenceContexts, listPreferenceItems, mergePreferenceContexts, startPreferenceGame, submitAbsoluteSignal, submitPairwiseJudgment, updatePreferenceCatalog, updatePreferenceCatalogItem, updatePreferenceContext, updatePreferenceItem, updatePreferenceScore } from "./repositories/preferences.js";
|
|
26
26
|
import { createStrategy, getStrategyById, listStrategies, updateStrategy } from "./repositories/strategies.js";
|
|
27
|
+
import { buildKnowledgeGraph, buildKnowledgeGraphFocus } from "./services/knowledge-graph.js";
|
|
27
28
|
import { createManualRewardGrant, getDailyAmbientXp, getRewardRuleById, listRewardLedger, listRewardRules, recordWorkAdjustmentReward, recordSessionEvent, updateRewardRule } from "./repositories/rewards.js";
|
|
28
|
-
import { listAgentIdentities, getSettings, isPsycheAuthRequired, updateSettings, verifyAgentToken } from "./repositories/settings.js";
|
|
29
|
+
import { getSettingsFileStatus, listAgentIdentities, getSettings, isPsycheAuthRequired, mirrorSettingsFileFromCurrentState, updateSettings, verifyAgentToken } from "./repositories/settings.js";
|
|
29
30
|
import { deleteAiModelConnection, getAiModelConnectionById, readModelConnectionCredential, upsertAiModelConnection } from "./repositories/model-settings.js";
|
|
30
31
|
import { createTag, getTagById, listTags, updateTag } from "./repositories/tags.js";
|
|
31
32
|
import { createUser, ensureSystemUsers, getDefaultUser, getUserById, listUserAccessGrants, listUserOwnershipSummaries, listUserXpSummaries, listUsers, resolveUserForMutation, updateUserAccessGrant, updateUser } from "./repositories/users.js";
|
|
32
33
|
import { claimTaskRun, completeTaskRun, focusTaskRun, heartbeatTaskRun, listTaskRuns, recoverTimedOutTaskRuns, releaseTaskRun } from "./repositories/task-runs.js";
|
|
33
|
-
import { createTask, createTaskWithIdempotency, getTaskById, listTasks, uncompleteTask, updateTask } from "./repositories/tasks.js";
|
|
34
|
+
import { createTask, createTaskWithIdempotency, getTaskById, listTasks, splitTask, uncompleteTask, updateTask } from "./repositories/tasks.js";
|
|
34
35
|
import { createWorkAdjustment } from "./repositories/work-adjustments.js";
|
|
35
|
-
import { createCalendarEvent, createTaskTimebox, createWorkBlockTemplate, deleteCalendarEvent, deleteTaskTimebox, deleteWorkBlockTemplate, getCalendarConnectionById, getCalendarEventById, listCalendars, listCalendarEvents, listTaskTimeboxes, suggestTaskTimeboxes, listWorkBlockInstances, listWorkBlockTemplates, updateCalendarEvent, updateTaskTimebox, updateWorkBlockTemplate } from "./repositories/calendar.js";
|
|
36
|
+
import { createCalendarEvent, createTaskTimebox, createWorkBlockTemplate, deleteCalendarEvent, deleteTaskTimebox, deleteWorkBlockTemplate, getCalendarConnectionById, getCalendarEventById, getTaskTimeboxById, getWorkBlockTemplateById, listCalendars, listCalendarEvents, listTaskTimeboxes, suggestTaskTimeboxes, listWorkBlockInstances, listWorkBlockTemplates, updateCalendarEvent, updateTaskTimebox, updateWorkBlockTemplate } from "./repositories/calendar.js";
|
|
36
37
|
import { getDashboard } from "./services/dashboard.js";
|
|
37
38
|
import { getOverviewContext, getRiskContext, getTodayContext } from "./services/context.js";
|
|
38
39
|
import { buildGamificationOverview, buildGamificationProfile, buildXpMomentumPulse } from "./services/gamification.js";
|
|
39
40
|
import { getInsightsPayload } from "./services/insights.js";
|
|
41
|
+
import { buildLifeForcePayload, createFatigueSignal, listLifeForceTemplates, resolveLifeForceUser, updateLifeForceProfile, updateLifeForceTemplate } from "./services/life-force.js";
|
|
40
42
|
import { createEntities, deleteEntities, deleteEntity, getSettingsBinPayload, restoreEntities, searchEntities, updateEntities } from "./services/entity-crud.js";
|
|
41
43
|
import { getPsycheOverview } from "./services/psyche.js";
|
|
42
|
-
import { getPsycheObservationCalendar } from "./services/psyche-observation-calendar.js";
|
|
44
|
+
import { exportPsycheObservationCalendar, getPsycheObservationCalendar } from "./services/psyche-observation-calendar.js";
|
|
43
45
|
import { getProjectBoard, getProjectSummary, listProjectSummaries } from "./services/projects.js";
|
|
46
|
+
import { createDataBackup, exportData, getDataManagementState, maybeRunAutomaticBackup, restoreDataBackup, scanForDataRecoveryCandidates, switchDataRoot, updateDataManagementSettings } from "./services/data-management.js";
|
|
44
47
|
import { getWeeklyReviewPayload } from "./services/reviews.js";
|
|
45
48
|
import { finalizeWeeklyReviewClosure } from "./repositories/weekly-reviews.js";
|
|
46
49
|
import { createTaskRunWatchdog } from "./services/task-run-watchdog.js";
|
|
@@ -50,13 +53,15 @@ import { consumeOpenAiCodexOauthCredentials, getOpenAiCodexOauthSession, startOp
|
|
|
50
53
|
import { PSYCHE_ENTITY_TYPES, createBehaviorSchema, createBeliefEntrySchema, createBehaviorPatternSchema, createEmotionDefinitionSchema, createEventTypeSchema, createModeGuideSessionSchema, createModeProfileSchema, createPsycheValueSchema, createTriggerReportSchema, updateBehaviorSchema, updateBeliefEntrySchema, updateBehaviorPatternSchema, updateEmotionDefinitionSchema, updateEventTypeSchema, updateModeGuideSessionSchema, updateModeProfileSchema, updatePsycheValueSchema, updateTriggerReportSchema } from "./psyche-types.js";
|
|
51
54
|
import { createQuestionnaireInstrumentSchema, publishQuestionnaireVersionSchema, startQuestionnaireRunSchema, updateQuestionnaireRunSchema, updateQuestionnaireVersionSchema } from "./questionnaire-types.js";
|
|
52
55
|
import { createPreferenceCatalogItemSchema, createPreferenceCatalogSchema, createPreferenceContextSchema, createPreferenceItemSchema, enqueueEntityPreferenceItemSchema, mergePreferenceContextsSchema, preferenceWorkspaceQuerySchema, startPreferenceGameSchema, submitAbsoluteSignalSchema, submitPairwiseJudgmentSchema, updatePreferenceCatalogItemSchema, updatePreferenceCatalogSchema, updatePreferenceContextSchema, updatePreferenceItemSchema, updatePreferenceScoreSchema } from "./preferences-types.js";
|
|
53
|
-
import {
|
|
56
|
+
import { createDataBackupSchema, dataExportQuerySchema, restoreDataBackupSchema, switchDataRootSchema, updateDataManagementSettingsSchema } from "./data-management-types.js";
|
|
57
|
+
import { activityListQuerySchema, activitySourceSchema, createAgentActionSchema, createAgentTokenSchema, createAiConnectorSchema, createAiProcessorLinkSchema, createAiProcessorSchema, runAiConnectorSchema, writeSurfaceLayoutSchema, upsertAiModelConnectionSchema, testAiModelConnectionSchema, submitOpenAiCodexOauthManualCodeSchema, batchCreateEntitiesSchema, batchDeleteEntitiesSchema, batchRestoreEntitiesSchema, batchSearchEntitiesSchema, batchUpdateEntitiesSchema, createGoalSchema, createInsightFeedbackSchema, createInsightSchema, createStrategySchema, createUserSchema, createNoteSchema, createProjectSchema, createManualRewardGrantSchema, createCalendarEventSchema, createHabitCheckInSchema, createCalendarConnectionSchema, createDiagnosticLogSchema, discoverCalendarConnectionSchema, startGoogleCalendarOauthSchema, startMicrosoftCalendarOauthSchema, testMicrosoftCalendarOauthConfigurationSchema, createHabitSchema, createTaskTimeboxSchema, createWorkBlockTemplateSchema, createSessionEventSchema, createWorkAdjustmentSchema, createTagSchema, calendarOverviewQuerySchema, psycheObservationCalendarExportQuerySchema, notesListQuerySchema, updateTagSchema, createTaskSchema, diagnosticLogListQuerySchema, eventsListQuerySchema, operatorLogWorkSchema, projectBoardPayloadSchema, projectListQuerySchema, entityDeleteQuerySchema, removeActivityEventSchema, resolveApprovalRequestSchema, rewardsLedgerQuerySchema, habitListQuerySchema, taskContextPayloadSchema, taskRunClaimSchema, taskRunFocusSchema, taskRunFinishSchema, taskRunHeartbeatSchema, taskRunListQuerySchema, taskSplitCreateSchema, taskListQuerySchema, tagSuggestionRequestSchema, uncompleteTaskSchema, updateSettingsSchema, updateGoalSchema, updateHabitSchema, updateInsightSchema, updateStrategySchema, updateUserSchema, updateCalendarConnectionSchema, updateCalendarEventSchema, updateNoteSchema, updateProjectSchema, updateRewardRuleSchema, updateTaskTimeboxSchema, updateTaskSchema, lifeForceProfilePatchSchema, lifeForceTemplateUpdateSchema, fatigueSignalCreateSchema, updateUserAccessGrantSchema, updateWorkBlockTemplateSchema, updateAiConnectorSchema, updateAiProcessorSchema, runAiProcessorSchema, workAdjustmentResultSchema, finalizeWeeklyReviewResultSchema, goalListQuerySchema, recommendTaskTimeboxesSchema, strategyListQuerySchema } from "./types.js";
|
|
54
58
|
import { buildOpenApiDocument } from "./openapi.js";
|
|
55
59
|
import { registerWebRoutes } from "./web.js";
|
|
56
60
|
import { createManagerRuntime } from "./managers/runtime.js";
|
|
57
61
|
import { isManagerError } from "./managers/type-guards.js";
|
|
58
|
-
import { createCompanionPairingSession, createCompanionPairingSessionSchema, getCompanionOverview, getFitnessViewData, getSleepViewData, ingestMobileHealthSync, mobileHealthSyncSchema, requireValidPairing, revokeAllCompanionPairingSessions, revokeAllCompanionPairingSessionsSchema, revokeCompanionPairingSession, verifyCompanionPairing, verifyCompanionPairingSchema, updateSleepMetadata, updateSleepMetadataSchema, updateWorkoutMetadata, updateWorkoutMetadataSchema } from "./health.js";
|
|
59
|
-
import { createMovementPlace, getMovementAllTimeSummary, getMovementDayDetail, getMovementMobileBootstrap, getMovementTimeline, getMovementSelectionAggregate, getMovementSettings, getMovementTripDetail, getMovementMonthSummary, listMovementPlaces, movementMobileBootstrapSchema, movementMobilePlaceMutationSchema,
|
|
62
|
+
import { createCompanionPairingSession, createCompanionPairingSessionSchema, createSleepSession, createSleepSessionSchema, createWorkoutSession, createWorkoutSessionSchema, deleteSleepSession, deleteWorkoutSession, getCompanionPairingSessionById, getCompanionOverview, getFitnessViewData, getSleepSessionById, getSleepViewData, getWorkoutSessionById, ingestMobileHealthSync, mobileHealthSyncSchema, patchCompanionPairingSourceState, patchCompanionPairingSourceStateSchema, companionSourceKeySchema, requireValidPairing, revokeAllCompanionPairingSessions, revokeAllCompanionPairingSessionsSchema, revokeCompanionPairingSession, updateMobileCompanionSourceState, updateMobileCompanionSourceStateSchema, verifyCompanionPairing, verifyCompanionPairingSchema, updateSleepMetadata, updateSleepMetadataSchema, updateWorkoutMetadata, updateWorkoutMetadataSchema } from "./health.js";
|
|
63
|
+
import { analyzeMovementUserBoxPreflight, createMovementUserBox, createMovementPlace, deleteMovementUserBox, getMovementAllTimeSummary, getMovementDayDetail, getMovementMobileBootstrap, getMovementTimeline, getMovementSelectionAggregate, getMovementSettings, getMovementTripDetail, getMovementMonthSummary, invalidateAutomaticMovementBox, listMovementPlaces, movementAutomaticBoxInvalidateSchema, movementMobileBootstrapSchema, movementMobilePlaceMutationSchema, movementMobileUserBoxCreateSchema, movementMobileUserBoxPreflightSchema, movementMobileUserBoxPatchSchema, movementMobileAutomaticBoxInvalidateSchema, movementMobileTimelineSchema, movementPlaceMutationSchema, movementPlacePatchSchema, movementSelectionAggregateSchema, movementStayPatchSchema, movementTripPatchSchema, movementUserBoxCreateSchema, movementUserBoxPreflightSchema, movementUserBoxPatchSchema, movementSettingsPatchSchema, movementTimelineQuerySchema, movementTripPointPatchSchema, deleteMovementStay, deleteMovementTrip, deleteMovementTripPoint, updateMovementPlace, updateMovementSettings, updateMovementStay, updateMovementTrip, updateMovementUserBox, updateMovementTripPoint, resolveMovementTimelineSegmentForBox } from "./movement.js";
|
|
64
|
+
import { getScreenTimeAllTimeSummary, getScreenTimeDayDetail, getScreenTimeMonthSummary, getScreenTimeSettings, screenTimeSettingsPatchSchema, updateScreenTimeSettings } from "./screen-time.js";
|
|
60
65
|
import { assertWatchReady, buildWatchBootstrap, ingestWatchCaptureBatch, mobileWatchBootstrapSchema, mobileWatchCaptureBatchSchema, mobileWatchHabitCheckInSchema } from "./watch-mobile.js";
|
|
61
66
|
const COMPATIBILITY_SUNSET = "transitional-node";
|
|
62
67
|
function markCompatibilityRoute(reply) {
|
|
@@ -162,7 +167,7 @@ function getRequestOrigin(request) {
|
|
|
162
167
|
request.hostname;
|
|
163
168
|
return `${protocol}://${host}`;
|
|
164
169
|
}
|
|
165
|
-
const
|
|
170
|
+
const AGENT_ONBOARDING_ENTITY_CATALOG_BASE = [
|
|
166
171
|
{
|
|
167
172
|
entityType: "goal",
|
|
168
173
|
purpose: "A long-horizon outcome or direction. Goals anchor projects and tasks.",
|
|
@@ -1837,73 +1842,813 @@ const AGENT_ONBOARDING_ENTITY_CATALOG = [
|
|
|
1837
1842
|
defaultValue: []
|
|
1838
1843
|
},
|
|
1839
1844
|
{
|
|
1840
|
-
name: "linkedBehaviorIds",
|
|
1841
|
-
type: "string[]",
|
|
1842
|
-
required: false,
|
|
1843
|
-
description: "Linked behavior ids.",
|
|
1844
|
-
defaultValue: []
|
|
1845
|
+
name: "linkedBehaviorIds",
|
|
1846
|
+
type: "string[]",
|
|
1847
|
+
required: false,
|
|
1848
|
+
description: "Linked behavior ids.",
|
|
1849
|
+
defaultValue: []
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
name: "linkedBeliefIds",
|
|
1853
|
+
type: "string[]",
|
|
1854
|
+
required: false,
|
|
1855
|
+
description: "Linked belief ids.",
|
|
1856
|
+
defaultValue: []
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
name: "linkedModeIds",
|
|
1860
|
+
type: "string[]",
|
|
1861
|
+
required: false,
|
|
1862
|
+
description: "Linked mode ids.",
|
|
1863
|
+
defaultValue: []
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
name: "modeOverlays",
|
|
1867
|
+
type: "string[]",
|
|
1868
|
+
required: false,
|
|
1869
|
+
description: "Extra mode labels noticed during the incident.",
|
|
1870
|
+
defaultValue: []
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
name: "schemaLinks",
|
|
1874
|
+
type: "string[]",
|
|
1875
|
+
required: false,
|
|
1876
|
+
description: "Schema names or themes that seem related to the incident.",
|
|
1877
|
+
defaultValue: []
|
|
1878
|
+
},
|
|
1879
|
+
{
|
|
1880
|
+
name: "modeTimeline",
|
|
1881
|
+
type: "array",
|
|
1882
|
+
required: false,
|
|
1883
|
+
description: "List of { stage, modeId|null, label, note } items describing the sequence of modes.",
|
|
1884
|
+
defaultValue: []
|
|
1885
|
+
},
|
|
1886
|
+
{
|
|
1887
|
+
name: "nextMoves",
|
|
1888
|
+
type: "string[]",
|
|
1889
|
+
required: false,
|
|
1890
|
+
description: "Concrete next steps or repair moves.",
|
|
1891
|
+
defaultValue: []
|
|
1892
|
+
}
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
];
|
|
1896
|
+
const AGENT_ONBOARDING_BATCH_ROUTE_BASES = {
|
|
1897
|
+
goal: "/api/v1/goals",
|
|
1898
|
+
project: "/api/v1/projects",
|
|
1899
|
+
task: "/api/v1/tasks",
|
|
1900
|
+
strategy: "/api/v1/strategies",
|
|
1901
|
+
habit: "/api/v1/habits",
|
|
1902
|
+
tag: "/api/v1/tags",
|
|
1903
|
+
note: "/api/v1/notes",
|
|
1904
|
+
insight: "/api/v1/insights",
|
|
1905
|
+
calendar_event: "/api/v1/calendar/events",
|
|
1906
|
+
work_block_template: "/api/v1/calendar/work-block-templates",
|
|
1907
|
+
task_timebox: "/api/v1/calendar/timeboxes",
|
|
1908
|
+
sleep_session: "/api/v1/health/sleep",
|
|
1909
|
+
workout_session: "/api/v1/health/workouts",
|
|
1910
|
+
psyche_value: "/api/v1/psyche/values",
|
|
1911
|
+
behavior_pattern: "/api/v1/psyche/patterns",
|
|
1912
|
+
behavior: "/api/v1/psyche/behaviors",
|
|
1913
|
+
belief_entry: "/api/v1/psyche/beliefs",
|
|
1914
|
+
mode_profile: "/api/v1/psyche/modes",
|
|
1915
|
+
mode_guide_session: "/api/v1/psyche/mode-guides",
|
|
1916
|
+
event_type: "/api/v1/psyche/event-types",
|
|
1917
|
+
emotion_definition: "/api/v1/psyche/emotions",
|
|
1918
|
+
trigger_report: "/api/v1/psyche/reports",
|
|
1919
|
+
preference_catalog: "/api/v1/preferences/catalogs",
|
|
1920
|
+
preference_catalog_item: "/api/v1/preferences/catalog-items",
|
|
1921
|
+
preference_context: "/api/v1/preferences/contexts",
|
|
1922
|
+
preference_item: "/api/v1/preferences/items",
|
|
1923
|
+
questionnaire_instrument: "/api/v1/psyche/questionnaires"
|
|
1924
|
+
};
|
|
1925
|
+
function classifyOnboardingEntity(entityType) {
|
|
1926
|
+
if (entityType in AGENT_ONBOARDING_BATCH_ROUTE_BASES) {
|
|
1927
|
+
return "batch_crud_entity";
|
|
1928
|
+
}
|
|
1929
|
+
if (entityType === "wiki_page" || entityType === "calendar_connection") {
|
|
1930
|
+
return "specialized_crud_entity";
|
|
1931
|
+
}
|
|
1932
|
+
if (entityType === "task_run" ||
|
|
1933
|
+
entityType === "questionnaire_run" ||
|
|
1934
|
+
entityType === "preference_judgment" ||
|
|
1935
|
+
entityType === "preference_signal" ||
|
|
1936
|
+
entityType === "work_adjustment") {
|
|
1937
|
+
return "action_workflow_entity";
|
|
1938
|
+
}
|
|
1939
|
+
return "read_model_only_surface";
|
|
1940
|
+
}
|
|
1941
|
+
function buildPreferredMutationPath(entityType) {
|
|
1942
|
+
if (entityType in AGENT_ONBOARDING_BATCH_ROUTE_BASES) {
|
|
1943
|
+
return "/api/v1/entities/create | /api/v1/entities/update | /api/v1/entities/delete | /api/v1/entities/search";
|
|
1944
|
+
}
|
|
1945
|
+
switch (entityType) {
|
|
1946
|
+
case "wiki_page":
|
|
1947
|
+
return "Use /api/v1/wiki/pages with POST or PATCH for page CRUD.";
|
|
1948
|
+
case "calendar_connection":
|
|
1949
|
+
return "Use /api/v1/calendar/connections plus provider-specific setup flows.";
|
|
1950
|
+
case "task_run":
|
|
1951
|
+
return "Use the task-run action routes to start, heartbeat, focus, complete, or release live work.";
|
|
1952
|
+
case "questionnaire_run":
|
|
1953
|
+
return "Use the questionnaire-run action routes to start, patch answers, and complete the run.";
|
|
1954
|
+
case "preference_judgment":
|
|
1955
|
+
return "Use /api/v1/preferences/judgments to record one pairwise comparison.";
|
|
1956
|
+
case "preference_signal":
|
|
1957
|
+
return "Use /api/v1/preferences/signals to record one direct signal such as favorite or veto.";
|
|
1958
|
+
case "work_adjustment":
|
|
1959
|
+
return "Use /api/v1/work-adjustments to apply an explicit operator adjustment.";
|
|
1960
|
+
case "self_observation":
|
|
1961
|
+
return "Read the calendar surface; mutate it by creating or updating note-backed observations with frontmatter.observedAt.";
|
|
1962
|
+
case "sleep_overview":
|
|
1963
|
+
return "Read-only surface. Use batch CRUD for sleep_session records or the review enrichment route for reflective notes.";
|
|
1964
|
+
case "sports_overview":
|
|
1965
|
+
return "Read-only surface. Use batch CRUD for workout_session records or the review enrichment route for reflective notes.";
|
|
1966
|
+
default:
|
|
1967
|
+
return "Read-only surface.";
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
function buildPreferredReadPath(entityType) {
|
|
1971
|
+
if (entityType in AGENT_ONBOARDING_BATCH_ROUTE_BASES) {
|
|
1972
|
+
return AGENT_ONBOARDING_BATCH_ROUTE_BASES[entityType];
|
|
1973
|
+
}
|
|
1974
|
+
switch (entityType) {
|
|
1975
|
+
case "wiki_page":
|
|
1976
|
+
return "/api/v1/wiki/pages/:id";
|
|
1977
|
+
case "calendar_connection":
|
|
1978
|
+
return "/api/v1/calendar/connections";
|
|
1979
|
+
case "task_run":
|
|
1980
|
+
return "/api/v1/operator/context";
|
|
1981
|
+
case "questionnaire_run":
|
|
1982
|
+
return "/api/v1/psyche/questionnaire-runs/:id";
|
|
1983
|
+
case "preference_judgment":
|
|
1984
|
+
case "preference_signal":
|
|
1985
|
+
return "/api/v1/preferences/workspace";
|
|
1986
|
+
case "work_adjustment":
|
|
1987
|
+
return "/api/v1/operator/context";
|
|
1988
|
+
case "self_observation":
|
|
1989
|
+
return "/api/v1/psyche/self-observation/calendar";
|
|
1990
|
+
case "sleep_overview":
|
|
1991
|
+
return "/api/v1/health/sleep";
|
|
1992
|
+
case "sports_overview":
|
|
1993
|
+
return "/api/v1/health/fitness";
|
|
1994
|
+
default:
|
|
1995
|
+
return null;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
function enrichOnboardingEntityGuide(entry) {
|
|
1999
|
+
const classification = classifyOnboardingEntity(entry.entityType);
|
|
2000
|
+
return {
|
|
2001
|
+
...entry,
|
|
2002
|
+
classification,
|
|
2003
|
+
routeBase: classification === "batch_crud_entity"
|
|
2004
|
+
? AGENT_ONBOARDING_BATCH_ROUTE_BASES[entry.entityType]
|
|
2005
|
+
: null,
|
|
2006
|
+
preferredMutationPath: buildPreferredMutationPath(entry.entityType),
|
|
2007
|
+
preferredReadPath: buildPreferredReadPath(entry.entityType),
|
|
2008
|
+
preferredMutationTool: classification === "batch_crud_entity"
|
|
2009
|
+
? "forge_create_entities | forge_update_entities | forge_delete_entities | forge_search_entities"
|
|
2010
|
+
: null
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
const AGENT_ONBOARDING_ENTITY_CATALOG = [
|
|
2014
|
+
...AGENT_ONBOARDING_ENTITY_CATALOG_BASE.map(enrichOnboardingEntityGuide),
|
|
2015
|
+
enrichOnboardingEntityGuide({
|
|
2016
|
+
entityType: "tag",
|
|
2017
|
+
purpose: "A shared classification label used across Forge entities and notes.",
|
|
2018
|
+
minimumCreateFields: ["label"],
|
|
2019
|
+
relationshipRules: [
|
|
2020
|
+
"Tags are simple reusable labels, not a substitute for richer entity links.",
|
|
2021
|
+
"They use batch CRUD like other simple entities."
|
|
2022
|
+
],
|
|
2023
|
+
searchHints: ["Search by label before creating a near-duplicate tag."],
|
|
2024
|
+
examples: ['{"label":"Deep work","kind":"execution"}'],
|
|
2025
|
+
fieldGuide: [
|
|
2026
|
+
{
|
|
2027
|
+
name: "label",
|
|
2028
|
+
type: "string",
|
|
2029
|
+
required: true,
|
|
2030
|
+
description: "Human-readable tag label."
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
name: "kind",
|
|
2034
|
+
type: "value|category|execution",
|
|
2035
|
+
required: false,
|
|
2036
|
+
description: "Optional tag family.",
|
|
2037
|
+
enumValues: ["value", "category", "execution"],
|
|
2038
|
+
defaultValue: "category"
|
|
2039
|
+
}
|
|
2040
|
+
]
|
|
2041
|
+
}),
|
|
2042
|
+
enrichOnboardingEntityGuide({
|
|
2043
|
+
entityType: "sleep_session",
|
|
2044
|
+
purpose: "A first-class health record for one night with timing, derived sleep scores, optional stage detail, and reflective links back into Forge.",
|
|
2045
|
+
minimumCreateFields: ["startedAt", "endedAt"],
|
|
2046
|
+
relationshipRules: [
|
|
2047
|
+
"Use batch CRUD for ordinary sleep_session create, update, delete, and search work.",
|
|
2048
|
+
"The direct PATCH route is still available when enriching an existing night with reflective notes after review.",
|
|
2049
|
+
"Sleep deletions are immediate and do not go through the settings bin."
|
|
2050
|
+
],
|
|
2051
|
+
searchHints: [
|
|
2052
|
+
"Search by linked entities or date window before creating a duplicate manual night."
|
|
2053
|
+
],
|
|
2054
|
+
examples: [
|
|
2055
|
+
'{"startedAt":"2026-04-10T22:45:00.000Z","endedAt":"2026-04-11T06:45:00.000Z","qualitySummary":"Slept cleanly after a light evening.","links":[{"entityType":"habit","entityId":"habit_sleep_hygiene","relationshipType":"supports"}]}'
|
|
2056
|
+
],
|
|
2057
|
+
fieldGuide: [
|
|
2058
|
+
{
|
|
2059
|
+
name: "startedAt",
|
|
2060
|
+
type: "ISO datetime",
|
|
2061
|
+
required: true,
|
|
2062
|
+
description: "Sleep start timestamp."
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
name: "endedAt",
|
|
2066
|
+
type: "ISO datetime",
|
|
2067
|
+
required: true,
|
|
2068
|
+
description: "Sleep end timestamp."
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
name: "timeInBedSeconds",
|
|
2072
|
+
type: "integer",
|
|
2073
|
+
required: false,
|
|
2074
|
+
description: "Defaults from startedAt and endedAt when omitted."
|
|
2075
|
+
},
|
|
2076
|
+
{
|
|
2077
|
+
name: "asleepSeconds",
|
|
2078
|
+
type: "integer",
|
|
2079
|
+
required: false,
|
|
2080
|
+
description: "Defaults to timeInBedSeconds when omitted."
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
name: "awakeSeconds",
|
|
2084
|
+
type: "integer",
|
|
2085
|
+
required: false,
|
|
2086
|
+
description: "Defaults to the residual between timeInBedSeconds and asleepSeconds."
|
|
2087
|
+
},
|
|
2088
|
+
{
|
|
2089
|
+
name: "stageBreakdown",
|
|
2090
|
+
type: "array",
|
|
2091
|
+
required: false,
|
|
2092
|
+
description: "Optional list of { stage, seconds } items.",
|
|
2093
|
+
defaultValue: []
|
|
2094
|
+
},
|
|
2095
|
+
{
|
|
2096
|
+
name: "recoveryMetrics",
|
|
2097
|
+
type: "object",
|
|
2098
|
+
required: false,
|
|
2099
|
+
description: "Optional metric bag attached to the night.",
|
|
2100
|
+
defaultValue: {}
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
name: "qualitySummary",
|
|
2104
|
+
type: "string",
|
|
2105
|
+
required: false,
|
|
2106
|
+
description: "Optional reflection summary.",
|
|
2107
|
+
defaultValue: ""
|
|
2108
|
+
},
|
|
2109
|
+
{
|
|
2110
|
+
name: "notes",
|
|
2111
|
+
type: "string",
|
|
2112
|
+
required: false,
|
|
2113
|
+
description: "Optional longer reflective note.",
|
|
2114
|
+
defaultValue: ""
|
|
2115
|
+
},
|
|
2116
|
+
{
|
|
2117
|
+
name: "tags",
|
|
2118
|
+
type: "string[]",
|
|
2119
|
+
required: false,
|
|
2120
|
+
description: "Optional review tags.",
|
|
2121
|
+
defaultValue: []
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
name: "links",
|
|
2125
|
+
type: "array",
|
|
2126
|
+
required: false,
|
|
2127
|
+
description: "Linked Forge entities for context or support.",
|
|
2128
|
+
defaultValue: []
|
|
2129
|
+
}
|
|
2130
|
+
]
|
|
2131
|
+
}),
|
|
2132
|
+
enrichOnboardingEntityGuide({
|
|
2133
|
+
entityType: "workout_session",
|
|
2134
|
+
purpose: "A first-class sports record with workout type, timing, optional effort or biometric detail, and linked Forge context.",
|
|
2135
|
+
minimumCreateFields: ["workoutType", "startedAt", "endedAt"],
|
|
2136
|
+
relationshipRules: [
|
|
2137
|
+
"Use batch CRUD for ordinary workout_session create, update, delete, and search work.",
|
|
2138
|
+
"The direct PATCH route remains useful for reflective enrichment after reviewing an existing imported or habit-generated workout.",
|
|
2139
|
+
"Workout deletions are immediate and do not go through the settings bin."
|
|
2140
|
+
],
|
|
2141
|
+
searchHints: [
|
|
2142
|
+
"Search by workoutType, linked entity, or nearby timestamps before creating another manual workout."
|
|
2143
|
+
],
|
|
2144
|
+
examples: [
|
|
2145
|
+
'{"workoutType":"walk","startedAt":"2026-04-11T10:00:00.000Z","endedAt":"2026-04-11T10:45:00.000Z","subjectiveEffort":6,"meaningText":"Reset after a long planning block."}'
|
|
2146
|
+
],
|
|
2147
|
+
fieldGuide: [
|
|
2148
|
+
{
|
|
2149
|
+
name: "workoutType",
|
|
2150
|
+
type: "string",
|
|
2151
|
+
required: true,
|
|
2152
|
+
description: "Canonical workout label such as walk, run, ride, or mobility."
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
name: "startedAt",
|
|
2156
|
+
type: "ISO datetime",
|
|
2157
|
+
required: true,
|
|
2158
|
+
description: "Workout start timestamp."
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
name: "endedAt",
|
|
2162
|
+
type: "ISO datetime",
|
|
2163
|
+
required: true,
|
|
2164
|
+
description: "Workout end timestamp."
|
|
2165
|
+
},
|
|
2166
|
+
{
|
|
2167
|
+
name: "activeEnergyKcal",
|
|
2168
|
+
type: "number|null",
|
|
2169
|
+
required: false,
|
|
2170
|
+
description: "Optional active calories.",
|
|
2171
|
+
defaultValue: null,
|
|
2172
|
+
nullable: true
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
name: "totalEnergyKcal",
|
|
2176
|
+
type: "number|null",
|
|
2177
|
+
required: false,
|
|
2178
|
+
description: "Optional total calories.",
|
|
2179
|
+
defaultValue: null,
|
|
2180
|
+
nullable: true
|
|
2181
|
+
},
|
|
2182
|
+
{
|
|
2183
|
+
name: "distanceMeters",
|
|
2184
|
+
type: "number|null",
|
|
2185
|
+
required: false,
|
|
2186
|
+
description: "Optional distance.",
|
|
2187
|
+
defaultValue: null,
|
|
2188
|
+
nullable: true
|
|
2189
|
+
},
|
|
2190
|
+
{
|
|
2191
|
+
name: "exerciseMinutes",
|
|
2192
|
+
type: "number|null",
|
|
2193
|
+
required: false,
|
|
2194
|
+
description: "Optional exercise minutes.",
|
|
2195
|
+
defaultValue: null,
|
|
2196
|
+
nullable: true
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
name: "subjectiveEffort",
|
|
2200
|
+
type: "integer|null",
|
|
2201
|
+
required: false,
|
|
2202
|
+
description: "Optional subjective effort 1-10.",
|
|
2203
|
+
defaultValue: null,
|
|
2204
|
+
nullable: true
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
name: "meaningText",
|
|
2208
|
+
type: "string",
|
|
2209
|
+
required: false,
|
|
2210
|
+
description: "Optional reflective meaning or context.",
|
|
2211
|
+
defaultValue: ""
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
name: "tags",
|
|
2215
|
+
type: "string[]",
|
|
2216
|
+
required: false,
|
|
2217
|
+
description: "Optional workout tags.",
|
|
2218
|
+
defaultValue: []
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "links",
|
|
2222
|
+
type: "array",
|
|
2223
|
+
required: false,
|
|
2224
|
+
description: "Linked Forge entities for context or support.",
|
|
2225
|
+
defaultValue: []
|
|
2226
|
+
}
|
|
2227
|
+
]
|
|
2228
|
+
}),
|
|
2229
|
+
enrichOnboardingEntityGuide({
|
|
2230
|
+
entityType: "preference_catalog",
|
|
2231
|
+
purpose: "A reusable concept list inside one preference domain, used to seed or organize comparison candidates.",
|
|
2232
|
+
minimumCreateFields: ["userId", "domain", "title"],
|
|
2233
|
+
relationshipRules: [
|
|
2234
|
+
"Preference catalogs are simple entities and should default to batch CRUD.",
|
|
2235
|
+
"Catalog items belong to one preference_catalog through catalogId."
|
|
2236
|
+
],
|
|
2237
|
+
searchHints: [
|
|
2238
|
+
"Search by title and domain before creating another concept list."
|
|
2239
|
+
],
|
|
2240
|
+
examples: [
|
|
2241
|
+
'{"userId":"user_operator","domain":"food","title":"Cafe shortlist"}'
|
|
2242
|
+
],
|
|
2243
|
+
fieldGuide: [
|
|
2244
|
+
{
|
|
2245
|
+
name: "userId",
|
|
2246
|
+
type: "string",
|
|
2247
|
+
required: true,
|
|
2248
|
+
description: "Owner user id."
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
name: "domain",
|
|
2252
|
+
type: "string",
|
|
2253
|
+
required: true,
|
|
2254
|
+
description: "Preference domain such as food, places, tools, or custom."
|
|
2255
|
+
},
|
|
2256
|
+
{
|
|
2257
|
+
name: "title",
|
|
2258
|
+
type: "string",
|
|
2259
|
+
required: true,
|
|
2260
|
+
description: "Catalog display title."
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
name: "description",
|
|
2264
|
+
type: "string",
|
|
2265
|
+
required: false,
|
|
2266
|
+
description: "Optional catalog summary.",
|
|
2267
|
+
defaultValue: ""
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
name: "slug",
|
|
2271
|
+
type: "string",
|
|
2272
|
+
required: false,
|
|
2273
|
+
description: "Optional stable slug.",
|
|
2274
|
+
defaultValue: ""
|
|
2275
|
+
}
|
|
2276
|
+
]
|
|
2277
|
+
}),
|
|
2278
|
+
enrichOnboardingEntityGuide({
|
|
2279
|
+
entityType: "preference_catalog_item",
|
|
2280
|
+
purpose: "One comparable candidate inside a preference catalog.",
|
|
2281
|
+
minimumCreateFields: ["catalogId", "label"],
|
|
2282
|
+
relationshipRules: [
|
|
2283
|
+
"Catalog items belong to a preference_catalog and use batch CRUD.",
|
|
2284
|
+
"They are concept seeds, not judgments or inferred scores."
|
|
2285
|
+
],
|
|
2286
|
+
searchHints: [
|
|
2287
|
+
"Search inside the catalog before creating another near-duplicate concept item."
|
|
2288
|
+
],
|
|
2289
|
+
examples: ['{"catalogId":"preference_catalog_123","label":"Flat white"}'],
|
|
2290
|
+
fieldGuide: [
|
|
2291
|
+
{
|
|
2292
|
+
name: "catalogId",
|
|
2293
|
+
type: "string",
|
|
2294
|
+
required: true,
|
|
2295
|
+
description: "Parent catalog id."
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
name: "label",
|
|
2299
|
+
type: "string",
|
|
2300
|
+
required: true,
|
|
2301
|
+
description: "Candidate label."
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
name: "description",
|
|
2305
|
+
type: "string",
|
|
2306
|
+
required: false,
|
|
2307
|
+
description: "Optional description.",
|
|
2308
|
+
defaultValue: ""
|
|
2309
|
+
},
|
|
2310
|
+
{
|
|
2311
|
+
name: "tags",
|
|
2312
|
+
type: "string[]",
|
|
2313
|
+
required: false,
|
|
2314
|
+
description: "Optional tags.",
|
|
2315
|
+
defaultValue: []
|
|
2316
|
+
},
|
|
2317
|
+
{
|
|
2318
|
+
name: "featureWeights",
|
|
2319
|
+
type: "object",
|
|
2320
|
+
required: false,
|
|
2321
|
+
description: "Optional interpretable feature weight hints.",
|
|
2322
|
+
defaultValue: {}
|
|
2323
|
+
}
|
|
2324
|
+
]
|
|
2325
|
+
}),
|
|
2326
|
+
enrichOnboardingEntityGuide({
|
|
2327
|
+
entityType: "preference_context",
|
|
2328
|
+
purpose: "A named preference mode such as Work, Personal, or Discovery under one user and domain.",
|
|
2329
|
+
minimumCreateFields: ["userId", "domain", "name"],
|
|
2330
|
+
relationshipRules: [
|
|
2331
|
+
"Preference contexts are simple entities and should default to batch CRUD.",
|
|
2332
|
+
"Use the merge action only when the operator explicitly wants context consolidation."
|
|
2333
|
+
],
|
|
2334
|
+
searchHints: ["Search by name and domain before creating another context."],
|
|
2335
|
+
examples: [
|
|
2336
|
+
'{"userId":"user_operator","domain":"food","name":"Work breakfasts","shareMode":"blended"}'
|
|
2337
|
+
],
|
|
2338
|
+
fieldGuide: [
|
|
2339
|
+
{
|
|
2340
|
+
name: "userId",
|
|
2341
|
+
type: "string",
|
|
2342
|
+
required: true,
|
|
2343
|
+
description: "Owner user id."
|
|
2344
|
+
},
|
|
2345
|
+
{
|
|
2346
|
+
name: "domain",
|
|
2347
|
+
type: "string",
|
|
2348
|
+
required: true,
|
|
2349
|
+
description: "Preference domain."
|
|
2350
|
+
},
|
|
2351
|
+
{
|
|
2352
|
+
name: "name",
|
|
2353
|
+
type: "string",
|
|
2354
|
+
required: true,
|
|
2355
|
+
description: "Context display name."
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
name: "description",
|
|
2359
|
+
type: "string",
|
|
2360
|
+
required: false,
|
|
2361
|
+
description: "Optional summary.",
|
|
2362
|
+
defaultValue: ""
|
|
2363
|
+
},
|
|
2364
|
+
{
|
|
2365
|
+
name: "shareMode",
|
|
2366
|
+
type: "shared|isolated|blended",
|
|
2367
|
+
required: false,
|
|
2368
|
+
description: "How this context mixes evidence with others.",
|
|
2369
|
+
enumValues: ["shared", "isolated", "blended"],
|
|
2370
|
+
defaultValue: "blended"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
name: "active",
|
|
2374
|
+
type: "boolean",
|
|
2375
|
+
required: false,
|
|
2376
|
+
description: "Whether the context is active.",
|
|
2377
|
+
defaultValue: true
|
|
2378
|
+
}
|
|
2379
|
+
]
|
|
2380
|
+
}),
|
|
2381
|
+
enrichOnboardingEntityGuide({
|
|
2382
|
+
entityType: "preference_item",
|
|
2383
|
+
purpose: "One modeled preference candidate that may stand alone or point back to another Forge entity.",
|
|
2384
|
+
minimumCreateFields: ["userId", "domain", "label"],
|
|
2385
|
+
relationshipRules: [
|
|
2386
|
+
"Preference items are simple entities and should default to batch CRUD.",
|
|
2387
|
+
"They can optionally point back to another Forge entity through sourceEntityType and sourceEntityId."
|
|
2388
|
+
],
|
|
2389
|
+
searchHints: [
|
|
2390
|
+
"Search by label, domain, or linked source entity before creating another preference item."
|
|
2391
|
+
],
|
|
2392
|
+
examples: [
|
|
2393
|
+
'{"userId":"user_operator","domain":"tools","label":"Mechanical keyboard"}'
|
|
2394
|
+
],
|
|
2395
|
+
fieldGuide: [
|
|
2396
|
+
{
|
|
2397
|
+
name: "userId",
|
|
2398
|
+
type: "string",
|
|
2399
|
+
required: true,
|
|
2400
|
+
description: "Owner user id."
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
name: "domain",
|
|
2404
|
+
type: "string",
|
|
2405
|
+
required: true,
|
|
2406
|
+
description: "Preference domain."
|
|
2407
|
+
},
|
|
2408
|
+
{
|
|
2409
|
+
name: "label",
|
|
2410
|
+
type: "string",
|
|
2411
|
+
required: true,
|
|
2412
|
+
description: "Item display label."
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
name: "description",
|
|
2416
|
+
type: "string",
|
|
2417
|
+
required: false,
|
|
2418
|
+
description: "Optional description.",
|
|
2419
|
+
defaultValue: ""
|
|
2420
|
+
},
|
|
2421
|
+
{
|
|
2422
|
+
name: "sourceEntityType",
|
|
2423
|
+
type: "string|null",
|
|
2424
|
+
required: false,
|
|
2425
|
+
description: "Optional linked Forge entity type.",
|
|
2426
|
+
defaultValue: null,
|
|
2427
|
+
nullable: true
|
|
2428
|
+
},
|
|
2429
|
+
{
|
|
2430
|
+
name: "sourceEntityId",
|
|
2431
|
+
type: "string|null",
|
|
2432
|
+
required: false,
|
|
2433
|
+
description: "Optional linked Forge entity id.",
|
|
2434
|
+
defaultValue: null,
|
|
2435
|
+
nullable: true
|
|
2436
|
+
},
|
|
2437
|
+
{
|
|
2438
|
+
name: "tags",
|
|
2439
|
+
type: "string[]",
|
|
2440
|
+
required: false,
|
|
2441
|
+
description: "Optional tags.",
|
|
2442
|
+
defaultValue: []
|
|
2443
|
+
}
|
|
2444
|
+
]
|
|
2445
|
+
}),
|
|
2446
|
+
enrichOnboardingEntityGuide({
|
|
2447
|
+
entityType: "questionnaire_instrument",
|
|
2448
|
+
purpose: "A reusable Psyche questionnaire instrument with versions, scoring rules, and provenance.",
|
|
2449
|
+
minimumCreateFields: [
|
|
2450
|
+
"title",
|
|
2451
|
+
"sourceClass",
|
|
2452
|
+
"availability",
|
|
2453
|
+
"isSelfReport",
|
|
2454
|
+
"versionLabel",
|
|
2455
|
+
"definition",
|
|
2456
|
+
"scoring",
|
|
2457
|
+
"provenance"
|
|
2458
|
+
],
|
|
2459
|
+
relationshipRules: [
|
|
2460
|
+
"Questionnaire instruments now default to batch CRUD for normal create, update, delete, and search work.",
|
|
2461
|
+
"Clone, ensure draft, and publish remain specialized actions because they operate on instrument version state."
|
|
2462
|
+
],
|
|
2463
|
+
searchHints: [
|
|
2464
|
+
"Search by title or key before creating a new custom instrument."
|
|
2465
|
+
],
|
|
2466
|
+
examples: [
|
|
2467
|
+
'{"title":"Tiny weekly check-in","sourceClass":"secondary_verified","availability":"custom","isSelfReport":true,"versionLabel":"Draft 1","definition":{"locale":"en","instructions":"Rate how present this feels today.","completionNote":"","presentationMode":"single_question","responseStyle":"four_point_frequency","itemIds":[],"items":[],"sections":[],"pageSize":null},"scoring":{"scores":[]},"provenance":{"retrievalDate":"2026-04-06","sourceClass":"secondary_verified","scoringNotes":"","sources":[]}}'
|
|
2468
|
+
],
|
|
2469
|
+
fieldGuide: [
|
|
2470
|
+
{
|
|
2471
|
+
name: "title",
|
|
2472
|
+
type: "string",
|
|
2473
|
+
required: true,
|
|
2474
|
+
description: "Instrument title."
|
|
2475
|
+
},
|
|
2476
|
+
{
|
|
2477
|
+
name: "sourceClass",
|
|
2478
|
+
type: "string",
|
|
2479
|
+
required: true,
|
|
2480
|
+
description: "Evidence or provenance class."
|
|
2481
|
+
},
|
|
2482
|
+
{
|
|
2483
|
+
name: "availability",
|
|
2484
|
+
type: "string",
|
|
2485
|
+
required: true,
|
|
2486
|
+
description: "System or custom availability mode."
|
|
2487
|
+
},
|
|
2488
|
+
{
|
|
2489
|
+
name: "isSelfReport",
|
|
2490
|
+
type: "boolean",
|
|
2491
|
+
required: true,
|
|
2492
|
+
description: "Whether the instrument is self-report."
|
|
1845
2493
|
},
|
|
1846
2494
|
{
|
|
1847
|
-
name: "
|
|
1848
|
-
type: "string
|
|
1849
|
-
required:
|
|
1850
|
-
description: "
|
|
1851
|
-
defaultValue: []
|
|
2495
|
+
name: "versionLabel",
|
|
2496
|
+
type: "string",
|
|
2497
|
+
required: true,
|
|
2498
|
+
description: "Initial draft version label on create."
|
|
1852
2499
|
},
|
|
1853
2500
|
{
|
|
1854
|
-
name: "
|
|
1855
|
-
type: "
|
|
1856
|
-
required:
|
|
1857
|
-
description: "
|
|
1858
|
-
defaultValue: []
|
|
2501
|
+
name: "definition",
|
|
2502
|
+
type: "object",
|
|
2503
|
+
required: true,
|
|
2504
|
+
description: "Questionnaire definition payload."
|
|
1859
2505
|
},
|
|
1860
2506
|
{
|
|
1861
|
-
name: "
|
|
1862
|
-
type: "
|
|
1863
|
-
required:
|
|
1864
|
-
description: "
|
|
1865
|
-
defaultValue: []
|
|
2507
|
+
name: "scoring",
|
|
2508
|
+
type: "object",
|
|
2509
|
+
required: true,
|
|
2510
|
+
description: "Scoring payload."
|
|
1866
2511
|
},
|
|
1867
2512
|
{
|
|
1868
|
-
name: "
|
|
1869
|
-
type: "
|
|
1870
|
-
required:
|
|
1871
|
-
description: "
|
|
1872
|
-
|
|
1873
|
-
|
|
2513
|
+
name: "provenance",
|
|
2514
|
+
type: "object",
|
|
2515
|
+
required: true,
|
|
2516
|
+
description: "Provenance payload."
|
|
2517
|
+
}
|
|
2518
|
+
]
|
|
2519
|
+
}),
|
|
2520
|
+
enrichOnboardingEntityGuide({
|
|
2521
|
+
entityType: "task_run",
|
|
2522
|
+
purpose: "A live timed work session attached to a task.",
|
|
2523
|
+
minimumCreateFields: [],
|
|
2524
|
+
relationshipRules: [
|
|
2525
|
+
"Task runs are action-heavy records. Do not model them as ordinary CRUD entities.",
|
|
2526
|
+
"Start, focus, heartbeat, complete, or release them through the dedicated task-run routes."
|
|
2527
|
+
],
|
|
2528
|
+
searchHints: [
|
|
2529
|
+
"Read operator context before starting or altering live work."
|
|
2530
|
+
],
|
|
2531
|
+
fieldGuide: []
|
|
2532
|
+
}),
|
|
2533
|
+
enrichOnboardingEntityGuide({
|
|
2534
|
+
entityType: "questionnaire_run",
|
|
2535
|
+
purpose: "One user-owned answer session against a questionnaire instrument version.",
|
|
2536
|
+
minimumCreateFields: [],
|
|
2537
|
+
relationshipRules: [
|
|
2538
|
+
"Questionnaire runs are action-heavy records with a lifecycle of start, patch answers, and complete.",
|
|
2539
|
+
"Use the run routes instead of batch CRUD."
|
|
2540
|
+
],
|
|
2541
|
+
searchHints: [
|
|
2542
|
+
"Read the run detail when continuing or reviewing an in-flight answer session."
|
|
2543
|
+
],
|
|
2544
|
+
fieldGuide: []
|
|
2545
|
+
}),
|
|
2546
|
+
enrichOnboardingEntityGuide({
|
|
2547
|
+
entityType: "calendar_connection",
|
|
2548
|
+
purpose: "A stored external calendar provider connection and its selected calendars.",
|
|
2549
|
+
minimumCreateFields: [],
|
|
2550
|
+
relationshipRules: [
|
|
2551
|
+
"Calendar connections use specialized setup and sync flows rather than batch CRUD.",
|
|
2552
|
+
"Provider auth and writable Forge-calendar selection are part of the same specialized surface."
|
|
2553
|
+
],
|
|
2554
|
+
searchHints: [
|
|
2555
|
+
"Read the calendar overview before changing connections or sync state."
|
|
2556
|
+
],
|
|
2557
|
+
fieldGuide: []
|
|
2558
|
+
}),
|
|
2559
|
+
enrichOnboardingEntityGuide({
|
|
2560
|
+
entityType: "wiki_page",
|
|
2561
|
+
purpose: "A file-backed Forge wiki page or evidence page.",
|
|
2562
|
+
minimumCreateFields: ["title", "contentMarkdown"],
|
|
2563
|
+
relationshipRules: [
|
|
2564
|
+
"Wiki pages live on the wiki surface and use specialized page upsert routes rather than batch CRUD.",
|
|
2565
|
+
"Entity links remain explicit inside the page link model."
|
|
2566
|
+
],
|
|
2567
|
+
searchHints: [
|
|
2568
|
+
"Search or list wiki pages before creating another page with the same topic."
|
|
2569
|
+
],
|
|
2570
|
+
fieldGuide: [
|
|
1874
2571
|
{
|
|
1875
|
-
name: "
|
|
1876
|
-
type: "
|
|
1877
|
-
required:
|
|
1878
|
-
description: "
|
|
1879
|
-
defaultValue: []
|
|
2572
|
+
name: "title",
|
|
2573
|
+
type: "string",
|
|
2574
|
+
required: true,
|
|
2575
|
+
description: "Page title."
|
|
1880
2576
|
},
|
|
1881
2577
|
{
|
|
1882
|
-
name: "
|
|
1883
|
-
type: "string
|
|
1884
|
-
required:
|
|
1885
|
-
description: "
|
|
1886
|
-
defaultValue: []
|
|
2578
|
+
name: "contentMarkdown",
|
|
2579
|
+
type: "string",
|
|
2580
|
+
required: true,
|
|
2581
|
+
description: "Markdown body."
|
|
1887
2582
|
}
|
|
1888
2583
|
]
|
|
1889
|
-
}
|
|
2584
|
+
}),
|
|
2585
|
+
enrichOnboardingEntityGuide({
|
|
2586
|
+
entityType: "self_observation",
|
|
2587
|
+
purpose: "The note-backed Psyche self-observation calendar surface for observed events and reflections.",
|
|
2588
|
+
minimumCreateFields: [],
|
|
2589
|
+
relationshipRules: [
|
|
2590
|
+
"This is a read model, not a standalone CRUD entity.",
|
|
2591
|
+
"Mutate it by creating or updating a note with frontmatter.observedAt."
|
|
2592
|
+
],
|
|
2593
|
+
searchHints: [
|
|
2594
|
+
"Read the self-observation calendar before proposing new reflected notes or edits."
|
|
2595
|
+
],
|
|
2596
|
+
fieldGuide: []
|
|
2597
|
+
}),
|
|
2598
|
+
enrichOnboardingEntityGuide({
|
|
2599
|
+
entityType: "sleep_overview",
|
|
2600
|
+
purpose: "The read-model sleep workspace that summarizes recent sleep sessions, trends, and stage averages.",
|
|
2601
|
+
minimumCreateFields: [],
|
|
2602
|
+
relationshipRules: [
|
|
2603
|
+
"Use this surface for review.",
|
|
2604
|
+
"Create, update, delete, or search the underlying sleep_session records through batch CRUD by default."
|
|
2605
|
+
],
|
|
2606
|
+
searchHints: [
|
|
2607
|
+
"Read this surface before suggesting reflective edits or health-planning follow-up."
|
|
2608
|
+
],
|
|
2609
|
+
fieldGuide: []
|
|
2610
|
+
}),
|
|
2611
|
+
enrichOnboardingEntityGuide({
|
|
2612
|
+
entityType: "sports_overview",
|
|
2613
|
+
purpose: "The read-model sports workspace that summarizes recent workout sessions and training load.",
|
|
2614
|
+
minimumCreateFields: [],
|
|
2615
|
+
relationshipRules: [
|
|
2616
|
+
"Use this surface for review.",
|
|
2617
|
+
"Create, update, delete, or search the underlying workout_session records through batch CRUD by default."
|
|
2618
|
+
],
|
|
2619
|
+
searchHints: [
|
|
2620
|
+
"Read this surface before suggesting workout reflections or recovery follow-up."
|
|
2621
|
+
],
|
|
2622
|
+
fieldGuide: []
|
|
2623
|
+
})
|
|
1890
2624
|
];
|
|
1891
2625
|
const AGENT_ONBOARDING_CONVERSATION_RULES = [
|
|
1892
2626
|
"Ask only for what is missing or unclear instead of walking the user through every optional field.",
|
|
2627
|
+
"Start by saying what seems to matter here or what the record is becoming, then ask the next useful question.",
|
|
2628
|
+
"Before each question, decide the one missing thing you are trying to clarify and why it matters for the record.",
|
|
1893
2629
|
"Use a progression of concrete example or intent, working name, purpose or meaning, placement in Forge, operational details, and linked context.",
|
|
1894
2630
|
"Ask one to three focused questions at a time. One is usually best when the user is uncertain or emotionally loaded.",
|
|
2631
|
+
"One focused question is the default. Only stack a second question when both serve the same clarification job and the user is steady enough for it.",
|
|
1895
2632
|
"If the user already answered the normal opening question, do not repeat it. Move to the next missing clarification.",
|
|
1896
2633
|
"Do not over-therapize logistical entities. For tasks, calendar events, work blocks, timeboxes, and task runs, one brief confirming sentence plus one question is usually enough.",
|
|
2634
|
+
"After each substantive answer, briefly say what is becoming clearer and ask only for the next thing that still changes the record shape or usefulness.",
|
|
2635
|
+
"For reusable records such as tags, event types, emotion definitions, preference contexts, or questionnaires, ask what distinction or decision the record should help with before you ask for wording.",
|
|
2636
|
+
"When useful, help the user name, define, and connect the record in that order: offer a working label, clarify what belongs inside it, then ask about links only after the record itself feels steady.",
|
|
2637
|
+
"When the meaning is clearer than the wording, offer a tentative title or formulation yourself and invite correction instead of forcing the user to wordsmith alone.",
|
|
1897
2638
|
"Before saving, briefly summarize the working formulation in the user's own language when that would reduce ambiguity.",
|
|
2639
|
+
"Once the record is clear enough to name, stop exploring broadly and ask only for the last structural detail that still matters.",
|
|
2640
|
+
"If the record is already clear enough to save, save it instead of performing a ceremonial extra question.",
|
|
2641
|
+
"If the user accepts the wording or record shape, move to the write instead of reopening the intake.",
|
|
1898
2642
|
"When updating an entity, start with what is changing, what should stay true, and what prompted the update now."
|
|
1899
2643
|
];
|
|
1900
2644
|
const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
1901
2645
|
{
|
|
1902
2646
|
focus: "goal",
|
|
1903
|
-
openingQuestion: "What direction
|
|
2647
|
+
openingQuestion: "What direction are you trying to keep hold of here?",
|
|
1904
2648
|
coachingGoal: "Clarify the direction and why it matters, not just produce a title.",
|
|
1905
2649
|
askSequence: [
|
|
1906
2650
|
"Ask what direction or outcome the user wants to keep in view.",
|
|
2651
|
+
"Reflect the deeper stake in plain language before moving on.",
|
|
1907
2652
|
"Ask why it matters now.",
|
|
1908
2653
|
"Distinguish the goal from a project or task.",
|
|
1909
2654
|
"Clarify horizon and status only after the meaning is clear."
|
|
@@ -1911,10 +2656,11 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1911
2656
|
},
|
|
1912
2657
|
{
|
|
1913
2658
|
focus: "project",
|
|
1914
|
-
openingQuestion: "If this became a real project, what would you be trying to make true?",
|
|
2659
|
+
openingQuestion: "If this became a real project, what would you be trying to make true in your life or work?",
|
|
1915
2660
|
coachingGoal: "Turn an intention into a bounded workstream with a clear outcome.",
|
|
1916
2661
|
askSequence: [
|
|
1917
2662
|
"Ask what this piece of work is trying to make true.",
|
|
2663
|
+
"Reflect the emerging boundary so the user can hear what is in scope.",
|
|
1918
2664
|
"Ask what outcome would make the project feel real or complete for now.",
|
|
1919
2665
|
"Ask which goal it belongs under.",
|
|
1920
2666
|
"Land on a working name once the scope is clear.",
|
|
@@ -1923,10 +2669,11 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1923
2669
|
},
|
|
1924
2670
|
{
|
|
1925
2671
|
focus: "strategy",
|
|
1926
|
-
openingQuestion: "What future state
|
|
2672
|
+
openingQuestion: "What future state are you actually trying to arrive at with this strategy?",
|
|
1927
2673
|
coachingGoal: "Turn a vague plan into a deliberate sequence toward a real end state.",
|
|
1928
2674
|
askSequence: [
|
|
1929
2675
|
"Ask what end state the strategy is trying to land.",
|
|
2676
|
+
"Reflect the destination in plain language so the user can correct it early.",
|
|
1930
2677
|
"Ask which goals or projects are the true targets.",
|
|
1931
2678
|
"Ask what the major steps or nodes are.",
|
|
1932
2679
|
"Ask about order, dependencies, and anything that must not be skipped."
|
|
@@ -1934,7 +2681,7 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1934
2681
|
},
|
|
1935
2682
|
{
|
|
1936
2683
|
focus: "task",
|
|
1937
|
-
openingQuestion: "What is the next concrete move
|
|
2684
|
+
openingQuestion: "What is the next concrete move here?",
|
|
1938
2685
|
coachingGoal: "Identify the next concrete move, not just capture a vague obligation.",
|
|
1939
2686
|
askSequence: [
|
|
1940
2687
|
"Ask what the next concrete action is.",
|
|
@@ -1944,7 +2691,7 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1944
2691
|
},
|
|
1945
2692
|
{
|
|
1946
2693
|
focus: "habit",
|
|
1947
|
-
openingQuestion: "What recurring move are you trying to strengthen or
|
|
2694
|
+
openingQuestion: "What recurring move are you trying to strengthen or interrupt?",
|
|
1948
2695
|
coachingGoal: "Define the recurring behavior and cadence clearly enough for honest later check-ins.",
|
|
1949
2696
|
askSequence: [
|
|
1950
2697
|
"Ask what the recurring behavior is in plain language.",
|
|
@@ -1953,9 +2700,20 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1953
2700
|
"Ask about links only if they will help later review."
|
|
1954
2701
|
]
|
|
1955
2702
|
},
|
|
2703
|
+
{
|
|
2704
|
+
focus: "tag",
|
|
2705
|
+
openingQuestion: "What do you want this tag to help you notice or find again later?",
|
|
2706
|
+
coachingGoal: "Create a label that helps later retrieval or grouping instead of another vague bucket.",
|
|
2707
|
+
askSequence: [
|
|
2708
|
+
"Ask what the tag should help the user notice, group, or find later.",
|
|
2709
|
+
"Ask what kinds of records should belong under it and what should stay outside it.",
|
|
2710
|
+
"Offer a concise label if the grouping meaning is clearer than the wording.",
|
|
2711
|
+
"Ask about color, kind, or parent grouping only if that changes how the tag will be used."
|
|
2712
|
+
]
|
|
2713
|
+
},
|
|
1956
2714
|
{
|
|
1957
2715
|
focus: "note",
|
|
1958
|
-
openingQuestion: "What feels
|
|
2716
|
+
openingQuestion: "What about this feels worth preserving in a note?",
|
|
1959
2717
|
coachingGoal: "Preserve the useful context and link it to the right places without turning the note into a dump.",
|
|
1960
2718
|
askSequence: [
|
|
1961
2719
|
"Ask what the note needs to preserve.",
|
|
@@ -1964,9 +2722,20 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
1964
2722
|
"Ask about tags or author only if they help retrieval or handoff."
|
|
1965
2723
|
]
|
|
1966
2724
|
},
|
|
2725
|
+
{
|
|
2726
|
+
focus: "wiki_page",
|
|
2727
|
+
openingQuestion: "What should this page become the main reference for?",
|
|
2728
|
+
coachingGoal: "Create a durable reference page with a clear scope instead of dumping raw notes into the wiki.",
|
|
2729
|
+
askSequence: [
|
|
2730
|
+
"Ask what topic this page should become the canonical place for.",
|
|
2731
|
+
"Ask whether it is a durable wiki page or supporting evidence.",
|
|
2732
|
+
"Ask what future lookup, decision, or collaboration this page should support.",
|
|
2733
|
+
"Ask about linked entities, aliases, or tags only if they will make the page more navigable later."
|
|
2734
|
+
]
|
|
2735
|
+
},
|
|
1967
2736
|
{
|
|
1968
2737
|
focus: "insight",
|
|
1969
|
-
openingQuestion: "What
|
|
2738
|
+
openingQuestion: "What is the clearest thing you want future-you or the agent to remember from this?",
|
|
1970
2739
|
coachingGoal: "Capture one grounded observation or recommendation clearly enough that it remains useful later.",
|
|
1971
2740
|
askSequence: [
|
|
1972
2741
|
"Ask what pattern, tension, or observation should be remembered.",
|
|
@@ -2006,23 +2775,147 @@ const AGENT_ONBOARDING_ENTITY_CONVERSATION_PLAYBOOKS = [
|
|
|
2006
2775
|
"Ask about source or override reason only when that context matters."
|
|
2007
2776
|
]
|
|
2008
2777
|
},
|
|
2778
|
+
{
|
|
2779
|
+
focus: "calendar_connection",
|
|
2780
|
+
openingQuestion: "Which calendar provider are you trying to connect, and what do you want Forge to do with it?",
|
|
2781
|
+
coachingGoal: "Connect the right provider deliberately without turning setup into a credential dump.",
|
|
2782
|
+
askSequence: [
|
|
2783
|
+
"Ask which provider the user wants to connect and what they want Forge to do with it.",
|
|
2784
|
+
"Ask whether the goal is read-only visibility, writable planning, or both.",
|
|
2785
|
+
"Ask only for the next provider-specific step that still matters, such as auth flow, label, or calendar selection.",
|
|
2786
|
+
"Move into the actual connection flow once the setup goal is clear."
|
|
2787
|
+
]
|
|
2788
|
+
},
|
|
2789
|
+
{
|
|
2790
|
+
focus: "task_run",
|
|
2791
|
+
openingQuestion: "Which task should I start?",
|
|
2792
|
+
coachingGoal: "Start truthful live work with as little friction as possible while still knowing what is being worked on and by whom.",
|
|
2793
|
+
askSequence: [
|
|
2794
|
+
"Confirm the task.",
|
|
2795
|
+
"Confirm the actor only if it is not already obvious.",
|
|
2796
|
+
"Ask whether the run should be planned or unlimited only if that changes the action.",
|
|
2797
|
+
"Start the run instead of turning it into a longer intake."
|
|
2798
|
+
]
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
focus: "self_observation",
|
|
2802
|
+
openingQuestion: "What did you notice most clearly in that moment?",
|
|
2803
|
+
coachingGoal: "Capture one observation clearly enough that it can support later reflection without pretending it is already a full interpretation.",
|
|
2804
|
+
askSequence: [
|
|
2805
|
+
"Ask what was observed.",
|
|
2806
|
+
"Reflect the moment without pretending it is already a finished interpretation.",
|
|
2807
|
+
"Ask when it happened or became noticeable unless timing is already clear.",
|
|
2808
|
+
"Ask what it may connect to: pattern, belief, value, mode, task, project, or note.",
|
|
2809
|
+
"Ask for tags or extra context only if that will help later review."
|
|
2810
|
+
]
|
|
2811
|
+
},
|
|
2812
|
+
{
|
|
2813
|
+
focus: "sleep_session",
|
|
2814
|
+
openingQuestion: "What about this night feels important enough to remember or connect?",
|
|
2815
|
+
coachingGoal: "Enrich one night's record with reflective context instead of treating it like a generic note.",
|
|
2816
|
+
askSequence: [
|
|
2817
|
+
"Ask what about the night feels worth capturing.",
|
|
2818
|
+
"Ask whether the main point is quality, pattern, context, meaning, or links.",
|
|
2819
|
+
"Ask what goal, project, task, habit, or Psyche record it should stay connected to.",
|
|
2820
|
+
"Ask about tags only if they will help later review."
|
|
2821
|
+
]
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
focus: "workout_session",
|
|
2825
|
+
openingQuestion: "What about this workout feels most worth remembering or connecting?",
|
|
2826
|
+
coachingGoal: "Enrich one workout with subjective effort, mood, meaning, or linked context.",
|
|
2827
|
+
askSequence: [
|
|
2828
|
+
"Ask what about the session the user wants to preserve.",
|
|
2829
|
+
"Ask whether the key layer is effort, mood, meaning, social context, or links.",
|
|
2830
|
+
"Ask what it connects to in Forge if links matter.",
|
|
2831
|
+
"Ask about tags only if they help later retrieval."
|
|
2832
|
+
]
|
|
2833
|
+
},
|
|
2834
|
+
{
|
|
2835
|
+
focus: "preference_catalog",
|
|
2836
|
+
openingQuestion: "What decision or taste question should this catalog help with?",
|
|
2837
|
+
coachingGoal: "Define a useful comparison pool rather than a list with no decision purpose.",
|
|
2838
|
+
askSequence: [
|
|
2839
|
+
"Ask what preference question this catalog is meant to support.",
|
|
2840
|
+
"Ask what domain or concept area it belongs to.",
|
|
2841
|
+
"Ask what kinds of items should be included or excluded.",
|
|
2842
|
+
"Offer a working catalog name once the purpose is clear."
|
|
2843
|
+
]
|
|
2844
|
+
},
|
|
2845
|
+
{
|
|
2846
|
+
focus: "preference_catalog_item",
|
|
2847
|
+
openingQuestion: "What makes this option meaningfully worth comparing?",
|
|
2848
|
+
coachingGoal: "Add one candidate in a way that will make later comparisons feel clear and fair.",
|
|
2849
|
+
askSequence: [
|
|
2850
|
+
"Ask what makes this item worth including in the catalog.",
|
|
2851
|
+
"Ask what catalog or domain it belongs to if that is still unclear.",
|
|
2852
|
+
"Ask for a short clarifying description only if the label would be ambiguous later.",
|
|
2853
|
+
"Ask about aliases or tags only if they help retrieval."
|
|
2854
|
+
]
|
|
2855
|
+
},
|
|
2856
|
+
{
|
|
2857
|
+
focus: "preference_context",
|
|
2858
|
+
openingQuestion: "In what situation should Forge treat your preferences differently here?",
|
|
2859
|
+
coachingGoal: "Define a real operating mode for preferences instead of a decorative label.",
|
|
2860
|
+
askSequence: [
|
|
2861
|
+
"Ask what situation or mode this context is meant to represent.",
|
|
2862
|
+
"Ask what decisions or comparisons should feel different inside that context.",
|
|
2863
|
+
"Ask what should count inside that context and what should stay outside it.",
|
|
2864
|
+
"Ask whether it should be active, default, or kept separate from other evidence.",
|
|
2865
|
+
"Offer a concise name if the mode is clearer than the wording."
|
|
2866
|
+
]
|
|
2867
|
+
},
|
|
2868
|
+
{
|
|
2869
|
+
focus: "preference_item",
|
|
2870
|
+
openingQuestion: "What preference are you trying to make clearer by saving this item?",
|
|
2871
|
+
coachingGoal: "Save one concrete preference candidate or signal without losing the context that makes it meaningful.",
|
|
2872
|
+
askSequence: [
|
|
2873
|
+
"Ask what preference or taste question this item belongs to.",
|
|
2874
|
+
"Ask what domain or context it should live in.",
|
|
2875
|
+
"Ask whether the user is saving a comparison candidate or a direct signal such as favorite, veto, or compare-later.",
|
|
2876
|
+
"Ask what makes the item distinct enough to compare usefully only if it is still a comparison candidate."
|
|
2877
|
+
]
|
|
2878
|
+
},
|
|
2879
|
+
{
|
|
2880
|
+
focus: "questionnaire_instrument",
|
|
2881
|
+
openingQuestion: "What would this questionnaire help someone notice or track?",
|
|
2882
|
+
coachingGoal: "Clarify whether the user is authoring a reusable questionnaire and what the instrument is for.",
|
|
2883
|
+
askSequence: [
|
|
2884
|
+
"Ask what the questionnaire is meant to measure or surface.",
|
|
2885
|
+
"Ask who it is for and when it should be used.",
|
|
2886
|
+
"Ask what kind of honest moment or decision it should help someone answer before getting into item wording.",
|
|
2887
|
+
"Reflect the practical use case back in plain language.",
|
|
2888
|
+
"Move to draft creation once the purpose is clear."
|
|
2889
|
+
]
|
|
2890
|
+
},
|
|
2891
|
+
{
|
|
2892
|
+
focus: "questionnaire_run",
|
|
2893
|
+
openingQuestion: "Do you want to start, continue, review, or finish a questionnaire run?",
|
|
2894
|
+
coachingGoal: "Clarify whether the user wants to start, continue, or complete one answer session.",
|
|
2895
|
+
askSequence: [
|
|
2896
|
+
"Ask which questionnaire run this is about.",
|
|
2897
|
+
"Ask whether the user wants to start, continue, review, or complete it.",
|
|
2898
|
+
"If answering is still in progress, ask only for the next answer or note that matters."
|
|
2899
|
+
]
|
|
2900
|
+
},
|
|
2009
2901
|
{
|
|
2010
2902
|
focus: "event_type",
|
|
2011
|
-
openingQuestion: "
|
|
2903
|
+
openingQuestion: "What kind of moment keeps happening that you want future reports to name the same way each time?",
|
|
2012
2904
|
coachingGoal: "Create a reusable incident category that will actually help future reports stay consistent.",
|
|
2013
2905
|
askSequence: [
|
|
2014
|
-
"Ask what
|
|
2906
|
+
"Ask what kind of moment or incident this label should capture in lived terms.",
|
|
2015
2907
|
"Ask how narrow or broad it should be.",
|
|
2908
|
+
"Ask what would count as inside versus outside the category if that boundary is still fuzzy.",
|
|
2016
2909
|
"Ask for a short description only if the label could be ambiguous later."
|
|
2017
2910
|
]
|
|
2018
2911
|
},
|
|
2019
2912
|
{
|
|
2020
2913
|
focus: "emotion_definition",
|
|
2021
|
-
openingQuestion: "
|
|
2914
|
+
openingQuestion: "When this feeling is present, what tells you it is this feeling and not a nearby one?",
|
|
2022
2915
|
coachingGoal: "Create a reusable emotion label with enough clarity to use consistently later.",
|
|
2023
2916
|
askSequence: [
|
|
2024
|
-
"Ask what
|
|
2025
|
-
"Ask what distinguishes it from nearby emotions.",
|
|
2917
|
+
"Ask what this feeling is like in lived terms when the user says it.",
|
|
2918
|
+
"Ask what distinguishes it from nearby emotions if that matters.",
|
|
2026
2919
|
"Ask for a broader category only if it will help later browsing or reporting."
|
|
2027
2920
|
]
|
|
2028
2921
|
}
|
|
@@ -2331,7 +3224,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2331
3224
|
{
|
|
2332
3225
|
toolName: "forge_create_entities",
|
|
2333
3226
|
summary: "Create one or more entities in one ordered batch.",
|
|
2334
|
-
whenToUse: "Use after explicit save intent and after duplicate checks when needed.",
|
|
3227
|
+
whenToUse: "Use after explicit save intent and after duplicate checks when needed. This is the default create path for simple Forge entities; do not spray one-off direct mutation routes when the batch contract already covers the record.",
|
|
2335
3228
|
inputShape: "{ atomic?: boolean, operations: Array<{ entityType: CrudEntityType, clientRef?: string, data: object }> }",
|
|
2336
3229
|
requiredFields: [
|
|
2337
3230
|
"operations",
|
|
@@ -2342,7 +3235,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2342
3235
|
"entityType alone is never enough; full data is required.",
|
|
2343
3236
|
"Batch multiple related creates together when they come from one user ask.",
|
|
2344
3237
|
"Goal, project, and task creates can include notes: [{ contentMarkdown, author?, tags?, destroyAt?, links? }] and Forge will auto-link those notes to the newly created entity.",
|
|
2345
|
-
"The same batch create route also handles calendar_event, work_block_template, task_timebox, preference_catalog, preference_catalog_item, preference_context, preference_item, and questionnaire_instrument.",
|
|
3238
|
+
"The same batch create route also handles calendar_event, work_block_template, task_timebox, sleep_session, workout_session, preference_catalog, preference_catalog_item, preference_context, preference_item, and questionnaire_instrument.",
|
|
2346
3239
|
"Calendar-event creates still trigger downstream projection sync when a writable provider calendar is selected."
|
|
2347
3240
|
],
|
|
2348
3241
|
example: '{"operations":[{"entityType":"task","data":{"title":"Write the public release notes","projectId":"project_123","status":"focus","notes":[{"contentMarkdown":"Starting from the changelog draft and the last QA pass."}]},"clientRef":"task-1"}]}'
|
|
@@ -2350,7 +3243,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2350
3243
|
{
|
|
2351
3244
|
toolName: "forge_update_entities",
|
|
2352
3245
|
summary: "Patch one or more entities in one ordered batch.",
|
|
2353
|
-
whenToUse: "Use when ids are known and the user explicitly wants a change persisted.",
|
|
3246
|
+
whenToUse: "Use when ids are known and the user explicitly wants a change persisted. This is the default update path for simple Forge entities, including manual health-session CRUD.",
|
|
2354
3247
|
inputShape: "{ atomic?: boolean, operations: Array<{ entityType: CrudEntityType, id: string, clientRef?: string, patch: object }> }",
|
|
2355
3248
|
requiredFields: [
|
|
2356
3249
|
"operations",
|
|
@@ -2363,7 +3256,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2363
3256
|
"Project lifecycle is status-driven: patch project.status to active, paused, or completed instead of looking for separate suspend, restart, or finish routes.",
|
|
2364
3257
|
"Setting project.status to completed finishes the project and auto-completes linked unfinished tasks through the normal task completion path.",
|
|
2365
3258
|
"Task and project scheduling rules stay on these same entity patches. Update task.schedulingRules, task.plannedDurationSeconds, or project.schedulingRules here.",
|
|
2366
|
-
"Use this same route to move or relink calendar_event records, edit work_block_template or
|
|
3259
|
+
"Use this same route to move or relink calendar_event records, edit work_block_template, task_timebox, sleep_session, or workout_session records, and do normal field updates on preference_catalog, preference_catalog_item, preference_context, preference_item, and questionnaire_instrument."
|
|
2367
3260
|
],
|
|
2368
3261
|
example: '{"operations":[{"entityType":"project","id":"project_123","patch":{"status":"completed"},"clientRef":"project-finish-1"}]}'
|
|
2369
3262
|
},
|
|
@@ -2381,7 +3274,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2381
3274
|
"Delete defaults to soft.",
|
|
2382
3275
|
"Use mode=hard only for explicit permanent removal.",
|
|
2383
3276
|
"Restoration is only possible after soft delete.",
|
|
2384
|
-
"calendar_event, work_block_template, and
|
|
3277
|
+
"calendar_event, work_block_template, task_timebox, sleep_session, and workout_session are immediate deletions: calendar events delete remote projections too, and these records do not go through the settings bin."
|
|
2385
3278
|
],
|
|
2386
3279
|
example: '{"operations":[{"entityType":"task","id":"task_123","mode":"soft","reason":"Merged into another task"}]}'
|
|
2387
3280
|
},
|
|
@@ -2532,7 +3425,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2532
3425
|
{
|
|
2533
3426
|
toolName: "forge_update_sleep_session",
|
|
2534
3427
|
summary: "Patch one sleep session with reflective notes, tags, or linked Forge context.",
|
|
2535
|
-
whenToUse: "Use after reviewing a specific night when the operator wants richer context stored on that sleep record.",
|
|
3428
|
+
whenToUse: "Use after reviewing a specific night when the operator wants richer context stored on that sleep record. Do not use this as the primary CRUD path when batch entity mutation already fits the job.",
|
|
2536
3429
|
inputShape: "{ sleepId: string, qualitySummary?: string, notes?: string, tags?: string[], links?: Array<{ entityType, entityId, relationshipType? }> }",
|
|
2537
3430
|
requiredFields: ["sleepId"],
|
|
2538
3431
|
notes: [
|
|
@@ -2544,7 +3437,7 @@ const AGENT_ONBOARDING_TOOL_INPUT_CATALOG = [
|
|
|
2544
3437
|
{
|
|
2545
3438
|
toolName: "forge_update_workout_session",
|
|
2546
3439
|
summary: "Patch one workout session with subjective effort, mood, meaning, tags, or linked Forge context.",
|
|
2547
|
-
whenToUse: "Use after reviewing one sports session when the operator wants the workout record to carry narrative or planning context.",
|
|
3440
|
+
whenToUse: "Use after reviewing one sports session when the operator wants the workout record to carry narrative or planning context. Do not use this as the primary CRUD path when batch entity mutation already fits the job.",
|
|
2548
3441
|
inputShape: "{ workoutId: string, subjectiveEffort?: integer|null, moodBefore?: string, moodAfter?: string, meaningText?: string, plannedContext?: string, socialContext?: string, tags?: string[], links?: Array<{ entityType, entityId, relationshipType? }> }",
|
|
2549
3442
|
requiredFields: ["workoutId"],
|
|
2550
3443
|
notes: [
|
|
@@ -2864,7 +3757,9 @@ function buildAgentOnboardingPayload(request) {
|
|
|
2864
3757
|
"preference_catalog_item",
|
|
2865
3758
|
"preference_context",
|
|
2866
3759
|
"preference_item",
|
|
2867
|
-
"questionnaire_instrument"
|
|
3760
|
+
"questionnaire_instrument",
|
|
3761
|
+
"sleep_session",
|
|
3762
|
+
"workout_session"
|
|
2868
3763
|
],
|
|
2869
3764
|
batchRoutes: {
|
|
2870
3765
|
search: "/api/v1/entities/search",
|
|
@@ -2873,6 +3768,19 @@ function buildAgentOnboardingPayload(request) {
|
|
|
2873
3768
|
delete: "/api/v1/entities/delete",
|
|
2874
3769
|
restore: "/api/v1/entities/restore"
|
|
2875
3770
|
},
|
|
3771
|
+
specializedCrudEntities: {
|
|
3772
|
+
wiki_page: {
|
|
3773
|
+
create: "/api/v1/wiki/pages",
|
|
3774
|
+
update: "/api/v1/wiki/pages/:id",
|
|
3775
|
+
read: "/api/v1/wiki/pages/:id"
|
|
3776
|
+
},
|
|
3777
|
+
calendar_connection: {
|
|
3778
|
+
list: "/api/v1/calendar/connections",
|
|
3779
|
+
create: "/api/v1/calendar/connections",
|
|
3780
|
+
update: "/api/v1/calendar/connections/:id",
|
|
3781
|
+
delete: "/api/v1/calendar/connections/:id"
|
|
3782
|
+
}
|
|
3783
|
+
},
|
|
2876
3784
|
actionEntities: {
|
|
2877
3785
|
task_run: {
|
|
2878
3786
|
readModel: "/api/v1/operator/context",
|
|
@@ -2915,15 +3823,15 @@ function buildAgentOnboardingPayload(request) {
|
|
|
2915
3823
|
selfObservation: {
|
|
2916
3824
|
read: "/api/v1/psyche/self-observation/calendar",
|
|
2917
3825
|
writeModel: "Create or update an observed note with frontmatter.observedAt. Manual reflections usually carry the Self-observation tag, while movement sync can also publish rolling observed notes tagged movement."
|
|
2918
|
-
},
|
|
2919
|
-
sleep_session: {
|
|
2920
|
-
read: "/api/v1/health/sleep",
|
|
2921
|
-
update: "/api/v1/health/sleep/:id"
|
|
2922
|
-
},
|
|
2923
|
-
workout_session: {
|
|
2924
|
-
read: "/api/v1/health/fitness",
|
|
2925
|
-
update: "/api/v1/health/workouts/:id"
|
|
2926
3826
|
}
|
|
3827
|
+
},
|
|
3828
|
+
readModelOnlySurfaces: {
|
|
3829
|
+
sleepOverview: "/api/v1/health/sleep",
|
|
3830
|
+
sportsOverview: "/api/v1/health/fitness",
|
|
3831
|
+
selfObservation: "/api/v1/psyche/self-observation/calendar",
|
|
3832
|
+
calendarOverview: "/api/v1/calendar/overview",
|
|
3833
|
+
operatorOverview: "/api/v1/operator/overview",
|
|
3834
|
+
operatorContext: "/api/v1/operator/context"
|
|
2927
3835
|
}
|
|
2928
3836
|
},
|
|
2929
3837
|
multiUserModel: {
|
|
@@ -3072,11 +3980,11 @@ function buildAgentOnboardingPayload(request) {
|
|
|
3072
3980
|
saveSuggestionPlacement: "end_of_message",
|
|
3073
3981
|
saveSuggestionTone: "gentle_optional",
|
|
3074
3982
|
maxQuestionsPerTurn: 1,
|
|
3075
|
-
psycheExplorationRule: "When a Psyche entity needs understanding first, begin with one exploratory question before any working formulation, replacement belief, suggested title, or save pitch. Keep the opening reflection to one or two short sentences, stay in plain prose instead of bullets or numbered lists, keep that first reply short, do not mention Forge search or save structure yet, avoid colons or list-shaped phrasing, prefer what/when/how over why until the experience is grounded,
|
|
3076
|
-
psycheOpeningQuestionRule: "Prefer a concrete opening question tied to the entity: ask when the value mattered, what happened the last time the pattern appeared, what cue or body signal came first before the behavior, what the belief starts saying about self or outcome, what feels most at risk inside the mode, what the part is trying to get the user to do or stop doing, or where the shift began in the incident. Reflect briefly before the question
|
|
3983
|
+
psycheExplorationRule: "When a Psyche entity needs understanding first, begin with one exploratory question before any working formulation, replacement belief, suggested title, or save pitch. Keep the opening reflection to one or two short sentences, stay in plain prose instead of bullets or numbered lists, keep that first reply short, do not mention Forge search or save structure yet, avoid colons or list-shaped phrasing, prefer what/when/how over why until the experience is grounded, wait for the user's answer before offering a fuller formulation, ask permission before moving from charged exploration into naming or challenge when needed, do not widen into adjacent entities until the current one has a working sentence the user recognizes, and once the lived experience is coherent stop deepening and help the user name it cleanly. If the user accepts the wording, move toward the save instead of reopening deeper exploration.",
|
|
3984
|
+
psycheOpeningQuestionRule: "Prefer a concrete opening question tied to the entity: ask when the value mattered, what happened the last time the pattern appeared, what cue or body signal came first before the behavior, what the belief starts saying about self or outcome, what feels most at risk inside the mode, what the part is trying to get the user to do or stop doing, or where the shift began in the incident. Reflect briefly before the question, choose one follow-up lane at a time, say what is becoming clearer before the next deeper question, and if several Psyche entities are visible hold the adjacent ones lightly until the main container is clear.",
|
|
3077
3985
|
duplicateCheckRoute: "/api/v1/entities/search",
|
|
3078
3986
|
uiSuggestionRule: "offer_visual_ui_when_review_or_editing_would_be_easier",
|
|
3079
|
-
browserFallbackRule: "Do not open the Forge UI or a browser just to create or update normal entities when the batch entity tools can do the job.",
|
|
3987
|
+
browserFallbackRule: "Do not open the Forge UI or a browser just to create or update normal entities when the batch entity tools can do the job. Batch CRUD is the default for simple entities; avoid spamming the agent with a large one-route-per-entity mental model.",
|
|
3080
3988
|
writeConsentRule: "If an entity is only implied, keep helping in the main conversation and offer Forge lightly at the end. Only write after explicit save intent or after the user accepts the Forge save offer."
|
|
3081
3989
|
},
|
|
3082
3990
|
mutationGuidance: {
|
|
@@ -3089,12 +3997,12 @@ function buildAgentOnboardingPayload(request) {
|
|
|
3089
3997
|
},
|
|
3090
3998
|
deleteDefault: "soft",
|
|
3091
3999
|
hardDeleteRequiresExplicitMode: true,
|
|
3092
|
-
restoreSummary: "Restore soft-deleted entities through the restore route or the settings bin.
|
|
3093
|
-
entityDeleteSummary: "Entity DELETE routes default to soft delete. Pass mode=hard only when permanent removal is intended.
|
|
3094
|
-
batchingRule: "forge_create_entities, forge_update_entities, forge_delete_entities, and forge_restore_entities all accept operations as arrays. Batch multiple related mutations together
|
|
4000
|
+
restoreSummary: "Restore soft-deleted entities through the restore route or the settings bin. Immediate-delete entities such as calendar_event, work_block_template, task_timebox, sleep_session, and workout_session do not enter the bin.",
|
|
4001
|
+
entityDeleteSummary: "Entity DELETE routes default to soft delete. Pass mode=hard only when permanent removal is intended. Immediate-delete entities skip the bin, and calendar-event deletes still remove remote projections downstream.",
|
|
4002
|
+
batchingRule: "forge_create_entities, forge_update_entities, forge_delete_entities, and forge_restore_entities all accept operations as arrays. Batch CRUD is the default for simple entities, so batch multiple related mutations together instead of reaching for a long list of entity-specific routes.",
|
|
3095
4003
|
searchRule: "forge_search_entities accepts searches as an array. Search before create or update when duplicate risk exists.",
|
|
3096
|
-
createRule: "Each create operation must include entityType and full data. entityType alone is not enough. This includes calendar_event, work_block_template, and
|
|
3097
|
-
updateRule: "Each update operation must include entityType, id, and patch. For projects, lifecycle changes are status patches: active to restart, paused to suspend, completed to finish. Keep task and project scheduling rules on those same patch payloads. Calendar-event updates still run downstream provider projection sync.",
|
|
4004
|
+
createRule: "Each create operation must include entityType and full data. entityType alone is not enough. This includes calendar_event, work_block_template, task_timebox, sleep_session, workout_session, preference CRUD entities, and questionnaire_instrument alongside the usual planning and Psyche entities.",
|
|
4005
|
+
updateRule: "Each update operation must include entityType, id, and patch. For projects, lifecycle changes are status patches: active to restart, paused to suspend, completed to finish. Keep task and project scheduling rules on those same patch payloads. Calendar-event updates still run downstream provider projection sync, and manual health-session field edits belong on the batch route by default rather than on the reflective review helpers.",
|
|
3098
4006
|
createExample: '{"operations":[{"entityType":"goal","data":{"title":"Create meaningfully"},"clientRef":"goal-create-1"},{"entityType":"goal","data":{"title":"Build a beautiful family"},"clientRef":"goal-create-2"}]}',
|
|
3099
4007
|
updateExample: '{"operations":[{"entityType":"project","id":"project_123","patch":{"status":"paused","schedulingRules":{"blockWorkBlockKinds":["main_activity"],"allowWorkBlockKinds":["secondary_activity"]}},"clientRef":"project-suspend-1"},{"entityType":"task","id":"task_456","patch":{"plannedDurationSeconds":5400,"schedulingRules":{"allowEventKeywords":["creative"],"blockEventKeywords":["clinic"]}},"clientRef":"task-scheduling-1"}]}'
|
|
3100
4008
|
}
|
|
@@ -3309,6 +4217,7 @@ function buildV1Context(userIds) {
|
|
|
3309
4217
|
const tasks = filterOwnedEntities("task", listTasks(), userIds);
|
|
3310
4218
|
const habits = filterOwnedEntities("habit", listHabits(), userIds);
|
|
3311
4219
|
const users = listUsers();
|
|
4220
|
+
const dashboard = getDashboard({ userIds });
|
|
3312
4221
|
const selectedUsers = userIds && userIds.length > 0
|
|
3313
4222
|
? users.filter((user) => userIds.includes(user.id))
|
|
3314
4223
|
: users;
|
|
@@ -3321,7 +4230,7 @@ function buildV1Context(userIds) {
|
|
|
3321
4230
|
mode: "transitional-node"
|
|
3322
4231
|
},
|
|
3323
4232
|
metrics: buildGamificationProfile(goals, tasks, habits),
|
|
3324
|
-
dashboard
|
|
4233
|
+
dashboard,
|
|
3325
4234
|
overview: getOverviewContext(new Date(), { userIds }),
|
|
3326
4235
|
today: getTodayContext(new Date(), { userIds }),
|
|
3327
4236
|
risk: getRiskContext(new Date(), { userIds }),
|
|
@@ -3337,7 +4246,8 @@ function buildV1Context(userIds) {
|
|
|
3337
4246
|
selectedUsers
|
|
3338
4247
|
},
|
|
3339
4248
|
activeTaskRuns: listTaskRuns({ active: true, limit: 25 }),
|
|
3340
|
-
activity:
|
|
4249
|
+
activity: dashboard.recentActivity,
|
|
4250
|
+
lifeForce: buildLifeForcePayload(new Date(), userIds)
|
|
3341
4251
|
};
|
|
3342
4252
|
}
|
|
3343
4253
|
function buildXpMetricsPayload() {
|
|
@@ -3614,6 +4524,7 @@ export async function buildServer(options = {}) {
|
|
|
3614
4524
|
configureDatabaseSeeding(options.seedDemoData ?? false);
|
|
3615
4525
|
await managers.migration.initialize();
|
|
3616
4526
|
ensureSystemUsers();
|
|
4527
|
+
getSettings();
|
|
3617
4528
|
const app = Fastify({
|
|
3618
4529
|
logger: false,
|
|
3619
4530
|
rewriteUrl: (request) => rewriteMountPath(request.url ?? "/")
|
|
@@ -3654,7 +4565,8 @@ export async function buildServer(options = {}) {
|
|
|
3654
4565
|
}
|
|
3655
4566
|
try {
|
|
3656
4567
|
const interval = CronExpressionParser.parse(processor.cronExpression, {
|
|
3657
|
-
currentDate: processor.lastRunAt &&
|
|
4568
|
+
currentDate: processor.lastRunAt &&
|
|
4569
|
+
Number.isFinite(Date.parse(processor.lastRunAt))
|
|
3658
4570
|
? processor.lastRunAt
|
|
3659
4571
|
: new Date(now.getTime() - 60_000).toISOString()
|
|
3660
4572
|
});
|
|
@@ -3676,9 +4588,19 @@ export async function buildServer(options = {}) {
|
|
|
3676
4588
|
}
|
|
3677
4589
|
}, 30_000);
|
|
3678
4590
|
cronSchedulerTimer.unref?.();
|
|
4591
|
+
const dataBackupTimer = setInterval(() => {
|
|
4592
|
+
void maybeRunAutomaticBackup().catch(() => {
|
|
4593
|
+
// Automatic backup sweeps should never crash the runtime loop.
|
|
4594
|
+
});
|
|
4595
|
+
}, 5 * 60 * 1000);
|
|
4596
|
+
dataBackupTimer.unref?.();
|
|
4597
|
+
void maybeRunAutomaticBackup().catch(() => {
|
|
4598
|
+
// Ignore startup backup failures; the Data settings surface exposes recovery.
|
|
4599
|
+
});
|
|
3679
4600
|
app.addHook("onClose", async () => {
|
|
3680
4601
|
clearInterval(diagnosticRetentionTimer);
|
|
3681
4602
|
clearInterval(cronSchedulerTimer);
|
|
4603
|
+
clearInterval(dataBackupTimer);
|
|
3682
4604
|
taskRunWatchdog?.stop();
|
|
3683
4605
|
await managers.backgroundJobs.stop();
|
|
3684
4606
|
});
|
|
@@ -3706,8 +4628,7 @@ export async function buildServer(options = {}) {
|
|
|
3706
4628
|
url.startsWith("/api/v1/events/meta"));
|
|
3707
4629
|
};
|
|
3708
4630
|
app.addHook("onRequest", async (request) => {
|
|
3709
|
-
request.diagnosticStartedAt =
|
|
3710
|
-
process.hrtime.bigint();
|
|
4631
|
+
request.diagnosticStartedAt = process.hrtime.bigint();
|
|
3711
4632
|
});
|
|
3712
4633
|
app.addHook("onResponse", async (request, reply) => {
|
|
3713
4634
|
const routeUrl = request.routeOptions.url || request.url;
|
|
@@ -3984,12 +4905,59 @@ export async function buildServer(options = {}) {
|
|
|
3984
4905
|
? {
|
|
3985
4906
|
runtime: {
|
|
3986
4907
|
pid: process.pid,
|
|
3987
|
-
storageRoot:
|
|
4908
|
+
storageRoot: getEffectiveDataRoot(),
|
|
3988
4909
|
basePath: runtimeConfig.basePath
|
|
3989
4910
|
}
|
|
3990
4911
|
}
|
|
3991
4912
|
: {})
|
|
3992
4913
|
}));
|
|
4914
|
+
app.get("/api/v1/doctor", async (request) => {
|
|
4915
|
+
requireScopedAccess(request.headers, ["read", "write"], { route: "/api/v1/doctor" });
|
|
4916
|
+
const settings = getSettings();
|
|
4917
|
+
const settingsFile = getSettingsFileStatus();
|
|
4918
|
+
const runtime = {
|
|
4919
|
+
pid: process.pid,
|
|
4920
|
+
storageRoot: getEffectiveDataRoot(),
|
|
4921
|
+
dataDir: resolveDataDir(),
|
|
4922
|
+
databasePath: resolveDatabasePathForDataRoot(),
|
|
4923
|
+
basePath: runtimeConfig.basePath,
|
|
4924
|
+
devWebOrigin: process.env.FORGE_DEV_WEB_ORIGIN?.trim() || null
|
|
4925
|
+
};
|
|
4926
|
+
const health = buildHealthPayload(taskRunWatchdog, {
|
|
4927
|
+
apiVersion: "v1",
|
|
4928
|
+
backend: "forge-node-runtime",
|
|
4929
|
+
runtime
|
|
4930
|
+
});
|
|
4931
|
+
const warnings = [];
|
|
4932
|
+
if (!settingsFile.valid) {
|
|
4933
|
+
warnings.push(`forge.json is invalid at ${settingsFile.path}. Forge ignored file precedence until the JSON is repaired or rewritten.`);
|
|
4934
|
+
}
|
|
4935
|
+
if (settingsFile.syncState === "applied_file_overrides") {
|
|
4936
|
+
warnings.push("forge.json overrode one or more persisted database settings on this run.");
|
|
4937
|
+
}
|
|
4938
|
+
if (health.ok === false) {
|
|
4939
|
+
warnings.push("The task-run watchdog reported degraded health.");
|
|
4940
|
+
}
|
|
4941
|
+
return {
|
|
4942
|
+
doctor: {
|
|
4943
|
+
ok: health.ok && settingsFile.valid,
|
|
4944
|
+
now: new Date().toISOString(),
|
|
4945
|
+
runtime,
|
|
4946
|
+
health,
|
|
4947
|
+
settingsFile,
|
|
4948
|
+
settingsSummary: {
|
|
4949
|
+
themePreference: settings.themePreference,
|
|
4950
|
+
localePreference: settings.localePreference,
|
|
4951
|
+
operatorName: settings.profile.operatorName,
|
|
4952
|
+
maxActiveTasks: settings.execution.maxActiveTasks,
|
|
4953
|
+
timeAccountingMode: settings.execution.timeAccountingMode,
|
|
4954
|
+
psycheAuthRequired: settings.security.psycheAuthRequired,
|
|
4955
|
+
webAppUrl: `http://127.0.0.1:${runtimeConfig.port}${runtimeConfig.basePath}`
|
|
4956
|
+
},
|
|
4957
|
+
warnings
|
|
4958
|
+
}
|
|
4959
|
+
};
|
|
4960
|
+
});
|
|
3993
4961
|
app.get("/api/v1/auth/operator-session", async (request, reply) => ({
|
|
3994
4962
|
session: managers.session.ensureLocalOperatorSession(request.headers, reply)
|
|
3995
4963
|
}));
|
|
@@ -3998,15 +4966,116 @@ export async function buildServer(options = {}) {
|
|
|
3998
4966
|
}));
|
|
3999
4967
|
app.get("/api/v1/openapi.json", async () => buildOpenApiDocument());
|
|
4000
4968
|
app.get("/api/v1/context", async (request) => buildV1Context(resolveScopedUserIds(request.query)));
|
|
4969
|
+
app.get("/api/v1/life-force", async (request) => ({
|
|
4970
|
+
lifeForce: buildLifeForcePayload(new Date(), resolveScopedUserIds(request.query)),
|
|
4971
|
+
templates: listLifeForceTemplates(resolveLifeForceUser(resolveScopedUserIds(request.query)).id)
|
|
4972
|
+
}));
|
|
4973
|
+
app.patch("/api/v1/life-force/profile", async (request) => {
|
|
4974
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/life-force/profile" });
|
|
4975
|
+
const userId = resolveLifeForceUser(resolveScopedUserIds(request.query)).id;
|
|
4976
|
+
return {
|
|
4977
|
+
lifeForce: updateLifeForceProfile(userId, lifeForceProfilePatchSchema.parse(request.body ?? {})),
|
|
4978
|
+
actor: auth.session?.actorLabel ?? auth.actor ?? "Forge"
|
|
4979
|
+
};
|
|
4980
|
+
});
|
|
4981
|
+
app.put("/api/v1/life-force/templates/:weekday", async (request) => {
|
|
4982
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/life-force/templates/:weekday" });
|
|
4983
|
+
const weekday = Number(request.params.weekday);
|
|
4984
|
+
return {
|
|
4985
|
+
weekday,
|
|
4986
|
+
points: updateLifeForceTemplate(resolveLifeForceUser(resolveScopedUserIds(request.query)).id, weekday, lifeForceTemplateUpdateSchema.parse(request.body ?? {})),
|
|
4987
|
+
actor: auth.session?.actorLabel ?? auth.actor ?? "Forge"
|
|
4988
|
+
};
|
|
4989
|
+
});
|
|
4990
|
+
app.post("/api/v1/life-force/fatigue-signals", async (request) => {
|
|
4991
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/life-force/fatigue-signals" });
|
|
4992
|
+
return {
|
|
4993
|
+
lifeForce: createFatigueSignal(resolveLifeForceUser(resolveScopedUserIds(request.query)).id, fatigueSignalCreateSchema.parse(request.body ?? {})),
|
|
4994
|
+
actor: auth.session?.actorLabel ?? auth.actor ?? "Forge"
|
|
4995
|
+
};
|
|
4996
|
+
});
|
|
4997
|
+
app.get("/api/v1/knowledge-graph", async (request) => {
|
|
4998
|
+
const query = request.query;
|
|
4999
|
+
const readString = (value) => typeof value === "string" ? value.trim() : "";
|
|
5000
|
+
const readList = (key) => {
|
|
5001
|
+
const value = query[key];
|
|
5002
|
+
const values = Array.isArray(value) ? value : [value];
|
|
5003
|
+
return values
|
|
5004
|
+
.flatMap((entry) => (typeof entry === "string" ? entry.split(",") : []))
|
|
5005
|
+
.map((entry) => entry.trim())
|
|
5006
|
+
.filter(Boolean);
|
|
5007
|
+
};
|
|
5008
|
+
const limitRaw = readString(query.limit);
|
|
5009
|
+
const limit = limitRaw.length > 0 && Number.isFinite(Number(limitRaw))
|
|
5010
|
+
? Math.max(1, Math.min(2000, Math.round(Number(limitRaw))))
|
|
5011
|
+
: null;
|
|
5012
|
+
return {
|
|
5013
|
+
graph: buildKnowledgeGraph(resolveScopedUserIds(query), {
|
|
5014
|
+
q: readString(query.q) || null,
|
|
5015
|
+
entityKinds: readList("entityKind"),
|
|
5016
|
+
relationKinds: readList("relationKind"),
|
|
5017
|
+
tags: readList("tag"),
|
|
5018
|
+
owners: readList("owner"),
|
|
5019
|
+
updatedFrom: readString(query.updatedFrom) || null,
|
|
5020
|
+
updatedTo: readString(query.updatedTo) || null,
|
|
5021
|
+
limit,
|
|
5022
|
+
focusNodeId: readString(query.focusNodeId) || null
|
|
5023
|
+
})
|
|
5024
|
+
};
|
|
5025
|
+
});
|
|
5026
|
+
app.get("/api/v1/knowledge-graph/focus", async (request, reply) => {
|
|
5027
|
+
const query = request.query;
|
|
5028
|
+
const entityType = typeof query.entityType === "string" ? query.entityType.trim() : "";
|
|
5029
|
+
const entityId = typeof query.entityId === "string" ? query.entityId.trim() : "";
|
|
5030
|
+
if (!entityType || !entityId) {
|
|
5031
|
+
reply.code(400);
|
|
5032
|
+
return {
|
|
5033
|
+
error: "entityType and entityId are required."
|
|
5034
|
+
};
|
|
5035
|
+
}
|
|
5036
|
+
return {
|
|
5037
|
+
focus: buildKnowledgeGraphFocus(entityType, entityId, resolveScopedUserIds(query))
|
|
5038
|
+
};
|
|
5039
|
+
});
|
|
4001
5040
|
app.get("/api/v1/health/overview", async (request) => ({
|
|
4002
5041
|
overview: getCompanionOverview(resolveScopedUserIds(request.query))
|
|
4003
5042
|
}));
|
|
4004
5043
|
app.get("/api/v1/health/sleep", async (request) => ({
|
|
4005
5044
|
sleep: getSleepViewData(resolveScopedUserIds(request.query))
|
|
4006
5045
|
}));
|
|
5046
|
+
app.post("/api/v1/health/sleep", async (request, reply) => {
|
|
5047
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/health/sleep" });
|
|
5048
|
+
const sleep = createSleepSession(createSleepSessionSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
5049
|
+
reply.code(201);
|
|
5050
|
+
return { sleep };
|
|
5051
|
+
});
|
|
5052
|
+
app.get("/api/v1/health/sleep/:id", async (request, reply) => {
|
|
5053
|
+
const { id } = request.params;
|
|
5054
|
+
const sleep = getSleepSessionById(id);
|
|
5055
|
+
if (!sleep) {
|
|
5056
|
+
reply.code(404);
|
|
5057
|
+
return { error: "Sleep session not found" };
|
|
5058
|
+
}
|
|
5059
|
+
return { sleep };
|
|
5060
|
+
});
|
|
4007
5061
|
app.get("/api/v1/health/fitness", async (request) => ({
|
|
4008
5062
|
fitness: getFitnessViewData(resolveScopedUserIds(request.query))
|
|
4009
5063
|
}));
|
|
5064
|
+
app.post("/api/v1/health/workouts", async (request, reply) => {
|
|
5065
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/health/workouts" });
|
|
5066
|
+
const workout = createWorkoutSession(createWorkoutSessionSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
5067
|
+
reply.code(201);
|
|
5068
|
+
return { workout };
|
|
5069
|
+
});
|
|
5070
|
+
app.get("/api/v1/health/workouts/:id", async (request, reply) => {
|
|
5071
|
+
const { id } = request.params;
|
|
5072
|
+
const workout = getWorkoutSessionById(id);
|
|
5073
|
+
if (!workout) {
|
|
5074
|
+
reply.code(404);
|
|
5075
|
+
return { error: "Workout session not found" };
|
|
5076
|
+
}
|
|
5077
|
+
return { workout };
|
|
5078
|
+
});
|
|
4010
5079
|
app.get("/api/v1/movement/day", async (request) => {
|
|
4011
5080
|
const query = request.query;
|
|
4012
5081
|
return {
|
|
@@ -4028,6 +5097,40 @@ export async function buildServer(options = {}) {
|
|
|
4028
5097
|
app.get("/api/v1/movement/all-time", async (request) => ({
|
|
4029
5098
|
movement: getMovementAllTimeSummary(resolveScopedUserIds(request.query))
|
|
4030
5099
|
}));
|
|
5100
|
+
app.get("/api/v1/screen-time/day", async (request) => {
|
|
5101
|
+
const query = request.query;
|
|
5102
|
+
return {
|
|
5103
|
+
screenTime: getScreenTimeDayDetail({
|
|
5104
|
+
date: typeof query.date === "string" ? query.date : undefined,
|
|
5105
|
+
userIds: resolveScopedUserIds(query)
|
|
5106
|
+
})
|
|
5107
|
+
};
|
|
5108
|
+
});
|
|
5109
|
+
app.get("/api/v1/screen-time/month", async (request) => {
|
|
5110
|
+
const query = request.query;
|
|
5111
|
+
return {
|
|
5112
|
+
screenTime: getScreenTimeMonthSummary({
|
|
5113
|
+
month: typeof query.month === "string" ? query.month : undefined,
|
|
5114
|
+
userIds: resolveScopedUserIds(query)
|
|
5115
|
+
})
|
|
5116
|
+
};
|
|
5117
|
+
});
|
|
5118
|
+
app.get("/api/v1/screen-time/all-time", async (request) => ({
|
|
5119
|
+
screenTime: getScreenTimeAllTimeSummary(resolveScopedUserIds(request.query))
|
|
5120
|
+
}));
|
|
5121
|
+
app.get("/api/v1/screen-time/settings", async (request) => ({
|
|
5122
|
+
settings: getScreenTimeSettings(resolveScopedUserIds(request.query))
|
|
5123
|
+
}));
|
|
5124
|
+
app.patch("/api/v1/screen-time/settings", async (request) => {
|
|
5125
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
5126
|
+
route: "/api/v1/screen-time/settings"
|
|
5127
|
+
});
|
|
5128
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5129
|
+
getDefaultUser().id;
|
|
5130
|
+
return {
|
|
5131
|
+
settings: updateScreenTimeSettings(userId, screenTimeSettingsPatchSchema.parse(request.body ?? {}))
|
|
5132
|
+
};
|
|
5133
|
+
});
|
|
4031
5134
|
app.get("/api/v1/movement/timeline", async (request) => {
|
|
4032
5135
|
const parsed = movementTimelineQuerySchema.parse(request.query ?? {});
|
|
4033
5136
|
return {
|
|
@@ -4035,7 +5138,8 @@ export async function buildServer(options = {}) {
|
|
|
4035
5138
|
...parsed,
|
|
4036
5139
|
userIds: parsed.userIds.length > 0
|
|
4037
5140
|
? parsed.userIds
|
|
4038
|
-
: (resolveScopedUserIds(request.query) ??
|
|
5141
|
+
: (resolveScopedUserIds(request.query) ??
|
|
5142
|
+
[])
|
|
4039
5143
|
})
|
|
4040
5144
|
};
|
|
4041
5145
|
});
|
|
@@ -4066,15 +5170,80 @@ export async function buildServer(options = {}) {
|
|
|
4066
5170
|
}, toActivityContext(auth))
|
|
4067
5171
|
};
|
|
4068
5172
|
});
|
|
4069
|
-
app.patch("/api/v1/movement/places/:id", async (request, reply) => {
|
|
4070
|
-
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/places/:id" });
|
|
5173
|
+
app.patch("/api/v1/movement/places/:id", async (request, reply) => {
|
|
5174
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/places/:id" });
|
|
5175
|
+
const { id } = request.params;
|
|
5176
|
+
const place = updateMovementPlace(id, movementPlacePatchSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
5177
|
+
if (!place) {
|
|
5178
|
+
reply.code(404);
|
|
5179
|
+
return { error: "Movement place not found" };
|
|
5180
|
+
}
|
|
5181
|
+
return { place };
|
|
5182
|
+
});
|
|
5183
|
+
app.post("/api/v1/movement/user-boxes", async (request, reply) => {
|
|
5184
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/user-boxes" });
|
|
5185
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5186
|
+
getDefaultUser().id;
|
|
5187
|
+
reply.code(201);
|
|
5188
|
+
const created = createMovementUserBox({
|
|
5189
|
+
...movementUserBoxCreateSchema.parse(request.body ?? {}),
|
|
5190
|
+
userId
|
|
5191
|
+
}, toActivityContext(auth));
|
|
5192
|
+
return {
|
|
5193
|
+
box: resolveMovementTimelineSegmentForBox(userId, created.id) ?? created
|
|
5194
|
+
};
|
|
5195
|
+
});
|
|
5196
|
+
app.post("/api/v1/movement/user-boxes/preflight", async (request) => {
|
|
5197
|
+
requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/user-boxes/preflight" });
|
|
5198
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5199
|
+
getDefaultUser().id;
|
|
5200
|
+
return {
|
|
5201
|
+
preflight: analyzeMovementUserBoxPreflight({
|
|
5202
|
+
...movementUserBoxPreflightSchema.parse(request.body ?? {}),
|
|
5203
|
+
userId
|
|
5204
|
+
})
|
|
5205
|
+
};
|
|
5206
|
+
});
|
|
5207
|
+
app.patch("/api/v1/movement/user-boxes/:id", async (request, reply) => {
|
|
5208
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/user-boxes/:id" });
|
|
5209
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5210
|
+
getDefaultUser().id;
|
|
5211
|
+
const { id } = request.params;
|
|
5212
|
+
const box = updateMovementUserBox(id, movementUserBoxPatchSchema.parse(request.body ?? {}), toActivityContext(auth), { userId });
|
|
5213
|
+
if (!box) {
|
|
5214
|
+
reply.code(404);
|
|
5215
|
+
return { error: "Movement user box not found" };
|
|
5216
|
+
}
|
|
5217
|
+
return {
|
|
5218
|
+
box: resolveMovementTimelineSegmentForBox(userId, box.id) ?? box
|
|
5219
|
+
};
|
|
5220
|
+
});
|
|
5221
|
+
app.delete("/api/v1/movement/user-boxes/:id", async (request, reply) => {
|
|
5222
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/user-boxes/:id" });
|
|
5223
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5224
|
+
getDefaultUser().id;
|
|
5225
|
+
const { id } = request.params;
|
|
5226
|
+
const result = deleteMovementUserBox(id, toActivityContext(auth), { userId });
|
|
5227
|
+
if (!result) {
|
|
5228
|
+
reply.code(404);
|
|
5229
|
+
return { error: "Movement user box not found" };
|
|
5230
|
+
}
|
|
5231
|
+
return result;
|
|
5232
|
+
});
|
|
5233
|
+
app.post("/api/v1/movement/automatic-boxes/:id/invalidate", async (request, reply) => {
|
|
5234
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/automatic-boxes/:id/invalidate" });
|
|
5235
|
+
const userId = resolveScopedUserIds(request.query)?.[0] ??
|
|
5236
|
+
getDefaultUser().id;
|
|
4071
5237
|
const { id } = request.params;
|
|
4072
|
-
const
|
|
4073
|
-
if (!
|
|
5238
|
+
const result = invalidateAutomaticMovementBox(id, movementAutomaticBoxInvalidateSchema.parse(request.body ?? {}), toActivityContext(auth), { userId });
|
|
5239
|
+
if (!result) {
|
|
4074
5240
|
reply.code(404);
|
|
4075
|
-
return { error: "
|
|
5241
|
+
return { error: "Automatic movement box not found" };
|
|
4076
5242
|
}
|
|
4077
|
-
|
|
5243
|
+
reply.code(201);
|
|
5244
|
+
return {
|
|
5245
|
+
box: resolveMovementTimelineSegmentForBox(userId, result.box.id) ?? result.box
|
|
5246
|
+
};
|
|
4078
5247
|
});
|
|
4079
5248
|
app.patch("/api/v1/movement/stays/:id", async (request, reply) => {
|
|
4080
5249
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/movement/stays/:id" });
|
|
@@ -4173,6 +5342,23 @@ export async function buildServer(options = {}) {
|
|
|
4173
5342
|
}
|
|
4174
5343
|
return { session };
|
|
4175
5344
|
});
|
|
5345
|
+
app.patch("/api/v1/health/pairing-sessions/:id/sources/:source", async (request, reply) => {
|
|
5346
|
+
requireOperatorSession(request.headers, {
|
|
5347
|
+
route: "/api/v1/health/pairing-sessions/:id/sources/:source"
|
|
5348
|
+
});
|
|
5349
|
+
const params = z
|
|
5350
|
+
.object({
|
|
5351
|
+
id: z.string().trim().min(1),
|
|
5352
|
+
source: companionSourceKeySchema
|
|
5353
|
+
})
|
|
5354
|
+
.parse(request.params ?? {});
|
|
5355
|
+
const session = patchCompanionPairingSourceState(params.id, params.source, patchCompanionPairingSourceStateSchema.parse(request.body ?? {}));
|
|
5356
|
+
if (!session) {
|
|
5357
|
+
reply.code(404);
|
|
5358
|
+
return { error: "Companion pairing session not found" };
|
|
5359
|
+
}
|
|
5360
|
+
return { session };
|
|
5361
|
+
});
|
|
4176
5362
|
app.post("/api/v1/health/pairing-sessions/revoke-all", async (request) => {
|
|
4177
5363
|
const auth = requireOperatorSession(request.headers, {
|
|
4178
5364
|
route: "/api/v1/health/pairing-sessions/revoke-all"
|
|
@@ -4189,9 +5375,13 @@ export async function buildServer(options = {}) {
|
|
|
4189
5375
|
const parsed = movementMobileBootstrapSchema.parse(request.body ?? {});
|
|
4190
5376
|
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
4191
5377
|
return {
|
|
5378
|
+
pairingSession: getCompanionPairingSessionById(pairing.id),
|
|
4192
5379
|
movement: getMovementMobileBootstrap(pairing)
|
|
4193
5380
|
};
|
|
4194
5381
|
});
|
|
5382
|
+
app.post("/api/v1/mobile/source-state", async (request) => ({
|
|
5383
|
+
pairingSession: updateMobileCompanionSourceState(updateMobileCompanionSourceStateSchema.parse(request.body ?? {}))
|
|
5384
|
+
}));
|
|
4195
5385
|
app.post("/api/v1/mobile/movement/places", async (request, reply) => {
|
|
4196
5386
|
const parsed = movementMobilePlaceMutationSchema.parse(request.body ?? {});
|
|
4197
5387
|
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
@@ -4218,33 +5408,90 @@ export async function buildServer(options = {}) {
|
|
|
4218
5408
|
})
|
|
4219
5409
|
};
|
|
4220
5410
|
});
|
|
4221
|
-
app.
|
|
4222
|
-
const parsed =
|
|
5411
|
+
app.post("/api/v1/mobile/movement/user-boxes", async (request, reply) => {
|
|
5412
|
+
const parsed = movementMobileUserBoxCreateSchema.parse(request.body ?? {});
|
|
5413
|
+
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
5414
|
+
reply.code(201);
|
|
5415
|
+
const created = createMovementUserBox({
|
|
5416
|
+
...parsed.box,
|
|
5417
|
+
userId: pairing.user_id
|
|
5418
|
+
}, {
|
|
5419
|
+
actor: "Forge Companion",
|
|
5420
|
+
source: "system"
|
|
5421
|
+
});
|
|
5422
|
+
return {
|
|
5423
|
+
box: resolveMovementTimelineSegmentForBox(pairing.user_id, created.id) ?? created
|
|
5424
|
+
};
|
|
5425
|
+
});
|
|
5426
|
+
app.post("/api/v1/mobile/movement/user-boxes/preflight", async (request) => {
|
|
5427
|
+
const parsed = movementMobileUserBoxPreflightSchema.parse(request.body ?? {});
|
|
5428
|
+
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
5429
|
+
return {
|
|
5430
|
+
preflight: analyzeMovementUserBoxPreflight({
|
|
5431
|
+
...parsed.draft,
|
|
5432
|
+
userId: pairing.user_id
|
|
5433
|
+
})
|
|
5434
|
+
};
|
|
5435
|
+
});
|
|
5436
|
+
app.patch("/api/v1/mobile/movement/user-boxes/:id", async (request, reply) => {
|
|
5437
|
+
const parsed = movementMobileUserBoxPatchSchema.parse(request.body ?? {});
|
|
4223
5438
|
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
4224
5439
|
const { id } = request.params;
|
|
4225
|
-
const
|
|
5440
|
+
const box = updateMovementUserBox(id, parsed.patch, {
|
|
4226
5441
|
actor: "Forge Companion",
|
|
4227
5442
|
source: "system"
|
|
4228
5443
|
}, { userId: pairing.user_id });
|
|
4229
|
-
if (!
|
|
5444
|
+
if (!box) {
|
|
4230
5445
|
reply.code(404);
|
|
4231
|
-
return { error: "Movement
|
|
5446
|
+
return { error: "Movement user box not found" };
|
|
4232
5447
|
}
|
|
4233
|
-
return {
|
|
5448
|
+
return {
|
|
5449
|
+
box: resolveMovementTimelineSegmentForBox(pairing.user_id, box.id) ?? box
|
|
5450
|
+
};
|
|
4234
5451
|
});
|
|
4235
|
-
app.
|
|
4236
|
-
const parsed =
|
|
5452
|
+
app.delete("/api/v1/mobile/movement/user-boxes/:id", async (request, reply) => {
|
|
5453
|
+
const parsed = movementMobileBootstrapSchema.parse(request.body ?? {});
|
|
4237
5454
|
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
4238
5455
|
const { id } = request.params;
|
|
4239
|
-
const
|
|
5456
|
+
const result = deleteMovementUserBox(id, {
|
|
4240
5457
|
actor: "Forge Companion",
|
|
4241
5458
|
source: "system"
|
|
4242
5459
|
}, { userId: pairing.user_id });
|
|
4243
|
-
if (!
|
|
5460
|
+
if (!result) {
|
|
4244
5461
|
reply.code(404);
|
|
4245
|
-
return { error: "Movement
|
|
5462
|
+
return { error: "Movement user box not found" };
|
|
4246
5463
|
}
|
|
4247
|
-
return
|
|
5464
|
+
return result;
|
|
5465
|
+
});
|
|
5466
|
+
app.post("/api/v1/mobile/movement/automatic-boxes/:id/invalidate", async (request, reply) => {
|
|
5467
|
+
const parsed = movementMobileAutomaticBoxInvalidateSchema.parse(request.body ?? {});
|
|
5468
|
+
const pairing = requireValidPairing(parsed.sessionId, parsed.pairingToken);
|
|
5469
|
+
const { id } = request.params;
|
|
5470
|
+
const result = invalidateAutomaticMovementBox(id, parsed.invalidate, {
|
|
5471
|
+
actor: "Forge Companion",
|
|
5472
|
+
source: "system"
|
|
5473
|
+
}, { userId: pairing.user_id });
|
|
5474
|
+
if (!result) {
|
|
5475
|
+
reply.code(404);
|
|
5476
|
+
return { error: "Automatic movement box not found" };
|
|
5477
|
+
}
|
|
5478
|
+
reply.code(201);
|
|
5479
|
+
return {
|
|
5480
|
+
box: resolveMovementTimelineSegmentForBox(pairing.user_id, result.box.id) ??
|
|
5481
|
+
result.box
|
|
5482
|
+
};
|
|
5483
|
+
});
|
|
5484
|
+
app.patch("/api/v1/mobile/movement/stays/:id", async (request, reply) => {
|
|
5485
|
+
reply.code(409);
|
|
5486
|
+
return {
|
|
5487
|
+
error: "Recorded stays are immutable in product UI. Create or edit a user-defined movement box instead."
|
|
5488
|
+
};
|
|
5489
|
+
});
|
|
5490
|
+
app.patch("/api/v1/mobile/movement/trips/:id", async (request, reply) => {
|
|
5491
|
+
reply.code(409);
|
|
5492
|
+
return {
|
|
5493
|
+
error: "Recorded moves are immutable in product UI. Create or edit a user-defined movement box instead."
|
|
5494
|
+
};
|
|
4248
5495
|
});
|
|
4249
5496
|
app.post("/api/v1/mobile/watch/bootstrap", async (request) => {
|
|
4250
5497
|
const parsed = mobileWatchBootstrapSchema.parse(request.body ?? {});
|
|
@@ -4298,6 +5545,16 @@ export async function buildServer(options = {}) {
|
|
|
4298
5545
|
}
|
|
4299
5546
|
return { workout };
|
|
4300
5547
|
});
|
|
5548
|
+
app.delete("/api/v1/health/workouts/:id", async (request, reply) => {
|
|
5549
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/health/workouts/:id" });
|
|
5550
|
+
const { id } = request.params;
|
|
5551
|
+
const workout = deleteWorkoutSession(id, toActivityContext(auth));
|
|
5552
|
+
if (!workout) {
|
|
5553
|
+
reply.code(404);
|
|
5554
|
+
return { error: "Workout session not found" };
|
|
5555
|
+
}
|
|
5556
|
+
return { workout };
|
|
5557
|
+
});
|
|
4301
5558
|
app.patch("/api/v1/health/sleep/:id", async (request, reply) => {
|
|
4302
5559
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/health/sleep/:id" });
|
|
4303
5560
|
const { id } = request.params;
|
|
@@ -4308,6 +5565,16 @@ export async function buildServer(options = {}) {
|
|
|
4308
5565
|
}
|
|
4309
5566
|
return { sleep };
|
|
4310
5567
|
});
|
|
5568
|
+
app.delete("/api/v1/health/sleep/:id", async (request, reply) => {
|
|
5569
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/health/sleep/:id" });
|
|
5570
|
+
const { id } = request.params;
|
|
5571
|
+
const sleep = deleteSleepSession(id, toActivityContext(auth));
|
|
5572
|
+
if (!sleep) {
|
|
5573
|
+
reply.code(404);
|
|
5574
|
+
return { error: "Sleep session not found" };
|
|
5575
|
+
}
|
|
5576
|
+
return { sleep };
|
|
5577
|
+
});
|
|
4311
5578
|
app.get("/api/v1/operator/context", async (request) => {
|
|
4312
5579
|
requireOperatorSession(request.headers, {
|
|
4313
5580
|
route: "/api/v1/operator/context"
|
|
@@ -4355,6 +5622,26 @@ export async function buildServer(options = {}) {
|
|
|
4355
5622
|
const userIds = resolveScopedUserIds(request.query);
|
|
4356
5623
|
return getQuestionnaireInstrumentDetail(id, { userIds });
|
|
4357
5624
|
});
|
|
5625
|
+
app.patch("/api/v1/psyche/questionnaires/:id", async (request, reply) => {
|
|
5626
|
+
const auth = requirePsycheScopedAccess(request.headers, ["psyche.write"], { route: "/api/v1/psyche/questionnaires/:id" });
|
|
5627
|
+
const { id } = request.params;
|
|
5628
|
+
const instrument = updateQuestionnaireInstrument(id, updateQuestionnaireInstrumentSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
5629
|
+
if (!instrument) {
|
|
5630
|
+
reply.code(404);
|
|
5631
|
+
return { error: "Questionnaire instrument not found" };
|
|
5632
|
+
}
|
|
5633
|
+
return { instrument };
|
|
5634
|
+
});
|
|
5635
|
+
app.delete("/api/v1/psyche/questionnaires/:id", async (request, reply) => {
|
|
5636
|
+
const auth = requirePsycheScopedAccess(request.headers, ["psyche.write"], { route: "/api/v1/psyche/questionnaires/:id" });
|
|
5637
|
+
const { id } = request.params;
|
|
5638
|
+
const instrument = deleteQuestionnaireInstrument(id, toActivityContext(auth));
|
|
5639
|
+
if (!instrument) {
|
|
5640
|
+
reply.code(404);
|
|
5641
|
+
return { error: "Questionnaire instrument not found" };
|
|
5642
|
+
}
|
|
5643
|
+
return { instrument };
|
|
5644
|
+
});
|
|
4358
5645
|
app.post("/api/v1/psyche/questionnaires/:id/clone", async (request, reply) => {
|
|
4359
5646
|
const auth = requirePsycheScopedAccess(request.headers, ["psyche.write"], { route: "/api/v1/psyche/questionnaires/:id/clone" });
|
|
4360
5647
|
const { id } = request.params;
|
|
@@ -4420,6 +5707,29 @@ export async function buildServer(options = {}) {
|
|
|
4420
5707
|
})
|
|
4421
5708
|
};
|
|
4422
5709
|
});
|
|
5710
|
+
app.get("/api/v1/psyche/self-observation/calendar/export", async (request, reply) => {
|
|
5711
|
+
requirePsycheScopedAccess(request.headers, ["psyche.read"], { route: "/api/v1/psyche/self-observation/calendar/export" });
|
|
5712
|
+
const query = psycheObservationCalendarExportQuerySchema.parse(request.query ?? {});
|
|
5713
|
+
const now = new Date();
|
|
5714
|
+
const from = query.from ??
|
|
5715
|
+
new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
5716
|
+
const to = query.to ??
|
|
5717
|
+
new Date(now.getTime() + 21 * 24 * 60 * 60 * 1000).toISOString();
|
|
5718
|
+
const exported = exportPsycheObservationCalendar({
|
|
5719
|
+
from,
|
|
5720
|
+
to,
|
|
5721
|
+
userIds: query.userIds,
|
|
5722
|
+
format: query.format,
|
|
5723
|
+
tags: query.tags,
|
|
5724
|
+
includeObservations: query.includeObservations,
|
|
5725
|
+
includeActivity: query.includeActivity,
|
|
5726
|
+
onlyHumanOwned: query.onlyHumanOwned,
|
|
5727
|
+
search: query.search
|
|
5728
|
+
});
|
|
5729
|
+
reply.header("Content-Disposition", `attachment; filename="${exported.fileName}"`);
|
|
5730
|
+
reply.type(exported.mimeType);
|
|
5731
|
+
return reply.send(exported.body);
|
|
5732
|
+
});
|
|
4423
5733
|
app.get("/api/v1/psyche/values", async (request) => {
|
|
4424
5734
|
requirePsycheScopedAccess(request.headers, ["psyche.read"], { route: "/api/v1/psyche/values" });
|
|
4425
5735
|
const userIds = resolveScopedUserIds(request.query);
|
|
@@ -5329,6 +6639,7 @@ export async function buildServer(options = {}) {
|
|
|
5329
6639
|
plannedDurationSeconds: null,
|
|
5330
6640
|
schedulingRules: null,
|
|
5331
6641
|
tagIds: readStringArrayField(suggestedFields, "tagIds"),
|
|
6642
|
+
actionCostBand: "standard",
|
|
5332
6643
|
notes: []
|
|
5333
6644
|
}, toActivityContext(auth));
|
|
5334
6645
|
return { entityType: "task", entityId: task.id };
|
|
@@ -5557,7 +6868,9 @@ export async function buildServer(options = {}) {
|
|
|
5557
6868
|
return job;
|
|
5558
6869
|
});
|
|
5559
6870
|
app.post("/api/v1/wiki/ingest-jobs/:id/rerun", async (request, reply) => {
|
|
5560
|
-
requireScopedAccess(request.headers, ["write"], {
|
|
6871
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
6872
|
+
route: "/api/v1/wiki/ingest-jobs/:id/rerun"
|
|
6873
|
+
});
|
|
5561
6874
|
const { id } = request.params;
|
|
5562
6875
|
try {
|
|
5563
6876
|
const result = await rerunWikiIngestJob(id, {
|
|
@@ -5584,7 +6897,9 @@ export async function buildServer(options = {}) {
|
|
|
5584
6897
|
}
|
|
5585
6898
|
});
|
|
5586
6899
|
app.post("/api/v1/wiki/ingest-jobs/:id/resume", async (request, reply) => {
|
|
5587
|
-
requireScopedAccess(request.headers, ["write"], {
|
|
6900
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
6901
|
+
route: "/api/v1/wiki/ingest-jobs/:id/resume"
|
|
6902
|
+
});
|
|
5588
6903
|
const { id } = request.params;
|
|
5589
6904
|
const job = getWikiIngestJob(id);
|
|
5590
6905
|
if (!job) {
|
|
@@ -5614,7 +6929,9 @@ export async function buildServer(options = {}) {
|
|
|
5614
6929
|
};
|
|
5615
6930
|
});
|
|
5616
6931
|
app.delete("/api/v1/wiki/ingest-jobs/:id", async (request, reply) => {
|
|
5617
|
-
requireScopedAccess(request.headers, ["write"], {
|
|
6932
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
6933
|
+
route: "/api/v1/wiki/ingest-jobs/:id"
|
|
6934
|
+
});
|
|
5618
6935
|
const { id } = request.params;
|
|
5619
6936
|
try {
|
|
5620
6937
|
const deleted = deleteWikiIngestJob(id);
|
|
@@ -5716,8 +7033,8 @@ export async function buildServer(options = {}) {
|
|
|
5716
7033
|
route: "/api/v1/calendar/oauth/google/start"
|
|
5717
7034
|
});
|
|
5718
7035
|
return await startGoogleCalendarOauth(startGoogleCalendarOauthSchema.parse(request.body ?? {}), {
|
|
5719
|
-
browserOrigin: typeof request.body
|
|
5720
|
-
"string"
|
|
7036
|
+
browserOrigin: typeof request.body
|
|
7037
|
+
?.browserOrigin === "string"
|
|
5721
7038
|
? request.body.browserOrigin
|
|
5722
7039
|
: null,
|
|
5723
7040
|
openerOrigin: typeof request.headers.origin === "string"
|
|
@@ -5995,6 +7312,9 @@ export async function buildServer(options = {}) {
|
|
|
5995
7312
|
workspace: startPreferenceGame(startPreferenceGameSchema.parse(request.body ?? {}))
|
|
5996
7313
|
};
|
|
5997
7314
|
});
|
|
7315
|
+
app.get("/api/v1/preferences/catalogs", async () => ({
|
|
7316
|
+
catalogs: listPreferenceCatalogs()
|
|
7317
|
+
}));
|
|
5998
7318
|
app.post("/api/v1/preferences/catalogs", async (request, reply) => {
|
|
5999
7319
|
requireScopedAccess(request.headers, ["write"], {
|
|
6000
7320
|
route: "/api/v1/preferences/catalogs"
|
|
@@ -6003,6 +7323,15 @@ export async function buildServer(options = {}) {
|
|
|
6003
7323
|
reply.code(201);
|
|
6004
7324
|
return { catalog };
|
|
6005
7325
|
});
|
|
7326
|
+
app.get("/api/v1/preferences/catalogs/:id", async (request, reply) => {
|
|
7327
|
+
const { id } = request.params;
|
|
7328
|
+
const catalog = getPreferenceCatalogById(id);
|
|
7329
|
+
if (!catalog) {
|
|
7330
|
+
reply.code(404);
|
|
7331
|
+
return { error: "Preferences catalog not found" };
|
|
7332
|
+
}
|
|
7333
|
+
return { catalog };
|
|
7334
|
+
});
|
|
6006
7335
|
app.patch("/api/v1/preferences/catalogs/:id", async (request) => {
|
|
6007
7336
|
requireScopedAccess(request.headers, ["write"], {
|
|
6008
7337
|
route: "/api/v1/preferences/catalogs/:id"
|
|
@@ -6019,6 +7348,9 @@ export async function buildServer(options = {}) {
|
|
|
6019
7348
|
const { id } = request.params;
|
|
6020
7349
|
return { catalog: deletePreferenceCatalog(id) };
|
|
6021
7350
|
});
|
|
7351
|
+
app.get("/api/v1/preferences/catalog-items", async () => ({
|
|
7352
|
+
items: listPreferenceCatalogItems()
|
|
7353
|
+
}));
|
|
6022
7354
|
app.post("/api/v1/preferences/catalog-items", async (request, reply) => {
|
|
6023
7355
|
requireScopedAccess(request.headers, ["write"], {
|
|
6024
7356
|
route: "/api/v1/preferences/catalog-items"
|
|
@@ -6027,6 +7359,15 @@ export async function buildServer(options = {}) {
|
|
|
6027
7359
|
reply.code(201);
|
|
6028
7360
|
return { item };
|
|
6029
7361
|
});
|
|
7362
|
+
app.get("/api/v1/preferences/catalog-items/:id", async (request, reply) => {
|
|
7363
|
+
const { id } = request.params;
|
|
7364
|
+
const item = getPreferenceCatalogItemById(id);
|
|
7365
|
+
if (!item) {
|
|
7366
|
+
reply.code(404);
|
|
7367
|
+
return { error: "Preferences catalog item not found" };
|
|
7368
|
+
}
|
|
7369
|
+
return { item };
|
|
7370
|
+
});
|
|
6030
7371
|
app.patch("/api/v1/preferences/catalog-items/:id", async (request) => {
|
|
6031
7372
|
requireScopedAccess(request.headers, ["write"], {
|
|
6032
7373
|
route: "/api/v1/preferences/catalog-items/:id"
|
|
@@ -6043,6 +7384,9 @@ export async function buildServer(options = {}) {
|
|
|
6043
7384
|
const { id } = request.params;
|
|
6044
7385
|
return { item: deletePreferenceCatalogItem(id) };
|
|
6045
7386
|
});
|
|
7387
|
+
app.get("/api/v1/preferences/contexts", async () => ({
|
|
7388
|
+
contexts: listPreferenceContexts()
|
|
7389
|
+
}));
|
|
6046
7390
|
app.post("/api/v1/preferences/contexts", async (request, reply) => {
|
|
6047
7391
|
requireScopedAccess(request.headers, ["write"], {
|
|
6048
7392
|
route: "/api/v1/preferences/contexts"
|
|
@@ -6051,6 +7395,15 @@ export async function buildServer(options = {}) {
|
|
|
6051
7395
|
reply.code(201);
|
|
6052
7396
|
return { context };
|
|
6053
7397
|
});
|
|
7398
|
+
app.get("/api/v1/preferences/contexts/:id", async (request, reply) => {
|
|
7399
|
+
const { id } = request.params;
|
|
7400
|
+
const context = getPreferenceContextById(id);
|
|
7401
|
+
if (!context) {
|
|
7402
|
+
reply.code(404);
|
|
7403
|
+
return { error: "Preferences context not found" };
|
|
7404
|
+
}
|
|
7405
|
+
return { context };
|
|
7406
|
+
});
|
|
6054
7407
|
app.patch("/api/v1/preferences/contexts/:id", async (request) => {
|
|
6055
7408
|
requireScopedAccess(request.headers, ["write"], {
|
|
6056
7409
|
route: "/api/v1/preferences/contexts/:id"
|
|
@@ -6060,6 +7413,13 @@ export async function buildServer(options = {}) {
|
|
|
6060
7413
|
context: updatePreferenceContext(id, updatePreferenceContextSchema.parse(request.body ?? {}))
|
|
6061
7414
|
};
|
|
6062
7415
|
});
|
|
7416
|
+
app.delete("/api/v1/preferences/contexts/:id", async (request) => {
|
|
7417
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7418
|
+
route: "/api/v1/preferences/contexts/:id"
|
|
7419
|
+
});
|
|
7420
|
+
const { id } = request.params;
|
|
7421
|
+
return { context: deletePreferenceContext(id) };
|
|
7422
|
+
});
|
|
6063
7423
|
app.post("/api/v1/preferences/contexts/merge", async (request) => {
|
|
6064
7424
|
requireScopedAccess(request.headers, ["write"], {
|
|
6065
7425
|
route: "/api/v1/preferences/contexts/merge"
|
|
@@ -6068,6 +7428,9 @@ export async function buildServer(options = {}) {
|
|
|
6068
7428
|
merge: mergePreferenceContexts(mergePreferenceContextsSchema.parse(request.body ?? {}))
|
|
6069
7429
|
};
|
|
6070
7430
|
});
|
|
7431
|
+
app.get("/api/v1/preferences/items", async () => ({
|
|
7432
|
+
items: listPreferenceItems()
|
|
7433
|
+
}));
|
|
6071
7434
|
app.post("/api/v1/preferences/items", async (request, reply) => {
|
|
6072
7435
|
requireScopedAccess(request.headers, ["write"], {
|
|
6073
7436
|
route: "/api/v1/preferences/items"
|
|
@@ -6076,6 +7439,15 @@ export async function buildServer(options = {}) {
|
|
|
6076
7439
|
reply.code(201);
|
|
6077
7440
|
return { item };
|
|
6078
7441
|
});
|
|
7442
|
+
app.get("/api/v1/preferences/items/:id", async (request, reply) => {
|
|
7443
|
+
const { id } = request.params;
|
|
7444
|
+
const item = getPreferenceItemById(id);
|
|
7445
|
+
if (!item) {
|
|
7446
|
+
reply.code(404);
|
|
7447
|
+
return { error: "Preferences item not found" };
|
|
7448
|
+
}
|
|
7449
|
+
return { item };
|
|
7450
|
+
});
|
|
6079
7451
|
app.patch("/api/v1/preferences/items/:id", async (request) => {
|
|
6080
7452
|
requireScopedAccess(request.headers, ["write"], {
|
|
6081
7453
|
route: "/api/v1/preferences/items/:id"
|
|
@@ -6085,6 +7457,13 @@ export async function buildServer(options = {}) {
|
|
|
6085
7457
|
item: updatePreferenceItem(id, updatePreferenceItemSchema.parse(request.body ?? {}))
|
|
6086
7458
|
};
|
|
6087
7459
|
});
|
|
7460
|
+
app.delete("/api/v1/preferences/items/:id", async (request) => {
|
|
7461
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7462
|
+
route: "/api/v1/preferences/items/:id"
|
|
7463
|
+
});
|
|
7464
|
+
const { id } = request.params;
|
|
7465
|
+
return { item: deletePreferenceItem(id) };
|
|
7466
|
+
});
|
|
6088
7467
|
app.post("/api/v1/preferences/items/from-entity", async (request, reply) => {
|
|
6089
7468
|
requireScopedAccess(request.headers, ["write"], {
|
|
6090
7469
|
route: "/api/v1/preferences/items/from-entity"
|
|
@@ -6400,6 +7779,59 @@ export async function buildServer(options = {}) {
|
|
|
6400
7779
|
requireScopedAccess(request.headers, ["read", "write"], { route: "/api/v1/settings/bin" });
|
|
6401
7780
|
return { bin: getSettingsBinPayload() };
|
|
6402
7781
|
});
|
|
7782
|
+
app.get("/api/v1/settings/data", async (request) => {
|
|
7783
|
+
requireScopedAccess(request.headers, ["read", "write"], { route: "/api/v1/settings/data" });
|
|
7784
|
+
return { data: await getDataManagementState() };
|
|
7785
|
+
});
|
|
7786
|
+
app.patch("/api/v1/settings/data", async (request) => {
|
|
7787
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7788
|
+
route: "/api/v1/settings/data"
|
|
7789
|
+
});
|
|
7790
|
+
return {
|
|
7791
|
+
settings: await updateDataManagementSettings(updateDataManagementSettingsSchema.parse(request.body ?? {})),
|
|
7792
|
+
data: await getDataManagementState()
|
|
7793
|
+
};
|
|
7794
|
+
});
|
|
7795
|
+
app.post("/api/v1/settings/data/scan", async (request) => {
|
|
7796
|
+
requireScopedAccess(request.headers, ["read", "write"], { route: "/api/v1/settings/data/scan" });
|
|
7797
|
+
return { candidates: await scanForDataRecoveryCandidates() };
|
|
7798
|
+
});
|
|
7799
|
+
app.post("/api/v1/settings/data/backups", async (request, reply) => {
|
|
7800
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7801
|
+
route: "/api/v1/settings/data/backups"
|
|
7802
|
+
});
|
|
7803
|
+
const backup = await createDataBackup(createDataBackupSchema.parse(request.body ?? {}));
|
|
7804
|
+
reply.code(201);
|
|
7805
|
+
return {
|
|
7806
|
+
backup,
|
|
7807
|
+
data: await getDataManagementState()
|
|
7808
|
+
};
|
|
7809
|
+
});
|
|
7810
|
+
app.post("/api/v1/settings/data/backups/:id/restore", async (request) => {
|
|
7811
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7812
|
+
route: "/api/v1/settings/data/backups/:id/restore"
|
|
7813
|
+
});
|
|
7814
|
+
const { id } = request.params;
|
|
7815
|
+
return {
|
|
7816
|
+
data: await restoreDataBackup(id, restoreDataBackupSchema.parse(request.body ?? {}), { secretsManager: managers.secrets })
|
|
7817
|
+
};
|
|
7818
|
+
});
|
|
7819
|
+
app.post("/api/v1/settings/data/switch-root", async (request) => {
|
|
7820
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
7821
|
+
route: "/api/v1/settings/data/switch-root"
|
|
7822
|
+
});
|
|
7823
|
+
return {
|
|
7824
|
+
data: await switchDataRoot(switchDataRootSchema.parse(request.body ?? {}), { secretsManager: managers.secrets })
|
|
7825
|
+
};
|
|
7826
|
+
});
|
|
7827
|
+
app.get("/api/v1/settings/data/export", async (request, reply) => {
|
|
7828
|
+
requireScopedAccess(request.headers, ["read", "write"], { route: "/api/v1/settings/data/export" });
|
|
7829
|
+
const query = dataExportQuerySchema.parse(request.query ?? {});
|
|
7830
|
+
const exported = await exportData(query.format);
|
|
7831
|
+
reply.header("Content-Disposition", `attachment; filename="${exported.fileName}"`);
|
|
7832
|
+
reply.type(exported.mimeType);
|
|
7833
|
+
return reply.send(exported.body);
|
|
7834
|
+
});
|
|
6403
7835
|
app.post("/api/v1/projects", async (request, reply) => {
|
|
6404
7836
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/projects" });
|
|
6405
7837
|
const project = createProject(createProjectSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
@@ -6488,6 +7920,15 @@ export async function buildServer(options = {}) {
|
|
|
6488
7920
|
userIds: resolveScopedUserIds(request.query)
|
|
6489
7921
|
})
|
|
6490
7922
|
}));
|
|
7923
|
+
app.get("/api/v1/calendar/work-block-templates/:id", async (request, reply) => {
|
|
7924
|
+
const { id } = request.params;
|
|
7925
|
+
const template = getWorkBlockTemplateById(id);
|
|
7926
|
+
if (!template) {
|
|
7927
|
+
reply.code(404);
|
|
7928
|
+
return { error: "Work block template not found" };
|
|
7929
|
+
}
|
|
7930
|
+
return { template };
|
|
7931
|
+
});
|
|
6491
7932
|
app.post("/api/v1/calendar/work-block-templates", async (request, reply) => {
|
|
6492
7933
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/calendar/work-block-templates" });
|
|
6493
7934
|
const template = createWorkBlockTemplate(createWorkBlockTemplateSchema.parse(request.body ?? {}));
|
|
@@ -6563,6 +8004,15 @@ export async function buildServer(options = {}) {
|
|
|
6563
8004
|
timeboxes: listTaskTimeboxes({ from, to, userIds: query.userIds })
|
|
6564
8005
|
};
|
|
6565
8006
|
});
|
|
8007
|
+
app.get("/api/v1/calendar/timeboxes/:id", async (request, reply) => {
|
|
8008
|
+
const { id } = request.params;
|
|
8009
|
+
const timebox = getTaskTimeboxById(id);
|
|
8010
|
+
if (!timebox) {
|
|
8011
|
+
reply.code(404);
|
|
8012
|
+
return { error: "Task timebox not found" };
|
|
8013
|
+
}
|
|
8014
|
+
return { timebox };
|
|
8015
|
+
});
|
|
6566
8016
|
app.post("/api/v1/calendar/timeboxes", async (request, reply) => {
|
|
6567
8017
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/calendar/timeboxes" });
|
|
6568
8018
|
const timebox = createTaskTimebox(createTaskTimeboxSchema.parse(request.body ?? {}));
|
|
@@ -6637,6 +8087,17 @@ export async function buildServer(options = {}) {
|
|
|
6637
8087
|
})
|
|
6638
8088
|
};
|
|
6639
8089
|
});
|
|
8090
|
+
app.get("/api/v1/calendar/events", async (request) => {
|
|
8091
|
+
const query = calendarOverviewQuerySchema.parse(request.query ?? {});
|
|
8092
|
+
const now = new Date();
|
|
8093
|
+
const from = query.from ??
|
|
8094
|
+
new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
8095
|
+
const to = query.to ??
|
|
8096
|
+
new Date(now.getTime() + 21 * 24 * 60 * 60 * 1000).toISOString();
|
|
8097
|
+
return {
|
|
8098
|
+
events: listCalendarEvents({ from, to, userIds: query.userIds })
|
|
8099
|
+
};
|
|
8100
|
+
});
|
|
6640
8101
|
app.post("/api/v1/calendar/events", async (request, reply) => {
|
|
6641
8102
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/calendar/events" });
|
|
6642
8103
|
const event = createCalendarEvent(createCalendarEventSchema.parse(request.body ?? {}));
|
|
@@ -6658,6 +8119,15 @@ export async function buildServer(options = {}) {
|
|
|
6658
8119
|
reply.code(201);
|
|
6659
8120
|
return { event: refreshed };
|
|
6660
8121
|
});
|
|
8122
|
+
app.get("/api/v1/calendar/events/:id", async (request, reply) => {
|
|
8123
|
+
const { id } = request.params;
|
|
8124
|
+
const event = getCalendarEventById(id);
|
|
8125
|
+
if (!event) {
|
|
8126
|
+
reply.code(404);
|
|
8127
|
+
return { error: "Calendar event not found" };
|
|
8128
|
+
}
|
|
8129
|
+
return { event };
|
|
8130
|
+
});
|
|
6661
8131
|
app.patch("/api/v1/calendar/events/:id", async (request, reply) => {
|
|
6662
8132
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/calendar/events/:id" });
|
|
6663
8133
|
const { id } = request.params;
|
|
@@ -6829,6 +8299,7 @@ export async function buildServer(options = {}) {
|
|
|
6829
8299
|
}
|
|
6830
8300
|
}, { secrets: managers.secrets });
|
|
6831
8301
|
}
|
|
8302
|
+
mirrorSettingsFileFromCurrentState();
|
|
6832
8303
|
reply.code(201);
|
|
6833
8304
|
return { connection };
|
|
6834
8305
|
});
|
|
@@ -6839,6 +8310,7 @@ export async function buildServer(options = {}) {
|
|
|
6839
8310
|
reply.code(404);
|
|
6840
8311
|
return { error: "AI model connection not found" };
|
|
6841
8312
|
}
|
|
8313
|
+
mirrorSettingsFileFromCurrentState();
|
|
6842
8314
|
return { deletedId };
|
|
6843
8315
|
});
|
|
6844
8316
|
app.post("/api/v1/settings/models/connections/test", async (request, reply) => {
|
|
@@ -6869,7 +8341,9 @@ export async function buildServer(options = {}) {
|
|
|
6869
8341
|
recordDiagnosticLog({
|
|
6870
8342
|
level,
|
|
6871
8343
|
source: normalizeDiagnosticSource(request.headers["x-forge-source"]),
|
|
6872
|
-
scope: typeof details.scope === "string"
|
|
8344
|
+
scope: typeof details.scope === "string"
|
|
8345
|
+
? details.scope
|
|
8346
|
+
: "model_settings",
|
|
6873
8347
|
eventKey: typeof details.eventKey === "string"
|
|
6874
8348
|
? details.eventKey
|
|
6875
8349
|
: "model_connection_test",
|
|
@@ -6905,7 +8379,9 @@ export async function buildServer(options = {}) {
|
|
|
6905
8379
|
}
|
|
6906
8380
|
});
|
|
6907
8381
|
app.post("/api/v1/settings/models/oauth/openai-codex/session/:id/manual", async (request) => {
|
|
6908
|
-
requireScopedAccess(request.headers, ["write"], {
|
|
8382
|
+
requireScopedAccess(request.headers, ["write"], {
|
|
8383
|
+
route: "/api/v1/settings/models/oauth/openai-codex/session/:id/manual"
|
|
8384
|
+
});
|
|
6909
8385
|
return {
|
|
6910
8386
|
session: submitOpenAiCodexOauthManualInput(request.params.id, submitOpenAiCodexOauthManualCodeSchema.parse(request.body ?? {})
|
|
6911
8387
|
.codeOrUrl)
|
|
@@ -7175,6 +8651,87 @@ export async function buildServer(options = {}) {
|
|
|
7175
8651
|
runs: listAiConnectorRuns(connector.id)
|
|
7176
8652
|
};
|
|
7177
8653
|
});
|
|
8654
|
+
app.get(`${basePath}/:id/runs/:runId`, async (request, reply) => {
|
|
8655
|
+
requireScopedAccess(request.headers, ["read"], {
|
|
8656
|
+
route: `${basePath}/:id/runs/:runId`
|
|
8657
|
+
});
|
|
8658
|
+
const params = request.params;
|
|
8659
|
+
const connector = getAiConnectorById(params.id);
|
|
8660
|
+
if (!connector) {
|
|
8661
|
+
reply.code(404);
|
|
8662
|
+
return { error: `${noun} not found` };
|
|
8663
|
+
}
|
|
8664
|
+
const run = getAiConnectorRunById(connector.id, params.runId);
|
|
8665
|
+
if (!run) {
|
|
8666
|
+
reply.code(404);
|
|
8667
|
+
return { error: `${noun} run not found` };
|
|
8668
|
+
}
|
|
8669
|
+
return {
|
|
8670
|
+
[singularKey]: connector,
|
|
8671
|
+
run
|
|
8672
|
+
};
|
|
8673
|
+
});
|
|
8674
|
+
app.get(`${basePath}/:id/runs/:runId/nodes`, async (request, reply) => {
|
|
8675
|
+
requireScopedAccess(request.headers, ["read"], {
|
|
8676
|
+
route: `${basePath}/:id/runs/:runId/nodes`
|
|
8677
|
+
});
|
|
8678
|
+
const params = request.params;
|
|
8679
|
+
const connector = getAiConnectorById(params.id);
|
|
8680
|
+
if (!connector) {
|
|
8681
|
+
reply.code(404);
|
|
8682
|
+
return { error: `${noun} not found` };
|
|
8683
|
+
}
|
|
8684
|
+
const nodeResults = getAiConnectorRunNodeResults(connector.id, params.runId);
|
|
8685
|
+
if (!nodeResults) {
|
|
8686
|
+
reply.code(404);
|
|
8687
|
+
return { error: `${noun} run not found` };
|
|
8688
|
+
}
|
|
8689
|
+
return {
|
|
8690
|
+
[singularKey]: connector,
|
|
8691
|
+
nodeResults
|
|
8692
|
+
};
|
|
8693
|
+
});
|
|
8694
|
+
app.get(`${basePath}/:id/runs/:runId/nodes/:nodeId`, async (request, reply) => {
|
|
8695
|
+
requireScopedAccess(request.headers, ["read"], {
|
|
8696
|
+
route: `${basePath}/:id/runs/:runId/nodes/:nodeId`
|
|
8697
|
+
});
|
|
8698
|
+
const params = request.params;
|
|
8699
|
+
const connector = getAiConnectorById(params.id);
|
|
8700
|
+
if (!connector) {
|
|
8701
|
+
reply.code(404);
|
|
8702
|
+
return { error: `${noun} not found` };
|
|
8703
|
+
}
|
|
8704
|
+
const nodeResult = getAiConnectorRunNodeResult(connector.id, params.runId, params.nodeId);
|
|
8705
|
+
if (!nodeResult) {
|
|
8706
|
+
reply.code(404);
|
|
8707
|
+
return { error: `${noun} node result not found` };
|
|
8708
|
+
}
|
|
8709
|
+
return {
|
|
8710
|
+
[singularKey]: connector,
|
|
8711
|
+
nodeResult
|
|
8712
|
+
};
|
|
8713
|
+
});
|
|
8714
|
+
app.get(`${basePath}/:id/nodes/:nodeId/output`, async (request, reply) => {
|
|
8715
|
+
requireScopedAccess(request.headers, ["read"], {
|
|
8716
|
+
route: `${basePath}/:id/nodes/:nodeId/output`
|
|
8717
|
+
});
|
|
8718
|
+
const params = request.params;
|
|
8719
|
+
const connector = getAiConnectorById(params.id);
|
|
8720
|
+
if (!connector) {
|
|
8721
|
+
reply.code(404);
|
|
8722
|
+
return { error: `${noun} not found` };
|
|
8723
|
+
}
|
|
8724
|
+
const latest = getLatestAiConnectorNodeOutput(connector.id, params.nodeId);
|
|
8725
|
+
if (!latest) {
|
|
8726
|
+
reply.code(404);
|
|
8727
|
+
return { error: `${noun} node output not found` };
|
|
8728
|
+
}
|
|
8729
|
+
return {
|
|
8730
|
+
[singularKey]: connector,
|
|
8731
|
+
run: latest.run,
|
|
8732
|
+
nodeResult: latest.nodeResult
|
|
8733
|
+
};
|
|
8734
|
+
});
|
|
7178
8735
|
};
|
|
7179
8736
|
registerFlowApiRoutes("/api/v1/workbench/flows", "Workbench flow", {
|
|
7180
8737
|
collectionKey: "flows",
|
|
@@ -7577,6 +9134,16 @@ export async function buildServer(options = {}) {
|
|
|
7577
9134
|
}
|
|
7578
9135
|
return { task };
|
|
7579
9136
|
});
|
|
9137
|
+
app.post("/api/v1/tasks/:id/split", async (request, reply) => {
|
|
9138
|
+
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/tasks/:id/split" });
|
|
9139
|
+
const { id } = request.params;
|
|
9140
|
+
const result = splitTask(id, taskSplitCreateSchema.parse(request.body ?? {}), toActivityContext(auth));
|
|
9141
|
+
if (!result) {
|
|
9142
|
+
reply.code(404);
|
|
9143
|
+
return { error: "Task not found" };
|
|
9144
|
+
}
|
|
9145
|
+
return result;
|
|
9146
|
+
});
|
|
7580
9147
|
app.delete("/api/v1/tasks/:id", async (request, reply) => {
|
|
7581
9148
|
const auth = requireScopedAccess(request.headers, ["write"], { route: "/api/v1/tasks/:id" });
|
|
7582
9149
|
const { id } = request.params;
|