feat(work): add task-scoped attachment intake and durable file delivery

This commit is contained in:
ex_tianzy
2026-11-10 14:19:50 +08:00
parent ce64167627
commit 79c15ee7ce
16 changed files with 680 additions and 12 deletions
+8 -2
View File
@@ -196,7 +196,7 @@ def validate_overlay(base, merged, candidate, router_key_required=True):
env = new[name]["environment"]
for key, value in old[name].get("environment", {}).items():
if key not in {"HN_CREDENTIAL_MODE","HN_ROUTER_ADMISSION_SECRET","HN_CREDENTIAL_KEYRING_FILE",
"HN_CREDENTIAL_PERMISSION_PROFILES","HN_CONNECTOR_INTERNAL_URL","HN_FEISHU_APP_ID","HN_OAUTH_ENABLED"}:
"HN_CREDENTIAL_PERMISSION_PROFILES","HN_CONNECTOR_INTERNAL_URL","HN_FEISHU_APP_ID","HN_OAUTH_ENABLED","HN_WORK_FILES_ENABLED"}:
if env.get(key) != value:
raise DeployError("existing environment changed: "+key)
old_volumes = {v["target"]:v for v in old[name].get("volumes", [])}
@@ -373,6 +373,8 @@ def prepare_update(args):
raise DeployError('update output must be a new absolute directory outside the live deployment')
if not (source/'relay/connector.py').is_file():
raise DeployError('missing update source')
if getattr(args,'enable_work_files',False)and not (source/'relay/work_files.py').is_file():
raise DeployError('work files implementation missing from update source')
output=output.resolve()
output.mkdir(mode=0o700)
os.chmod(output,0o700)
@@ -389,8 +391,11 @@ def prepare_update(args):
for mount in overlay['services']['connector']['volumes']:
if mount['target']=='/run/hainuo-credentials/keyring.json':
mount['source']=str(output/'credential-keyring.json')
write_json(output/'compose.broker.json',overlay)
rollback=json.loads(json.dumps(overlay))
if getattr(args,'enable_work_files',False):
overlay['services']['connector']['environment']['HN_WORK_FILES_ENABLED']='true'
plan['work_files_enabled']=True
write_json(output/'compose.broker.json',overlay)
for name in ('connector','router'):
rollback['services'][name]['image']=roles[name]['image']
# An update rollback must retain broker env/key mounts, never silently
@@ -708,6 +713,7 @@ def main():
update.add_argument("--plan",required=True)
update.add_argument("--source-root",default=str(Path(__file__).resolve().parents[1]))
update.add_argument("--output",required=True)
update.add_argument('--enable-work-files',action='store_true',help='Opt in after paired-client preparation; rollback retains the previous flag.')
permissions=sub.add_parser('update-permissions')
permissions.add_argument('--plan',required=True)
permissions.add_argument('--profiles',required=True)